예제 #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]);
     }
   }
 }
 @VisibleForTesting
 static Sha1HashCode computeAbiKey(ImmutableSortedMap<String, HashCode> classNames) {
   Hasher hasher = Hashing.sha1().newHasher();
   for (Map.Entry<String, HashCode> entry : classNames.entrySet()) {
     hasher.putUnencodedChars(entry.getKey());
     hasher.putByte((byte) 0);
     hasher.putUnencodedChars(entry.getValue().toString());
     hasher.putByte((byte) 0);
   }
   return Sha1HashCode.fromHashCode(hasher.hash());
 }