本文整理汇总了Java中com.google.protobuf.ByteString.EMPTY属性的典型用法代码示例。如果您正苦于以下问题:Java ByteString.EMPTY属性的具体用法?Java ByteString.EMPTY怎么用?Java ByteString.EMPTY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.google.protobuf.ByteString
的用法示例。
在下文中一共展示了ByteString.EMPTY属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AssistantClient
public AssistantClient(OAuthCredentials oAuthCredentials, AssistantConf assistantConf, DeviceModel deviceModel,
Device device) {
this.assistantConf = assistantConf;
this.deviceModel = deviceModel;
this.device = device;
this.currentConversationState = ByteString.EMPTY;
// Create a channel to the test service.
ManagedChannel channel = ManagedChannelBuilder.forAddress(assistantConf.getAssistantApiEndpoint(), 443)
.build();
// Create a stub with credential
embeddedAssistantStub = EmbeddedAssistantGrpc.newStub(channel);
updateCredentials(oAuthCredentials);
}
示例2: getDefaultValue
/**
* Gets the default value for a field type. Note that we use proto3
* language defaults and ignore any default values set through the
* proto "default" option.
*/
private Object getDefaultValue(FieldDescriptor field, Message.Builder builder) {
switch (field.getType()) {
case INT32:
case SINT32:
case SFIXED32:
case UINT32:
case FIXED32:
return 0;
case INT64:
case SINT64:
case SFIXED64:
case UINT64:
case FIXED64:
return 0L;
case FLOAT:
return 0.0f;
case DOUBLE:
return 0.0;
case BOOL:
return false;
case STRING:
return "";
case BYTES:
return ByteString.EMPTY;
case ENUM:
return field.getEnumType().getValues().get(0);
case MESSAGE:
case GROUP:
return builder.newBuilderForField(field).getDefaultInstanceForType();
default:
throw new IllegalStateException("Invalid field type: " + field.getType());
}
}
示例3: advance
private void advance() {
ByteString data = ByteString.EMPTY;
while (iterator.hasNext() && data.isEmpty()) {
data = iterator.next();
}
input = data.newInput();
}
示例4: readBlob
private void readBlob(
ReadRequest request,
StreamObserver<ReadResponse> responseObserver) {
String resourceName = request.getResourceName();
Instance instance;
try {
instance = instances.getFromBlob(resourceName);
} catch (InstanceNotFoundException ex) {
responseObserver.onError(BuildFarmInstances.toStatusException(ex));
return;
}
Digest digest = UrlPath.parseBlobDigest(resourceName);
ByteString blob = instance.getBlob(
digest, request.getReadOffset(), request.getReadLimit());
if (blob == null) {
responseObserver.onError(new StatusException(Status.NOT_FOUND));
return;
}
while (!blob.isEmpty()) {
ByteString chunk;
if (blob.size() < DEFAULT_CHUNK_SIZE) {
chunk = blob;
blob = ByteString.EMPTY;
} else {
chunk = blob.substring(0, (int) DEFAULT_CHUNK_SIZE);
blob = blob.substring((int) DEFAULT_CHUNK_SIZE);
}
responseObserver.onNext(ReadResponse.newBuilder()
.setData(chunk)
.build());
}
responseObserver.onCompleted();
}
示例5: addParameterSets
public void addParameterSets(List<ByteString> params) {
for (int i = 0, cnt = params.size(); i < cnt; i++) {
ByteString bs = (this.param_indexes.get(i) ? params.get(i) : ByteString.EMPTY);
this.builder.addParams(bs);
} // FOR
}
示例6: getByteString
public static ByteString getByteString(byte[] bytes) {
// return singleton to reduce object allocation
return (bytes.length == 0) ? ByteString.EMPTY : ByteString.copyFrom(bytes);
}
示例7: getByteString
public static ByteString getByteString(byte[] bytes) {
// return singleton to reduce object allocation
return (bytes.length == 0) ? ByteString.EMPTY : ByteString.copyFrom(bytes);
}
示例8: RecordFileReader
private RecordFileReader(RecordFileSource<T> source) {
super(source);
buffer = ByteString.EMPTY;
coder = source.coder;
separator = source.separator;
}
示例9: split
public static List<Coprocessor.KeyRange> split(Coprocessor.KeyRange range, int splitFactor) {
if (splitFactor > 32 || splitFactor <= 0 || (splitFactor & (splitFactor - 1)) != 0) {
throw new TiClientInternalException(
"splitFactor must be positive integer power of 2 and no greater than 16");
}
ByteString startKey = range.getStart();
ByteString endKey = range.getEnd();
// we don't cut infinite
if (startKey.isEmpty() || endKey.isEmpty()) {
return ImmutableList.of(range);
}
ImmutableList.Builder<Coprocessor.KeyRange> resultList = ImmutableList.builder();
int maxSize = Math.max(startKey.size(), endKey.size());
int i;
for (i = 0; i < maxSize; i++) {
byte sb = i < startKey.size() ? startKey.byteAt(i) : 0;
byte eb = i < endKey.size() ? endKey.byteAt(i) : 0;
if (sb != eb) {
break;
}
}
ByteString sRemaining = i < startKey.size() ? startKey.substring(i) : ByteString.EMPTY;
ByteString eRemaining = i < endKey.size() ? endKey.substring(i) : ByteString.EMPTY;
CodecDataInput cdi = new CodecDataInput(sRemaining);
int uss = cdi.readPartialUnsignedShort();
cdi = new CodecDataInput(eRemaining);
int ues = cdi.readPartialUnsignedShort();
int delta = (ues - uss) / splitFactor;
if (delta <= 0) {
return ImmutableList.of(range);
}
ByteString prefix = startKey.size() > endKey.size() ?
startKey.substring(0, i) : endKey.substring(0, i);
ByteString newStartKey = startKey;
ByteString newEndKey;
for (int j = 0; j < splitFactor; j++) {
uss += delta;
if (j == splitFactor - 1) {
newEndKey = endKey;
} else {
CodecDataOutput cdo = new CodecDataOutput();
cdo.writeShort(uss);
newEndKey = prefix.concat(cdo.toByteString());
}
resultList.add(makeCoprocRange(newStartKey, newEndKey));
newStartKey = newEndKey;
}
return resultList.build();
}
示例10: handleToByteString
private static ByteString handleToByteString(long tableId, Long k) {
if (k != null) {
return TableCodec.encodeRowKeyWithHandle(tableId, k);
}
return ByteString.EMPTY;
}
示例11: getBlocksBuffer
@Override
public ByteString getBlocksBuffer() {
return ByteString.EMPTY;
}
示例12: ByteStringSinkReader
public ByteStringSinkReader(InputStream input, OutputStream sink) {
this.input = input;
this.sink = sink;
data = ByteString.EMPTY;
completed = false;
}