Skip to content

Commit 2897e2c

Browse files
authored
added option usePlanCache to AqlQueryOptions (#609)
1 parent 2e595b0 commit 2897e2c

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

core/src/main/java/com/arangodb/model/AqlQueryOptions.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ public static final class Options implements Cloneable {
236236
private Long spillOverThresholdMemoryUsage;
237237
private Long spillOverThresholdNumRows;
238238
private Boolean stream;
239+
private Boolean usePlanCache;
239240

240241
@JsonInclude
241242
@JsonAnyGetter
@@ -354,6 +355,10 @@ public Boolean getStream() {
354355
return stream;
355356
}
356357

358+
public Boolean getUsePlanCache() {
359+
return usePlanCache;
360+
}
361+
357362
public void setAllPlans(Boolean allPlans) {
358363
this.allPlans = allPlans;
359364
}
@@ -446,6 +451,10 @@ public void setStream(Boolean stream) {
446451
this.stream = stream;
447452
}
448453

454+
public void setUsePlanCache(Boolean usePlanCache) {
455+
this.usePlanCache = usePlanCache;
456+
}
457+
449458
@Override
450459
public Options clone() {
451460
try {
@@ -961,6 +970,11 @@ public Boolean getStream() {
961970
return getOptions().getStream();
962971
}
963972

973+
@JsonIgnore
974+
public Boolean getUsePlanCache() {
975+
return getOptions().getUsePlanCache();
976+
}
977+
964978
/**
965979
* @param stream Specify true and the query will be executed in a streaming fashion. The query result is not
966980
* stored on
@@ -983,6 +997,20 @@ public AqlQueryOptions stream(final Boolean stream) {
983997
return this;
984998
}
985999

1000+
/**
1001+
* @param usePlanCache Set this option to true to utilize a cached query plan or add the execution plan of this
1002+
* query to the cache if it’s not in the cache yet. Otherwise, the plan cache is bypassed
1003+
* (introduced in v3.12.4).
1004+
* Query plan caching can reduce the total time for processing queries by avoiding to parse,
1005+
* plan, and optimize queries over and over again that effectively have the same execution plan
1006+
* with at most some changes to bind parameter values.
1007+
* @return this
1008+
*/
1009+
public AqlQueryOptions usePlanCache(final Boolean usePlanCache) {
1010+
getOptions().setUsePlanCache(usePlanCache);
1011+
return this;
1012+
}
1013+
9861014
@JsonIgnore
9871015
public Collection<String> getRules() {
9881016
return getOptions().getOptimizer().getRules();

core/src/main/java/com/arangodb/model/ExplainAqlQueryOptions.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,11 @@ public Boolean getStream() {
554554
return getOptions().getStream();
555555
}
556556

557+
@JsonIgnore
558+
public Boolean getUsePlanCache() {
559+
return getOptions().getUsePlanCache();
560+
}
561+
557562
/**
558563
* @param stream Specify true and the query will be executed in a streaming fashion. The query result is not
559564
* stored on
@@ -576,6 +581,20 @@ public ExplainAqlQueryOptions stream(final Boolean stream) {
576581
return this;
577582
}
578583

584+
/**
585+
* @param usePlanCache Set this option to true to utilize a cached query plan or add the execution plan of this
586+
* query to the cache if it’s not in the cache yet. Otherwise, the plan cache is bypassed
587+
* (introduced in v3.12.4).
588+
* Query plan caching can reduce the total time for processing queries by avoiding to parse,
589+
* plan, and optimize queries over and over again that effectively have the same execution plan
590+
* with at most some changes to bind parameter values.
591+
* @return this
592+
*/
593+
public ExplainAqlQueryOptions usePlanCache(final Boolean usePlanCache) {
594+
getOptions().setUsePlanCache(usePlanCache);
595+
return this;
596+
}
597+
579598
@JsonIgnore
580599
public Collection<String> getRules() {
581600
return getOptions().getOptimizer().getRules();

test-functional/src/test/java/com/arangodb/model/AqlQueryOptionsTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ void cloneable() {
1515
AqlQueryOptions options = new AqlQueryOptions()
1616
.cache(true)
1717
.stream(true)
18+
.usePlanCache(true)
1819
.rules(rules)
1920
.shardIds("a", "b");
2021
AqlQueryOptions clone = options.clone();
2122
assertThat(clone.getCache()).isEqualTo(options.getCache());
2223
assertThat(clone.getStream()).isEqualTo(options.getStream());
24+
assertThat(clone.getUsePlanCache()).isEqualTo(options.getUsePlanCache());
2325
assertThat(clone.getRules())
2426
.isEqualTo(options.getRules())
2527
.isNotSameAs(options.getRules());

0 commit comments

Comments
 (0)