encoder.js
function encodeArray_NUM_DELTA_FLOAT( encoder, data, n_from, n_to, pivot, f_scale ) {

	//
	// Pivot Float Numeric Array (NUM_DELTA_FLOAT)
	//
	// ...  ....       .   +   Data Length  +   Mean Value  +  Scale
	// 001 [DWS_TYPE] [LN]    [16bit/32bit]      [F32/F64]     [F32]
	//

	// Get downscale type
	var n_delta_type = deltaEncTypeFloat( n_from, n_to );
	if (n_delta_type === undefined) {
		throw new Errors.EncodeError('Non-viable float delta value from '+_NUMTYPE[n_from]+' to '+_NUMTYPE[n_to]+'!');
	}

	encoder.counters.arr_delta_float+=1;
	encoder.log(LOG.ARR, "array.numeric.delta.float, len="+data.length+
		", from="+_NUMTYPE[n_from]+", to="+_NUMTYPE[n_to]+
		", type="+_NUMTYPE_DOWNSCALE_DELTA_FLOAT[n_delta_type]+" ("+n_delta_type+")"+
		", pivot="+pivot+", scale="+f_scale);

	if (data.length < UINT16_MAX) { // 16-bit length prefix
		encoder.stream8.write( pack1b( ARR_OP.NUM_DELTA_FLOAT | NUMTYPE_LN.UINT16 | (n_delta_type << 1) ) );
		encoder.stream16.write( pack2b( data.length, false ) );
		encoder.counters.arr_hdr+=3;
	} else { // 32-bit length prefix
		encoder.stream8.write( pack1b( ARR_OP.NUM_DELTA_FLOAT | NUMTYPE_LN.UINT32 | (n_delta_type << 1) ) );
		encoder.stream32.write( pack4b( data.length, false ) );
		encoder.counters.arr_hdr+=5;
	}

	// Write pivot value
	pickStream( encoder, n_from )
		.write( packByNumType[n_from]( pivot ) );

	// Write scale
	encoder.stream64.write( pack8f( f_scale ) );

	// Pivot-encode floats
	var pivot_array = new NUMTYPE_CLASS[n_to]( data.length );
	for (var i=1; i<data.length; ++i) {
		pivot_array[i] = (data[i] - pivot) / f_scale;
		// console.log(">>>", data[i],"->", pivot_array[i]);
	}

	// Envode pivot array
	pickStream( encoder, n_to)
		.write( packTypedArray( pivot_array ) );

}
function encodeArray_NUM_DELTA_FLOAT( encoder, data, n_from, n_to, pivot, f_scale ) {

	//
	// Pivot Float Numeric Array (NUM_DELTA_FLOAT)
	//
	// ...  ....       .   +   Data Length  +   Mean Value  +  Scale
	// 001 [DWS_TYPE] [LN]    [16bit/32bit]      [F32/F64]     [F32]
	//

	// Get downscale type
	var n_delta_type = deltaEncTypeFloat( n_from, n_to );
	if (n_delta_type === undefined) {
		throw new Errors.EncodeError('Non-viable float delta value from '+_NUMTYPE[n_from]+' to '+_NUMTYPE[n_to]+'!');
	}

	encoder.counters.arr_delta_float+=1;
	encoder.log(LOG.ARR, "array.numeric.delta.float, len="+data.length+
		", from="+_NUMTYPE[n_from]+", to="+_NUMTYPE[n_to]+
		", type="+_NUMTYPE_DOWNSCALE_DELTA_FLOAT[n_delta_type]+" ("+n_delta_type+")"+
		", pivot="+pivot+", scale="+f_scale);

	if (data.length < UINT16_MAX) { // 16-bit length prefix
		encoder.stream8.write( pack1b( ARR_OP.NUM_DELTA_FLOAT | NUMTYPE_LN.UINT16 | (n_delta_type << 1) ) );
		encoder.stream16.write( pack2b( data.length, false ) );
		encoder.counters.arr_hdr+=3;
	} else { // 32-bit length prefix
		encoder.stream8.write( pack1b( ARR_OP.NUM_DELTA_FLOAT | NUMTYPE_LN.UINT32 | (n_delta_type << 1) ) );
		encoder.stream32.write( pack4b( data.length, false ) );
		encoder.counters.arr_hdr+=5;
	}

	// Write pivot value
	pickStream( encoder, n_from )
		.write( packByNumType[n_from]( pivot ) );

	// Write scale
	encoder.stream64.write( pack8f( f_scale ) );

	// Pivot-encode floats
	var pivot_array = new NUMTYPE_CLASS[n_to]( data.length );
	for (var i=1; i<data.length; ++i) {
		pivot_array[i] = (data[i] - pivot) / f_scale;
		// console.log(">>>", data[i],"->", pivot_array[i]);
	}

	// Envode pivot array
	pickStream( encoder, n_to)
		.write( packTypedArray( pivot_array ) );

}
function encodeArray_NUM_DELTA_FLOAT ( encoder , data , n_from , n_to , pivot , f_scale ) { // // Pivot Float Numeric Array (NUM_DELTA_FLOAT) // // ...  ....       .   +   Data Length  +   Mean Value  +  Scale // 001 [DWS_TYPE] [LN]    [16bit/32bit]      [F32/F64]     [F32] // // Get downscale type var n_delta_type = deltaEncTypeFloat ( n_from , n_to ) ; if ( n_delta_type === undefined ) { throw new Errors . EncodeError ( 'Non-viable float delta value from ' + _NUMTYPE [ n_from ] + ' to ' + _NUMTYPE [ n_to ] + '!' ) ; } encoder . counters . arr_delta_float += 1 ; encoder . log ( LOG . ARR , "array.numeric.delta.float, len=" + data . length + ", from=" + _NUMTYPE [ n_from ] + ", to=" + _NUMTYPE [ n_to ] + ", type=" + _NUMTYPE_DOWNSCALE_DELTA_FLOAT [ n_delta_type ] + " (" + n_delta_type + ")" + ", pivot=" + pivot + ", scale=" + f_scale ) ; if ( data . length < UINT16_MAX ) { // 16-bit length prefix encoder . stream8 . write ( pack1b ( ARR_OP . NUM_DELTA_FLOAT | NUMTYPE_LN . UINT16 | ( n_delta_type << 1 ) ) ) ; encoder . stream16 . write ( pack2b ( data . length , false ) ) ; encoder . counters . arr_hdr += 3 ; } else { // 32-bit length prefix encoder . stream8 . write ( pack1b ( ARR_OP . NUM_DELTA_FLOAT | NUMTYPE_LN . UINT32 | ( n_delta_type << 1 ) ) ) ; encoder . stream32 . write ( pack4b ( data . length , false ) ) ; encoder . counters . arr_hdr += 5 ; } // Write pivot value pickStream ( encoder , n_from ) . write ( packByNumType [ n_from ] ( pivot ) ) ; // Write scale encoder . stream64 . write ( pack8f ( f_scale ) ) ; // Pivot-encode floats var pivot_array = new NUMTYPE_CLASS [ n_to ] ( data . length ) ; for ( var i = 1 ; i < data . length ; ++ i ) { pivot_array [ i ] = ( data [ i ] - pivot ) / f_scale ; // console.log(">>>", data[i],"->", pivot_array[i]); } // Envode pivot array pickStream ( encoder , n_to ) . write ( packTypedArray ( pivot_array ) ) ; }
Pivot-encode float array
Pivot - encode float array