Search in sources :

Example 61 with Entry

use of java.util.Map.Entry in project neo4j by neo4j.

the class ServerSettingsTest method webServerThreadCountDefaultShouldBeDocumented.

@Test
public void webServerThreadCountDefaultShouldBeDocumented() throws Exception {
    Config config = Config.serverDefaults();
    String documentedDefaultValue = config.getConfigValues().entrySet().stream().filter(c -> c.getKey().equals(ServerSettings.webserver_max_threads.name())).map(Entry::getValue).findAny().orElseThrow(() -> new RuntimeException("Setting not present!")).documentedDefaultValue().orElseThrow(() -> new RuntimeException("Default value not present!"));
    assertEquals("Number of available processors (max 500).", documentedDefaultValue);
}
Also used : Assert.assertThat(org.junit.Assert.assertThat) ConfigValue(org.neo4j.configuration.ConfigValue) List(java.util.List) Config(org.neo4j.kernel.configuration.Config) Collectors.toList(java.util.stream.Collectors.toList) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Entry(java.util.Map.Entry) Optional(java.util.Optional) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) MapUtil.stringMap(org.neo4j.helpers.collection.MapUtil.stringMap) Assert.assertEquals(org.junit.Assert.assertEquals) Entry(java.util.Map.Entry) Config(org.neo4j.kernel.configuration.Config) Test(org.junit.Test)

Example 62 with Entry

use of java.util.Map.Entry in project neo4j by neo4j.

the class ServerSettingsTest method connectorSettingHasItsOwnValues.

@Test
public void connectorSettingHasItsOwnValues() throws Exception {
    Config config = Config.serverDefaults(stringMap("dbms.connector.http.address", "localhost:123"));
    ConfigValue address = config.getConfigValues().entrySet().stream().filter(c -> c.getKey().equals("dbms.connector.http.address")).map(Entry::getValue).findAny().orElseThrow(() -> new RuntimeException("Setting not present!"));
    assertTrue(address.deprecated());
    assertEquals(Optional.of("dbms.connector.http.listen_address"), address.replacement());
}
Also used : Assert.assertThat(org.junit.Assert.assertThat) ConfigValue(org.neo4j.configuration.ConfigValue) List(java.util.List) Config(org.neo4j.kernel.configuration.Config) Collectors.toList(java.util.stream.Collectors.toList) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Entry(java.util.Map.Entry) Optional(java.util.Optional) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) MapUtil.stringMap(org.neo4j.helpers.collection.MapUtil.stringMap) Assert.assertEquals(org.junit.Assert.assertEquals) ConfigValue(org.neo4j.configuration.ConfigValue) Entry(java.util.Map.Entry) Config(org.neo4j.kernel.configuration.Config) Test(org.junit.Test)

Example 63 with Entry

use of java.util.Map.Entry in project jop by jop-devel.

the class GlobalAnalysis method exportCostProfile.

/**
	 * @param flowMap 
     * @param costMissEdges 
	 * @param ipetSolver 
	 * @param problemId
	 */
private WcetCost exportCostProfile(Map<SuperGraphEdge, Long> flowMap, HashMap<String, Set<SuperGraphEdge>> costMissEdges, IPETSolver<SuperGraphEdge> ipetSolver, String problemId) {
    File profileFile = new File(project.getOutDir("profiles"), problemId + ".txt");
    WcetCost cost = new WcetCost();
    HashMap<SuperGraphEdge, Long> costProfile = new HashMap<SuperGraphEdge, Long>();
    HashMap<SuperGraphEdge, Long> cacheCostProfile = new HashMap<SuperGraphEdge, Long>();
    /* extra cost lookup map */
    HashMap<SuperGraphEdge, String> extraCostKeys = new HashMap<SuperGraphEdge, String>();
    for (Entry<String, Set<SuperGraphEdge>> cacheEntry : costMissEdges.entrySet()) {
        String key = cacheEntry.getKey();
        for (SuperGraphEdge costEdge : cacheEntry.getValue()) {
            extraCostKeys.put(costEdge, key);
        }
    }
    for (Entry<SuperGraphEdge, Long> flowEntry : flowMap.entrySet()) {
        SuperGraphEdge edge = flowEntry.getKey();
        long edgeCost = ipetSolver.getEdgeCost(edge);
        long flowCost = edgeCost * flowEntry.getValue();
        if (extraCostKeys.containsKey(edge)) {
            cost.addCacheCost(extraCostKeys.get(edge), flowCost);
            MiscUtils.incrementBy(cacheCostProfile, edge, flowCost, 0);
        } else {
            cost.addLocalCost(flowCost);
        }
        MiscUtils.incrementBy(costProfile, edge, flowCost, 0);
    }
    /* export profile */
    try {
        ArrayList<Entry<SuperGraphEdge, Long>> profile = new ArrayList<Entry<SuperGraphEdge, Long>>(costProfile.entrySet());
        Collections.sort(profile, new Comparator<Entry<SuperGraphEdge, Long>>() {

            @Override
            public int compare(Entry<SuperGraphEdge, Long> o1, Entry<SuperGraphEdge, Long> o2) {
                return o2.getValue().compareTo(o1.getValue());
            }
        });
        FileWriter fw = new FileWriter(profileFile);
        fw.append("Profile\n");
        fw.append(problemId + "\n");
        fw.append("------------------------------------------------------\n");
        long totalCost = cost.getCost();
        for (Entry<SuperGraphEdge, Long> entry : profile) {
            Long flowCost = entry.getValue();
            double contribution = (100.0 * flowCost) / totalCost;
            fw.append(String.format("  %-50s %8d %.2f%%", entry.getKey(), flowCost, contribution));
            if (cacheCostProfile.containsKey(entry.getKey())) {
                fw.append(String.format(" cache{%d}", cacheCostProfile.get(entry.getKey())));
            }
            fw.append(String.format(" flow{%d}", flowMap.get(entry.getKey())));
            fw.append('\n');
        }
        fw.close();
    } catch (IOException ex) {
        WCETTool.logger.error("Generating profile file failed: " + ex);
    }
    return cost;
}
Also used : EnumSet(java.util.EnumSet) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) FileWriter(java.io.FileWriter) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Entry(java.util.Map.Entry) SuperGraphEdge(com.jopdesign.common.code.SuperGraph.SuperGraphEdge) File(java.io.File)

