Skip to content

Commit 44650c9

Browse files
committed
update
1 parent d877b5c commit 44650c9

File tree

5 files changed

+52
-12
lines changed

5 files changed

+52
-12
lines changed

src/main/java/tabby/algo/PathFinding.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ depthFirst, new CommonJudgment()
8080
}
8181

8282
@Procedure
83-
@Description("tabby.algo.findJavaGadget(source, sinks, maxNodes, depthFirst) YIELD path, " +
84-
"weight - run findJavaGadget with maxNodes from source to sink")
83+
@Description("tabby.algo.findJavaGadget(source, sinks, maxNodes, depthFirst) YIELD path, weight" +
84+
" - run findJavaGadget with maxNodes from source to sinks")
8585
public Stream<PathResult> findJavaGadget(
8686
@Name("startNode") Node startNode,
8787
@Name("endNodes") List<Node> endNodes,

src/main/java/tabby/evaluator/judgment/CommonJudgment.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,21 @@ public Evaluation judge(Path path, State state, List<Node> endNodes, int maxDept
2929
}
3030
}else if(endNodes != null && endNodes.contains(node)){
3131
// 长度没到,但已经找到了endNode,停止进行
32+
// Relationship relationship = path.lastRelationship();
33+
// int[] position = state.getPositions(relationship.getId() + "");
34+
// String pollutedStr = (String) node.getProperty("POLLUTED_POSITION", "[]");
35+
// int[] polluted = JsonHelper.gson.fromJson(pollutedStr, int[].class);
36+
// if(polluted != null && polluted.length > 0){
37+
// Set<Integer> set = Transformer.intArrayToSet(position);
38+
// boolean flag = true;
39+
// for(int p:polluted){
40+
// if(!set.contains(p)){
41+
// flag = false;
42+
// break;
43+
// }
44+
// }
45+
// includes = flag;
46+
// }
3247
continues = false;
3348
} else {
3449
includes = false;

src/main/java/tabby/expander/ForwardedPathExpander.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ public ForwardedPathExpander(boolean parallel, Processor processor) {
3131
this.processor = processor;
3232
String[] types = new String[]{"CALL>", "ALIAS>"};
3333
direction = Types.directionFor(types[0]);
34-
relationshipTypes
35-
= new RelationshipType[]{
34+
relationshipTypes = new RelationshipType[]{
3635
Types.relationshipTypeFor(types[0]),
3736
Types.relationshipTypeFor(types[1])
3837
};

src/main/java/tabby/help/Help.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import tabby.result.HelpResult;
99

1010
import java.util.HashSet;
11+
import java.util.Map;
1112
import java.util.Set;
1213
import java.util.stream.Stream;
1314

@@ -38,13 +39,18 @@ public Stream<HelpResult> info(@Name("proc") String name) throws Exception {
3839
}
3940
String filter = " WHERE name starts with 'tabby.' " +
4041
" AND ($name IS NULL OR toLower(name) CONTAINS toLower($name) " +
41-
" OR ($desc IS NOT NULL AND toLower(description) CONTAINS toLower($desc))) " +
42-
"RETURN type, name, description, signature ";
43-
44-
String query = "WITH 'procedure' as type CALL dbms.procedures() yield name, description, signature " + filter +
45-
" UNION ALL " +
46-
"WITH 'function' as type CALL dbms.functions() yield name, description, signature " + filter;
47-
return tx.execute(query, map("name", name, "desc", searchText ? name : null))
48-
.stream().map(row -> new HelpResult(row, !extended.contains((String) row.get("name"))));
42+
" OR ($desc IS NOT NULL AND toLower(description) CONTAINS toLower($desc))) ";
43+
44+
String proceduresQuery = "SHOW PROCEDURES yield name, description, signature " + filter +
45+
"RETURN 'procedure' as type, name, description, signature ";
46+
47+
String functionsQuery = "SHOW FUNCTIONS yield name, description, signature " + filter +
48+
"RETURN 'function' as type, name, description, signature ";
49+
Map<String,Object> params = map( "name", name, "desc", searchText ? name : null );
50+
Stream<Map<String,Object>> proceduresResults = tx.execute( proceduresQuery, params ).stream();
51+
Stream<Map<String,Object>> functionsResults = tx.execute( functionsQuery, params ).stream();
52+
53+
return Stream.of( proceduresResults, functionsResults ).flatMap( results -> results.map(
54+
row -> new HelpResult( row, !extended.contains( (String) row.get( "name" ) ) ) ) );
4955
}
5056
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package tabby.util;
2+
3+
import java.util.Arrays;
4+
import java.util.Set;
5+
import java.util.stream.Collectors;
6+
7+
/**
8+
* @author wh1t3p1g
9+
* @since 2022/6/2
10+
*/
11+
public class Transformer {
12+
13+
public static int[] setToIntArray(Set<Integer> set){
14+
return set.stream().mapToInt(Integer::intValue).toArray();
15+
}
16+
17+
public static Set<Integer> intArrayToSet(int[] array){
18+
return Arrays.stream(array).boxed().collect(Collectors.toSet());
19+
}
20+
}

0 commit comments

Comments
 (0)