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


Java Cell.getRow方法代碼示例

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


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

示例1: append

import org.apache.hadoop.hbase.Cell; //導入方法依賴的package包/類
@Override
public void append(Cell cell) throws IOException {
  // If we are waiting for opportunity to close and we started writing different row,
  // discard the writer and stop waiting.
  boolean doCreateWriter = false;
  if (currentWriter == null) {
    // First append ever, do a sanity check.
    sanityCheckLeft(left, cell.getRowArray(), cell.getRowOffset(), cell.getRowLength());
    doCreateWriter = true;
  } else if (lastRowInCurrentWriter != null
      && !comparator.matchingRows(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(),
          lastRowInCurrentWriter, 0, lastRowInCurrentWriter.length)) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Stopping to use a writer after [" + Bytes.toString(lastRowInCurrentWriter)
          + "] row; wrote out "  + cellsInCurrentWriter + " kvs");
    }
    lastRowInCurrentWriter = null;
    cellsInCurrentWriter = 0;
    cellsSeenInPrevious += cellsSeen;
    doCreateWriter = true;
  }
  if (doCreateWriter) {
    byte[] boundary = existingWriters.isEmpty() ? left : cell.getRow(); // make a copy
    if (LOG.isDebugEnabled()) {
      LOG.debug("Creating new writer starting at [" + Bytes.toString(boundary) + "]");
    }
    currentWriter = writerFactory.createWriter();
    boundaries.add(boundary);
    existingWriters.add(currentWriter);
  }

  currentWriter.append(cell);
  lastCell = cell; // for the sanity check
  ++cellsInCurrentWriter;
  cellsSeen = cellsInCurrentWriter;
  if (this.sourceScanner != null) {
    cellsSeen = Math.max(cellsSeen,
        this.sourceScanner.getEstimatedNumberOfKvsScanned() - cellsSeenInPrevious);
  }

  // If we are not already waiting for opportunity to close, start waiting if we can
  // create any more writers and if the current one is too big.
  if (lastRowInCurrentWriter == null
      && existingWriters.size() < targetCount
      && cellsSeen >= targetCells) {
    lastRowInCurrentWriter = cell.getRow(); // make a copy
    if (LOG.isDebugEnabled()) {
      LOG.debug("Preparing to start a new writer after [" + Bytes.toString(
          lastRowInCurrentWriter) + "] row; observed " + cellsSeen + " kvs and wrote out "
          + cellsInCurrentWriter + " kvs");
    }
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:54,代碼來源:StripeMultiFileWriter.java

示例2: testSecureWAL

import org.apache.hadoop.hbase.Cell; //導入方法依賴的package包/類
@Test
public void testSecureWAL() throws Exception {
  TableName tableName = TableName.valueOf("TestSecureWAL");
  HTableDescriptor htd = new HTableDescriptor(tableName);
  htd.addFamily(new HColumnDescriptor(tableName.getName()));
  HRegionInfo regioninfo = new HRegionInfo(tableName,
    HConstants.EMPTY_START_ROW, HConstants.EMPTY_END_ROW, false);
  final int total = 10;
  final byte[] row = Bytes.toBytes("row");
  final byte[] family = Bytes.toBytes("family");
  final byte[] value = Bytes.toBytes("Test value");
  FileSystem fs = TEST_UTIL.getTestFileSystem();
  final WALFactory wals = new WALFactory(TEST_UTIL.getConfiguration(), null, "TestSecureWAL");

  // Write the WAL
  final WAL wal = wals.getWAL(regioninfo.getEncodedNameAsBytes());

  for (int i = 0; i < total; i++) {
    WALEdit kvs = new WALEdit();
    kvs.add(new KeyValue(row, family, Bytes.toBytes(i), value));
    wal.append(htd, regioninfo, new WALKey(regioninfo.getEncodedNameAsBytes(), tableName,
        System.currentTimeMillis()), kvs, true);
  }
  wal.sync();
  final Path walPath = DefaultWALProvider.getCurrentFileName(wal);
  wals.shutdown();

  // Insure edits are not plaintext
  long length = fs.getFileStatus(walPath).getLen();
  FSDataInputStream in = fs.open(walPath);
  byte[] fileData = new byte[(int)length];
  IOUtils.readFully(in, fileData);
  in.close();
  assertFalse("Cells appear to be plaintext", Bytes.contains(fileData, value));

  // Confirm the WAL can be read back
  WAL.Reader reader = wals.createReader(TEST_UTIL.getTestFileSystem(), walPath);
  int count = 0;
  WAL.Entry entry = new WAL.Entry();
  while (reader.next(entry) != null) {
    count++;
    List<Cell> cells = entry.getEdit().getCells();
    assertTrue("Should be one KV per WALEdit", cells.size() == 1);
    for (Cell cell: cells) {
      byte[] thisRow = cell.getRow();
      assertTrue("Incorrect row", Bytes.equals(thisRow, row));
      byte[] thisFamily = cell.getFamily();
      assertTrue("Incorrect family", Bytes.equals(thisFamily, family));
      byte[] thisValue = cell.getValue();
      assertTrue("Incorrect value", Bytes.equals(thisValue, value));
    }
  }
  assertEquals("Should have read back as many KVs as written", total, count);
  reader.close();
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:56,代碼來源:TestSecureWAL.java


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