本文整理汇总了Java中java.util.function.ToLongBiFunction类的典型用法代码示例。如果您正苦于以下问题:Java ToLongBiFunction类的具体用法?Java ToLongBiFunction怎么用?Java ToLongBiFunction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ToLongBiFunction类属于java.util.function包,在下文中一共展示了ToLongBiFunction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldMemoizeBiFunction
import java.util.function.ToLongBiFunction; //导入依赖的package包/类
/**
*
*/
@Test
public void shouldMemoizeBiFunction() {
// given
final ToLongBiFunction<String, String> function = (first, second) -> 123;
final BiFunction<String, String, String> keyfunction = hashCodeKeyFunction();
try (final Cache<String, Long> cache = JCacheMemoize.createCache(ToLongBiFunction.class)) {
// when
final JCacheBasedToLongBiFunctionMemoizer<String, String, String> loader = new JCacheBasedToLongBiFunctionMemoizer<>(
cache, keyfunction, function);
// then
Assert.assertEquals("Memoized value does not match expectation", 123,
loader.applyAsLong("first", "second"));
}
}
示例2: shouldRequireNonNullCache
import java.util.function.ToLongBiFunction; //导入依赖的package包/类
/**
*
*/
@Test
@SuppressWarnings(CompilerWarnings.UNUSED)
public void shouldRequireNonNullCache() {
// given
final ConcurrentMap<String, Long> cache = null;
final BiFunction<String, String, String> keyFunction = (a, b) -> "key";
final ToLongBiFunction<String, String> biFunction = (a, b) -> 123L;
// when
thrown.expect(NullPointerException.class);
thrown.expectMessage("Provide an empty map instead of NULL.");
// then
new ConcurrentMapBasedToLongBiFunctionMemoizer<>(cache, keyFunction, biFunction);
}
开发者ID:sebhoss,项目名称:memoization.java,代码行数:19,代码来源:ConcurrentMapBasedToLongBiFunctionMemoizerTest.java
示例3: shouldRequireNonNullKeyBiFunction
import java.util.function.ToLongBiFunction; //导入依赖的package包/类
/**
*
*/
@Test
@SuppressWarnings(CompilerWarnings.UNUSED)
public void shouldRequireNonNullKeyBiFunction() {
// given
final ConcurrentMap<String, Long> cache = new ConcurrentHashMap<>();
final BiFunction<String, String, String> keyFunction = null;
final ToLongBiFunction<String, String> biFunction = (a, b) -> 123L;
// when
thrown.expect(NullPointerException.class);
thrown.expectMessage("Provide a key function, might just be 'MemoizationDefaults.hashCodeKeyFunction()'.");
// then
new ConcurrentMapBasedToLongBiFunctionMemoizer<>(cache, keyFunction, biFunction);
}
开发者ID:sebhoss,项目名称:memoization.java,代码行数:19,代码来源:ConcurrentMapBasedToLongBiFunctionMemoizerTest.java
示例4: shouldRequireNonNullBiFunction
import java.util.function.ToLongBiFunction; //导入依赖的package包/类
/**
*
*/
@Test
@SuppressWarnings(CompilerWarnings.UNUSED)
public void shouldRequireNonNullBiFunction() {
// given
final ConcurrentMap<String, Long> cache = new ConcurrentHashMap<>();
final BiFunction<String, String, String> keyFunction = (a, b) -> "key";
final ToLongBiFunction<String, String> biFunction = null;
// when
thrown.expect(NullPointerException.class);
thrown.expectMessage(
"Cannot memoize a NULL ToLongBiFunction - provide an actual ToLongBiFunction to fix this.");
// then
new ConcurrentMapBasedToLongBiFunctionMemoizer<>(cache, keyFunction, biFunction);
}
开发者ID:sebhoss,项目名称:memoization.java,代码行数:20,代码来源:ConcurrentMapBasedToLongBiFunctionMemoizerTest.java
示例5: shouldUseSetCacheKeyAndValue
import java.util.function.ToLongBiFunction; //导入依赖的package包/类
/**
*
*/
@Test
public void shouldUseSetCacheKeyAndValue() {
// given
final ConcurrentMap<String, Long> cache = new ConcurrentHashMap<>();
final BiFunction<String, String, String> keyFunction = (a, b) -> "key";
final ToLongBiFunction<String, String> biFunction = (a, b) -> 123L;
// when
final ConcurrentMapBasedToLongBiFunctionMemoizer<String, String, String> memoizer = new ConcurrentMapBasedToLongBiFunctionMemoizer<>(
cache, keyFunction, biFunction);
// then
memoizer.applyAsLong("123.456", "789.123");
Assert.assertFalse("Cache is still empty after memoization", memoizer.viewCacheForTest().isEmpty());
Assert.assertEquals("Memoization key does not match expectations", "key",
memoizer.viewCacheForTest().keySet().iterator().next());
Assert.assertEquals("Memoization value does not match expectations", 123L,
memoizer.viewCacheForTest().values().iterator().next().longValue());
}
开发者ID:sebhoss,项目名称:memoization.java,代码行数:23,代码来源:ConcurrentMapBasedToLongBiFunctionMemoizerTest.java
示例6: shouldUseCallWrappedBiFunction
import java.util.function.ToLongBiFunction; //导入依赖的package包/类
/**
*
*/
@Test
@SuppressWarnings(CompilerWarnings.UNCHECKED)
public void shouldUseCallWrappedBiFunction() {
// given
final ConcurrentMap<String, Long> cache = new ConcurrentHashMap<>();
final BiFunction<String, String, String> keyFunction = (a, b) -> "key";
final ToLongBiFunction<String, String> biFunction = Mockito.mock(ToLongBiFunction.class);
// when
final ConcurrentMapBasedToLongBiFunctionMemoizer<String, String, String> memoizer = new ConcurrentMapBasedToLongBiFunctionMemoizer<>(
cache, keyFunction, biFunction);
// then
memoizer.applyAsLong("123.456", "789.123");
Mockito.verify(biFunction).applyAsLong("123.456", "789.123");
}
开发者ID:sebhoss,项目名称:memoization.java,代码行数:20,代码来源:ConcurrentMapBasedToLongBiFunctionMemoizerTest.java
示例7: of
import java.util.function.ToLongBiFunction; //导入依赖的package包/类
static <ENTITY> SqlStreamOptimizerInfo<ENTITY> of(
final DbmsType dbmsType,
final String sqlSelect,
final String sqlSelectCount,
final ToLongBiFunction<String, List<Object>> counter,
final Function<Field<ENTITY>, String> sqlColumnNamer,
final Function<Field<ENTITY>, Class<?>> sqlDatabaseTypeFunction
) {
return new SqlStreamOptimizerInfoImpl<>(
dbmsType,
sqlSelect,
sqlSelectCount,
counter,
sqlColumnNamer,
sqlDatabaseTypeFunction
);
}
示例8: testCheckedToLongBiFunction
import java.util.function.ToLongBiFunction; //导入依赖的package包/类
@Test
public void testCheckedToLongBiFunction() {
final CheckedToLongBiFunction<Object, Object> toLongBiFunction = (t, u) -> {
throw new Exception(t + ":" + u);
};
ToLongBiFunction<Object, Object> f1 = Unchecked.toLongBiFunction(toLongBiFunction);
ToLongBiFunction<Object, Object> f2 = CheckedToLongBiFunction.unchecked(toLongBiFunction);
ToLongBiFunction<Object, Object> f3 = Sneaky.toLongBiFunction(toLongBiFunction);
ToLongBiFunction<Object, Object> f4 = CheckedToLongBiFunction.sneaky(toLongBiFunction);
assertToLongBiFunction(f1, UncheckedException.class);
assertToLongBiFunction(f2, UncheckedException.class);
assertToLongBiFunction(f3, Exception.class);
assertToLongBiFunction(f4, Exception.class);
}
示例9: super
import java.util.function.ToLongBiFunction; //导入依赖的package包/类
MapReduceMappingsToLongTask
(BulkTask<K,V,?> p, int b, int i, int f, Node<K,V>[] t,
MapReduceMappingsToLongTask<K,V> nextRight,
ToLongBiFunction<? super K, ? super V> transformer,
long basis,
LongBinaryOperator reducer) {
super(p, b, i, f, t); this.nextRight = nextRight;
this.transformer = transformer;
this.basis = basis; this.reducer = reducer;
}
示例10: compute
import java.util.function.ToLongBiFunction; //导入依赖的package包/类
public final void compute() {
final ToLongBiFunction<? super K, ? super V> transformer;
final LongBinaryOperator reducer;
if ((transformer = this.transformer) != null &&
(reducer = this.reducer) != null) {
long r = this.basis;
for (int i = baseIndex, f, h; batch > 0 &&
(h = ((f = baseLimit) + i) >>> 1) > i;) {
addToPendingCount(1);
(rights = new MapReduceMappingsToLongTask<K,V>
(this, batch >>>= 1, baseLimit = h, f, tab,
rights, transformer, r, reducer)).fork();
}
for (Node<K,V> p; (p = advance()) != null; )
r = reducer.applyAsLong(r, transformer.applyAsLong(p.key, p.val));
result = r;
CountedCompleter<?> c;
for (c = firstComplete(); c != null; c = c.nextComplete()) {
@SuppressWarnings("unchecked")
MapReduceMappingsToLongTask<K,V>
t = (MapReduceMappingsToLongTask<K,V>)c,
s = t.rights;
while (s != null) {
t.result = reducer.applyAsLong(t.result, s.result);
s = t.rights = s.nextRight;
}
}
}
}
示例11: compute
import java.util.function.ToLongBiFunction; //导入依赖的package包/类
@Override
public final void compute() {
final ToLongBiFunction<? super K, ? super V> transformer;
final LongBinaryOperator reducer;
if ((transformer = this.transformer) != null &&
(reducer = this.reducer) != null) {
long r = this.basis;
for (int i = this.baseIndex, f, h; this.batch > 0 &&
(h = ((f = this.baseLimit) + i) >>> 1) > i;) {
this.addToPendingCount(1);
(this.rights = new MapReduceMappingsToLongTask<K,V>
(this, this.batch >>>= 1, this.baseLimit = h, f, this.tab,
this.rights, transformer, r, reducer)).fork();
}
for (Node<K,V> p; (p = this.advance()) != null; ) {
r = reducer.applyAsLong(r, transformer.applyAsLong(p.key, p.val));
}
this.result = r;
CountedCompleter<?> c;
for (c = this.firstComplete(); c != null; c = c.nextComplete()) {
@SuppressWarnings("unchecked")
MapReduceMappingsToLongTask<K,V>
t = (MapReduceMappingsToLongTask<K,V>)c,
s = t.rights;
while (s != null) {
t.result = reducer.applyAsLong(t.result, s.result);
s = t.rights = s.nextRight;
}
}
}
}
示例12: MapReduceMappingsToLongTask
import java.util.function.ToLongBiFunction; //导入依赖的package包/类
MapReduceMappingsToLongTask(final BulkTask<K, V, ?> p, final int b, final int i, final int f, final Node<K, V>[] t, final MapReduceMappingsToLongTask<K, V> nextRight, final ToLongBiFunction<? super K, ? super V> transformer, final long basis, final LongBinaryOperator reducer)
{
super(p, b, i, f, t);
this.nextRight = nextRight;
this.transformer = transformer;
this.basis = basis;
this.reducer = reducer;
}
示例13: compute
import java.util.function.ToLongBiFunction; //导入依赖的package包/类
@Override
public final void compute()
{
final ToLongBiFunction<? super K, ? super V> transformer;
final LongBinaryOperator reducer;
if ((((transformer = this.transformer)) != null) && (((reducer = this.reducer)) != null))
{
long r = this.basis;
for (int i = this.baseIndex, f, h; (this.batch > 0) && (((h = (((f = this.baseLimit)) + i) >>> 1)) > i); )
{
this.addToPendingCount(1);
(this.rights = new MapReduceMappingsToLongTask<>(this, this.batch >>>= 1, this.baseLimit = h, f, this.tab, this.rights, transformer, r, reducer)).fork();
}
for (Node<K, V> p; (p = this.advance()) != null; )
{
r = reducer.applyAsLong(r, transformer.applyAsLong(p.key, p.val));
}
this.result = r;
CountedCompleter<?> c;
for (c = this.firstComplete(); c != null; c = c.nextComplete())
{
@SuppressWarnings("unchecked")
final MapReduceMappingsToLongTask<K, V> t = (MapReduceMappingsToLongTask<K, V>) c;
@SuppressWarnings("unchecked")
MapReduceMappingsToLongTask<K, V> s = t.rights;
while (s != null)
{
t.result = reducer.applyAsLong(t.result, s.result);
s = t.rights = s.nextRight;
}
}
}
}
示例14: DefaultCardinalityEstimator
import java.util.function.ToLongBiFunction; //导入依赖的package包/类
public DefaultCardinalityEstimator(double certaintyProb,
int numInputs,
boolean isAllowMoreInputs,
ToLongBiFunction<long[], Configuration> singlePointEstimator) {
this.certaintyProb = certaintyProb;
this.numInputs = numInputs;
this.singlePointEstimator = singlePointEstimator;
this.isAllowMoreInputs = isAllowMoreInputs;
}
示例15: DefaultLoadEstimator
import java.util.function.ToLongBiFunction; //导入依赖的package包/类
public DefaultLoadEstimator(int numInputs,
int numOutputs,
double correctnessProbability,
CardinalityEstimate nullCardinalityReplacement,
ToLongBiFunction<long[], long[]> singlePointFunction) {
this(
numInputs, numOutputs, correctnessProbability, nullCardinalityReplacement,
(context, inputEstimates, outputEstimates) -> singlePointFunction.applyAsLong(inputEstimates, outputEstimates)
);
}