當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。