@Override public long parseValue(BytesRef term) { return NumericUtils.prefixCodedToLong(term); } @Override
@Override public Number toNumber(BytesRef indexForm) { return NumericUtils.prefixCodedToLong(indexForm); } },
@Override public long parseValue(BytesRef term) { long val = NumericUtils.prefixCodedToLong(term); if (val<0) val ^= 0x7fffffffffffffffL; return val; } @Override
@Override public long parseValue(BytesRef term) { return NumericUtils.prefixCodedToLong(term); } @Override
@Override public long parseValue(BytesRef term) { long val = NumericUtils.prefixCodedToLong(term); if (val<0) val ^= 0x7fffffffffffffffL; return val; } @Override
@Override public long toLong(BytesRef indexForm) { return NumericUtils.prefixCodedToLong(indexForm); }
public static Date stringToDate(final String s) { if (s != null) { long seconds = NumericUtils.prefixCodedToLong(s); if (seconds == Long.MAX_VALUE) { return null; } return new Date(seconds * 1000); } return new Date(); } }
/** * Returns the minimum long value indexed into this * numeric field or null if no terms exist. */ public static Long getMinLong(Terms terms) throws IOException { // All shift=0 terms are sorted first, so we don't need // to filter the incoming terms; we can just get the // min: BytesRef min = terms.getMin(); return (min != null) ? NumericUtils.prefixCodedToLong(min) : null; }
/** * Returns the minimum long value indexed into this * numeric field or null if no terms exist. */ public static Long getMinLong(Terms terms) throws IOException { // All shift=0 terms are sorted first, so we don't need // to filter the incoming terms; we can just get the // min: BytesRef min = terms.getMin(); return (min != null) ? NumericUtils.prefixCodedToLong(min) : null; }
@Override public Number toNumber(BytesRef indexForm) { return NumericUtils.sortableLongToDouble(NumericUtils.prefixCodedToLong(indexForm)); } };
@Override public String indexedToReadable(String indexedForm) { return super.toExternal( new Date(NumericUtils.prefixCodedToLong(indexedForm)) ); }
@Override public double toDouble(BytesRef indexForm) { return NumericUtils.sortableLongToDouble(NumericUtils.prefixCodedToLong(indexForm)); }
@Override public void consume(final BytesRef ref) throws Exception { //check both ref length and data type before consuming the ref value if(ref.length == NumericUtils.BUF_SIZE_LONG && _dataType == Constants.FIELD_DATA_TYPE.LONG) { _strings[_ptr++] = Long.toString(NumericUtils.prefixCodedToLong(ref)); } else if(ref.length == NumericUtils.BUF_SIZE_INT && _dataType == Constants.FIELD_DATA_TYPE.INT) { _strings[_ptr++] = Integer.toString(NumericUtils.prefixCodedToInt(ref)); } else _strings[_ptr++] = ref.utf8ToString(); }
public Long next() throws IOException { final BytesRef term = termsEnum.next(); if (term == null) { return null; } if (termEncoding == GeoPointField.TermEncoding.PREFIX) { return GeoEncodingUtils.prefixCodedToGeoCoded(term); } else if (termEncoding == GeoPointField.TermEncoding.NUMERIC) { return NumericUtils.prefixCodedToLong(term); } throw new IllegalArgumentException("GeoPoint.TermEncoding should be one of: " + GeoPointField.TermEncoding.PREFIX + " or " + GeoPointField.TermEncoding.NUMERIC + " found: " + termEncoding); } }
@Override public String indexedToReadable(String indexedForm) { switch (type) { case INTEGER: return Integer.toString( NumericUtils.prefixCodedToInt(indexedForm) ); case FLOAT: return Float.toString( NumericUtils.sortableIntToFloat(NumericUtils.prefixCodedToInt(indexedForm)) ); case LONG: return Long.toString( NumericUtils.prefixCodedToLong(indexedForm) ); case DOUBLE: return Double.toString( NumericUtils.sortableLongToDouble(NumericUtils.prefixCodedToLong(indexedForm)) ); case DATE: return dateField.formatDate( new Date(NumericUtils.prefixCodedToLong(indexedForm)) ); default: throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + type); } }
/** * Returns the maximum long value indexed into this * numeric field or null if no terms exist. */ public static Long getMaxLong(Terms terms) throws IOException { BytesRef max = longTerms(terms).getMax(); return (max != null) ? NumericUtils.prefixCodedToLong(max) : null; }
/** * Returns the maximum long value indexed into this * numeric field or null if no terms exist. */ public static Long getMaxLong(Terms terms) throws IOException { BytesRef max = longTerms(terms).getMax(); return (max != null) ? NumericUtils.prefixCodedToLong(max) : null; }
void dump(PrintStream out){ out.println(field+":"); final BytesRef ref = new BytesRef(); for (int i = 0; i < terms.size(); i++) { terms.get(ords[i], ref); out.print(ref+" "+ref.utf8ToString()+" "); try { out.print(Long.toHexString(NumericUtils.prefixCodedToLong(ref))+"L"); } catch (Exception e) { try { out.print(Integer.toHexString(NumericUtils.prefixCodedToInt(ref))+"i"); } catch (Exception ee) { } } out.println(" score="+scores[ords[i]]); out.println(""); } } }
@Override protected boolean termCompare(final Term term) { if (term.field() != NumericIntervalIntersectionQuery.this.name) { this.endEnum = true; return false; } // Taken from NumericUtils.prefixCodedToLong final int shift = term.text().charAt(0) - NumericUtils.SHIFT_START_LONG; final long startOfRange = NumericUtils.prefixCodedToLong(term.text()); final long endOfRange = startOfRange + (1 << shift) - 1; final boolean result = // The query interval contains the start of the indexed. (startOfRange >= NumericIntervalIntersectionQuery.this.start && startOfRange <= NumericIntervalIntersectionQuery.this.end) || // The query interval contains the start of the indexed. (endOfRange >= NumericIntervalIntersectionQuery.this.start && endOfRange <= NumericIntervalIntersectionQuery.this.end) || // The query interval is contained in the indexed interval. (startOfRange <= NumericIntervalIntersectionQuery.this.start && endOfRange >= NumericIntervalIntersectionQuery.this.end); this.skip = !result; return result; }
while ((term = iter.next()) != null) { values = BigArrays.NON_RECYCLING_INSTANCE.grow(values, numTerms + 1); values.set(numTerms++, NumericUtils.sortableLongToDouble(NumericUtils.prefixCodedToLong(term)));