Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a46aa26

Browse files
committed
QueryEntity updates
1 parent 6bdea52 commit a46aa26

File tree

2 files changed

+59
-12
lines changed

2 files changed

+59
-12
lines changed

‎core/src/main/java/com/arangodb/entity/QueryEntity.java‎

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,16 @@
2828
*/
2929
public final class QueryEntity {
3030

31-
public static final String PROPERTY_STARTED = "started";
32-
3331
private String id;
32+
private String database;
33+
private String user;
3434
private String query;
35+
private Map<String, Object> bindVars;
3536
private Date started;
3637
private Double runTime;
37-
private Map<String, Object> bindVars;
38+
private LongpeakMemoryUsage;
3839
private QueryExecutionState state;
39-
40-
public QueryEntity() {
41-
super();
42-
}
40+
private Boolean stream;
4341

4442
/**
4543
* @return the query's id
@@ -48,13 +46,34 @@ public String getId() {
4846
return id;
4947
}
5048

49+
/**
50+
* @return the name of the database the query runs in
51+
*/
52+
public String getDatabase() {
53+
return database;
54+
}
55+
56+
/**
57+
* @return the name of the user that started the query
58+
*/
59+
public String getUser() {
60+
return user;
61+
}
62+
5163
/**
5264
* @return the query string (potentially truncated)
5365
*/
5466
public String getQuery() {
5567
return query;
5668
}
5769

70+
/**
71+
* @return the bind parameter values used by the query
72+
*/
73+
public Map<String, Object> getBindVars() {
74+
return bindVars;
75+
}
76+
5877
/**
5978
* @return the date and time when the query was started
6079
*/
@@ -70,10 +89,10 @@ public Double getRunTime() {
7089
}
7190

7291
/**
73-
* @return the bind parameter values used by the query
92+
* @return the query’s peak memory usage in bytes (in increments of 32KB)
7493
*/
75-
public Map<String, Object> getBindVars() {
76-
return bindVars;
94+
public LonggetPeakMemoryUsage() {
95+
return peakMemoryUsage;
7796
}
7897

7998
/**
@@ -83,4 +102,10 @@ public QueryExecutionState getState() {
83102
return state;
84103
}
85104

105+
/**
106+
* @return whether or not the query uses a streaming cursor
107+
*/
108+
public Boolean getStream() {
109+
return stream;
110+
}
86111
}

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

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,8 +1089,18 @@ void getCurrentlyRunningQueries(ArangoDatabase db) throws InterruptedException {
10891089
final Collection<QueryEntity> currentlyRunningQueries = db.getCurrentlyRunningQueries();
10901090
assertThat(currentlyRunningQueries).hasSize(1);
10911091
final QueryEntity queryEntity = currentlyRunningQueries.iterator().next();
1092+
assertThat(queryEntity.getId()).isNotNull();
1093+
assertThat(queryEntity.getDatabase()).isEqualTo(db.name());
1094+
assertThat(queryEntity.getUser()).isEqualTo("root");
10921095
assertThat(queryEntity.getQuery()).isEqualTo(query);
1096+
assertThat(queryEntity.getBindVars()).isEmpty();
1097+
assertThat(queryEntity.getStarted()).isInThePast();
1098+
assertThat(queryEntity.getRunTime()).isPositive();
1099+
if(isAtLeastVersion(3,11)){
1100+
assertThat(queryEntity.getPeakMemoryUsage()).isNotNull();
1101+
}
10931102
assertThat(queryEntity.getState()).isEqualTo(QueryExecutionState.EXECUTING);
1103+
assertThat(queryEntity.getStream()).isFalse();
10941104
t.join();
10951105
}
10961106

@@ -1134,11 +1144,23 @@ void getAndClearSlowQueries(ArangoDatabase db) {
11341144
properties.setSlowQueryThreshold(1L);
11351145
db.setQueryTrackingProperties(properties);
11361146

1137-
db.query("return sleep(1.1)", Void.class);
1147+
String query = "return sleep(1.1)";
1148+
db.query(query, Void.class);
11381149
final Collection<QueryEntity> slowQueries = db.getSlowQueries();
11391150
assertThat(slowQueries).hasSize(1);
11401151
final QueryEntity queryEntity = slowQueries.iterator().next();
1141-
assertThat(queryEntity.getQuery()).isEqualTo("return sleep(1.1)");
1152+
assertThat(queryEntity.getId()).isNotNull();
1153+
assertThat(queryEntity.getDatabase()).isEqualTo(db.name());
1154+
assertThat(queryEntity.getUser()).isEqualTo("root");
1155+
assertThat(queryEntity.getQuery()).isEqualTo(query);
1156+
assertThat(queryEntity.getBindVars()).isEmpty();
1157+
assertThat(queryEntity.getStarted()).isInThePast();
1158+
assertThat(queryEntity.getRunTime()).isPositive();
1159+
if(isAtLeastVersion(3,11)){
1160+
assertThat(queryEntity.getPeakMemoryUsage()).isNotNull();
1161+
}
1162+
assertThat(queryEntity.getState()).isEqualTo(QueryExecutionState.FINISHED);
1163+
assertThat(queryEntity.getStream()).isFalse();
11421164

11431165
db.clearSlowQueries();
11441166
assertThat(db.getSlowQueries()).isEmpty();

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /