public static void mergeFrom(Message.Builder builder, CodedInputStream codedInput, int length) throws IOException { codedInput.resetSizeCounter(); int prevLimit = codedInput.setSizeLimit(length); int limit = codedInput.pushLimit(length); builder.mergeFrom(codedInput); codedInput.popLimit(limit); codedInput.checkLastTagWas(0); codedInput.setSizeLimit(prevLimit); }
private SnapshotDataManifest readDataManifest() throws IOException { FSDataInputStream in = null; try { in = workingDirFs.open(new Path(workingDir, DATA_MANIFEST_NAME)); CodedInputStream cin = CodedInputStream.newInstance(in); cin.setSizeLimit(manifestSizeLimit); return SnapshotDataManifest.parseFrom(cin); } catch (FileNotFoundException e) { return null; } catch (InvalidProtocolBufferException e) { throw new CorruptedSnapshotException("unable to parse data manifest " + e.getMessage(), e); } finally { if (in != null) in.close(); } }
/** * 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); }
/** * 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); }
/** * This version of protobuf's mergeFrom avoids the hard-coded 64MB limit for decoding * buffers where the message size is known * @param builder current message builder * @param in InputStream containing protobuf data * @param size known size of protobuf data * @throws IOException */ public static void mergeFrom(Message.Builder builder, InputStream in, int size) throws IOException { final CodedInputStream codedInput = CodedInputStream.newInstance(in); codedInput.setSizeLimit(size); builder.mergeFrom(codedInput); codedInput.checkLastTagWas(0); }
/** * 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 * @param offset * @param length * @throws IOException */ public static void mergeFrom(Message.Builder builder, byte[] b, int offset, int length) throws IOException { final CodedInputStream codedInput = CodedInputStream.newInstance(b, offset, length); codedInput.setSizeLimit(length); builder.mergeFrom(codedInput); codedInput.checkLastTagWas(0); }
/** * This version of protobuf's mergeFrom avoids the hard-coded 64MB limit for decoding * buffers when working with ByteStrings * @param builder current message builder * @param bs ByteString containing the * @throws IOException */ public static void mergeFrom(Message.Builder builder, ByteString bs) throws IOException { final CodedInputStream codedInput = bs.newCodedInput(); codedInput.setSizeLimit(bs.size()); builder.mergeFrom(codedInput); codedInput.checkLastTagWas(0); }
/** * This version of protobuf's mergeDelimitedFrom avoid 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 = ByteStreams.limit(in, size); final CodedInputStream codedInput = CodedInputStream.newInstance(limitedInput); codedInput.setSizeLimit(size); builder.mergeFrom(codedInput); codedInput.checkLastTagWas(0); } }
public static void mergeFrom(Message.Builder builder, CodedInputStream codedInput, int length) throws IOException { codedInput.resetSizeCounter(); int prevLimit = codedInput.setSizeLimit(length); int limit = codedInput.pushLimit(length); builder.mergeFrom(codedInput); codedInput.popLimit(limit); codedInput.checkLastTagWas(0); codedInput.setSizeLimit(prevLimit); }
/** * 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); }
/** * 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); }
/** * This version of protobuf's mergeFrom avoids the hard-coded 64MB limit for decoding * buffers where the message size is known * @param builder current message builder * @param in InputStream containing protobuf data * @param size known size of protobuf data * @throws IOException */ public static void mergeFrom(Message.Builder builder, InputStream in, int size) throws IOException { final CodedInputStream codedInput = CodedInputStream.newInstance(in); codedInput.setSizeLimit(size); builder.mergeFrom(codedInput); codedInput.checkLastTagWas(0); }
/** * 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 * @param offset * @param length * @throws IOException */ public static void mergeFrom(Message.Builder builder, byte[] b, int offset, int length) throws IOException { final CodedInputStream codedInput = CodedInputStream.newInstance(b, offset, length); codedInput.setSizeLimit(length); builder.mergeFrom(codedInput); codedInput.checkLastTagWas(0); }
/** * This version of protobuf's mergeFrom avoids the hard-coded 64MB limit for decoding * buffers when working with ByteStrings * @param builder current message builder * @param bs ByteString containing the * @throws IOException */ public static void mergeFrom(Message.Builder builder, ByteString bs) throws IOException { final CodedInputStream codedInput = bs.newCodedInput(); codedInput.setSizeLimit(bs.size()); builder.mergeFrom(codedInput); codedInput.checkLastTagWas(0); }
/** * This version of protobuf's mergeDelimitedFrom avoid 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 = ByteStreams.limit(in, size); final CodedInputStream codedInput = CodedInputStream.newInstance(limitedInput); codedInput.setSizeLimit(size); builder.mergeFrom(codedInput); codedInput.checkLastTagWas(0); } }
public static void mergeFrom(Message.Builder builder, CodedInputStream codedInput, int length) throws IOException { codedInput.resetSizeCounter(); int prevLimit = codedInput.setSizeLimit(length); int limit = codedInput.pushLimit(length); builder.mergeFrom(codedInput); codedInput.popLimit(limit); codedInput.checkLastTagWas(0); codedInput.setSizeLimit(prevLimit); }
/** * 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); }
/** * 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); }
/** * This version of protobuf's mergeFrom avoids the hard-coded 64MB limit for decoding * buffers where the message size is known * @param builder current message builder * @param in InputStream containing protobuf data * @param size known size of protobuf data * @throws IOException */ public static void mergeFrom(Message.Builder builder, InputStream in, int size) throws IOException { final CodedInputStream codedInput = CodedInputStream.newInstance(in); codedInput.setSizeLimit(size); builder.mergeFrom(codedInput); codedInput.checkLastTagWas(0); }
/** * This version of protobuf's mergeFrom avoids the hard-coded 64MB limit for decoding * buffers when working with ByteStrings * @param builder current message builder * @param bs ByteString containing the * @throws IOException */ public static void mergeFrom(Message.Builder builder, ByteString bs) throws IOException { final CodedInputStream codedInput = bs.newCodedInput(); codedInput.setSizeLimit(bs.size()); builder.mergeFrom(codedInput); codedInput.checkLastTagWas(0); }