@Override public FixedLengthSliceInput get() { Slice buffer = lazyBufferLoader.loadNestedDiskRangeBuffer(diskRange); return new BasicSliceInput(buffer); } }
private static Geometry readGeometryCollection(BasicSliceInput input) { List<Geometry> geometries = new ArrayList<>(); while (input.available() > 0) { // skip length input.readInt(); GeometrySerializationType type = GeometrySerializationType.getForCode(input.readByte()); geometries.add(readGeometry(input, type)); } return GEOMETRY_FACTORY.createGeometryCollection(geometries.toArray(new Geometry[0])); }
public static StringClassifierAdapter deserialize(byte[] data) { Slice slice = Slices.wrappedBuffer(data); BasicSliceInput input = slice.getInput(); int classifierLength = input.readInt(); Model classifier = ModelUtils.deserialize(input.readSlice(classifierLength)); int numEnumerations = input.readInt(); ImmutableMap.Builder<Integer, String> builder = ImmutableMap.builder(); for (int i = 0; i < numEnumerations; i++) { int key = input.readInt(); int valueLength = input.readInt(); String value = input.readSlice(valueLength).toStringUtf8(); builder.put(key, value); } return new StringClassifierAdapter((Classifier) classifier, builder.build()); }
@Nullable public static Envelope deserializeEnvelope(Slice shape) { requireNonNull(shape, "shape is null"); BasicSliceInput input = shape.getInput(); verify(input.available() > 0); int length = input.available() - 1; GeometrySerializationType type = GeometrySerializationType.getForCode(input.readByte()); return getEnvelope(input, type, length); }
@Benchmark public Object baselineLength1(BenchmarkData data) throws Throwable { data.input.setPosition(0); unpackGeneric(data.buffer, 0, 1, data.bits, data.input); return data.buffer; }
private static Envelope getSimpleGeometryEnvelope(BasicSliceInput input, int length) { // skip type injected by esri input.readInt(); double xMin = input.readDouble(); double yMin = input.readDouble(); double xMax = input.readDouble(); double yMax = input.readDouble(); int skipLength = length - (4 * Double.BYTES) - Integer.BYTES; verify(input.skip(skipLength) == skipLength); if (isEsriNaN(xMin) || isEsriNaN(yMin) || isEsriNaN(xMax) || isEsriNaN(yMax)) { // TODO: isn't it better to return empty envelope instead? return null; } return new Envelope(xMin, yMin, xMax, yMax); }
Slice slice = slicesIterator.next(); if (slice.getInput().available() == 0) { continue;
public SparseHll(Slice serialized) { BasicSliceInput input = serialized.getInput(); checkArgument(input.readByte() == Format.SPARSE_V2.getTag(), "invalid format tag"); indexBitLength = input.readByte(); validatePrefixLength(indexBitLength); numberOfEntries = input.readShort(); entries = new int[numberOfEntries]; for (int i = 0; i < numberOfEntries; i++) { entries[i] = input.readInt(); } checkArgument(!input.isReadable(), "input is too big"); }
private static OGCGeometry readSimpleGeometry(BasicSliceInput input, Slice inputSlice, GeometrySerializationType type, int length) { int currentPosition = toIntExact(input.position()); ByteBuffer geometryBuffer = inputSlice.toByteBuffer(currentPosition, length).slice(); input.setPosition(currentPosition + length); Geometry esriGeometry = OperatorImportFromESRIShape.local().execute(0, Unknown, geometryBuffer); return createFromEsriGeometry(esriGeometry, type.geometryType().isMultitype()); }
@Override public boolean readBoolean() { return readByte() != 0; }
Slice lengthsBuffer = headerInput.readSlice(lengthsSize);
@Override public long skip(long n) throws IOException { return sliceInput.skip(n); }
public static OGCGeometry deserialize(Slice shape) { requireNonNull(shape, "shape is null"); BasicSliceInput input = shape.getInput(); verify(input.available() > 0); int length = input.available() - 1; GeometrySerializationType type = GeometrySerializationType.getForCode(input.readByte()); return readGeometry(input, shape, type, length); }
@Benchmark public Object optimizedLength1(BenchmarkData data) throws Throwable { data.input.setPosition(0); data.packer.unpack(data.buffer, 0, 1, data.bits, data.input); return data.buffer; }
private static Envelope getSimpleGeometryEnvelope(BasicSliceInput input, int length) { // skip type injected by esri input.readInt(); double xMin = input.readDouble(); double yMin = input.readDouble(); double xMax = input.readDouble(); double yMax = input.readDouble(); int skipLength = length - (4 * Double.BYTES) - Integer.BYTES; verify(input.skip(skipLength) == skipLength); if (isEsriNaN(xMin) || isEsriNaN(yMin) || isEsriNaN(xMax) || isEsriNaN(yMax)) { // TODO: isn't it better to return empty envelope instead? return null; } return new Envelope(xMin, yMin, xMax, yMax); }
@Override public int available() throws IOException { return sliceInput.available(); }
public SparseHll(Slice serialized) { BasicSliceInput input = serialized.getInput(); checkArgument(input.readByte() == Format.SPARSE_V2.getTag(), "invalid format tag"); indexBitLength = input.readByte(); validatePrefixLength(indexBitLength); numberOfEntries = input.readShort(); entries = new int[numberOfEntries]; for (int i = 0; i < numberOfEntries; i++) { entries[i] = input.readInt(); } checkArgument(!input.isReadable(), "input is too big"); }
private static OGCGeometry readSimpleGeometry(BasicSliceInput input, Slice inputSlice, GeometrySerializationType type, int length) { int currentPosition = toIntExact(input.position()); ByteBuffer geometryBuffer = inputSlice.toByteBuffer(currentPosition, length).slice(); input.setPosition(currentPosition + length); Geometry esriGeometry = OperatorImportFromESRIShape.local().execute(0, Unknown, geometryBuffer); return createFromEsriGeometry(esriGeometry, type.geometryType().isMultitype()); }
@Override public boolean readBoolean() { return readByte() != 0; }
Slice lengthsBuffer = headerInput.readSlice(lengthsSize);