Skip to content

Commit e497171

Browse files
author
mpv1989
committed
Add AqlQueryOptions.memoryLimit(Long)
1 parent 8792057 commit e497171

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
v4.3.3 (2018-xx-xx)
2+
---------------------------
3+
* added AqlQueryOptions.memoryLimit(Long)
4+
15
v4.3.2 (2017-11-30)
26
---------------------------
37
* fixed redirect header (uppercase)

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class AqlQueryOptions {
3535
private Integer ttl;
3636
private Integer batchSize;
3737
private Boolean cache;
38+
private Long memoryLimit;
3839
private Map<String, Object> bindVars;
3940
private String query;
4041
private Options options;
@@ -92,6 +93,22 @@ public AqlQueryOptions batchSize(final Integer batchSize) {
9293
return this;
9394
}
9495

96+
public Long getMemoryLimit() {
97+
return memoryLimit;
98+
}
99+
100+
/**
101+
* @param memoryLimit
102+
* the maximum number of memory (measured in bytes) that the query is allowed to use. If set, then the
103+
* query will fail with error "resource limit exceeded" in case it allocates too much memory. A value of
104+
* 0 indicates that there is no memory limit.
105+
* @return options
106+
*/
107+
public AqlQueryOptions memoryLimit(final Long memoryLimit) {
108+
this.memoryLimit = memoryLimit;
109+
return this;
110+
}
111+
95112
public Boolean getCache() {
96113
return cache;
97114
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,16 @@ public void queryWithCache() throws InterruptedException {
632632
}
633633
}
634634

635+
@Test
636+
public void queryWithMemoryLimit() {
637+
try {
638+
db.query("RETURN 'bla'", null, new AqlQueryOptions().memoryLimit(1L), String.class);
639+
fail();
640+
} catch (final ArangoDBException e) {
641+
assertThat(e.getErrorNum(), is(32));
642+
}
643+
}
644+
635645
@Test
636646
public void queryCursor() {
637647
try {

0 commit comments

Comments
 (0)