|
1 | 1 | package org.apache.calcite.adapter.redisearch; |
2 | 2 |
|
3 | | -import com.google.common.base.Strings; |
4 | | -import com.redis.lettucemod.RedisModulesClient; |
5 | | -import com.redis.lettucemod.api.StatefulRedisModulesConnection; |
6 | | -import io.lettuce.core.RedisURI; |
| 3 | +import java.util.Map; |
| 4 | +import java.util.Objects; |
| 5 | + |
7 | 6 | import org.apache.calcite.schema.Schema; |
8 | 7 | import org.apache.calcite.schema.SchemaFactory; |
9 | 8 | import org.apache.calcite.schema.SchemaPlus; |
10 | | -import org.slf4j.Logger; |
11 | | -import org.slf4j.LoggerFactory; |
12 | 9 |
|
13 | | -import java.util.Map; |
14 | | -import java.util.Objects; |
| 10 | +import com.google.common.base.Strings; |
| 11 | +import com.redis.lettucemod.RedisModulesClient; |
| 12 | +import com.redis.lettucemod.api.StatefulRedisModulesConnection; |
15 | 13 |
|
| 14 | +import io.lettuce.core.RedisURI; |
16 | 15 |
|
17 | 16 | /** |
18 | 17 | * Factory that creates a {@link RediSearchSchema}. |
19 | 18 | */ |
20 | | -@SuppressWarnings("UnusedDeclaration") |
21 | 19 | public class RediSearchSchemaFactory implements SchemaFactory { |
22 | 20 |
|
23 | | - private static final Logger LOGGER = LoggerFactory.getLogger(RediSearchSchemaFactory.class); |
24 | | - |
25 | | - @Override |
26 | | - public Schema create(SchemaPlus parentSchema, String name, Map<String, Object> operand) { |
27 | | - Map map = operand; |
28 | | - String uri = (String) map.get("uri"); |
29 | | - String index = (String) map.get("index"); |
30 | | - String username = (String) map.get("username"); |
31 | | - String password = (String) map.get("password"); |
32 | | - return new RediSearchSchema(connect(uri, username, password), index); |
33 | | - } |
| 21 | + @Override |
| 22 | + public Schema create(SchemaPlus parentSchema, String name, Map<String, Object> operand) { |
| 23 | + Map<String, Object> map = operand; |
| 24 | + String uri = (String) map.get("uri"); |
| 25 | + String index = (String) map.get("index"); |
| 26 | + String username = (String) map.get("username"); |
| 27 | + String password = (String) map.get("password"); |
| 28 | + return new RediSearchSchema(connect(uri, username, password), index); |
| 29 | + } |
34 | 30 |
|
35 | | - private StatefulRedisModulesConnection<String, String> connect(String uri, String username, String password) { |
36 | | - Objects.requireNonNull(uri, "URI"); |
37 | | - RedisURI redisURI = RedisURI.create(uri); |
38 | | - if (!Strings.isNullOrEmpty(username) && !Strings.isNullOrEmpty(password)) { |
39 | | - redisURI.setUsername(username); |
40 | | - redisURI.setPassword(password.toCharArray()); |
41 | | - } |
42 | | - RedisModulesClient client = RedisModulesClient.create(redisURI); |
43 | | - return client.connect(); |
44 | | - } |
| 31 | + private StatefulRedisModulesConnection<String, String> connect(String uri, String username, String password) { |
| 32 | + Objects.requireNonNull(uri, "URI"); |
| 33 | + RedisURI redisURI = RedisURI.create(uri); |
| 34 | + if (!Strings.isNullOrEmpty(username) && !Strings.isNullOrEmpty(password)) { |
| 35 | + redisURI.setUsername(username); |
| 36 | + redisURI.setPassword(password.toCharArray()); |
| 37 | + } |
| 38 | + RedisModulesClient client = RedisModulesClient.create(redisURI); |
| 39 | + return client.connect(); |
| 40 | + } |
45 | 41 | } |
0 commit comments