Example 64 with Entry

use of java.util.Map.Entry in project neo4j by neo4j.

the class ArrayMap method synchronizedRemove.

private synchronized V synchronizedRemove(K key) {
    for (int i = 0; i < arrayCount; i++) {
        if (((ArrayEntry[]) data)[i].getKey().equals(key)) {
            V removedProperty = (V) ((ArrayEntry[]) data)[i].getValue();
            arrayCount--;
            System.arraycopy(data, i + 1, data, i, arrayCount - i);
            ((ArrayEntry[]) data)[arrayCount] = null;
            return removedProperty;
        }
    }
    if (arrayCount == -1) {
        V value = (V) ((Map) data).remove(key);
        if (switchBackToArray && ((Map) data).size() < toMapThreshold) {
            ArrayEntry[] arrayEntries = new ArrayEntry[toMapThreshold];
            int tmpCount = 0;
            for (Object entryObject : ((Map) data).entrySet()) {
                Entry entry = (Entry) entryObject;
                arrayEntries[tmpCount++] = new ArrayEntry(entry.getKey(), entry.getValue());
            }
            data = arrayEntries;
            arrayCount = (byte) tmpCount;
        }
        return value;
    }
    return null;
}
Also used : Entry(java.util.Map.Entry) Map(java.util.Map) HashMap(java.util.HashMap)

Example 65 with Entry

use of java.util.Map.Entry in project jersey by jersey.

the class ParameterizedHeadersMapTest method testEntrySet.

/**
     * Test of entrySet method, of class ParametrizedHeadersMap.
     */
@Test
public void testEntrySet() throws Exception {
    List<ParameterizedHeader> valuesFoo = new ArrayList<>();
    valuesFoo.add(new ParameterizedHeader("foo1"));
    valuesFoo.add(new ParameterizedHeader("foo2"));
    map.put("foo", valuesFoo);
    List<ParameterizedHeader> valuesBar = new ArrayList<>();
    valuesBar.add(new ParameterizedHeader("bar1"));
    valuesBar.add(new ParameterizedHeader("bar2"));
    map.put("bar", valuesBar);
    Set<Entry<String, List<ParameterizedHeader>>> entrySet = map.entrySet();
    assertEquals(2, entrySet.size());
// TODO - detailed tests for the HeadersEntries methods
}
Also used : ParameterizedHeader(org.glassfish.jersey.message.internal.ParameterizedHeader) Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

Entry (java.util.Map.Entry)2862 Map (java.util.Map)804 HashMap (java.util.HashMap)786 ArrayList (java.util.ArrayList)749 List (java.util.List)579 IOException (java.io.IOException)314 Iterator (java.util.Iterator)311 Test (org.junit.Test)308 Set (java.util.Set)294 HashSet (java.util.HashSet)271 LinkedHashMap (java.util.LinkedHashMap)194 Collection (java.util.Collection)186 Collectors (java.util.stream.Collectors)179 File (java.io.File)146 TreeMap (java.util.TreeMap)125 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)114 Key (org.apache.accumulo.core.data.Key)112 Value (org.apache.accumulo.core.data.Value)111 Collections (java.util.Collections)104 LinkedList (java.util.LinkedList)103