Package org.apache.accumulo.core.client

Examples of org.apache.accumulo.core.client.Scanner


    bw.flush();

    // test null end
    // will remove rows 4 through 9 (6 * 5 = 30 entries)
    to.deleteRows("test2", new Text("30"), null);
    Scanner s = connector.createScanner("test2", Constants.NO_AUTHS);
    int rowCnt = 0;
    for (Entry<Key,Value> entry : s) {
      String rowId = entry.getKey().getRow().toString();
      Assert.assertFalse(rowId.startsWith("30"));
      rowCnt++;
    }
    s.close();
    Assert.assertEquals(120, rowCnt);

    // test null start
    // will remove 0-1, 10-19, 2
    to.deleteRows("test2", null, new Text("2"));
    s = connector.createScanner("test2", Constants.NO_AUTHS);
    rowCnt = 0;
    for (Entry<Key,Value> entry : s) {
      char rowStart = entry.getKey().getRow().toString().charAt(0);
      Assert.assertTrue(rowStart >= '2');
      rowCnt++;
    }
    s.close();
    Assert.assertEquals(55, rowCnt);

    // test null start and end
    // deletes everything still left
    to.deleteRows("test2", null, null);
    s = connector.createScanner("test2", Constants.NO_AUTHS);
    rowCnt = 0;
    for (@SuppressWarnings("unused")
    Entry<Key,Value> entry : s) {
      rowCnt++;
    }
    s.close();
    to.delete("test2");
    Assert.assertEquals(0, rowCnt);

  }
View Full Code Here


      m.put(new Text(elt[1]), new Text(elt[2]), new Value("1".getBytes()));
      bw.addMutation(m);
    }
    bw.close();
   
    Scanner s = c.createScanner("perDayCounts", Constants.NO_AUTHS);
    Iterator<Entry<Key,Value>> iterator = s.iterator();
    assertTrue(iterator.hasNext());
    checkEntry(iterator.next(), "bar", "day", "20080101", "2");
    assertTrue(iterator.hasNext());
    checkEntry(iterator.next(), "foo", "day", "20080101", "2");
    assertTrue(iterator.hasNext());
View Full Code Here

    m2.putDelete("cf1", "cq1", 2);
   
    bw.addMutation(m2);
    bw.flush();
   
    Scanner scanner = c.createScanner("test", Constants.NO_AUTHS);
   
    int count = 0;
    for (@SuppressWarnings("unused")
    Entry<Key,Value> entry : scanner) {
      count++;
View Full Code Here

   *          Table to check
   * @param count
   *          number of entries to expect in the table
   */
  private void checkRemaining(Connector c, String tableName, int count) throws Exception {
    Scanner scanner = c.createScanner(tableName, Constants.NO_AUTHS);
   
    int total = 0;
    for (@SuppressWarnings("unused")
    Entry<Key,Value> entry : scanner) {
      total++;
View Full Code Here

   
    bw.flush();
   
    int count = 10;
   
    Scanner scanner = c.createScanner("test", Constants.NO_AUTHS);
    for (Entry<Key,Value> entry : scanner) {
      Key key = entry.getKey();
      Mutation m = new Mutation(key.getRow());
      m.put(key.getColumnFamily().toString(), key.getColumnQualifier().toString(), key.getTimestamp() + 1, "v" + (count));
      count++;
View Full Code Here

    b.flush();
    b = bw.getBatchWriter("b");
    b.addMutation(m1);
    b.flush();
   
    Scanner scanner = c.createScanner("a", Constants.NO_AUTHS);
    int count = 0;
    for (@SuppressWarnings("unused")
    Entry<Key,Value> entry : scanner) {
      count++;
    }
View Full Code Here

      bw.addMutation(m);
    }
   
    bw.close();
   
    Scanner scanner = c.createScanner("test", Constants.NO_AUTHS);
   
    Entry<Key,Value> entry = scanner.iterator().next();
   
    assertEquals("9", entry.getValue().toString());
   
  }
View Full Code Here

    ClientOpts opts = new ClientOpts();
    opts.parseArgs(LocalityCheck.class.getName(), args);
   
    FileSystem fs = FileSystem.get(CachedConfiguration.getInstance());
    Connector connector = opts.getConnector();
    Scanner scanner = connector.createScanner(Constants.METADATA_TABLE_NAME, Constants.NO_AUTHS);
    scanner.fetchColumnFamily(Constants.METADATA_CURRENT_LOCATION_COLUMN_FAMILY);
    scanner.fetchColumnFamily(Constants.METADATA_DATAFILE_COLUMN_FAMILY);
    scanner.setRange(Constants.METADATA_KEYSPACE);
   
    Map<String,Long> totalBlocks = new HashMap<String,Long>();
    Map<String,Long> localBlocks = new HashMap<String,Long>();
    ArrayList<String> files = new ArrayList<String>();
   
View Full Code Here

    final ScanInterpreter interpeter = getInterpreter(cl, tableName, shellState);
   
    // handle first argument, if present, the authorizations list to
    // scan with
    final Authorizations auths = getAuths(cl, shellState);
    final Scanner scanner = shellState.getConnector().createScanner(tableName, auths);
   
    // handle session-specific scan iterators
    addScanIterators(shellState, cl, scanner, tableName);
   
    // handle remaining optional arguments
    scanner.setRange(getRange(cl, interpeter));
   
    // handle columns
    fetchColumns(cl, scanner, interpeter);
   
    // set timeout
    scanner.setTimeout(getTimeout(cl), TimeUnit.MILLISECONDS);

    // output the records
    if (cl.hasOption(showFewOpt.getOpt())) {
      final String showLength = cl.getOptionValue(showFewOpt.getOpt());
      try {
View Full Code Here

  }
 
  protected Iterator<Size> getSizeIterator(Connector conn, String tablename, Text start, Text end) throws MergeException {
    // open up the !METADATA table, walk through the tablets.
    String tableId;
    Scanner scanner;
    try {
      tableId = Tables.getTableId(conn.getInstance(), tablename);
      scanner = conn.createScanner(Constants.METADATA_TABLE_NAME, Constants.NO_AUTHS);
    } catch (Exception e) {
      throw new MergeException(e);
    }
    scanner.setRange(new KeyExtent(new Text(tableId), end, start).toMetadataRange());
    scanner.fetchColumnFamily(Constants.METADATA_DATAFILE_COLUMN_FAMILY);
    Constants.METADATA_PREV_ROW_COLUMN.fetch(scanner);
    final Iterator<Entry<Key,Value>> iterator = scanner.iterator();
   
    Iterator<Size> result = new Iterator<Size>() {
      Size next = fetch();
     
      @Override
View Full Code Here

TOP

Related Classes of org.apache.accumulo.core.client.Scanner

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.