use of java.util.AbstractMap.SimpleImmutableEntry in project es6draft by anba.
the class CodeGenerator method compile.
Entry<MethodName, LabelState> compile(DoExpression node, CodeVisitor mv) {
if (!isCompiled(node)) {
if (!isEnabled(Compiler.Option.NoCompletion)) {
CompletionValueVisitor.performCompletion(node);
}
MethodCode method = newMethod(mv.getTopLevelNode(), node);
DoExpressionCodeVisitor body = new DoExpressionCodeVisitor(node, method, mv);
body.lineInfo(node);
// force line-number entry
body.nop();
body.begin();
GeneratorState generatorState = null;
if (node.hasYieldOrAwait()) {
generatorState = body.generatorPrologue();
}
body.labelPrologue();
Completion result = statement(node.getStatement(), body);
if (!result.isAbrupt()) {
// fall-thru, return `0`.
body.iconst(0);
body._return();
}
LabelState labelState = body.labelEpilogue(result);
if (generatorState != null) {
body.generatorEpilogue(generatorState);
}
body.end();
doExpressionCompletions.put(node, labelState);
}
return new SimpleImmutableEntry<>(methodDesc(node), doExpressionCompletions.get(node));
}
use of java.util.AbstractMap.SimpleImmutableEntry in project hazelcast by hazelcast.
the class PagingPredicate method setAnchor.
/**
* After each query, an anchor entry is set for that page.
* The anchor entry is the last entry of the query.
*
* @param anchor the last entry of the query
*/
void setAnchor(int page, Map.Entry anchor) {
SimpleImmutableEntry anchorEntry = new SimpleImmutableEntry(page, anchor);
int anchorCount = anchorList.size();
if (page < anchorCount) {
anchorList.set(page, anchorEntry);
} else if (page == anchorCount) {
anchorList.add(anchorEntry);
} else {
throw new IllegalArgumentException("Anchor index is not correct, expected: " + page + " found: " + anchorCount);
}
}
use of java.util.AbstractMap.SimpleImmutableEntry in project jackrabbit-oak by apache.
the class CacheWeightsTest method testSegmentCache.
@Test
public void testSegmentCache() {
final int count = 10000;
final int cacheSizeMB = 100;
final int bufferSize = 5 * 1024;
Supplier<Entry<Object, Long[]>> factory = new Supplier<Entry<Object, Long[]>>() {
@Override
public Entry<Object, Long[]> get() {
SegmentCache cache = new SegmentCache(cacheSizeMB);
for (int i = 0; i < count; ++i) {
Segment segment = randomSegment(bufferSize);
cache.putSegment(segment);
}
AbstractCacheStats stats = cache.getCacheStats();
long elements = stats.getElementCount();
long weight = stats.estimateCurrentWeight();
return new SimpleImmutableEntry<Object, Long[]>(cache, new Long[] { elements, weight });
}
};
runTest(factory, "SegmentCache[x" + cacheSizeMB + "MB|" + bufferSize + "|Cache<SegmentId, Segment>]");
}
use of java.util.AbstractMap.SimpleImmutableEntry in project jmeter by apache.
the class ObjectTableSorterTest method customKeyOrder.
@Test
public void customKeyOrder() {
HashMap<String, Integer> customKeyOrder = asList("a", "c", "b", "d").stream().reduce(new HashMap<String, Integer>(), (map, key) -> {
map.put(key, map.size());
return map;
}, (a, b) -> a);
Comparator<String> customKeyComparator = (a, b) -> customKeyOrder.get(a).compareTo(customKeyOrder.get(b));
sorter.setValueComparator(0, customKeyComparator).setSortKey(new SortKey(0, SortOrder.ASCENDING));
List<SimpleImmutableEntry<String, Integer>> expected = asList(a3(), c1(), b2(), d4());
assertRowOrderAndIndexes(expected);
}
use of java.util.AbstractMap.SimpleImmutableEntry in project jmeter by apache.
the class ObjectTableSorterTest method fixLastRowWithAscendingKey.
@Test
public void fixLastRowWithAscendingKey() {
sorter.fixLastRow().setSortKey(new SortKey(0, SortOrder.ASCENDING));
List<SimpleImmutableEntry<String, Integer>> expected = asList(a3(), b2(), d4(), c1());
assertRowOrderAndIndexes(expected);
}
Aggregations