本文整理汇总了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();
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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());
}
示例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);
}
示例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);
}