Skip to content

[DE-560] ArangoSearch column cache (v6) #493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ jobs:
fail-fast: false
matrix:
docker-img:
- docker.io/arangodb/arangodb:3.8.8
- docker.io/arangodb/arangodb:3.9.5
- docker.io/arangodb/arangodb:3.10.1
- docker.io/arangodb/enterprise:3.8.8
- docker.io/arangodb/enterprise:3.9.5
- docker.io/arangodb/enterprise:3.10.1
- docker.io/arangodb/arangodb:3.9.10
- docker.io/arangodb/arangodb:3.10.5
- docker.io/arangodb/enterprise:3.9.10
- docker.io/arangodb/enterprise:3.10.5
topology:
- single
- cluster
Expand All @@ -37,12 +35,12 @@ jobs:
user-language:
- en
include:
- docker-img: docker.io/arangodb/arangodb:3.10.1
- docker-img: docker.io/arangodb/arangodb:3.10.5
topology: single
db-ext-names: true
java-version: 11
user-language: tr
- docker-img: docker.io/arangodb/enterprise:3.10.1
- docker-img: docker.io/arangodb/enterprise:3.10.5
topology: cluster
db-ext-names: true
java-version: 17
Expand Down Expand Up @@ -92,7 +90,7 @@ jobs:
fail-fast: false
matrix:
docker-img:
- docker.io/arangodb/enterprise:3.10.1
- docker.io/arangodb/enterprise:3.10.5
topology:
- single
- cluster
Expand Down Expand Up @@ -139,7 +137,7 @@ jobs:
fail-fast: false
matrix:
docker-img:
- docker.io/arangodb/enterprise:3.10.1
- docker.io/arangodb/enterprise:3.10.5
topology:
- cluster
db-ext-names:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fail-fast: false
matrix:
docker-img:
- docker.io/arangodb/enterprise:3.10.1
- docker.io/arangodb/enterprise:3.10.5
topology:
- cluster
db-ext-names:
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/arangodb/entity/InvertedIndexEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public class InvertedIndexEntity implements Entity {
private Long writebufferIdle;
private Long writebufferActive;
private Long writebufferSizeMax;
private Boolean cache;
private Boolean primaryKeyCache;

public String getId() {
return id;
Expand Down Expand Up @@ -149,4 +151,12 @@ public Long getWritebufferActive() {
public Long getWritebufferSizeMax() {
return writebufferSizeMax;
}

public Boolean getCache() {
return cache;
}

public Boolean getPrimaryKeyCache() {
return primaryKeyCache;
}
}
22 changes: 20 additions & 2 deletions src/main/java/com/arangodb/entity/InvertedIndexField.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class InvertedIndexField implements Entity {
private Boolean includeAllFields;
private Boolean searchField;
private Boolean trackListPositions;
private Boolean cache;
private final Set<AnalyzerFeature> features = new HashSet<>();
private Collection<InvertedIndexField> nested;

Expand Down Expand Up @@ -103,6 +104,23 @@ public InvertedIndexField trackListPositions(Boolean trackListPositions) {
return this;
}

public Boolean getCache() {
return cache;
}

/**
* @param cache Enable this option to always cache the field normalization values in memory for this specific field.
* This can improve the performance of scoring and ranking queries. Otherwise, these values are
* memory-mapped and it is up to the operating system to load them from disk into memory and to evict
* them from memory. (Enterprise Edition only)
* @return this
* @since ArangoDB 3.10.2
*/
public InvertedIndexField cache(Boolean cache) {
this.cache = cache;
return this;
}

public Set<AnalyzerFeature> getFeatures() {
return features;
}
Expand Down Expand Up @@ -139,11 +157,11 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
InvertedIndexField that = (InvertedIndexField) o;
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);
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);
}

