Package org.apache.hadoop.hbase.client

Examples of org.apache.hadoop.hbase.client.ResultScanner


        byte[] row = randomRowKey();
        Put put = new Put(row);
        put.add(cf, row, row);
        hTable.put(put);

        ResultScanner rs = hTable.getScanner(new Scan());
       
        Assert.assertArrayEquals(row, rs.next().getRow());
        assertMetricsUpdated(OpType.PUT, OpType.GET_SCANNER, OpType.RESULTSCANNER_NEXT);
       
        rs.close();
    }
View Full Code Here


        byte[] row = randomRowKey();
        Put put = new Put(row);
        put.add(cf, row, row);
        hTable.put(put);

        ResultScanner rs = hTable.getScanner(new Scan());
       
        Assert.assertArrayEquals(row, rs.iterator().next().getRow());
        assertMetricsUpdated(OpType.PUT, OpType.GET_SCANNER, OpType.RESULTSCANNER_ITERATOR,
                OpType.RESULTITERATOR_NEXT);
       
        rs.close();
    }
View Full Code Here

        Put put2 = new Put(rows.get(1));
        put1.add(cf, rows.get(0), rows.get(0));
        put2.add(cf, rows.get(1), rows.get(1));
        hTable.batch(ImmutableList.<Row>of(put1, put2));

        ResultScanner rs = hTable.getScanner(new Scan());
       
        Result[] results = rs.next(2);
        Assert.assertArrayEquals(rows.get(0), results[0].getRow());
        Assert.assertArrayEquals(rows.get(1), results[1].getRow());

        rs.close();

        assertMetricsUpdated(OpType.BATCH, OpType.GET_SCANNER, OpType.RESULTSCANNER_NEXTARRAY,
                OpType.RESULTSCANNER_CLOSE);
    }
View Full Code Here

        Put put = new Put(row);
        put.add(cf, row, row);
        hTable.put(put);

        ResultScanner rs = hTable.getScanner(new Scan());

        Assert.assertTrue(rs.iterator().hasNext());

        rs.close();

        assertMetricsUpdated(OpType.PUT, OpType.GET_SCANNER, OpType.RESULTSCANNER_ITERATOR,
                OpType.RESULTSCANNER_CLOSE, OpType.RESULTITERATOR_HASNEXT);
    }
View Full Code Here

        Put put = new Put(row);
        put.add(cf, row, row);
        hTable.put(put);

        ResultScanner rs = hTable.getScanner(cf);

        Assert.assertNotNull(rs.next());

        assertMetricsUpdated(OpType.PUT, OpType.GET_SCANNER, OpType.RESULTSCANNER_NEXT);
       
        rs.close();
    }
View Full Code Here

       Put put = new Put(row);
       put.add(cf, qual, row);
       hTable.put(put);

       ResultScanner rs = hTable.getScanner(cf, qual);

       Assert.assertNotNull(rs.next());

       assertMetricsUpdated(OpType.PUT, OpType.GET_SCANNER, OpType.RESULTSCANNER_NEXT);

       rs.close();
   }
View Full Code Here

       Put put2 = new Put(rows.get(1));
       put1.add(cf, rows.get(0), rows.get(0));
       put2.add(cf, rows.get(1), rows.get(1));
       hTable.put(ImmutableList.of(put1, put2));

       ResultScanner rs = hTable.getScanner(cf);
       Result[] results = rs.next(2);
       Assert.assertArrayEquals(rows.get(0), results[0].getRow());
       Assert.assertArrayEquals(rows.get(1), results[1].getRow());
      
       assertMetricsUpdated(OpType.MULTIPUT, OpType.RESULTSCANNER_NEXTARRAY,
               OpType.GET_SCANNER);
      
       rs.close();
   }
View Full Code Here

           Put put = new Put(row);
           put.add(cf, row, row);
           hTable.put(put);
       }

       ResultScanner rs = hTable.getScanner(new Scan());
       int countRows = 0;
       while(rs.next() != null) {
           countRows++;
       }
       rs.close();
       Assert.assertEquals(ROWS_TO_INSERT, countRows);
      
       List<Delete> deletes = new ArrayList<Delete>();
       for(byte[] row: rows) {
           deletes.add(new Delete(row));
       }
       hTable.delete(deletes);
      
       rs = hTable.getScanner(new Scan());
       countRows = 0;
       while(rs.next() != null) {
           countRows++;
       }
       Assert.assertEquals(0, countRows);
       rs.close();
      
       assertMetricsUpdated(OpType.PUT, OpType.RESULTSCANNER_NEXT, OpType.MULTIDELETE,
               OpType.RESULTSCANNER_CLOSE, OpType.GET_SCANNER);
      
   }
View Full Code Here

      }
    }

    public void scannerClose(int id) throws IOError, IllegalArgument {
      LOG.debug("scannerClose: id=" + id);
      ResultScanner scanner = getScanner(id);
      if (scanner == null) {
        String message = "scanner ID is invalid";
        LOG.warn(message);
        throw new IllegalArgument("scanner ID is invalid");
      }
      scanner.close();
      removeScanner(id);
    }
View Full Code Here

    @Override
    public List<TRowResult> scannerGetList(int id,int nbRows)
        throws IllegalArgument, IOError {
      LOG.debug("scannerGetList: id=" + id);
      ResultScanner scanner = getScanner(id);
      if (null == scanner) {
        String message = "scanner ID is invalid";
        LOG.warn(message);
        throw new IllegalArgument("scanner ID is invalid");
      }

      Result [] results = null;
      try {
        results = scanner.next(nbRows);
        if (null == results) {
          return new ArrayList<TRowResult>();
        }
      } catch (IOException e) {
        LOG.warn(e.getMessage(), e);
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.client.ResultScanner

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.