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


Java CodedInputStream.isAtEnd方法代码示例

本文整理汇总了Java中com.google.protobuf.CodedInputStream.isAtEnd方法的典型用法代码示例。如果您正苦于以下问题:Java CodedInputStream.isAtEnd方法的具体用法?Java CodedInputStream.isAtEnd怎么用?Java CodedInputStream.isAtEnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.protobuf.CodedInputStream的用法示例。


在下文中一共展示了CodedInputStream.isAtEnd方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readFrom

import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
public static BlockListAsLongs readFrom(InputStream is) throws IOException {
  CodedInputStream cis = CodedInputStream.newInstance(is);
  int numBlocks = -1;
  ByteString blocksBuf = null;
  while (!cis.isAtEnd()) {
    int tag = cis.readTag();
    int field = WireFormat.getTagFieldNumber(tag);
    switch(field) {
      case 0:
        break;
      case 1:
        numBlocks = (int)cis.readInt32();
        break;
      case 2:
        blocksBuf = cis.readBytes();
        break;
      default:
        cis.skipField(tag);
        break;
    }
  }
  if (numBlocks != -1 && blocksBuf != null) {
    return decodeBuffer(numBlocks, blocksBuf);
  }
  return null;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:27,代码来源:BlockListAsLongs.java

示例2: readPreprocessedBlock

import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
private Iterable<RtbImpression> readPreprocessedBlock(BlockContext context) throws IOException {
    List<RtbImpression> impressions = new ArrayList<>();
    try (InputStream is = context.createInputStream(PREPROCESS)) {
        CodedInputStream cis = CodedInputStream.newInstance(is);
        while (!cis.isAtEnd()) {
            int len = cis.readRawVarint32();
            int oldLimit = cis.pushLimit(len);
            impressions.add(RtbImpression.parseFrom(cis));
            cis.popLimit(oldLimit);
        }
    }
    return impressions;
}
 
开发者ID:papyrusglobal,项目名称:state-channels,代码行数:14,代码来源:RtbValidator.java

示例3: readLog

import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
private OnlineSectioningLog.ExportedLog readLog(CodedInputStream cin) throws IOException {
	if (cin.isAtEnd()) return null;
	int size = cin.readInt32();
	int limit = cin.pushLimit(size);
	OnlineSectioningLog.ExportedLog ret = OnlineSectioningLog.ExportedLog.parseFrom(cin);
	cin.popLimit(limit);
	cin.resetSizeCounter();
	return ret;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:10,代码来源:ReplayLogTest.java

示例4: readTable

import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
public static TableData.Table readTable(CodedInputStream cin) throws IOException {
	if (cin.isAtEnd()) return null;
	int size = cin.readInt32();
	int limit = cin.pushLimit(size);
	TableData.Table ret = TableData.Table.parseFrom(cin);
	cin.popLimit(limit);
	cin.resetSizeCounter();
	return ret;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:10,代码来源:SessionRestore.java

示例5: apply

import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
List<T> apply(InputStream in) throws IOException {
    List<T> list = new ArrayList<>();
    CodedInputStream stream = CodedInputStream.newInstance(in);
    int size;
    while (!stream.isAtEnd() && (size = stream.readRawVarint32()) != 0) {
        ByteArrayInputStream delimited = new ByteArrayInputStream(stream.readRawBytes(size));
        list.add(parse.apply(delimited));
    }
    return list;
}
 
开发者ID:horrorho,项目名称:InflatableDonkey,代码行数:11,代码来源:DelimitedProtobufHandler.java

示例6: decode

import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
/**
 * Decode custom protobuf variable length array.
 *
 * @param <T> the item type
 * @param data the raw input, not null
 * @param parser the parser to decode each message, not null
 * @return the decoded list of items, not null
 * @throws IOException
 * @throws NullPointerException if any arguments are null
 */
public static <T> List<T> decode(InputStream data, Parser<T> parser) throws IOException {
    CodedInputStream stream = CodedInputStream.newInstance(data);
    List<T> list = new ArrayList<>();
    while (!stream.isAtEnd()) {
        int size = stream.readRawVarint32();
        byte[] element = stream.readRawBytes(size);
        T decoded = parser.parseFrom(element);
        list.add(decoded);
    }
    return list;
}
 
开发者ID:horrorho,项目名称:LiquidDonkey,代码行数:22,代码来源:ProtoBufArray.java


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