@Test(expected = IllegalArgumentException.class) public void testEmptyPut() { byte[] row = dataHelper.randomData("rk-"); Put emptyPut = new Put(row); adapt(emptyPut); }
@Override public void adapt( Put operation, com.google.cloud.bigtable.data.v2.models.MutationApi<?> mutation) { if (operation.isEmpty()) { throw new IllegalArgumentException("No columns to insert"); } long currentTimestampMicros = setClientTimestamp ? clock.currentTimeMillis() * 1000 : -1; final int rowLength = operation.getRow().length; for (Entry<byte[], List<Cell>> entry : operation.getFamilyCellMap().entrySet()) { ByteString familyString = ByteString.copyFrom(entry.getKey()); int familySize = familyString.size(); for (Cell cell : entry.getValue()) { int qualifierLength = cell.getQualifierLength(); int valueLength = cell.getValueLength(); int keyValueSize = (20 + rowLength + familySize + qualifierLength + valueLength); if (maxKeyValueSize > 0 && keyValueSize > maxKeyValueSize) { throw new IllegalArgumentException("KeyValue size too large"); } ByteString cellQualifierByteString = ByteString.copyFrom( cell.getQualifierArray(), cell.getQualifierOffset(), qualifierLength); ByteString value = ByteString.copyFrom(cell.getValueArray(), cell.getValueOffset(), valueLength); long timestampMicros = currentTimestampMicros; if (cell.getTimestamp() != HConstants.LATEST_TIMESTAMP) { timestampMicros = TimestampConverter.hbase2bigtable(cell.getTimestamp()); } mutation.setCell( familyString.toStringUtf8(), cellQualifierByteString, timestampMicros, value); } } }
PutAdapter extends MutationAdapter<Put> { @Override public void adapt( Put operation, com.google.cloud.bigtable.data.v2.models.MutationApi<?> mutation) { if (operation.isEmpty()) { throw new IllegalArgumentException("No columns to insert"); } long currentTimestampMicros = setClientTimestamp ? clock.currentTimeMillis() * 1000 : -1; final int rowLength = operation.getRow().length; for (Entry<byte[], List<Cell>> entry : operation.getFamilyCellMap().entrySet()) { ByteString familyString = ByteString.copyFrom(entry.getKey()); int familySize = familyString.size(); for (Cell cell : entry.getValue()) { int qualifierLength = cell.getQualifierLength(); int valueLength = cell.getValueLength(); int keyValueSize = (20 + rowLength + familySize + qualifierLength + valueLength); if (maxKeyValueSize > 0 && keyValueSize > maxKeyValueSize) { throw new IllegalArgumentException("KeyValue size too large"); } ByteString cellQualifierByteString = ByteString.copyFrom( cell.getQualifierArray(), cell.getQualifierOffset(), qualifierLength); ByteString value = ByteString.copyFrom(cell.getValueArray(), cell.getValueOffset(), valueLength); long timestampMicros = currentTimestampMicros; if (cell.getTimestamp() != HConstants.LATEST_TIMESTAMP) { timestampMicros = TimestampConverter.hbase2bigtable(cell.getTimestamp()); } mutation.setCell( familyString.toStringUtf8(), cellQualifierByteString, timestampMicros, value); } } } }
PutAdapter extends MutationAdapter<Put> { @Override public void adapt( Put operation, com.google.cloud.bigtable.data.v2.models.MutationApi<?> mutation) { if (operation.isEmpty()) { throw new IllegalArgumentException("No columns to insert"); } long currentTimestampMicros = setClientTimestamp ? clock.currentTimeMillis() * 1000 : -1; final int rowLength = operation.getRow().length; for (Entry<byte[], List<Cell>> entry : operation.getFamilyCellMap().entrySet()) { ByteString familyString = ByteString.copyFrom(entry.getKey()); int familySize = familyString.size(); for (Cell cell : entry.getValue()) { int qualifierLength = cell.getQualifierLength(); int valueLength = cell.getValueLength(); int keyValueSize = (20 + rowLength + familySize + qualifierLength + valueLength); if (maxKeyValueSize > 0 && keyValueSize > maxKeyValueSize) { throw new IllegalArgumentException("KeyValue size too large"); } ByteString cellQualifierByteString = ByteString.copyFrom( cell.getQualifierArray(), cell.getQualifierOffset(), qualifierLength); ByteString value = ByteString.copyFrom(cell.getValueArray(), cell.getValueOffset(), valueLength); long timestampMicros = currentTimestampMicros; if (cell.getTimestamp() != HConstants.LATEST_TIMESTAMP) { timestampMicros = TimestampConverter.hbase2bigtable(cell.getTimestamp()); } mutation.setCell( familyString.toStringUtf8(), cellQualifierByteString, timestampMicros, value); } } } PutAdapter(int maxKeyValueSize);  PutAdapter(int maxKeyValueSize, boolean setClientTimestamp); }
PutAdapter extends MutationAdapter<Put> { @Override public void adapt( Put operation, com.google.cloud.bigtable.data.v2.models.MutationApi<?> mutation) { if (operation.isEmpty()) { throw new IllegalArgumentException("No columns to insert"); } long currentTimestampMicros = setClientTimestamp ? clock.currentTimeMillis() * 1000 : -1; final int rowLength = operation.getRow().length; for (Entry<byte[], List<Cell>> entry : operation.getFamilyCellMap().entrySet()) { ByteString familyString = ByteString.copyFrom(entry.getKey()); int familySize = familyString.size(); for (Cell cell : entry.getValue()) { int qualifierLength = cell.getQualifierLength(); int valueLength = cell.getValueLength(); int keyValueSize = (20 + rowLength + familySize + qualifierLength + valueLength); if (maxKeyValueSize > 0 && keyValueSize > maxKeyValueSize) { throw new IllegalArgumentException("KeyValue size too large"); } ByteString cellQualifierByteString = ByteString.copyFrom( cell.getQualifierArray(), cell.getQualifierOffset(), qualifierLength); ByteString value = ByteString.copyFrom(cell.getValueArray(), cell.getValueOffset(), valueLength); long timestampMicros = currentTimestampMicros; if (cell.getTimestamp() != HConstants.LATEST_TIMESTAMP) { timestampMicros = TimestampConverter.hbase2bigtable(cell.getTimestamp()); } mutation.setCell( familyString.toStringUtf8(), cellQualifierByteString, timestampMicros, value); } } } PutAdapter(int maxKeyValueSize);  PutAdapter(int maxKeyValueSize, boolean setClientTimestamp); @Override void adapt(
      Put operation, com.google.cloud.bigtable.data.v2.models.MutationApi<?> mutation); }
