public void testStringMerge() { TypeDescription schema = TypeDescription.createString(); ColumnStatisticsImpl stats1 = ColumnStatisticsImpl.create(schema); ColumnStatisticsImpl stats2 = ColumnStatisticsImpl.create(schema); stats1.updateString("bob"); stats1.updateString("david"); stats1.updateString("charles"); stats2.updateString("anne"); byte[] erin = new byte[] { 0, 1, 2, 3, 4, 5, 101, 114, 105, 110 }; stats2.updateString(erin, 6, 4, 5); Assert.Equal(24, ((StringColumnStatistics)stats2).getSum()); stats1.merge(stats2); StringColumnStatistics typed = (StringColumnStatistics)stats1; Assert.Equal("anne", typed.getMinimum()); Assert.Equal("erin", typed.getMaximum()); Assert.Equal(39, typed.getSum()); stats1.reset(); stats1.updateString("aaa"); stats1.updateString("zzz"); stats1.merge(stats2); Assert.Equal("aaa", typed.getMinimum()); Assert.Equal("zzz", typed.getMaximum()); }
public void testLongMerge() { TypeDescription schema = TypeDescription.createInt(); ColumnStatisticsImpl stats1 = ColumnStatisticsImpl.create(schema); ColumnStatisticsImpl stats2 = ColumnStatisticsImpl.create(schema); stats1.updateInteger(10, 2); stats2.updateInteger(1, 1); stats2.updateInteger(1000, 1); stats1.merge(stats2); IntegerColumnStatistics typed = (IntegerColumnStatistics)stats1; Assert.Equal(1, typed.getMinimum()); Assert.Equal(1000, typed.getMaximum()); stats1.reset(); stats1.updateInteger(-10, 1); stats1.updateInteger(10000, 1); stats1.merge(stats2); Assert.Equal(-10, typed.getMinimum()); Assert.Equal(10000, typed.getMaximum()); }
public void testDoubleMerge() { TypeDescription schema = TypeDescription.createDouble(); ColumnStatisticsImpl stats1 = ColumnStatisticsImpl.create(schema); ColumnStatisticsImpl stats2 = ColumnStatisticsImpl.create(schema); stats1.updateDouble(10.0); stats1.updateDouble(100.0); stats2.updateDouble(1.0); stats2.updateDouble(1000.0); stats1.merge(stats2); DoubleColumnStatistics typed = (DoubleColumnStatistics)stats1; Assert.Equal(1.0, typed.getMinimum(), 3); Assert.Equal(1000.0, typed.getMaximum(), 3); stats1.reset(); stats1.updateDouble(-10); stats1.updateDouble(10000); stats1.merge(stats2); Assert.Equal(-10, typed.getMinimum(), 3); Assert.Equal(10000, typed.getMaximum(), 3); }
public void testTimestampMerge() { TypeDescription schema = TypeDescription.createTimestamp(); ColumnStatisticsImpl stats1 = ColumnStatisticsImpl.create(schema); ColumnStatisticsImpl stats2 = ColumnStatisticsImpl.create(schema); stats1.updateTimestamp(10); stats1.updateTimestamp(100); stats2.updateTimestamp(1); stats2.updateTimestamp(1000); stats1.merge(stats2); TimestampColumnStatistics typed = (TimestampColumnStatistics)stats1; Assert.Equal(new Timestamp(1), typed.getMinimum()); Assert.Equal(new Timestamp(1000), typed.getMaximum()); stats1.reset(); stats1.updateTimestamp(new Timestamp(-10)); stats1.updateTimestamp(new Timestamp(10000)); stats1.merge(stats2); Assert.Equal(new Timestamp(-10), typed.getMinimum()); Assert.Equal(new Timestamp(10000), typed.getMaximum()); }
public void testDateMerge() { TypeDescription schema = TypeDescription.createDate(); ColumnStatisticsImpl stats1 = ColumnStatisticsImpl.create(schema); ColumnStatisticsImpl stats2 = ColumnStatisticsImpl.create(schema); stats1.updateDate(1000); stats1.updateDate(100); stats2.updateDate(10); stats2.updateDate(2000); stats1.merge(stats2); DateColumnStatistics typed = (DateColumnStatistics)stats1; Assert.Equal(new Date(10), typed.getMinimum()); Assert.Equal(new Date(2000), typed.getMaximum()); stats1.reset(); stats1.updateDate(-10); stats1.updateDate(10000); stats1.merge(stats2); Assert.Equal(new Date(-10), typed.getMinimum()); Assert.Equal(new Date(10000), typed.getMaximum()); }
public void testDecimalMerge() { TypeDescription schema = TypeDescription.createDecimal() .withPrecision(38).withScale(16); ColumnStatisticsImpl stats1 = ColumnStatisticsImpl.create(schema); ColumnStatisticsImpl stats2 = ColumnStatisticsImpl.create(schema); stats1.updateDecimal(HiveDecimal.create(10)); stats1.updateDecimal(HiveDecimal.create(100)); stats2.updateDecimal(HiveDecimal.create(1)); stats2.updateDecimal(HiveDecimal.create(1000)); stats1.merge(stats2); DecimalColumnStatistics typed = (DecimalColumnStatistics)stats1; Assert.Equal(1, typed.getMinimum().longValue()); Assert.Equal(1000, typed.getMaximum().longValue()); stats1.reset(); stats1.updateDecimal(HiveDecimal.create(-10)); stats1.updateDecimal(HiveDecimal.create(10000)); stats1.merge(stats2); Assert.Equal(-10, typed.getMinimum().longValue()); Assert.Equal(10000, typed.getMaximum().longValue()); }