public final long updateAndGet(LongUnaryOperator updateFunction) { int expectedVersion; long newValue; do { expectedVersion = version; newValue = updateFunction.applyAsLong(value); } while (expectedVersion != version); ++version; value = newValue; return newValue; }
@Override public LongUnaryOperator globalOrdinalsMapping(LeafReaderContext context) throws IOException { return LongUnaryOperator.identity(); }
/** * Valid for any number of calls from the beginning of assembly. * * @param andThen a LongUnaryOperator * @return this FunctionAssemble */ public FunctionAssembler andThen(LongUnaryOperator andThen) { // TODO: add type checks or possible miswiring assertions here. if (longlongfunction == null) { longlongfunction = andThen; } else { longlongfunction = longlongfunction.andThen(andThen); } return this; }
@Override public LongUnaryOperator globalOrdinalsMapping(LeafReaderContext context) throws IOException { final IndexOrdinalsFieldData global = indexFieldData.loadGlobal((DirectoryReader)context.parent.reader()); final OrdinalMap map = global.getOrdinalMap(); if (map == null) { // segments and global ordinals are the same return LongUnaryOperator.identity(); } final org.apache.lucene.util.LongValues segmentToGlobalOrd = map.getGlobalOrds(context.ord); return segmentToGlobalOrd::get; } }
/** * Valid for any number of calls from the beginning of assembly. * * @param andThen a LongUnaryOperator * @return this FunctionAssemble */ public FunctionAssembler andThen(LongUnaryOperator andThen) { // TODO: add type checks or possible miswiring assertions here. if (longlongfunction == null) { longlongfunction = andThen; } else { longlongfunction = longlongfunction.andThen(andThen); } return this; }
public final long getAndUpdate(LongUnaryOperator updateFunction) { int expectedVersion; long result; long newValue; do { expectedVersion = version; result = value; newValue = updateFunction.applyAsLong(value); } while (expectedVersion != version); ++version; value = newValue; return result; }
@Override public LongUnaryOperator globalOrdinalsMapping(LeafReaderContext context) throws IOException { return LongUnaryOperator.identity(); }
public static long apply(LongUnaryOperator longUnaryOperator, long value) { return longUnaryOperator.applyAsLong(value); } }
@Override public LongUnaryOperator globalOrdinalsMapping(LeafReaderContext context) throws IOException { return LongUnaryOperator.identity(); }
/** * Updates the value currently associated with {@code key} with the specified function, and * returns the new value. If there is not currently a value associated with {@code key}, the * function is applied to {@code 0L}. * * @since 21.0 */ @CanIgnoreReturnValue public long updateAndGet(K key, LongUnaryOperator updaterFunction) { checkNotNull(updaterFunction); return map.compute( key, (k, value) -> updaterFunction.applyAsLong((value == null) ? 0L : value.longValue())); }
rounding = ((RoundingValuesSource) vs)::round; } else { rounding = LongUnaryOperator.identity();
/** * Updates the value currently associated with {@code key} with the specified function, and * returns the old value. If there is not currently a value associated with {@code key}, the * function is applied to {@code 0L}. * * @since 21.0 */ @CanIgnoreReturnValue public long getAndUpdate(K key, LongUnaryOperator updaterFunction) { checkNotNull(updaterFunction); AtomicLong holder = new AtomicLong(); map.compute( key, (k, value) -> { long oldValue = (value == null) ? 0L : value.longValue(); holder.set(oldValue); return updaterFunction.applyAsLong(oldValue); }); return holder.get(); }
@Override public LongUnaryOperator globalOrdinalsMapping(LeafReaderContext context) throws IOException { final IndexOrdinalsFieldData global = indexFieldData.loadGlobal((DirectoryReader)context.parent.reader()); final OrdinalMap map = global.getOrdinalMap(); if (map == null) { // segments and global ordinals are the same return LongUnaryOperator.identity(); } final org.apache.lucene.util.LongValues segmentToGlobalOrd = map.getGlobalOrds(context.ord); return segmentToGlobalOrd::get; } }
@Override public ToLongNullable<T> mapIfPresent(LongUnaryOperator mapper) { return t -> isNull.test(t) ? null : mapper.applyAsLong(original.applyAsLong(t)); }
@Override public LongUnaryOperator globalOrdinalsMapping(LeafReaderContext context) throws IOException { final IndexOrdinalsFieldData global = indexFieldData.loadGlobal((DirectoryReader)context.parent.reader()); final OrdinalMap map = global.getOrdinalMap(); if (map == null) { // segments and global ordinals are the same return LongUnaryOperator.identity(); } final org.apache.lucene.util.LongValues segmentToGlobalOrd = map.getGlobalOrds(context.ord); return segmentToGlobalOrd::get; } }
@Override public long applyAsLong(T object) throws NullPointerException { return mapper.applyAsLong(delegate.applyAsLong(object)); }
@Override public long applyAsLong(T object) { return this.mapper.applyAsLong(this.inner.applyAsLong(object)); }
@Override public boolean next(LongPredicate consumer) { while (true) { long valueToReport = value; value = f.applyAsLong(value); if (!consumer.test(valueToReport)) { return true; } } } }
@Override protected LongPredicate wrap(LongPredicate consumer) { return t -> consumer.test(mapper.applyAsLong(t)); }
/** * Updates the value currently associated with {@code key} with the specified function, and * returns the old value. If there is not currently a value associated with {@code key}, the * function is applied to {@code 0L}. * * @since 21.0 */ @CanIgnoreReturnValue public long getAndUpdate(K key, LongUnaryOperator updaterFunction) { checkNotNull(updaterFunction); AtomicLong holder = new AtomicLong(); map.compute( key, (k, value) -> { long oldValue = (value == null) ? 0L : value.longValue(); holder.set(oldValue); return updaterFunction.applyAsLong(oldValue); }); return holder.get(); }