Examples of ScanResult


Examples of org.apache.accumulo.proxy.thrift.ScanResult

    // fetch the scanner
    ScannerPlusIterator spi = getScanner(scanner);
    Iterator<Map.Entry<Key,Value>> batchScanner = spi.iterator;
    // synchronized to prevent race conditions
    synchronized (batchScanner) {
      ScanResult ret = new ScanResult();
      ret.setResults(new ArrayList<KeyValue>());
      int numRead = 0;
      try {
        while (batchScanner.hasNext() && numRead < k) {
          Map.Entry<Key,Value> next = batchScanner.next();
          ret.addToResults(new KeyValue(Util.toThrift(next.getKey()), ByteBuffer.wrap(next.getValue().get())));
          numRead++;
        }
        ret.setMore(numRead == k);
      } catch (Exception ex) {
        closeScanner(scanner);
        throw new org.apache.accumulo.proxy.thrift.AccumuloSecurityException(ex.toString());
      }
      return ret;
View Full Code Here

Examples of org.apache.accumulo.proxy.thrift.ScanResult

 
  @Override
  public KeyValueAndPeek nextEntry(String scanner) throws NoMoreEntriesException, UnknownScanner, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
      TException {
   
    ScanResult scanResult = nextK(scanner, 1);
    if (scanResult.results.size() > 0) {
      return new KeyValueAndPeek(scanResult.results.get(0), scanResult.isMore());
    } else {
      throw new NoMoreEntriesException();
    }
  }
View Full Code Here

Examples of org.apache.accumulo.proxy.thrift.ScanResult

    // fetch the scanner
    ScannerPlusIterator spi = getScanner(scanner);
    Iterator<Map.Entry<Key,Value>> batchScanner = spi.iterator;
    // synchronized to prevent race conditions
    synchronized (batchScanner) {
      ScanResult ret = new ScanResult();
      ret.setResults(new ArrayList<KeyValue>());
      int numRead = 0;
      try {
        while (batchScanner.hasNext() && numRead < k) {
          Map.Entry<Key,Value> next = batchScanner.next();
          ret.addToResults(new KeyValue(Util.toThrift(next.getKey()), ByteBuffer.wrap(next.getValue().get())));
          numRead++;
        }
        ret.setMore(numRead == k);
      } catch (Exception ex) {
        closeScanner(scanner);
        throw new org.apache.accumulo.proxy.thrift.AccumuloSecurityException(ex.toString());
      }
      return ret;
View Full Code Here

Examples of org.apache.accumulo.proxy.thrift.ScanResult

    then = new Date();
    boolean hasNext = true;
   
    int k = 1000;
    while (hasNext) {
      ScanResult kvList = tpc.proxy().nextK(cookie, k);
     
      Date now = new Date();
      System.out.println(i + " " + (now.getTime() - then.getTime()));
      then = now;
     
      i += kvList.getResultsSize();
      // for (TKeyValue kv:kvList.getResults()) System.out.println(new Key(kv.getKey()));
      hasNext = kvList.isMore();
    }
    end = new Date();
    System.out.println("Total entries: " + i + " total time " + (end.getTime() - start.getTime()));
  }
View Full Code Here

Examples of org.apache.accumulo.proxy.thrift.ScanResult

    boolean hasNext = true;
   
    int k = 1000;
    int numRead = 0;
    while (hasNext) {
      ScanResult kvList = tpc.proxy().nextK(cookie, k);
      for (KeyValue kv : kvList.getResults()) {
        assertEquals(i, Integer.parseInt(new String(kv.getKey().getRow())));
        numRead++;
        i += 2;
      }
      hasNext = kvList.isMore();
    }
    assertEquals(maxInserts / 2, numRead);
  }
View Full Code Here

Examples of org.apache.accumulo.proxy.thrift.ScanResult

    boolean hasNext = true;
   
    int k = 1000;
    int numRead = 0;
    while (hasNext) {
      ScanResult kvList = tpc.proxy().nextK(cookie, k);
      for (KeyValue kv : kvList.getResults()) {
        assertEquals(Integer.parseInt(new String(kv.getKey().getRow())), i);
        i += 2;
        numRead++;
      }
      hasNext = kvList.isMore();
     
    }
    assertEquals(maxInserts / 2, numRead);
  }
View Full Code Here

Examples of org.apache.accumulo.proxy.thrift.ScanResult

    client.update(batchWriter, mutation("row1", "cf", "cq", "x"));
    client.flush(batchWriter);
    client.closeWriter(batchWriter);
   
    String scanner = client.createScanner(creds, TABLE_TEST, null);
    ScanResult more = client.nextK(scanner, 2);
    assertEquals(1, more.getResults().size());
    client.closeScanner(scanner);
   
    client.deleteTable(creds, TABLE_TEST);
  }
View Full Code Here

