Skip to content

Commit

Permalink
Merge branch 'master' into mac-m1-jna-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
javeme authored Nov 15, 2022
2 parents 87fd8f5 + b79a690 commit 25c5fd7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ public String get(@Context GraphManager manager,
Directions dir = Directions.convert(EdgeAPI.parseDirection(direction));

HugeGraph g = graph(manager, graph);
PredictionTraverser traverser = new PredictionTraverser(g);
double score = traverser.adamicAdar(sourceId, targetId, dir,
edgeLabel, maxDegree, limit);
return JsonUtil.toJson(ImmutableMap.of("adamic_adar", score));
try (PredictionTraverser traverser = new PredictionTraverser(g)) {
double score = traverser.adamicAdar(sourceId, targetId, dir,
edgeLabel, maxDegree, limit);
return JsonUtil.toJson(ImmutableMap.of("adamic_adar", score));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,11 @@ public String create(@Context GraphManager manager,
Directions dir = Directions.convert(EdgeAPI.parseDirection(direction));

HugeGraph g = graph(manager, graph);
PredictionTraverser traverser = new PredictionTraverser(g);
double score = traverser.resourceAllocation(sourceId, targetId, dir,
edgeLabel, maxDegree,
limit);
return JsonUtil.toJson(ImmutableMap.of("resource_allocation", score));
try (PredictionTraverser traverser = new PredictionTraverser(g)) {
double score = traverser.resourceAllocation(sourceId, targetId, dir,
edgeLabel, maxDegree,
limit);
return JsonUtil.toJson(ImmutableMap.of("resource_allocation", score));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ protected <R> Iterator<R> query(Query query,
} catch (DriverException e) {
LOG.debug("Failed to query [{}], detail statement: {}",
query, selects, e);
// Closing the iterator
try {
rs.close();
} catch (Exception e2) {
LOG.error("Got error {} when closing iterator for query {}", e2, query);
}
throw new BackendException("Failed to query [%s]", e, query);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,12 @@ protected <R> Iterator<R> query(Session session, Query query,
rs.extend(parser.apply(query, results));
}
} catch (SQLException e) {
// Closing the iterator
try {
rs.close();
} catch (Exception e2) {
LOG.error("Got error {} when closing iterator for query {}", e2, query);
}
throw new BackendException("Failed to query [%s]", e, query);
}

Expand Down

0 comments on commit 25c5fd7

Please sign in to comment.