use of org.apache.commons.collections.Bag in project ANNIS by korpling.
the class TableAccessStrategy method aliasedTable.
public static String aliasedTable(QueryNode node, Map<String, String> tableAliases, String table, int count) {
if (node != null) {
// throw new IllegalArgumentException("access to node annotation table out of range: " + count);
if (table.equals(EDGE_ANNOTATION_TABLE) && count > node.getEdgeAnnotations().size()) {
throw new IllegalArgumentException("access to edge annotation table out of range: " + count);
}
if (table.equals(NODE_TABLE) && count > 1) {
throw new IllegalArgumentException("access to struct table out of range: " + count);
}
if (table.equals(RANK_TABLE) && count > 1) {
throw new IllegalArgumentException("access to rank table out of range: " + count);
}
// offset table count for edge annotations if node and edge annotations are the same table
if (table.equals(EDGE_ANNOTATION_TABLE) && isMaterialized(tableAliases, EDGE_ANNOTATION_TABLE, NODE_ANNOTATION_TABLE)) {
count = count + node.getNodeAnnotations().size() - 1;
}
}
if (count == 0) {
count = 1;
}
// compute table counts
Bag tables = computeSourceTables(node, tableAliases);
String aliasedName = tableName(tableAliases, table);
String aliasCount = node != null ? String.valueOf(node.getId()) : "";
String countSuffix = tables.getCount(aliasedName) > 1 ? "_" + count : "";
return aliasedName + aliasCount + countSuffix;
}
use of org.apache.commons.collections.Bag 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 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