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);
}
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());
}
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;
}
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;
}
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
}
Aggregations