Package org.apache.hadoop.hbase.client.idx

Examples of org.apache.hadoop.hbase.client.idx.IdxScan


    for (int i = 0; i < 5; i++) {
      service.submit(new Writer(table, family, qualifier, sequence, rows));
    }

    byte[] value = Bytes.toBytes((FIXED_PART + 0).toCharArray());
    IdxScan idxScan = new IdxScan();
    idxScan.setExpression(Expression.comparison(family, qualifier,
      Comparison.Operator.EQ, value));
    idxScan.setFilter(new SingleColumnValueFilter(family, qualifier,
      CompareFilter.CompareOp.EQUAL, value));
    idxScan.setCaching(1000);

    int count = 0;
    int finalCount = maxRows / 10;
    int printCount = 0;
    while (count < finalCount) {
View Full Code Here


    final byte[] intValue = Bytes.toBytes(numberOfRows - numberOfRows / 5);
    final byte[] charsValue =
      Bytes.toBytes(String.format("%010d", 50).toCharArray());
    final byte[] bytesValue = String.format("%010d", 990).getBytes();

    IdxScan scan = new IdxScan();
    scan.setExpression(Expression.or(
      Expression.and(
        Expression.comparison(FAMILY_1_NAME, INT_QUAL_NAME,
          Comparison.Operator.GTE, intValue),
        Expression.comparison(FAMILY_2_NAME, CHARS_QUAL_NAME,
          Comparison.Operator.LT, charsValue)),
      Expression.comparison(FAMILY_1_NAME, BYTES_QUAL_NAME,
        Comparison.Operator.GTE, bytesValue)));

    scan.setFilter(new FilterList(FilterList.Operator.MUST_PASS_ONE,
      Arrays.<Filter>asList(
        new FilterList(FilterList.Operator.MUST_PASS_ALL,
          Arrays.<Filter>asList(
            new SingleColumnValueFilter(FAMILY_1_NAME, INT_QUAL_NAME,
              CompareFilter.CompareOp.GREATER_OR_EQUAL, intValue),
View Full Code Here

    region.flushcache();

    byte[] startRow = Bytes.toBytes(75L);

    IdxScan idxScan = new IdxScan();
    idxScan.addFamily(family);
    idxScan.setStartRow(startRow);
    idxScan.setExpression(Comparison.comparison(family, qualLong,
      Comparison.Operator.GTE, Bytes.toBytes(50L)));
    InternalScanner scanner = region.getScanner(idxScan);

    List<KeyValue> res = new ArrayList<KeyValue>();
View Full Code Here

    assertEquals(Bytes.toLong(res.get(0).getValue()), 42L);

    /**
     * Scan the index with a matching expression
     */
    IdxScan idxScan = new IdxScan();
    idxScan.addFamily(family);
    idxScan.setExpression(Comparison.comparison(family, qualLong,
      Comparison.Operator.EQ, Bytes.toBytes(42L)));
    scanner = region.getScanner(idxScan);
    res.clear();

    while (scanner.next(res)) ;
    assertEquals(1, res.size());
    assertEquals(Bytes.toLong(res.get(0).getValue()), 42L);

    /**
     * Scan the index with a non matching expression
     */
    idxScan = new IdxScan();
    idxScan.addFamily(family);
    idxScan.setExpression(Comparison.comparison(family, qualLong,
      Comparison.Operator.EQ, Bytes.toBytes(24L)));
    if (!memStoreEmpty) {
      idxScan.setFilter(new ValueFilter(CompareFilter.CompareOp.EQUAL,
        new BinaryComparator(Bytes.toBytes(24L))));
    }
    scanner = region.getScanner(idxScan);
    res.clear();

View Full Code Here


    /**
     * Scan the index with a matching expression
     */
    IdxScan idxScan = new IdxScan();
    idxScan.addFamily(family);
    idxScan.setExpression(Comparison.comparison(family, qualLong,
      Comparison.Operator.EQ, Bytes.toBytes(42L)));
    if (!memStoreEmpty) {
      idxScan.setFilter(new SingleColumnValueFilter(family, qualLong,
        CompareFilter.CompareOp.EQUAL,
        new BinaryComparator(Bytes.toBytes(42L))));
    }
    scanner = region.getScanner(idxScan);
    res.clear();

    //long start = System.nanoTime();
    while (scanner.next(res)) ;
    //long end = System.nanoTime();
    //System.out.println("memStoreEmpty=" + memStoreEmpty + ", time=" + (end - start) / 1000000D);
    assertEquals(numColumns, res.size());
    for (KeyValue kv : res) {
      if (Bytes.equals(kv.getQualifier(), qualLong)) {
        assertEquals(42L, Bytes.toLong(kv.getValue()));
      }
    }

    /**
     * Scan the index with a non matching expression
     */
    idxScan = new IdxScan();
    idxScan.addFamily(family);
    idxScan.setExpression(Comparison.comparison(family, qualLong,
      Comparison.Operator.EQ, Bytes.toBytes(1000000000L)));
    if (!memStoreEmpty) {
      idxScan.setFilter(new SingleColumnValueFilter(family, qualLong,
        CompareFilter.CompareOp.EQUAL,
        new BinaryComparator(Bytes.toBytes(1000000000L))));
    }
    scanner = region.getScanner(idxScan);
    res.clear();

    while (scanner.next(res)) ;
    assertEquals(0, res.size());


    /**
     * Scan for all the records which are greater than 49499
     */
    idxScan = new IdxScan();
    idxScan.addFamily(family);
    long min = numRows - 500L;
    idxScan.setExpression(Comparison.comparison(family, qualLong,
      Comparison.Operator.GTE, Bytes.toBytes(min)));
    if (!memStoreEmpty) {
      idxScan.setFilter(new SingleColumnValueFilter(family, qualLong,
        CompareFilter.CompareOp.GREATER_OR_EQUAL,
        new BinaryComparator(Bytes.toBytes(min))));
    }
    scanner = region.getScanner(idxScan);
    res.clear();

    //long start = System.nanoTime();
    while (scanner.next(res)) ;
    //long end = System.nanoTime();
    //System.out.println("scan for val >= min memStoreEmpty=" + memStoreEmpty + ", time=" + (end - start)/1000000D);
    assertEquals(500 * numColumns, res.size());

    /**
     * Scan for all the records which are greater than 49499
     */
    idxScan = new IdxScan();
    idxScan.addFamily(family);
    min = numRows / 2;
    long delta = 100;
    long max = min + delta;
    idxScan.setExpression(
      And.and(Comparison.comparison(family, qualLong, Comparison.Operator.GTE, Bytes.toBytes(min)),
        Comparison.comparison(family, qualLong, Comparison.Operator.LT, Bytes.toBytes(max))));
    if (!memStoreEmpty) {
      idxScan.setFilter(new FilterList(Arrays.<Filter>asList(
        new SingleColumnValueFilter(family, qualLong, CompareFilter.CompareOp.GREATER_OR_EQUAL,
          new BinaryComparator(Bytes.toBytes(min))),
        new SingleColumnValueFilter(family, qualLong, CompareFilter.CompareOp.LESS,
          new BinaryComparator(Bytes.toBytes(max))))
      ));
View Full Code Here

  private void checkScanWithThreeColumns(byte[] family, boolean memStoreEmpty, int numRows, int numColumns) throws IOException {

    /**
     * Scan the index with a matching or expression on two indices
     */
    IdxScan idxScan = new IdxScan();
    idxScan.addFamily(family);
    int low = numRows / 10;
    int high = numRows - low;
    idxScan.setExpression(Or.or(Comparison.comparison(family, qualLong, Comparison.Operator.GTE, Bytes.toBytes((long) high)),
      Comparison.comparison(family, qualDouble, Comparison.Operator.LT, Bytes.toBytes((double) low))));
    if (!memStoreEmpty) {
      idxScan.setFilter(new FilterList(FilterList.Operator.MUST_PASS_ONE,
        Arrays.<Filter>asList(
          new SingleColumnValueFilter(family, qualLong, CompareFilter.CompareOp.GREATER_OR_EQUAL,
            new BinaryComparator(Bytes.toBytes((long) high))),
          new SingleColumnValueFilter(family, qualDouble, CompareFilter.CompareOp.LESS,
            new BinaryComparator(Bytes.toBytes((double) low))))
      ));
    }
    InternalScanner scanner = region.getScanner(idxScan);
    List<KeyValue> res = new ArrayList<KeyValue>();

    //long start = System.nanoTime();
    while (scanner.next(res)) ;
    //long end = System.nanoTime();
    //System.out.println("[top and botoom 10%] memStoreEmpty=" + memStoreEmpty + ", time=" + (end - start)/1000000D);
    assertEquals(numRows / 5 * numColumns, res.size());

    /**
     * Scan the index with a matching and expression on two indices
     */
    idxScan = new IdxScan();
    idxScan.addFamily(family);
    int half = numRows / 2;
    idxScan.setExpression(And.and(Comparison.comparison(family, qualLong, Comparison.Operator.GTE, Bytes.toBytes((long) half)),
      Comparison.comparison(family, qualBytes, Comparison.Operator.EQ, Bytes.toBytes("str" + 30))));
    if (!memStoreEmpty) {
      idxScan.setFilter(new FilterList(FilterList.Operator.MUST_PASS_ALL,
        Arrays.<Filter>asList(
          new SingleColumnValueFilter(family, qualLong, CompareFilter.CompareOp.GREATER_OR_EQUAL,
            new BinaryComparator(Bytes.toBytes((long) half))),
          new SingleColumnValueFilter(family, qualBytes, CompareFilter.CompareOp.EQUAL,
            new BinaryComparator(Bytes.toBytes("str" + 30))))
View Full Code Here

    boolean memStoreEmpty, int numRows, int numColumns) throws IOException {

    /**
     * Scan the index with a matching or expression on two indices
     */
    IdxScan idxScan = new IdxScan();
    final byte[] longVal = Bytes.toBytes((long) 1);
    final byte[] doubleVal = Bytes.toBytes((double) 4);
    final byte[] bytesVal = Bytes.toBytes(String.format("%04d", 9));
    idxScan.setExpression(
      Or.or(Comparison.comparison(family1, qualLong, Comparison.Operator.EQ, longVal),
        Comparison.comparison(family1, qualDouble, Comparison.Operator.EQ, doubleVal),
        Comparison.comparison(family2, qualBytes, Comparison.Operator.EQ, bytesVal)));
    if (!memStoreEmpty) {
      idxScan.setFilter(new FilterList(FilterList.Operator.MUST_PASS_ONE,
        Arrays.<Filter>asList(
          new SingleColumnValueFilter(family1, qualLong, CompareFilter.CompareOp.EQUAL,
            new BinaryComparator(longVal)),
          new SingleColumnValueFilter(family1, qualDouble, CompareFilter.CompareOp.EQUAL,
            new BinaryComparator(doubleVal)),
View Full Code Here

  private void checkIndexedScanWithMultipleVersions(byte[] family, boolean memStoreEmpty, int numRows, int numVersions) throws IOException {

    /**
     * Scan the index with a matching or expression on two indices
     */
    IdxScan idxScan = new IdxScan();
    idxScan.addFamily(family);

    int[] values = new int[numVersions];
    for (int i = 0; i < numVersions; i++) {
      values[i] = 10 * i + 7;
    }
View Full Code Here

    boolean memStoreEmpty, long value, int expectedCount) throws IOException {

    /**
     * Scan the index with a matching or expression on two indices
     */
    IdxScan idxScan = new IdxScan();
    idxScan.addFamily(family);
    idxScan.setExpression(Comparison.comparison(family, qualLong,
      Comparison.Operator.EQ, Bytes.toBytes(value)));
    if (!memStoreEmpty) {
      idxScan.setFilter(new SingleColumnValueFilter(family, qualLong,
        CompareFilter.CompareOp.EQUAL,
        new BinaryComparator(Bytes.toBytes(value))));
    }
    InternalScanner scanner = region.getScanner(idxScan);
    List<KeyValue> res = new ArrayList<KeyValue>();
View Full Code Here

    throws IOException {

    /**
     * Scan the index with a matching or expression on two indices
     */
    IdxScan idxScan = new IdxScan();
    idxScan.addFamily(family);
    idxScan.setExpression(
      Comparison.and(Comparison.comparison(family, qualLong,
        Comparison.Operator.GTE, Bytes.toBytes(minValue)),
        Comparison.comparison(family, qualLong,
          Comparison.Operator.LTE, Bytes.toBytes(maxValue))));
    if (!memStoreEmpty) {
      idxScan.setFilter(new FilterList(FilterList.Operator.MUST_PASS_ALL,
        Arrays.<Filter>asList(new SingleColumnValueFilter(family, qualLong,
          CompareFilter.CompareOp.GREATER_OR_EQUAL,
          new BinaryComparator(Bytes.toBytes(minValue))),
          new SingleColumnValueFilter(family, qualLong,
            CompareFilter.CompareOp.LESS_OR_EQUAL,
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.client.idx.IdxScan

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.