@Override
public int hashCode() {
return Objects.hash(name, analyzer, includeAllFields, searchField, trackListPositions, features, nested);
return Objects.hash(name, analyzer, includeAllFields, searchField, trackListPositions, cache, features, nested);
}
}
22 changes: 20 additions & 2 deletions src/main/java/com/arangodb/entity/InvertedIndexPrimarySort.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
public class InvertedIndexPrimarySort implements Entity {
private final List<Field> fields = new ArrayList<>();
private ArangoSearchCompression compression;
private Boolean cache;

public List<Field> getFields() {
return fields;
Expand Down Expand Up @@ -42,17 +43,34 @@ public InvertedIndexPrimarySort compression(ArangoSearchCompression compression)
return this;
}

public Boolean getCache() {
return cache;
}

/**
* @param cache If you enable this option, then the primary sort columns are always cached in memory. This can
* improve the performance of queries that utilize the primary sort order. Otherwise, these values are
* memory-mapped and it is up to the operating system to load them from disk into memory and to evict
* them from memory (Enterprise Edition only).
* @return this
* @since ArangoDB 3.10.2
*/
public InvertedIndexPrimarySort cache(Boolean cache) {
this.cache = cache;
return this;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
InvertedIndexPrimarySort that = (InvertedIndexPrimarySort) o;
return Objects.equals(fields, that.fields) && compression == that.compression;
return Objects.equals(fields, that.fields) && compression == that.compression && Objects.equals(cache, that.cache);
}

@Override
public int hashCode() {
return Objects.hash(fields, compression);
return Objects.hash(fields, compression, cache);
}

public static class Field {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

package com.arangodb.entity.arangosearch;

import com.arangodb.model.arangosearch.ArangoSearchCreateOptions;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand All @@ -40,6 +42,8 @@ public class ArangoSearchProperties {
private final Collection<CollectionLink> links;
private ArangoSearchCompression primarySortCompression;
private final Collection<StoredValue> storedValues;
private Boolean primarySortCache;
private Boolean primaryKeyCache;

public ArangoSearchProperties() {
super();
Expand Down Expand Up @@ -123,4 +127,35 @@ public void addStoredValues(final StoredValue... storedValues) {
this.storedValues.addAll(Arrays.asList(storedValues));
}

public Boolean getPrimarySortCache() {
return primarySortCache;
}


/**
* @param primarySortCache If you enable this option, then the primary sort columns are always cached in memory.
* This can improve the performance of queries that utilize the primary sort order.
* Otherwise, these values are memory-mapped and it is up to the operating system to load
* them from disk into memory and to evict them from memory.
* @since ArangoDB 3.9.6, Enterprise Edition only
*/
public void setPrimarySortCache(final Boolean primarySortCache) {
this.primarySortCache = primarySortCache;
}

public Boolean getPrimaryKeyCache() {
return primaryKeyCache;
}

/**
* @param primaryKeyCache If you enable this option, then the primary key columns are always cached in memory. This
* can improve the performance of queries that return many documents. Otherwise, these values
* are memory-mapped and it is up to the operating system to load them from disk into memory
* and to evict them from memory.
* @since ArangoDB 3.9.6, Enterprise Edition only
*/
public void setPrimaryKeyCache(final Boolean primaryKeyCache) {
this.primaryKeyCache = primaryKeyCache;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,23 @@ public Collection<StoredValue> getStoredValues() {
return properties.getStoredValues();
}

/**
* @return If you enable this option, then the primary sort columns are always cached in memory. This can improve
* the performance of queries that utilize the primary sort order. Otherwise, these values are memory-mapped and it
* is up to the operating system to load them from disk into memory and to evict them from memory.
* @since ArangoDB 3.9.6, Enterprise Edition only
*/
public Boolean getPrimarySortCache() {
return properties.getPrimarySortCache();
}

/**
* @return If you enable this option, then the primary key columns are always cached in memory. This can improve the
* performance of queries that return many documents. Otherwise, these values are memory-mapped and it is up to the
* operating system to load them from disk into memory and to evict them from memory.
* @since ArangoDB 3.9.6, Enterprise Edition only
*/
public Boolean getPrimaryKeyCache() {
return properties.getPrimaryKeyCache();
}
}
18 changes: 18 additions & 0 deletions src/main/java/com/arangodb/entity/arangosearch/FieldLink.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class FieldLink {
private final Collection<FieldLink> fields;
private final Collection<FieldLink> nested;
private Boolean inBackground;
private Boolean cache;

private FieldLink(final String name) {
super();
Expand Down Expand Up @@ -102,6 +103,19 @@ public FieldLink inBackground(final Boolean inBackground) {
return this;
}

/**
* @param cache If you enable this option, then field normalization values are always cached in memory. This can
* improve the performance of scoring and ranking queries. Otherwise, these values are memory-mapped
* and it is up to the operating system to load them from disk into memory and to evict them from
* memory.
* @return link
* @since ArangoDB 3.9.5, Enterprise Edition only
*/
public FieldLink cache(final Boolean cache) {
this.cache = cache;
return this;
}

public String getName() {
return name;
}
Expand Down Expand Up @@ -133,4 +147,8 @@ public Collection<FieldLink> getNested() {
public Boolean getInBackground() {
return inBackground;
}

public Boolean getCache() {
return cache;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,16 @@ public class VPackDeserializers {
context.deserialize(consolidationPolicy, ConsolidationPolicy.class));
}

final VPackSlice primarySortCache = vpack.get("primarySortCache");
if (primarySortCache.isBoolean()) {
properties.setPrimarySortCache(primarySortCache.getAsBoolean());
}

final VPackSlice primaryKeyCache = vpack.get("primaryKeyCache");
if (primaryKeyCache.isBoolean()) {
properties.setPrimaryKeyCache(primaryKeyCache.getAsBoolean());
}

final VPackSlice links = vpack.get("links");
if (links.isObject()) {
final Iterator<Entry<String, VPackSlice>> collectionIterator = links.objectIterator();
Expand Down Expand Up @@ -303,6 +313,10 @@ protected static FieldLink deserializeField(final Entry<String, VPackSlice> fiel
link.nested(deserializeField(fieldsIterator.next()));
}
}
final VPackSlice cache = value.get("cache");
if (cache.isBoolean()) {
link.cache(cache.getAsBoolean());
}
return link;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,16 @@ public class VPackSerializers {
}
context.serialize(builder, "consolidationPolicy", value.getConsolidationPolicy());

final Boolean primarySortCache = value.getPrimarySortCache();
if (primarySortCache != null) {
builder.add("primarySortCache", primarySortCache);
}

final Boolean primaryKeyCache = value.getPrimaryKeyCache();
if (primaryKeyCache != null) {
builder.add("primaryKeyCache", primaryKeyCache);
}

final Collection<CollectionLink> links = value.getLinks();
if (!links.isEmpty()) {
builder.add("links", ValueType.OBJECT);
Expand Down Expand Up @@ -314,6 +324,10 @@ private static void serializeFields(final VPackBuilder builder, final Collection
if (inBackground != null) {
builder.add("inBackground", inBackground);
}
Boolean cache = fieldLink.getCache();
if (cache != null) {
builder.add("cache", cache);
}
serializeFieldLinks(builder, fieldLink.getFields());
serializeNested(builder, fieldLink.getNested());
builder.close();
Expand Down
Loading