当前位置: 首页>>代码示例>>Java>>正文


Java ToLongFunction类代码示例

本文整理汇总了Java中java.util.function.ToLongFunction的典型用法代码示例。如果您正苦于以下问题:Java ToLongFunction类的具体用法?Java ToLongFunction怎么用?Java ToLongFunction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ToLongFunction类属于java.util.function包,在下文中一共展示了ToLongFunction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: callLong

import java.util.function.ToLongFunction; //导入依赖的package包/类
private static <A extends Annotation, E extends Throwable> long callLong(
        AnnotationInterceptor<A> annotationInterceptor,
        int annotationId, A[] annotations, CallContext context, Arguments currentArguments,
        ToLongFunction<Arguments> terminalInvokeFun) throws E {

    A annotation = annotations[annotationId];
    if (annotationId == annotations.length - 1) { // last annotation
        return annotationInterceptor.onCall(annotation, context,
                new SimpleLongInterceptionHandler(currentArguments, terminalInvokeFun));
    } else {
        return annotationInterceptor.onCall(annotation, context,
                new SimpleLongInterceptionHandler(currentArguments,
                        (args) -> callLong(annotationInterceptor, annotationId + 1, annotations, context, args,
                                terminalInvokeFun)));
    }
}
 
开发者ID:primeval-io,项目名称:primeval-reflex,代码行数:17,代码来源:RepeatedAnnotationObjectInterceptor.java

示例2: mapToLong

import java.util.function.ToLongFunction; //导入依赖的package包/类
@Override
public final LongStream mapToLong(ToLongFunction<? super P_OUT> mapper) {
    Objects.requireNonNull(mapper);
    return new LongPipeline.StatelessOp<P_OUT>(this, StreamShape.REFERENCE,
                                  StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<P_OUT> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedReference<P_OUT, Long>(sink) {
                @Override
                public void accept(P_OUT u) {
                    downstream.accept(mapper.applyAsLong(u));
                }
            };
        }
    };
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:ReferencePipeline.java

示例3: testLongComparator

