Java Code Examples for org.apache.lucene.util.NumericUtils#sortableBytesToInt()
The following examples show how to use
org.apache.lucene.util.NumericUtils#sortableBytesToInt() .
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: EnumFieldType.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public String indexedToReadable(String indexedForm) { if (indexedForm == null) return null; final BytesRef bytesRef = new BytesRef(indexedForm); final Integer intValue = NumericUtils.sortableBytesToInt(bytesRef.bytes, 0); return enumMapping.intValueToStringValue(intValue); }
Example 2
Source File: EnumFieldType.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public CharsRef indexedToReadable(BytesRef input, CharsRefBuilder output) { final Integer intValue = NumericUtils.sortableBytesToInt(input.bytes, 0); final String stringValue = enumMapping.intValueToStringValue(intValue); output.grow(stringValue.length()); output.setLength(stringValue.length()); stringValue.getChars(0, output.length(), output.chars(), 0); return output.get(); }
Example 3
Source File: EnumFieldType.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public IndexableField createField(SchemaField field, Object value) { final Integer intValue = enumMapping.stringValueToIntValue(value.toString()); if (intValue == null || intValue.equals(EnumMapping.DEFAULT_VALUE)) { String exceptionMessage = String.format(Locale.ENGLISH, "Unknown value for enum field: %s, value: %s", field.getName(), value.toString()); throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, exceptionMessage); } org.apache.lucene.document.FieldType newType = new org.apache.lucene.document.FieldType(); newType.setTokenized(false); newType.setStored(field.stored()); newType.setOmitNorms(field.omitNorms()); newType.setIndexOptions(field.indexOptions()); newType.setStoreTermVectors(field.storeTermVector()); newType.setStoreTermVectorOffsets(field.storeTermOffsets()); newType.setStoreTermVectorPositions(field.storeTermPositions()); newType.setStoreTermVectorPayloads(field.storeTermPayloads()); byte[] bytes = new byte[Integer.BYTES]; NumericUtils.intToSortableBytes(intValue, bytes, 0); return new Field(field.getName(), bytes, newType) { @Override public Number numericValue() { return NumericUtils.sortableBytesToInt(((BytesRef)fieldsData).bytes, 0); } }; }
Example 4
Source File: IntRange.java From lucene-solr with Apache License 2.0 | 4 votes |
/** decodes the min value (for the defined dimension) from the encoded input byte array */ static int decodeMin(byte[] b, int dimension) { int offset = dimension*BYTES; return NumericUtils.sortableBytesToInt(b, offset); }
Example 5
Source File: IntRange.java From lucene-solr with Apache License 2.0 | 4 votes |
/** decodes the max value (for the defined dimension) from the encoded input byte array */ static int decodeMax(byte[] b, int dimension) { int offset = b.length/2 + dimension*BYTES; return NumericUtils.sortableBytesToInt(b, offset); }
Example 6
Source File: IntPoint.java From lucene-solr with Apache License 2.0 | 4 votes |
/** Decode single integer dimension */ public static int decodeDimension(byte value[], int offset) { return NumericUtils.sortableBytesToInt(value, offset); }
Example 7
Source File: FieldCache.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public long parseValue(BytesRef point) { return NumericUtils.sortableBytesToInt(point.bytes, point.offset); }
Example 8
Source File: EnumFieldType.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public EnumFieldValue toObject(SchemaField sf, BytesRef term) { final Integer intValue = NumericUtils.sortableBytesToInt(term.bytes, 0); final String stringValue = enumMapping.intValueToStringValue(intValue); return new EnumFieldValue(intValue, stringValue); }