Search in sources :

Example 11 with SimpleImmutableEntry

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));
}
Also used : Completion(com.github.anba.es6draft.compiler.StatementGenerator.Completion) SimpleImmutableEntry(java.util.AbstractMap.SimpleImmutableEntry) LabelState(com.github.anba.es6draft.compiler.CodeVisitor.LabelState) MethodCode(com.github.anba.es6draft.compiler.assembler.Code.MethodCode) GeneratorState(com.github.anba.es6draft.compiler.CodeVisitor.GeneratorState)

Example 12 with SimpleImmutableEntry

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);
    }
}
Also used : SimpleImmutableEntry(java.util.AbstractMap.SimpleImmutableEntry)

Example 13 with SimpleImmutableEntry

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>]");
}
Also used : SimpleImmutableEntry(java.util.AbstractMap.SimpleImmutableEntry) Entry(java.util.Map.Entry) SimpleImmutableEntry(java.util.AbstractMap.SimpleImmutableEntry) Supplier(com.google.common.base.Supplier) AbstractCacheStats(org.apache.jackrabbit.oak.cache.AbstractCacheStats) Test(org.junit.Test)

Example 14 with SimpleImmutableEntry

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);
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) IntStream(java.util.stream.IntStream) CoreMatchers(org.hamcrest.CoreMatchers) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) SortKey(javax.swing.RowSorter.SortKey) CoreMatchers.not(org.hamcrest.CoreMatchers.not) HashMap(java.util.HashMap) SimpleImmutableEntry(java.util.AbstractMap.SimpleImmutableEntry) Collections.singletonList(java.util.Collections.singletonList) ArrayList(java.util.ArrayList) Assert.assertSame(org.junit.Assert.assertSame) Assert.assertThat(org.junit.Assert.assertThat) Arrays.asList(java.util.Arrays.asList) CoreMatchers.allOf(org.hamcrest.CoreMatchers.allOf) ExpectedException(org.junit.rules.ExpectedException) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) CoreMatchers.sameInstance(org.hamcrest.CoreMatchers.sameInstance) Before(org.junit.Before) Functor(org.apache.jorphan.reflect.Functor) Collections.emptyList(java.util.Collections.emptyList) Test(org.junit.Test) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) ErrorCollector(org.junit.rules.ErrorCollector) SortOrder(javax.swing.SortOrder) AbstractMap(java.util.AbstractMap) List(java.util.List) Rule(org.junit.Rule) Entry(java.util.Map.Entry) Comparator(java.util.Comparator) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) SimpleImmutableEntry(java.util.AbstractMap.SimpleImmutableEntry) SortKey(javax.swing.RowSorter.SortKey) Test(org.junit.Test)

Example 15 with SimpleImmutableEntry

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);
}
Also used : SimpleImmutableEntry(java.util.AbstractMap.SimpleImmutableEntry) SortKey(javax.swing.RowSorter.SortKey) Test(org.junit.Test)

Aggregations

SimpleImmutableEntry (java.util.AbstractMap.SimpleImmutableEntry)29 Test (org.junit.Test)19 FakeProcess (com.facebook.buck.util.FakeProcess)9 FakeProcessExecutor (com.facebook.buck.util.FakeProcessExecutor)9 ImmutableList (com.google.common.collect.ImmutableList)9 SortKey (javax.swing.RowSorter.SortKey)9 HashMap (java.util.HashMap)5 NonNull (android.support.annotation.NonNull)4 WorkerThread (android.support.annotation.WorkerThread)4 StorIOException (com.pushtorefresh.storio.StorIOException)4 Entry (java.util.Map.Entry)4 GeneratorState (com.github.anba.es6draft.compiler.CodeVisitor.GeneratorState)2 LabelState (com.github.anba.es6draft.compiler.CodeVisitor.LabelState)2 Completion (com.github.anba.es6draft.compiler.StatementGenerator.Completion)2 MethodCode (com.github.anba.es6draft.compiler.assembler.Code.MethodCode)2 ContentResolverTypeMapping (com.pushtorefresh.storio.contentresolver.ContentResolverTypeMapping)2 StorIOContentResolver (com.pushtorefresh.storio.contentresolver.StorIOContentResolver)2 SQLiteTypeMapping (com.pushtorefresh.storio.sqlite.SQLiteTypeMapping)2 StorIOSQLite (com.pushtorefresh.storio.sqlite.StorIOSQLite)2 ArrayList (java.util.ArrayList)2