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 e6e2ec4

Browse files
authored
[DE-434] ArangoSearch cache (#472)
* ArangoSearch cache * updated test docker images * fixed deserialization * fixed deserialization
1 parent e5169fa commit e6e2ec4

File tree

8 files changed

+69
-18
lines changed

8 files changed

+69
-18
lines changed

‎.github/workflows/maven.yml‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ jobs:
2222
fail-fast: false
2323
matrix:
2424
docker-img:
25-
- docker.io/arangodb/arangodb:3.8.7
26-
- docker.io/arangodb/arangodb:3.9.3
27-
- docker.io/arangodb/arangodb-preview:3.10-nightly
28-
- docker.io/arangodb/enterprise:3.8.7
29-
- docker.io/arangodb/enterprise:3.9.3
30-
- docker.io/arangodb/enterprise-preview:3.10-nightly
25+
- docker.io/arangodb/arangodb:3.8.8
26+
- docker.io/arangodb/arangodb:3.9.5
27+
- docker.io/arangodb/arangodb:3.10.1
28+
- docker.io/arangodb/enterprise:3.8.8
29+
- docker.io/arangodb/enterprise:3.9.5
30+
- docker.io/arangodb/enterprise:3.10.1
3131
topology:
3232
- single
3333
- cluster
@@ -39,12 +39,12 @@ jobs:
3939
user-language:
4040
- en
4141
include:
42-
- docker-img: docker.io/arangodb/arangodb:3.9.3
42+
- docker-img: docker.io/arangodb/arangodb:3.10.1
4343
topology: single
4444
db-ext-names: true
4545
java-version: 11
4646
user-language: tr
47-
- docker-img: docker.io/arangodb/enterprise:3.9.3
47+
- docker-img: docker.io/arangodb/enterprise:3.10.1
4848
topology: cluster
4949
db-ext-names: true
5050
java-version: 17
@@ -94,7 +94,7 @@ jobs:
9494
fail-fast: false
9595
matrix:
9696
docker-img:
97-
- docker.io/arangodb/enterprise:3.9.3
97+
- docker.io/arangodb/enterprise:3.10.1
9898
topology:
9999
- single
100100
- cluster
@@ -141,7 +141,7 @@ jobs:
141141
fail-fast: false
142142
matrix:
143143
docker-img:
144-
- docker.io/arangodb/enterprise:3.9.1
144+
- docker.io/arangodb/enterprise:3.10.1
145145
topology:
146146
- cluster
147147
db-ext-names:

‎.github/workflows/native.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
fail-fast: false
1515
matrix:
1616
docker-img:
17-
- docker.io/arangodb/enterprise:3.9.3
17+
- docker.io/arangodb/enterprise:3.10.1
1818
topology:
1919
- cluster
2020
db-ext-names:

‎docker/start_db.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ docker run -d \
7070
--auth.jwt-secret=/jwtSecret \
7171
--starter.address="${GW}" \
7272
--docker.image="${DOCKER_IMAGE}" \
73-
--starter.local --starter.mode=${STARTER_MODE} --all.log.level=debug --all.log.output=+ --log.verbose
73+
--starter.local --starter.mode=${STARTER_MODE} --all.log.level=debug --all.log.output=+ --log.verbose --all.server.descriptors-minimum=1024
7474

7575

7676
wait_server() {

‎src/main/java/com/arangodb/entity/arangosearch/CollectionLink.java‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class CollectionLink {
3737
private final Collection<FieldLink> fields;
3838
private final Collection<FieldLink> nested;
3939
private Boolean inBackground;
40+
private Boolean cache;
4041

4142
private CollectionLink(final String name) {
4243
super();
@@ -125,6 +126,19 @@ public CollectionLink inBackground(final Boolean inBackground) {
125126
return this;
126127
}
127128

129+
/**
130+
* @param cache If you enable this option, then field normalization values are always cached in memory. This can
131+
* improve the performance of scoring and ranking queries. Otherwise, these values are memory-mapped
132+
* and it is up to the operating system to load them from disk into memory and to evict them from
133+
* memory.
134+
* @return link
135+
* @since ArangoDB 3.9.5, Enterprise Edition only
136+
*/
137+
public CollectionLink cache(final Boolean cache) {
138+
this.cache = cache;
139+
return this;
140+
}
141+
128142
public String getName() {
129143
return name;
130144
}
@@ -156,4 +170,7 @@ public Collection<FieldLink> getNested() {
156170
public Boolean getInBackground() {
157171
return inBackground;
158172
}
173+
public Boolean getCache() {
174+
return cache;
175+
}
159176
}

‎src/main/java/com/arangodb/entity/arangosearch/StoredValue.java‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,21 @@ public class StoredValue {
3333

3434
private final List<String> fields;
3535
private final ArangoSearchCompression compression;
36+
private final Boolean cache;
3637

3738
/**
3839
* @param fields A list of attribute paths. The . character denotes sub-attributes.
3940
* @param compression Defines how to compress the attribute values.
41+
* @param cache Whether to cache stored values in memory. (Since ArangoDB 3.9.5, Enterprise Edition only)
4042
*/
41-
public StoredValue(List<String> fields, ArangoSearchCompression compression) {
43+
public StoredValue(List<String> fields, ArangoSearchCompression compression, Booleancache) {
4244
this.fields = fields;
4345
this.compression = compression;
46+
this.cache = cache;
47+
}
48+
49+
public StoredValue(List<String> fields, ArangoSearchCompression compression) {
50+
this(fields, compression, null);
4451
}
4552

4653
public StoredValue(List<String> fields) {
@@ -55,16 +62,20 @@ public ArangoSearchCompression getCompression() {
5562
return compression;
5663
}
5764

65+
public Boolean getCache() {
66+
return cache;
67+
}
68+
5869
@Override
5970
public boolean equals(Object o) {
6071
if (this == o) return true;
6172
if (o == null || getClass() != o.getClass()) return false;
6273
StoredValue that = (StoredValue) o;
63-
return Objects.equals(fields, that.fields) && compression == that.compression;
74+
return Objects.equals(fields, that.fields) && compression == that.compression && Objects.equals(cache, that.cache);
6475
}
6576

6677
@Override
6778
public int hashCode() {
68-
return Objects.hash(fields, compression);
79+
return Objects.hash(fields, compression, cache);
6980
}
7081
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,14 @@ public class VPackDeserializers {
156156
public static final VPackDeserializer<StoredValue> STORED_VALUE = (parent, vpack, context) -> {
157157
VPackSlice fields = vpack.get("fields");
158158
VPackSlice compression = vpack.get("compression");
159+
VPackSlice cache = vpack.get("cache");
160+
Boolean cacheValue = cache.isBoolean() ? cache.getAsBoolean() : null;
159161
final Iterator<VPackSlice> fieldsIterator = fields.arrayIterator();
160162
List<String> fieldsList = new ArrayList<>();
161163
while (fieldsIterator.hasNext()) {
162164
fieldsList.add(fieldsIterator.next().getAsString());
163165
}
164-
return new StoredValue(fieldsList, ArangoSearchCompression.valueOf(compression.getAsString()));
166+
return new StoredValue(fieldsList, ArangoSearchCompression.valueOf(compression.getAsString()), cacheValue);
165167
};
166168

167169
public static final VPackDeserializer<ArangoSearchProperties> ARANGO_SEARCH_PROPERTIES = (parent, vpack, context) -> {
@@ -205,6 +207,10 @@ public class VPackDeserializers {
205207
if (includeAllFields.isBoolean()) {
206208
link.includeAllFields(includeAllFields.getAsBoolean());
207209
}
210+
final VPackSlice cache = value.get("cache");
211+
if (cache.isBoolean()) {
212+
link.cache(cache.getAsBoolean());
213+
}
208214
final VPackSlice trackListPositions = value.get("trackListPositions");
209215
if (trackListPositions.isBoolean()) {
210216
link.trackListPositions(trackListPositions.getAsBoolean());

‎src/main/java/com/arangodb/internal/velocypack/VPackSerializers.java‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import com.arangodb.model.TraversalOptions.Order;
3131
import com.arangodb.model.ZKDIndexOptions;
3232
import com.arangodb.model.arangosearch.ArangoSearchPropertiesOptions;
33-
import com.arangodb.model.arangosearch.SearchAliasCreateOptions;
3433
import com.arangodb.velocypack.*;
3534
import com.arangodb.velocystream.Request;
3635

@@ -193,6 +192,10 @@ public class VPackSerializers {
193192
if (inBackground != null) {
194193
builder.add("inBackground", inBackground);
195194
}
195+
Boolean cache = collectionLink.getCache();
196+
if (cache != null) {
197+
builder.add("cache", cache);
198+
}
196199
serializeFieldLinks(builder, collectionLink.getFields());
197200
serializeNested(builder, collectionLink.getNested());
198201
builder.close();
@@ -255,6 +258,9 @@ public class VPackSerializers {
255258
if (value.getCompression() != null) {
256259
builder.add("compression", value.getCompression().getValue());
257260
}
261+
if (value.getCache() != null) {
262+
builder.add("cache", value.getCache());
263+
}
258264
builder.close(); // close object
259265
};
260266

‎src/test/java/com/arangodb/ArangoSearchTest.java‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,11 +918,14 @@ void arangoSearchOptions(ArangoDatabase db) {
918918
.includeAllFields(true)
919919
.storeValues(StoreValuesType.ID)
920920
.trackListPositions(false)
921-
.inBackground(true);
921+
.inBackground(true)
922+
.cache(true);
922923
if (isEnterprise()) {
923924
link.nested(FieldLink.on("f3"));
924925
}
925926
ArangoSearchCreateOptions options = new ArangoSearchCreateOptions().link(link);
927+
StoredValue storedValue = new StoredValue(Arrays.asList("a", "b"), ArangoSearchCompression.none, true);
928+
options.storedValues(storedValue);
926929

927930
final ArangoSearch view = db.arangoSearch(viewName);
928931
view.create(options);
@@ -940,6 +943,14 @@ void arangoSearchOptions(ArangoDatabase db) {
940943
assertThat(createdLink.getIncludeAllFields()).isTrue();
941944
assertThat(createdLink.getStoreValues()).isEqualTo(StoreValuesType.ID);
942945
assertThat(createdLink.getTrackListPositions()).isFalse();
946+
947+
if (isEnterprise() && isAtLeastVersion(3, 9, 5) && isLessThanVersion(3, 10)) {
948+
assertThat(createdLink.getCache()).isTrue();
949+
assertThat(properties.getStoredValues())
950+
.isNotEmpty()
951+
.allSatisfy(it -> assertThat(it.getCache()).isTrue());
952+
}
953+
943954
if (isEnterprise() && isAtLeastVersion(3, 10)) {
944955
assertThat(createdLink.getNested()).isNotEmpty();
945956
FieldLink nested = createdLink.getNested().iterator().next();

0 commit comments

Comments
(0)

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