Package org.apache.accumulo.core.client

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


      ranges.add(new Range(row));
    }
   
    // logger.setLevel(Level.TRACE);
   
    BatchScanner bs = getConnector().createBatchScanner("bss", Constants.NO_AUTHS, 4);
   
    HashMap<Text,Value> found = new HashMap<Text,Value>();
   
    for (int i = 0; i < 20; i++) {
     
      found.clear();
     
      long t1 = System.currentTimeMillis();
     
      bs.setRanges(ranges);
     
      for (Entry<Key,Value> entry : bs) {
        found.put(entry.getKey().getRow(), entry.getValue());
      }
     
View Full Code Here


    groups.put("g1", Collections.singleton(t("colf")));
    connector.tableOperations().setLocalityGroups("test_ingest", groups);
    ingest(connector, 2000, 1, 50, 0);
    verify(connector, 2000, 1, 50, 0);
    connector.tableOperations().flush("test_ingest", null, null, true);
    BatchScanner bscanner = connector.createBatchScanner(MetadataTable.NAME, Authorizations.EMPTY, 1);
    String tableId = connector.tableOperations().tableIdMap().get("test_ingest");
    bscanner.setRanges(Collections.singletonList(new Range(new Text(tableId + ";"), new Text(tableId + "<"))));
    bscanner.fetchColumnFamily(DataFileColumnFamily.NAME);
    boolean foundFile = false;
    for (Entry<Key,Value> entry : bscanner) {
      foundFile = true;
      Process info = cluster.exec(PrintInfo.class, entry.getKey().getColumnQualifier().toString());
      assertEquals(0, info.waitFor());
      String out = FunctionalTestUtils.readAll(cluster, PrintInfo.class, info);
      assertTrue(out.contains("Locality group         : g1"));
      assertTrue(out.contains("families      : [colf]"));
    }
    bscanner.close();
    assertTrue(foundFile);
  }
View Full Code Here

    }

    String table3 = getUniqueNames(1)[0];
    getConnector().tableOperations().create(table3);
    getConnector().tableOperations().addSplits(table3, splits);
    BatchScanner bs = getConnector().createBatchScanner(table3, Authorizations.EMPTY, 3);
    bs.setRanges(ranges);
    Iterator<Entry<Key,Value>> iter = bs.iterator();
    int count = Iterators.size(iter);
    bs.close();

    Assert.assertEquals("Did not expect to find any entries", 0, count);
  }
View Full Code Here

    c.tableOperations().create("shard");
    c.tableOperations().create("doc2term");
    bw = c.createBatchWriter("shard", bwc);
    Index.index(30, new File(System.getProperty("user.dir") + "/src"), "\\W+", bw);
    bw.close();
    BatchScanner bs = c.createBatchScanner("shard", Authorizations.EMPTY, 4);
    List<String> found = Query.query(bs, Arrays.asList("foo", "bar"));
    bs.close();
    // should find ourselves
    boolean thisFile = false;
    for (String file : found) {
      if (file.endsWith("/ExamplesIT.java"))
        thisFile = true;
View Full Code Here

      System.out.println("Scanner row: " + entry.getKey() + " " + entry.getValue());
    }
    scanner.close();

    // A batch scan
    BatchScanner bs = auditConnector.createBatchScanner(OLD_TEST_TABLE_NAME, auths, 1);
    bs.fetchColumn(new Text("cf1"), new Text("cq1"));
    bs.setRanges(Arrays.asList(new Range("myRow", "myRow~")));

    for (Map.Entry<Key,Value> entry : bs) {
      System.out.println("BatchScanner row: " + entry.getKey() + " " + entry.getValue());
    }
    bs.close();

    // Delete some data.
    auditConnector.tableOperations().deleteRows(OLD_TEST_TABLE_NAME, new Text("myRow"), new Text("myRow~"));

    // End of testing activities
