use of org.apache.commons.collections.bag.HashBag in project ANNIS by korpling.
the class TableAccessStrategy method computeSourceTables.
protected static Bag computeSourceTables(QueryNode node, Map<String, String> tableAliases) {
Bag tables = new HashBag();
// hack to support table selections for ANNOTATE query
if (node == null) {
String[] tableNames = { NODE_TABLE, RANK_TABLE, COMPONENT_TABLE, NODE_ANNOTATION_TABLE, EDGE_ANNOTATION_TABLE };
for (String table : tableNames) tables.add(table);
return tables;
}
tables.add(tableName(tableAliases, NODE_ANNOTATION_TABLE), node.getNodeAnnotations().size());
if (node.getNodeAnnotations().isEmpty() && node.getNodeAnnotations().size() > 0)
tables.add(tableName(tableAliases, NODE_ANNOTATION_TABLE));
tables.add(tableName(tableAliases, EDGE_ANNOTATION_TABLE), node.getEdgeAnnotations().size());
if (tables.getCount(tableName(tableAliases, RANK_TABLE)) == 0 && usesRankTable(node))
tables.add(tableName(tableAliases, RANK_TABLE));
if (tables.getCount(tableName(tableAliases, COMPONENT_TABLE)) == 0 && usesRankTable(node))
tables.add(tableName(tableAliases, COMPONENT_TABLE));
if (tables.getCount(tableName(tableAliases, NODE_TABLE)) == 0)
tables.add(tableName(tableAliases, NODE_TABLE));
return tables;
}
use of org.apache.commons.collections.bag.HashBag in project Gargoyle by callakrsos.
the class HashBagTest method test.
@Test
public void test() {
HashBag hashBag = new HashBag();
hashBag.add("zzz");
hashBag.add("zzz");
hashBag.add("zzz");
hashBag.add("zzz1");
System.out.println(hashBag.getCount("zzz"));
hashBag.forEach(System.out::println);
}
use of org.apache.commons.collections.bag.HashBag in project ANNIS by korpling.
the class TestAbstractFromClauseGenerator method setupTableAliases.
// set up table access strategy to return the requested table alias
// simulate that count copies of the table (alias) are required
private Map<String, String> setupTableAliases(QueryNode node, String table, String tableAlias, int count) {
HashMap<String, String> tableAliases = new HashMap<>();
tableAliases.put(table, tableAlias);
if (count > 0) {
tableAliases.put(TableAccessStrategy.NODE_ANNOTATION_TABLE, tableAlias);
}
for (int i = 0; i < count; i++) {
// this will add new entries for the source tables
node.addNodeAnnotation(new QueryAnnotation("dummy", "dummy" + i));
}
tableAccessStrategy.setTableAliases(tableAliases);
tableAccessStrategy.setNode(node);
Bag tables = new HashBag();
tables.add(tableAlias, count);
given(tableAccessStrategy.computeSourceTables()).willReturn(tables);
return tableAliases;
}
use of org.apache.commons.collections.bag.HashBag in project new-cloud by xie-summer.
the class JVMHelper method exportThread.
public static Map<String, String> exportThread(Writer writer) throws IOException {
Map<Thread, StackTraceElement[]> traceList = Thread.getAllStackTraces();
Bag bag = new HashBag();
for (Map.Entry<Thread, StackTraceElement[]> trace : traceList.entrySet()) {
Thread t = trace.getKey();
writer.write("\"" + t.getName() + "\" - " + t.getState() + "\n");
for (StackTraceElement stack : trace.getValue()) {
writer.write("\tat " + stack.toString() + "\n");
}
writer.write("\n");
bag.add(t.getState().name());
}
Map<String, String> result = Maps.newHashMap();
result.put("threadCount", "" + traceList.size());
for (Object key : bag.uniqueSet()) {
result.put((String) key, "" + bag.getCount(key));
}
return result;
}
use of org.apache.commons.collections.bag.HashBag in project new-cloud by xie-summer.
the class JVMHelper method exportMBeanThread.
public static Map<String, String> exportMBeanThread(Writer writer) throws IOException {
ThreadMXBean bean = ManagementFactory.getThreadMXBean();
ThreadInfo[] tiList = bean.getThreadInfo(bean.getAllThreadIds(), true, true);
Bag bag = new HashBag();
for (ThreadInfo ti : tiList) {
appendThreadInfo(writer, ti);
bag.add(ti.getThreadState().name());
}
Map<String, String> result = Maps.newHashMap();
result.put("threadCount", "" + tiList.length);
for (Object key : bag.uniqueSet()) {
result.put((String) key, "" + bag.getCount(key));
}
return result;
}
Aggregations