Skip to content

Commit 94afe4c

Browse files
author
Julien Ruaux
committed
build: Fixed dockerfile
1 parent 45e95ab commit 94afe4c

16 files changed

+165
-74
lines changed

.github/workflows/release.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ jobs:
3232
run: |
3333
VERSION=${{ github.event.inputs.version }}
3434
sed -i -e "s/^\:project-version\:\ .*/:project-version: $VERSION/g" README.adoc
35-
sed -i -e "s/^ARG TRINO_VERSION=.*/ARG TRINO_VERSION=$VERSION/g" Dockerfile
3635
git add README.adoc
37-
git add Dockerfile
3836
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
3937
git config --global user.name "GitHub Action"
4038
git commit -a -m "Releasing version $VERSION"

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ COPY --from=builder --chown=trino:trino /root/trino-redisearch/target/trino-redi
1212

1313
USER root:root
1414
RUN apt-get update
15-
RUN apt-get install -y -q gettext
15+
RUN apt-get install -y -q gettext uuid-runtime
1616
COPY --chown=trino:trino docker/etc /etc/trino
1717
COPY docker/template docker/setup.sh /tmp/
1818

README.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
:project-owner: redis-field-engineering
44
:project-name: redis-sql
55
:project-group: com.redis
6-
:project-version: 393
6+
:project-version: 0.2.4-SNAPSHOT
77
:artifact-id: trino-redisearch
88
:codecov-token: CQFF495IPH
99

pom.xml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
<properties>
1818
<trino.version>395</trino.version>
19-
<lettucemod.version>3.1.2</lettucemod.version>
19+
<lettucemod.version>3.1.5</lettucemod.version>
2020
<lettuce.version>6.2.0.RELEASE</lettuce.version>
2121
<testcontainers-redis.version>1.6.2</testcontainers-redis.version>
2222
<ulid.version>5.0.0</ulid.version>
@@ -367,4 +367,29 @@
367367
</dependency>
368368
</dependencies>
369369

370+
<build>
371+
<plugins>
372+
<plugin>
373+
<groupId>org.jacoco</groupId>
374+
<artifactId>jacoco-maven-plugin</artifactId>
375+
<version>0.8.8</version>
376+
<executions>
377+
<execution>
378+
<id>prepare-agent</id>
379+
<goals>
380+
<goal>prepare-agent</goal>
381+
</goals>
382+
</execution>
383+
<execution>
384+
<id>report</id>
385+
<phase>test</phase>
386+
<goals>
387+
<goal>report</goal>
388+
</goals>
389+
</execution>
390+
</executions>
391+
</plugin>
392+
</plugins>
393+
</build>
394+
370395
</project>

src/main/java/com/redis/trino/MetricAggregation.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import io.trino.spi.type.Type;
4646

