Java Code Examples for org.apache.cassandra.utils.ByteBufferUtil#compareUnsigned()
The following examples show how to use
org.apache.cassandra.utils.ByteBufferUtil#compareUnsigned() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractSimpleCellNameType.java From stratio-cassandra with Apache License 2.0 | 5 votes |
@Inline static int compareUnsigned(Composite c1, Composite c2) { ByteBuffer b1 = c1.toByteBuffer(); ByteBuffer b2 = c2.toByteBuffer(); return ByteBufferUtil.compareUnsigned(b1, b2); }
Example 2
Source File: AbstractCType.java From stratio-cassandra with Apache License 2.0 | 5 votes |
static int compareUnsigned(Composite c1, Composite c2) { if (c1.isStatic() != c2.isStatic()) { // Static sorts before non-static no matter what, except for empty which // always sort first if (c1.isEmpty()) return c2.isEmpty() ? 0 : -1; if (c2.isEmpty()) return 1; return c1.isStatic() ? -1 : 1; } int s1 = c1.size(); int s2 = c2.size(); int minSize = Math.min(s1, s2); for (int i = 0; i < minSize; i++) { int cmp = ByteBufferUtil.compareUnsigned(c1.get(i), c2.get(i)); if (cmp != 0) return cmp; } if (s1 == s2) return c1.eoc().compareTo(c2.eoc()); return s1 < s2 ? c1.eoc().prefixComparisonResult : -c2.eoc().prefixComparisonResult; }
Example 3
Source File: AbstractCType.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public int compare(Composite c1, Composite c2) { if (c1.isStatic() != c2.isStatic()) { // Static sorts before non-static no matter what, except for empty which // always sort first if (c1.isEmpty()) return c2.isEmpty() ? 0 : -1; if (c2.isEmpty()) return 1; return c1.isStatic() ? -1 : 1; } int s1 = c1.size(); int s2 = c2.size(); int minSize = Math.min(s1, s2); for (int i = 0; i < minSize; i++) { int cmp = isByteOrderComparable ? ByteBufferUtil.compareUnsigned(c1.get(i), c2.get(i)) : subtype(i).compare(c1.get(i), c2.get(i)); if (cmp != 0) return cmp; } if (s1 == s2) return c1.eoc().compareTo(c2.eoc()); return s1 < s2 ? c1.eoc().prefixComparisonResult : -c2.eoc().prefixComparisonResult; }
Example 4
Source File: DecoratedKey.java From stratio-cassandra with Apache License 2.0 | 5 votes |
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || !(obj instanceof DecoratedKey)) return false; DecoratedKey other = (DecoratedKey)obj; return ByteBufferUtil.compareUnsigned(getKey(), other.getKey()) == 0; // we compare faster than BB.equals for array backed BB }
Example 5
Source File: DecoratedKey.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public int compareTo(RowPosition pos) { if (this == pos) return 0; // delegate to Token.KeyBound if needed if (!(pos instanceof DecoratedKey)) return -pos.compareTo(this); DecoratedKey otherKey = (DecoratedKey) pos; int cmp = getToken().compareTo(otherKey.getToken()); return cmp == 0 ? ByteBufferUtil.compareUnsigned(getKey(), otherKey.getKey()) : cmp; }
Example 6
Source File: DecoratedKey.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public static int compareTo(IPartitioner partitioner, ByteBuffer key, RowPosition position) { // delegate to Token.KeyBound if needed if (!(position instanceof DecoratedKey)) return -position.compareTo(partitioner.decorateKey(key)); DecoratedKey otherKey = (DecoratedKey) position; int cmp = partitioner.getToken(key).compareTo(otherKey.getToken()); return cmp == 0 ? ByteBufferUtil.compareUnsigned(key, otherKey.getKey()) : cmp; }
Example 7
Source File: DateType.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public int compare(ByteBuffer o1, ByteBuffer o2) { if (!o1.hasRemaining() || !o2.hasRemaining()) return o1.hasRemaining() ? 1 : o2.hasRemaining() ? -1 : 0; return ByteBufferUtil.compareUnsigned(o1, o2); }
Example 8
Source File: LongType.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public static int compareLongs(ByteBuffer o1, ByteBuffer o2) { if (!o1.hasRemaining() || !o2.hasRemaining()) return o1.hasRemaining() ? 1 : o2.hasRemaining() ? -1 : 0; int diff = o1.get(o1.position()) - o2.get(o2.position()); if (diff != 0) return diff; return ByteBufferUtil.compareUnsigned(o1, o2); }
Example 9
Source File: Int32Type.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public int compare(ByteBuffer o1, ByteBuffer o2) { if (!o1.hasRemaining() || !o2.hasRemaining()) return o1.hasRemaining() ? 1 : o2.hasRemaining() ? -1 : 0; int diff = o1.get(o1.position()) - o2.get(o2.position()); if (diff != 0) return diff; return ByteBufferUtil.compareUnsigned(o1, o2); }
Example 10
Source File: BytesType.java From stratio-cassandra with Apache License 2.0 | 4 votes |
public int compare(ByteBuffer o1, ByteBuffer o2) { return ByteBufferUtil.compareUnsigned(o1, o2); }
Example 11
Source File: InetAddressType.java From stratio-cassandra with Apache License 2.0 | 4 votes |
public int compare(ByteBuffer o1, ByteBuffer o2) { return ByteBufferUtil.compareUnsigned(o1, o2); }
Example 12
Source File: UTF8Type.java From stratio-cassandra with Apache License 2.0 | 4 votes |
public int compare(ByteBuffer o1, ByteBuffer o2) { return ByteBufferUtil.compareUnsigned(o1, o2); }
Example 13
Source File: AsciiType.java From stratio-cassandra with Apache License 2.0 | 4 votes |
public int compare(ByteBuffer o1, ByteBuffer o2) { return ByteBufferUtil.compareUnsigned(o1, o2); }
Example 14
Source File: CounterColumnType.java From stratio-cassandra with Apache License 2.0 | 4 votes |
public int compare(ByteBuffer o1, ByteBuffer o2) { return ByteBufferUtil.compareUnsigned(o1, o2); }
Example 15
Source File: ColumnFamilyWideRowRecordReader.java From Hive-Cassandra with Apache License 2.0 | 4 votes |
private void maybeInit() { // check if we need another row if (rows != null && columnsRead < rowPageSize) { columnsRead = 0; startToken = partitioner.getTokenFactory().toString(partitioner.getToken(rows.get(0).key)); predicate.getSlice_range().setStart(startSlicePredicate); rows = null; prevStartSlice = null; totalRead++; } if (startToken == null) { startToken = split.getStartToken(); } else if (startToken.equals(split.getEndToken()) && rows == null) { // reached end of the split return; } KeyRange keyRange = new KeyRange(batchRowCount) .setStart_token(startToken) .setEnd_token(split.getEndToken()); try { rows = client.get_range_slices(new ColumnParent(cfName), predicate, keyRange, consistencyLevel); // nothing new? reached the end if (rows.isEmpty()) { rows = null; return; } //detect infinite loop if (prevStartSlice != null && ByteBufferUtil.compareUnsigned(prevStartSlice, predicate.slice_range.start) == 0) { rows = null; return; } // prepare for the next slice to be read KeySlice row = rows.get(0); if (row.getColumnsSize() > 0) { ColumnOrSuperColumn cosc = row.getColumns().get(row.getColumnsSize() - 1); prevStartSlice = predicate.slice_range.start; //prepare next slice if (cosc.column != null) { predicate.slice_range.start = cosc.column.name; } if (cosc.super_column != null) { predicate.slice_range.start = cosc.super_column.name; } if (cosc.counter_column != null) { predicate.slice_range.start = cosc.counter_column.name; } if (cosc.counter_super_column != null) { predicate.slice_range.start = cosc.counter_super_column.name; } columnsRead = row.getColumnsSize(); //If we've hit the max columns then rm the last column //to make sure we don't know where to start next without overlap if (columnsRead == rowPageSize) { row.getColumns().remove(columnsRead - 1); } } } catch (Exception e) { throw new RuntimeException(e); } }