@@ -21,20 +21,27 @@ public record Encoding(int encoding, byte[] data) {
2121 public static final byte ENCODING_STATIC_DENSE = 1 ;
2222 public static final byte ENCODING_STATIC_SPARSE8 = 2 ;
2323 public static final byte ENCODING_STATIC_SPARSE16 = 3 ;
24- public static final byte ENCODING_STATIC_SPARSE32 = 4 ;
25- public static final byte ENCODING_POOL_CONSTANT = 5 ;
26- public static final byte ENCODING_POOL8_DENSE = 6 ;
27- public static final byte ENCODING_POOL16_DENSE = 7 ;
28- public static final byte ENCODING_POOL32_DENSE = 8 ;
29- public static final byte ENCODING_POOL8_SPARSE8 = 9 ;
30- public static final byte ENCODING_POOL8_SPARSE16 = 10 ;
31- public static final byte ENCODING_POOL8_SPARSE32 = 11 ;
32- public static final byte ENCODING_POOL16_SPARSE8 = 12 ;
33- public static final byte ENCODING_POOL16_SPARSE16 = 13 ;
34- public static final byte ENCODING_POOL16_SPARSE32 = 14 ;
35- public static final byte ENCODING_POOL32_SPARSE8 = 15 ;
36- public static final byte ENCODING_POOL32_SPARSE16 = 16 ;
37- public static final byte ENCODING_POOL32_SPARSE32 = 17 ;
24+ public static final byte ENCODING_STATIC_SPARSE24 = 4 ; // not supported
25+ public static final byte ENCODING_STATIC_SPARSE32 = 5 ;
26+ public static final byte ENCODING_POOL_CONSTANT = 6 ;
27+ public static final byte ENCODING_POOL1_DENSE = 7 ;
28+ public static final byte ENCODING_POOL2_DENSE = 8 ;
29+ public static final byte ENCODING_POOL4_DENSE = 9 ;
30+ public static final byte ENCODING_POOL8_DENSE = 10 ;
31+ public static final byte ENCODING_POOL16_DENSE = 11 ;
32+ public static final byte ENCODING_POOL32_DENSE = 12 ;
33+ public static final byte ENCODING_POOL8_SPARSE8 = 13 ;
34+ public static final byte ENCODING_POOL8_SPARSE16 = 14 ;
35+ public static final byte ENCODING_POOL8_SPARSE24 = 15 ; // not supported
36+ public static final byte ENCODING_POOL8_SPARSE32 = 16 ;
37+ public static final byte ENCODING_POOL16_SPARSE8 = 17 ;
38+ public static final byte ENCODING_POOL16_SPARSE16 = 18 ;
39+ public static final byte ENCODING_POOL16_SPARSE24 = 19 ; // not supported
40+ public static final byte ENCODING_POOL16_SPARSE32 = 20 ;
41+ public static final byte ENCODING_POOL32_SPARSE8 = 21 ;
42+ public static final byte ENCODING_POOL32_SPARSE16 = 22 ;
43+ public static final byte ENCODING_POOL32_SPARSE24 = 23 ; // not supported
44+ public static final byte ENCODING_POOL32_SPARSE32 = 24 ;
3845
3946 public Encoding (boolean pooled , int constant , byte [] data ) {
4047 this (encodingConstant (pooled , constant ), data );
@@ -84,6 +91,12 @@ private static int encodingDense(boolean pooled, int entryWidth, int bitwidth) {
8491 //
8592 if (!pooled ) {
8693 opcode = ENCODING_STATIC_DENSE ;
94+ } else if (entryWidth <= 1 ) {
95+ opcode = ENCODING_POOL1_DENSE ;
96+ } else if (entryWidth <= 2 ) {
97+ opcode = ENCODING_POOL2_DENSE ;
98+ } else if (entryWidth <= 4 ) {
99+ opcode = ENCODING_POOL4_DENSE ;
87100 } else if (entryWidth <= 8 ) {
88101 opcode = ENCODING_POOL8_DENSE ;
89102 } else if (entryWidth <= 16 ) {
@@ -116,7 +129,7 @@ private static int encodingConstant(boolean pooled, int constant) {
116129 * @param buffer Column data
117130 * @return Encoded column data
118131 */
119- public static Encoding of (int [] buffer ) {
132+ public static Encoding of (String name , int [] buffer ) {
120133 long maxValue = Util .maxValue (buffer );
121134 long minValue = Util .minValue (buffer );
122135 int numberOfBlocks = Util .countNumberOfBlocks (buffer );
@@ -145,7 +158,7 @@ public static Encoding of(int[] buffer) {
145158 * @param buffer Column data
146159 * @return Encoded column data
147160 */
148- public static Encoding of (int [] buffer , int bitwidth , BytesHeap heap ) {
161+ public static Encoding of (String name , int [] buffer , int bitwidth , BytesHeap heap ) {
149162 long maxValue = Util .maxValue (buffer );
150163 long minValue = Util .minValue (buffer );
151164 int numberOfBlocks = Util .countNumberOfBlocks (buffer );
@@ -426,7 +439,7 @@ private static byte[] encodeU8Sparse8(int numBlocks, int[] buffer) {
426439 * Encode 8bit values using a "sparse encoding" consisting of tuples (u8 value, u16 n), where each
427440 * represents n copies of the given value.
428441 *
429- * @param buffer Contains only values in {0,1,...65534,65535 }.
442+ * @param buffer Contains only values in {0,1,...254,255 }.
430443 * @return byte encoding of the data
431444 */
432445 private static byte [] encodeU8Sparse16 (int numBlocks , int [] buffer ) {
0 commit comments