4747
public class MetricAggregation {
48+
4849
public static final String MAX = "max";
4950
public static final String MIN = "min";
5051
public static final String AVG = "avg";

src/main/java/com/redis/trino/RediSearchClientModule.java

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,7 @@
3232
import com.google.inject.Module;
3333
import com.google.inject.Provides;
3434
import com.google.inject.Scopes;
35-
import com.redis.lettucemod.util.RedisClientBuilder;
36-
import com.redis.lettucemod.util.RedisClientOptions;
37-
import com.redis.lettucemod.util.RedisClientOptions.Builder;
3835

39-
import io.lettuce.core.SslVerifyMode;
4036
import io.trino.spi.type.TypeManager;
4137

4238
public class RediSearchClientModule implements Module {
@@ -55,19 +51,7 @@ public void configure(Binder binder) {
5551
@Provides
5652
public static RediSearchSession createRediSearchSession(TypeManager typeManager, RediSearchConfig config) {
5753
requireNonNull(config, "config is null");
58-
Builder options = RedisClientOptions.builder();
59-
options.uriString(config.getUri());
60-
options.ssl(config.isTls());
61-
options.username(config.getUsername());
62-
options.password(config.getPassword());
63-
if (config.isInsecure()) {
64-
options.sslVerifyMode(SslVerifyMode.NONE);
65-
}
66-
if (config.getTimeout() > 0) {
67-
options.timeoutInSeconds(config.getTimeout());
68-
}
69-
RedisClientBuilder clientBuilder = RedisClientBuilder.create(options.build());
70-
return new RediSearchSession(typeManager, clientBuilder.client(), config);
54+
return new RediSearchSession(typeManager, config);
7155
}
7256

7357
}

src/main/java/com/redis/trino/RediSearchConfig.java

Lines changed: 68 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*/
2424
package com.redis.trino;
2525

26+
import java.io.File;
2627
import java.time.Duration;
2728
import java.util.Optional;
2829

@@ -33,6 +34,7 @@
3334
import io.airlift.configuration.Config;
3435
import io.airlift.configuration.ConfigDescription;
3536
import io.airlift.configuration.ConfigSecuritySensitive;
37+
import io.airlift.configuration.validation.FileExists;
3638

3739
public class RediSearchConfig {
3840

@@ -46,13 +48,18 @@ public class RediSearchConfig {
4648
private Optional<String> username = Optional.empty();
4749
private Optional<String> password = Optional.empty();
4850
private boolean insecure;
49-
private boolean tls;
5051
private long timeout; // Use Lettuce default
5152
private boolean caseInsensitiveNameMatching;
5253
private long defaultLimit = DEFAULT_LIMIT;
5354
private long cursorCount; // Use RediSearch default
5455
private long tableCacheExpiration = DEFAULT_TABLE_CACHE_EXPIRATION.toSeconds();
5556
private long tableCacheRefresh = DEFAULT_TABLE_CACHE_REFRESH.toSeconds();
57+
private boolean cluster;
58+
private boolean tls;
59+
private File caCertPath;
60+
private File keyPath;
61+
private File certPath;
62+
private String keyPassword;
5663

5764
@Min(0)
5865
public long getCursorCount() {
@@ -169,26 +176,78 @@ public RediSearchConfig setInsecure(boolean insecure) {
169176
return this;
170177
}
171178

179+
@Min(0)
180+
public long getTimeout() {
181+
return timeout;
182+
}
183+
184+
@Config("redisearch.timeout")
185+
@ConfigDescription("Redis command timeout in seconds")
186+
public RediSearchConfig setTimeout(long timeout) {
187+
this.timeout = timeout;
188+
return this;
189+
}
190+
172191
public boolean isTls() {
173192
return tls;
174193
}
175194

176-
@Config("redisearch.tls")
195+
@Config("redisearch.tls.enabled")
177196
@ConfigDescription("Establish a secure TLS connection")
178197
public RediSearchConfig setTls(boolean tls) {
179198
this.tls = tls;
180199
return this;
181200
}
182201

183-
@Min(0)
184-
public long getTimeout() {
185-
return timeout;
202+
public boolean isCluster() {
203+
return cluster;
186204
}
187205

188-
@Config("redisearch.timeout")
189-
@ConfigDescription("Redis command timeout in seconds")
190-
public RediSearchConfig setTimeout(long timeout) {
191-
this.timeout = timeout;
206+
@Config("redisearch.cluster")
207+
@ConfigDescription("Connect to a Redis Cluster")
208+
public RediSearchConfig setCluster(boolean cluster) {
209+
this.cluster = cluster;
210+
return this;
211+
}
212+
213+
public Optional<@FileExists File> getCaCertPath() {
214+
return Optional.ofNullable(caCertPath);
215+
}
216+
217+
@Config("redisearch.tls.ca-cert-path")
218+
public RediSearchConfig setCaCertPath(File path) {
219+
this.caCertPath = path;
220+
return this;
221+
}
222+
223+
public Optional<@FileExists File> getCertPath() {
224+
return Optional.ofNullable(certPath);
225+
}
226+
227+
@Config("redisearch.tls.cert-path")
228+
public RediSearchConfig setCertPath(File path) {
229+
this.certPath = path;
230+
return this;
231+
}
232+
233+
public Optional<@FileExists File> getKeyPath() {
234+
return Optional.ofNullable(keyPath);
235+
}
236+
237+
@Config("redisearch.tls.key-path")
238+
public RediSearchConfig setKeyPath(File path) {
239+
this.keyPath = path;
240+
return this;
241+
}
242+
243+
public Optional<String> getKeyPassword() {
244+
return Optional.ofNullable(keyPassword);
245+
}
246+
247+
@Config("redisearch.tls.key-password")
248+
@ConfigSecuritySensitive
249+
public RediSearchConfig setKeyPassword(String password) {
250+
this.keyPassword = password;
192251
return this;
193252
}
194253

src/main/java/com/redis/trino/RediSearchMetadata.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@
2525

2626
import static com.google.common.base.Preconditions.checkState;
2727
import static com.google.common.base.Verify.verify;
28-
import static com.google.common.collect.ImmutableList.toImmutableList;
2928
import static java.util.Objects.requireNonNull;
30-
import static java.util.stream.Collectors.toList;
3129

3230
import java.util.Collection;
3331
import java.util.List;
@@ -88,7 +86,7 @@ public RediSearchMetadata(RediSearchSession rediSearchSession) {
8886

8987
@Override
9088
public List<String> listSchemaNames(ConnectorSession session) {
91-
return ImmutableList.of(schemaName);
89+
return List.of(schemaName);
9290
}
9391

9492
@Override
@@ -152,7 +150,7 @@ private List<SchemaTableName> listTables(ConnectorSession session, SchemaTablePr
152150
if (prefix.getTable().isEmpty()) {
153151
return listTables(session, prefix.getSchema());
154152
}
155-
return ImmutableList.of(prefix.toSchemaTableName());
153+
return List.of(prefix.toSchemaTableName());
156154
}
157155

158156
@Override
@@ -196,7 +194,7 @@ public ConnectorOutputTableHandle beginCreateTable(ConnectorSession session, Con
196194
setRollback(() -> rediSearchSession.dropTable(tableMetadata.getTable()));
197195

198196
return new RediSearchOutputTableHandle(tableMetadata.getTable(),
199-
columns.stream().filter(c -> !c.isHidden()).collect(toList()));
197+
columns.stream().filter(c -> !c.isHidden()).toList());
200198
}
201199

202200
@Override
@@ -217,7 +215,7 @@ public ConnectorInsertTableHandle beginInsert(ConnectorSession session, Connecto
217215
List<RediSearchColumnHandle> columns = rediSearchSession.getTable(table.getSchemaTableName()).getColumns();
218216

219217
return new RediSearchInsertTableHandle(table.getSchemaTableName(),
220-
columns.stream().filter(column -> !column.isHidden()).collect(toImmutableList()));
218+
columns.stream().filter(column -> !column.isHidden()).toList());
221219
}
222220

223221
@Override
@@ -231,7 +229,7 @@ public Optional<ConnectorOutputMetadata> finishInsert(ConnectorSession session,
231229
public ConnectorTableProperties getTableProperties(ConnectorSession session, ConnectorTableHandle table) {
232230
RediSearchTableHandle handle = (RediSearchTableHandle) table;
233231
return new ConnectorTableProperties(handle.getConstraint(), Optional.empty(), Optional.empty(),
234-
Optional.empty(), ImmutableList.of());
232+
Optional.empty(), List.of());
235233
}
236234

237235
@Override
@@ -334,15 +332,14 @@ private static SchemaTableName getTableName(ConnectorTableHandle tableHandle) {
334332
private ConnectorTableMetadata getTableMetadata(ConnectorSession session, SchemaTableName tableName) {
335333
RediSearchTableHandle tableHandle = rediSearchSession.getTable(tableName).getTableHandle();
336334

337-
List<ColumnMetadata> columns = ImmutableList
338-
.copyOf(getColumnHandles(session, tableHandle).values().stream().map(RediSearchColumnHandle.class::cast)
339-
.map(RediSearchColumnHandle::toColumnMetadata).collect(toList()));
335+
List<ColumnMetadata> columns = ImmutableList.copyOf(getColumnHandles(session, tableHandle).values().stream()
336+
.map(RediSearchColumnHandle.class::cast).map(RediSearchColumnHandle::toColumnMetadata).toList());
340337

341338
return new ConnectorTableMetadata(tableName, columns);
342339
}
343340

344341
private static List<RediSearchColumnHandle> buildColumnHandles(ConnectorTableMetadata tableMetadata) {
345342
return tableMetadata.getColumns().stream()
346-
.map(m -> new RediSearchColumnHandle(m.getName(), m.getType(), m.isHidden())).collect(toList());
343+
.map(m -> new RediSearchColumnHandle(m.getName(), m.getType(), m.isHidden())).toList();
347344
}
348345
}

src/main/java/com/redis/trino/RediSearchPageSink.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ public class RediSearchPageSink implements ConnectorPageSink {
8383
private final List<RediSearchColumnHandle> columns;
8484
private final UlidFactory factory = UlidFactory.newInstance(new Random());
8585

86-
public RediSearchPageSink(RediSearchConfig config, RediSearchSession rediSearchSession,
87-
SchemaTableName schemaTableName, List<RediSearchColumnHandle> columns) {
86+
public RediSearchPageSink(RediSearchSession rediSearchSession, SchemaTableName schemaTableName,
87+
List<RediSearchColumnHandle> columns) {
8888
this.rediSearchSession = rediSearchSession;
8989
this.schemaTableName = schemaTableName;
9090
this.columns = columns;
@@ -140,8 +140,8 @@ private String getObjectValue(Type type, Block block, int position) {
140140
if (type instanceof VarcharType) {
141141
return type.getSlice(block, position).toStringUtf8();
142142
}
143-
if (type instanceof CharType) {
144-
return padSpaces(type.getSlice(block, position), ((CharType) type)).toStringUtf8();
143+
if (type instanceof CharType charType) {
144+
return padSpaces(type.getSlice(block, position), charType).toStringUtf8();
145145
}
146146
if (type.equals(VarbinaryType.VARBINARY)) {
147147
return new String(type.getSlice(block, position).getBytes());
@@ -162,8 +162,8 @@ private String getObjectValue(Type type, Block block, int position) {
162162
long millisUtc = unpackMillisUtc(type.getLong(block, position));
163163
return String.valueOf(millisUtc);
164164
}
165-
if (type instanceof DecimalType) {
166-
return readBigDecimal((DecimalType) type, block, position).toPlainString();
165+
if (type instanceof DecimalType decimalType) {
166+
return readBigDecimal(decimalType, block, position).toPlainString();
167167
}
168168
throw new TrinoException(NOT_SUPPORTED, "unsupported type: " + type);
169169
}

src/main/java/com/redis/trino/RediSearchPageSinkProvider.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,37 +23,35 @@
2323
*/
2424
package com.redis.trino;
2525

26+
import javax.inject.Inject;
27+
2628
import io.trino.spi.connector.ConnectorInsertTableHandle;
2729
import io.trino.spi.connector.ConnectorOutputTableHandle;
2830
import io.trino.spi.connector.ConnectorPageSink;
2931
import io.trino.spi.connector.ConnectorPageSinkProvider;
3032
import io.trino.spi.connector.ConnectorSession;
3133
import io.trino.spi.connector.ConnectorTransactionHandle;
3234

33-
import javax.inject.Inject;
34-
3535
public class RediSearchPageSinkProvider implements ConnectorPageSinkProvider {
3636

37-
private final RediSearchConfig config;
3837
private final RediSearchSession rediSearchSession;
3938

4039
@Inject
41-
public RediSearchPageSinkProvider(RediSearchConfig config, RediSearchSession rediSearchSession) {
42-
this.config = config;
40+
public RediSearchPageSinkProvider(RediSearchSession rediSearchSession) {
4341
this.rediSearchSession = rediSearchSession;
4442
}
4543

4644
@Override
4745
public ConnectorPageSink createPageSink(ConnectorTransactionHandle transactionHandle, ConnectorSession session,
4846
ConnectorOutputTableHandle outputTableHandle) {
4947
RediSearchOutputTableHandle handle = (RediSearchOutputTableHandle) outputTableHandle;
50-
return new RediSearchPageSink(config, rediSearchSession, handle.getSchemaTableName(), handle.getColumns());
48+
return new RediSearchPageSink(rediSearchSession, handle.getSchemaTableName(), handle.getColumns());
5149
}
5250

5351
@Override
5452
public ConnectorPageSink createPageSink(ConnectorTransactionHandle transactionHandle, ConnectorSession session,
5553
ConnectorInsertTableHandle insertTableHandle) {
5654
RediSearchInsertTableHandle handle = (RediSearchInsertTableHandle) insertTableHandle;
57-
return new RediSearchPageSink(config, rediSearchSession, handle.getSchemaTableName(), handle.getColumns());
55+
return new RediSearchPageSink(rediSearchSession, handle.getSchemaTableName(), handle.getColumns());
5856
}
5957
}

0 commit comments

Comments
 (0)