scala.collection.mutable.HashMap Java Examples
The following examples show how to use
scala.collection.mutable.HashMap.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GraphProcessorTest.java From neo4j-mazerunner with Apache License 2.0 | 5 votes |
@Test public void testVertexPath() throws Exception { DecisionTree<Long> tree = new DecisionTree<>(0L, new HashMap<>()); tree.traverseTo(0L).addLeaf(1L); tree.traverseTo(0L).addLeaf(2L).addLeaf(3L).addLeaf(4L).addLeaf(5L); tree.traverseTo(4L).addLeaf(6L); tree.traverseTo(4L).addLeaf(7L).addLeaf(8L); tree.traverseTo(7L).addLeaf(9L); System.out.println(tree.renderGraph()); System.out.println(tree.shortestPathTo(9L)); }
Example #2
Source File: SparkInterpreter.java From Explorer with Apache License 2.0 | 5 votes |
private int[] getProgressFromStage_1_1x(JobProgressListener sparkListener, Stage stage) { int numTasks = stage.numTasks(); int completedTasks = 0; try { Method stageIdToData = sparkListener.getClass().getMethod("stageIdToData"); HashMap<Tuple2<Object, Object>, Object> stageIdData = (HashMap<Tuple2<Object, Object>, Object>) stageIdToData .invoke(sparkListener); Class<?> stageUIDataClass = this.getClass().forName("org.apache.spark.ui.jobs.UIData$StageUIData"); Method numCompletedTasks = stageUIDataClass.getMethod("numCompleteTasks"); Set<Tuple2<Object, Object>> keys = JavaConverters.asJavaSetConverter(stageIdData.keySet()).asJava(); for (Tuple2<Object, Object> k : keys) { if (stage.id() == (int) k._1()) { Object uiData = stageIdData.get(k).get(); completedTasks += (int) numCompletedTasks.invoke(uiData); } } } catch (Exception e) { logger.error("Error on getting progress information", e); } List<Stage> parents = JavaConversions.asJavaList(stage.parents()); if (parents != null) { for (Stage s : parents) { int[] p = getProgressFromStage_1_1x(sparkListener, s); numTasks += p[0]; completedTasks += p[1]; } } return new int[] { numTasks, completedTasks }; }
Example #3
Source File: SparkSqlInterpreter.java From Explorer with Apache License 2.0 | 5 votes |
private int[] getProgressFromStage_1_1x(JobProgressListener sparkListener, Stage stage) { int numTasks = stage.numTasks(); int completedTasks = 0; try { Method stageIdToData = sparkListener.getClass().getMethod("stageIdToData"); HashMap<Tuple2<Object, Object>, Object> stageIdData = (HashMap<Tuple2<Object, Object>, Object>) stageIdToData .invoke(sparkListener); Class<?> stageUIDataClass = this.getClass().forName("org.apache.spark.ui.jobs.UIData$StageUIData"); Method numCompletedTasks = stageUIDataClass.getMethod("numCompleteTasks"); Set<Tuple2<Object, Object>> keys = JavaConverters.asJavaSetConverter(stageIdData.keySet()).asJava(); for (Tuple2<Object, Object> k : keys) { if (stage.id() == (int) k._1()) { Object uiData = stageIdData.get(k).get(); completedTasks += (int) numCompletedTasks.invoke(uiData); } } } catch (Exception e) { logger.error("Error on getting progress information", e); } List<Stage> parents = JavaConversions.asJavaList(stage.parents()); if (parents != null) { for (Stage s : parents) { int[] p = getProgressFromStage_1_1x(sparkListener, s); numTasks += p[0]; completedTasks += p[1]; } } return new int[] { numTasks, completedTasks }; }
Example #4
Source File: DecisionTreeTest.java From graphify with Apache License 2.0 | 4 votes |
@Test public void testPatternMatchTraversal() throws Exception { // Invalidate all caches NodeManager.globalNodeCache.invalidateAll(); DataNodeManager.dataCache.invalidateAll(); ClassNodeManager.classCache.invalidateAll(); GraphManager.edgeCache.invalidateAll(); GraphManager.inversePatternCache.invalidateAll(); GraphManager.patternCache.invalidateAll(); DataRelationshipManager.relationshipCache.invalidateAll(); ClassRelationshipCache.relationshipCache.invalidateAll(); PatternRelationshipCache.relationshipCache.invalidateAll(); GraphManager graphManager = new GraphManager("Pattern"); GraphDatabaseService db = setUpDb(); DecisionTree<Long> tree = new DecisionTree<>(0L, new HashMap<>(), db, graphManager); // Creates a hierarchical graph of branch factor 2 with depth 5 createHierarchy(db, graphManager, null, 2, 5, 0, "[0-9]"); //System.out.println(tree.traverseTo(1L).renderGraph()); nodeManager.setNodeProperty(0L, "pattern", String.join(" ", Arrays.asList("The first person to go to space was smart".split(" ")) .subList(0, 1)), db); nodeManager.setNodeProperty(1L, "pattern", String.join(" ", Arrays.asList("The first person to go to space was smart".split(" ")) .subList(0, 2)), db); nodeManager.setNodeProperty(2L, "pattern", String.join(" ", Arrays.asList("The first person to go to space was smart".split(" ")) .subList(0, 3)), db); nodeManager.setNodeProperty(3L, "pattern", String.join(" ", Arrays.asList("The first person to go to space was smart".split(" ")) .subList(0, 4)), db); nodeManager.setNodeProperty(7L, "pattern", String.join(" ", Arrays.asList("The first person to go to space was smart".split(" ")) .subList(0, 5)), db); nodeManager.setNodeProperty(9L, "pattern", String.join(" ", Arrays.asList("The first person to go to space was smart".split(" ")) .subList(0, 6)), db); graphManager.updateCache(0L, db); graphManager.updateCache(1L, db); graphManager.updateCache(2L, db); graphManager.updateCache(3L, db); graphManager.updateCache(7L, db); graphManager.updateCache(9L, db); // Traverse by pattern System.out.println(tree.traverseByPattern("The first person to go to space was smart")); System.out.println(tree.renderGraph()); }