/**
  * This is used to compute the predicate or value columns in the PH tables Deals with multiple
  * hash functions
  *
  * @param columnName
  * @return
  */
 private String hashColumnExpression(String columnName) {
   String predicateString = planNode.getTriple().getPredicate().toString();
   PredicateTable hashingFamily = null;
   AccessMethod am = planNode.getMethod();
   if (AccessMethodType.isDirectAccess(am.getType())) {
     hashingFamily = store.getDirectPredicates();
   } else {
     hashingFamily = store.getReversePredicates();
   }
   int numberOfPredHashes = hashingFamily.getHashCount(predicateString);
   if (numberOfPredHashes == 0) {
     return null;
   } else if (numberOfPredHashes
       == 1 /*&& (mergeLogicType != SQLLogicNodeType.AND || !tapn.hasPossibleSpills(store))*/) {
     String pExpression = "T." + columnName + hashingFamily.getHashes(predicateString)[0];
     return pExpression;
   } else {
     MonitoredStringBuffer tmpProjectString = new MonitoredStringBuffer(" CASE ");
     for (int h = 0; h < numberOfPredHashes; h++) {
       int hash = hashingFamily.getHashes(predicateString)[h];
       if (hash == -1) {
         hash = 0;
       }
       readPredicateColumn(predicateString, tmpProjectString, hash, columnName);
       if (hashingFamily.getHashes(predicateString)[0] == -1) {
         break;
       }
     }
     tmpProjectString.append(" ELSE NULL END");
     return tmpProjectString.toString();
   }
 }
 private void readPredicateColumn(
     String predicateString, MonitoredStringBuffer projectString, int hash, String columnName) {
   projectString.append(" WHEN T.");
   projectString.append(Constants.NAME_COLUMN_PREFIX_PREDICATE);
   projectString.append(hash);
   projectString.append(" = '");
   projectString.append(printPredicateString(predicateString));
   projectString.append("' ");
   projectString.append(" THEN T.");
   projectString.append(columnName);
   projectString.append(hash);
   projectString.append("\n");
 }