import java.util.function.ToLongFunction; //导入依赖的package包/类
public void testLongComparator() {
    Thing[] things = new Thing[longValues.length];
    for (int i=0; i<longValues.length; i++)
        things[i] = new Thing(0, longValues[i], 0.0, null);
    Comparator<Thing> comp = Comparator.comparingLong(new ToLongFunction<Thing>() {
        @Override
        public long applyAsLong(Thing thing) {
            return thing.getLongField();
        }
    });

    assertComparisons(things, comp, comparisons);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:BasicTest.java

示例4: mapToLongs

import java.util.function.ToLongFunction; //导入依赖的package包/类
/**
 * Maps the specified column to longs using the mapper function provided
 * @param frame     the frame reference
 * @param colKey    the column key to apply mapper function to
 * @param mapper    the mapper function to apply
 * @return          the newly created content, with update column
 */
@SuppressWarnings("unchecked")
final XDataFrameContent<R,C> mapToLongs(XDataFrame<R,C> frame, C colKey, ToLongFunction<DataFrameValue<R,C>> mapper) {
    if (!isColumnStore()) {
        throw new DataFrameException("Cannot apply columns of a transposed DataFrame");
    } else {
        final int rowCount = rowKeys.size();
        final boolean parallel  = frame.isParallel();
        final int colIndex = colKeys.getIndexForKey(colKey);
        return new XDataFrameContent<>(rowKeys, colKeys, true, Mapper.apply(data, parallel, (index, array) -> {
            if (index != colIndex) {
                return array;
            } else {
                final int colOrdinal = colKeys.getOrdinalForKey(colKey);
                final Array<?> targetValues = Array.of(Long.class, array.length());
                final Cursor cursor = new Cursor(frame, rowKeys.isEmpty() ? -1 : 0, colOrdinal);
                for (int i = 0; i < rowCount; ++i) {
                    cursor.atRowOrdinal(i);
                    final long value = mapper.applyAsLong(cursor);
                    targetValues.setLong(cursor.rowIndex, value);
                }
                return targetValues;
            }
        }));
    }
}
 
开发者ID:zavtech,项目名称:morpheus-core,代码行数:33,代码来源:XDataFrameContent.java

示例5: testBinaryInputEstimation

import java.util.function.ToLongFunction; //导入依赖的package包/类
@Test
public void testBinaryInputEstimation() {
    OptimizationContext optimizationContext = mock(OptimizationContext.class);
    when(optimizationContext.getConfiguration()).thenReturn(new Configuration());

    CardinalityEstimate inputEstimate1 = new CardinalityEstimate(50, 60, 0.8);
    CardinalityEstimate inputEstimate2 = new CardinalityEstimate(10, 100, 0.4);

    final ToLongFunction<long[]> singlePointEstimator =
            inputEstimates -> (long) Math.ceil(0.8 * inputEstimates[0] * inputEstimates[1]);

    CardinalityEstimator estimator = new DefaultCardinalityEstimator(
            0.9,
            2,
            false,
            singlePointEstimator
    );

    CardinalityEstimate estimate = estimator.estimate(optimizationContext, inputEstimate1, inputEstimate2);

    Assert.assertEquals(0.9 * 0.4, estimate.getCorrectnessProbability(), 0.001);
    Assert.assertEquals(singlePointEstimator.applyAsLong(new long[]{50, 10}), estimate.getLowerEstimate());
    Assert.assertEquals(singlePointEstimator.applyAsLong(new long[]{60, 100}), estimate.getUpperEstimate());

}
 
开发者ID:daqcri,项目名称:rheem,代码行数:26,代码来源:DefaultCardinalityEstimatorTest.java

示例6: shouldUseCallWrappedFunction

import java.util.function.ToLongFunction; //导入依赖的package包/类
/**
*
*/
@Test
@SuppressWarnings(CompilerWarnings.UNCHECKED)
public void shouldUseCallWrappedFunction() {
    // given
    final ConcurrentMap<String, Long> cache = new ConcurrentHashMap<>();
    final ToLongFunction<String> function = Mockito.mock(ToLongFunction.class);
    final Function<String, String> keyFunction = Function.identity();

    // when
    final ConcurrentMapBasedToLongFunctionMemoizer<String, String> memoizer = new ConcurrentMapBasedToLongFunctionMemoizer<>(
            cache, keyFunction, function);

    // then
    memoizer.applyAsLong("123");
    Mockito.verify(function).applyAsLong("123");
}
 
开发者ID:sebhoss,项目名称:memoization.java,代码行数:20,代码来源:ConcurrentMapBasedToLongFunctionMemoizerTest.java

示例7: newFunctionTimer

import java.util.function.ToLongFunction; //导入依赖的package包/类
@Override
protected <T> FunctionTimer newFunctionTimer(Meter.Id id, T obj, ToLongFunction<T> countFunction, ToDoubleFunction<T> totalTimeFunction, TimeUnit totalTimeFunctionUnits) {
    DropwizardFunctionTimer ft = new DropwizardFunctionTimer<>(id, clock, obj, countFunction, totalTimeFunction,
        totalTimeFunctionUnits, getBaseTimeUnit());
    registry.register(hierarchicalName(id), ft.getDropwizardMeter());
    return ft;
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:8,代码来源:DropwizardMeterRegistry.java

示例8: CumulativeFunctionTimer

import java.util.function.ToLongFunction; //导入依赖的package包/类
public CumulativeFunctionTimer(Id id, T obj, ToLongFunction<T> countFunction, ToDoubleFunction<T> totalTimeFunction,
                               TimeUnit totalTimeFunctionUnits, TimeUnit baseTimeUnit) {
    this.id = id;
    this.ref = new WeakReference<>(obj);
    this.countFunction = countFunction;
    this.totalTimeFunction = totalTimeFunction;
    this.totalTimeFunctionUnits = totalTimeFunctionUnits;
    this.baseTimeUnit = baseTimeUnit;
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:10,代码来源:CumulativeFunctionTimer.java

示例9: StepFunctionTimer

import java.util.function.ToLongFunction; //导入依赖的package包/类
public StepFunctionTimer(Id id, Clock clock, long stepMillis, T obj, ToLongFunction<T> countFunction,
                         ToDoubleFunction<T> totalTimeFunction, TimeUnit totalTimeFunctionUnits, TimeUnit baseTimeUnit) {
    this.id = id;
    this.ref = new WeakReference<>(obj);
    this.countFunction = countFunction;
    this.totalTimeFunction = totalTimeFunction;
    this.totalTimeFunctionUnits = totalTimeFunctionUnits;
    this.baseTimeUnit = baseTimeUnit;
    this.count = new StepLong(clock, stepMillis);
    this.total = new StepDouble(clock, stepMillis);
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:12,代码来源:StepFunctionTimer.java

示例10: timer

import java.util.function.ToLongFunction; //导入依赖的package包/类
/**
 * A timer that tracks monotonically increasing functions for count and totalTime.
 */
public <T> FunctionTimer timer(String name, Iterable<Tag> tags, T obj,
                               ToLongFunction<T> countFunction,
                               ToDoubleFunction<T> totalTimeFunction,
                               TimeUnit totalTimeFunctionUnits) {
    return globalRegistry.more().timer(name, tags, obj, countFunction, totalTimeFunction, totalTimeFunctionUnits);
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:10,代码来源:Metrics.java

示例11: Builder

import java.util.function.ToLongFunction; //导入依赖的package包/类
private Builder(String name, T obj,
                ToLongFunction<T> countFunction,
                ToDoubleFunction<T> totalTimeFunction,
                TimeUnit totalTimeFunctionUnits) {
    this.name = name;
    this.obj = obj;
    this.countFunction = countFunction;
    this.totalTimeFunction = totalTimeFunction;
    this.totalTimeFunctionUnits = totalTimeFunctionUnits;
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:11,代码来源:FunctionTimer.java

示例12: CompositeFunctionTimer

import java.util.function.ToLongFunction; //导入依赖的package包/类
CompositeFunctionTimer(Meter.Id id, T obj, ToLongFunction<T> countFunction,
                       ToDoubleFunction<T> totalTimeFunction, TimeUnit totalTimeFunctionUnits) {
    super(id);
    this.ref = new WeakReference<>(obj);
    this.countFunction = countFunction;
    this.totalTimeFunction = totalTimeFunction;
    this.totalTimeFunctionUnits = totalTimeFunctionUnits;
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:9,代码来源:CompositeFunctionTimer.java

示例13: StatsdFunctionTimer

import java.util.function.ToLongFunction; //导入依赖的package包/类
StatsdFunctionTimer(Id id, T obj, ToLongFunction<T> countFunction, ToDoubleFunction<T> totalTimeFunction,
                    TimeUnit totalTimeFunctionUnits, TimeUnit baseTimeUnit,
                    StatsdLineBuilder lineBuilder, Subscriber<String> publisher) {
    super(id, obj, countFunction, totalTimeFunction, totalTimeFunctionUnits, baseTimeUnit);
    this.lineBuilder = lineBuilder;
    this.publisher = publisher;
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:8,代码来源:StatsdFunctionTimer.java

示例14: newFunctionTimer

import java.util.function.ToLongFunction; //导入依赖的package包/类
@Override
protected <T> FunctionTimer newFunctionTimer(Meter.Id id, T obj, ToLongFunction<T> countFunction, ToDoubleFunction<T> totalTimeFunction, TimeUnit totalTimeFunctionUnits) {
    StatsdFunctionTimer ft = new StatsdFunctionTimer<>(id, obj, countFunction, totalTimeFunction, totalTimeFunctionUnits,
        getBaseTimeUnit(), lineBuilder(id), publisher);
    pollableMeters.add(ft);
    return ft;
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:8,代码来源:StatsdMeterRegistry.java

示例15: newFunctionTimer

import java.util.function.ToLongFunction; //导入依赖的package包/类
@Override
protected <T> FunctionTimer newFunctionTimer(Meter.Id id, T obj, ToLongFunction<T> countFunction, ToDoubleFunction<T> totalTimeFunction, TimeUnit totalTimeFunctionUnits) {
    MicrometerCollector collector = collectorByName(id, Collector.Type.SUMMARY);
    FunctionTimer ft = new CumulativeFunctionTimer<>(id, obj, countFunction, totalTimeFunction, totalTimeFunctionUnits, getBaseTimeUnit());
    List<String> tagValues = tagValues(id);

    collector.add((conventionName, tagKeys) -> Stream.of(
        new Collector.MetricFamilySamples.Sample(conventionName + "_count", tagKeys, tagValues, ft.count()),
        new Collector.MetricFamilySamples.Sample(conventionName + "_sum", tagKeys, tagValues, ft.totalTime(TimeUnit.SECONDS))
    ));

    return ft;
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:14,代码来源:PrometheusMeterRegistry.java


注:本文中的java.util.function.ToLongFunction类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。