static GenericColumnSerializer createLongColumnSerializer( SegmentWriteOutMedium segmentWriteOutMedium, String columnName, IndexSpec indexSpec ) { // If using default values for null use LongColumnSerializer to allow rollback to previous versions. if (NullHandling.replaceWithDefault()) { return LongColumnSerializer.create( segmentWriteOutMedium, columnName, indexSpec.getMetricCompression(), indexSpec.getLongEncoding() ); } else { return LongColumnSerializerV2.create( segmentWriteOutMedium, columnName, indexSpec.getMetricCompression(), indexSpec.getLongEncoding(), indexSpec.getBitmapSerdeFactory() ); } }
@Test public void testSerde() throws Exception { final ObjectMapper objectMapper = new DefaultObjectMapper(); final String json = "{ \"bitmap\" : { \"type\" : \"roaring\" }, \"dimensionCompression\" : \"lz4\", \"metricCompression\" : \"lzf\"" + ", \"longEncoding\" : \"auto\" }"; final IndexSpec spec = objectMapper.readValue(json, IndexSpec.class); Assert.assertEquals(new RoaringBitmapSerdeFactory(null), spec.getBitmapSerdeFactory()); Assert.assertEquals(CompressionStrategy.LZ4, spec.getDimensionCompression()); Assert.assertEquals(CompressionStrategy.LZF, spec.getMetricCompression()); Assert.assertEquals(CompressionFactory.LongEncodingStrategy.AUTO, spec.getLongEncoding()); Assert.assertEquals(spec, objectMapper.readValue(objectMapper.writeValueAsBytes(spec), IndexSpec.class)); }
@Test public void testDefaults() { final IndexSpec spec = new IndexSpec(); Assert.assertEquals(CompressionStrategy.LZ4, spec.getDimensionCompression()); Assert.assertEquals(CompressionStrategy.LZ4, spec.getMetricCompression()); Assert.assertEquals(CompressionFactory.LongEncodingStrategy.LONGS, spec.getLongEncoding()); } }
CompressionStrategy.LZF : CompressionStrategy.LZ4, CompressionFactory.LongEncodingStrategy.LONGS.equals(indexSpec.getLongEncoding()) ? CompressionFactory.LongEncodingStrategy.AUTO : CompressionFactory.LongEncodingStrategy.LONGS
CompressionStrategy.LZF : CompressionStrategy.LZ4, CompressionFactory.LongEncodingStrategy.LONGS.equals(indexSpec.getLongEncoding()) ? CompressionFactory.LongEncodingStrategy.AUTO : CompressionFactory.LongEncodingStrategy.LONGS
static GenericColumnSerializer createLongColumnSerializer( SegmentWriteOutMedium segmentWriteOutMedium, String columnName, IndexSpec indexSpec ) { // If using default values for null use LongColumnSerializer to allow rollback to previous versions. if (NullHandling.replaceWithDefault()) { return LongColumnSerializer.create( segmentWriteOutMedium, columnName, indexSpec.getMetricCompression(), indexSpec.getLongEncoding() ); } else { return LongColumnSerializerV2.create( segmentWriteOutMedium, columnName, indexSpec.getMetricCompression(), indexSpec.getLongEncoding(), indexSpec.getBitmapSerdeFactory() ); } }