Skip to content

Commit 118699e

Browse files
author
mpv1989
committed
Add bindVars & state in QueryEntity
* QueryEntity.getBindVars(): Map<String, Object> * QueryEntity.getState(): QueryExecutionState
1 parent 7afc8b3 commit 118699e

File tree

6 files changed

+72
-0
lines changed

6 files changed

+72
-0
lines changed

ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ v4.3.3 (2018-xx-xx)
1111
* added TransactionOptions.maxTransactionSize(Long)
1212
* added TransactionOptions.intermediateCommitCount(Long)
1313
* added TransactionOptions.intermediateCommitSize(Long)
14+
* added QueryEntity.getBindVars(): Map<String, Object>
15+
* added QueryEntity.getState(): QueryExecutionState
1416

1517
v4.3.2 (2017-11-30)
1618
---------------------------

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
package com.arangodb.entity;
2222

2323
import java.util.Date;
24+
import java.util.Map;
2425

2526
/**
2627
* @author Mark Vollmary
@@ -34,6 +35,8 @@ public class QueryEntity {
3435
private String query;
3536
private Date started;
3637
private Double runTime;
38+
private Map<String, Object> bindVars;
39+
private QueryExecutionState state;
3740

3841
public QueryEntity() {
3942
super();
@@ -68,4 +71,18 @@ public Double getRunTime() {
6871
return runTime;
6972
}
7073

74+
/**
75+
* @return the bind parameter values used by the query
76+
*/
77+
public Map<String, Object> getBindVars() {
78+
return bindVars;
79+
}
80+
81+
/**
82+
* @return the query's current execution state
83+
*/
84+
public QueryExecutionState getState() {
85+
return state;
86+
}
87+
7188
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* DISCLAIMER
3+
*
4+
* Copyright 2018 ArangoDB GmbH, Cologne, Germany
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
*/
20+
21+
package com.arangodb.entity;
22+
23+
/**
24+
* @author Mark Vollmary
25+
*
26+
*/
27+
public enum QueryExecutionState {
28+
INITIALIZING,
29+
PARSING,
30+
OPTIMIZING_AST,
31+
LOADING_COLLECTIONS,
32+
INSTANTIATING_PLAN,
33+
OPTIMIZING_PLAN,
34+
EXECUTING,
35+
FINALIZING,
36+
FINISHED,
37+
INVALID
38+
}

src/main/java/com/arangodb/internal/velocypack/VPackDeserializers.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import com.arangodb.entity.CollectionType;
3737
import com.arangodb.entity.LogLevel;
3838
import com.arangodb.entity.Permissions;
39+
import com.arangodb.entity.QueryExecutionState;
3940
import com.arangodb.velocypack.VPackDeserializationContext;
4041
import com.arangodb.velocypack.VPackDeserializer;
4142
import com.arangodb.velocypack.VPackSlice;
@@ -157,4 +158,14 @@ public Permissions deserialize(
157158
return Permissions.valueOf(vpack.getAsString().toUpperCase());
158159
}
159160
};
161+
162+
public static final VPackDeserializer<QueryExecutionState> QUERY_EXECUTION_STATE = new VPackDeserializer<QueryExecutionState>() {
163+
@Override
164+
public QueryExecutionState deserialize(
165+
final VPackSlice parent,
166+
final VPackSlice vpack,
167+
final VPackDeserializationContext context) throws VPackException {
168+
return QueryExecutionState.valueOf(vpack.getAsString().toUpperCase().replaceAll(" ", "_"));
169+
}
170+
};
160171
}

src/main/java/com/arangodb/internal/velocypack/VPackDriverModule.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import com.arangodb.entity.LogLevel;
3333
import com.arangodb.entity.Permissions;
3434
import com.arangodb.entity.QueryEntity;
35+
import com.arangodb.entity.QueryExecutionState;
3536
import com.arangodb.internal.velocystream.internal.AuthenticationRequest;
3637
import com.arangodb.model.TraversalOptions;
3738
import com.arangodb.velocypack.VPackFieldNamingStrategy;
@@ -78,6 +79,7 @@ public String translateName(final Field field) {
7879
context.registerDeserializer(LogLevel.class, VPackDeserializers.LOG_LEVEL);
7980
context.registerDeserializer(ArangoDBVersion.License.class, VPackDeserializers.LICENSE);
8081
context.registerDeserializer(Permissions.class, VPackDeserializers.PERMISSIONS);
82+
context.registerDeserializer(QueryExecutionState.class, VPackDeserializers.QUERY_EXECUTION_STATE);
8183
}
8284

8385
@Override

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
import com.arangodb.entity.QueryCachePropertiesEntity;
6767
import com.arangodb.entity.QueryCachePropertiesEntity.CacheMode;
6868
import com.arangodb.entity.QueryEntity;
69+
import com.arangodb.entity.QueryExecutionState;
6970
import com.arangodb.entity.QueryTrackingPropertiesEntity;
7071
import com.arangodb.entity.ServerRole;
7172
import com.arangodb.entity.TraversalEntity;
@@ -843,6 +844,7 @@ public void run() {
843844
assertThat(currentlyRunningQueries.size(), is(1));
844845
final QueryEntity queryEntity = currentlyRunningQueries.iterator().next();
845846
assertThat(queryEntity.getQuery(), is("return sleep(0.2)"));
847+
assertThat(queryEntity.getState(), is(QueryExecutionState.EXECUTING));
846848
} finally {
847849
t.join();
848850
}

0 commit comments

Comments
 (0)