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


Java ByteString.newInput方法代碼示例

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


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

示例1: uncompressByteString

import com.google.protobuf.ByteString; //導入方法依賴的package包/類
private static byte[] uncompressByteString(ByteString bs, Dictionary dict) throws IOException {
  InputStream in = bs.newInput();
  byte status = (byte)in.read();
  if (status == Dictionary.NOT_IN_DICTIONARY) {
    byte[] arr = new byte[StreamUtils.readRawVarint32(in)];
    int bytesRead = in.read(arr);
    if (bytesRead != arr.length) {
      throw new IOException("Cannot read; wanted " + arr.length + ", but got " + bytesRead);
    }
    if (dict != null) dict.addEntry(arr, 0, arr.length);
    return arr;
  } else {
    // Status here is the higher-order byte of index of the dictionary entry.
    short dictIdx = StreamUtils.toShort(status, (byte)in.read());
    byte[] entry = dict.getEntry(dictIdx);
    if (entry == null) {
      throw new IOException("Missing dictionary entry for index " + dictIdx);
    }
    return entry;
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:22,代碼來源:WALCellCodec.java

示例2: readMessageList

import com.google.protobuf.ByteString; //導入方法依賴的package包/類
/**
 * Reads a list of protos, using the provided parser, from the provided {@link ByteString}.
 * @throws IOException if the proto list could not be parsed.
 */
public static <T extends MessageLite> List<T> readMessageList(
        ByteString bytes,
        Parser<T> parser)
        throws IOException {
    InputStream stream = bytes.newInput();
    return readMessageList(stream, parser);
}
 
開發者ID:openid,項目名稱:OpenYOLO-Android,代碼行數:12,代碼來源:ProtoListUtil.java

示例3: advance

import com.google.protobuf.ByteString; //導入方法依賴的package包/類
private void advance() {
  ByteString data = ByteString.EMPTY;
  while (iterator.hasNext() && data.isEmpty()) {
    data = iterator.next();
  }
  input = data.newInput();
}
 
開發者ID:bazelbuild,項目名稱:bazel-buildfarm,代碼行數:8,代碼來源:ByteStringIteratorInputStream.java

示例4: Chunker

import com.google.protobuf.ByteString; //導入方法依賴的package包/類
public Chunker(ByteString data, int chunkSize) {
  this(() -> data.newInput(), Digests.computeDigest(data), chunkSize);
}
 
開發者ID:bazelbuild,項目名稱:bazel-buildfarm,代碼行數:4,代碼來源:Chunker.java


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