Skip to content

added inBackground option to all indices #286

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 6 commits into from
Aug 5, 2019
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
2 changes: 1 addition & 1 deletion src/main/java/com/arangodb/entity/ArangoDBVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ public License getLicense() {
return license;
}

}
}
5 changes: 5 additions & 0 deletions src/main/java/com/arangodb/entity/IndexEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class IndexEntity implements Entity {
private Boolean geoJson;
private Boolean constraint;
private Boolean deduplicate;
private Boolean inBackground;

public IndexEntity() {
super();
Expand All @@ -49,6 +50,10 @@ public String getId() {
return id;
}

public Boolean getInBackground() {
return inBackground;
}

public String getName() {
return name;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/arangodb/entity/ServerRole.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
*/
public enum ServerRole {
SINGLE, AGENT, COORDINATOR, PRIMARY, SECONDARY, UNDEFINED
}
}
17 changes: 1 addition & 16 deletions src/main/java/com/arangodb/model/FulltextIndexOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@
* @see <a href="https://docs.arangodb.com/current/HTTP/Indexes/Fulltext.html#create-fulltext-index">API
* Documentation</a>
*/
public class FulltextIndexOptions {
public class FulltextIndexOptions extends IndexOptions {

private Iterable<String> fields;
private final IndexType type = IndexType.fulltext;
private Integer minLength;
private String name;

public FulltextIndexOptions() {
super();
Expand Down Expand Up @@ -61,20 +60,6 @@ public Integer getMinLength() {
return minLength;
}

/**
* @param name
* the name of the index
* @return options
*/
public FulltextIndexOptions name(final String name) {
this.name = name;
return this;
}

protected String getName() {
return name;
}

/**
* @param minLength
* Minimum character length of words to index. Will default to a server-defined value if unspecified. It
Expand Down
17 changes: 1 addition & 16 deletions src/main/java/com/arangodb/model/GeoIndexOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@
*
* @see <a href="https://docs.arangodb.com/current/HTTP/Indexes/Geo.html#create-geospatial-index">API Documentation</a>
*/
public class GeoIndexOptions {
public class GeoIndexOptions extends IndexOptions {

private Iterable<String> fields;
private final IndexType type = IndexType.geo;
private Boolean geoJson;
private String name;

public GeoIndexOptions() {
super();
Expand All @@ -56,20 +55,6 @@ protected IndexType getType() {
return type;
}

/**
* @param name
* the name of the index
* @return options
*/
public GeoIndexOptions name(final String name) {
this.name = name;
return this;
}

protected String getName() {
return name;
}

public Boolean getGeoJson() {
return geoJson;
}
Expand Down
18 changes: 1 addition & 17 deletions src/main/java/com/arangodb/model/HashIndexOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@
*
* @see <a href="https://docs.arangodb.com/current/HTTP/Indexes/Hash.html#create-hash-index">API Documentation</a>
*/
public class HashIndexOptions {
public class HashIndexOptions extends IndexOptions {

private Iterable<String> fields;
private final IndexType type = IndexType.hash;
private Boolean unique;
private Boolean sparse;
private Boolean deduplicate;
private String name;

public HashIndexOptions() {
super();
Expand Down Expand Up @@ -99,19 +98,4 @@ public HashIndexOptions deduplicate(final Boolean deduplicate) {
this.deduplicate = deduplicate;
return this;
}

/**
* @param name
* the name of the index
* @return options
*/
public HashIndexOptions name(final String name) {
this.name = name;
return this;
}

protected String getName() {
return name;
}

}
67 changes: 67 additions & 0 deletions src/main/java/com/arangodb/model/IndexOptions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* 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.model;

import com.arangodb.entity.IndexType;

/**
* @author Heiko Kernbach
*
* This class is used for all index similarities
*/
public class IndexOptions {

private Boolean inBackground;
private String name;

public IndexOptions() {
super();
}

/**
* @param inBackground
* create the the index in the background
* this is a RocksDB only flag.
* @return options
*/
public IndexOptions inBackground(final Boolean inBackground) {
this.inBackground = inBackground;
return this;
}

public Boolean getInBackground() {
return inBackground;
}

/**
* @param name
* the name of the index
* @return options
*/
public IndexOptions name(final String name) {
this.name = name;
return this;
}

protected String getName() {
return name;
}
}
17 changes: 1 addition & 16 deletions src/main/java/com/arangodb/model/PersistentIndexOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@
* @see <a href="https://docs.arangodb.com/current/HTTP/Indexes/Persistent.html#create-a-persistent-index">API
* Documentation</a>
*/
public class PersistentIndexOptions {
public class PersistentIndexOptions extends IndexOptions {

private Iterable<String> fields;
protected IndexType type = IndexType.persistent;
private String name;
private Boolean unique;
private Boolean sparse;

Expand Down Expand Up @@ -72,20 +71,6 @@ public PersistentIndexOptions unique(final Boolean unique) {
return this;
}

/**
* @param name
* the name of the index
* @return options
*/
public PersistentIndexOptions name(final String name) {
this.name = name;
return this;
}

protected String getName() {
return name;
}

public Boolean getSparse() {
return sparse;
}
Expand Down
18 changes: 1 addition & 17 deletions src/main/java/com/arangodb/model/SkiplistIndexOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@
*
* @see <a href="https://docs.arangodb.com/current/HTTP/Indexes/Skiplist.html#create-skip-list">API Documentation</a>
*/
public class SkiplistIndexOptions {
public class SkiplistIndexOptions extends IndexOptions {

private Iterable<String> fields;
private final IndexType type = IndexType.skiplist;
private Boolean unique;
private Boolean sparse;
private Boolean deduplicate;
private String name;

public SkiplistIndexOptions() {
super();
Expand Down Expand Up @@ -99,19 +98,4 @@ public SkiplistIndexOptions deduplicate(final Boolean deduplicate) {
this.deduplicate = deduplicate;
return this;
}

/**
* @param name
* the name of the index
* @return options
*/
public SkiplistIndexOptions name(final String name) {
this.name = name;
return this;
}

protected String getName() {
return name;
}

}
8 changes: 8 additions & 0 deletions src/test/java/com/arangodb/util/ArangoSerializationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ public void serializeNullValues() {
assertThat(vpack.get("foo").isNull(), is(true));
}

@Test
public void skipSerializeNullValues() {
final BaseDocument entity = new BaseDocument();
entity.addAttribute("bar", null);
final VPackSlice vpack = util.serialize(entity);
assertThat(vpack.get("bar").isNone(), is(true));
}

@Test
public void serializeType() {
final Collection<BaseDocument> list = new ArrayList<BaseDocument>();
Expand Down