Beispiel #1
0
 @Override
 public void hashRow(DimensionSelector dimSelector, Hasher hasher) {
   final IndexedInts row = dimSelector.getRow();
   final int size = row.size();
   // nothing to add to hasher if size == 0, only handle size == 1 and size != 0 cases.
   if (size == 1) {
     final String value = dimSelector.lookupName(row.get(0));
     hasher.putUnencodedChars(nullToSpecial(value));
   } else if (size != 0) {
     final String[] values = new String[size];
     for (int i = 0; i < size; ++i) {
       final String value = dimSelector.lookupName(row.get(i));
       values[i] = nullToSpecial(value);
     }
     // Values need to be sorted to ensure consistent multi-value ordering across different
     // segments
     Arrays.sort(values);
     for (int i = 0; i < size; ++i) {
       if (i != 0) {
         hasher.putChar(CARDINALITY_AGG_SEPARATOR);
       }
       hasher.putUnencodedChars(values[i]);
     }
   }
 }
  @Override
  public Object getRowValueArrayFromColumn(Closeable column, int currRow) {
    DictionaryEncodedColumn dict = (DictionaryEncodedColumn) column;
    int[] theVals;
    if (dict.hasMultipleValues()) {
      final IndexedInts dimVals = dict.getMultiValueRow(currRow);
      theVals = new int[dimVals.size()];
      for (int i = 0; i < theVals.length; ++i) {
        theVals[i] = dimVals.get(i);
      }
    } else {
      theVals = new int[1];
      theVals[0] = dict.getSingleValueRow(currRow);
    }

    return theVals;
  }