当前位置: 首页>>代码示例>>Java>>正文


Java ByteString.EMPTY属性代码示例

本文整理汇总了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);
}
 
开发者ID:mautini,项目名称:google-assistant-java-demo,代码行数:17,代码来源:AssistantClient.java

示例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());
  }
}
 
开发者ID:SeldonIO,项目名称:seldon-core,代码行数:38,代码来源:JsonFormat.java

示例3: advance

private void advance() {
  ByteString data = ByteString.EMPTY;
  while (iterator.hasNext() && data.isEmpty()) {
    data = iterator.next();
  }
  input = data.newInput();
}
 
开发者ID:bazelbuild,项目名称:bazel-buildfarm,代码行数:7,代码来源:ByteStringIteratorInputStream.java

示例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();
}
 
开发者ID:bazelbuild,项目名称:bazel-buildfarm,代码行数:38,代码来源:ByteStreamService.java

示例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
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:6,代码来源:TransactionWorkRequestBuilder.java

示例6: getByteString

public static ByteString getByteString(byte[] bytes) {
	// return singleton to reduce object allocation
	return (bytes.length == 0) ? ByteString.EMPTY : ByteString.copyFrom(bytes);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:4,代码来源:KeyRotationBC.java

示例7: getByteString

public static ByteString getByteString(byte[] bytes) {
  // return singleton to reduce object allocation
  return (bytes.length == 0) ? ByteString.EMPTY : ByteString.copyFrom(bytes);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:4,代码来源:NuCypherExtPBHelperClient.java

示例8: RecordFileReader

private RecordFileReader(RecordFileSource<T> source) {
  super(source);
  buffer = ByteString.EMPTY;
  coder = source.coder;
  separator = source.separator;
}
 
开发者ID:GoogleCloudPlatform,项目名称:dataflow-opinion-analysis,代码行数:6,代码来源:RecordFileSource.java

示例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();
}
 
开发者ID:pingcap,项目名称:tikv-client-lib-java,代码行数:58,代码来源:KeyRangeUtils.java

示例10: handleToByteString

private static ByteString handleToByteString(long tableId, Long k) {
  if (k != null) {
    return TableCodec.encodeRowKeyWithHandle(tableId, k);
  }
  return ByteString.EMPTY;
}
 
开发者ID:pingcap,项目名称:tikv-client-lib-java,代码行数:6,代码来源:RangeSplitterTest.java

示例11: getBlocksBuffer

@Override
public ByteString getBlocksBuffer() {
  return ByteString.EMPTY;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:4,代码来源:BlockListAsLongs.java

示例12: ByteStringSinkReader

public ByteStringSinkReader(InputStream input, OutputStream sink) {
  this.input = input;
  this.sink = sink;
  data = ByteString.EMPTY;
  completed = false;
}
 
开发者ID:bazelbuild,项目名称:bazel-buildfarm,代码行数:6,代码来源:ByteStringSinkReader.java


注:本文中的com.google.protobuf.ByteString.EMPTY属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。