Skip to content

Commit dc2af2c

Browse files
authored
[DE-560] ArangoSearch column cache (v6) (#493)
* upd test docker images * ArangoSearch column cache
1 parent 1b6a060 commit dc2af2c

14 files changed

+248
-23
lines changed

.github/workflows/maven.yml

+8-10
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@ jobs:
2020
fail-fast: false
2121
matrix:
2222
docker-img:
23-
- docker.io/arangodb/arangodb:3.8.8
24-
- docker.io/arangodb/arangodb:3.9.5
25-
- docker.io/arangodb/arangodb:3.10.1
26-
- docker.io/arangodb/enterprise:3.8.8
27-
- docker.io/arangodb/enterprise:3.9.5
28-
- docker.io/arangodb/enterprise:3.10.1
23+
- docker.io/arangodb/arangodb:3.9.10
24+
- docker.io/arangodb/arangodb:3.10.5
25+
- docker.io/arangodb/enterprise:3.9.10
26+
- docker.io/arangodb/enterprise:3.10.5
2927
topology:
3028
- single
3129
- cluster
@@ -37,12 +35,12 @@ jobs:
3735
user-language:
3836
- en
3937
include:
40-
- docker-img: docker.io/arangodb/arangodb:3.10.1
38+
- docker-img: docker.io/arangodb/arangodb:3.10.5
4139
topology: single
4240
db-ext-names: true
4341
java-version: 11
4442
user-language: tr
45-
- docker-img: docker.io/arangodb/enterprise:3.10.1
43+
- docker-img: docker.io/arangodb/enterprise:3.10.5
4644
topology: cluster
4745
db-ext-names: true
4846
java-version: 17
@@ -92,7 +90,7 @@ jobs:
9290
fail-fast: false
9391
matrix:
9492
docker-img:
95-
- docker.io/arangodb/enterprise:3.10.1
93+
- docker.io/arangodb/enterprise:3.10.5
9694
topology:
9795
- single
9896
- cluster
@@ -139,7 +137,7 @@ jobs:
139137
fail-fast: false
140138
matrix:
141139
docker-img:
142-
- docker.io/arangodb/enterprise:3.10.1
140+
- docker.io/arangodb/enterprise:3.10.5
143141
topology:
144142
- cluster
145143
db-ext-names:

.github/workflows/native.yml

+1-1
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.10.1
17+
- docker.io/arangodb/enterprise:3.10.5
1818
topology:
1919
- cluster
2020
db-ext-names:

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

+10
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ public class InvertedIndexEntity implements Entity {
5757
private Long writebufferIdle;
5858
private Long writebufferActive;
5959
private Long writebufferSizeMax;
60+
private Boolean cache;
61+
private Boolean primaryKeyCache;
6062

6163
public String getId() {
6264
return id;
@@ -149,4 +151,12 @@ public Long getWritebufferActive() {
149151
public Long getWritebufferSizeMax() {
150152
return writebufferSizeMax;
151153
}
154+
155+
public Boolean getCache() {
156+
return cache;
157+
}
158+
159+
public Boolean getPrimaryKeyCache() {
160+
return primaryKeyCache;
161+
}
152162
}

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

+20-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class InvertedIndexField implements Entity {
1515
private Boolean includeAllFields;
1616
private Boolean searchField;
1717
private Boolean trackListPositions;
18+
private Boolean cache;
1819
private final Set<AnalyzerFeature> features = new HashSet<>();
1920
private Collection<InvertedIndexField> nested;
2021

@@ -103,6 +104,23 @@ public InvertedIndexField trackListPositions(Boolean trackListPositions) {
103104
return this;
104105
}
105106

107+
public Boolean getCache() {
108+
return cache;
109+
}
110+
111+
/**
112+
* @param cache Enable this option to always cache the field normalization values in memory for this specific field.
113+
* This can improve the performance of scoring and ranking queries. Otherwise, these values are
114+
* memory-mapped and it is up to the operating system to load them from disk into memory and to evict
115+
* them from memory. (Enterprise Edition only)
116+
* @return this
117+
* @since ArangoDB 3.10.2
118+
*/
119+
public InvertedIndexField cache(Boolean cache) {
120+
this.cache = cache;
121+
return this;
122+
}
123+
106124
public Set<AnalyzerFeature> getFeatures() {
107125
return features;
108126
}
@@ -139,11 +157,11 @@ public boolean equals(Object o) {
139157
if (this == o) return true;
140158
if (o == null || getClass() != o.getClass()) return false;
141159
InvertedIndexField that = (InvertedIndexField) o;
142-
return Objects.equals(name, that.name) && Objects.equals(analyzer, that.analyzer) && Objects.equals(includeAllFields, that.includeAllFields) && Objects.equals(searchField, that.searchField) && Objects.equals(trackListPositions, that.trackListPositions) && Objects.equals(features, that.features) && Objects.equals(nested, that.nested);
160+
return Objects.equals(name, that.name) && Objects.equals(analyzer, that.analyzer) && Objects.equals(includeAllFields, that.includeAllFields) && Objects.equals(searchField, that.searchField) && Objects.equals(trackListPositions, that.trackListPositions) && Objects.equals(cache, that.cache) && Objects.equals(features, that.features) && Objects.equals(nested, that.nested);
143161
}
144162

145163
@Override
146164
public int hashCode() {
147-
return Objects.hash(name, analyzer, includeAllFields, searchField, trackListPositions, features, nested);
165+
return Objects.hash(name, analyzer, includeAllFields, searchField, trackListPositions, cache, features, nested);
148166
}
149167
}

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

+20-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
public class InvertedIndexPrimarySort implements Entity {
1616
private final List<Field> fields = new ArrayList<>();
1717
private ArangoSearchCompression compression;
18+
private Boolean cache;
1819

1920
public List<Field> getFields() {
2021
return fields;
@@ -42,17 +43,34 @@ public InvertedIndexPrimarySort compression(ArangoSearchCompression compression)
4243
return this;
4344
}
4445

46+
public Boolean getCache() {
47+
return cache;
48+
}
49+
50+
/**
51+
* @param cache If you enable this option, then the primary sort columns are always cached in memory. This can
52+
* improve the performance of queries that utilize the primary sort order. Otherwise, these values are
53+
* memory-mapped and it is up to the operating system to load them from disk into memory and to evict
54+
* them from memory (Enterprise Edition only).
55+
* @return this
56+
* @since ArangoDB 3.10.2
57+
*/
58+
public InvertedIndexPrimarySort cache(Boolean cache) {
59+
this.cache = cache;
60+
return this;
61+
}
62+
4563
@Override
4664
public boolean equals(Object o) {
4765
if (this == o) return true;
4866
if (o == null || getClass() != o.getClass()) return false;
4967
InvertedIndexPrimarySort that = (InvertedIndexPrimarySort) o;
50-
return Objects.equals(fields, that.fields) && compression == that.compression;
68+
return Objects.equals(fields, that.fields) && compression == that.compression && Objects.equals(cache, that.cache);
5169
}
5270

5371
@Override
5472
public int hashCode() {
55-
return Objects.hash(fields, compression);
73+
return Objects.hash(fields, compression, cache);
5674
}
5775

5876
public static class Field {

src/main/java/com/arangodb/entity/arangosearch/ArangoSearchProperties.java

+35
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
package com.arangodb.entity.arangosearch;
2222

23+
import com.arangodb.model.arangosearch.ArangoSearchCreateOptions;
24+
2325
import java.util.ArrayList;
2426
import java.util.Arrays;
2527
import java.util.Collection;
@@ -40,6 +42,8 @@ public class ArangoSearchProperties {
4042
private final Collection<CollectionLink> links;
4143
private ArangoSearchCompression primarySortCompression;
4244
private final Collection<StoredValue> storedValues;
45+
private Boolean primarySortCache;
46+
private Boolean primaryKeyCache;
4347

4448
public ArangoSearchProperties() {
4549
super();
@@ -123,4 +127,35 @@ public void addStoredValues(final StoredValue... storedValues) {
123127
this.storedValues.addAll(Arrays.asList(storedValues));
124128
}
125129

130+
public Boolean getPrimarySortCache() {
131+
return primarySortCache;
132+
}
133+
134+
135+
/**
136+
* @param primarySortCache If you enable this option, then the primary sort columns are always cached in memory.
137+
* This can improve the performance of queries that utilize the primary sort order.
138+
* Otherwise, these values are memory-mapped and it is up to the operating system to load
139+
* them from disk into memory and to evict them from memory.
140+
* @since ArangoDB 3.9.6, Enterprise Edition only
141+
*/
142+
public void setPrimarySortCache(final Boolean primarySortCache) {
143+
this.primarySortCache = primarySortCache;
144+
}
145+
146+
public Boolean getPrimaryKeyCache() {
147+
return primaryKeyCache;
148+
}
149+
150+
/**
151+
* @param primaryKeyCache If you enable this option, then the primary key columns are always cached in memory. This
152+
* can improve the performance of queries that return many documents. Otherwise, these values
153+
* are memory-mapped and it is up to the operating system to load them from disk into memory
154+
* and to evict them from memory.
155+
* @since ArangoDB 3.9.6, Enterprise Edition only
156+
*/
157+
public void setPrimaryKeyCache(final Boolean primaryKeyCache) {
158+
this.primaryKeyCache = primaryKeyCache;
159+
}
160+
126161
}

src/main/java/com/arangodb/entity/arangosearch/ArangoSearchPropertiesEntity.java

+19
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,23 @@ public Collection<StoredValue> getStoredValues() {
116116
return properties.getStoredValues();
117117
}
118118

119+
/**
120+
* @return If you enable this option, then the primary sort columns are always cached in memory. This can improve
121+
* the performance of queries that utilize the primary sort order. Otherwise, these values are memory-mapped and it
122+
* is up to the operating system to load them from disk into memory and to evict them from memory.
123+
* @since ArangoDB 3.9.6, Enterprise Edition only
124+
*/
125+
public Boolean getPrimarySortCache() {
126+
return properties.getPrimarySortCache();
127+
}
128+
129+
/**
130+
* @return If you enable this option, then the primary key columns are always cached in memory. This can improve the
131+
* performance of queries that return many documents. Otherwise, these values are memory-mapped and it is up to the
132+
* operating system to load them from disk into memory and to evict them from memory.
133+
* @since ArangoDB 3.9.6, Enterprise Edition only
134+
*/
135+
public Boolean getPrimaryKeyCache() {
136+
return properties.getPrimaryKeyCache();
137+
}
119138
}

src/main/java/com/arangodb/entity/arangosearch/FieldLink.java

+18
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class FieldLink {
1414
private final Collection<FieldLink> fields;
1515
private final Collection<FieldLink> nested;
1616
private Boolean inBackground;
17+
private Boolean cache;
1718

1819
private FieldLink(final String name) {
1920
super();
@@ -102,6 +103,19 @@ public FieldLink inBackground(final Boolean inBackground) {
102103
return this;
103104
}
104105

106+
/**
107+
* @param cache If you enable this option, then field normalization values are always cached in memory. This can
108+
* improve the performance of scoring and ranking queries. Otherwise, these values are memory-mapped
109+
* and it is up to the operating system to load them from disk into memory and to evict them from
110+
* memory.
111+
* @return link
112+
* @since ArangoDB 3.9.5, Enterprise Edition only
113+
*/
114+
public FieldLink cache(final Boolean cache) {
115+
this.cache = cache;
116+
return this;
117+
}
118+
105119
public String getName() {
106120
return name;
107121
}
@@ -133,4 +147,8 @@ public Collection<FieldLink> getNested() {
133147
public Boolean getInBackground() {
134148
return inBackground;
135149
}
150+
151+
public Boolean getCache() {
152+
return cache;
153+
}
136154
}

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

+14
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,16 @@ public class VPackDeserializers {
189189
context.deserialize(consolidationPolicy, ConsolidationPolicy.class));
190190
}
191191

192+
final VPackSlice primarySortCache = vpack.get("primarySortCache");
193+
if (primarySortCache.isBoolean()) {
194+
properties.setPrimarySortCache(primarySortCache.getAsBoolean());
195+
}
196+
197+
final VPackSlice primaryKeyCache = vpack.get("primaryKeyCache");
198+
if (primaryKeyCache.isBoolean()) {
199+
properties.setPrimaryKeyCache(primaryKeyCache.getAsBoolean());
200+
}
201+
192202
final VPackSlice links = vpack.get("links");
193203
if (links.isObject()) {
194204
final Iterator<Entry<String, VPackSlice>> collectionIterator = links.objectIterator();
@@ -303,6 +313,10 @@ protected static FieldLink deserializeField(final Entry<String, VPackSlice> fiel
303313
link.nested(deserializeField(fieldsIterator.next()));
304314
}
305315
}
316+
final VPackSlice cache = value.get("cache");
317+
if (cache.isBoolean()) {
318+
link.cache(cache.getAsBoolean());
319+
}
306320
return link;
307321
}
308322

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

+14
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,16 @@ public class VPackSerializers {
163163
}
164164
context.serialize(builder, "consolidationPolicy", value.getConsolidationPolicy());
165165

166+
final Boolean primarySortCache = value.getPrimarySortCache();
167+
if (primarySortCache != null) {
168+
builder.add("primarySortCache", primarySortCache);
169+
}
170+
171+
final Boolean primaryKeyCache = value.getPrimaryKeyCache();
172+
if (primaryKeyCache != null) {
173+
builder.add("primaryKeyCache", primaryKeyCache);
174+
}
175+
166176
final Collection<CollectionLink> links = value.getLinks();
167177
if (!links.isEmpty()) {
168178
builder.add("links", ValueType.OBJECT);
@@ -314,6 +324,10 @@ private static void serializeFields(final VPackBuilder builder, final Collection
314324
if (inBackground != null) {
315325
builder.add("inBackground", inBackground);
316326
}
327+
Boolean cache = fieldLink.getCache();
328+
if (cache != null) {
329+
builder.add("cache", cache);
330+
}
317331
serializeFieldLinks(builder, fieldLink.getFields());
318332
serializeNested(builder, fieldLink.getNested());
319333
builder.close();

0 commit comments

Comments
 (0)