Java Code Examples for org.apache.lucene.util.NumericUtils#sortableBytesToLong()

The following examples show how to use org.apache.lucene.util.NumericUtils#sortableBytesToLong() . 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: TestPointQueries.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public void testLongEncode() {
  for(int i=0;i<10000;i++) {
    long v = random().nextLong();
    byte[] tmp = new byte[8];
    NumericUtils.longToSortableBytes(v, tmp, 0);
    long v2 = NumericUtils.sortableBytesToLong(tmp, 0);
    assertEquals("got bytes=" + Arrays.toString(tmp), v, v2);
  }
}
 
Example 2
Source File: LongPoint.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
/** Decode single long dimension */
public static long decodeDimension(byte value[], int offset) {
  return NumericUtils.sortableBytesToLong(value, offset);
}
 
Example 3
Source File: LongRange.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
/** decodes the min value (for the defined dimension) from the encoded input byte array */
static long decodeMin(byte[] b, int dimension) {
  int offset = dimension*BYTES;
  return NumericUtils.sortableBytesToLong(b, offset);
}
 
Example 4
Source File: LongRange.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
/** decodes the max value (for the defined dimension) from the encoded input byte array */
static long decodeMax(byte[] b, int dimension) {
  int offset = b.length/2 + dimension*BYTES;
  return NumericUtils.sortableBytesToLong(b, offset);
}
 
Example 5
Source File: FieldCache.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Override
public long parseValue(BytesRef point) {
  return NumericUtils.sortableBytesToLong(point.bytes, point.offset);
}