Skip to content

Commit 7662457

Browse files
authored
Merge pull request #113 from steleal/gh-110_is_no_column
Closes gh-110
2 parents 3503ecf + f002e9e commit 7662457

6 files changed

Lines changed: 33 additions & 125 deletions

File tree

src/main/java/ru/rt/restream/reindexer/ReindexerIndex.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ public class ReindexerIndex {
9999

100100
private boolean isDense;
101101

102+
private boolean isNoColumn;
103+
102104
private boolean isSparse;
103105

104106
private boolean isUuid;

src/main/java/ru/rt/restream/reindexer/annotations/Reindex.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@
5757
*/
5858
boolean isDense() default false;
5959

60+
/**
61+
* Reduces the index size. Allows to save ~(`stored_type_size` * `namespace_items_count`) bytes,
62+
* where `stored_type_size` is the size of the type stored in the index, and `namespace_items_count`
63+
* is the number of items in the namespace. May reduce performance.
64+
*
65+
* @return true, if index
66+
*/
67+
boolean isNoColumn() default false;
68+
6069
/**
6170
* Row (document) contains a value of Sparse index only in case if it's set on purpose - there are no empty
6271
* (or default) records of this type of indexes in the row (document). It allows to save RAM but it will cost you

src/main/java/ru/rt/restream/reindexer/annotations/ReindexAnnotationScanner.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ && getFieldTypeByClass(fieldInfo.componentType) == COMPOSITE) {
163163
ReindexerIndex index = createIndex(reindexPath, Collections.singletonList(jsonPath), indexType,
164164
fieldType, reindex.isDense(), reindex.isSparse(), reindex.isPrimaryKey(),
165165
fieldInfo.isArray, collateMode, sortOrder, precept, fullTextConfig, isUuid, reindex.isAppendable(),
166-
hnswConfig, ivfConfig, vecBfConfig);
166+
reindex.isNoColumn(), hnswConfig, ivfConfig, vecBfConfig);
167167

168168
ReindexerIndex sameNameIndex = nameToIndexMap.get(reindex.name());
169169
if (sameNameIndex == null) {
@@ -199,7 +199,7 @@ && getFieldTypeByClass(fieldInfo.componentType) == COMPOSITE) {
199199
ReindexerIndex compositeIndex = createIndex(String.join("+", composite.subIndexes()),
200200
Arrays.asList(composite.subIndexes()), composite.type(), COMPOSITE, composite.isDense(),
201201
composite.isSparse(), composite.isPrimaryKey(), false, collateMode, sortOrder, null, null, false,
202-
false, null, null, null);
202+
false, composite.isNoColumn(), null, null, null);
203203
indexes.add(compositeIndex);
204204
}
205205

@@ -317,7 +317,7 @@ private ReindexerIndex createIndex(String reindexPath, List<String> jsonPath, In
317317
FieldType fieldType, boolean isDense, boolean isSparse, boolean isPk,
318318
boolean isArray, CollateMode collateMode, String sortOrder, String precept,
319319
FullTextConfig textConfig, boolean isUuid, boolean isAppendable,
320-
HnswConfig hnswConfig, IvfConfig ivfConfig, VecBfConfig vecBfConfig) {
320+
boolean isNoColumn, HnswConfig hnswConfig, IvfConfig ivfConfig, VecBfConfig vecBfConfig) {
321321
ReindexerIndex index = new ReindexerIndex();
322322
index.setName(reindexPath);
323323
index.setSortOrder(sortOrder);
@@ -336,6 +336,7 @@ private ReindexerIndex createIndex(String reindexPath, List<String> jsonPath, In
336336
index.setConfig(vecBfConfig);
337337
index.setUuid(isUuid);
338338
index.setAppendable(isAppendable);
339+
index.setNoColumn(isNoColumn);
339340
return index;
340341
}
341342

src/main/java/ru/rt/restream/reindexer/binding/definition/IndexDefinition.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public class IndexDefinition {
5656

5757
private IndexConfig config;
5858

59+
private boolean isNoColumn;
60+
5961
/**
6062
* Construct a new IndexDefinition from a {@link ReindexerIndex} object.
6163
*
@@ -68,6 +70,7 @@ public static IndexDefinition fromIndex(ReindexerIndex index) {
6870
indexDefinition.setCollateMode(index.getCollateMode().getName());
6971
indexDefinition.setSortOrder(index.getSortOrder());
7072
indexDefinition.setDense(index.isDense());
73+
indexDefinition.setNoColumn(index.isNoColumn());
7174
indexDefinition.setFieldType(index.getFieldType().getName());
7275
indexDefinition.setIndexType(index.getIndexType().getName());
7376
indexDefinition.setArray(index.isArray());

src/test/java/ru/rt/restream/reindexer/connector/CprotoReindexerTest.java

Lines changed: 14 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import com.google.gson.Gson;
2020
import com.google.gson.GsonBuilder;
2121
import com.google.gson.annotations.SerializedName;
22+
import lombok.Getter;
23+
import lombok.Setter;
2224
import org.apache.http.client.methods.CloseableHttpResponse;
2325
import org.apache.http.client.methods.HttpGet;
2426
import org.apache.http.impl.client.CloseableHttpClient;
@@ -63,6 +65,12 @@ public void testOpenNamespace() {
6365
assertThat(nameIdx.isPk, is(false));
6466
assertThat(nameIdx.name, is("name"));
6567
assertThat(nameIdx.fieldType, is("string"));
68+
NamespaceResponse.IndexResponse valueIdx = indexes.get(7);
69+
assertThat(valueIdx.isPk, is(false));
70+
assertThat(valueIdx.name, is("value"));
71+
assertThat(valueIdx.fieldType, is("string"));
72+
assertThat(valueIdx.isSparse, is(true));
73+
assertThat(valueIdx.isNoColumn, is(true));
6674
}
6775

6876
@Test
@@ -96,6 +104,8 @@ private <T> T get(String path, Class<T> clazz) {
96104
}
97105
}
98106

107+
@Getter
108+
@Setter
99109
private static class NamespaceResponse {
100110
private String name;
101111
private StorageResponse storage;
@@ -105,30 +115,8 @@ private static class StorageResponse {
105115
private boolean enabled;
106116
}
107117

108-
public String getName() {
109-
return name;
110-
}
111-
112-
public void setName(String name) {
113-
this.name = name;
114-
}
115-
116-
public StorageResponse getStorage() {
117-
return storage;
118-
}
119-
120-
public void setStorage(StorageResponse storage) {
121-
this.storage = storage;
122-
}
123-
124-
public List<IndexResponse> getIndexes() {
125-
return indexes;
126-
}
127-
128-
public void setIndexes(List<IndexResponse> indexes) {
129-
this.indexes = indexes;
130-
}
131-
118+
@Getter
119+
@Setter
132120
private static class IndexResponse {
133121
private String name;
134122
@SerializedName("json_paths")
@@ -145,6 +133,8 @@ private static class IndexResponse {
145133
private boolean isDense;
146134
@SerializedName("is_sparse")
147135
private boolean isSparse;
136+
@SerializedName("is_no_column")
137+
private boolean isNoColumn;
148138
@SerializedName("is_linear")
149139
private boolean isLinear;
150140
@SerializedName("is_simple_tag")
@@ -153,103 +143,6 @@ private static class IndexResponse {
153143
private String collateMode;
154144
@SerializedName("sort_order_letters")
155145
private String sortOrderLetters;
156-
157-
public String getName() {
158-
return name;
159-
}
160-
161-
public void setName(String name) {
162-
this.name = name;
163-
}
164-
165-
public List<String> getJsonPaths() {
166-
return jsonPaths;
167-
}
168-
169-
public void setJsonPaths(List<String> jsonPaths) {
170-
this.jsonPaths = jsonPaths;
171-
}
172-
173-
public String getFieldType() {
174-
return fieldType;
175-
}
176-
177-
public void setFieldType(String fieldType) {
178-
this.fieldType = fieldType;
179-
}
180-
181-
public String getIndexType() {
182-
return indexType;
183-
}
184-
185-
public void setIndexType(String indexType) {
186-
this.indexType = indexType;
187-
}
188-
189-
public boolean isPk() {
190-
return isPk;
191-
}
192-
193-
public void setPk(boolean pk) {
194-
isPk = pk;
195-
}
196-
197-
public boolean isArray() {
198-
return isArray;
199-
}
200-
201-
public void setArray(boolean array) {
202-
isArray = array;
203-
}
204-
205-
public boolean isDense() {
206-
return isDense;
207-
}
208-
209-
public void setDense(boolean dense) {
210-
isDense = dense;
211-
}
212-
213-
public boolean isSparse() {
214-
return isSparse;
215-
}
216-
217-
public void setSparse(boolean sparse) {
218-
isSparse = sparse;
219-
}
220-
221-
public boolean isLinear() {
222-
return isLinear;
223-
}
224-
225-
public void setLinear(boolean linear) {
226-
isLinear = linear;
227-
}
228-
229-
public boolean isSimpleTag() {
230-
return isSimpleTag;
231-
}
232-
233-
public void setSimpleTag(boolean simpleTag) {
234-
isSimpleTag = simpleTag;
235-
}
236-
237-
public String getCollateMode() {
238-
return collateMode;
239-
}
240-
241-
public void setCollateMode(String collateMode) {
242-
this.collateMode = collateMode;
243-
}
244-
245-
public String getSortOrderLetters() {
246-
return sortOrderLetters;
247-
}
248-
249-
public void setSortOrderLetters(String sortOrderLetters) {
250-
this.sortOrderLetters = sortOrderLetters;
251-
}
252146
}
253147
}
254-
255148
}

src/test/java/ru/rt/restream/reindexer/connector/ReindexerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2833,7 +2833,7 @@ public static class TestItem {
28332833
private Integer id;
28342834
@Reindex(name = "name")
28352835
private String name;
2836-
@Reindex(name = "value", isSparse = true)
2836+
@Reindex(name = "value", isSparse = true, isNoColumn = true)
28372837
private String value;
28382838
private String nonIndex;
28392839
@Reindex(name = "nestedTest")

0 commit comments

Comments
 (0)