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