PutAdapter extends MutationAdapter<Put> { @Override public void adapt( Put operation, com.google.cloud.bigtable.data.v2.models.MutationApi<?> mutation) { if (operation.isEmpty()) { throw new IllegalArgumentException("No columns to insert"); } long currentTimestampMicros = setClientTimestamp ? clock.currentTimeMillis() * 1000 : -1; final int rowLength = operation.getRow().length; for (Entry<byte[], List<Cell>> entry : operation.getFamilyCellMap().entrySet()) { ByteString familyString = ByteString.copyFrom(entry.getKey()); int familySize = familyString.size(); for (Cell cell : entry.getValue()) { int qualifierLength = cell.getQualifierLength(); int valueLength = cell.getValueLength(); int keyValueSize = (20 + rowLength + familySize + qualifierLength + valueLength); if (maxKeyValueSize > 0 && keyValueSize > maxKeyValueSize) { throw new IllegalArgumentException("KeyValue size too large"); } ByteString cellQualifierByteString = ByteString.copyFrom( cell.getQualifierArray(), cell.getQualifierOffset(), qualifierLength); ByteString value = ByteString.copyFrom(cell.getValueArray(), cell.getValueOffset(), valueLength); long timestampMicros = currentTimestampMicros; if (cell.getTimestamp() != HConstants.LATEST_TIMESTAMP) { timestampMicros = TimestampConverter.hbase2bigtable(cell.getTimestamp()); } mutation.setCell( familyString.toStringUtf8(), cellQualifierByteString, timestampMicros, value); } } } PutAdapter(int maxKeyValueSize);  PutAdapter(int maxKeyValueSize, boolean setClientTimestamp); @Override void adapt(
      Put operation, com.google.cloud.bigtable.data.v2.models.MutationApi<?> mutation);  }