コード例 #1
0
  @Test
  public void testAddIterator() throws IOException {
    @SuppressWarnings("deprecation")
    Job job = new Job();

    AccumuloInputFormat.addIterator(
        job, new IteratorSetting(1, "WholeRow", WholeRowIterator.class));
    AccumuloInputFormat.addIterator(
        job,
        new IteratorSetting(
            2, "Versions", "org.apache.accumulo.core.iterators.VersioningIterator"));
    IteratorSetting iter =
        new IteratorSetting(3, "Count", "org.apache.accumulo.core.iterators.CountingIterator");
    iter.addOption("v1", "1");
    iter.addOption("junk", "\0omg:!\\xyzzy");
    AccumuloInputFormat.addIterator(job, iter);

    List<IteratorSetting> list = AccumuloInputFormat.getIterators(job);

    // Check the list size
    assertTrue(list.size() == 3);

    // Walk the list and make sure our settings are correct
    IteratorSetting setting = list.get(0);
    assertEquals(1, setting.getPriority());
    assertEquals(
        "org.apache.accumulo.core.iterators.user.WholeRowIterator", setting.getIteratorClass());
    assertEquals("WholeRow", setting.getName());
    assertEquals(0, setting.getOptions().size());

    setting = list.get(1);
    assertEquals(2, setting.getPriority());
    assertEquals(
        "org.apache.accumulo.core.iterators.VersioningIterator", setting.getIteratorClass());
    assertEquals("Versions", setting.getName());
    assertEquals(0, setting.getOptions().size());

    setting = list.get(2);
    assertEquals(3, setting.getPriority());
    assertEquals("org.apache.accumulo.core.iterators.CountingIterator", setting.getIteratorClass());
    assertEquals("Count", setting.getName());
    assertEquals(2, setting.getOptions().size());
    assertEquals("1", setting.getOptions().get("v1"));
    assertEquals("\0omg:!\\xyzzy", setting.getOptions().get("junk"));
  }
コード例 #2
0
ファイル: IteratorUtil.java プロジェクト: apache/accumulo
  public static <K extends WritableComparable<?>, V extends Writable>
      SortedKeyValueIterator<K, V> loadIterators(
          IteratorScope scope,
          SortedKeyValueIterator<K, V> source,
          KeyExtent extent,
          AccumuloConfiguration conf,
          List<IteratorSetting> iterators,
          IteratorEnvironment env)
          throws IOException {

    List<IterInfo> ssiList = new ArrayList<>();
    Map<String, Map<String, String>> ssio = new HashMap<>();

    for (IteratorSetting is : iterators) {
      ssiList.add(new IterInfo(is.getPriority(), is.getIteratorClass(), is.getName()));
      ssio.put(is.getName(), is.getOptions());
    }

    return loadIterators(scope, source, extent, conf, ssiList, ssio, env, true);
  }
コード例 #3
0
 /**
  * Add the given Iterator to a table on scan, minc, majc scopes. If already present on a scope,
  * does not re-add the iterator to that scope. Call it "plus".
  */
 public static void applyIteratorSoft(IteratorSetting itset, TableOperations tops, String table) {
   // checking if iterator already exists. Not checking for conflicts.
   try {
     IteratorSetting existing;
     EnumSet<IteratorUtil.IteratorScope> enumSet =
         EnumSet.noneOf(IteratorUtil.IteratorScope.class);
     for (IteratorUtil.IteratorScope scope : IteratorUtil.IteratorScope.values()) {
       existing = tops.getIteratorSetting(table, itset.getName(), scope);
       if (existing == null) enumSet.add(scope);
     }
     tops.attachIterator(table, itset, enumSet);
   } catch (AccumuloSecurityException | AccumuloException e) {
     log.error("error trying to add " + itset + " to " + table, e);
     throw new RuntimeException(e);
   } catch (TableNotFoundException e) {
     log.error("no table: " + table, e);
     throw new RuntimeException(e);
   }
 }
コード例 #4
0
  public ByteBuffer compress(IteratorSetting[] iterators) {

    UnsynchronizedBuffer.Writer out = new UnsynchronizedBuffer.Writer(iterators.length * 8);

    out.writeVInt(iterators.length);

    for (IteratorSetting is : iterators) {
      out.writeVInt(getSymbolID(is.getName()));
      out.writeVInt(getSymbolID(is.getIteratorClass()));
      out.writeVInt(is.getPriority());

      Map<String, String> opts = is.getOptions();
      out.writeVInt(opts.size());

      for (Entry<String, String> entry : opts.entrySet()) {
        out.writeVInt(getSymbolID(entry.getKey()));
        out.writeVInt(getSymbolID(entry.getValue()));
      }
    }

    return out.toByteBuffer();
  }
コード例 #5
0
ファイル: IteratorUtil.java プロジェクト: apache/accumulo
 public static TIteratorSetting toTIteratorSetting(IteratorSetting is) {
   return new TIteratorSetting(
       is.getPriority(), is.getName(), is.getIteratorClass(), is.getOptions());
 }