@Test public void responseCorrectlyTransformed() throws Exception { ApiFuture<List<KeyOffset>> result = callable.futureCall("my-table"); inner.response.set( ImmutableList.of( SampleRowKeysResponse.newBuilder() .setRowKey(ByteString.copyFromUtf8("key1")) .setOffsetBytes(100) .build(), SampleRowKeysResponse.newBuilder() .setRowKey(ByteString.copyFromUtf8("")) .setOffsetBytes(1000) .build())); assertThat(result.get(1, TimeUnit.SECONDS)) .isEqualTo( ImmutableList.of( KeyOffset.create(ByteString.copyFromUtf8("key1"), 100), KeyOffset.create(ByteString.EMPTY, 1000))); }
@java.lang.Override public Builder mergeFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { com.google.bigtable.v2.SampleRowKeysResponse parsedMessage = null; try { parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); } catch (com.google.protobuf.InvalidProtocolBufferException e) { parsedMessage = (com.google.bigtable.v2.SampleRowKeysResponse) e.getUnfinishedMessage(); throw e.unwrapIOException(); } finally { if (parsedMessage != null) { mergeFrom(parsedMessage); } } return this; }
/** * * * <pre> * Sorted streamed sequence of sample row keys in the table. The table might * have contents before the first row key in the list and after the last one, * but a key containing the empty string indicates "end of table" and will be * the last response given, if present. * Note that row keys in this list may not have ever been written to or read * from, and users should therefore not make any assumptions about the row key * structure that are specific to their use case. * </pre> * * <code>bytes row_key = 1;</code> */ public Builder setRowKey(com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } rowKey_ = value; onChanged(); return this; } /**
/** Sets up the sample row keys for the specified table. */ void setupSampleRowKeys(String tableId, int numSamples, long bytesPerRow) { verifyTableExists(tableId); checkArgument(numSamples > 0, "Number of samples must be positive: %s", numSamples); checkArgument(bytesPerRow > 0, "Bytes/Row must be positive: %s", bytesPerRow); ImmutableList.Builder<SampleRowKeysResponse> ret = ImmutableList.builder(); SortedMap<ByteString, ByteString> rows = getTable(tableId); int currentSample = 1; int rowsSoFar = 0; for (Map.Entry<ByteString, ByteString> entry : rows.entrySet()) { if (((double) rowsSoFar) / rows.size() >= ((double) currentSample) / numSamples) { // add the sample with the total number of bytes in the table before this key. ret.add( SampleRowKeysResponse.newBuilder() .setRowKey(entry.getKey()) .setOffsetBytes(rowsSoFar * bytesPerRow) .build()); // Move on to next sample currentSample++; } ++rowsSoFar; } // Add the last sample indicating the end of the table, with all rows before it. ret.add(SampleRowKeysResponse.newBuilder().setOffsetBytes(rows.size() * bytesPerRow).build()); sampleRowKeys.put(tableId, ret.build()); } }
/** * * * <pre> * Sorted streamed sequence of sample row keys in the table. The table might * have contents before the first row key in the list and after the last one, * but a key containing the empty string indicates "end of table" and will be * the last response given, if present. * Note that row keys in this list may not have ever been written to or read * from, and users should therefore not make any assumptions about the row key * structure that are specific to their use case. * </pre> * * <code>bytes row_key = 1;</code> */ public Builder setRowKey(com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } rowKey_ = value; onChanged(); return this; } /**
/** * <pre> * Sorted streamed sequence of sample row keys in the table. The table might * have contents before the first row key in the list and after the last one, * but a key containing the empty string indicates "end of table" and will be * the last response given, if present. * Note that row keys in this list may not have ever been written to or read * from, and users should therefore not make any assumptions about the row key * structure that are specific to their use case. * </pre> * * <code>bytes row_key = 1;</code> */ public Builder setRowKey(com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } rowKey_ = value; onChanged(); return this; } /**
/** * * * <pre> * Sorted streamed sequence of sample row keys in the table. The table might * have contents before the first row key in the list and after the last one, * but a key containing the empty string indicates "end of table" and will be * the last response given, if present. * Note that row keys in this list may not have ever been written to or read * from, and users should therefore not make any assumptions about the row key * structure that are specific to their use case. * </pre> * * <code>bytes row_key = 1;</code> */ public Builder clearRowKey() { rowKey_ = getDefaultInstance().getRowKey(); onChanged(); return this; }
@java.lang.Override public Builder mergeFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { com.google.bigtable.v2.SampleRowKeysResponse parsedMessage = null; try { parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); } catch (com.google.protobuf.InvalidProtocolBufferException e) { parsedMessage = (com.google.bigtable.v2.SampleRowKeysResponse) e.getUnfinishedMessage(); throw e.unwrapIOException(); } finally { if (parsedMessage != null) { mergeFrom(parsedMessage); } } return this; }
/** * * * <pre> * Approximate total storage space used by all rows in the table which precede * `row_key`. Buffering the contents of all rows between two subsequent * samples would require space roughly equal to the difference in their * `offset_bytes` fields. * </pre> * * <code>int64 offset_bytes = 2;</code> */ public Builder setOffsetBytes(long value) { offsetBytes_ = value; onChanged(); return this; } /**
/** * * * <pre> * Approximate total storage space used by all rows in the table which precede * `row_key`. Buffering the contents of all rows between two subsequent * samples would require space roughly equal to the difference in their * `offset_bytes` fields. * </pre> * * <code>int64 offset_bytes = 2;</code> */ public Builder clearOffsetBytes() { offsetBytes_ = 0L; onChanged(); return this; }
/** * <pre> * Approximate total storage space used by all rows in the table which precede * `row_key`. Buffering the contents of all rows between two subsequent * samples would require space roughly equal to the difference in their * `offset_bytes` fields. * </pre> * * <code>int64 offset_bytes = 2;</code> */ public Builder clearOffsetBytes() { offsetBytes_ = 0L; onChanged(); return this; } public final Builder setUnknownFields(
public Builder mergeFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { com.google.bigtable.v2.SampleRowKeysResponse parsedMessage = null; try { parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); } catch (com.google.protobuf.InvalidProtocolBufferException e) { parsedMessage = (com.google.bigtable.v2.SampleRowKeysResponse) e.getUnfinishedMessage(); throw e.unwrapIOException(); } finally { if (parsedMessage != null) { mergeFrom(parsedMessage); } } return this; }
/** * <pre> * Sorted streamed sequence of sample row keys in the table. The table might * have contents before the first row key in the list and after the last one, * but a key containing the empty string indicates "end of table" and will be * the last response given, if present. * Note that row keys in this list may not have ever been written to or read * from, and users should therefore not make any assumptions about the row key * structure that are specific to their use case. * </pre> * * <code>bytes row_key = 1;</code> */ public Builder clearRowKey() { rowKey_ = getDefaultInstance().getRowKey(); onChanged(); return this; }
/** * <pre> * Approximate total storage space used by all rows in the table which precede * `row_key`. Buffering the contents of all rows between two subsequent * samples would require space roughly equal to the difference in their * `offset_bytes` fields. * </pre> * * <code>int64 offset_bytes = 2;</code> */ public Builder setOffsetBytes(long value) { offsetBytes_ = value; onChanged(); return this; } /**
private Builder() { maybeForceBuilderInitialization(); }
private Builder() { maybeForceBuilderInitialization(); }
public static Builder newBuilder(com.google.bigtable.v2.SampleRowKeysResponse prototype) { return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); } public Builder toBuilder() {
public static Builder newBuilder(com.google.bigtable.v2.SampleRowKeysResponse prototype) { return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); }
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { super(parent); maybeForceBuilderInitialization(); }