当前位置: 首页>>代码示例>>Java>>正文


Java CellUtil.matchingRow方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.CellUtil.matchingRow方法的典型用法代码示例。如果您正苦于以下问题:Java CellUtil.matchingRow方法的具体用法?Java CellUtil.matchingRow怎么用?Java CellUtil.matchingRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.CellUtil的用法示例。


在下文中一共展示了CellUtil.matchingRow方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: backwardSeek

import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
@Override
public boolean backwardSeek(Cell seekKey) throws IOException {
  if (current == null) {
    return false;
  }
  heap.add(current);
  current = null;

  KeyValueScanner scanner;
  while ((scanner = heap.poll()) != null) {
    Cell topKey = scanner.peek();
    if ((CellUtil.matchingRow(seekKey, topKey) && comparator
        .getComparator().compare(seekKey, topKey) <= 0)
        || comparator.getComparator().compareRows(seekKey, topKey) > 0) {
      heap.add(scanner);
      current = pollRealKV();
      return current != null;
    }
    if (!scanner.backwardSeek(seekKey)) {
      scanner.close();
    } else {
      heap.add(scanner);
    }
  }
  return false;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:27,代码来源:ReversedKeyValueHeap.java

示例2: joinedHeapMayHaveData

import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
/**
 * @param currentRow
 * @param offset
 * @param length
 * @return true when the joined heap may have data for the current row
 * @throws IOException
 */
private boolean joinedHeapMayHaveData(byte[] currentRow, int offset, short length)
    throws IOException {
  Cell nextJoinedKv = joinedHeap.peek();
  boolean matchCurrentRow =
      nextJoinedKv != null && CellUtil.matchingRow(nextJoinedKv, currentRow, offset, length);
  boolean matchAfterSeek = false;

  // If the next value in the joined heap does not match the current row,
  // try to seek to the
  // correct row
  if (!matchCurrentRow) {
    Cell firstOnCurrentRow = KeyValueUtil.createFirstOnRow(currentRow, offset, length);
    boolean seekSuccessful = this.joinedHeap.requestSeek(firstOnCurrentRow, true, true);
    matchAfterSeek = seekSuccessful && joinedHeap.peek() != null && CellUtil
        .matchingRow(joinedHeap.peek(), currentRow, offset, length);
  }

  return matchCurrentRow || matchAfterSeek;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:27,代码来源:HRegion.java

示例3: countDistinctRowKeys

import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
/**
 * Count the number of different row keys in the given edit because of mini-batching. We assume
 * that there's at least one Cell in the WALEdit.
 * @param edit edit to count row keys from
 * @return number of different row keys
 */
private int countDistinctRowKeys(WALEdit edit) {
  List<Cell> cells = edit.getCells();
  int distinctRowKeys = 1;
  Cell lastCell = cells.get(0);
  for (int i = 0; i < edit.size(); i++) {
    if (!CellUtil.matchingRow(cells.get(i), lastCell)) {
      distinctRowKeys++;
    }
  }
  return distinctRowKeys;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:ReplicationSource.java

示例4: updateColumnValue

import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
/**
 * Only used by tests. TODO: Remove
 *
 * Given the specs of a column, update it, first by inserting a new record,
 * then removing the old one.  Since there is only 1 KeyValue involved, the memstoreTS
 * will be set to 0, thus ensuring that they instantly appear to anyone. The underlying
 * store will ensure that the insert/delete each are atomic. A scanner/reader will either
 * get the new value, or the old value and all readers will eventually only see the new
 * value after the old was removed.
 *
 * @param row
 * @param family
 * @param qualifier
 * @param newValue
 * @param now
 * @return  Timestamp
 */
@Override
public long updateColumnValue(byte[] row,
                              byte[] family,
                              byte[] qualifier,
                              long newValue,
                              long now) {
  Cell firstCell = KeyValueUtil.createFirstOnRow(row, family, qualifier);
  // Is there a Cell in 'snapshot' with the same TS? If so, upgrade the timestamp a bit.
  SortedSet<Cell> snSs = snapshot.tailSet(firstCell);
  if (!snSs.isEmpty()) {
    Cell snc = snSs.first();
    // is there a matching Cell in the snapshot?
    if (CellUtil.matchingRow(snc, firstCell) && CellUtil.matchingQualifier(snc, firstCell)) {
      if (snc.getTimestamp() == now) {
        // poop,
        now += 1;
      }
    }
  }

  // logic here: the new ts MUST be at least 'now'. But it could be larger if necessary.
  // But the timestamp should also be max(now, mostRecentTsInMemstore)

  // so we cant add the new Cell w/o knowing what's there already, but we also
  // want to take this chance to delete some cells. So two loops (sad)

  SortedSet<Cell> ss = cellSet.tailSet(firstCell);
  for (Cell cell : ss) {
    // if this isnt the row we are interested in, then bail:
    if (!CellUtil.matchingColumn(cell, family, qualifier)
        || !CellUtil.matchingRow(cell, firstCell)) {
      break; // rows dont match, bail.
    }

    // if the qualifier matches and it's a put, just RM it out of the cellSet.
    if (cell.getTypeByte() == KeyValue.Type.Put.getCode() &&
        cell.getTimestamp() > now && CellUtil.matchingQualifier(firstCell, cell)) {
      now = cell.getTimestamp();
    }
  }

  // create or update (upsert) a new Cell with
  // 'now' and a 0 memstoreTS == immediately visible
  List<Cell> cells = new ArrayList<Cell>(1);
  cells.add(new KeyValue(row, family, qualifier, now, Bytes.toBytes(newValue)));
  return upsert(cells, 1L);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:65,代码来源:DefaultMemStore.java

示例5: upsert

import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
/**
 * Inserts the specified KeyValue into MemStore and deletes any existing
 * versions of the same row/family/qualifier as the specified KeyValue.
 * <p>
 * First, the specified KeyValue is inserted into the Memstore.
 * <p>
 * If there are any existing KeyValues in this MemStore with the same row,
 * family, and qualifier, they are removed.
 * <p>
 * Callers must hold the read lock.
 *
 * @param cell
 * @return change in size of MemStore
 */
private long upsert(Cell cell, long readpoint) {
  // Add the Cell to the MemStore
  // Use the internalAdd method here since we (a) already have a lock
  // and (b) cannot safely use the MSLAB here without potentially
  // hitting OOME - see TestMemStore.testUpsertMSLAB for a
  // test that triggers the pathological case if we don't avoid MSLAB
  // here.
  long addedSize = internalAdd(cell);

  // Get the Cells for the row/family/qualifier regardless of timestamp.
  // For this case we want to clean up any other puts
  Cell firstCell = KeyValueUtil.createFirstOnRow(
      cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(),
      cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength(),
      cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
  SortedSet<Cell> ss = cellSet.tailSet(firstCell);
  Iterator<Cell> it = ss.iterator();
  // versions visible to oldest scanner
  int versionsVisible = 0;
  while ( it.hasNext() ) {
    Cell cur = it.next();

    if (cell == cur) {
      // ignore the one just put in
      continue;
    }
    // check that this is the row and column we are interested in, otherwise bail
    if (CellUtil.matchingRow(cell, cur) && CellUtil.matchingQualifier(cell, cur)) {
      // only remove Puts that concurrent scanners cannot possibly see
      if (cur.getTypeByte() == KeyValue.Type.Put.getCode() &&
          cur.getSequenceId() <= readpoint) {
        if (versionsVisible >= 1) {
          // if we get here we have seen at least one version visible to the oldest scanner,
          // which means we can prove that no scanner will see this version

          // false means there was a change, so give us the size.
          long delta = heapSizeChange(cur, true);
          addedSize -= delta;
          this.size.addAndGet(-delta);
          it.remove();
          setOldestEditTimeToNow();
        } else {
          versionsVisible++;
        }
      }
    } else {
      // past the row or column, done
      break;
    }
  }
  return addedSize;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:67,代码来源:DefaultMemStore.java

示例6: getRowKeyAtOrBefore

import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
@Override public Cell getRowKeyAtOrBefore(final byte[] row) throws IOException {
  // If minVersions is set, we will not ignore expired KVs.
  // As we're only looking for the latest matches, that should be OK.
  // With minVersions > 0 we guarantee that any KV that has any version
  // at all (expired or not) has at least one version that will not expire.
  // Note that this method used to take a KeyValue as arguments. KeyValue
  // can be back-dated, a row key cannot.
  long ttlToUse = scanInfo.getMinVersions() > 0 ? Long.MAX_VALUE : this.scanInfo.getTtl();

  KeyValue kv = new KeyValue(row, HConstants.LATEST_TIMESTAMP);

  GetClosestRowBeforeTracker state = new GetClosestRowBeforeTracker(this.comparator, kv, ttlToUse,
      this.getRegionInfo().isMetaRegion());
  this.lock.readLock().lock();
  try {
    // First go to the memstore. Pick up deletes and candidates.
    this.memstore.getRowKeyAtOrBefore(state);
    // Check if match, if we got a candidate on the asked for 'kv' row.
    // Process each relevant store file. Run through from newest to oldest.
    Iterator<StoreFile> sfIterator = this.storeEngine.getStoreFileManager()
        .getCandidateFilesForRowKeyBefore(state.getTargetKey());
    while (sfIterator.hasNext()) {
      StoreFile sf = sfIterator.next();
      sfIterator.remove(); // Remove sf from iterator.
      boolean haveNewCandidate = rowAtOrBeforeFromStoreFile(sf, state);
      Cell candidate = state.getCandidate();
      // we have an optimization here which stops the search if we find exact
      // match.
      if (candidate != null && CellUtil.matchingRow(candidate, row)) {
        return candidate;
      }
      if (haveNewCandidate) {
        sfIterator = this.storeEngine.getStoreFileManager()
            .updateCandidateFilesForRowKeyBefore(sfIterator, state.getTargetKey(), candidate);
      }
    }
    return state.getCandidate();
  } finally {
    this.lock.readLock().unlock();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:42,代码来源:HStore.java

示例7: isNewRowOrType

import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
/**
 * @param previousCell
 * @param cell
 * @return True if we have crossed over onto a new row or type
 */
private boolean isNewRowOrType(final Cell previousCell, final Cell cell) {
  return previousCell == null || previousCell.getTypeByte() != cell.getTypeByte() ||
      !CellUtil.matchingRow(previousCell, cell);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:10,代码来源:ReplicationSink.java

示例8: moreCellsInRow

import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
/**
 * Based on the nextKv in the heap, and the current row, decide whether or not there are more
 * cells to be read in the heap. If the row of the nextKv in the heap matches the current row
 * then there are more cells to be read in the row.
 *
 * @param nextKv
 * @param currentRow
 * @param offset
 * @param length
 * @return true When there are more cells in the row to be read
 */
private boolean moreCellsInRow(final Cell nextKv, byte[] currentRow, int offset, short length) {
  return nextKv != null && CellUtil.matchingRow(nextKv, currentRow, offset, length);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:15,代码来源:HRegion.java


注:本文中的org.apache.hadoop.hbase.CellUtil.matchingRow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。