Skip to content

Commit

Permalink
Polishing #1
Browse files Browse the repository at this point in the history
  • Loading branch information
tishun committed Feb 3, 2025
1 parent 986cab7 commit dada00e
Show file tree
Hide file tree
Showing 16 changed files with 93 additions and 105 deletions.
4 changes: 2 additions & 2 deletions src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import io.lettuce.core.protocol.CommandType;
import io.lettuce.core.protocol.ProtocolKeyword;
import io.lettuce.core.protocol.RedisCommand;
import io.lettuce.core.search.Fields;
import io.lettuce.core.search.Field;
import io.lettuce.core.search.arguments.CreateArgs;
import reactor.core.publisher.Mono;

Expand Down Expand Up @@ -1485,7 +1485,7 @@ public boolean isOpen() {
}

@Override
public RedisFuture<String> ftCreate(K index, CreateArgs<K, V> options, Fields<K> fields) {
public RedisFuture<String> ftCreate(K index, CreateArgs<K, V> options, List<Field<K>> fields) {
return dispatch(searchCommandBuilder.ftCreate(index, options, fields));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import io.lettuce.core.protocol.RedisCommand;
import io.lettuce.core.protocol.TracedCommand;
import io.lettuce.core.resource.ClientResources;
import io.lettuce.core.search.Fields;
import io.lettuce.core.search.Field;
import io.lettuce.core.search.arguments.CreateArgs;
import io.lettuce.core.tracing.TraceContext;
import io.lettuce.core.tracing.TraceContextProvider;
Expand Down Expand Up @@ -1549,7 +1549,7 @@ public boolean isOpen() {
}

@Override
public Mono<String> ftCreate(K index, CreateArgs<K, V> options, Fields<K> fields) {
public Mono<String> ftCreate(K index, CreateArgs<K, V> options, List<Field<K>> fields) {
return createMono(() -> searchCommandBuilder.ftCreate(index, options, fields));
}

Expand Down
9 changes: 5 additions & 4 deletions src/main/java/io/lettuce/core/RediSearchCommandBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
import io.lettuce.core.protocol.Command;
import io.lettuce.core.protocol.CommandArgs;
import io.lettuce.core.protocol.CommandKeyword;
import io.lettuce.core.search.Fields;
import io.lettuce.core.search.arguments.CreateArgs;
import io.lettuce.core.search.Field;

import java.util.List;

import static io.lettuce.core.protocol.CommandType.*;

/**
Expand All @@ -39,9 +40,9 @@ class RediSearchCommandBuilder<K, V> extends BaseRedisCommandBuilder<K, V> {
* @param fields the fields
* @return the result of the create command
*/
public Command<K, V, String> ftCreate(K index, CreateArgs<K, V> createArgs, Fields<K> fields) {
public Command<K, V, String> ftCreate(K index, CreateArgs<K, V> createArgs, List<Field<K>> fields) {
notNullKey(index);
notEmpty(fields.getFields().toArray());
notEmpty(fields.toArray());

CommandArgs<K, V> args = new CommandArgs<>(codec).addKey(index);

Expand All @@ -51,7 +52,7 @@ public Command<K, V, String> ftCreate(K index, CreateArgs<K, V> createArgs, Fiel

args.add(CommandKeyword.SCHEMA);

for (Field<K> field : fields.getFields()) {
for (Field<K> field : fields) {
field.build(args);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
*/
package io.lettuce.core.api.async;

import java.util.List;
import io.lettuce.core.RedisFuture;
import io.lettuce.core.search.Fields;
import io.lettuce.core.search.Field;
import io.lettuce.core.search.arguments.CreateArgs;

/**
Expand All @@ -23,13 +24,15 @@
public interface RediSearchAsyncCommands<K, V> {

/**
* Create a new index with the given name, index options and fields.
* Create a new index with the given name, index options, and fields.
*
* @param index the index name
* @param options the index options
* @param fields the fields
* @param index the index name, as a key
* @param options the index {@link CreateArgs}
* @param fields the {@link Field}s of the index
* @return the result of the create command
* @since 6.6
* @see <a href="https://redis.io/docs/latest/commands/ft.create/">FT.CREATE</a>
*/
RedisFuture<String> ftCreate(K index, CreateArgs<K, V> options, Fields<K> fields);
RedisFuture<String> ftCreate(K index, CreateArgs<K, V> options, List<Field<K>> fields);

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/
package io.lettuce.core.api.reactive;

import java.util.List;
import io.lettuce.core.search.Field;
import io.lettuce.core.search.Fields;
import io.lettuce.core.search.arguments.CreateArgs;
import reactor.core.publisher.Mono;

Expand All @@ -24,13 +24,15 @@
public interface RediSearchReactiveCommands<K, V> {

/**
* Create a new index with the given name, index options and fields.
* Create a new index with the given name, index options, and fields.
*
* @param index the index name
* @param options the index options
* @param fields the fields
* @param index the index name, as a key
* @param options the index {@link CreateArgs}
* @param fields the {@link Field}s of the index
* @return the result of the create command
* @since 6.6
* @see <a href="https://redis.io/docs/latest/commands/ft.create/">FT.CREATE</a>
*/
Mono<String> ftCreate(K index, CreateArgs<K, V> options, Fields<K> fields);
Mono<String> ftCreate(K index, CreateArgs<K, V> options, List<Field<K>> fields);

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@
* @author Mark Paluch
* @since 5.0
*/
public interface RedisReactiveCommands<K, V> extends BaseRedisReactiveCommands<K, V>, RedisAclReactiveCommands<K, V>,
RedisClusterReactiveCommands<K, V>, RedisFunctionReactiveCommands<K, V>, RedisGeoReactiveCommands<K, V>,
RedisHashReactiveCommands<K, V>, RedisHLLReactiveCommands<K, V>, RedisKeyReactiveCommands<K, V>,
RedisListReactiveCommands<K, V>, RedisScriptingReactiveCommands<K, V>, RedisServerReactiveCommands<K, V>,
RedisSetReactiveCommands<K, V>, RedisSortedSetReactiveCommands<K, V>, RedisStreamReactiveCommands<K, V>,
RedisStringReactiveCommands<K, V>, RedisTransactionalReactiveCommands<K, V>, RedisJsonReactiveCommands<K, V> {
public interface RedisReactiveCommands<K, V>
extends BaseRedisReactiveCommands<K, V>, RedisAclReactiveCommands<K, V>, RedisClusterReactiveCommands<K, V>,
RedisFunctionReactiveCommands<K, V>, RedisGeoReactiveCommands<K, V>, RedisHashReactiveCommands<K, V>,
RedisHLLReactiveCommands<K, V>, RedisKeyReactiveCommands<K, V>, RedisListReactiveCommands<K, V>,
RedisScriptingReactiveCommands<K, V>, RedisServerReactiveCommands<K, V>, RedisSetReactiveCommands<K, V>,
RedisSortedSetReactiveCommands<K, V>, RedisStreamReactiveCommands<K, V>, RedisStringReactiveCommands<K, V>,
RedisTransactionalReactiveCommands<K, V>, RedisJsonReactiveCommands<K, V>, RediSearchReactiveCommands<K, V> {

/**
* Authenticate to the server.
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/io/lettuce/core/api/sync/RediSearchCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
*/
package io.lettuce.core.api.sync;

import io.lettuce.core.search.Fields;
import java.util.List;
import io.lettuce.core.search.Field;
import io.lettuce.core.search.arguments.CreateArgs;

/**
Expand All @@ -22,13 +23,15 @@
public interface RediSearchCommands<K, V> {

/**
* Create a new index with the given name, index options and fields.
* Create a new index with the given name, index options, and fields.
*
* @param index the index name
* @param options the index options
* @param fields the fields
* @param index the index name, as a key
* @param options the index {@link CreateArgs}
* @param fields the {@link Field}s of the index
* @return the result of the create command
* @since 6.6
* @see <a href="https://redis.io/docs/latest/commands/ft.create/">FT.CREATE</a>
*/
String ftCreate(K index, CreateArgs<K, V> options, Fields<K> fields);
String ftCreate(K index, CreateArgs<K, V> options, List<Field<K>> fields);

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
*/
package io.lettuce.core.cluster.api.async;

import io.lettuce.core.search.Fields;
import java.util.List;
import io.lettuce.core.search.Field;
import io.lettuce.core.search.arguments.CreateArgs;

/**
Expand All @@ -22,13 +23,15 @@
public interface RediSearchAsyncCommands<K, V> {

/**
* Create a new index with the given name, index options and fields.
* Create a new index with the given name, index options, and fields.
*
* @param index the index name
* @param options the index options
* @param fields the fields
* @param index the index name, as a key
* @param options the index {@link CreateArgs}
* @param fields the {@link Field}s of the index
* @return the result of the create command
* @since 6.6
* @see <a href="https://redis.io/docs/latest/commands/ft.create/">FT.CREATE</a>
*/
AsyncExecutions<String> ftCreate(K index, CreateArgs<K, V> options, Fields<K> fields);
AsyncExecutions<String> ftCreate(K index, CreateArgs<K, V> options, List<Field<K>> fields);

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/
package io.lettuce.core.cluster.api.sync;

import java.util.List;
import io.lettuce.core.search.Field;
import io.lettuce.core.search.Fields;
import io.lettuce.core.search.arguments.CreateArgs;

/**
Expand All @@ -23,13 +23,15 @@
public interface RediSearchCommands<K, V> {

/**
* Create a new index with the given name, index options and fields.
* Create a new index with the given name, index options, and fields.
*
* @param index the index name
* @param options the index options
* @param fields the fields
* @param index the index name, as a key
* @param options the index {@link CreateArgs}
* @param fields the {@link Field}s of the index
* @return the result of the create command
* @since 6.6
* @see <a href="https://redis.io/docs/latest/commands/ft.create/">FT.CREATE</a>
*/
Executions<String> ftCreate(K index, CreateArgs<K, V> options, Fields<K> fields);
Executions<String> ftCreate(K index, CreateArgs<K, V> options, List<Field<K>> fields);

}
9 changes: 6 additions & 3 deletions src/main/java/io/lettuce/core/search/Field.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import io.lettuce.core.protocol.CommandArgs;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import static io.lettuce.core.protocol.CommandKeyword.*;
Expand Down Expand Up @@ -359,9 +361,10 @@ public Field<K> build() {
*
* @return the instance of the {@link Field}
*/
public Fields<K> buildFields() {
Fields<K> fields = new Fields<>();
return fields.add(instance);
public List<Field<K>> buildFields() {
List<Field<K>> fields = new ArrayList<>();
fields.add(instance);
return fields;
}

}
Expand Down
39 changes: 0 additions & 39 deletions src/main/java/io/lettuce/core/search/Fields.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,8 @@ public Builder<K, V> skipInitialScan(boolean skipInitialScan) {
*
* @param stopWords a list of stop words
* @return the instance of the current {@link Builder} for the purpose of method chaining
* @see <a href="https://redis.io/docs/latest/develop/interact/search-and-query/advanced-concepts/stopwords/">Stop
* words</a>
*/
public Builder<K, V> stopWords(List<V> stopWords) {
instance.stopWords = Optional.of(stopWords);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
*
* Licensed under the MIT License.
*/

package io.lettuce.core.api.coroutines

import io.lettuce.core.ExperimentalLettuceCoroutinesApi
import io.lettuce.core.search.Fields
import kotlinx.coroutines.flow.Flow
import io.lettuce.core.search.Field
import io.lettuce.core.search.arguments.CreateArgs

/**
Expand All @@ -18,20 +20,22 @@ import io.lettuce.core.search.arguments.CreateArgs
* @author Tihomir Mateev
* @see <a href="https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/search/">RediSearch</a>
* @since 6.6
* @generated by io.lettuce.apigenerator.CreateKotlinCoroutinesApi
* @generated by io.lettuce.apigenerator.CreateKotlinCoroutinesApi
*/
@ExperimentalLettuceCoroutinesApi
interface RediSearchCoroutinesCommands<K : Any, V : Any> {

/**
* Create a new index with the given name, index options and fields.
* Create a new index with the given name, index options, and fields.
*
* @param index the index name
* @param options the index options
* @param fields the fields
* @param index the index name, as a key
* @param options the index [CreateArgs]
* @param fields the [Field]s of the index
* @return the result of the create command
* @since 6.6
* @see <a href="https://redis.io/docs/latest/commands/ft.create/">FT.CREATE</a>
*/
suspend fun ftCreate(index: K, options: CreateArgs<K, V>, fields: Fields<K>): String?
suspend fun ftCreate(index: K, options: CreateArgs<K, V>, fields: List<Field<K>>): String?

}

17 changes: 10 additions & 7 deletions src/main/templates/io/lettuce/core/api/RediSearchCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
*/
package io.lettuce.core.api;

import io.lettuce.core.search.Fields;
import io.lettuce.core.search.arguments.CreateArgs;
import io.lettuce.core.search.Field;
import io.lettuce.core.search.arguments.CreateArgs;

import java.util.List;

/**
* ${intent} for RediSearch functionality
Expand All @@ -22,13 +23,15 @@
public interface RediSearchCommands<K, V> {

/**
* Create a new index with the given name, index options and fields.
* Create a new index with the given name, index options, and fields.
*
* @param index the index name
* @param options the index options
* @param fields the fields
* @param index the index name, as a key
* @param options the index {@link CreateArgs}
* @param fields the {@link Field}s of the index
* @return the result of the create command
* @since 6.6
* @see <a href="https://redis.io/docs/latest/commands/ft.create/">FT.CREATE</a>
*/
String ftCreate(K index, CreateArgs<K, V> options, Fields<K> fields);
String ftCreate(K index, CreateArgs<K, V> options, List<Field<K>> fields);

}
Loading

0 comments on commit dada00e

Please sign in to comment.