Skip to content
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

Gh 105 improvements #106

Merged
merged 8 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
26 changes: 26 additions & 0 deletions builtin-adapter/BuiltinAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,32 @@ JNIEXPORT jobject JNICALL Java_ru_rt_restream_reindexer_binding_builtin_BuiltinA
return res;
}

JNIEXPORT jobject JNICALL Java_ru_rt_restream_reindexer_binding_builtin_BuiltinAdapter_updateIndex(JNIEnv *env, jobject,
jlong rx, jlong ctxId,
jlong timeout,
jstring namespaceName,
jstring indexJson) {
reindexer_string nsName = rx_string(env, namespaceName);
reindexer_string indexDefJson = rx_string(env, indexJson);
jobject res = j_res(env, reindexer_update_index(rx, nsName, indexDefJson, rx_ctx(ctxId, timeout)));
env->ReleaseStringUTFChars(namespaceName, reinterpret_cast<const char *>(nsName.p));
env->ReleaseStringUTFChars(indexJson, reinterpret_cast<const char *>(indexDefJson.p));
return res;
}

JNIEXPORT jobject JNICALL Java_ru_rt_restream_reindexer_binding_builtin_BuiltinAdapter_dropIndex(JNIEnv *env, jobject,
jlong rx, jlong ctxId,
jlong timeout,
jstring namespaceName,
jstring indexName) {
reindexer_string nsName = rx_string(env, namespaceName);
reindexer_string index = rx_string(env, indexName);
jobject res = j_res(env, reindexer_drop_index(rx, nsName, index, rx_ctx(ctxId, timeout)));
env->ReleaseStringUTFChars(namespaceName, reinterpret_cast<const char *>(nsName.p));
env->ReleaseStringUTFChars(indexName, reinterpret_cast<const char *>(index.p));
return res;
}

JNIEXPORT jobject JNICALL Java_ru_rt_restream_reindexer_binding_builtin_BuiltinAdapter_modifyItem(JNIEnv *env, jobject,
jlong rx, jlong ctxId,
jlong timeout,
Expand Down
8 changes: 8 additions & 0 deletions builtin-adapter/BuiltinAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ JNIEXPORT jobject JNICALL Java_ru_rt_restream_reindexer_binding_builtin_BuiltinA
jlong, jlong, jlong,
jstring, jstring);

JNIEXPORT jobject JNICALL Java_ru_rt_restream_reindexer_binding_builtin_BuiltinAdapter_updateIndex(JNIEnv *, jobject,
jlong, jlong, jlong,
jstring, jstring);

JNIEXPORT jobject JNICALL Java_ru_rt_restream_reindexer_binding_builtin_BuiltinAdapter_dropIndex(JNIEnv *, jobject,
jlong, jlong, jlong,
jstring, jstring);

