Skip to content

Commit 9f488e4

Browse files
committed
Add profiling information on each traversal step - count hits vs elastic controller
Add tagging for each step via ASG strategy (all steps must have tags)
1 parent 610c328 commit 9f488e4

File tree

5 files changed

+30
-12
lines changed

5 files changed

+30
-12
lines changed

fuse-asg/src/main/java/com/yangdb/fuse/asg/AsgQueryTransformer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ public AsgQuery transform(AsgQuery query) {
5959
}
6060

6161
AsgStrategyContext asgStrategyContext = new AsgStrategyContext(new Ontology.Accessor(ontology.get()));
62-
Stream.ofAll(this.asgStrategies).forEach(strategy -> strategy.apply(query,asgStrategyContext));
62+
Stream.ofAll(this.asgStrategies)
63+
.forEach(strategy -> strategy.apply(query,asgStrategyContext));
6364

6465
return query;
6566
}

fuse-asg/src/main/java/com/yangdb/fuse/asg/strategy/propertyGrouping/Quant1AllQuantGroupingAsgStrategy.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,13 @@ public void apply(AsgQuery query, AsgStrategyContext context) {
4343
while(hasWorkToDo.get()) {
4444
hasWorkToDo.set(false);
4545

46-
AsgQueryUtil.<Quant1>elements(query, Quant1.class).forEach(quant -> {
46+
AsgQueryUtil.elements(query, Quant1.class).forEach(quant -> {
4747
if (quant.geteBase().getqType().equals(QuantType.all)) {
4848
AsgQueryUtil.<Quant1, Quant1>nextAdjacentDescendants(quant, Quant1.class).forEach(childQuant -> {
4949
if (childQuant.geteBase().getqType().equals(QuantType.all)) {
5050
hasWorkToDo.set(true);
51-
52-
List<AsgEBase<? extends EBase>> nextChildren = childQuant.getNext();
53-
nextChildren.forEach(childQuant::removeNextChild);
54-
nextChildren.forEach(quant::addNextChild);
51+
AsgQueryUtil.replaceParents(quant,childQuant);
52+
AsgQueryUtil.remove(query,childQuant);
5553
}
5654
});
5755
}

fuse-dv/fuse-dv-asg/src/main/java/com/yangdb/fuse/asg/strategy/schema/ExactConstraintTransformationAsgStrategy.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,10 @@
4040
import javaslang.collection.Stream;
4141

4242
import java.util.ArrayList;
43-
import java.util.Collections;
4443
import java.util.Optional;
4544
import java.util.Set;
4645

4746
import static com.yangdb.fuse.unipop.schemaProviders.GraphElementPropertySchema.IndexingSchema.Type.exact;
48-
import static java.util.Collections.unmodifiableList;
4947

5048
/**
5149
* Created by roman.margolis on 08/02/2018.

fuse-model/src/main/java/com/yangdb/fuse/model/asgQuery/AsgEBase.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@
4848
import com.yangdb.fuse.model.Next;
4949
import com.yangdb.fuse.model.query.EBase;
5050

51-
import java.util.*;
51+
import java.util.ArrayList;
52+
import java.util.Arrays;
53+
import java.util.List;
54+
import java.util.Objects;
5255
import java.util.stream.Collectors;
5356

5457
/**
@@ -147,7 +150,7 @@ public AsgEBase<T> clone(int eNum) {
147150

148151
//region Properties
149152
public List<AsgEBase<? extends EBase>> getNext() {
150-
return Collections.unmodifiableList(this.next);
153+
return this.next;
151154
}
152155

153156
public AsgEBase<? extends EBase> addNext(AsgEBase<? extends EBase> node) {
@@ -174,7 +177,7 @@ public void setNext(List<AsgEBase<? extends EBase>> next) {
174177
}
175178

176179
public List<AsgEBase<? extends EBase>> getB() {
177-
return Collections.unmodifiableList(this.b);
180+
return this.b;
178181
}
179182

180183
public T geteBase() {
@@ -196,7 +199,7 @@ public void setParent(List<AsgEBase<? extends EBase>> parent) {
196199
@JsonIgnore
197200
@JsonIgnoreProperties
198201
public List<AsgEBase<? extends EBase>> getParents() {
199-
return Collections.unmodifiableList(this.parent);
202+
return this.parent;
200203
}
201204

202205
public int geteNum() {

fuse-model/src/main/java/com/yangdb/fuse/model/asgQuery/AsgQueryUtil.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,19 @@ public static void replace(AsgEBase source, AsgEBase target) {
822822
target.setNext(next);
823823
}
824824

825+
/**
826+
* replace the targets parent with the new given one
827+
* @param newParent
828+
* @param oldParent
829+
*/
830+
public static void replaceParents(AsgEBase newParent,AsgEBase oldParent) {
831+
//assuming single parent strategy
832+
List<AsgEBase<? extends EBase>> next = new ArrayList<>(oldParent.getNext());
833+
next.forEach(oldParent::removeNextChild);
834+
next.forEach(newParent::addNextChild);
835+
836+
}
837+
825838

826839
public static int count(AsgEBase<? extends EBase> asgEBase, Class<? extends EBase> aClass) {
827840
return elements(asgEBase, classPredicateFunction.apply(aClass)).size();
@@ -1107,12 +1120,17 @@ private static <T> List<T> values(
11071120

11081121
public static <T extends EBase> Optional<AsgEBase<T>> calculateNextAncestor(AsgEBase<? extends EBase> eProp, Class<T> clazz) {
11091122
final List<AsgEBase<? extends EBase>> path = AsgQueryUtil.pathToAncestor(eProp, clazz);
1123+
if(path.isEmpty()) return Optional.empty();
1124+
return Optional.of((AsgEBase<T>) path.get(path.size()-1));
1125+
1126+
/*
11101127
Optional<AsgEBase<T>> element = Optional.empty();
11111128
if(!path.isEmpty() && path.size()==2)
11121129
element = Optional.of((AsgEBase<T>) path.get(1));
11131130
if(!path.isEmpty() && path.size()==3 && QuantBase.class.isAssignableFrom(path.get(1).geteBase().getClass()))
11141131
element = Optional.of((AsgEBase<T>) path.get(2));
11151132
return element;
1133+
*/
11161134
}
11171135

11181136
public static List<AsgEBase<? extends EBase>> path(

0 commit comments

Comments
 (0)