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


Java ByteArrayComparable.compareTo方法代码示例

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


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

示例1: compareRow

import org.apache.hadoop.hbase.filter.ByteArrayComparable; //导入方法依赖的package包/类
/**
 * Compare cell's row against given comparator
 * @param cell
 * @param comparator
 * @return result comparing cell's row
 */
public static int compareRow(Cell cell, ByteArrayComparable comparator) {
  if (cell instanceof ByteBufferExtendedCell) {
    return comparator.compareTo(((ByteBufferExtendedCell) cell).getRowByteBuffer(),
      ((ByteBufferExtendedCell) cell).getRowPosition(), cell.getRowLength());
  }
  return comparator.compareTo(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength());
}
 
开发者ID:apache,项目名称:hbase,代码行数:14,代码来源:PrivateCellUtil.java

示例2: compareFamily

import org.apache.hadoop.hbase.filter.ByteArrayComparable; //导入方法依赖的package包/类
/**
 * Compare cell's column family against given comparator
 * @param cell
 * @param comparator
 * @return result comparing cell's column family
 */
public static int compareFamily(Cell cell, ByteArrayComparable comparator) {
  if (cell instanceof ByteBufferExtendedCell) {
    return comparator.compareTo(((ByteBufferExtendedCell) cell).getFamilyByteBuffer(),
      ((ByteBufferExtendedCell) cell).getFamilyPosition(), cell.getFamilyLength());
  }
  return comparator.compareTo(cell.getFamilyArray(), cell.getFamilyOffset(),
    cell.getFamilyLength());
}
 
开发者ID:apache,项目名称:hbase,代码行数:15,代码来源:PrivateCellUtil.java

示例3: compareQualifier

import org.apache.hadoop.hbase.filter.ByteArrayComparable; //导入方法依赖的package包/类
/**
 * Compare cell's qualifier against given comparator
 * @param cell
 * @param comparator
 * @return result comparing cell's qualifier
 */
public static int compareQualifier(Cell cell, ByteArrayComparable comparator) {
  if (cell instanceof ByteBufferExtendedCell) {
    return comparator.compareTo(((ByteBufferExtendedCell) cell).getQualifierByteBuffer(),
      ((ByteBufferExtendedCell) cell).getQualifierPosition(), cell.getQualifierLength());
  }
  return comparator.compareTo(cell.getQualifierArray(), cell.getQualifierOffset(),
    cell.getQualifierLength());
}
 
开发者ID:apache,项目名称:hbase,代码行数:15,代码来源:PrivateCellUtil.java

示例4: compareValue

import org.apache.hadoop.hbase.filter.ByteArrayComparable; //导入方法依赖的package包/类
/**
 * Compare cell's value against given comparator
 * @param cell
 * @param comparator
 * @return result comparing cell's value
 */
public static int compareValue(Cell cell, ByteArrayComparable comparator) {
  if (cell instanceof ByteBufferExtendedCell) {
    return comparator.compareTo(((ByteBufferExtendedCell) cell).getValueByteBuffer(),
      ((ByteBufferExtendedCell) cell).getValuePosition(), cell.getValueLength());
  }
  return comparator.compareTo(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
}
 
开发者ID:apache,项目名称:hbase,代码行数:14,代码来源:PrivateCellUtil.java

示例5: 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.compareTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。