use of org.apache.hadoop.hive.metastore.api.ColumnStatisticsData in project hive by apache.
the class TestHBaseStoreBitVector method mockLongStats.
private static ColumnStatisticsObj mockLongStats(int i) {
long high = 120938479124L + 100 * i;
long low = -12341243213412124L - 50 * i;
long nulls = 23 + i;
long dVs = 213L + 10 * i;
String bitVectors = "{0, 1, 2, 3, 4, 5, 6, 7, 8}{1, 2, 3, 4, 5, 6, 7, 8}";
ColumnStatisticsObj colStatsObj = new ColumnStatisticsObj();
colStatsObj.setColName(LONG_COL);
colStatsObj.setColType(LONG_TYPE);
ColumnStatisticsData data = new ColumnStatisticsData();
LongColumnStatsData longData = new LongColumnStatsData();
longData.setHighValue(high);
longData.setLowValue(low);
longData.setNumNulls(nulls);
longData.setNumDVs(dVs);
longData.setBitVectors(bitVectors);
data.setLongStats(longData);
colStatsObj.setStatsData(data);
return colStatsObj;
}
use of org.apache.hadoop.hive.metastore.api.ColumnStatisticsData in project hive by apache.
the class TestHBaseStoreBitVector method doubleTableStatistics.
@Test
public void doubleTableStatistics() throws Exception {
createMockTable(DOUBLE_COL, DOUBLE_TYPE);
ColumnStatistics stats = new ColumnStatistics();
// Get a default ColumnStatisticsDesc for table level stats
ColumnStatisticsDesc desc = getMockTblColStatsDesc();
stats.setStatsDesc(desc);
// Get one of the pre-created ColumnStatisticsObj
ColumnStatisticsObj obj = doubleColStatsObjs.get(0);
DoubleColumnStatsData doubleData = obj.getStatsData().getDoubleStats();
// Add to DB
stats.addToStatsObj(obj);
store.updateTableColumnStatistics(stats);
// Get from DB
ColumnStatistics statsFromDB = store.getTableColumnStatistics(DB, TBL, Arrays.asList(DOUBLE_COL));
// Compare ColumnStatisticsDesc
Assert.assertEquals(desc.getLastAnalyzed(), statsFromDB.getStatsDesc().getLastAnalyzed());
Assert.assertEquals(DB, statsFromDB.getStatsDesc().getDbName());
Assert.assertEquals(TBL, statsFromDB.getStatsDesc().getTableName());
Assert.assertTrue(statsFromDB.getStatsDesc().isIsTblLevel());
// Compare ColumnStatisticsObj
Assert.assertEquals(1, statsFromDB.getStatsObjSize());
ColumnStatisticsObj objFromDB = statsFromDB.getStatsObj().get(0);
ColumnStatisticsData dataFromDB = objFromDB.getStatsData();
// Compare ColumnStatisticsData
Assert.assertEquals(ColumnStatisticsData._Fields.DOUBLE_STATS, dataFromDB.getSetField());
// Compare DoubleColumnStatsData
DoubleColumnStatsData doubleDataFromDB = dataFromDB.getDoubleStats();
Assert.assertEquals(doubleData.getHighValue(), doubleDataFromDB.getHighValue(), 0.01);
Assert.assertEquals(doubleData.getLowValue(), doubleDataFromDB.getLowValue(), 0.01);
Assert.assertEquals(doubleData.getNumNulls(), doubleDataFromDB.getNumNulls());
Assert.assertEquals(doubleData.getNumDVs(), doubleDataFromDB.getNumDVs());
Assert.assertEquals(doubleData.getBitVectors(), doubleDataFromDB.getBitVectors());
}
use of org.apache.hadoop.hive.metastore.api.ColumnStatisticsData in project hive by apache.
the class TestHBaseStoreBitVector method longTableStatistics.
@Test
public void longTableStatistics() throws Exception {
createMockTable(LONG_COL, LONG_TYPE);
ColumnStatistics stats = new ColumnStatistics();
// Get a default ColumnStatisticsDesc for table level stats
ColumnStatisticsDesc desc = getMockTblColStatsDesc();
stats.setStatsDesc(desc);
// Get one of the pre-created ColumnStatisticsObj
ColumnStatisticsObj obj = longColStatsObjs.get(0);
LongColumnStatsData longData = obj.getStatsData().getLongStats();
// Add to DB
stats.addToStatsObj(obj);
store.updateTableColumnStatistics(stats);
// Get from DB
ColumnStatistics statsFromDB = store.getTableColumnStatistics(DB, TBL, Arrays.asList(LONG_COL));
// Compare ColumnStatisticsDesc
Assert.assertEquals(desc.getLastAnalyzed(), statsFromDB.getStatsDesc().getLastAnalyzed());
Assert.assertEquals(DB, statsFromDB.getStatsDesc().getDbName());
Assert.assertEquals(TBL, statsFromDB.getStatsDesc().getTableName());
Assert.assertTrue(statsFromDB.getStatsDesc().isIsTblLevel());
// Compare ColumnStatisticsObj
Assert.assertEquals(1, statsFromDB.getStatsObjSize());
ColumnStatisticsObj objFromDB = statsFromDB.getStatsObj().get(0);
ColumnStatisticsData dataFromDB = objFromDB.getStatsData();
// Compare ColumnStatisticsData
Assert.assertEquals(ColumnStatisticsData._Fields.LONG_STATS, dataFromDB.getSetField());
// Compare LongColumnStatsData
LongColumnStatsData longDataFromDB = dataFromDB.getLongStats();
Assert.assertEquals(longData.getHighValue(), longDataFromDB.getHighValue());
Assert.assertEquals(longData.getLowValue(), longDataFromDB.getLowValue());
Assert.assertEquals(longData.getNumNulls(), longDataFromDB.getNumNulls());
Assert.assertEquals(longData.getNumDVs(), longDataFromDB.getNumDVs());
Assert.assertEquals(longData.getBitVectors(), longDataFromDB.getBitVectors());
}
use of org.apache.hadoop.hive.metastore.api.ColumnStatisticsData in project hive by apache.
the class TestHBaseStoreBitVector method decimalTableStatistics.
@Test
public void decimalTableStatistics() throws Exception {
createMockTable(DECIMAL_COL, DECIMAL_TYPE);
ColumnStatistics stats = new ColumnStatistics();
// Get a default ColumnStatisticsDesc for table level stats
ColumnStatisticsDesc desc = getMockTblColStatsDesc();
stats.setStatsDesc(desc);
// Get one of the pre-created ColumnStatisticsObj
ColumnStatisticsObj obj = decimalColStatsObjs.get(0);
DecimalColumnStatsData decimalData = obj.getStatsData().getDecimalStats();
// Add to DB
stats.addToStatsObj(obj);
store.updateTableColumnStatistics(stats);
// Get from DB
ColumnStatistics statsFromDB = store.getTableColumnStatistics(DB, TBL, Arrays.asList(DECIMAL_COL));
// Compare ColumnStatisticsDesc
Assert.assertEquals(desc.getLastAnalyzed(), statsFromDB.getStatsDesc().getLastAnalyzed());
Assert.assertEquals(DB, statsFromDB.getStatsDesc().getDbName());
Assert.assertEquals(TBL, statsFromDB.getStatsDesc().getTableName());
Assert.assertTrue(statsFromDB.getStatsDesc().isIsTblLevel());
// Compare ColumnStatisticsObj
Assert.assertEquals(1, statsFromDB.getStatsObjSize());
ColumnStatisticsObj objFromDB = statsFromDB.getStatsObj().get(0);
ColumnStatisticsData dataFromDB = objFromDB.getStatsData();
// Compare ColumnStatisticsData
Assert.assertEquals(ColumnStatisticsData._Fields.DECIMAL_STATS, dataFromDB.getSetField());
// Compare DecimalColumnStatsData
DecimalColumnStatsData decimalDataFromDB = dataFromDB.getDecimalStats();
Assert.assertEquals(decimalData.getHighValue(), decimalDataFromDB.getHighValue());
Assert.assertEquals(decimalData.getLowValue(), decimalDataFromDB.getLowValue());
Assert.assertEquals(decimalData.getNumNulls(), decimalDataFromDB.getNumNulls());
Assert.assertEquals(decimalData.getNumDVs(), decimalDataFromDB.getNumDVs());
Assert.assertEquals(decimalData.getBitVectors(), decimalDataFromDB.getBitVectors());
}
use of org.apache.hadoop.hive.metastore.api.ColumnStatisticsData in project hive by apache.
the class TestHBaseStoreBitVector method mockDecimalStats.
private static ColumnStatisticsObj mockDecimalStats(int i) {
Decimal high = new Decimal();
high.setScale((short) 3);
String strHigh = String.valueOf(3876 + 100 * i);
high.setUnscaled(strHigh.getBytes());
Decimal low = new Decimal();
low.setScale((short) 3);
String strLow = String.valueOf(38 + i);
low.setUnscaled(strLow.getBytes());
long nulls = 13 + i;
long dVs = 923947293L + 100 * i;
String bitVectors = "{0, 1, 2, 3, 4, 5, 6, 7, 8}{0, 1, 2, 4, 5, 6, 7, 8}";
ColumnStatisticsObj colStatsObj = new ColumnStatisticsObj();
colStatsObj.setColName(DECIMAL_COL);
colStatsObj.setColType(DECIMAL_TYPE);
ColumnStatisticsData data = new ColumnStatisticsData();
DecimalColumnStatsData decimalData = new DecimalColumnStatsData();
decimalData.setHighValue(high);
decimalData.setLowValue(low);
decimalData.setNumNulls(nulls);
decimalData.setNumDVs(dVs);
decimalData.setBitVectors(bitVectors);
data.setDecimalStats(decimalData);
colStatsObj.setStatsData(data);
return colStatsObj;
}
Aggregations