Пример #1
0
  /**
   * Generates RemoteSourceIterator (possibly x2), TwoTableIterator, RemoteWriteIterator
   * configuration through a DynamicIteratorSetting.
   *
   * @param map Map of all options.
   * @param priority Priority to use for the IteratorSetting of the whole stack
   * @param name Null means use the default name "TableMultIterator"
   */
  public static IteratorSetting tableMultIterator(
      Map<String, String> map, int priority, String name) {
    Map<String, String> optDM = new HashMap<>(), optC = new HashMap<>();
    {
      Map<String, Map<String, String>> prefixMap = GraphuloUtil.splitMapPrefix(map);
      for (Map.Entry<String, Map<String, String>> prefixEntry : prefixMap.entrySet()) {
        final String prefix = prefixEntry.getKey();
        Map<String, String> entryMap = prefixEntry.getValue();

        switch (prefix) {
          case TwoTableIterator.PREFIX_AT:
          case TwoTableIterator.PREFIX_B:
            optDM.putAll(GraphuloUtil.preprendPrefixToKey(prefix + '.', entryMap));
            break;
          case "C":
            optC.putAll(entryMap);
            break;
          default:
            for (Map.Entry<String, String> entry : entryMap.entrySet()) {
              //              switch (entry.getKey()) {
              //                case "dotmode":
              //                case "multiplyOp":
              //                  optDM.put(entry.getKey(), entry.getValue());
              //                  break;
              //                default:
              //                  log.warn("Unrecognized option: " + prefix + '.' + entry);
              //                  break;
              //              }
              if (prefix.isEmpty()) optDM.put(entry.getKey(), entry.getValue());
              else optDM.put(prefix + '.' + entry.getKey(), entry.getValue());
            }
            break;
        }
      }
    }
    DynamicIteratorSetting dis =
        new DynamicIteratorSetting(priority, name == null ? "TableMultIterator" : name)
            .append(new IteratorSetting(1, TwoTableIterator.class, optDM));
    if (!optC.isEmpty()) dis.append(new IteratorSetting(1, RemoteWriteIterator.class, optC));
    return dis.toIteratorSetting();
  }
Пример #2
0
 /**
  * Apply an appropriate column filter based on the input string. Four modes of operation:
  *
  * <ol>
  *   <li>1. Null or blank ("") `colFilter`: do nothing.
  *   <li>2. No ranges `colFilter`: use scanner.fetchColumn() which invokes an Accumulo system
  *       {@link ColumnQualifierFilter}.
  *   <li>3. Singleton range `colFilter`: use Accumulo user {@link ColumnSliceFilter}.
  *   <li>4. Multi-range `colFilter`: use Graphulo {@link D4mRangeFilter}.
  * </ol>
  *
  * @param colFilter column filter string
  * @param scanner to call fetchColumn() on, for case #2
  * @param dis to call append()/prepend() on, for cases #3 and #4
  * @param append True means call {@link DynamicIteratorSetting#append}. False means call {@link
  *     DynamicIteratorSetting#prepend}
  */
 public static void applyGeneralColumnFilter(
     String colFilter, ScannerBase scanner, DynamicIteratorSetting dis, boolean append) {
   //    System.err.println("colFilter: "+colFilter);
   if (colFilter != null && !colFilter.isEmpty()) {
     int pos1 = colFilter.indexOf(':');
     if (pos1 == -1) { // no ranges - collection of singleton texts
       // todo - the order this filter applies is different. Ensure no logical bugs when we have
       // case 2.
       for (Text text : GraphuloUtil.d4mRowToTexts(colFilter)) {
         scanner.fetchColumn(GraphuloUtil.EMPTY_TEXT, text);
       }
     } else {
       SortedSet<Range> ranges = GraphuloUtil.d4mRowToRanges(colFilter);
       assert ranges.size() > 0;
       IteratorSetting s;
       if (ranges.size() == 1) { // single range - use ColumnSliceFilter
         Range r = ranges.first();
         s = new IteratorSetting(1, ColumnSliceFilter.class);
         //          System.err.println("start: "+(r.isInfiniteStartKey() ? null :
         // r.getStartKey().getRow().toString())
         //              +"end: "+(r.isInfiniteStopKey() ? null :
         // r.getEndKey().getRow().toString()));
         ColumnSliceFilter.setSlice(
             s,
             r.isInfiniteStartKey() ? null : r.getStartKey().getRow().toString(),
             true,
             r.isInfiniteStopKey() ? null : r.getEndKey().getRow().toString(),
             true);
         //          System.err.println("!ok "+GraphuloUtil.d4mRowToRanges(colFilter));
       } else { // multiple ranges
         //          System.err.println("ok "+GraphuloUtil.d4mRowToRanges(colFilter));
         s = D4mRangeFilter.iteratorSetting(1, D4mRangeFilter.KeyPart.COLQ, colFilter);
       }
       if (append) dis.append(s);
       else dis.prepend(s);
     }
   }
 }