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


Java ByteArrayComparable.getValue方法代码示例

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


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

示例1: checkAndRowMutate

import org.apache.hadoop.hbase.filter.ByteArrayComparable; //导入方法依赖的package包/类
/**
 * @return true if the new put was executed, false otherwise
 * @throws IOException
 */
public boolean checkAndRowMutate(byte[] row, byte[] family, byte[] qualifier,
                                 CompareOp compareOp, ByteArrayComparable comparator, RowMutations rm,
                                 boolean writeToWAL)
        throws IOException {
    checkReadOnly();
    //TODO, add check for value length or maybe even better move this to the
    //client if this becomes a global setting
    checkResources();

    startRegionOperation();
    try {
        Get get = new Get(row);
        checkFamily(family);
        get.addColumn(family, qualifier);

        // Lock row - note that doBatchMutate will relock this row if called
        RowLock rowLock = getRowLock(get.getRow());
        // wait for all previous transactions to complete (with lock held)
        mvcc.waitForPreviousTransactionsComplete();
        try {
            List<Cell> result = get(get, false);

            boolean valueIsNull = comparator.getValue() == null ||
                    comparator.getValue().length == 0;
            boolean matches = false;
            if (result.size() == 0 && valueIsNull) {
                matches = true;
            } else if (result.size() > 0 && result.get(0).getValueLength() == 0 &&
                    valueIsNull) {
                matches = true;
            } else if (result.size() == 1 && !valueIsNull) {
                Cell kv = result.get(0);
                int compareResult = comparator.compareTo(kv.getValueArray(),
                        kv.getValueOffset(), kv.getValueLength());
                switch (compareOp) {
                    case LESS:
                        matches = compareResult < 0;
                        break;
                    case LESS_OR_EQUAL:
                        matches = compareResult <= 0;
                        break;
                    case EQUAL:
                        matches = compareResult == 0;
                        break;
                    case NOT_EQUAL:
                        matches = compareResult != 0;
                        break;
                    case GREATER_OR_EQUAL:
                        matches = compareResult >= 0;
                        break;
                    case GREATER:
                        matches = compareResult > 0;
                        break;
                    default:
                        throw new RuntimeException("Unknown Compare op " + compareOp.name());
                }
            }
            //If matches put the new put or delete the new delete
            if (matches) {
                // All edits for the given row (across all column families) must
                // happen atomically.
                mutateRow(rm);
                this.checkAndMutateChecksPassed.increment();
                return true;
            }
            this.checkAndMutateChecksFailed.increment();
            return false;
        } finally {
            rowLock.release();
        }
    } finally {
        closeRegionOperation();
    }
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:79,代码来源:HRegion.java


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