@Test public void adaptResponse_emptyRow() { FlatRow row = FlatRow.newBuilder().withRowKey(ByteString.copyFromUtf8("key")).build(); Result result = instance.adaptResponse(row); assertEquals(0, result.rawCells().length); assertNull(transformToFlatRow(result)); }
@Override public Result adaptResponse(FlatRow flatRow) { if (flatRow == null || flatRow.getRowKey() == null) { return Result.EMPTY_RESULT; } byte[] RowKey = flatRow.getRowKey().toByteArray(); List<FlatRow.Cell> cells = flatRow.getCells(); List<Cell> hbaseCells = new ArrayList<>(cells.size()); byte[] previousFamilyBytes = null; String previousFamily = null; for (FlatRow.Cell cell : cells) { String family = cell.getFamily(); byte[] familyBytes = !Objects.equal(family, previousFamily) ? Bytes.toBytes(family) : previousFamilyBytes; hbaseCells.add(toRowCell(RowKey, cell, familyBytes)); previousFamily = family; previousFamilyBytes = familyBytes; } return Result.create(hbaseCells); }
FlatRowAdapter implements ResponseAdapter<FlatRow, Result> { @Override public Result adaptResponse(FlatRow flatRow) { if (flatRow == null || flatRow.getRowKey() == null) { return Result.EMPTY_RESULT; } byte[] RowKey = flatRow.getRowKey().toByteArray(); List<FlatRow.Cell> cells = flatRow.getCells(); List<Cell> hbaseCells = new ArrayList<>(cells.size()); byte[] previousFamilyBytes = null; String previousFamily = null; for (FlatRow.Cell cell : cells) { String family = cell.getFamily(); byte[] familyBytes = !Objects.equal(family, previousFamily) ? Bytes.toBytes(family) : previousFamilyBytes; hbaseCells.add(toRowCell(RowKey, cell, familyBytes)); previousFamily = family; previousFamilyBytes = familyBytes; } return Result.create(hbaseCells); } }
FlatRowAdapter implements ResponseAdapter<FlatRow, Result> { @Override public Result adaptResponse(FlatRow flatRow) { if (flatRow == null || flatRow.getRowKey() == null) { return Result.EMPTY_RESULT; } byte[] RowKey = flatRow.getRowKey().toByteArray(); List<FlatRow.Cell> cells = flatRow.getCells(); List<Cell> hbaseCells = new ArrayList<>(cells.size()); byte[] previousFamilyBytes = null; String previousFamily = null; for (FlatRow.Cell cell : cells) { String family = cell.getFamily(); byte[] familyBytes = !Objects.equal(family, previousFamily) ? Bytes.toBytes(family) : previousFamilyBytes; hbaseCells.add(toRowCell(RowKey, cell, familyBytes)); previousFamily = family; previousFamilyBytes = familyBytes; } return Result.create(hbaseCells); }  }
FlatRowAdapter implements ResponseAdapter<FlatRow, Result> { @Override public Result adaptResponse(FlatRow flatRow) { if (flatRow == null || flatRow.getRowKey() == null) { return Result.EMPTY_RESULT; } byte[] RowKey = flatRow.getRowKey().toByteArray(); List<FlatRow.Cell> cells = flatRow.getCells(); List<Cell> hbaseCells = new ArrayList<>(cells.size()); byte[] previousFamilyBytes = null; String previousFamily = null; for (FlatRow.Cell cell : cells) { String family = cell.getFamily(); byte[] familyBytes = !Objects.equal(family, previousFamily) ? Bytes.toBytes(family) : previousFamilyBytes; hbaseCells.add(toRowCell(RowKey, cell, familyBytes)); previousFamily = family; previousFamilyBytes = familyBytes; } return Result.create(hbaseCells); }  @Override Result adaptResponse(FlatRow flatRow); }
FlatRowAdapter implements ResponseAdapter<FlatRow, Result> { @Override public Result adaptResponse(FlatRow flatRow) { if (flatRow == null || flatRow.getRowKey() == null) { return Result.EMPTY_RESULT; } byte[] RowKey = flatRow.getRowKey().toByteArray(); List<FlatRow.Cell> cells = flatRow.getCells(); List<Cell> hbaseCells = new ArrayList<>(cells.size()); byte[] previousFamilyBytes = null; String previousFamily = null; for (FlatRow.Cell cell : cells) { String family = cell.getFamily(); byte[] familyBytes = !Objects.equal(family, previousFamily) ? Bytes.toBytes(family) : previousFamilyBytes; hbaseCells.add(toRowCell(RowKey, cell, familyBytes)); previousFamily = family; previousFamilyBytes = familyBytes; } return Result.create(hbaseCells); }  @Override Result adaptResponse(FlatRow flatRow);  }