Skip to content

Commit e0c45e9

Browse files
committed
[DE-372] enhanced cursor stats
1 parent b86f1c5 commit e0c45e9

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

src/main/java/com/arangodb/entity/CursorEntity.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ public static class Stats {
143143
private Long fullCount;
144144
private Double executionTime;
145145
private Long peakMemoryUsage;
146+
private Long cursorsCreated;
147+
private Long cursorsRearmed;
148+
private Long cacheHits;
149+
private Long cacheMisses;
146150

147151
public Long getWritesExecuted() {
148152
return writesExecuted;
@@ -175,5 +179,33 @@ public Double getExecutionTime() {
175179
public Long getPeakMemoryUsage() {
176180
return peakMemoryUsage;
177181
}
182+
183+
/**
184+
* @since ArangoDB 3.10
185+
*/
186+
public Long getCursorsCreated() {
187+
return cursorsCreated;
188+
}
189+
190+
/**
191+
* @since ArangoDB 3.10
192+
*/
193+
public Long getCursorsRearmed() {
194+
return cursorsRearmed;
195+
}
196+
197+
/**
198+
* @since ArangoDB 3.10
199+
*/
200+
public Long getCacheHits() {
201+
return cacheHits;
202+
}
203+
204+
/**
205+
* @since ArangoDB 3.10
206+
*/
207+
public Long getCacheMisses() {
208+
return cacheMisses;
209+
}
178210
}
179211
}

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,34 @@ void queryWithLimitAndFullCount(ArangoDatabase db) {
627627
assertThat(cursor.getStats().getFullCount()).isGreaterThanOrEqualTo(10L);
628628
}
629629

630+
@ParameterizedTest(name = "{index}")
631+
@MethodSource("dbs")
632+
void queryStats(ArangoDatabase db) {
633+
for (int i = 0; i < 10; i++) {
634+
db.collection(CNAME1).insertDocument(new BaseDocument(), null);
635+
}
636+
637+
final ArangoCursor<Object> cursor = db.query("for i in " + CNAME1 + " return i", Object.class);
638+
assertThat((Object) cursor).isNotNull();
639+
for (int i = 0; i < 5; i++, cursor.next()) {
640+
assertThat((Iterator<?>) cursor).hasNext();
641+
}
642+
assertThat(cursor.getStats()).isNotNull();
643+
assertThat(cursor.getStats().getWritesExecuted()).isNotNull();
644+
assertThat(cursor.getStats().getWritesIgnored()).isNotNull();
645+
assertThat(cursor.getStats().getScannedFull()).isNotNull();
646+
assertThat(cursor.getStats().getScannedIndex()).isNotNull();
647+
assertThat(cursor.getStats().getFiltered()).isNotNull();
648+
assertThat(cursor.getStats().getExecutionTime()).isNotNull();
649+
assertThat(cursor.getStats().getPeakMemoryUsage()).isNotNull();
650+
if (isAtLeastVersion(3, 10)) {
651+
assertThat(cursor.getStats().getCursorsCreated()).isNotNull();
652+
assertThat(cursor.getStats().getCursorsRearmed()).isNotNull();
653+
assertThat(cursor.getStats().getCacheHits()).isNotNull();
654+
assertThat(cursor.getStats().getCacheMisses()).isNotNull();
655+
}
656+
}
657+
630658
@ParameterizedTest(name = "{index}")
631659
@MethodSource("dbs")
632660
void queryWithBatchSize(ArangoDatabase db) {

0 commit comments

Comments
 (0)