當前位置: 首頁>>代碼示例>>Java>>正文


Java ByteString.newOutput方法代碼示例

本文整理匯總了Java中com.google.protobuf.ByteString.newOutput方法的典型用法代碼示例。如果您正苦於以下問題:Java ByteString.newOutput方法的具體用法?Java ByteString.newOutput怎麽用?Java ByteString.newOutput使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.protobuf.ByteString的用法示例。


在下文中一共展示了ByteString.newOutput方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: writeMessageList

import com.google.protobuf.ByteString; //導入方法依賴的package包/類
/**
 * Creates a {@link ByteString} by serializing the list of protos. Use
 * {@link #readMessageList(ByteString, Parser)} to deserialize.
 */
public static <T extends MessageLite> ByteString writeMessageList(List<T> protos) {
    Output output = ByteString.newOutput();
    try {
        writeMessageListTo(output, protos);
    } catch (IOException ex) {
        throw new IllegalStateException("Unable to write protobufs to memory");
    }

    return output.toByteString();
}
 
開發者ID:openid,項目名稱:OpenYOLO-Android,代碼行數:15,代碼來源:ProtoListUtil.java

示例2: Builder

import com.google.protobuf.ByteString; //導入方法依賴的package包/類
Builder() {
  out = ByteString.newOutput(64*1024);
  cos = CodedOutputStream.newInstance(out);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:5,代碼來源:BlockListAsLongs.java

示例3: convert

import com.google.protobuf.ByteString; //導入方法依賴的package包/類
/**
 * Helper to convert the procedure to protobuf.
 * Used by ProcedureStore implementations.
 */
@InterfaceAudience.Private
public static ProcedureProtos.Procedure convert(final Procedure proc)
    throws IOException {
  Preconditions.checkArgument(proc != null);
  validateClass(proc);

  ProcedureProtos.Procedure.Builder builder = ProcedureProtos.Procedure.newBuilder()
    .setClassName(proc.getClass().getName())
    .setProcId(proc.getProcId())
    .setState(proc.getState())
    .setStartTime(proc.getStartTime())
    .setLastUpdate(proc.getLastUpdate());

  if (proc.hasParent()) {
    builder.setParentId(proc.getParentProcId());
  }

  if (proc.hasTimeout()) {
    builder.setTimeout(proc.getTimeout());
  }

  if (proc.hasOwner()) {
    builder.setOwner(proc.getOwner());
  }

  int[] stackIds = proc.getStackIndexes();
  if (stackIds != null) {
    for (int i = 0; i < stackIds.length; ++i) {
      builder.addStackId(stackIds[i]);
    }
  }

  if (proc.hasException()) {
    RemoteProcedureException exception = proc.getException();
    builder.setException(
      RemoteProcedureException.toProto(exception.getSource(), exception.getCause()));
  }

  byte[] result = proc.getResult();
  if (result != null) {
    builder.setResult(ByteStringer.wrap(result));
  }

  ByteString.Output stateStream = ByteString.newOutput();
  proc.serializeStateData(stateStream);
  if (stateStream.size() > 0) {
    builder.setStateData(stateStream.toByteString());
  }

  if (proc.getNonceKey() != null) {
    builder.setNonceGroup(proc.getNonceKey().getNonceGroup());
    builder.setNonce(proc.getNonceKey().getNonce());
  }

  return builder.build();
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:61,代碼來源:Procedure.java


注:本文中的com.google.protobuf.ByteString.newOutput方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。