private byte[] readBlobContent() throws IOException { Fileformat.Blob blob = Fileformat.Blob.parseFrom(rawBlob); byte[] blobData; if (blob.hasRaw()) { blobData = blob.getRaw().toByteArray(); } else if (blob.hasZlibData()) { Inflater inflater = new Inflater(); inflater.setInput(blob.getZlibData().toByteArray()); blobData = new byte[blob.getRawSize()]; try { inflater.inflate(blobData); } catch (DataFormatException e) { throw new RuntimeException("Unable to decompress PBF blob.", e); } if (!inflater.finished()) { throw new RuntimeException("PBF blob contains incomplete compressed data."); } inflater.end(); } else { throw new RuntimeException("PBF blob uses unsupported compression, only raw or zlib may be used."); } return blobData; }
switch (method) { case NEW_MUTABLE_INSTANCE: { return new org.openstreetmap.osmosis.osmbinary.Fileformat.Blob(); org.openstreetmap.osmosis.osmbinary.Fileformat.Blob other = (org.openstreetmap.osmosis.osmbinary.Fileformat.Blob) arg1; raw_ = visitor.visitByteString( hasRaw(), raw_, other.hasRaw(), other.raw_); rawSize_ = visitor.visitInt( hasRawSize(), rawSize_, other.hasRawSize(), other.rawSize_); zlibData_ = visitor.visitByteString( hasZlibData(), zlibData_, other.hasZlibData(), other.zlibData_); lzmaData_ = visitor.visitByteString( hasLzmaData(), lzmaData_, other.hasLzmaData(), other.lzmaData_); oBSOLETEBzip2Data_ = visitor.visitByteString( hasOBSOLETEBzip2Data(), oBSOLETEBzip2Data_, other.hasOBSOLETEBzip2Data(), other.oBSOLETEBzip2Data_); if (visitor == com.google.protobuf.GeneratedMessageLite.MergeFromVisitor .INSTANCE) { if (!parseUnknownField(tag, input)) { done = true;
return null; Fileformat.Blob blob = Fileformat.Blob.parseFrom(blobBytes); if (blob.hasZlibData()) { blobData = new InflaterInputStream(blob.getZlibData().newInput()); } else { blobData = blob.getRaw().newInput();
Fileformat.Blob.Builder blobBuilder = Fileformat.Blob.newBuilder(); byte[] serializedBlock = block.toByteArray(); byte[] deflatedBlock = new byte[serializedBlock.length]; blobBuilder.setRawSize(serializedBlock.length); byte[] serializedBlob = blobBuilder.build().toByteArray();
builder.setType(type); Fileformat.Blob.Builder blobbuilder = Fileformat.Blob.newBuilder(); if (flags == CompressFlags.NONE) { blobbuilder.setRaw(data); builder.setDatasize(blob.getSerializedSize()); Fileformat.BlobHeader message = builder.build(); int size = message.getSerializedSize(); offset = ((FileOutputStream) outwrite).getChannel().position(); blob.writeTo(outwrite); return FileBlockPosition.newInstance(this, offset, size);
private byte[] readBlobContent() throws IOException { Fileformat.Blob blob = Fileformat.Blob.parseFrom(rawBlob); byte[] blobData; if (blob.hasRaw()) { blobData = blob.getRaw().toByteArray(); } else if (blob.hasZlibData()) { Inflater inflater = new Inflater(); inflater.setInput(blob.getZlibData().toByteArray()); blobData = new byte[blob.getRawSize()]; try { inflater.inflate(blobData); } catch (DataFormatException e) { throw new RuntimeException("Unable to decompress PBF blob.", e); } if (!inflater.finished()) { throw new RuntimeException("PBF blob contains incomplete compressed data."); } } else { throw new RuntimeException("PBF blob uses unsupported compression, only raw or zlib may be used."); } return blobData; }
/** Parse out and decompress the data part of a fileblock helper function. */ FileBlock parseData(byte buf[]) throws InvalidProtocolBufferException { FileBlock out = FileBlock.newInstance(type, null, indexdata); Fileformat.Blob blob = Fileformat.Blob.parseFrom(buf); if (blob.hasRaw()) { out.data = blob.getRaw(); } else if (blob.hasZlibData()) { byte buf2[] = new byte[blob.getRawSize()]; Inflater decompresser = new Inflater(); decompresser.setInput(blob.getZlibData().toByteArray()); // decompresser.getRemaining(); try { decompresser.inflate(buf2); } catch (DataFormatException e) { e.printStackTrace(); throw new Error(e); } assert (decompresser.finished()); decompresser.end(); out.data = ByteString.copyFrom(buf2); } return out; }
private byte[] readBlobContent() throws IOException { Fileformat.Blob blob = Fileformat.Blob.parseFrom(rawBlob); byte[] blobData; if (blob.hasRaw()) { blobData = blob.getRaw().toByteArray(); } else if (blob.hasZlibData()) { Inflater inflater = new Inflater(); inflater.setInput(blob.getZlibData().toByteArray()); blobData = new byte[blob.getRawSize()]; try { inflater.inflate(blobData); } catch (DataFormatException e) { throw new RuntimeException("Unable to decompress PBF blob.", e); } if (!inflater.finished()) { throw new RuntimeException("PBF blob contains incomplete compressed data."); } } else { throw new RuntimeException("PBF blob uses unsupported compression, only raw or zlib may be used."); } return blobData; }
private byte[] readBlobContent() throws IOException { Fileformat.Blob blob = Fileformat.Blob.parseFrom(rawBlob); byte[] blobData; if (blob.hasRaw()) { blobData = blob.getRaw().toByteArray(); } else if (blob.hasZlibData()) { Inflater inflater = new Inflater(); inflater.setInput(blob.getZlibData().toByteArray()); blobData = new byte[blob.getRawSize()]; try { inflater.inflate(blobData); } catch (DataFormatException e) { throw new RuntimeException("Unable to decompress PBF blob.", e); } if (!inflater.finished()) { throw new RuntimeException("PBF blob contains incomplete compressed data."); } } else { throw new RuntimeException("PBF blob uses unsupported compression, only raw or zlib may be used."); } return blobData; }
@Override public byte[] apply(Fileformat.Blob blob) { byte[] blobData; if (blob.hasRaw()) { blobData = blob.getRaw().toByteArray(); } else if (blob.hasZlibData()) { Inflater inflater = new Inflater(); inflater.setInput(blob.getZlibData().toByteArray()); blobData = new byte[blob.getRawSize()]; try { inflater.inflate(blobData); } catch (DataFormatException e) { throw new OsmosisRuntimeException("Unable to decompress PBF blob.", e); } if (!inflater.finished()) { throw new OsmosisRuntimeException("PBF blob contains incomplete compressed data."); } } else { throw new OsmosisRuntimeException("PBF blob uses unsupported compression, only raw or zlib may be used."); } return blobData; } }
/** * <pre> * Possible compressed versions of the data. * </pre> * * <code>optional bytes zlib_data = 3;</code> */ @java.lang.Override public com.google.protobuf.ByteString getZlibData() { return instance.getZlibData(); } /**
/** * <pre> * Possible compressed versions of the data. * </pre> * * <code>optional bytes zlib_data = 3;</code> */ @java.lang.Override public boolean hasZlibData() { return instance.hasZlibData(); } /**
/** * <pre> * When compressed, the uncompressed size * </pre> * * <code>optional int32 raw_size = 2;</code> */ @java.lang.Override public int getRawSize() { return instance.getRawSize(); } /**
/** * <pre> * Possible compressed versions of the data. * </pre> * * <code>optional bytes zlib_data = 3;</code> */ private void clearZlibData() { bitField0_ = (bitField0_ & ~0x00000004); zlibData_ = getDefaultInstance().getZlibData(); }
/** * <pre> * No compression * </pre> * * <code>optional bytes raw = 1;</code> */ @java.lang.Override public boolean hasRaw() { return instance.hasRaw(); } /**
/** * <pre> * No compression * </pre> * * <code>optional bytes raw = 1;</code> */ private void clearRaw() { bitField0_ = (bitField0_ & ~0x00000001); raw_ = getDefaultInstance().getRaw(); }
/** * <pre> * No compression * </pre> * * <code>optional bytes raw = 1;</code> */ @java.lang.Override public com.google.protobuf.ByteString getRaw() { return instance.getRaw(); } /**
private Fileformat.Blob parseBlob(byte[] data) { try { return Fileformat.Blob.parseFrom(data); } catch (InvalidProtocolBufferException e) { throw new OsmosisRuntimeException("Unable to parse PBF blob", e); } }