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


Java CellUtil.matchingQualifier方法代码示例

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


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

示例1: hasColumn

import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
private boolean hasColumn(final List<Cell> kvs, final byte [] family,
    final byte [] qualifier) {
  for (Cell kv: kvs) {
    if (CellUtil.matchingFamily(kv, family) && CellUtil.matchingQualifier(kv, qualifier)) {
      return true;
    }
  }
  return false;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:10,代码来源:TestScanner.java

示例2: getColumn

import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
private Cell getColumn(final List<Cell> kvs, final byte [] family,
    final byte [] qualifier) {
  for (Cell kv: kvs) {
    if (CellUtil.matchingFamily(kv, family) && CellUtil.matchingQualifier(kv, qualifier)) {
      return kv;
    }
  }
  return null;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:10,代码来源:TestScanner.java

示例3: get

import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
/**
 * Returns a list of all KeyValue objects with matching column family and qualifier.
 *
 * @param family column family
 * @param qualifier column qualifier
 * @return a list of KeyValue objects with the matching family and qualifier,
 * returns an empty list if one doesn't exist for the given family.
 */
public List<Cell> get(byte[] family, byte[] qualifier) {
  List<Cell> filteredList = new ArrayList<Cell>();
  for (Cell cell: getCellList(family)) {
    if (CellUtil.matchingQualifier(cell, qualifier)) {
      filteredList.add(cell);
    }
  }
  return filteredList;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:Put.java

示例4: hasOneMatchingQualifier

import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
private boolean hasOneMatchingQualifier(Cell v) {
  for (byte[] q : qualifiers) {
    if (CellUtil.matchingQualifier(v, q)) {
      return true;
    }
  }
  return false;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:9,代码来源:FirstKeyValueMatchingQualifiersFilter.java

示例5: 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

示例6: 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

示例7: applyIncrementsToColumnFamily

import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
/**
 * Apply increments to a column family.
 *
 * @param sortedIncrements The passed in increments to apply MUST be sorted so that they match the
 *                         order that they appear in the Get results (get results will be sorted on return).
 *                         Otherwise, we won't be able to find the existing values if the cells are not specified
 *                         in order by the client since cells are in an array list.
 * @return Resulting increments after <code>sortedIncrements</code> have been applied to current
 * values (if any -- else passed increment is the final result).
 * @throws IOException
 * @islation Isolation level to use when running the 'get'. Pass null for default.
 */
private List<Cell> applyIncrementsToColumnFamily(Increment increment, byte[] columnFamilyName,
    List<Cell> sortedIncrements, long now, long mvccNum, List<Cell> allKVs,
    final IsolationLevel isolation) throws IOException {
  List<Cell> results = new ArrayList<Cell>(sortedIncrements.size());
  byte[] row = increment.getRow();
  // Get previous values for all columns in this family
  List<Cell> currentValues =
      getIncrementCurrentValue(increment, columnFamilyName, sortedIncrements, isolation);
  // Iterate the input columns and update existing values if they were found,
  // otherwise
  // add new column initialized to the increment amount
  int idx = 0;
  for (int i = 0; i < sortedIncrements.size(); i++) {
    Cell inc = sortedIncrements.get(i);
    long incrementAmount = getLongValue(inc);
    // If increment amount == 0, then don't write this Increment to the WAL.
    boolean writeBack = (incrementAmount != 0);
    // Carry forward any tags that might have been added by a coprocessor.
    List<Tag> tags = Tag.carryForwardTags(inc);

    Cell currentValue = null;
    long ts = now;
    if (idx < currentValues.size() && CellUtil.matchingQualifier(currentValues.get(idx), inc)) {
      currentValue = currentValues.get(idx);
      ts = Math.max(now, currentValue.getTimestamp());
      incrementAmount += getLongValue(currentValue);
      // Carry forward all tags
      tags = Tag.carryForwardTags(tags, currentValue);
      if (i < (sortedIncrements.size() - 1) && !CellUtil
          .matchingQualifier(inc, sortedIncrements.get(i + 1))) idx++;
    }

    // Append new incremented KeyValue to list
    byte[] qualifier = CellUtil.cloneQualifier(inc);
    byte[] incrementAmountInBytes = Bytes.toBytes(incrementAmount);
    tags = carryForwardTTLTag(tags, increment);

    Cell newValue =
        new KeyValue(row, 0, row.length, columnFamilyName, 0, columnFamilyName.length, qualifier,
            0, qualifier.length, ts, KeyValue.Type.Put, incrementAmountInBytes, 0,
            incrementAmountInBytes.length, tags);

    // Don't set an mvcc if none specified. The mvcc may be assigned later in
    // case where we
    // write the memstore AFTER we sync our edit to the log.
    if (mvccNum != MultiVersionConcurrencyControl.NO_WRITE_NUMBER) {
      CellUtil.setSequenceId(newValue, mvccNum);
    }

    // Give coprocessors a chance to update the new cell
    if (coprocessorHost != null) {
      newValue = coprocessorHost
          .postMutationBeforeWAL(RegionObserver.MutationType.INCREMENT, increment, currentValue,
              newValue);
    }
    allKVs.add(newValue);
    if (writeBack) {
      results.add(newValue);
    }
  }
  return results;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:75,代码来源:HRegion.java


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