use of org.apache.carbondata.core.datastore.page.encoding.adaptive.AdaptiveIntegralCodec in project carbondata by apache.
the class TestEncodingFactory method testSelectProperDeltaType.
@Test
public void testSelectProperDeltaType() {
PrimitivePageStatsCollector primitivePageStatsCollector = PrimitivePageStatsCollector.newInstance(DataTypes.LONG);
// for Byte
primitivePageStatsCollector.update((long) Byte.MAX_VALUE);
ColumnPageCodec columnPageCodec = DefaultEncodingFactory.selectCodecByAlgorithmForIntegral(primitivePageStatsCollector);
assert (columnPageCodec instanceof AdaptiveIntegralCodec);
assert (DataTypes.BYTE == ((AdaptiveIntegralCodec) columnPageCodec).getTargetDataType());
// for Short
primitivePageStatsCollector.update((long) Short.MAX_VALUE);
columnPageCodec = DefaultEncodingFactory.selectCodecByAlgorithmForIntegral(primitivePageStatsCollector);
assert (columnPageCodec instanceof AdaptiveIntegralCodec);
assert (DataTypes.SHORT == ((AdaptiveIntegralCodec) columnPageCodec).getTargetDataType());
// for int
primitivePageStatsCollector.update((long) Integer.MAX_VALUE);
columnPageCodec = DefaultEncodingFactory.selectCodecByAlgorithmForIntegral(primitivePageStatsCollector);
assert (columnPageCodec instanceof AdaptiveIntegralCodec);
assert (DataTypes.INT == ((AdaptiveIntegralCodec) columnPageCodec).getTargetDataType());
// for long
primitivePageStatsCollector.update(Long.MAX_VALUE);
columnPageCodec = DefaultEncodingFactory.selectCodecByAlgorithmForIntegral(primitivePageStatsCollector);
assert (columnPageCodec instanceof DirectCompressCodec);
assert ("DirectCompressCodec".equals(columnPageCodec.getName()));
}
Aggregations