Skip to content

Commit 71e8d55

Browse files
hkernbachrashtao
authored andcommitted
added inBackground option to all indices (#286)
* added inBackground option to all indices * add info about rocksdb * fixed merge error * test vpack serialization for null values
1 parent 7626c19 commit 71e8d55

File tree

10 files changed

+87
-84
lines changed

10 files changed

+87
-84
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ public License getLicense() {
5858
return license;
5959
}
6060

61-
}
61+
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public class IndexEntity implements Entity {
4040
private Boolean geoJson;
4141
private Boolean constraint;
4242
private Boolean deduplicate;
43+
private Boolean inBackground;
4344

4445
public IndexEntity() {
4546
super();
@@ -49,6 +50,10 @@ public String getId() {
4950
return id;
5051
}
5152

53+
public Boolean getInBackground() {
54+
return inBackground;
55+
}
56+
5257
public String getName() {
5358
return name;
5459
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@
2626
*/
2727
public enum ServerRole {
2828
SINGLE, AGENT, COORDINATOR, PRIMARY, SECONDARY, UNDEFINED
29-
}
29+
}

src/main/java/com/arangodb/model/FulltextIndexOptions.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@
2828
* @see <a href="https://docs.arangodb.com/current/HTTP/Indexes/Fulltext.html#create-fulltext-index">API
2929
* Documentation</a>
3030
*/
31-
public class FulltextIndexOptions {
31+
public class FulltextIndexOptions extends IndexOptions {
3232

3333
private Iterable<String> fields;
3434
private final IndexType type = IndexType.fulltext;
3535
private Integer minLength;
36-
private String name;
3736

3837
public FulltextIndexOptions() {
3938
super();
@@ -61,20 +60,6 @@ public Integer getMinLength() {
6160
return minLength;
6261
}
6362

64-
/**
65-
* @param name
66-
* the name of the index
67-
* @return options
68-
*/
69-
public FulltextIndexOptions name(final String name) {
70-
this.name = name;
71-
return this;
72-
}
73-
74-
protected String getName() {
75-
return name;
76-
}
77-
7863
/**
7964
* @param minLength
8065
* Minimum character length of words to index. Will default to a server-defined value if unspecified. It

src/main/java/com/arangodb/model/GeoIndexOptions.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@
2727
*
2828
* @see <a href="https://docs.arangodb.com/current/HTTP/Indexes/Geo.html#create-geospatial-index">API Documentation</a>
2929
*/
30-
public class GeoIndexOptions {
30+
public class GeoIndexOptions extends IndexOptions {
3131

3232
private Iterable<String> fields;
3333
private final IndexType type = IndexType.geo;
3434
private Boolean geoJson;
35-
private String name;
3635

3736
public GeoIndexOptions() {
3837
super();
@@ -56,20 +55,6 @@ protected IndexType getType() {
5655
return type;
5756
}
5857

59-
/**
60-
* @param name
61-
* the name of the index
62-
* @return options
63-
*/
64-
public GeoIndexOptions name(final String name) {
65-
this.name = name;
66-
return this;
67-
}
68-
69-
protected String getName() {
70-
return name;
71-
}
72-
7358
public Boolean getGeoJson() {
7459
return geoJson;
7560
}

src/main/java/com/arangodb/model/HashIndexOptions.java

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,13 @@
2727
*
2828
* @see <a href="https://docs.arangodb.com/current/HTTP/Indexes/Hash.html#create-hash-index">API Documentation</a>
2929
*/
30-
public class HashIndexOptions {
30+
public class HashIndexOptions extends IndexOptions {
3131

3232
private Iterable<String> fields;
3333
private final IndexType type = IndexType.hash;
3434
private Boolean unique;
3535
private Boolean sparse;
3636
private Boolean deduplicate;
37-
private String name;
3837

3938
public HashIndexOptions() {
4039
super();
@@ -99,19 +98,4 @@ public HashIndexOptions deduplicate(final Boolean deduplicate) {
9998
this.deduplicate = deduplicate;
10099
return this;
101100
}
102-
103-
/**
104-
* @param name
105-
* the name of the index
106-
* @return options
107-
*/
108-
public HashIndexOptions name(final String name) {
109-
this.name = name;
110-
return this;
111-
}
112-
113-
protected String getName() {
114-
return name;
115-
}
116-
117101
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* DISCLAIMER
3+
*
4+
* Copyright 2019 ArangoDB GmbH, Cologne, Germany
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
*/
20+
21+
package com.arangodb.model;
22+
23+
import com.arangodb.entity.IndexType;
24+
25+
/**
26+
* @author Heiko Kernbach
27+
*
28+
* This class is used for all index similarities
29+
*/
30+
public class IndexOptions {
31+
32+
private Boolean inBackground;
33+
private String name;
34+
35+
public IndexOptions() {
36+
super();
37+
}
38+
39+
/**
40+
* @param inBackground
41+
* create the the index in the background
42+
* this is a RocksDB only flag.
43+
* @return options
44+
*/
45+
public IndexOptions inBackground(final Boolean inBackground) {
46+
this.inBackground = inBackground;
47+
return this;
48+
}
49+
50+
public Boolean getInBackground() {
51+
return inBackground;
52+
}
53+
54+
/**
55+
* @param name
56+
* the name of the index
57+
* @return options
58+
*/
59+
public IndexOptions name(final String name) {
60+
this.name = name;
61+
return this;
62+
}
63+
64+
protected String getName() {
65+
return name;
66+
}
67+
}

src/main/java/com/arangodb/model/PersistentIndexOptions.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@
2828
* @see <a href="https://docs.arangodb.com/current/HTTP/Indexes/Persistent.html#create-a-persistent-index">API
2929
* Documentation</a>
3030
*/
31-
public class PersistentIndexOptions {
31+
public class PersistentIndexOptions extends IndexOptions {
3232

3333
private Iterable<String> fields;
3434
protected IndexType type = IndexType.persistent;
35-
private String name;
3635
private Boolean unique;
3736
private Boolean sparse;
3837

@@ -72,20 +71,6 @@ public PersistentIndexOptions unique(final Boolean unique) {
7271
return this;
7372
}
7473

75-
/**
76-
* @param name
77-
* the name of the index
78-
* @return options
79-
*/
80-
public PersistentIndexOptions name(final String name) {
81-
this.name = name;
82-
return this;
83-
}
84-
85-
protected String getName() {
86-
return name;
87-
}
88-
8974
public Boolean getSparse() {
9075
return sparse;
9176
}

src/main/java/com/arangodb/model/SkiplistIndexOptions.java

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,13 @@
2727
*
2828
* @see <a href="https://docs.arangodb.com/current/HTTP/Indexes/Skiplist.html#create-skip-list">API Documentation</a>
2929
*/
30-
public class SkiplistIndexOptions {
30+
public class SkiplistIndexOptions extends IndexOptions {
3131

3232
private Iterable<String> fields;
3333
private final IndexType type = IndexType.skiplist;
3434
private Boolean unique;
3535
private Boolean sparse;
3636
private Boolean deduplicate;
37-
private String name;
3837

3938
public SkiplistIndexOptions() {
4039
super();
@@ -99,19 +98,4 @@ public SkiplistIndexOptions deduplicate(final Boolean deduplicate) {
9998
this.deduplicate = deduplicate;
10099
return this;
101100
}
102-
103-
/**
104-
* @param name
105-
* the name of the index
106-
* @return options
107-
*/
108-
public SkiplistIndexOptions name(final String name) {
109-
this.name = name;
110-
return this;
111-
}
112-
113-
protected String getName() {
114-
return name;
115-
}
116-
117101
}

src/test/java/com/arangodb/util/ArangoSerializationTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ public void serializeNullValues() {
7676
assertThat(vpack.get("foo").isNull(), is(true));
7777
}
7878

79+
@Test
80+
public void skipSerializeNullValues() {
81+
final BaseDocument entity = new BaseDocument();
82+
entity.addAttribute("bar", null);
83+
final VPackSlice vpack = util.serialize(entity);
84+
assertThat(vpack.get("bar").isNone(), is(true));
85+
}
86+
7987
@Test
8088
public void serializeType() {
8189
final Collection<BaseDocument> list = new ArrayList<BaseDocument>();

0 commit comments

Comments
 (0)