8000 Add parameters in AqlQueryOptions · Sunghyeok93/arangodb-java-driver@c549653 · GitHub
[go: up one dir, main page]

Skip to content

Commit c549653

Browse files
author
mpv1989
committed
Add parameters in AqlQueryOptions
* AqlQueryOptions.failOnWarning(Boolean) * AqlQueryOptions.maxTransactionSize(Long) * AqlQueryOptions.maxWarningCount(Long) * AqlQueryOptions.intermediateCommitCount(Long) * AqlQueryOptions.intermediateCommitSize(Long) * AqlQueryOptions.satelliteSyncWait(Double)
1 parent 1498c25 commit c549653

File tree

3 files changed

+128
-1
lines changed

3 files changed

+128
-1
lines changed

ChangeLog

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
v4.3.3 (2018-xx-xx)
22
---------------------------
3-
* added AqlQueryOptions.memoryLimit(Long)
43
* fixed inconsistency of getDocument() variants (Issue #168)
4+
* added AqlQueryOptions.memoryLimit(Long)
5+
* added AqlQueryOptions.failOnWarning(Boolean)
6+
* added AqlQueryOptions.maxTransactionSize(Long)
7+
* added AqlQueryOptions.maxWarningCount(Long)
8+
* added AqlQueryOptions.intermediateCommitCount(Long)
9+
* added AqlQueryOptions.intermediateCommitSize(Long)
10+
* added AqlQueryOptions.satelliteSyncWait(Double)
511

612
v4.3.2 (2017-11-30)
713
---------------------------

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

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,24 @@ protected AqlQueryOptions query(final String query) {
153153
return this;
154154
}
155155

156+
public Boolean getFailOnWarning() {
157+
return options != null ? options.failOnWarning : null;
158+
}
159+
160+
/**
161+
* @param failOnWarning
162+
* When set to true, the query will throw an exception and abort instead of producing a warning. This
163+
* option should be used during development to catch potential issues early. When the attribute is set to
164+
* false, warnings will not be propagated to exceptions and will be returned with the query result. There
165+
* is also a server configuration option --query.fail-on-warning for setting the default value for
166+
* failOnWarning so it does not need to be set on a per-query level.
167+
* @return options
168+
*/
169+
public AqlQueryOptions failOnWarning(final Boolean failOnWarning) {
170+
getOptions().failOnWarning = failOnWarning;
171+
return this;
172+
}
173+
156174
/**
157175
* @return If set to true, then the additional query profiling information will be returned in the sub-attribute
158176
* profile of the extra return attribute if the query result is not served from the query cache.
@@ -172,6 +190,81 @@ public AqlQueryOptions profile(final Boolean profile) {
172190
return this;
173191
}
174192

193+
public Long getMaxTransactionSize() {
194+
return options != null ? options.maxTransactionSize : null;
195+
}
196+
197+
/**
198+
* @param maxTransactionSize
199+
* Transaction size limit in bytes. Honored by the RocksDB storage engine only.
200+
* @return options
201+
*/
202+
public AqlQueryOptions maxTransactionSize(final Long maxTransactionSize) {
203+
getOptions().maxTransactionSize = maxTransactionSize;
204+
return this;
205+
}
206+
207+
public Long getMaxWarningCount() {
208+
return options != null ? options.maxWarningCount : null;
209+
}
210+
211+
/**
212+
* @param maxWarningCount
213+
* Limits the maximum number of warnings a query will return. The number of warnings a query will return
214+
* is limited to 10 by default, but that number can be increased or decreased by setting this attribute.
215+
* @return options
216+
*/
217+
public AqlQueryOptions maxWarningCount(final Long maxWarningCount) {
218+
getOptions().maxWarningCount = maxWarningCount;
219+
return this;
220+
}
221+
222+
public Long getIntermediateCommitCount() {
223+
return options != null ? options.intermediateCommitCount : null;
224+
}
225+
226+
/**
227+
* @param intermediateCommitCount
228+
* Maximum number of operations after which an intermediate commit is performed automatically. Honored by
229+
* the RocksDB storage engine only.
230+
* @return options
231+
*/
232+
public AqlQueryOptions intermediateCommitCount(final Long intermediateCommitCount) {
233+
getOptions().intermediateCommitCount = intermediateCommitCount;
234+
return this;
235+
}
236+
237+
public Long getIntermediateCommitSize() {
238+
return options != null ? options.intermediateCommitSize : null;
239+
}
240+
241+
/**
242+
* @param intermediateCommitSize
243+
* Maximum total size of operations after which an intermediate commit is performed automatically.
244+
* Honored by the RocksDB storage engine only.
245+
* @return options
246+
*/
247+
public AqlQueryOptions intermediateCommitSize(final Long intermediateCommitSize) {
248+
getOptions().intermediateCommitSize = intermediateCommitSize;
249+
return this;
250+
}
251+
252+
public Double getSatelliteSyncWait() {
253+
return options != null ? options.satelliteSyncWait : null;
254+
}
255+
256+
/**
257+
* @param satelliteSyncWait
258+
* This enterprise parameter allows to configure how long a DBServer will have time to bring the
259+
* satellite collections involved in the query into sync. The default value is 60.0 (seconds). When the
260+
* max time has been reached the query will be stopped.
261+
* @return options
262+
*/
263+
public AqlQueryOptions satelliteSyncWait(final Double satelliteSyncWait) {
264+
getOptions().satelliteSyncWait = satelliteSyncWait;
265+
return this;
266+
}
267+
175268
public Boolean getFullCount() {
176269
return options != null ? options.fullCount : null;
177270
}
@@ -234,7 +327,13 @@ private Options getOptions() {
234327
}
235328

236329
private static class Options {
330+
private Boolean failOnWarning;
237331
private Boolean profile;
332+
private Long maxTransactionSize;
333+
private Long maxWarningCount;
334+
private Long intermediateCommitCount;
335+
private Long intermediateCommitSize;
336+
private Double satelliteSyncWait;
238337
private Optimizer optimizer;
239338
private Boolean fullCount;
240339
private Integer maxPlans;

src/test/java/com/arangodb/ArangoDatabaseTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,28 @@ public void queryWithMemoryLimit() {
642642
}
643643
}
644644

645+
@Test(expected = ArangoDBException.class)
646+
public void queryWithFailOnWarningTrue() {
647+
db.query("RETURN 1 / 0", null, new AqlQueryOptions().failOnWarning(true), String.class);
648+
}
649+
650+
@Test
651+
public void queryWithFailOnWarningFalse() {
652+
final ArangoCursor<String> cursor = db.query("RETURN 1 / 0", null, new AqlQueryOptions().failOnWarning(false),
653+
String.class);
654+
assertThat(cursor.next(), is("null"));
655+
}
656+
657+
@Test
658+
public void queryWithMaxWarningCount() {
659+
final ArangoCursor<String> cursorWithWarnings = db.query("RETURN 1 / 0", null, new AqlQueryOptions(),
660+
String.class);
661+
assertThat(cursorWithWarnings.getWarnings().size(), is(1));
662+
final ArangoCursor<String> cursorWithLimitedWarnings = db.query("RETURN 1 / 0", null,
663+
new AqlQueryOptions().maxWarningCount(0L), String.class);
664+
assertThat(cursorWithLimitedWarnings.getWarnings().size(), is(0));
665+
}
666+
645667
@Test
646668
public void queryCursor() {
647669
try {

0 commit comments

Comments
 (0)
0