當前位置: 首頁>>代碼示例>>Java>>正文


Java ResultScanner.next方法代碼示例

本文整理匯總了Java中org.apache.hadoop.hbase.client.ResultScanner.next方法的典型用法代碼示例。如果您正苦於以下問題:Java ResultScanner.next方法的具體用法?Java ResultScanner.next怎麽用?Java ResultScanner.next使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.hadoop.hbase.client.ResultScanner的用法示例。


在下文中一共展示了ResultScanner.next方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: qualifierFilter

import org.apache.hadoop.hbase.client.ResultScanner; //導入方法依賴的package包/類
/**
 * 列限定符過濾器
 *
 * @param tableName  表名
 * @param columnName 列限定符
 * @param count      數量
 */
public void qualifierFilter(String tableName, String columnName, int count) {
    HBaseConfiguration hBaseConfiguration = new HBaseConfiguration();
    Table table = hBaseConfiguration.table(tableName);
    Scan scan = new Scan();
    //使用列族過濾器
    scan.setFilter(new QualifierFilter(CompareFilter.CompareOp.EQUAL, new BinaryComparator(Bytes.toBytes(columnName))));//直接行健
    //scan.setFilter(new QualifierFilter(CompareFilter.CompareOp.EQUAL, new RegexStringComparator("row.*")));//正則表達式
    //scan.setFilter(new QualifierFilter(CompareFilter.CompareOp.EQUAL, new SubstringComparator("row")));//字符串包含
    //scan.setFilter(new QualifierFilter(CompareFilter.CompareOp.EQUAL, new BinaryPrefixComparator("m".getBytes())));//字符串前綴
    scan.setCaching(10);
    scan.setBatch(10);
    try {
        ResultScanner scanner = table.getScanner(scan);
        Result[] results = scanner.next(count);
        HBaseResultUtil.print(results);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
開發者ID:mumuhadoop,項目名稱:mumu-hbase,代碼行數:27,代碼來源:HBaseFilterOperation.java

示例2: getRowOrBefore

import org.apache.hadoop.hbase.client.ResultScanner; //導入方法依賴的package包/類
public Result getRowOrBefore(Table table, byte[] row, byte[] family) throws IOException {
  long start = System.currentTimeMillis();
  Scan scan = new Scan();
  scan.addFamily(family);
  scan.setReversed(true);
  scan.setStartRow(row);
  scan.setCacheBlocks(false);
  scan.setCaching(1);
  scan.setSmall(true);
  ResultScanner scanner = table.getScanner(scan);
  Result ret = scanner.next();
  scanner.close();
  prevRowTotalTime += System.currentTimeMillis() - start;
  prevRowTotalCount++;
  return ret;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:17,代碼來源:MDIndex.java

示例3: findStartNode

import org.apache.hadoop.hbase.client.ResultScanner; //導入方法依賴的package包/類
private static CINode findStartNode(Table table, byte[] startKey) throws IOException {
  Scan scan = new Scan();
  scan.setStartRow(startKey);
  scan.setBatch(1);
  scan.addColumn(FAMILY_NAME, COLUMN_PREV);

  long t1 = System.currentTimeMillis();
  ResultScanner scanner = table.getScanner(scan);
  Result result = scanner.next();
  long t2 = System.currentTimeMillis();
  scanner.close();

  if ( result != null) {
    CINode node = getCINode(result, new CINode());
    System.out.printf("FSR %d %s\n", t2 - t1, Bytes.toStringBinary(node.key));
    return node;
  }

  System.out.println("FSR " + (t2 - t1));

  return null;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:23,代碼來源:IntegrationTestBigLinkedList.java

示例4: countHBaseTable

import org.apache.hadoop.hbase.client.ResultScanner; //導入方法依賴的package包/類
protected int countHBaseTable(String tableName, String colFamily)
    throws IOException {
  int count = 0;
  HTable table = new HTable(new Configuration(
      hbaseTestUtil.getConfiguration()), Bytes.toBytes(tableName));
  try {
    ResultScanner scanner = table.getScanner(Bytes.toBytes(colFamily));
    for(Result result = scanner.next();
        result != null;
        result = scanner.next()) {
      count++;
    }
  } finally {
    table.close();
  }
  return count;
}
 
開發者ID:aliyun,項目名稱:aliyun-maxcompute-data-collectors,代碼行數:18,代碼來源:HBaseTestCase.java

示例5: testScanForSuperUserWithFewerLabelAuths

import org.apache.hadoop.hbase.client.ResultScanner; //導入方法依賴的package包/類
@Test
public void testScanForSuperUserWithFewerLabelAuths() throws Throwable {
  String[] auths = { SECRET };
  String user = "admin";
  try (Connection conn = ConnectionFactory.createConnection(conf)) {
    VisibilityClient.setAuths(conn, auths, user);
  }
  TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
  final Table table = createTableAndWriteDataWithLabels(tableName, SECRET + "&" + CONFIDENTIAL
      + "&!" + PRIVATE, SECRET + "&!" + PRIVATE);
  PrivilegedExceptionAction<Void> scanAction = new PrivilegedExceptionAction<Void>() {
    public Void run() throws Exception {
      Scan s = new Scan();
      s.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL));
      try (Connection connection = ConnectionFactory.createConnection(conf);
           Table t = connection.getTable(table.getName())) {
        ResultScanner scanner = t.getScanner(s);
        Result[] result = scanner.next(5);
        assertTrue(result.length == 2);
      }
      return null;
    }
  };
  SUPERUSER.runAs(scanAction);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:26,代碼來源:TestVisibilityLabelsWithACL.java

示例6: testSmallScansDoNotAllowPartials

import org.apache.hadoop.hbase.client.ResultScanner; //導入方法依賴的package包/類
public void testSmallScansDoNotAllowPartials(Scan baseScan) throws Exception {
  Scan scan = new Scan(baseScan);
  scan.setAllowPartialResults(true);
  scan.setSmall(true);
  scan.setMaxResultSize(1);

  ResultScanner scanner = TABLE.getScanner(scan);
  Result r = null;

  while ((r = scanner.next()) != null) {
    assertFalse(r.isPartial());
  }

  scanner.close();
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:16,代碼來源:TestPartialResultsFromClientSide.java

示例7: testBatchingResultWhenRegionMove

import org.apache.hadoop.hbase.client.ResultScanner; //導入方法依賴的package包/類
@Test
public void testBatchingResultWhenRegionMove() throws IOException {
  Table table =
      createTestTable(TableName.valueOf("testBatchingResultWhenRegionMove"), ROWS, FAMILIES,
          QUALIFIERS, VALUE);

  moveRegion(table, 1);

  Scan scan = new Scan();
  scan.setCaching(1);
  scan.setBatch(1);

  ResultScanner scanner = table.getScanner(scan);
  for (int i = 0; i < NUM_FAMILIES * NUM_QUALIFIERS - 1; i++) {
    scanner.next();
  }
  Result result1 = scanner.next();
  assertEquals(1, result1.rawCells().length);
  Cell c1 = result1.rawCells()[0];
  assertCell(c1, ROWS[0], FAMILIES[NUM_FAMILIES - 1], QUALIFIERS[NUM_QUALIFIERS - 1]);

  moveRegion(table, 2);

  Result result2 = scanner.next();
  assertEquals(1, result2.rawCells().length);
  Cell c2 = result2.rawCells()[0];
  assertCell(c2, ROWS[1], FAMILIES[0], QUALIFIERS[0]);

  moveRegion(table, 3);

  Result result3 = scanner.next();
  assertEquals(1, result3.rawCells().length);
  Cell c3 = result3.rawCells()[0];
  assertCell(c3, ROWS[1], FAMILIES[0], QUALIFIERS[1]);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:36,代碼來源:TestPartialResultsFromClientSide.java

示例8: countRows

import org.apache.hadoop.hbase.client.ResultScanner; //導入方法依賴的package包/類
/**
 * Counts the number of row to verify data loss or non-dataloss.
 */
int countRows() throws IOException {
   Scan s = new Scan();
   ResultScanner rs = tbl.getScanner(s);
   int i = 0;
   while(rs.next() !=null) {
     i++;
   }
   return i;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:13,代碼來源:TestHBaseFsck.java

示例9: testScanForUserWithFewerLabelAuthsThanLabelsInScanAuthorizations

import org.apache.hadoop.hbase.client.ResultScanner; //導入方法依賴的package包/類
@Test
public void testScanForUserWithFewerLabelAuthsThanLabelsInScanAuthorizations() throws Throwable {
  String[] auths = { SECRET };
  String user = "user2";
  VisibilityClient.setAuths(TEST_UTIL.getConnection(), auths, user);
  TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
  final Table table = createTableAndWriteDataWithLabels(tableName, SECRET + "&" + CONFIDENTIAL
      + "&!" + PRIVATE, SECRET + "&!" + PRIVATE);
  SecureTestUtil.grantOnTable(TEST_UTIL, NORMAL_USER2.getShortName(), tableName,
    null, null, Permission.Action.READ);
  PrivilegedExceptionAction<Void> scanAction = new PrivilegedExceptionAction<Void>() {
    public Void run() throws Exception {
      Scan s = new Scan();
      s.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL));
      try (Connection connection = ConnectionFactory.createConnection(conf);
           Table t = connection.getTable(table.getName())) {
        ResultScanner scanner = t.getScanner(s);
        Result result = scanner.next();
        assertTrue(!result.isEmpty());
        assertTrue(Bytes.equals(Bytes.toBytes("row2"), result.getRow()));
        result = scanner.next();
        assertNull(result);
      }
      return null;
    }
  };
  NORMAL_USER2.runAs(scanAction);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:29,代碼來源:TestVisibilityLabelsWithACL.java

示例10: doIndexScan

import org.apache.hadoop.hbase.client.ResultScanner; //導入方法依賴的package包/類
private void doIndexScan() throws IOException {
  ScanRange.ScanRangeList rangeList = new ScanRange.ScanRangeList();
  FilterList filterList = new FilterList();
  CompareFilter.CompareOp startOp = CompareFilter.CompareOp.GREATER_OR_EQUAL;
  CompareFilter.CompareOp stopOp = CompareFilter.CompareOp.LESS_OR_EQUAL;
  for (int i = 0; i < indexColumnNames.length && i < scanValues.length; i++) {
    rangeList.addScanRange(new ScanRange(familyName, Bytes.toBytes(indexColumnNames[i]),
        Bytes.toBytes(scanValues[i][0]), Bytes.toBytes(scanValues[i][1]), startOp, stopOp,
        DataType.INT));
    filterList.addFilter(
        new SingleColumnValueFilter(familyName, Bytes.toBytes(indexColumnNames[i]), startOp,
            Bytes.toBytes(scanValues[i][0])));
    filterList.addFilter(
        new SingleColumnValueFilter(familyName, Bytes.toBytes(indexColumnNames[i]), stopOp,
            Bytes.toBytes(scanValues[i][1])));
  }
  Scan scan = new Scan();
  scan.setFilter(filterList);
  if (rangeList.getRanges().size() > 0) {
    scan.setAttribute(ScanRange.SCAN_RANGE_ATTRIBUTE_STR, rangeList.toBytesAttribute());
  }
  scan.setId("LMD-scan");
  scan.setCaching(1);
  ResultScanner scanner = BaseIndexScanner.getIndexScanner(conn, relation, scan);
  Result result;
  int count = 0;
  while ((result = scanner.next()) != null) {
    count++;
    if (PRINT_RESULT) printResult(result);
  }
  scanner.close();
  System.out.println("LMDIndex scan has " + count + " records");
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:34,代碼來源:LMDTester.java

示例11: testVisibilityLabelsInScanThatDoesNotMatchAnyDefinedLabels

import org.apache.hadoop.hbase.client.ResultScanner; //導入方法依賴的package包/類
@Test
public void testVisibilityLabelsInScanThatDoesNotMatchAnyDefinedLabels() throws Exception {
  TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
  try ( Table table = createTableAndWriteDataWithLabels(tableName, "(" + SECRET + "|"
      + CONFIDENTIAL + ")", PRIVATE)){
    Scan s = new Scan();
    s.setAuthorizations(new Authorizations("SAMPLE"));
    ResultScanner scanner = table.getScanner(s);
    Result[] next = scanner.next(3);
    assertTrue(next.length == 0);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:13,代碼來源:TestVisibilityLabels.java

示例12: assertAllOnLine

import org.apache.hadoop.hbase.client.ResultScanner; //導入方法依賴的package包/類
private void assertAllOnLine(final HTable t) throws IOException {
  NavigableMap<HRegionInfo, ServerName> regions = t.getRegionLocations();
  for (Map.Entry<HRegionInfo, ServerName> e: regions.entrySet()) {
    byte [] startkey = e.getKey().getStartKey();
    Scan s = new Scan(startkey);
    ResultScanner scanner = t.getScanner(s);
    Result r = scanner.next();
    org.junit.Assert.assertTrue(r != null && r.size() > 0);
    scanner.close();
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:12,代碼來源:TestLoadAndSwitchEncodeOnDisk.java

示例13: testVisibilityLabelsThatDoesNotPassTheCriteria

import org.apache.hadoop.hbase.client.ResultScanner; //導入方法依賴的package包/類
@Test
public void testVisibilityLabelsThatDoesNotPassTheCriteria() throws Exception {
  TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
  try (Table table = createTableAndWriteDataWithLabels(tableName,
      "(" + SECRET + "|" + CONFIDENTIAL + ")", PRIVATE)){
    Scan s = new Scan();
    s.setAuthorizations(new Authorizations(PUBLIC));
    ResultScanner scanner = table.getScanner(s);
    Result[] next = scanner.next(3);
    assertTrue(next.length == 0);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:13,代碼來源:TestVisibilityLabels.java

示例14: testVisibilityLabelsWithDeleteFamilyVersion

import org.apache.hadoop.hbase.client.ResultScanner; //導入方法依賴的package包/類
@Test
public void testVisibilityLabelsWithDeleteFamilyVersion() throws Exception {
  setAuths();
  final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
  long[] ts = new long[] { 123l, 125l };
  try (Table table = createTableAndWriteDataWithLabels(tableName, ts,
      CONFIDENTIAL + "|" + TOPSECRET, SECRET)) {
    PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
      @Override
      public Void run() throws Exception {
        try (Connection connection = ConnectionFactory.createConnection(conf);
             Table table = connection.getTable(tableName)) {
          Delete d = new Delete(row1);
          d.setCellVisibility(new CellVisibility(TOPSECRET + "|" + CONFIDENTIAL));
          d.deleteFamilyVersion(fam, 123l);
          table.delete(d);
        } catch (Throwable t) {
          throw new IOException(t);
        }
        return null;
      }
    };
    SUPERUSER.runAs(actiona);

    TEST_UTIL.getHBaseAdmin().flush(tableName);
    Scan s = new Scan();
    s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL));
    ResultScanner scanner = table.getScanner(s);
    Result[] next = scanner.next(3);
    assertTrue(next.length == 1);
    CellScanner cellScanner = next[0].cellScanner();
    cellScanner.advance();
    Cell current = cellScanner.current();
    assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
        current.getRowLength(), row2, 0, row2.length));
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:38,代碼來源:TestVisibilityLabelsWithDeletes.java

示例15: testVisibilityLabelsWithDeleteColumnExactVersion

import org.apache.hadoop.hbase.client.ResultScanner; //導入方法依賴的package包/類
@Test
public void testVisibilityLabelsWithDeleteColumnExactVersion() throws Exception {
  setAuths();
  final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
  long[] ts = new long[] { 123l, 125l };
  try (Table table = createTableAndWriteDataWithLabels(tableName, ts,
      CONFIDENTIAL + "|" + TOPSECRET, SECRET);) {
    PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
      @Override
      public Void run() throws Exception {
        try (Connection connection = ConnectionFactory.createConnection(conf);
             Table table = connection.getTable(tableName)) {
          Delete d = new Delete(row1);
          d.setCellVisibility(new CellVisibility(TOPSECRET + "|" + CONFIDENTIAL));
          d.addColumn(fam, qual, 123l);
          table.delete(d);
        } catch (Throwable t) {
          throw new IOException(t);
        }
        return null;
      }
    };
    SUPERUSER.runAs(actiona);

    TEST_UTIL.getHBaseAdmin().flush(tableName);
    Scan s = new Scan();
    s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL));
    ResultScanner scanner = table.getScanner(s);
    Result[] next = scanner.next(3);
    assertTrue(next.length == 1);
    CellScanner cellScanner = next[0].cellScanner();
    cellScanner.advance();
    Cell current = cellScanner.current();
    assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
        current.getRowLength(), row2, 0, row2.length));
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:38,代碼來源:TestVisibilityLabelsWithDeletes.java


注:本文中的org.apache.hadoop.hbase.client.ResultScanner.next方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。