@Override public Dictionary<?> getDictionary(TblColRef col) { int index = getTableRecordInfo().findColumn(col); return getTableRecordInfo().dict(index); }
/** * get value of columns which belongs to the original table columns. * i.e. columns like min_xx, max_yy will never appear */ public String getValueString(int col) { if (rawRecord.isMetric(col)) return getValueMetric(col); else return info.dict(col).getValueFromId(rawRecord.getValueID(col)); }
public void setValueString(int col, String value) { if (rawRecord.isMetric(col)) { LongWritable v = rawRecord.codec(col).valueOf(value); setValueMetrics(col, v); } else { int id = info.dict(col).getIdFromValue(value); rawRecord.setValueID(col, id); } }
@Test public void testBitMapContainer() { // create container BitMapContainer container = new BitMapContainer(info.getDigest(), 0); Dictionary<String> dict = info.dict(0); for (int v = dict.getMinId(); v <= dict.getMaxId(); v++) { container.append(v); } container.append(Dictionary.NULL_ID[dict.getSizeOfId()]); container.closeForChange(); // copy by serialization List<ImmutableBytesWritable> bytes = container.toBytes(); BitMapContainer container2 = new BitMapContainer(info.getDigest(), 0); container2.fromBytes(bytes); // check the copy int i = 0; for (int v = dict.getMinId(); v <= dict.getMaxId(); v++) { int value = container2.getValueIntAt(i++); assertEquals(v, value); } assertEquals(Dictionary.NULL_ID[dict.getSizeOfId()], container2.getValueIntAt(i++)); assertEquals(container, container2); }
/** * get value of columns which belongs to the original table columns. * i.e. columns like min_xx, max_yy will never appear */ public String getValueString(int col) { if (rawRecord.isMetric(col)) { return getValueMetric(col); } else { final Dictionary<String> dict = info.dict(col); if (dict != null) { return dict.getValueFromId(rawRecord.getValueID(col)); } else { return getValueStringWithoutDictionary(col); // throw new UnsupportedOperationException("cannot get value when there is no dictionary"); } } }
public void setValueString(int col, String value) { if (rawRecord.isMetric(col)) { LongMutable v = rawRecord.codec(col).valueOf(value); setValueMetrics(col, v); } else { final Dictionary<String> dict = info.dict(col); if (dict != null) { int id = dict.getIdFromValue(value); rawRecord.setValueID(col, id); } else { setValueStringWithoutDictionary(col, value); // throw new UnsupportedOperationException("cannot set value when there is no dictionary"); } } }
Dictionary<String> dict = info.dict(0);