private ColumnStatisticsObj getDummyLongColStat(String colName, int highVal, int lowVal, int numDVs, int numNulls) { ColumnStatisticsObj aggrColStats = new ColumnStatisticsObj(); aggrColStats.setColName(colName); aggrColStats.setColType("long"); LongColumnStatsData longStatsData = new LongColumnStatsData(); longStatsData.setHighValue(highVal); longStatsData.setLowValue(lowVal); longStatsData.setNumDVs(numDVs); longStatsData.setNumNulls(numNulls); ColumnStatisticsData aggrColStatsData = new ColumnStatisticsData(); aggrColStatsData.setLongStats(longStatsData); aggrColStats.setStatsData(aggrColStatsData); return aggrColStats; } }
public Object getFieldValue(_Fields field) { switch (field) { case LOW_VALUE: return getLowValue(); case HIGH_VALUE: return getHighValue(); case NUM_NULLS: return getNumNulls(); case NUM_DVS: return getNumDVs(); case BIT_VECTORS: return getBitVectors(); } throw new IllegalStateException(); }
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new IllegalArgumentException(); } switch (field) { case LOW_VALUE: return isSetLowValue(); case HIGH_VALUE: return isSetHighValue(); case NUM_NULLS: return isSetNumNulls(); case NUM_DVS: return isSetNumDVs(); case BIT_VECTORS: return isSetBitVectors(); } throw new IllegalStateException(); }
case LOW_VALUE: if (value == null) { unsetLowValue(); } else { setLowValue((Long)value); unsetHighValue(); } else { setHighValue((Long)value); unsetNumNulls(); } else { setNumNulls((Long)value); unsetNumDVs(); } else { setNumDVs((Long)value); unsetBitVectors(); } else { setBitVectors((ByteBuffer)value);
LongColumnStatsData oldLongStatsData = oldStatObj.getStatsData().getLongStats(); LongColumnStatsData newLongStatsData = newStatObj.getStatsData().getLongStats(); if (newLongStatsData.isSetHighValue()) { oldLongStatsData.setHighValue(newLongStatsData.getHighValue()); if (newLongStatsData.isSetLowValue()) { oldLongStatsData.setLowValue(newLongStatsData.getLowValue()); if (newLongStatsData.isSetNumNulls()) { oldLongStatsData.setNumNulls(newLongStatsData.getNumNulls()); if (newLongStatsData.isSetNumDVs()) { oldLongStatsData.setNumDVs(newLongStatsData.getNumDVs()); if (newLongStatsData.isSetBitVectors()) { oldLongStatsData.setBitVectors(newLongStatsData.getBitVectors());
OptionalLong min = longStatsData.isSetLowValue() ? OptionalLong.of(longStatsData.getLowValue()) : OptionalLong.empty(); OptionalLong max = longStatsData.isSetHighValue() ? OptionalLong.of(longStatsData.getHighValue()) : OptionalLong.empty(); OptionalLong nullsCount = longStatsData.isSetNumNulls() ? fromMetastoreNullsCount(longStatsData.getNumNulls()) : OptionalLong.empty(); OptionalLong distinctValuesCount = longStatsData.isSetNumDVs() ? OptionalLong.of(longStatsData.getNumDVs()) : OptionalLong.empty(); return createIntegerColumnStatistics(min, max, nullsCount, fromMetastoreDistinctValuesCount(distinctValuesCount, nullsCount, rowCount));
|| columnType.equalsIgnoreCase("smallint") || columnType.equalsIgnoreCase("int") || columnType.equalsIgnoreCase("bigint")) { LongColumnStatsData longStats = new LongColumnStatsData(); longStats.setNumNullsIsSet(false); longStats.setNumDVsIsSet(false); longStats.setLowValueIsSet(false); longStats.setHighValueIsSet(false); Map<String, String> mapProp = work.getMapProp(); for (Entry<String, String> entry : mapProp.entrySet()) { String value = entry.getValue(); if (fName.equals("numNulls")) { longStats.setNumNulls(Long.parseLong(value)); } else if (fName.equals("numDVs")) { longStats.setNumDVs(Long.parseLong(value)); } else if (fName.equals("lowValue")) { longStats.setLowValue(Long.parseLong(value)); } else if (fName.equals("highValue")) { longStats.setHighValue(Long.parseLong(value)); } else { throw new SemanticException("Unknown stat");
LongSubType subType = LongSubType.valueOf(name); LongColumnStatsData lstats = statData.getLongStats(); if (lstats.isSetHighValue()) { oneRow.add(subType.cast(lstats.getHighValue())); } else { oneRow.add(null); if (statData == null) return null; LongColumnStatsData lstats = statData.getLongStats(); if (!lstats.isSetHighValue()) { continue; long curVal = lstats.getHighValue(); maxVal = maxVal == null ? curVal : Math.max(maxVal, curVal); LongSubType subType = LongSubType.valueOf(name); LongColumnStatsData lstats = statData.getLongStats(); if (lstats.isSetLowValue()) { oneRow.add(subType.cast(lstats.getLowValue())); } else { oneRow.add(null); if (statData == null) return null; LongColumnStatsData lstats = statData.getLongStats(); if (!lstats.isSetLowValue()) { continue; long curVal = lstats.getLowValue(); minVal = minVal == null ? curVal : Math.min(minVal, curVal);
boolStats.isSetNumTrues() ? boolStats.getNumTrues() : null, boolStats.isSetNumFalses() ? boolStats.getNumFalses() : null, boolStats.isSetNumNulls() ? boolStats.getNumNulls() : null); } else if (statsObj.getStatsData().isSetLongStats()) { LongColumnStatsData longStats = statsObj.getStatsData().getLongStats(); mColStats.setLongStats( longStats.isSetNumNulls() ? longStats.getNumNulls() : null, longStats.isSetNumDVs() ? longStats.getNumDVs() : null, longStats.isSetLowValue() ? longStats.getLowValue() : null, longStats.isSetHighValue() ? longStats.getHighValue() : null); } else if (statsObj.getStatsData().isSetDoubleStats()) {
@Override ColumnStatisticsObj generate() { LongColumnStatsData longData = new LongColumnStatsData(genNumNulls(), genNumDvs()); longData.setLowValue(genLowVal()); longData.setHighValue(genHighVal()); ColumnStatisticsData data = new ColumnStatisticsData(); data.setLongStats(longData); return new ColumnStatisticsObj(colName, colType, data); }
private void verifyLongStats(int dvCount, int min, int max, List<ColumnStatisticsObj> stats) { Assert.assertEquals(1, stats.size()); LongColumnStatsData data = stats.get(0).getStatsData().getLongStats(); Assert.assertEquals(min, data.getLowValue()); Assert.assertEquals(max, data.getHighValue()); Assert.assertEquals(dvCount, data.getNumDVs()); }
return false; boolean this_present_lowValue = true && this.isSetLowValue(); boolean that_present_lowValue = true && that.isSetLowValue(); if (this_present_lowValue || that_present_lowValue) { if (!(this_present_lowValue && that_present_lowValue)) boolean this_present_highValue = true && this.isSetHighValue(); boolean that_present_highValue = true && that.isSetHighValue(); if (this_present_highValue || that_present_highValue) { if (!(this_present_highValue && that_present_highValue)) boolean this_present_bitVectors = true && this.isSetBitVectors(); boolean that_present_bitVectors = true && that.isSetBitVectors(); if (this_present_bitVectors || that_present_bitVectors) { if (!(this_present_bitVectors && that_present_bitVectors))
public LongColumnStatsData deepCopy() { return new LongColumnStatsData(this); }
@Override public int hashCode() { HashCodeBuilder builder = new HashCodeBuilder(); boolean present_lowValue = true && (isSetLowValue()); builder.append(present_lowValue); if (present_lowValue) builder.append(lowValue); boolean present_highValue = true && (isSetHighValue()); builder.append(present_highValue); if (present_highValue) builder.append(highValue); boolean present_numNulls = true; builder.append(present_numNulls); if (present_numNulls) builder.append(numNulls); boolean present_numDVs = true; builder.append(present_numDVs); if (present_numDVs) builder.append(numDVs); return builder.toHashCode(); }
if (field.type == LONG_STATS_FIELD_DESC.type) { LongColumnStatsData longStats; longStats = new LongColumnStatsData(); longStats.read(iprot); return longStats; } else {
public void write(org.apache.thrift.protocol.TProtocol oprot, LongColumnStatsData struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.isSetLowValue()) { oprot.writeFieldBegin(LOW_VALUE_FIELD_DESC); oprot.writeI64(struct.lowValue); oprot.writeFieldEnd(); } if (struct.isSetHighValue()) { oprot.writeFieldBegin(HIGH_VALUE_FIELD_DESC); oprot.writeI64(struct.highValue); oprot.writeFieldEnd(); } oprot.writeFieldBegin(NUM_NULLS_FIELD_DESC); oprot.writeI64(struct.numNulls); oprot.writeFieldEnd(); oprot.writeFieldBegin(NUM_DVS_FIELD_DESC); oprot.writeI64(struct.numDVs); oprot.writeFieldEnd(); if (struct.bitVectors != null) { if (struct.isSetBitVectors()) { oprot.writeFieldBegin(BIT_VECTORS_FIELD_DESC); oprot.writeBinary(struct.bitVectors); oprot.writeFieldEnd(); } } oprot.writeFieldStop(); oprot.writeStructEnd(); }
aggrPartVals.add("2"); AggrStats aggrStats = cachedStore.get_aggr_stats_for(DEFAULT_CATALOG_NAME, dbName, tblName, aggrPartVals, colNames); Assert.assertEquals(aggrStats.getColStats().get(0).getStatsData().getLongStats().getNumNulls(), 100); Assert.assertEquals(aggrStats.getColStats().get(0).getStatsData().getLongStats().getNumDVs(), 40); aggrStats = cachedStore.get_aggr_stats_for(DEFAULT_CATALOG_NAME, dbName, tblName, aggrPartVals, colNames); Assert.assertEquals(aggrStats.getColStats().get(0).getStatsData().getLongStats().getNumNulls(), 100); Assert.assertEquals(aggrStats.getColStats().get(0).getStatsData().getLongStats().getNumDVs(), 40);
public void write(org.apache.thrift.protocol.TProtocol oprot, LongColumnStatsData struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.isSetLowValue()) { oprot.writeFieldBegin(LOW_VALUE_FIELD_DESC); oprot.writeI64(struct.lowValue); oprot.writeFieldEnd(); } if (struct.isSetHighValue()) { oprot.writeFieldBegin(HIGH_VALUE_FIELD_DESC); oprot.writeI64(struct.highValue); oprot.writeFieldEnd(); } oprot.writeFieldBegin(NUM_NULLS_FIELD_DESC); oprot.writeI64(struct.numNulls); oprot.writeFieldEnd(); oprot.writeFieldBegin(NUM_DVS_FIELD_DESC); oprot.writeI64(struct.numDVs); oprot.writeFieldEnd(); oprot.writeFieldStop(); oprot.writeStructEnd(); }
private Long getNullcountFor(StatType type, ColumnStatisticsData statData) { switch(type) { case Integeral : return statData.getLongStats().getNumNulls(); case Double: return statData.getDoubleStats().getNumNulls(); case String: return statData.getStringStats().getNumNulls(); case Boolean: return statData.getBooleanStats().getNumNulls(); case Binary: return statData.getBinaryStats().getNumNulls(); default: return null; } }
Map<String, List<ColumnStatisticsObj>> map = hms.getPartitionColumnStatistics("default", "T", partNames, colNames); Assert.assertEquals(4, map.get(partNames.get(0)).get(0).getStatsData().getLongStats().getHighValue()); Assert.assertEquals("", 5, map.get(partNames.get(0)).get(0).getStatsData().getLongStats().getHighValue());