public static void allocateFromNumbers( Collection<DynamicRecord> target, Object array, DynamicRecordAllocator recordAllocator ) { byte[] bytes = encodeFromNumbers( array, 0 ); allocateRecordsFromBytes( target, bytes, recordAllocator ); }
public static byte[] encodeLocalTimeArray( LocalTime[] times ) { long[] data = new long[times.length]; for ( int i = 0; i < data.length; i++ ) { data[i] = times[i].toNanoOfDay(); } TemporalHeader header = new TemporalHeader( TemporalType.TEMPORAL_LOCAL_TIME.temporalType ); byte[] bytes = DynamicArrayStore.encodeFromNumbers( data, DynamicArrayStore.TEMPORAL_HEADER_SIZE ); header.writeArrayHeaderTo( bytes ); return bytes; }
public static byte[] encodeDateArray( LocalDate[] dates ) { long[] data = new long[dates.length]; for ( int i = 0; i < data.length; i++ ) { data[i] = dates[i].toEpochDay(); } TemporalHeader header = new TemporalHeader( TemporalType.TEMPORAL_DATE.temporalType ); byte[] bytes = DynamicArrayStore.encodeFromNumbers( data, DynamicArrayStore.TEMPORAL_HEADER_SIZE ); header.writeArrayHeaderTo( bytes ); return bytes; }
public static byte[] encodeLocalDateTimeArray( LocalDateTime[] dateTimes ) { long[] data = new long[dateTimes.length * BLOCKS_LOCAL_DATETIME]; for ( int i = 0; i < dateTimes.length; i++ ) { data[i * BLOCKS_LOCAL_DATETIME] = dateTimes[i].toEpochSecond( UTC ); data[i * BLOCKS_LOCAL_DATETIME + 1] = dateTimes[i].getNano(); } TemporalHeader header = new TemporalHeader( TemporalType.TEMPORAL_LOCAL_DATE_TIME.temporalType ); byte[] bytes = DynamicArrayStore.encodeFromNumbers( data, DynamicArrayStore.TEMPORAL_HEADER_SIZE ); header.writeArrayHeaderTo( bytes ); return bytes; }
public static byte[] encodeTimeArray( OffsetTime[] times ) { // We could store this in dateTimes.length * 1.5 if we wanted long[] data = new long[(int) (Math.ceil( times.length * BLOCKS_TIME ))]; int i; for ( i = 0; i < times.length; i++ ) { data[i * BLOCKS_TIME] = times[i].toLocalTime().toNanoOfDay(); data[i * BLOCKS_TIME + 1] = times[i].getOffset().getTotalSeconds(); } TemporalHeader header = new TemporalHeader( TemporalType.TEMPORAL_TIME.temporalType ); byte[] bytes = DynamicArrayStore.encodeFromNumbers( data, DynamicArrayStore.TEMPORAL_HEADER_SIZE ); header.writeArrayHeaderTo( bytes ); return bytes; }
public static byte[] encodeDurationArray( DurationValue[] durations ) { long[] data = new long[durations.length * BLOCKS_DURATION]; for ( int i = 0; i < durations.length; i++ ) { data[i * BLOCKS_DURATION] = durations[i].get( ChronoUnit.MONTHS ); data[i * BLOCKS_DURATION + 1] = durations[i].get( ChronoUnit.DAYS ); data[i * BLOCKS_DURATION + 2] = durations[i].get( ChronoUnit.SECONDS ); data[i * BLOCKS_DURATION + 3] = durations[i].get( ChronoUnit.NANOS ); } TemporalHeader header = new TemporalHeader( TemporalType.TEMPORAL_DURATION.temporalType ); byte[] bytes = DynamicArrayStore.encodeFromNumbers( data, DynamicArrayStore.TEMPORAL_HEADER_SIZE ); header.writeArrayHeaderTo( bytes ); return bytes; }
public static byte[] encodePointArray( PointValue[] points ) { int dimension = points[0].coordinate().length; CoordinateReferenceSystem crs = points[0].getCoordinateReferenceSystem(); for ( int i = 1; i < points.length; i++ ) { if ( dimension != points[i].coordinate().length ) { throw new IllegalArgumentException( "Attempting to store array of points with inconsistent dimension. Point " + i + " has a different dimension." ); } if ( !crs.equals( points[i].getCoordinateReferenceSystem() ) ) { throw new IllegalArgumentException( "Attempting to store array of points with inconsistent CRS. Point " + i + " has a different CRS." ); } } double[] data = new double[points.length * dimension]; for ( int i = 0; i < data.length; i++ ) { data[i] = points[i / dimension].coordinate()[i % dimension]; } GeometryHeader geometryHeader = new GeometryHeader( GeometryType.GEOMETRY_POINT.gtype, dimension, crs ); byte[] bytes = DynamicArrayStore.encodeFromNumbers( data, DynamicArrayStore.GEOMETRY_HEADER_SIZE ); geometryHeader.writeArrayHeaderTo( bytes ); return bytes; }
public static byte[] encodeDateTimeArray( ZonedDateTime[] dateTimes ) { // We could store this in dateTimes.length * 2.5 if we wanted long[] data = new long[dateTimes.length * BLOCKS_DATETIME]; int i; for ( i = 0; i < dateTimes.length; i++ ) { data[i * BLOCKS_DATETIME] = dateTimes[i].toEpochSecond(); data[i * BLOCKS_DATETIME + 1] = dateTimes[i].getNano(); if ( dateTimes[i].getZone() instanceof ZoneOffset ) { ZoneOffset offset = (ZoneOffset) dateTimes[i].getZone(); int secondOffset = offset.getTotalSeconds(); // Set lowest bit to 1 means offset data[i * BLOCKS_DATETIME + 2] = secondOffset << 1 | 1L; } else { String timeZoneId = dateTimes[i].getZone().getId(); short zoneNumber = TimeZones.map( timeZoneId ); // Set lowest bit to 0 means zone id data[i * BLOCKS_DATETIME + 2] = zoneNumber << 1; } } TemporalHeader header = new TemporalHeader( TemporalType.TEMPORAL_DATE_TIME.temporalType ); byte[] bytes = DynamicArrayStore.encodeFromNumbers( data, DynamicArrayStore.TEMPORAL_HEADER_SIZE ); header.writeArrayHeaderTo( bytes ); return bytes; }
public static void allocateFromNumbers( Collection<DynamicRecord> target, Object array, DynamicRecordAllocator recordAllocator ) { byte[] bytes = encodeFromNumbers( array, 0 ); allocateRecordsFromBytes( target, bytes, recordAllocator ); }
public static byte[] encodeDateArray( LocalDate[] dates ) { long[] data = new long[dates.length]; for ( int i = 0; i < data.length; i++ ) { data[i] = dates[i].toEpochDay(); } TemporalHeader header = new TemporalHeader( TemporalType.TEMPORAL_DATE.temporalType ); byte[] bytes = DynamicArrayStore.encodeFromNumbers( data, DynamicArrayStore.TEMPORAL_HEADER_SIZE ); header.writeArrayHeaderTo( bytes ); return bytes; }
public static byte[] encodeLocalTimeArray( LocalTime[] times ) { long[] data = new long[times.length]; for ( int i = 0; i < data.length; i++ ) { data[i] = times[i].toNanoOfDay(); } TemporalHeader header = new TemporalHeader( TemporalType.TEMPORAL_LOCAL_TIME.temporalType ); byte[] bytes = DynamicArrayStore.encodeFromNumbers( data, DynamicArrayStore.TEMPORAL_HEADER_SIZE ); header.writeArrayHeaderTo( bytes ); return bytes; }
public static byte[] encodeLocalDateTimeArray( LocalDateTime[] dateTimes ) { long[] data = new long[dateTimes.length * BLOCKS_LOCAL_DATETIME]; for ( int i = 0; i < dateTimes.length; i++ ) { data[i * BLOCKS_LOCAL_DATETIME] = dateTimes[i].toEpochSecond( UTC ); data[i * BLOCKS_LOCAL_DATETIME + 1] = dateTimes[i].getNano(); } TemporalHeader header = new TemporalHeader( TemporalType.TEMPORAL_LOCAL_DATE_TIME.temporalType ); byte[] bytes = DynamicArrayStore.encodeFromNumbers( data, DynamicArrayStore.TEMPORAL_HEADER_SIZE ); header.writeArrayHeaderTo( bytes ); return bytes; }
public static byte[] encodeTimeArray( OffsetTime[] times ) { // We could store this in dateTimes.length * 1.5 if we wanted long[] data = new long[(int) (Math.ceil( times.length * BLOCKS_TIME ))]; int i; for ( i = 0; i < times.length; i++ ) { data[i * BLOCKS_TIME] = times[i].toLocalTime().toNanoOfDay(); data[i * BLOCKS_TIME + 1] = times[i].getOffset().getTotalSeconds(); } TemporalHeader header = new TemporalHeader( TemporalType.TEMPORAL_TIME.temporalType ); byte[] bytes = DynamicArrayStore.encodeFromNumbers( data, DynamicArrayStore.TEMPORAL_HEADER_SIZE ); header.writeArrayHeaderTo( bytes ); return bytes; }
public static byte[] encodeDurationArray( DurationValue[] durations ) { long[] data = new long[durations.length * BLOCKS_DURATION]; for ( int i = 0; i < durations.length; i++ ) { data[i * BLOCKS_DURATION] = durations[i].get( ChronoUnit.MONTHS ); data[i * BLOCKS_DURATION + 1] = durations[i].get( ChronoUnit.DAYS ); data[i * BLOCKS_DURATION + 2] = durations[i].get( ChronoUnit.SECONDS ); data[i * BLOCKS_DURATION + 3] = durations[i].get( ChronoUnit.NANOS ); } TemporalHeader header = new TemporalHeader( TemporalType.TEMPORAL_DURATION.temporalType ); byte[] bytes = DynamicArrayStore.encodeFromNumbers( data, DynamicArrayStore.TEMPORAL_HEADER_SIZE ); header.writeArrayHeaderTo( bytes ); return bytes; }
public static byte[] encodePointArray( PointValue[] points ) { int dimension = points[0].coordinate().length; CoordinateReferenceSystem crs = points[0].getCoordinateReferenceSystem(); for ( int i = 1; i < points.length; i++ ) { if ( dimension != points[i].coordinate().length ) { throw new IllegalArgumentException( "Attempting to store array of points with inconsistent dimension. Point " + i + " has a different dimension." ); } if ( !crs.equals( points[i].getCoordinateReferenceSystem() ) ) { throw new IllegalArgumentException( "Attempting to store array of points with inconsistent CRS. Point " + i + " has a different CRS." ); } } double[] data = new double[points.length * dimension]; for ( int i = 0; i < data.length; i++ ) { data[i] = points[i / dimension].coordinate()[i % dimension]; } GeometryHeader geometryHeader = new GeometryHeader( GeometryType.GEOMETRY_POINT.gtype, dimension, crs ); byte[] bytes = DynamicArrayStore.encodeFromNumbers( data, DynamicArrayStore.GEOMETRY_HEADER_SIZE ); geometryHeader.writeArrayHeaderTo( bytes ); return bytes; }
public static byte[] encodeDateTimeArray( ZonedDateTime[] dateTimes ) { // We could store this in dateTimes.length * 2.5 if we wanted long[] data = new long[dateTimes.length * BLOCKS_DATETIME]; int i; for ( i = 0; i < dateTimes.length; i++ ) { data[i * BLOCKS_DATETIME] = dateTimes[i].toEpochSecond(); data[i * BLOCKS_DATETIME + 1] = dateTimes[i].getNano(); if ( dateTimes[i].getZone() instanceof ZoneOffset ) { ZoneOffset offset = (ZoneOffset) dateTimes[i].getZone(); int secondOffset = offset.getTotalSeconds(); // Set lowest bit to 1 means offset data[i * BLOCKS_DATETIME + 2] = secondOffset << 1 | 1L; } else { String timeZoneId = dateTimes[i].getZone().getId(); short zoneNumber = TimeZones.map( timeZoneId ); // Set lowest bit to 0 means zone id data[i * BLOCKS_DATETIME + 2] = zoneNumber << 1; } } TemporalHeader header = new TemporalHeader( TemporalType.TEMPORAL_DATE_TIME.temporalType ); byte[] bytes = DynamicArrayStore.encodeFromNumbers( data, DynamicArrayStore.TEMPORAL_HEADER_SIZE ); header.writeArrayHeaderTo( bytes ); return bytes; }