Package org.apache.accumulo.core.data

Examples of org.apache.accumulo.core.data.Range


    if (opts.scanOffline) {
      Random random = new Random();
      clone = opts.getTableName() + "_" + String.format("%016x", (random.nextLong() & 0x7fffffffffffffffl));
      conn = opts.getConnector();
      conn.tableOperations().clone(opts.getTableName(), clone, true, new HashMap<String,String>(), new HashSet<String>());
      ranges = conn.tableOperations().splitRangeByTablets(opts.getTableName(), new Range(), opts.maxMaps);
      conn.tableOperations().offline(clone);
      AccumuloInputFormat.setInputTableName(job, clone);
      AccumuloInputFormat.setOfflineTableScan(job, true);
    } else {
      ranges = opts.getConnector().tableOperations().splitRangeByTablets(opts.getTableName(), new Range(), opts.maxMaps);
    }

    AccumuloInputFormat.setRanges(job, ranges);
    AccumuloInputFormat.setAutoAdjustRanges(job, false);
View Full Code Here


    job.setInputFormatClass(AccumuloInputFormat.class);
    opts.setAccumuloConfigs(job);
   
    // set up ranges
    try {
      Set<Range> ranges = opts.getConnector().tableOperations().splitRangeByTablets(opts.getTableName(), new Range(), opts.maxMaps);
      AccumuloInputFormat.setRanges(job, ranges);
      AccumuloInputFormat.setAutoAdjustRanges(job, false);
    } catch (Exception e) {
      throw new IOException(e);
    }
View Full Code Here

  private void verify(ByteArraySet nss, String... expected) throws Exception {
    Scanner scanner = getConnector().createScanner("vt", new Authorizations(nss));
    verify(scanner.iterator(), expected);
   
    BatchScanner bs = getConnector().createBatchScanner("vt", new Authorizations(nss), 3);
    bs.setRanges(Collections.singleton(new Range()));
    verify(bs.iterator(), expected);
    bs.close();
  }
View Full Code Here

    BatchScanner bscanner = conn.createBatchScanner(opts.getTableName(), opts.auths, bsOpts.scanThreads);
    bscanner.setTimeout(bsOpts.scanTimeout, TimeUnit.MILLISECONDS);
    List<Range> refs = new ArrayList<Range>();
   
    for (UndefinedNode undefinedNode : undefs)
      refs.add(new Range(new Text(undefinedNode.ref)));
   
    bscanner.setRanges(refs);
   
    HashMap<String,List<String>> refInfo = new HashMap<String,List<String>>();
   
View Full Code Here

    scanner.clearColumns();
    scanner.fetchColumn(new Text("cf1"), new Text("cq1"));
    assertEquals(new HashSet<String>(), getRows(scanner));

    scanner.setRange(new Range("0", "4"));
    scanner.clearColumns();
    assertEquals(new HashSet<String>(Arrays.asList("2", "3")), getRows(scanner));

    scanner.setRange(new Range("2"));
    scanner.clearColumns();
    assertEquals(new HashSet<String>(Arrays.asList("2")), getRows(scanner));

    scanner.setRange(new Range("4"));
    scanner.clearColumns();
    assertEquals(new HashSet<String>(), getRows(scanner));

    scanner.setRange(new Range("4"));
    scanner.clearColumns();
    scanner.fetchColumn(new Text("cf1"), new Text("cq2"));
    scanner.fetchColumn(new Text("cf1"), new Text("cq4"));
    assertEquals(new HashSet<String>(Arrays.asList("4")), getRows(scanner));
View Full Code Here

    SortedMapIterator source = new SortedMapIterator(createKeyValues());

    RowFilter filter = new RowZeroOrOneFilter();
    filter.init(source, Collections.<String,String> emptyMap(), new DefaultIteratorEnvironment());

    filter.seek(new Range(), Collections.<ByteSequence> emptySet(), false);

    // Save off the first key and value
    Key firstKey = filter.getTopKey();
    Value firstValue = filter.getTopValue();

    // Assert that the row is valid given our filter
    assertEquals("0", firstKey.getRow().toString());

    // Read some extra data, just making sure it's all valid
    Key lastKeyRead = null;
    for (int i = 0; i < 5; i++) {
      filter.next();
      lastKeyRead = filter.getTopKey();
      assertEquals("0", lastKeyRead.getRow().toString());
    }

    // Make a copy of the original RowFilter
    RowFilter copy = (RowFilter) filter.deepCopy(new DefaultIteratorEnvironment());

    // Because it's a copy, we should be able to safely seek this one without affecting the original
    copy.seek(new Range(), Collections.<ByteSequence> emptySet(), false);

    assertTrue("deepCopy'ed RowFilter did not have a top key", copy.hasTop());

    Key firstKeyFromCopy = copy.getTopKey();
    Value firstValueFromCopy = copy.getTopValue();