JNIEXPORT jobject JNICALL Java_ru_rt_restream_reindexer_binding_builtin_BuiltinAdapter_modifyItem(JNIEnv *, jobject,
jlong, jlong, jlong,
jbyteArray,
Expand Down
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,12 @@
<version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.34</version>
<scope>provided</scope>
</dependency>
</dependencies>

</project>
26 changes: 26 additions & 0 deletions src/main/java/ru/rt/restream/reindexer/Reindexer.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,32 @@ public <T> Query<T> query(String namespaceName, Class<T> clazz) {
return new Query<>(this, namespace, null);
}

/**
* ONLY FOR TEST PURPOSES!
*/
@Deprecated
public void addIndex(String namespaceName, ReindexerIndex index) {
IndexDefinition indexDefinition = IndexDefinition.fromIndex(index);
binding.addIndex(namespaceName, indexDefinition);
}

/**
* ONLY FOR TEST PURPOSES!
*/
@Deprecated
public void updateIndex(String namespaceName, ReindexerIndex index) {
IndexDefinition indexDefinition = IndexDefinition.fromIndex(index);
binding.updateIndex(namespaceName, indexDefinition);
}

/**
* ONLY FOR TEST PURPOSES!
*/
@Deprecated
public void dropIndex(String namespaceName, String indexName) {
binding.dropIndex(namespaceName, indexName);
}

private <T> ReindexerNamespace<T> getNamespace(String namespaceName, Class<T> itemClass) {
ReindexerNamespace<?> namespace = namespaceMap.get(namespaceName);
if (namespace == null) {
Expand Down
248 changes: 22 additions & 226 deletions src/main/java/ru/rt/restream/reindexer/ReindexerIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,23 @@
*/
package ru.rt.restream.reindexer;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import ru.rt.restream.reindexer.fulltext.FullTextConfig;

import java.util.List;

/**
* Contains the reindexer index configuration.
*/
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ReindexerIndex {

private String name;
Expand All @@ -36,12 +46,23 @@ public class ReindexerIndex {

private String sortOrder;

/**
* Full text search config for current index.
* Type of index must be TEXT.
*/
private FullTextConfig fullTextConfig;

/**
* Precept is a special reindexer embedded function, such as serial(), now().
* {@link ru.rt.restream.reindexer.annotations.Serial}
*/
private String precept;

private boolean isArray;

/**
* Indication, that the current index is a primary key.
*/
private boolean isPk;

private boolean isDense;
Expand All @@ -50,123 +71,7 @@ public class ReindexerIndex {

private boolean isUuid;

/**
* Get the current index name.
*
* @return the current index name
*/
public String getName() {
return name;
}

/**
* Set the current index name.
*
* @param name the index name
*/
public void setName(String name) {
this.name = name;
}

/**
* Get the current index json paths.
*
* @return the current index json paths
*/
public List<String> getJsonPaths() {
return jsonPaths;
}

/**
* Set the current index json paths.
*
* @param jsonPaths the index json paths
*/
public void setJsonPaths(List<String> jsonPaths) {
this.jsonPaths = jsonPaths;
}

/**
* Get the current index type. {@link IndexType}
*
* @return the current index type
*/
public IndexType getIndexType() {
return indexType;
}

/**
* Set the current index type. {@link IndexType}
*
* @param indexType the index type
*/
public void setIndexType(IndexType indexType) {
this.indexType = indexType;
}

/**
* Get the current index field type. {@link FieldType}
*
* @return the current index field type
*/
public FieldType getFieldType() {
return fieldType;
}

/**
* Set the current index field type. {@link FieldType}
*
* @param fieldType the index field type
*/
public void setFieldType(FieldType fieldType) {
this.fieldType = fieldType;
}

/**
* Get the current index collate mode. {@link CollateMode}
*
* @return the current index collate mode
*/
public CollateMode getCollateMode() {
return collateMode;
}

/**
* Set the current index collate mode. {@link CollateMode}
*
* @param collateMode the index collate mode
*/
public void setCollateMode(CollateMode collateMode) {
this.collateMode = collateMode;
}

/**
* Get the current index sort order.
*
* @return the current index sort order string
*/
public String getSortOrder() {
return sortOrder;
}

/**
* Set the current index sort order.
*
* @param sortOrder the sequence of letters, which defines the index sort order
*/
public void setSortOrder(String sortOrder) {
this.sortOrder = sortOrder;
}

/**
* Get full text search config for current index.
* Type of index must be TEXT.
*
* @return full text search config
*/
public FullTextConfig getFullTextConfig() {
return fullTextConfig;
}
private boolean isAppendable;

/**
* Set full text search config for current index, if the index is text index.
Expand All @@ -181,113 +86,4 @@ public void setFullTextConfig(FullTextConfig fullTextConfig) {
this.fullTextConfig = fullTextConfig;
}

/**
* Get the current index precept. Precept is a special reindexer embedded function, such as serial(), now().
* {@link ru.rt.restream.reindexer.annotations.Serial}
*
* @return the current index precept
*/
public String getPrecept() {
return precept;
}

/**
* Set the current index precepts. Precept is a special reindexer embedded function, such as serial(), now().
* {@link ru.rt.restream.reindexer.annotations.Serial}
*
* @param precept the index precept
*/
public void setPrecept(String precept) {
this.precept = precept;
}

/**
* Get the indication, that the current index is array.
*
* @return true, if the current index is array
*/
public boolean isArray() {
return isArray;
}

/**
* Set the indication, that the current index is array.
*
* @param array true, if the current index is array
*/
public void setArray(boolean array) {
isArray = array;
}

/**
* Get the indication, that the current index is a primary key.
*
* @return true, if the current index is a primary key
*/
public boolean isPk() {
return isPk;
}

/**
* Set the indication, that the current index is a primary key.
*
* @param pk true, if the current index is a primary key
*/
public void setPk(boolean pk) {
isPk = pk;
}

/**
* Get the indication, that the current index is dense.
*
* @return true, if the current index is dense
*/
public boolean isDense() {
return isDense;
}

/**
* Set the indication, that the current index is dense.
*
* @param dense true, if the current index is dense
*/
public void setDense(boolean dense) {
isDense = dense;
}

/**
* Get the indication, that the current index is sparse.
*
* @return true, if the current index is sparse
*/
public boolean isSparse() {
return isSparse;
}

/**
* Set the indication, that the current index is sparse.
*
* @param sparse true, if the current index is sparse
*/
public void setSparse(boolean sparse) {
isSparse = sparse;
}

/**
* Get the indication, that the current index is for UUID.
*
* @return true, if the current index is for UUID
*/
public boolean isUuid() {
return isUuid;
}

/**
* Set the indication, that the current index is for UUID.
*
* @param uuid true, if the current index is for UUID
*/
public void setUuid(boolean uuid) {
isUuid = uuid;
}
}
Loading
Loading