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


Java Scan.setReversed方法代碼示例

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


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

示例1: testWhileMatchFilterWithFilterRowKeyWithReverseScan

import org.apache.hadoop.hbase.client.Scan; //導入方法依賴的package包/類
public void testWhileMatchFilterWithFilterRowKeyWithReverseScan()
    throws Exception {
  Scan s = new Scan();
  String prefix = "testRowOne";
  WhileMatchFilter filter = new WhileMatchFilter(new PrefixFilter(
      Bytes.toBytes(prefix)));
  s.setFilter(filter);
  s.setReversed(true);

  InternalScanner scanner = this.region.getScanner(s);
  while (true) {
    ArrayList<Cell> values = new ArrayList<Cell>();
    boolean isMoreResults = scanner.next(values);
    if (!isMoreResults
        || !Bytes.toString(values.get(0).getRow()).startsWith(prefix)) {
      Assert.assertTrue(
          "The WhileMatchFilter should now filter all remaining",
          filter.filterAllRemaining());
    }
    if (!isMoreResults) {
      break;
    }
  }
  scanner.close();
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:26,代碼來源:TestFilter.java

示例2: testExpectedValuesOfPartialResults

import org.apache.hadoop.hbase.client.Scan; //導入方法依賴的package包/類
public void testExpectedValuesOfPartialResults(boolean reversed) throws Exception {
  Scan partialScan = new Scan();
  partialScan.setMaxVersions();
  // Max result size of 1 ensures that each RPC request will return a single cell. The scanner
  // will need to reconstruct the results into a complete result before returning to the caller
  partialScan.setMaxResultSize(1);
  partialScan.setReversed(reversed);
  ResultScanner partialScanner = TABLE.getScanner(partialScan);

  final int startRow = reversed ? ROWS.length - 1 : 0;
  final int endRow = reversed ? -1 : ROWS.length;
  final int loopDelta = reversed ? -1 : 1;
  String message;

  for (int row = startRow; row != endRow; row = row + loopDelta) {
    message = "Ensuring the expected keyValues are present for row " + row;
    List<Cell> expectedKeyValues = createKeyValuesForRow(ROWS[row], FAMILIES, QUALIFIERS, VALUE);
    Result result = partialScanner.next();
    assertFalse(result.isPartial());
    verifyResult(result, expectedKeyValues, message);
  }

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

示例3: getRowOrBefore

import org.apache.hadoop.hbase.client.Scan; //導入方法依賴的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

示例4: insertOneRecord

import org.apache.hadoop.hbase.client.Scan; //導入方法依賴的package包/類
@Override protected void insertOneRecord(AbstractDITBRecord record) throws IOException {
  // note, MD-HBase get before update, we summarize the time in get seperately
  MDPoint point = record.toMDPoint();
  byte[] row = MDUtils.bitwiseZip(point.values, mdAdmin.getDimensions());
  // get before row
  long startTime = System.currentTimeMillis();
  Scan scan = new Scan();
  scan.addFamily(MDHBaseAdmin.BUCKET_FAMILY);
  scan.setReversed(true);
  scan.setStartRow(row);
  scan.setCacheBlocks(false);
  scan.setCaching(1);
  scan.setSmall(true);
  ResultScanner scanner = table.getScanner(scan);
  Result result = scanner.next();
  scanner.close();
  gbuTime += System.currentTimeMillis() - startTime;
  gbuCount++;
  // default scan
  if (result == null) {
    row = mdAdmin.getBucketSuffixRow(point);
  } else {
    row = result.getRow();
  }
  table.incrementColumnValue(row, MDHBaseAdmin.BUCKET_FAMILY,
      MDHBaseAdmin.BUCKET_SIZE_QUALIFIER, 1);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:28,代碼來源:PerfMD.java

示例5: processGet

import org.apache.hadoop.hbase.client.Scan; //導入方法依賴的package包/類
@Override protected Result processGet(Table table, Get get) throws IOException {
  Scan scan = new Scan();
  scan.addFamily(MDHBaseAdmin.BUCKET_FAMILY);
  scan.setReversed(true);
  scan.setStartRow(get.getRow());
  scan.setCacheBlocks(false);
  scan.setCaching(1);
  scan.setSmall(true);
  ResultScanner scanner = table.getScanner(scan);
  Result ret = scanner.next();
  scanner.close();
  return ret;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:14,代碼來源:PerfMD.java

示例6: getRowOrBefore

import org.apache.hadoop.hbase.client.Scan; //導入方法依賴的package包/類
private Result getRowOrBefore(byte[] tableName, byte[] row, byte[] family) throws IOException {
  Scan scan = new Scan(row);
  scan.setReversed(true);
  scan.addFamily(family);
  scan.setStartRow(row);
  Table table = getTable(tableName);
  try (ResultScanner scanner = table.getScanner(scan)) {
    return scanner.next();
  } finally{
    if(table != null){
      table.close();
    }
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:15,代碼來源:ThriftServerRunner.java

示例7: testPrefixFilterWithReverseScan

import org.apache.hadoop.hbase.client.Scan; //導入方法依賴的package包/類
public void testPrefixFilterWithReverseScan() throws Exception {
  // Grab rows from group one (half of total)
  long expectedRows = this.numRows / 2;
  long expectedKeys = this.colsPerRow;
  Scan s = new Scan();
  s.setReversed(true);
  s.setFilter(new PrefixFilter(Bytes.toBytes("testRowOne")));
  verifyScan(s, expectedRows, expectedKeys);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:10,代碼來源:TestFilter.java

示例8: testWhileMatchFilterWithFilterRowWithReverseScan

import org.apache.hadoop.hbase.client.Scan; //導入方法依賴的package包/類
public void testWhileMatchFilterWithFilterRowWithReverseScan()
    throws Exception {
  final int pageSize = 4;

  Scan s = new Scan();
  s.setReversed(true);
  WhileMatchFilter filter = new WhileMatchFilter(new PageFilter(pageSize));
  s.setFilter(filter);

  InternalScanner scanner = this.region.getScanner(s);
  int scannerCounter = 0;
  while (true) {
    boolean isMoreResults = scanner.next(new ArrayList<Cell>());
    scannerCounter++;

    if (scannerCounter >= pageSize) {
      Assert.assertTrue(
          "The WhileMatchFilter should now filter all remaining",
          filter.filterAllRemaining());
    }
    if (!isMoreResults) {
      break;
    }
  }
  scanner.close();
  Assert.assertEquals("The page filter returned more rows than expected",
      pageSize, scannerCounter);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:29,代碼來源:TestFilter.java

示例9: testReverseScanWithoutPadding

import org.apache.hadoop.hbase.client.Scan; //導入方法依賴的package包/類
@Test
public void testReverseScanWithoutPadding() throws Exception {
  byte[] row1 = Bytes.toBytes("a");
  byte[] row2 = Bytes.toBytes("ab");
  byte[] row3 = Bytes.toBytes("b");

  Put put1 = new Put(row1);
  put1.addColumn(cfName, cqName, HConstants.EMPTY_BYTE_ARRAY);
  Put put2 = new Put(row2);
  put2.addColumn(cfName, cqName, HConstants.EMPTY_BYTE_ARRAY);
  Put put3 = new Put(row3);
  put3.addColumn(cfName, cqName, HConstants.EMPTY_BYTE_ARRAY);

  region.put(put1);
  region.put(put2);
  region.put(put3);
  region.flush(true);
  Scan scan = new Scan();
  scan.setCacheBlocks(false);
  scan.setReversed(true);
  scan.setFilter(new FirstKeyOnlyFilter());
  scan.addFamily(cfName);
  RegionScanner scanner = region.getScanner(scan);
  List<Cell> res = new ArrayList<Cell>();
  int count = 1;
  while (scanner.next(res)) {
    count++;
  }
  assertEquals(Bytes.toString(res.get(0).getRowArray(), res.get(0).getRowOffset(), res.get(0)
      .getRowLength()), "b");
  assertEquals(Bytes.toString(res.get(1).getRowArray(), res.get(1).getRowOffset(), res.get(1)
      .getRowLength()), "ab");
  assertEquals(Bytes.toString(res.get(2).getRowArray(), res.get(2).getRowOffset(), res.get(2)
      .getRowLength()), "a");
  assertEquals(3, count);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:37,代碼來源:TestSeekBeforeWithReverseScan.java

示例10: testReverseScanWithPadding

import org.apache.hadoop.hbase.client.Scan; //導入方法依賴的package包/類
@Test
public void testReverseScanWithPadding() throws Exception {
  byte[] terminator = new byte[] { -1 };
  byte[] row1 = Bytes.add(invert(Bytes.toBytes("a")), terminator);
  byte[] row2 = Bytes.add(invert(Bytes.toBytes("ab")), terminator);
  byte[] row3 = Bytes.add(invert(Bytes.toBytes("b")), terminator);

  Put put1 = new Put(row1);
  put1.addColumn(cfName, cqName, HConstants.EMPTY_BYTE_ARRAY);
  Put put2 = new Put(row2);
  put2.addColumn(cfName, cqName, HConstants.EMPTY_BYTE_ARRAY);
  Put put3 = new Put(row3);
  put3.addColumn(cfName, cqName, HConstants.EMPTY_BYTE_ARRAY);

  region.put(put1);
  region.put(put2);
  region.put(put3);
  region.flush(true);
  Scan scan = new Scan();
  scan.setCacheBlocks(false);
  scan.setReversed(true);
  scan.setFilter(new FirstKeyOnlyFilter());
  scan.addFamily(cfName);
  RegionScanner scanner = region.getScanner(scan);
  List<Cell> res = new ArrayList<Cell>();
  int count = 1;
  while (scanner.next(res)) {
    count++;
  }
  assertEquals(3, count);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:32,代碼來源:TestSeekBeforeWithReverseScan.java

示例11: testOrderingOfCellsInPartialResults

import org.apache.hadoop.hbase.client.Scan; //導入方法依賴的package包/類
/**
 * Order of cells in partial results matches the ordering of cells from complete results
 * @throws Exception
 */
@Test
public void testOrderingOfCellsInPartialResults() throws Exception {
  Scan scan = new Scan();

  for (int col = 1; col <= NUM_COLS; col++) {
    scan.setMaxResultSize(getResultSizeForNumberOfCells(col));
    testOrderingOfCellsInPartialResults(scan);

    // Test again with a reversed scanner
    scan.setReversed(true);
    testOrderingOfCellsInPartialResults(scan);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:18,代碼來源:TestPartialResultsFromClientSide.java

示例12: testExpectedNumberOfCellsPerPartialResult

import org.apache.hadoop.hbase.client.Scan; //導入方法依賴的package包/類
/**
 * Setting the max result size allows us to control how many cells we expect to see on each call
 * to next on the scanner. Test a variety of different sizes for correctness
 * @throws Exception
 */
@Test
public void testExpectedNumberOfCellsPerPartialResult() throws Exception {
  Scan scan = new Scan();
  testExpectedNumberOfCellsPerPartialResult(scan);

  scan.setReversed(true);
  testExpectedNumberOfCellsPerPartialResult(scan);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:14,代碼來源:TestPartialResultsFromClientSide.java

示例13: testPartialResultsReassembly

import org.apache.hadoop.hbase.client.Scan; //導入方法依賴的package包/類
/**
 * Test the method {@link Result#createCompleteResult(List)}
 * @throws Exception
 */
@Test
public void testPartialResultsReassembly() throws Exception {
  Scan scan = new Scan();
  testPartialResultsReassembly(scan);
  scan.setReversed(true);
  testPartialResultsReassembly(scan);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:12,代碼來源:TestPartialResultsFromClientSide.java

示例14: testSmallScansDoNotAllowPartials

import org.apache.hadoop.hbase.client.Scan; //導入方法依賴的package包/類
/**
 * Small scans should not return partial results because it would prevent small scans from
 * retrieving all of the necessary results in a single RPC request which is what makese small
 * scans useful. Thus, ensure that even when {@link Scan#getAllowPartialResults()} is true, small
 * scans do not return partial results
 * @throws Exception
 */
@Test
public void testSmallScansDoNotAllowPartials() throws Exception {
  Scan scan = new Scan();
  testSmallScansDoNotAllowPartials(scan);
  scan.setReversed(true);
  testSmallScansDoNotAllowPartials(scan);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:15,代碼來源:TestPartialResultsFromClientSide.java

示例15: testReversedPartialResultWhenRegionMove

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

  moveRegion(table, 1);

  Scan scan = new Scan();
  scan.setMaxResultSize(1);
  scan.setAllowPartialResults(true);
  scan.setReversed(true);
  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[NUM_ROWS-1], FAMILIES[NUM_FAMILIES - 1], QUALIFIERS[NUM_QUALIFIERS - 1]);
  assertFalse(result1.isPartial());

  moveRegion(table, 2);

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

  moveRegion(table, 3);

  Result result3 = scanner.next();
  assertEquals(1, result3.rawCells().length);
  Cell c3 = result3.rawCells()[0];
  assertCell(c3, ROWS[NUM_ROWS-2], FAMILIES[0], QUALIFIERS[1]);
  assertTrue(result3.isPartial());

}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:39,代碼來源:TestPartialResultsFromClientSide.java


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