diff --git a/docs/configs/janusgraph-cfg.md b/docs/configs/janusgraph-cfg.md
index 7de7f51790..44e0dfa3b0 100644
--- a/docs/configs/janusgraph-cfg.md
+++ b/docs/configs/janusgraph-cfg.md
@@ -363,13 +363,13 @@ Configuration options to configure batch queries optimization behavior
| ---- | ---- | ---- | ---- | ---- |
| query.batch.enabled | Whether traversal queries should be batched when executed against the storage backend. This can lead to significant performance improvement if there is a non-trivial latency to the backend. If `false` then all other configuration options under `query.batch` namespace are ignored. | Boolean | true | MASKABLE |
| query.batch.has-step-mode | Properties pre-fetching mode for `has` step. Used only when query.batch.enabled is `true`.
Supported modes:
- `all_properties` Pre-fetch all vertex properties on any property access
- `required_properties_only` Pre-fetch necessary vertex properties for the whole chain of foldable `has` steps
- `required_and_next_properties` Prefetch the same properties as with `required_properties_only` mode, but also prefetch
-properties which may be needed in the next properties access step like `values`, `properties,` `valueMap`, or `elementMap`.
+properties which may be needed in the next properties access step like `values`, `properties,` `valueMap`, `elementMap`, or `propertyMap`.
In case the next step is not one of those properties access steps then this mode behaves same as `required_properties_only`.
In case the next step is one of the properties access steps with limited scope of properties, those properties will be
pre-fetched together in the same multi-query.
In case the next step is one of the properties access steps with unspecified scope of property keys then this mode
-behaves same as `all_properties`.
- `required_and_next_properties_or_all` Prefetch the same properties as with `required_properties_only`, but in case the next step is not
-`values`, `properties,` `valueMap`, or `elementMap` then acts like `all_properties`.
- `none` Skips `has` step batch properties pre-fetch optimization.
| String | required_and_next_properties | MASKABLE |
+behaves same as `all_properties`.
- `required_and_next_properties_or_all` Prefetch the same properties as with `required_and_next_properties`, but in case the next step is not
+`values`, `properties,` `valueMap`, `elementMap`, or `propertyMap` then acts like `all_properties`.
- `none` Skips `has` step batch properties pre-fetch optimization.
| String | required_and_next_properties | MASKABLE |
| query.batch.limited | Configure a maximum batch size for queries against the storage backend. This can be used to ensure responsiveness if batches tend to grow very large. The used batch size is equivalent to the barrier size of a preceding `barrier()` step. If a step has no preceding `barrier()`, the default barrier of TinkerPop will be inserted. This option only takes effect if `query.batch.enabled` is `true`. | Boolean | true | MASKABLE |
| query.batch.limited-size | Default batch size (barrier() step size) for queries. This size is applied only for cases where `LazyBarrierStrategy` strategy didn't apply `barrier` step and where user didn't apply barrier step either. This option is used only when `query.batch.limited` is `true`. Notice, value `2147483647` is considered to be unlimited. | Integer | 2500 | MASKABLE |
| query.batch.repeat-step-mode | Batch mode for `repeat` step. Used only when query.batch.enabled is `true`.
These modes are controlling how the child steps with batch support are behaving if they placed to the start of the `repeat`, `emit`, or `until` traversals.
Supported modes:
- `closest_repeat_parent` Child start steps are receiving vertices for batching from the closest `repeat` step parent only.
- `all_repeat_parents` Child start steps are receiving vertices for batching from all `repeat` step parents.
- `starts_only_of_all_repeat_parents` Child start steps are receiving vertices for batching from the closest `repeat` step parent (both for the parent start and for next iterations) and also from all `repeat` step parents for the parent start. | String | all_repeat_parents | MASKABLE |
diff --git a/janusgraph-core/src/main/java/org/janusgraph/graphdb/configuration/GraphDatabaseConfiguration.java b/janusgraph-core/src/main/java/org/janusgraph/graphdb/configuration/GraphDatabaseConfiguration.java
index 2f9276e094..b10f609281 100644
--- a/janusgraph-core/src/main/java/org/janusgraph/graphdb/configuration/GraphDatabaseConfiguration.java
+++ b/janusgraph-core/src/main/java/org/janusgraph/graphdb/configuration/GraphDatabaseConfiguration.java
@@ -334,14 +334,14 @@ public class GraphDatabaseConfiguration {
"- `%s` Pre-fetch all vertex properties on any property access
" +
"- `%s` Pre-fetch necessary vertex properties for the whole chain of foldable `has` steps
" +
"- `%s` Prefetch the same properties as with `%s` mode, but also prefetch\n" +
- "properties which may be needed in the next properties access step like `values`, `properties,` `valueMap`, or `elementMap`.\n" +
+ "properties which may be needed in the next properties access step like `values`, `properties,` `valueMap`, `elementMap`, or `propertyMap`.\n" +
"In case the next step is not one of those properties access steps then this mode behaves same as `%s`.\n" +
"In case the next step is one of the properties access steps with limited scope of properties, those properties will be\n" +
"pre-fetched together in the same multi-query.\n" +
"In case the next step is one of the properties access steps with unspecified scope of property keys then this mode\n" +
"behaves same as `%s`.
"+
"- `%s` Prefetch the same properties as with `%s`, but in case the next step is not\n" +
- "`values`, `properties,` `valueMap`, or `elementMap` then acts like `%s`.
"+
+ "`values`, `properties,` `valueMap`, `elementMap`, or `propertyMap` then acts like `%s`.
"+
"- `%s` Skips `has` step batch properties pre-fetch optimization.
",
MultiQueryHasStepStrategyMode.ALL_PROPERTIES.getConfigName(),
MultiQueryHasStepStrategyMode.REQUIRED_PROPERTIES_ONLY.getConfigName(),
@@ -350,7 +350,7 @@ public class GraphDatabaseConfiguration {
MultiQueryHasStepStrategyMode.REQUIRED_PROPERTIES_ONLY.getConfigName(),
MultiQueryHasStepStrategyMode.ALL_PROPERTIES.getConfigName(),
MultiQueryHasStepStrategyMode.REQUIRED_AND_NEXT_PROPERTIES_OR_ALL.getConfigName(),
- MultiQueryHasStepStrategyMode.REQUIRED_PROPERTIES_ONLY.getConfigName(),
+ MultiQueryHasStepStrategyMode.REQUIRED_AND_NEXT_PROPERTIES.getConfigName(),
MultiQueryHasStepStrategyMode.ALL_PROPERTIES.getConfigName(),
MultiQueryHasStepStrategyMode.NONE.getConfigName()),
ConfigOption.Type.MASKABLE, MultiQueryHasStepStrategyMode.REQUIRED_AND_NEXT_PROPERTIES.getConfigName());
diff --git a/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/optimize/step/JanusGraphHasStep.java b/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/optimize/step/JanusGraphHasStep.java
index fec27ef946..ecb63ed1a2 100644
--- a/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/optimize/step/JanusGraphHasStep.java
+++ b/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/optimize/step/JanusGraphHasStep.java
@@ -119,10 +119,13 @@ public Q makeQuery(Q query) {
}
},
new FetchQueryBuildFunction() {
+ private String[] propertyKeys;
@Override
public Q makeQuery(Q query) {
- if(!prefetchAllPropertiesRequired && !propertiesToFetch.isEmpty()){
- String[] propertyKeys = propertiesToFetch.toArray(new String[0]);
+ if(!prefetchAllPropertiesRequired){
+ if(propertyKeys == null){
+ propertyKeys = propertiesToFetch.toArray(new String[0]);
+ }
query.keys(propertyKeys);
}
return (Q) ((BasicVertexCentricQueryBuilder) query).profiler(queryProfiler);
diff --git a/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/optimize/strategy/JanusGraphHasStepStrategy.java b/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/optimize/strategy/JanusGraphHasStepStrategy.java
index dfdf9bd32c..23416cdf10 100644
--- a/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/optimize/strategy/JanusGraphHasStepStrategy.java
+++ b/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/optimize/strategy/JanusGraphHasStepStrategy.java
@@ -45,6 +45,8 @@ public class JanusGraphHasStepStrategy extends AbstractTraversalStrategy> PRIORS = Collections.singleton(JanusGraphLocalQueryOptimizerStrategy.class);
+
private JanusGraphHasStepStrategy() {
}
@@ -146,8 +148,6 @@ public static JanusGraphHasStepStrategy instance() {
return INSTANCE;
}
- private static final Set> PRIORS = Collections.singleton(JanusGraphLocalQueryOptimizerStrategy.class);
-
@Override
public Set> applyPrior() {
return PRIORS;
diff --git a/janusgraph-core/src/test/java/org/janusgraph/util/datastructures/ExceptionUtilTest.java b/janusgraph-core/src/test/java/org/janusgraph/util/datastructures/ExceptionUtilTest.java
new file mode 100644
index 0000000000..2f3072ed0b
--- /dev/null
+++ b/janusgraph-core/src/test/java/org/janusgraph/util/datastructures/ExceptionUtilTest.java
@@ -0,0 +1,65 @@
+// Copyright 2023 JanusGraph Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.janusgraph.util.datastructures;
+
+import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalInterruptedException;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class ExceptionUtilTest {
+
+ @Test
+ public void isCausedBy_WhenExceptionHasNoCause_ReturnsFalse() {
+ Throwable exception = new RuntimeException("Test exception");
+ boolean result = ExceptionUtil.isCausedBy(exception, NullPointerException.class);
+ assertFalse(result);
+ }
+
+ @Test
+ public void isCausedBy_WhenExceptionCauseMatches_ReturnsTrue() {
+ NullPointerException cause = new NullPointerException("Test cause");
+ Throwable exception = new RuntimeException("Test exception", cause);
+ boolean result = ExceptionUtil.isCausedBy(exception, NullPointerException.class);
+ assertTrue(result);
+ }
+
+ @Test
+ public void isCausedBy_WhenExceptionCauseDoesNotMatch_ReturnsFalse() {
+ IllegalArgumentException cause = new IllegalArgumentException("Test cause");
+ Throwable exception = new RuntimeException("Test exception", cause);
+ boolean result = ExceptionUtil.isCausedBy(exception, NullPointerException.class);
+ assertFalse(result);
+ }
+
+ @Test
+ public void convertIfInterrupted_WhenRuntimeExceptionNotCausedByInterruptedException_ReturnsSameException() {
+ RuntimeException exception = new RuntimeException("Test exception");
+ RuntimeException result = ExceptionUtil.convertIfInterrupted(exception);
+ assertSame(exception, result);
+ }
+
+ @Test
+ public void convertIfInterrupted_WhenRuntimeExceptionCausedByInterruptedException_ReturnsTraversalInterruptedException() {
+ InterruptedException cause = new InterruptedException("Test cause");
+ RuntimeException exception = new RuntimeException("Test exception", cause);
+ RuntimeException result = ExceptionUtil.convertIfInterrupted(exception);
+ assertTrue(result instanceof TraversalInterruptedException);
+ assertEquals(exception, result.getCause());
+ }
+}