Java Code Examples for io.airlift.slice.DynamicSliceOutput#appendByte()
The following examples show how to use
io.airlift.slice.DynamicSliceOutput#appendByte() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JtsGeometrySerde.java From presto with Apache License 2.0 | 6 votes |
private static void writeGeometryCollection(Geometry collection, DynamicSliceOutput output) { output.appendByte(GeometrySerializationType.GEOMETRY_COLLECTION.code()); for (int geometryIndex = 0; geometryIndex < collection.getNumGeometries(); geometryIndex++) { Geometry geometry = collection.getGeometryN(geometryIndex); int startPosition = output.size(); // leave 4 bytes for the shape length output.appendInt(0); writeGeometry(geometry, output); int endPosition = output.size(); int length = endPosition - startPosition - Integer.BYTES; output.getUnderlyingSlice().setInt(startPosition, length); } }
Example 2
Source File: GeometrySerde.java From presto with Apache License 2.0 | 6 votes |
private static void writeGeometryCollection(DynamicSliceOutput output, OGCGeometryCollection collection) { output.appendByte(GeometrySerializationType.GEOMETRY_COLLECTION.code()); for (int geometryIndex = 0; geometryIndex < collection.numGeometries(); geometryIndex++) { OGCGeometry geometry = collection.geometryN(geometryIndex); int startPosition = output.size(); // leave 4 bytes for the shape length output.appendInt(0); writeGeometry(output, geometry); int endPosition = output.size(); int length = endPosition - startPosition - Integer.BYTES; output.getUnderlyingSlice().setInt(startPosition, length); } }
Example 3
Source File: GeometrySerde.java From presto with Apache License 2.0 | 6 votes |
private static void writePoint(DynamicSliceOutput output, OGCGeometry geometry) { Geometry esriGeometry = geometry.getEsriGeometry(); verify(esriGeometry instanceof Point, "geometry is expected to be an instance of Point"); Point point = (Point) esriGeometry; verify(!point.hasAttribute(VertexDescription.Semantics.Z) && !point.hasAttribute(VertexDescription.Semantics.M) && !point.hasAttribute(VertexDescription.Semantics.ID), "Only 2D points with no ID nor M attribute are supported"); output.appendByte(GeometrySerializationType.POINT.code()); if (!point.isEmpty()) { output.appendDouble(point.getX()); output.appendDouble(point.getY()); } else { output.appendDouble(NaN); output.appendDouble(NaN); } }
Example 4
Source File: EncodedPolylineFunctions.java From presto with Apache License 2.0 | 5 votes |
private static void encode(long value, DynamicSliceOutput output) { value = value < 0 ? ~(value << 1) : value << 1; while (value >= 0x20) { output.appendByte((byte) ((0x20 | (value & 0x1f)) + 63)); value >>= 5; } output.appendByte((byte) (value + 63)); }
Example 5
Source File: GeometrySerde.java From presto with Apache License 2.0 | 5 votes |
public static Slice serialize(Envelope envelope) { requireNonNull(envelope, "envelope is null"); verify(!envelope.isEmpty()); DynamicSliceOutput output = new DynamicSliceOutput(100); output.appendByte(GeometrySerializationType.ENVELOPE.code()); writeEnvelopeCoordinates(output, envelope); return output.slice(); }
Example 6
Source File: GeometrySerde.java From presto with Apache License 2.0 | 5 votes |
private static void writeSimpleGeometry(DynamicSliceOutput output, GeometrySerializationType type, OGCGeometry geometry) { output.appendByte(type.code()); Geometry esriGeometry = requireNonNull(geometry.getEsriGeometry(), "esriGeometry is null"); byte[] shape = geometryToEsriShape(esriGeometry); output.appendBytes(shape); }