View Full Code Here

      w.close();
    }
  }

  protected void assertVersionable(Connector c, String tableName, int size) throws TableNotFoundException {
    BatchScanner s = c.createBatchScanner(tableName, Authorizations.EMPTY, 1);
    s.setRanges(Collections.singleton(Range.exact("row1", "cf", "cq")));
    int count = 0;
    for (Map.Entry<Key,Value> e : s) {
      Assert.assertEquals("row1", e.getKey().getRow().toString());
      Assert.assertEquals("cf", e.getKey().getColumnFamily().toString());
      Assert.assertEquals("cq", e.getKey().getColumnQualifier().toString());
      count++;

    }
    Assert.assertEquals(size, count);
    s.close();
  }
View Full Code Here

      Mutation m = new Mutation(asText(r));
      m.put(asText(random.nextInt()), asText(random.nextInt()), new Value(Integer.toHexString(r).getBytes()));
      bw.addMutation(m);
    }
    bw.close();
    BatchScanner s = c.createBatchScanner("test", Authorizations.EMPTY, 2);
    s.setRanges(Collections.singletonList(new Range()));
    Key key = null;
    int count = 0;
    for (Entry<Key,Value> entry : s) {
      if (key != null)
        assertTrue(key.compareTo(entry.getKey()) < 0);
View Full Code Here

      undefs.add(new UndefinedNode(undef, ref));
    }

    Connector conn = opts.getConnector();
    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>>();

    for (Entry<Key,Value> entry : bscanner) {
      String ref = entry.getKey().getRow().toString();
      List<String> vals = refInfo.get(ref);
      if (vals == null) {
        vals = new ArrayList<String>();
        refInfo.put(ref, vals);
      }

      vals.add(entry.getValue().toString());
    }

    bscanner.close();

    IngestInfo ingestInfo = new IngestInfo(opts.logDir);
    TabletHistory tabletHistory = new TabletHistory(Tables.getTableId(conn.getInstance(), opts.getTableName()), opts.logDir);

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
View Full Code Here

        auth = connector.securityOperations().getUserAuthorizations(connector.whoami());
      }
      if (opts != null && opts.threads > 0)
        threads = opts.threads;
     
      BatchScanner scanner = connector.createBatchScanner(tableName, auth, threads);
     
      if (opts != null) {
        if (opts.iterators != null) {
          for (org.apache.accumulo.proxy.thrift.IteratorSetting iter : opts.iterators) {
            IteratorSetting is = new IteratorSetting(iter.getPriority(), iter.getName(), iter.getIteratorClass(), iter.getProperties());
            scanner.addScanIterator(is);
          }
        }
       
        ArrayList<Range> ranges = new ArrayList<Range>();
       
        if (opts.ranges == null) {
          ranges.add(new Range());
        } else {
          for (org.apache.accumulo.proxy.thrift.Range range : opts.ranges) {
            Range aRange = new Range(range.getStart() == null ? null : Util.fromThrift(range.getStart()), true, range.getStop() == null ? null
                : Util.fromThrift(range.getStop()), false);
            ranges.add(aRange);
          }
        }
        scanner.setRanges(ranges);
       
        if (opts.columns != null) {
          for (ScanColumn col : opts.columns) {
            if (col.isSetColQualifier())
              scanner.fetchColumn(ByteBufferUtil.toText(col.colFamily), ByteBufferUtil.toText(col.colQualifier));
            else
              scanner.fetchColumnFamily(ByteBufferUtil.toText(col.colFamily));
          }
        }
      }
     
      UUID uuid = UUID.randomUUID();
     
      ScannerPlusIterator spi = new ScannerPlusIterator();
      spi.scanner = scanner;
      spi.iterator = scanner.iterator();
      scannerCache.put(uuid, spi);
      return uuid.toString();
    } catch (Exception e) {
      handleExceptionTNF(e);
      return null;
View Full Code Here

  static class CloseScanner implements RemovalListener<UUID,ScannerPlusIterator> {
    @Override
    public void onRemoval(RemovalNotification<UUID,ScannerPlusIterator> notification) {
      final ScannerBase base = notification.getValue().scanner;
      if (base instanceof BatchScanner) {
        final BatchScanner scanner = (BatchScanner) base;
        scanner.close();
      }
    }
View Full Code Here

TOP

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

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.