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()); }
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])); }
private static OGCConcreteGeometryCollection readGeometryCollection(BasicSliceInput input, Slice inputSlice) { // GeometryCollection: geometryType|len-of-shape1|bytes-of-shape1|len-of-shape2|bytes-of-shape2... List<OGCGeometry> geometries = new ArrayList<>(); while (input.available() > 0) { int length = input.readInt() - 1; GeometrySerializationType type = GeometrySerializationType.getForCode(input.readByte()); geometries.add(readGeometry(input, inputSlice, type, length)); } return new OGCConcreteGeometryCollection(geometries, null); }
private static Envelope getGeometryCollectionOverallEnvelope(BasicSliceInput input) { Envelope overallEnvelope = null; while (input.available() > 0) { int length = input.readInt() - 1; GeometrySerializationType type = GeometrySerializationType.getForCode(input.readByte()); Envelope envelope = getEnvelope(input, type, length); overallEnvelope = merge(overallEnvelope, envelope); } return overallEnvelope; }
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); }
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()); }
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])); }
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])); }
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])); }
private static OGCConcreteGeometryCollection readGeometryCollection(BasicSliceInput input, Slice inputSlice) { // GeometryCollection: geometryType|len-of-shape1|bytes-of-shape1|len-of-shape2|bytes-of-shape2... List<OGCGeometry> geometries = new ArrayList<>(); while (input.available() > 0) { int length = input.readInt() - 1; GeometrySerializationType type = GeometrySerializationType.getForCode(input.readByte()); geometries.add(readGeometry(input, inputSlice, type, length)); } return new OGCConcreteGeometryCollection(geometries, null); }
private static OGCConcreteGeometryCollection readGeometryCollection(BasicSliceInput input, Slice inputSlice) { // GeometryCollection: geometryType|len-of-shape1|bytes-of-shape1|len-of-shape2|bytes-of-shape2... List<OGCGeometry> geometries = new ArrayList<>(); while (input.available() > 0) { int length = input.readInt() - 1; GeometrySerializationType type = GeometrySerializationType.getForCode(input.readByte()); geometries.add(readGeometry(input, inputSlice, type, length)); } return new OGCConcreteGeometryCollection(geometries, null); }
private static OGCConcreteGeometryCollection readGeometryCollection(BasicSliceInput input, Slice inputSlice) { // GeometryCollection: geometryType|len-of-shape1|bytes-of-shape1|len-of-shape2|bytes-of-shape2... List<OGCGeometry> geometries = new ArrayList<>(); while (input.available() > 0) { int length = input.readInt() - 1; GeometrySerializationType type = GeometrySerializationType.getForCode(input.readByte()); geometries.add(readGeometry(input, inputSlice, type, length)); } return new OGCConcreteGeometryCollection(geometries, null); }
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"); }
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 Envelope getGeometryCollectionOverallEnvelope(BasicSliceInput input) { Envelope overallEnvelope = null; while (input.available() > 0) { int length = input.readInt() - 1; GeometrySerializationType type = GeometrySerializationType.getForCode(input.readByte()); Envelope envelope = getEnvelope(input, type, length); overallEnvelope = merge(overallEnvelope, envelope); } return overallEnvelope; }
private static Envelope getGeometryCollectionOverallEnvelope(BasicSliceInput input) { Envelope overallEnvelope = null; while (input.available() > 0) { int length = input.readInt() - 1; GeometrySerializationType type = GeometrySerializationType.getForCode(input.readByte()); Envelope envelope = getEnvelope(input, type, length); overallEnvelope = merge(overallEnvelope, envelope); } return overallEnvelope; }
private static Envelope getGeometryCollectionOverallEnvelope(BasicSliceInput input) { Envelope overallEnvelope = null; while (input.available() > 0) { int length = input.readInt() - 1; GeometrySerializationType type = GeometrySerializationType.getForCode(input.readByte()); Envelope envelope = getEnvelope(input, type, length); overallEnvelope = merge(overallEnvelope, envelope); } return overallEnvelope; }
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); }
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); }
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); }