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


Java CodedInputStream.setSizeLimit方法代码示例

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


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

示例1: readDataManifest

import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
private SnapshotDataManifest readDataManifest() throws IOException {
  FSDataInputStream in = null;
  try {
    in = fs.open(new Path(workingDir, DATA_MANIFEST_NAME));
    CodedInputStream cin = CodedInputStream.newInstance(in);
    cin.setSizeLimit(manifestSizeLimit);
    return SnapshotDataManifest.parseFrom(cin);
  } catch (FileNotFoundException e) {
    return null;
  } finally {
    if (in != null) in.close();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:14,代码来源:SnapshotManifest.java

示例2: mergeDelimitedFrom

import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
/**
 * This version of protobuf's mergeDelimitedFrom avoids the hard-coded 64MB limit for decoding
 * buffers
 * @param builder current message builder
 * @param in Inputsream with delimited protobuf data
 * @throws IOException
 */
public static void mergeDelimitedFrom(Message.Builder builder, InputStream in)
  throws IOException {
  // This used to be builder.mergeDelimitedFrom(in);
  // but is replaced to allow us to bump the protobuf size limit.
  final int firstByte = in.read();
  if (firstByte != -1) {
    final int size = CodedInputStream.readRawVarint32(firstByte, in);
    final InputStream limitedInput = new LimitInputStream(in, size);
    final CodedInputStream codedInput = CodedInputStream.newInstance(limitedInput);
    codedInput.setSizeLimit(size);
    builder.mergeFrom(codedInput);
    codedInput.checkLastTagWas(0);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:22,代码来源:ProtobufUtil.java

示例3: mergeFrom

import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
/**
 * This version of protobuf's mergeFrom avoids the hard-coded 64MB limit for decoding
 * buffers where the message size is not known
 * @param builder current message builder
 * @param in InputStream containing protobuf data
 * @throws IOException 
 */
public static void mergeFrom(Message.Builder builder, InputStream in)
    throws IOException {
  final CodedInputStream codedInput = CodedInputStream.newInstance(in);
  codedInput.setSizeLimit(Integer.MAX_VALUE);
  builder.mergeFrom(codedInput);
  codedInput.checkLastTagWas(0);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:15,代码来源:ProtobufUtil.java

示例4: skip

import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
@Override
public int skip(PositionedByteRange src) {
  CellProtos.Cell.Builder builder = CellProtos.Cell.newBuilder();
  CodedInputStream is = inputStreamFromByteRange(src);
  is.setSizeLimit(src.getLength());
  try {
    builder.mergeFrom(is);
    int consumed = is.getTotalBytesRead();
    src.setPosition(src.getPosition() + consumed);
    return consumed;
  } catch (IOException e) {
    throw new RuntimeException("Error while skipping type.", e);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:15,代码来源:PBCell.java

示例5: decode

import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
@Override
public CellProtos.Cell decode(PositionedByteRange src) {
  CellProtos.Cell.Builder builder = CellProtos.Cell.newBuilder();
  CodedInputStream is = inputStreamFromByteRange(src);
  is.setSizeLimit(src.getLength());
  try {
    CellProtos.Cell ret = builder.mergeFrom(is).build();
    src.setPosition(src.getPosition() + is.getTotalBytesRead());
    return ret;
  } catch (IOException e) {
    throw new RuntimeException("Error while decoding type.", e);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:14,代码来源:PBCell.java

示例6: parseToProto

import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
/**
 * Returns the loaded protocol buffer from the given byte stream. You normally want
 * {@link Wallet#loadFromFile(java.io.File, WalletExtension...)} instead - this method is designed for low level
 * work involving the wallet file format itself.
 */
public static Protos.Wallet parseToProto(InputStream input) throws IOException {
    CodedInputStream codedInput = CodedInputStream.newInstance(input);
    codedInput.setSizeLimit(WALLET_SIZE_LIMIT);
    return Protos.Wallet.parseFrom(codedInput);
}
 
开发者ID:creativechain,项目名称:creacoinj,代码行数:11,代码来源:WalletProtobufSerializer.java

示例7: main

import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {

		String path = "data/caffe_models/alexnet/bvlc_alexnet.caffemodel";
//		String path = "data/caffe_models/alexnet/imagenet_mean.binaryproto";

		CodedInputStream input = CodedInputStream.newInstance(new FileInputStream(path));
		input.setSizeLimit(512*1024*1024);

		System.out.println("Before");
		Caffe.NetParameter parameters = Caffe.NetParameter.parseFrom(input);
		System.out.println("After");

		System.out.println("name = "+parameters.getName());

		System.out.println("   getInputDimCount()  = "+parameters.getInputDimCount());
		System.out.println("   getLayerList().size() = "+parameters.getLayerList().size());
		System.out.println("   getLayersList().size() = "+parameters.getLayersList().size());
		System.out.println("   getInputShapeCount() = "+parameters.getInputShapeCount());

		List<Caffe.LayerParameter> layers = parameters.getLayerList();

		printLayers(parameters.getLayersList());
		printLayer(parameters.getLayerList());


	}
 
开发者ID:lessthanoptimal,项目名称:DeepBoof,代码行数:27,代码来源:PrintWeightCrap.java

示例8: parsePartialFrom

import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
@Override
public T parsePartialFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
        throws InvalidProtocolBufferException {
    input.setSizeLimit(Integer.MAX_VALUE);
    return parser.parsePartialFrom(input, extensionRegistry);
}
 
开发者ID:glowroot,项目名称:glowroot,代码行数:7,代码来源:SizeLimitBypassingParser.java

示例9: mergeFrom

import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
/**
 * This version of protobuf's mergeFrom avoids the hard-coded 64MB limit for decoding
 * buffers when working with byte arrays
 * @param builder current message builder
 * @param b byte array
 * @throws IOException
 */
public static void mergeFrom(Message.Builder builder, byte[] b) throws IOException {
  final CodedInputStream codedInput = CodedInputStream.newInstance(b);
  codedInput.setSizeLimit(b.length);
  builder.mergeFrom(codedInput);
  codedInput.checkLastTagWas(0);
}
 
开发者ID:apache,项目名称:hbase,代码行数:14,代码来源:ProtobufUtil.java


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