Skip to content

Feature/arangosearch properties #287

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 11 commits into from
Aug 5, 2019
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,30 @@

/**
* @author Mark Vollmary
* @author Heiko Kernbach
*
*/
public class ArangoSearchProperties {

private Long consolidationIntervalMsec;
private Long commitIntervalMsec;
private Long cleanupIntervalStep;
private ConsolidationPolicy consolidationPolicy;
private final Collection<PrimarySort> primarySorts;
private final Collection<CollectionLink> links;

public ArangoSearchProperties() {
super();
links = new ArrayList<CollectionLink>();
primarySorts = new ArrayList<PrimarySort>();
}

public Long getCommitIntervalMsec() {
return commitIntervalMsec;
}

public void setCommitIntervalMsec(final Long commitIntervalMsec) {
this.commitIntervalMsec = commitIntervalMsec;
}

public Long getConsolidationIntervalMsec() {
Expand Down Expand Up @@ -72,4 +84,11 @@ public void addLink(final CollectionLink... links) {
this.links.addAll(Arrays.asList(links));
}

public Collection<PrimarySort> getPrimarySort() {
return primarySorts;
}

public void addPrimarySort(final PrimarySort... primarySorts) {
this.primarySorts.addAll(Arrays.asList(primarySorts));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,49 +27,71 @@

/**
* @author Mark Vollmary
*
*/
public class ArangoSearchPropertiesEntity extends ViewEntity {

private final ArangoSearchProperties properties;
private final ArangoSearchProperties properties;

public ArangoSearchPropertiesEntity(final String id, final String name, final ViewType type,
final ArangoSearchProperties properties) {
super(id, name, type);
this.properties = properties;
}

public ArangoSearchPropertiesEntity(final String id, final String name, final ViewType type,
final ArangoSearchProperties properties) {
super(id, name, type);
this.properties = properties;
}
/**
* @return Wait at least this many milliseconds between committing index data changes and making them visible to
* queries (default: 60000, to disable use: 0). For the case where there are a lot of inserts/updates, a
* lower value, until commit, will cause the index not to account for them and memory usage would continue
* to grow. For the case where there are a few inserts/updates, a higher value will impact performance and
* waste disk space for each commit call without any added benefits.
*/
public Long getConsolidationIntervalMsec() {
return properties.getConsolidationIntervalMsec();
}

/**
* @return Wait at least this many milliseconds between committing index data changes and making them visible to
* queries (default: 60000, to disable use: 0). For the case where there are a lot of inserts/updates, a
* lower value, until commit, will cause the index not to account for them and memory usage would continue
* to grow. For the case where there are a few inserts/updates, a higher value will impact performance and
* waste disk space for each commit call without any added benefits.
*/
public Long getConsolidationIntervalMsec() {
return properties.getConsolidationIntervalMsec();
}
/**
* @return Wait at least this many milliseconds between committing view data store changes and making documents
* visible to queries (default: 1000, to disable use: 0). For the case where there are a lot of inserts/updates, a
* lower value, until commit, will cause the index not to account for them and memory usage would continue to grow.
* For the case where there are a few inserts/updates, a higher value will impact performance and waste disk space
* for each commit call without any added benefits. Background: For data retrieval ArangoSearch views follow the
* concept of “eventually-consistent”, i.e. eventually all the data in ArangoDB will be matched by corresponding
* query expressions. The concept of ArangoSearch view “commit” operation is introduced to control the upper-bound
* on the time until document addition/removals are actually reflected by corresponding query expressions. Once a
* “commit” operation is complete all documents added/removed prior to the start of the “commit” operation will be
* reflected by queries invoked in subsequent ArangoDB transactions, in-progress ArangoDB transactions will still
* continue to return a repeatable-read state.
*/
public Long getCommitIntervalMsec() {
return properties.getCommitIntervalMsec();
}

/**
* @return Wait at least this many commits between removing unused files in data directory (default: 10, to disable
* use: 0). For the case where the consolidation policies merge segments often (i.e. a lot of
* commit+consolidate), a lower value will cause a lot of disk space to be wasted. For the case where the
* consolidation policies rarely merge segments (i.e. few inserts/deletes), a higher value will impact
* performance without any added benefits.
*/
public Long getCleanupIntervalStep() {
return properties.getCleanupIntervalStep();
}
/**
* @return Wait at least this many commits between removing unused files in data directory (default: 10, to disable
* use: 0). For the case where the consolidation policies merge segments often (i.e. a lot of
* commit+consolidate), a lower value will cause a lot of disk space to be wasted. For the case where the
* consolidation policies rarely merge segments (i.e. few inserts/deletes), a higher value will impact
* performance without any added benefits.
*/
public Long getCleanupIntervalStep() {
return properties.getCleanupIntervalStep();
}

public ConsolidationPolicy getConsolidationPolicy() {
return properties.getConsolidationPolicy();
}
public ConsolidationPolicy getConsolidationPolicy() {
return properties.getConsolidationPolicy();
}

/**
* @return A list of linked collections
*/
public Collection<CollectionLink> getLinks() {
return properties.getLinks();
}
/**
* @return A list of linked collections
*/
public Collection<CollectionLink> getLinks() {
return properties.getLinks();
}

/**
* @return A list of primary sort objects
*/
public Collection<PrimarySort> getPrimarySort() {
return properties.getPrimarySort();
}
}
61 changes: 61 additions & 0 deletions src/main/java/com/arangodb/entity/arangosearch/PrimarySort.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* DISCLAIMER
*
* Copyright 2019 ArangoDB GmbH, Cologne, Germany
*
* 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.
*
* Copyright holder is ArangoDB GmbH, Cologne, Germany
*/

package com.arangodb.entity.arangosearch;

/**
* @author Heiko Kernbach
*
*/
public class PrimarySort {

private final String fieldName;
private Boolean ascending;

private PrimarySort(final String fieldName) {
super();
this.fieldName = fieldName;
}

public static PrimarySort on(final String fieldName) {
return new PrimarySort(fieldName);
}

/**
* @param ascending
* @return primarySort
*/
public PrimarySort ascending(final Boolean ascending) {
if (ascending) {
this.ascending = true;
} else {
this.ascending = false;
}
return this;
}

public Boolean getAscending() {
return ascending;
}

public String getFieldName() {
return fieldName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,10 @@
import java.util.Map.Entry;

import com.arangodb.entity.*;
import com.arangodb.entity.arangosearch.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.arangodb.entity.arangosearch.ArangoSearchProperties;
import com.arangodb.entity.arangosearch.ArangoSearchPropertiesEntity;
import com.arangodb.entity.arangosearch.CollectionLink;
import com.arangodb.entity.arangosearch.ConsolidationPolicy;
import com.arangodb.entity.arangosearch.ConsolidationType;
import com.arangodb.entity.arangosearch.FieldLink;
import com.arangodb.entity.arangosearch.StoreValuesType;
import com.arangodb.velocypack.VPackDeserializationContext;
import com.arangodb.velocypack.VPackDeserializer;
import com.arangodb.velocypack.VPackSlice;
Expand Down Expand Up @@ -223,10 +217,17 @@ public ArangoSearchProperties deserialize(
if (consolidationIntervalMsec.isInteger()) {
properties.setConsolidationIntervalMsec(consolidationIntervalMsec.getAsLong());
}

final VPackSlice commitIntervalMsec = vpack.get("commitIntervalMsec");
if (commitIntervalMsec.isInteger()) {
properties.setCommitIntervalMsec(commitIntervalMsec.getAsLong());
}

final VPackSlice cleanupIntervalStep = vpack.get("cleanupIntervalStep");
if (cleanupIntervalStep.isInteger()) {
properties.setCleanupIntervalStep(cleanupIntervalStep.getAsLong());
}

final VPackSlice consolidationPolicy = vpack.get("consolidationPolicy");
if (consolidationPolicy.isObject()) {
properties.setConsolidationPolicy(
Expand Down Expand Up @@ -269,6 +270,22 @@ public ArangoSearchProperties deserialize(
properties.addLink(link);
}
}

final VPackSlice primarySorts = vpack.get("primarySort");
if (primarySorts.isArray()) {
final Iterator<VPackSlice> primarySortsIterator = primarySorts.arrayIterator();
for (; primarySortsIterator.hasNext();) {
final VPackSlice entry = primarySortsIterator.next();
if (entry.isObject()) {
if (entry.get("field").isString() && entry.get("asc").isBoolean()) {
final PrimarySort primarySort = PrimarySort.on(entry.get("field").getAsString());
primarySort.ascending(entry.get("asc").getAsBoolean());
properties.addPrimarySort(primarySort);
}
}
}
}

return properties;
}
};
Expand Down
Loading