Example usage for org.apache.hadoop.io BinaryComparable BinaryComparable

List of usage examples for org.apache.hadoop.io BinaryComparable BinaryComparable

Introduction

In this page you can find the example usage for org.apache.hadoop.io BinaryComparable BinaryComparable.

Prototype

BinaryComparable

Source Link

Usage

From source file:org.apache.accumulo.core.data.impl.KeyExtent.java

License:Apache License

public boolean contains(final ByteSequence bsrow) {
    if (bsrow == null) {
        throw new IllegalArgumentException(
                "Passing null to contains is ambiguous, could be in first or last extent of table");
    }//from   ww w.  j  a  va  2s .  c  om

    BinaryComparable row = new BinaryComparable() {

        @Override
        public int getLength() {
            return bsrow.length();
        }

        @Override
        public byte[] getBytes() {
            if (bsrow.isBackedByArray() && bsrow.offset() == 0)
                return bsrow.getBackingArray();

            return bsrow.toArray();
        }
    };

    if ((this.getPrevEndRow() == null || this.getPrevEndRow().compareTo(row) < 0)
            && (this.getEndRow() == null || this.getEndRow().compareTo(row) >= 0)) {
        return true;
    }
    return false;
}

From source file:org.apache.accumulo.core.dataImpl.KeyExtent.java

License:Apache License

public boolean contains(final ByteSequence bsrow) {
    if (bsrow == null) {
        throw new IllegalArgumentException(
                "Passing null to contains is ambiguous, could be in first or last extent of table");
    }//w w  w. j av a 2s .  com

    BinaryComparable row = new BinaryComparable() {

        @Override
        public int getLength() {
            return bsrow.length();
        }

        @Override
        public byte[] getBytes() {
            if (bsrow.isBackedByArray() && bsrow.offset() == 0)
                return bsrow.getBackingArray();

            return bsrow.toArray();
        }
    };

    return (this.getPrevEndRow() == null || this.getPrevEndRow().compareTo(row) < 0)
            && (this.getEndRow() == null || this.getEndRow().compareTo(row) >= 0);
}