View Full Code Here

        sum += Integer.parseInt(rowIterator.getTopValue().toString());
        rowIterator.next();
      }

      // ensure that seeks are confined to the row
      rowIterator.seek(new Range(), new HashSet<ByteSequence>(), false);
      while (rowIterator.hasTop()) {
        sum2 += Integer.parseInt(rowIterator.getTopValue().toString());
        rowIterator.next();
      }

      rowIterator.seek(new Range(firstKey.getRow(), false, null, true), new HashSet<ByteSequence>(), false);
      while (rowIterator.hasTop()) {
        sum2 += Integer.parseInt(rowIterator.getTopValue().toString());
        rowIterator.next();
      }
View Full Code Here

      }
    }
    SortedMapIterator source = new SortedMapIterator(map);
    WholeRowIterator iter = new WholeRowIterator(source);
    SortedMap<Key,Value> resultMap = new TreeMap<Key,Value>();
    iter.seek(new Range(), new ArrayList<ByteSequence>(), false);
    int numRows = 0;
    while (iter.hasTop()) {
      numRows++;
      Key rowKey = iter.getTopKey();
      Value rowValue = iter.getTopValue();
      resultMap.putAll(WholeRowIterator.decodeRow(rowKey, rowValue));
      iter.next();
    }
    assertTrue(numRows == 5);
    assertEquals(resultMap, map);
   
    WholeRowIterator iter2 = new WholeRowIterator(source) {
      @Override
      public boolean filter(Text row, List<Key> keys, List<Value> values) {
        return toInclude.get(row);
      }
    };
    resultMap.clear();
    iter2.seek(new Range(), new ArrayList<ByteSequence>(), false);
    numRows = 0;
    while (iter2.hasTop()) {
      numRows++;
      Key rowKey = iter2.getTopKey();
      Value rowValue = iter2.getTopValue();
View Full Code Here

    map.putAll(map3);
   
    SortedMapIterator source = new SortedMapIterator(map);
    WholeRowIterator iter = new WholeRowIterator(source);
   
    Range range = new Range(new Text("row1"), true, new Text("row2"), true);
    iter.seek(range, new ArrayList<ByteSequence>(), false);
   
    assertTrue(iter.hasTop());
    assertEquals(map1, WholeRowIterator.decodeRow(iter.getTopKey(), iter.getTopValue()));
   
    // simulate something continuing using the last key from the iterator
    // this is what client and server code will do
    range = new Range(iter.getTopKey(), false, range.getEndKey(), range.isEndKeyInclusive());
    iter.seek(range, new ArrayList<ByteSequence>(), false);
   
    assertTrue(iter.hasTop());
    assertEquals(map2, WholeRowIterator.decodeRow(iter.getTopKey(), iter.getTopValue()));
   
View Full Code Here

   
    SortedMap<Key,Value> map = new TreeMap<Key,Value>();
    map.putAll(map1);
    map.putAll(map2);
   
    MultiIterator source = new MultiIterator(Collections.singletonList((SortedKeyValueIterator<Key,Value>) new SortedMapIterator(map)), new Range(null, true,
        new Text("row1"), true));
    WholeRowIterator iter = new WholeRowIterator(source);
   
    Range range = new Range(new Text("row1"), true, new Text("row2"), true);
    iter.seek(range, new ArrayList<ByteSequence>(), false);
   
    assertTrue(iter.hasTop());
    assertEquals(map1, WholeRowIterator.decodeRow(iter.getTopKey(), iter.getTopValue()));
   
    // simulate something continuing using the last key from the iterator
    // this is what client and server code will do
    range = new Range(iter.getTopKey(), false, range.getEndKey(), range.isEndKeyInclusive());
    iter.seek(range, new ArrayList<ByteSequence>(), false);
   
    assertFalse(iter.hasTop());
   
  }
View Full Code Here

TOP

Related Classes of org.apache.accumulo.core.data.Range

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.