Examples of org.apache.accumulo.proxy.thrift.ScanResult

    } catch (MutationsRejectedException ex) {}
   
    client.removeConstraint(creds, TABLE_TEST, 1);
    client.updateAndFlush(creds, TABLE_TEST, mutation("row1", "cf", "cq", "x"));
    String scanner = client.createScanner(creds, TABLE_TEST, null);
    ScanResult more = client.nextK(scanner, 2);
    client.closeScanner(scanner);
    assertFalse(more.isMore());
    assertEquals(1, more.getResults().size());
    assertEquals(s2bb("x"), more.getResults().get(0).value);
    // splits, merge
    client.addSplits(creds, TABLE_TEST, new HashSet<ByteBuffer>(Arrays.asList(s2bb("a"), s2bb("m"), s2bb("z"))));
    List<ByteBuffer> splits = client.listSplits(creds, TABLE_TEST, 1);
    assertEquals(Arrays.asList(s2bb("m")), splits);
    client.mergeTablets(creds, TABLE_TEST, null, s2bb("m"));
    splits = client.listSplits(creds, TABLE_TEST, 10);
    assertEquals(Arrays.asList(s2bb("m"), s2bb("z")), splits);
    client.mergeTablets(creds, TABLE_TEST, null, null);
    splits = client.listSplits(creds, TABLE_TEST, 10);
    List<ByteBuffer> empty = Collections.emptyList();
    assertEquals(empty, splits);
    // iterators
    client.deleteTable(creds, TABLE_TEST);
    client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
    HashMap<String,String> options = new HashMap<String,String>();
    options.put("type", "STRING");
    options.put("columns", "cf");
    IteratorSetting setting = new IteratorSetting(10, TABLE_TEST, SummingCombiner.class.getName(), options);
    client.attachIterator(creds, TABLE_TEST, setting, EnumSet.allOf(IteratorScope.class));
    for (int i = 0; i < 10; i++) {
      client.updateAndFlush(creds, TABLE_TEST, mutation("row1", "cf", "cq", "1"));
    }
    scanner = client.createScanner(creds, TABLE_TEST, null);
    more = client.nextK(scanner, 2);
    client.closeScanner(scanner);
    assertEquals("10", new String(more.getResults().get(0).getValue()));
    try {
      client.checkIteratorConflicts(creds, TABLE_TEST, setting, EnumSet.allOf(IteratorScope.class));
      fail("checkIteratorConflicts did not throw and exception");
    } catch (Exception ex) {}
    client.deleteRows(creds, TABLE_TEST, null, null);
    client.removeIterator(creds, TABLE_TEST, "test", EnumSet.allOf(IteratorScope.class));
    for (int i = 0; i < 10; i++) {
      client.updateAndFlush(creds, TABLE_TEST, mutation("row" + i, "cf", "cq", "" + i));
      client.flushTable(creds, TABLE_TEST, null, null, true);
    }
    scanner = client.createScanner(creds, TABLE_TEST, null);
    more = client.nextK(scanner, 100);
    client.closeScanner(scanner);
    assertEquals(10, more.getResults().size());
    // clone
    client.cloneTable(creds, TABLE_TEST, "test2", true, null, null);
    scanner = client.createScanner(creds, "test2", null);
    more = client.nextK(scanner, 100);
    client.closeScanner(scanner);
    assertEquals(10, more.getResults().size());
    client.deleteTable(creds, "test2");
   
    // don't know how to test this, call it just for fun
    client.clearLocatorCache(creds, TABLE_TEST);
   
View Full Code Here

Examples of org.apache.commons.weaver.model.ScanResult

        final ScanRequest scanRequest =
            new ScanRequest().add(WeaveInterest.of(TestAnnotation.class, ElementType.TYPE))
                .add(WeaveInterest.of(TestAnnotation.class, ElementType.METHOD))
                .addSupertypes(AbstractTestBean.class, TestBeanInterface.class);

        final ScanResult scanResult = scanner.scan(scanRequest);

        for (WeavableClass<?> weavableClass : scanResult.getClasses().with(TestAnnotation.class)) {
            if (wovenClasses.add(weavableClass.getTarget())) {
                result = true;
            }
        }
        for (WeavableMethod<?> weavableMethod : scanResult.getMethods().with(TestAnnotation.class)) {
            if (wovenMethods.add(weavableMethod.getTarget())) {
                result = true;
            }
        }
        for (WeavableClass<?> weavableClass : scanResult.getClassesAssignableTo(TestBeanInterface.class)) {
            if (implementors.add(weavableClass.getTarget())) {
                result = true;
            }
        }
        for (WeavableClass<?> weavableClass : scanResult.getClassesAssignableTo(AbstractTestBean.class)) {
            if (subclasses.add(weavableClass.getTarget())) {
                result = true;
            }
        }
        return result;
View Full Code Here

Examples of org.apache.maven.surefire.util.ScanResult

        DependencyScanner scanner = new DependencyScanner(
                DependencyScanner.filter(Arrays.asList(artifact), scanDependencies),
                include, exclude, new ArrayList<String>() );

        ScanResult classNames = scanner.scan();
        assertNotNull( classNames );
        System.out.println( "classNames " + classNames.toString() );
        assertEquals( 1, classNames.size() );
        System.out.println(classNames.getClassName(0));

        Properties props = new Properties();
        classNames.writeTo( props );
        assertEquals( 1, props.size() );
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.