本文整理汇总了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;
}
}
示例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);
}
示例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();
}
示例4: Chunker
import com.google.protobuf.ByteString; //导入方法依赖的package包/类
public Chunker(ByteString data, int chunkSize) {
this(() -> data.newInput(), Digests.computeDigest(data), chunkSize);
}