Skip to content

Commit 262568f

Browse files
committed
primarySortCompression
1 parent d7bf6dc commit 262568f

File tree

8 files changed

+89
-6
lines changed

8 files changed

+89
-6
lines changed

ChangeLog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
66

77
## [Unreleased]
88

9-
- support `overwriteMode` values `ignore` and `conflict` (ArangoDB v3.7)
9+
- support for `ArangoSearchProperties` value `primarySortCompression` (ArangoDB v3.7)
10+
- support for `overwriteMode` values `ignore` and `conflict` (ArangoDB v3.7)
1011

1112
## [6.6.3] - 2020-05-06
1213

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* DISCLAIMER
3+
*
4+
* Copyright 2016 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.entity.arangosearch;
22+
23+
24+
/**
25+
* @author Michele Rastelli
26+
*/
27+
public enum ArangoSearchCompression {
28+
lz4("lz4"),
29+
none("none");
30+
31+
private final String value;
32+
33+
ArangoSearchCompression(String value) {
34+
this.value = value;
35+
}
36+
37+
public String getValue() {
38+
return value;
39+
}
40+
41+
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class ArangoSearchProperties {
3636
private ConsolidationPolicy consolidationPolicy;
3737
private final Collection<PrimarySort> primarySorts;
3838
private final Collection<CollectionLink> links;
39+
private ArangoSearchCompression primarySortCompression;
3940

4041
public ArangoSearchProperties() {
4142
super();
@@ -90,4 +91,13 @@ public Collection<PrimarySort> getPrimarySort() {
9091
public void addPrimarySort(final PrimarySort... primarySorts) {
9192
this.primarySorts.addAll(Arrays.asList(primarySorts));
9293
}
94+
95+
public ArangoSearchCompression getPrimarySortCompression() {
96+
return primarySortCompression;
97+
}
98+
99+
public void setPrimarySortCompression(ArangoSearchCompression primarySortCompression) {
100+
this.primarySortCompression = primarySortCompression;
101+
}
102+
93103
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,12 @@ public Collection<CollectionLink> getLinks() {
9494
public Collection<PrimarySort> getPrimarySort() {
9595
return properties.getPrimarySort();
9696
}
97+
98+
/**
99+
* @return how to compress the primary sort data
100+
*/
101+
public ArangoSearchCompression getPrimarySortCompression() {
102+
return properties.getPrimarySortCompression();
103+
}
104+
97105
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@ public class VPackDeserializers {
200200
}
201201
}
202202

203+
final VPackSlice primarySortCompression = vpack.get("primarySortCompression");
204+
if (primarySortCompression.isString()) {
205+
properties.setPrimarySortCompression(ArangoSearchCompression.valueOf(primarySortCompression.getAsString()));
206+
}
207+
203208
return properties;
204209
};
205210

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,12 @@ public class VPackSerializers {
187187
}
188188
builder.close(); // close array
189189
}
190+
191+
final ArangoSearchCompression primarySortCompression = value.getPrimarySortCompression();
192+
if (primarySortCompression != null) {
193+
builder.add("primarySortCompression", primarySortCompression.getValue());
194+
}
195+
190196
};
191197

192198
private static void serializeFieldLinks(final VPackBuilder builder, final Collection<FieldLink> links) {

src/main/java/com/arangodb/model/arangosearch/ArangoSearchCreateOptions.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@
2121
package com.arangodb.model.arangosearch;
2222

2323
import com.arangodb.entity.ViewType;
24-
import com.arangodb.entity.arangosearch.ArangoSearchProperties;
25-
import com.arangodb.entity.arangosearch.CollectionLink;
26-
import com.arangodb.entity.arangosearch.ConsolidationPolicy;
27-
import com.arangodb.entity.arangosearch.PrimarySort;
24+
import com.arangodb.entity.arangosearch.*;
2825

2926
/**
3027
* @author Mark Vollmary
@@ -119,4 +116,14 @@ public ArangoSearchCreateOptions primarySort(final PrimarySort... primarySorts)
119116
properties.addPrimarySort(primarySorts);
120117
return this;
121118
}
119+
120+
/**
121+
* @param primarySortCompression Defines how to compress the primary sort data
122+
* @return options
123+
*/
124+
public ArangoSearchCreateOptions primarySortCompression(final ArangoSearchCompression primarySortCompression) {
125+
properties.setPrimarySortCompression(primarySortCompression);
126+
return this;
127+
}
128+
122129
}

src/test/java/com/arangodb/ArangoSearchTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,19 @@ public void createWithPrimarySort() {
133133
final PrimarySort primarySort = PrimarySort.on("myFieldName");
134134
primarySort.ascending(true);
135135
options.primarySort(primarySort);
136+
options.primarySortCompression(ArangoSearchCompression.none);
136137
options.consolidationIntervalMsec(666666L);
137138

138-
final ViewEntity info = db.arangoSearch(viewName).create(options);
139+
final ArangoSearch view = db.arangoSearch(viewName);
140+
final ViewEntity info = view.create(options);
139141
assertThat(info, is(not(nullValue())));
140142
assertThat(info.getId(), is(not(nullValue())));
141143
assertThat(info.getName(), is(viewName));
142144
assertThat(info.getType(), is(ViewType.ARANGO_SEARCH));
143145
assertThat(db.arangoSearch(viewName).exists(), is(true));
146+
147+
final ArangoSearchPropertiesEntity properties = view.getProperties();
148+
assertThat(properties.getPrimarySortCompression(), is(ArangoSearchCompression.none));
144149
}
145150

146151
@Test

0 commit comments

Comments
 (0)