You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "Anush008 (via GitHub)" <gi...@apache.org> on 2024/08/02 06:42:05 UTC
[PR] feat: Qdrant sink and source [seatunnel]
Anush008 opened a new pull request, #7299:
URL: https://github.com/apache/seatunnel/pull/7299
## Description
This PR adds support for [Qdrant](https://qdrant.tech) to be used as a source/sink in SeaTunnel.
Fixes #7190
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support Qdrant sink and source connector [seatunnel]
Posted by "Anush008 (via GitHub)" <gi...@apache.org>.
Anush008 commented on PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#issuecomment-2316788955
Thanks a lot for the patch @Hisoka-X.
Reran the failing JDBC test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support Qdrant sink and source connector [seatunnel]
Posted by "Anush008 (via GitHub)" <gi...@apache.org>.
Anush008 commented on PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#issuecomment-2315201522
Looks like a dependency version conflict has come up.
```
2024-08-27T05:05:15.4732663Z [INFO]
2024-08-27T05:05:15.4733127Z [ERROR] Errors:
2024-08-27T05:05:15.4734201Z [ERROR] QdrantIT.startUp:75->initQdrant:82 » NoSuchMethod 'io.grpc.NameResolverProvide...
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support Qdrant sink and source connector [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#issuecomment-2320491102
waiting https://github.com/apache/seatunnel/pull/7531
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support Qdrant sink and source connector [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#issuecomment-2316747739
Please re-trigger failed CI. Thanks

--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support Qdrant sink and source connector [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#issuecomment-2290484223
> Hi @Anush008 , thanks for created this PR. Please follow the guide to open github action on your fork repository. https://github.com/apache/seatunnel/pull/7299/checks?check_run_id=28499358075
@Anush008 Please open github action. Thanks !
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: Qdrant sink and source [seatunnel]
Posted by "hailin0 (via GitHub)" <gi...@apache.org>.
hailin0 commented on code in PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#discussion_r1701571786
##########
docs/en/connector-v2/sink/Qdrant.md:
##########
@@ -0,0 +1,70 @@
+# Qdrant
Review Comment:
add `zh` docs
##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-qdrant-e2e/src/test/java/org/apache/seatunnel/e2e/connector/v2/qdrant/QdrantIT.java:
##########
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.e2e.connector.v2.qdrant;
+
+import org.apache.seatunnel.e2e.common.TestResource;
+import org.apache.seatunnel.e2e.common.TestSuiteBase;
+import org.apache.seatunnel.e2e.common.container.EngineType;
+import org.apache.seatunnel.e2e.common.container.TestContainer;
+import org.apache.seatunnel.e2e.common.junit.DisabledOnContainer;
+
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.TestTemplate;
+import org.testcontainers.containers.Container;
+import org.testcontainers.lifecycle.Startables;
+import org.testcontainers.qdrant.QdrantContainer;
+
+import io.qdrant.client.QdrantClient;
+import io.qdrant.client.QdrantGrpcClient;
+import io.qdrant.client.grpc.Collections;
+import io.qdrant.client.grpc.Points;
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Stream;
+
+import static io.qdrant.client.PointIdFactory.id;
+import static io.qdrant.client.ValueFactory.value;
+import static io.qdrant.client.VectorFactory.vector;
+import static io.qdrant.client.VectorsFactory.namedVectors;
+
+@Slf4j
+@DisabledOnContainer(
+ value = {},
+ type = {EngineType.SPARK, EngineType.FLINK},
+ disabledReason = "Currently SPARK and FLINK not support adapt")
Review Comment:
why?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support Qdrant sink and source connector [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#issuecomment-2311439135
Please merge from dev to retrigger github action. Thanks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support Qdrant sink and source connector [seatunnel]
Posted by "Anush008 (via GitHub)" <gi...@apache.org>.
Anush008 commented on code in PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#discussion_r1731634989
##########
seatunnel-connectors-v2/connector-qdrant/src/main/java/org/apache/seatunnel/connectors/seatunnel/qdrant/sink/QdrantBatchWriter.java:
##########
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.qdrant.sink;
+
+import org.apache.seatunnel.api.table.catalog.CatalogTable;
+import org.apache.seatunnel.api.table.catalog.PrimaryKey;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.api.table.type.SqlType;
+import org.apache.seatunnel.common.exception.CommonErrorCode;
+import org.apache.seatunnel.connectors.seatunnel.qdrant.config.QdrantParameters;
+import org.apache.seatunnel.connectors.seatunnel.qdrant.exception.QdrantConnectorException;
+
+import org.apache.commons.collections4.CollectionUtils;
+
+import io.qdrant.client.QdrantClient;
+import io.qdrant.client.ValueFactory;
+import io.qdrant.client.VectorFactory;
+import io.qdrant.client.grpc.JsonWithInt;
+import io.qdrant.client.grpc.Points;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.ExecutionException;
+
+import static io.qdrant.client.PointIdFactory.id;
+import static org.apache.seatunnel.api.table.catalog.PrimaryKey.isPrimaryKeyField;
+
+public class QdrantBatchWriter {
+
+ private final int batchSize;
+ private final CatalogTable catalogTable;
+ private final String collectionName;
+ private final QdrantClient qdrantClient;
+
+ private final List<Points.PointStruct> qdrantDataCache;
+ private volatile int writeCount = 0;
+
+ public QdrantBatchWriter(
+ CatalogTable catalogTable, Integer batchSize, QdrantParameters params) {
+ this.catalogTable = catalogTable;
+ this.qdrantClient = params.buildQdrantClient();
+ this.collectionName = params.getCollectionName();
+ this.batchSize = batchSize;
+ this.qdrantDataCache = new ArrayList<>(batchSize);
+ }
+
+ public void addToBatch(SeaTunnelRow element) {
+ Points.PointStruct point = buildPoint(element);
+ qdrantDataCache.add(point);
+ writeCount++;
+ }
+
+ public boolean needFlush() {
+ return this.writeCount >= this.batchSize;
+ }
+
+ public synchronized void flush() {
+ if (CollectionUtils.isEmpty(this.qdrantDataCache)) {
+ return;
+ }
+ upsert();
+ this.qdrantDataCache.clear();
+ this.writeCount = 0;
+ }
+
+ public void close() {
+ this.qdrantClient.close();
+ }
+
+ private Points.PointStruct buildPoint(SeaTunnelRow element) {
+ SeaTunnelRowType seaTunnelRowType = catalogTable.getSeaTunnelRowType();
+ PrimaryKey primaryKey = catalogTable.getTableSchema().getPrimaryKey();
+
+ Points.PointStruct.Builder point = Points.PointStruct.newBuilder();
+ Points.NamedVectors.Builder namedVectors = Points.NamedVectors.newBuilder();
+ for (int i = 0; i < seaTunnelRowType.getFieldNames().length; i++) {
+ String fieldName = seaTunnelRowType.getFieldNames()[i];
+ SeaTunnelDataType<?> fieldType = seaTunnelRowType.getFieldType(i);
+ Object value = element.getField(i);
+
+ if (isPrimaryKeyField(primaryKey, fieldName)) {
+ point.setId(pointId(fieldType, value));
+ continue;
+ }
+
+ JsonWithInt.Value payloadValue = buildPayload(fieldType, value);
+ if (payloadValue != null) {
+ point.putPayload(fieldName, payloadValue);
+ continue;
+ }
+
+ Points.Vector vector = buildVector(fieldType, value);
+ if (vector != null) {
+ namedVectors.putVectors(fieldName, vector);
+ }
+ }
+
+ if (!point.hasId()) {
+ point.setId(id(UUID.randomUUID()));
+ }
+
+ point.setVectors(Points.Vectors.newBuilder().setVectors(namedVectors).build());
+ return point.build();
+ }
+
+ private void upsert() {
+ try {
+ qdrantClient
+ .upsertAsync(
+ Points.UpsertPoints.newBuilder()
+ .setCollectionName(collectionName)
+ .addAllPoints(qdrantDataCache)
+ .build())
+ .get();
+ } catch (InterruptedException | ExecutionException e) {
+ throw new RuntimeException("Upsert failed", e);
+ }
+ }
+
+ public static Points.PointId pointId(SeaTunnelDataType<?> fieldType, Object value) {
+ SqlType sqlType = fieldType.getSqlType();
+ switch (sqlType) {
+ case INT:
+ return id(Integer.parseInt(value.toString()));
+ case STRING:
+ return id(UUID.fromString(value.toString()));
+ default:
+ throw new QdrantConnectorException(
+ CommonErrorCode.UNSUPPORTED_DATA_TYPE,
+ "Unexpected value type for point ID: " + sqlType.name());
+ }
+ }
+
+ public static JsonWithInt.Value buildPayload(SeaTunnelDataType<?> fieldType, Object value) {
+ SqlType sqlType = fieldType.getSqlType();
+ switch (sqlType) {
+ case SMALLINT:
+ case INT:
+ case BIGINT:
+ return ValueFactory.value(Integer.parseInt(value.toString()));
+ case FLOAT:
+ case DOUBLE:
+ return ValueFactory.value(Long.parseLong(value.toString()));
+ case STRING:
+ case DATE:
+ return ValueFactory.value(value.toString());
+ case BOOLEAN:
+ return ValueFactory.value(Boolean.parseBoolean(value.toString()));
+ default:
+ return null;
+ }
+ }
+
+ public static Points.Vector buildVector(SeaTunnelDataType<?> fieldType, Object value) {
+ SqlType sqlType = fieldType.getSqlType();
+ switch (sqlType) {
+ case FLOAT_VECTOR:
+ case FLOAT16_VECTOR:
+ case BFLOAT16_VECTOR:
+ case BINARY_VECTOR:
+ List<Float> floats = new ArrayList<>();
+ for (Object o : (Object[]) value) {
+ floats.add(Float.parseFloat(o.toString()));
+ }
+ return VectorFactory.vector(floats);
+ default:
+ return null;
Review Comment:
Done. [`3f60035` (#7299)](https://github.com/apache/seatunnel/pull/7299/commits/3f6003566dd0e5fd65f6c130fec5d5fcb61f98a8)
The null returned by default is used to check if any vector exists. It isn't written into Qdrant.
https://github.com/Anush008/seatunnel/blob/3f6003566dd0e5fd65f6c130fec5d5fcb61f98a8/seatunnel-connectors-v2/connector-qdrant/src/main/java/org/apache/seatunnel/connectors/seatunnel/qdrant/sink/QdrantBatchWriter.java#L114-L117
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support Qdrant sink and source connector [seatunnel]
Posted by "Anush008 (via GitHub)" <gi...@apache.org>.
Anush008 commented on PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#issuecomment-2290493735
> @Anush008 Please open github action. Thanks !
Hey. I missed your first comment. Done now.
Thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support Qdrant sink and source connector [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#issuecomment-2275656414
Hi @Anush008 , thanks for created this PR. Please follow the guide to open github action on your fork repository. https://github.com/apache/seatunnel/pull/7299/checks?check_run_id=28499358075
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support Qdrant sink and source connector [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#discussion_r1709389390
##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-qdrant-e2e/src/test/java/org/apache/seatunnel/e2e/connector/v2/qdrant/QdrantIT.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.e2e.connector.v2.qdrant;
+
+import org.apache.seatunnel.e2e.common.TestResource;
+import org.apache.seatunnel.e2e.common.TestSuiteBase;
+import org.apache.seatunnel.e2e.common.container.EngineType;
+import org.apache.seatunnel.e2e.common.container.TestContainer;
+import org.apache.seatunnel.e2e.common.junit.DisabledOnContainer;
+
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.TestTemplate;
+import org.testcontainers.containers.Container;
+import org.testcontainers.lifecycle.Startables;
+import org.testcontainers.qdrant.QdrantContainer;
+import org.testcontainers.shaded.com.google.common.collect.ImmutableMap;
+
+import io.qdrant.client.QdrantClient;
+import io.qdrant.client.QdrantGrpcClient;
+import io.qdrant.client.grpc.Collections;
+import io.qdrant.client.grpc.Points;
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Stream;
+
+import static io.qdrant.client.PointIdFactory.id;
+import static io.qdrant.client.ValueFactory.value;
+import static io.qdrant.client.VectorFactory.vector;
+import static io.qdrant.client.VectorsFactory.namedVectors;
+
+@Slf4j
+@DisabledOnContainer(
+ value = {},
+ type = {EngineType.SPARK, EngineType.FLINK})
Review Comment:
Current spark/flink not support vector series type.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support Qdrant sink and source connector [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#issuecomment-2301904365
Please resolve conflict and fix ci. Thanks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support Qdrant sink and source connector [seatunnel]
Posted by "hailin0 (via GitHub)" <gi...@apache.org>.
hailin0 commented on code in PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#discussion_r1709376510
##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-qdrant-e2e/src/test/resources/log4j2.properties:
##########
@@ -0,0 +1,45 @@
+################################################################################
Review Comment:
why add this file?
##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-qdrant-e2e/src/test/java/org/apache/seatunnel/e2e/connector/v2/qdrant/QdrantIT.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.e2e.connector.v2.qdrant;
+
+import org.apache.seatunnel.e2e.common.TestResource;
+import org.apache.seatunnel.e2e.common.TestSuiteBase;
+import org.apache.seatunnel.e2e.common.container.EngineType;
+import org.apache.seatunnel.e2e.common.container.TestContainer;
+import org.apache.seatunnel.e2e.common.junit.DisabledOnContainer;
+
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.TestTemplate;
+import org.testcontainers.containers.Container;
+import org.testcontainers.lifecycle.Startables;
+import org.testcontainers.qdrant.QdrantContainer;
+import org.testcontainers.shaded.com.google.common.collect.ImmutableMap;
+
+import io.qdrant.client.QdrantClient;
+import io.qdrant.client.QdrantGrpcClient;
+import io.qdrant.client.grpc.Collections;
+import io.qdrant.client.grpc.Points;
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Stream;
+
+import static io.qdrant.client.PointIdFactory.id;
+import static io.qdrant.client.ValueFactory.value;
+import static io.qdrant.client.VectorFactory.vector;
+import static io.qdrant.client.VectorsFactory.namedVectors;
+
+@Slf4j
+@DisabledOnContainer(
+ value = {},
+ type = {EngineType.SPARK, EngineType.FLINK})
Review Comment:
why disable spark/flink?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: Qdrant sink and source [seatunnel]
Posted by "Anush008 (via GitHub)" <gi...@apache.org>.
Anush008 commented on code in PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#discussion_r1701579554
##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-qdrant-e2e/src/test/java/org/apache/seatunnel/e2e/connector/v2/qdrant/QdrantIT.java:
##########
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.e2e.connector.v2.qdrant;
+
+import org.apache.seatunnel.e2e.common.TestResource;
+import org.apache.seatunnel.e2e.common.TestSuiteBase;
+import org.apache.seatunnel.e2e.common.container.EngineType;
+import org.apache.seatunnel.e2e.common.container.TestContainer;
+import org.apache.seatunnel.e2e.common.junit.DisabledOnContainer;
+
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.TestTemplate;
+import org.testcontainers.containers.Container;
+import org.testcontainers.lifecycle.Startables;
+import org.testcontainers.qdrant.QdrantContainer;
+
+import io.qdrant.client.QdrantClient;
+import io.qdrant.client.QdrantGrpcClient;
+import io.qdrant.client.grpc.Collections;
+import io.qdrant.client.grpc.Points;
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Stream;
+
+import static io.qdrant.client.PointIdFactory.id;
+import static io.qdrant.client.ValueFactory.value;
+import static io.qdrant.client.VectorFactory.vector;
+import static io.qdrant.client.VectorsFactory.namedVectors;
+
+@Slf4j
+@DisabledOnContainer(
+ value = {},
+ type = {EngineType.SPARK, EngineType.FLINK},
+ disabledReason = "Currently SPARK and FLINK not support adapt")
Review Comment:
TODO.
I have to add the primary key handling, then run tests with these envs too.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support Qdrant sink and source connector [seatunnel]
Posted by "Anush008 (via GitHub)" <gi...@apache.org>.
Anush008 commented on code in PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#discussion_r1738436451
##########
seatunnel-connectors-v2/connector-qdrant/src/main/java/org/apache/seatunnel/connectors/seatunnel/qdrant/source/QdrantSource.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.qdrant.source;
+
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
+import org.apache.seatunnel.api.source.Boundedness;
+import org.apache.seatunnel.api.table.catalog.CatalogTable;
+import org.apache.seatunnel.api.table.catalog.CatalogTableUtil;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.connectors.seatunnel.common.source.AbstractSingleSplitReader;
+import org.apache.seatunnel.connectors.seatunnel.common.source.AbstractSingleSplitSource;
+import org.apache.seatunnel.connectors.seatunnel.common.source.SingleSplitReaderContext;
+import org.apache.seatunnel.connectors.seatunnel.qdrant.config.QdrantConfig;
+import org.apache.seatunnel.connectors.seatunnel.qdrant.config.QdrantParameters;
+
+import java.util.Collections;
+import java.util.List;
+
+public class QdrantSource extends AbstractSingleSplitSource<SeaTunnelRow> {
+ private final QdrantParameters qdrantParameters;
+ private final CatalogTable catalogTable;
+
+ @Override
+ public String getPluginName() {
+ return QdrantConfig.CONNECTOR_IDENTITY;
+ }
+
+ public QdrantSource(ReadonlyConfig readonlyConfig) {
+ this.qdrantParameters = new QdrantParameters(readonlyConfig);
+ this.catalogTable = CatalogTableUtil.buildWithConfig(readonlyConfig);
Review Comment:
`payload_schema` only contains fields of the JSON payload for which an index is created.
https://qdrant.tech/documentation/concepts/indexing/#payload-index
https://api.qdrant.tech/api-reference/collections/get-collection#response.body.result.payload_schema.points
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support Qdrant sink and source connector [seatunnel]
Posted by "Anush008 (via GitHub)" <gi...@apache.org>.
Anush008 commented on code in PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#discussion_r1738410266
##########
seatunnel-connectors-v2/connector-qdrant/src/main/java/org/apache/seatunnel/connectors/seatunnel/qdrant/source/QdrantSource.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.qdrant.source;
+
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
+import org.apache.seatunnel.api.source.Boundedness;
+import org.apache.seatunnel.api.table.catalog.CatalogTable;
+import org.apache.seatunnel.api.table.catalog.CatalogTableUtil;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.connectors.seatunnel.common.source.AbstractSingleSplitReader;
+import org.apache.seatunnel.connectors.seatunnel.common.source.AbstractSingleSplitSource;
+import org.apache.seatunnel.connectors.seatunnel.common.source.SingleSplitReaderContext;
+import org.apache.seatunnel.connectors.seatunnel.qdrant.config.QdrantConfig;
+import org.apache.seatunnel.connectors.seatunnel.qdrant.config.QdrantParameters;
+
+import java.util.Collections;
+import java.util.List;
+
+public class QdrantSource extends AbstractSingleSplitSource<SeaTunnelRow> {
+ private final QdrantParameters qdrantParameters;
+ private final CatalogTable catalogTable;
+
+ @Override
+ public String getPluginName() {
+ return QdrantConfig.CONNECTOR_IDENTITY;
+ }
+
+ public QdrantSource(ReadonlyConfig readonlyConfig) {
+ this.qdrantParameters = new QdrantParameters(readonlyConfig);
+ this.catalogTable = CatalogTableUtil.buildWithConfig(readonlyConfig);
Review Comment:
As in getting pre-defined schema? No.
The payload for each entry can be arbitrary JSON.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support Qdrant sink and source connector [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#discussion_r1726144849
##########
seatunnel-connectors-v2/connector-qdrant/pom.xml:
##########
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.seatunnel</groupId>
+ <artifactId>seatunnel-connectors-v2</artifactId>
+ <version>${revision}</version>
+ </parent>
+
+ <artifactId>connector-qdrant</artifactId>
+ <name>SeaTunnel : Connectors V2 : Qdrant</name>
+
+ <properties>
+ <connector.name>connector.qdrant</connector.name>
+ </properties>
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.seatunnel</groupId>
+ <artifactId>connector-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-protobuf</artifactId>
+ <version>1.59.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>30.1-jre</version>
+ </dependency>
Review Comment:
Is this necessary? We have our own shaded guava dependency. https://github.com/apache/seatunnel/blob/a6b188d5528ba914c289f65bb910621659390fe3/seatunnel-shade/seatunnel-guava/pom.xml#L25
##########
seatunnel-connectors-v2/connector-qdrant/src/main/java/org/apache/seatunnel/connectors/seatunnel/qdrant/sink/QdrantBatchWriter.java:
##########
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.qdrant.sink;
+
+import org.apache.seatunnel.api.table.catalog.CatalogTable;
+import org.apache.seatunnel.api.table.catalog.PrimaryKey;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.api.table.type.SqlType;
+import org.apache.seatunnel.common.exception.CommonErrorCode;
+import org.apache.seatunnel.connectors.seatunnel.qdrant.config.QdrantParameters;
+import org.apache.seatunnel.connectors.seatunnel.qdrant.exception.QdrantConnectorException;
+
+import org.apache.commons.collections4.CollectionUtils;
+
+import io.qdrant.client.QdrantClient;
+import io.qdrant.client.ValueFactory;
+import io.qdrant.client.VectorFactory;
+import io.qdrant.client.grpc.JsonWithInt;
+import io.qdrant.client.grpc.Points;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.ExecutionException;
+
+import static io.qdrant.client.PointIdFactory.id;
+import static org.apache.seatunnel.api.table.catalog.PrimaryKey.isPrimaryKeyField;
+
+public class QdrantBatchWriter {
+
+ private final int batchSize;
+ private final CatalogTable catalogTable;
+ private final String collectionName;
+ private final QdrantClient qdrantClient;
+
+ private final List<Points.PointStruct> qdrantDataCache;
+ private volatile int writeCount = 0;
+
+ public QdrantBatchWriter(
+ CatalogTable catalogTable, Integer batchSize, QdrantParameters params) {
+ this.catalogTable = catalogTable;
+ this.qdrantClient = params.buildQdrantClient();
+ this.collectionName = params.getCollectionName();
+ this.batchSize = batchSize;
+ this.qdrantDataCache = new ArrayList<>(batchSize);
+ }
+
+ public void addToBatch(SeaTunnelRow element) {
+ Points.PointStruct point = buildPoint(element);
+ qdrantDataCache.add(point);
+ writeCount++;
+ }
+
+ public boolean needFlush() {
+ return this.writeCount >= this.batchSize;
+ }
+
+ public synchronized void flush() {
+ if (CollectionUtils.isEmpty(this.qdrantDataCache)) {
+ return;
+ }
+ upsert();
+ this.qdrantDataCache.clear();
+ this.writeCount = 0;
+ }
+
+ public void close() {
+ this.qdrantClient.close();
+ }
+
+ private Points.PointStruct buildPoint(SeaTunnelRow element) {
+ SeaTunnelRowType seaTunnelRowType = catalogTable.getSeaTunnelRowType();
+ PrimaryKey primaryKey = catalogTable.getTableSchema().getPrimaryKey();
+
+ Points.PointStruct.Builder point = Points.PointStruct.newBuilder();
+ Points.NamedVectors.Builder namedVectors = Points.NamedVectors.newBuilder();
+ for (int i = 0; i < seaTunnelRowType.getFieldNames().length; i++) {
+ String fieldName = seaTunnelRowType.getFieldNames()[i];
+ SeaTunnelDataType<?> fieldType = seaTunnelRowType.getFieldType(i);
+ Object value = element.getField(i);
+
+ if (isPrimaryKeyField(primaryKey, fieldName)) {
+ point.setId(pointId(fieldType, value));
+ continue;
+ }
+
+ JsonWithInt.Value payloadValue = buildPayload(fieldType, value);
+ if (payloadValue != null) {
+ point.putPayload(fieldName, payloadValue);
+ continue;
+ }
+
+ Points.Vector vector = buildVector(fieldType, value);
+ if (vector != null) {
+ namedVectors.putVectors(fieldName, vector);
+ }
+ }
+
+ if (!point.hasId()) {
+ point.setId(id(UUID.randomUUID()));
+ }
+
+ point.setVectors(Points.Vectors.newBuilder().setVectors(namedVectors).build());
+ return point.build();
+ }
+
+ private void upsert() {
+ try {
+ qdrantClient
+ .upsertAsync(
+ Points.UpsertPoints.newBuilder()
+ .setCollectionName(collectionName)
+ .addAllPoints(qdrantDataCache)
+ .build())
+ .get();
+ } catch (InterruptedException | ExecutionException e) {
+ throw new RuntimeException("Upsert failed", e);
+ }
+ }
+
+ public static Points.PointId pointId(SeaTunnelDataType<?> fieldType, Object value) {
+ SqlType sqlType = fieldType.getSqlType();
+ switch (sqlType) {
+ case INT:
+ return id(Integer.parseInt(value.toString()));
+ case STRING:
+ return id(UUID.fromString(value.toString()));
+ default:
+ throw new QdrantConnectorException(
+ CommonErrorCode.UNSUPPORTED_DATA_TYPE,
+ "Unexpected value type for point ID: " + sqlType.name());
+ }
+ }
+
+ public static JsonWithInt.Value buildPayload(SeaTunnelDataType<?> fieldType, Object value) {
+ SqlType sqlType = fieldType.getSqlType();
+ switch (sqlType) {
+ case SMALLINT:
+ case INT:
+ case BIGINT:
+ return ValueFactory.value(Integer.parseInt(value.toString()));
+ case FLOAT:
+ case DOUBLE:
+ return ValueFactory.value(Long.parseLong(value.toString()));
+ case STRING:
+ case DATE:
+ return ValueFactory.value(value.toString());
+ case BOOLEAN:
+ return ValueFactory.value(Boolean.parseBoolean(value.toString()));
+ default:
+ return null;
+ }
+ }
+
+ public static Points.Vector buildVector(SeaTunnelDataType<?> fieldType, Object value) {
+ SqlType sqlType = fieldType.getSqlType();
+ switch (sqlType) {
+ case FLOAT_VECTOR:
+ case FLOAT16_VECTOR:
+ case BFLOAT16_VECTOR:
+ case BINARY_VECTOR:
+ List<Float> floats = new ArrayList<>();
+ for (Object o : (Object[]) value) {
+ floats.add(Float.parseFloat(o.toString()));
+ }
+ return VectorFactory.vector(floats);
+ default:
+ return null;
Review Comment:
Hi,
1. the different vector type use different java class type to store data, not all use `List<Float>`.
```java
case FLOAT16_VECTOR:
case BFLOAT16_VECTOR:
case BINARY_VECTOR:
(ByteBuffer)value
```
2. default should throw exception make sure user know the data type can not be stored.
3. Feel free to discuss our vector api data type, it is currently an experimental API, and we can modify it at any time to ensure that it works properly for all vector databases.
##########
seatunnel-connectors-v2/connector-qdrant/src/main/java/org/apache/seatunnel/connectors/seatunnel/qdrant/sink/QdrantSinkWriter.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.qdrant.sink;
+
+import org.apache.seatunnel.api.sink.SupportMultiTableSinkWriter;
+import org.apache.seatunnel.api.table.catalog.CatalogTable;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.connectors.seatunnel.common.sink.AbstractSinkWriter;
+import org.apache.seatunnel.connectors.seatunnel.qdrant.config.QdrantParameters;
+
+import java.io.IOException;
+import java.util.Optional;
+
+public class QdrantSinkWriter extends AbstractSinkWriter<SeaTunnelRow, Void>
+ implements SupportMultiTableSinkWriter<Void> {
+
+ private final QdrantBatchWriter batchWriter;
+
+ public QdrantSinkWriter(CatalogTable catalog, QdrantParameters qdrantParameters) {
+ int BATCH_SIZE = 64;
+ this.batchWriter = new QdrantBatchWriter(catalog, BATCH_SIZE, qdrantParameters);
Review Comment:
```suggestion
int batchSize = 64;
this.batchWriter = new QdrantBatchWriter(catalog, batchSize, qdrantParameters);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support Qdrant sink and source connector [seatunnel]
Posted by "Anush008 (via GitHub)" <gi...@apache.org>.
Anush008 commented on code in PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#discussion_r1730663031
##########
seatunnel-connectors-v2/connector-qdrant/pom.xml:
##########
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.seatunnel</groupId>
+ <artifactId>seatunnel-connectors-v2</artifactId>
+ <version>${revision}</version>
+ </parent>
+
+ <artifactId>connector-qdrant</artifactId>
+ <name>SeaTunnel : Connectors V2 : Qdrant</name>
+
+ <properties>
+ <connector.name>connector.qdrant</connector.name>
+ </properties>
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.seatunnel</groupId>
+ <artifactId>connector-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-protobuf</artifactId>
+ <version>1.59.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>30.1-jre</version>
+ </dependency>
Review Comment:
[`0487e87` (#7299)](https://github.com/apache/seatunnel/pull/7299/commits/0487e870f3a24bee66e529970ce161e51b7239f0)
##########
seatunnel-connectors-v2/connector-qdrant/src/main/java/org/apache/seatunnel/connectors/seatunnel/qdrant/sink/QdrantBatchWriter.java:
##########
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.qdrant.sink;
+
+import org.apache.seatunnel.api.table.catalog.CatalogTable;
+import org.apache.seatunnel.api.table.catalog.PrimaryKey;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.api.table.type.SqlType;
+import org.apache.seatunnel.common.exception.CommonErrorCode;
+import org.apache.seatunnel.connectors.seatunnel.qdrant.config.QdrantParameters;
+import org.apache.seatunnel.connectors.seatunnel.qdrant.exception.QdrantConnectorException;
+
+import org.apache.commons.collections4.CollectionUtils;
+
+import io.qdrant.client.QdrantClient;
+import io.qdrant.client.ValueFactory;
+import io.qdrant.client.VectorFactory;
+import io.qdrant.client.grpc.JsonWithInt;
+import io.qdrant.client.grpc.Points;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.ExecutionException;
+
+import static io.qdrant.client.PointIdFactory.id;
+import static org.apache.seatunnel.api.table.catalog.PrimaryKey.isPrimaryKeyField;
+
+public class QdrantBatchWriter {
+
+ private final int batchSize;
+ private final CatalogTable catalogTable;
+ private final String collectionName;
+ private final QdrantClient qdrantClient;
+
+ private final List<Points.PointStruct> qdrantDataCache;
+ private volatile int writeCount = 0;
+
+ public QdrantBatchWriter(
+ CatalogTable catalogTable, Integer batchSize, QdrantParameters params) {
+ this.catalogTable = catalogTable;
+ this.qdrantClient = params.buildQdrantClient();
+ this.collectionName = params.getCollectionName();
+ this.batchSize = batchSize;
+ this.qdrantDataCache = new ArrayList<>(batchSize);
+ }
+
+ public void addToBatch(SeaTunnelRow element) {
+ Points.PointStruct point = buildPoint(element);
+ qdrantDataCache.add(point);
+ writeCount++;
+ }
+
+ public boolean needFlush() {
+ return this.writeCount >= this.batchSize;
+ }
+
+ public synchronized void flush() {
+ if (CollectionUtils.isEmpty(this.qdrantDataCache)) {
+ return;
+ }
+ upsert();
+ this.qdrantDataCache.clear();
+ this.writeCount = 0;
+ }
+
+ public void close() {
+ this.qdrantClient.close();
+ }
+
+ private Points.PointStruct buildPoint(SeaTunnelRow element) {
+ SeaTunnelRowType seaTunnelRowType = catalogTable.getSeaTunnelRowType();
+ PrimaryKey primaryKey = catalogTable.getTableSchema().getPrimaryKey();
+
+ Points.PointStruct.Builder point = Points.PointStruct.newBuilder();
+ Points.NamedVectors.Builder namedVectors = Points.NamedVectors.newBuilder();
+ for (int i = 0; i < seaTunnelRowType.getFieldNames().length; i++) {
+ String fieldName = seaTunnelRowType.getFieldNames()[i];
+ SeaTunnelDataType<?> fieldType = seaTunnelRowType.getFieldType(i);
+ Object value = element.getField(i);
+
+ if (isPrimaryKeyField(primaryKey, fieldName)) {
+ point.setId(pointId(fieldType, value));
+ continue;
+ }
+
+ JsonWithInt.Value payloadValue = buildPayload(fieldType, value);
+ if (payloadValue != null) {
+ point.putPayload(fieldName, payloadValue);
+ continue;
+ }
+
+ Points.Vector vector = buildVector(fieldType, value);
+ if (vector != null) {
+ namedVectors.putVectors(fieldName, vector);
+ }
+ }
+
+ if (!point.hasId()) {
+ point.setId(id(UUID.randomUUID()));
+ }
+
+ point.setVectors(Points.Vectors.newBuilder().setVectors(namedVectors).build());
+ return point.build();
+ }
+
+ private void upsert() {
+ try {
+ qdrantClient
+ .upsertAsync(
+ Points.UpsertPoints.newBuilder()
+ .setCollectionName(collectionName)
+ .addAllPoints(qdrantDataCache)
+ .build())
+ .get();
+ } catch (InterruptedException | ExecutionException e) {
+ throw new RuntimeException("Upsert failed", e);
+ }
+ }
+
+ public static Points.PointId pointId(SeaTunnelDataType<?> fieldType, Object value) {
+ SqlType sqlType = fieldType.getSqlType();
+ switch (sqlType) {
+ case INT:
+ return id(Integer.parseInt(value.toString()));
+ case STRING:
+ return id(UUID.fromString(value.toString()));
+ default:
+ throw new QdrantConnectorException(
+ CommonErrorCode.UNSUPPORTED_DATA_TYPE,
+ "Unexpected value type for point ID: " + sqlType.name());
+ }
+ }
+
+ public static JsonWithInt.Value buildPayload(SeaTunnelDataType<?> fieldType, Object value) {
+ SqlType sqlType = fieldType.getSqlType();
+ switch (sqlType) {
+ case SMALLINT:
+ case INT:
+ case BIGINT:
+ return ValueFactory.value(Integer.parseInt(value.toString()));
+ case FLOAT:
+ case DOUBLE:
+ return ValueFactory.value(Long.parseLong(value.toString()));
+ case STRING:
+ case DATE:
+ return ValueFactory.value(value.toString());
+ case BOOLEAN:
+ return ValueFactory.value(Boolean.parseBoolean(value.toString()));
+ default:
+ return null;
+ }
+ }
+
+ public static Points.Vector buildVector(SeaTunnelDataType<?> fieldType, Object value) {
+ SqlType sqlType = fieldType.getSqlType();
+ switch (sqlType) {
+ case FLOAT_VECTOR:
+ case FLOAT16_VECTOR:
+ case BFLOAT16_VECTOR:
+ case BINARY_VECTOR:
+ List<Float> floats = new ArrayList<>();
+ for (Object o : (Object[]) value) {
+ floats.add(Float.parseFloat(o.toString()));
+ }
+ return VectorFactory.vector(floats);
+ default:
+ return null;
Review Comment:
Will do.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support Qdrant sink and source connector [seatunnel]
Posted by "Anush008 (via GitHub)" <gi...@apache.org>.
Anush008 commented on code in PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#discussion_r1738436451
##########
seatunnel-connectors-v2/connector-qdrant/src/main/java/org/apache/seatunnel/connectors/seatunnel/qdrant/source/QdrantSource.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.qdrant.source;
+
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
+import org.apache.seatunnel.api.source.Boundedness;
+import org.apache.seatunnel.api.table.catalog.CatalogTable;
+import org.apache.seatunnel.api.table.catalog.CatalogTableUtil;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.connectors.seatunnel.common.source.AbstractSingleSplitReader;
+import org.apache.seatunnel.connectors.seatunnel.common.source.AbstractSingleSplitSource;
+import org.apache.seatunnel.connectors.seatunnel.common.source.SingleSplitReaderContext;
+import org.apache.seatunnel.connectors.seatunnel.qdrant.config.QdrantConfig;
+import org.apache.seatunnel.connectors.seatunnel.qdrant.config.QdrantParameters;
+
+import java.util.Collections;
+import java.util.List;
+
+public class QdrantSource extends AbstractSingleSplitSource<SeaTunnelRow> {
+ private final QdrantParameters qdrantParameters;
+ private final CatalogTable catalogTable;
+
+ @Override
+ public String getPluginName() {
+ return QdrantConfig.CONNECTOR_IDENTITY;
+ }
+
+ public QdrantSource(ReadonlyConfig readonlyConfig) {
+ this.qdrantParameters = new QdrantParameters(readonlyConfig);
+ this.catalogTable = CatalogTableUtil.buildWithConfig(readonlyConfig);
Review Comment:
`payload_schema` only contains fields of the JSON payload for which an index is created.
https://qdrant.tech/documentation/concepts/indexing/#payload-index
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support Qdrant sink and source connector [seatunnel]
Posted by "Anush008 (via GitHub)" <gi...@apache.org>.
Anush008 commented on code in PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#discussion_r1738410266
##########
seatunnel-connectors-v2/connector-qdrant/src/main/java/org/apache/seatunnel/connectors/seatunnel/qdrant/source/QdrantSource.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.qdrant.source;
+
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
+import org.apache.seatunnel.api.source.Boundedness;
+import org.apache.seatunnel.api.table.catalog.CatalogTable;
+import org.apache.seatunnel.api.table.catalog.CatalogTableUtil;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.connectors.seatunnel.common.source.AbstractSingleSplitReader;
+import org.apache.seatunnel.connectors.seatunnel.common.source.AbstractSingleSplitSource;
+import org.apache.seatunnel.connectors.seatunnel.common.source.SingleSplitReaderContext;
+import org.apache.seatunnel.connectors.seatunnel.qdrant.config.QdrantConfig;
+import org.apache.seatunnel.connectors.seatunnel.qdrant.config.QdrantParameters;
+
+import java.util.Collections;
+import java.util.List;
+
+public class QdrantSource extends AbstractSingleSplitSource<SeaTunnelRow> {
+ private final QdrantParameters qdrantParameters;
+ private final CatalogTable catalogTable;
+
+ @Override
+ public String getPluginName() {
+ return QdrantConfig.CONNECTOR_IDENTITY;
+ }
+
+ public QdrantSource(ReadonlyConfig readonlyConfig) {
+ this.qdrantParameters = new QdrantParameters(readonlyConfig);
+ this.catalogTable = CatalogTableUtil.buildWithConfig(readonlyConfig);
Review Comment:
As in a schema? No.
The payload for each entry can be arbitrary JSON.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: Qdrant sink and source [seatunnel]
Posted by "Anush008 (via GitHub)" <gi...@apache.org>.
Anush008 commented on code in PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#discussion_r1701580216
##########
docs/en/connector-v2/sink/Qdrant.md:
##########
@@ -0,0 +1,70 @@
+# Qdrant
Review Comment:
I can try that. This PR is a WIP.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support Qdrant sink and source connector [seatunnel]
Posted by "hailin0 (via GitHub)" <gi...@apache.org>.
hailin0 commented on code in PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#discussion_r1709480084
##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-qdrant-e2e/src/test/java/org/apache/seatunnel/e2e/connector/v2/qdrant/QdrantIT.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.e2e.connector.v2.qdrant;
+
+import org.apache.seatunnel.e2e.common.TestResource;
+import org.apache.seatunnel.e2e.common.TestSuiteBase;
+import org.apache.seatunnel.e2e.common.container.EngineType;
+import org.apache.seatunnel.e2e.common.container.TestContainer;
+import org.apache.seatunnel.e2e.common.junit.DisabledOnContainer;
+
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.TestTemplate;
+import org.testcontainers.containers.Container;
+import org.testcontainers.lifecycle.Startables;
+import org.testcontainers.qdrant.QdrantContainer;
+import org.testcontainers.shaded.com.google.common.collect.ImmutableMap;
+
+import io.qdrant.client.QdrantClient;
+import io.qdrant.client.QdrantGrpcClient;
+import io.qdrant.client.grpc.Collections;
+import io.qdrant.client.grpc.Points;
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Stream;
+
+import static io.qdrant.client.PointIdFactory.id;
+import static io.qdrant.client.ValueFactory.value;
+import static io.qdrant.client.VectorFactory.vector;
+import static io.qdrant.client.VectorsFactory.namedVectors;
+
+@Slf4j
+@DisabledOnContainer(
+ value = {},
+ type = {EngineType.SPARK, EngineType.FLINK})
Review Comment:
```suggestion
type = {EngineType.SPARK, EngineType.FLINK},
disabledReason = ...)
```
Please add a description
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support Qdrant sink and source connector [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#discussion_r1730691792
##########
seatunnel-connectors-v2/connector-qdrant/src/main/java/org/apache/seatunnel/connectors/seatunnel/qdrant/sink/QdrantBatchWriter.java:
##########
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.qdrant.sink;
+
+import org.apache.seatunnel.api.table.catalog.CatalogTable;
+import org.apache.seatunnel.api.table.catalog.PrimaryKey;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.api.table.type.SqlType;
+import org.apache.seatunnel.common.exception.CommonErrorCode;
+import org.apache.seatunnel.connectors.seatunnel.qdrant.config.QdrantParameters;
+import org.apache.seatunnel.connectors.seatunnel.qdrant.exception.QdrantConnectorException;
+
+import org.apache.commons.collections4.CollectionUtils;
+
+import io.qdrant.client.QdrantClient;
+import io.qdrant.client.ValueFactory;
+import io.qdrant.client.VectorFactory;
+import io.qdrant.client.grpc.JsonWithInt;
+import io.qdrant.client.grpc.Points;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.ExecutionException;
+
+import static io.qdrant.client.PointIdFactory.id;
+import static org.apache.seatunnel.api.table.catalog.PrimaryKey.isPrimaryKeyField;
+
+public class QdrantBatchWriter {
+
+ private final int batchSize;
+ private final CatalogTable catalogTable;
+ private final String collectionName;
+ private final QdrantClient qdrantClient;
+
+ private final List<Points.PointStruct> qdrantDataCache;
+ private volatile int writeCount = 0;
+
+ public QdrantBatchWriter(
+ CatalogTable catalogTable, Integer batchSize, QdrantParameters params) {
+ this.catalogTable = catalogTable;
+ this.qdrantClient = params.buildQdrantClient();
+ this.collectionName = params.getCollectionName();
+ this.batchSize = batchSize;
+ this.qdrantDataCache = new ArrayList<>(batchSize);
+ }
+
+ public void addToBatch(SeaTunnelRow element) {
+ Points.PointStruct point = buildPoint(element);
+ qdrantDataCache.add(point);
+ writeCount++;
+ }
+
+ public boolean needFlush() {
+ return this.writeCount >= this.batchSize;
+ }
+
+ public synchronized void flush() {
+ if (CollectionUtils.isEmpty(this.qdrantDataCache)) {
+ return;
+ }
+ upsert();
+ this.qdrantDataCache.clear();
+ this.writeCount = 0;
+ }
+
+ public void close() {
+ this.qdrantClient.close();
+ }
+
+ private Points.PointStruct buildPoint(SeaTunnelRow element) {
+ SeaTunnelRowType seaTunnelRowType = catalogTable.getSeaTunnelRowType();
+ PrimaryKey primaryKey = catalogTable.getTableSchema().getPrimaryKey();
+
+ Points.PointStruct.Builder point = Points.PointStruct.newBuilder();
+ Points.NamedVectors.Builder namedVectors = Points.NamedVectors.newBuilder();
+ for (int i = 0; i < seaTunnelRowType.getFieldNames().length; i++) {
+ String fieldName = seaTunnelRowType.getFieldNames()[i];
+ SeaTunnelDataType<?> fieldType = seaTunnelRowType.getFieldType(i);
+ Object value = element.getField(i);
+
+ if (isPrimaryKeyField(primaryKey, fieldName)) {
+ point.setId(pointId(fieldType, value));
+ continue;
+ }
+
+ JsonWithInt.Value payloadValue = buildPayload(fieldType, value);
+ if (payloadValue != null) {
+ point.putPayload(fieldName, payloadValue);
+ continue;
+ }
+
+ Points.Vector vector = buildVector(fieldType, value);
+ if (vector != null) {
+ namedVectors.putVectors(fieldName, vector);
+ }
+ }
+
+ if (!point.hasId()) {
+ point.setId(id(UUID.randomUUID()));
+ }
+
+ point.setVectors(Points.Vectors.newBuilder().setVectors(namedVectors).build());
+ return point.build();
+ }
+
+ private void upsert() {
+ try {
+ qdrantClient
+ .upsertAsync(
+ Points.UpsertPoints.newBuilder()
+ .setCollectionName(collectionName)
+ .addAllPoints(qdrantDataCache)
+ .build())
+ .get();
+ } catch (InterruptedException | ExecutionException e) {
+ throw new RuntimeException("Upsert failed", e);
+ }
+ }
+
+ public static Points.PointId pointId(SeaTunnelDataType<?> fieldType, Object value) {
+ SqlType sqlType = fieldType.getSqlType();
+ switch (sqlType) {
+ case INT:
+ return id(Integer.parseInt(value.toString()));
+ case STRING:
+ return id(UUID.fromString(value.toString()));
+ default:
+ throw new QdrantConnectorException(
+ CommonErrorCode.UNSUPPORTED_DATA_TYPE,
+ "Unexpected value type for point ID: " + sqlType.name());
+ }
+ }
+
+ public static JsonWithInt.Value buildPayload(SeaTunnelDataType<?> fieldType, Object value) {
+ SqlType sqlType = fieldType.getSqlType();
+ switch (sqlType) {
+ case SMALLINT:
+ case INT:
+ case BIGINT:
+ return ValueFactory.value(Integer.parseInt(value.toString()));
+ case FLOAT:
+ case DOUBLE:
+ return ValueFactory.value(Long.parseLong(value.toString()));
+ case STRING:
+ case DATE:
+ return ValueFactory.value(value.toString());
+ case BOOLEAN:
+ return ValueFactory.value(Boolean.parseBoolean(value.toString()));
+ default:
+ return null;
+ }
+ }
+
+ public static Points.Vector buildVector(SeaTunnelDataType<?> fieldType, Object value) {
+ SqlType sqlType = fieldType.getSqlType();
+ switch (sqlType) {
+ case FLOAT_VECTOR:
+ case FLOAT16_VECTOR:
+ case BFLOAT16_VECTOR:
+ case BINARY_VECTOR:
+ List<Float> floats = new ArrayList<>();
+ for (Object o : (Object[]) value) {
+ floats.add(Float.parseFloat(o.toString()));
+ }
+ return VectorFactory.vector(floats);
+ default:
+ return null;
Review Comment:
Also pay attention to we update FLOAT_VECTOR from `List<Float>` to `ByteBuffer`. Please refer https://github.com/apache/seatunnel/pull/7446/files#diff-da88074adfe9dc704c385cb440c04c201ba810578ed7e1ea7c25c116277c8115R324
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support Qdrant sink and source connector [seatunnel]
Posted by "Anush008 (via GitHub)" <gi...@apache.org>.
Anush008 commented on code in PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#discussion_r1731636003
##########
seatunnel-connectors-v2/connector-qdrant/src/main/java/org/apache/seatunnel/connectors/seatunnel/qdrant/sink/QdrantBatchWriter.java:
##########
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.qdrant.sink;
+
+import org.apache.seatunnel.api.table.catalog.CatalogTable;
+import org.apache.seatunnel.api.table.catalog.PrimaryKey;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.api.table.type.SqlType;
+import org.apache.seatunnel.common.exception.CommonErrorCode;
+import org.apache.seatunnel.connectors.seatunnel.qdrant.config.QdrantParameters;
+import org.apache.seatunnel.connectors.seatunnel.qdrant.exception.QdrantConnectorException;
+
+import org.apache.commons.collections4.CollectionUtils;
+
+import io.qdrant.client.QdrantClient;
+import io.qdrant.client.ValueFactory;
+import io.qdrant.client.VectorFactory;
+import io.qdrant.client.grpc.JsonWithInt;
+import io.qdrant.client.grpc.Points;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.ExecutionException;
+
+import static io.qdrant.client.PointIdFactory.id;
+import static org.apache.seatunnel.api.table.catalog.PrimaryKey.isPrimaryKeyField;
+
+public class QdrantBatchWriter {
+
+ private final int batchSize;
+ private final CatalogTable catalogTable;
+ private final String collectionName;
+ private final QdrantClient qdrantClient;
+
+ private final List<Points.PointStruct> qdrantDataCache;
+ private volatile int writeCount = 0;
+
+ public QdrantBatchWriter(
+ CatalogTable catalogTable, Integer batchSize, QdrantParameters params) {
+ this.catalogTable = catalogTable;
+ this.qdrantClient = params.buildQdrantClient();
+ this.collectionName = params.getCollectionName();
+ this.batchSize = batchSize;
+ this.qdrantDataCache = new ArrayList<>(batchSize);
+ }
+
+ public void addToBatch(SeaTunnelRow element) {
+ Points.PointStruct point = buildPoint(element);
+ qdrantDataCache.add(point);
+ writeCount++;
+ }
+
+ public boolean needFlush() {
+ return this.writeCount >= this.batchSize;
+ }
+
+ public synchronized void flush() {
+ if (CollectionUtils.isEmpty(this.qdrantDataCache)) {
+ return;
+ }
+ upsert();
+ this.qdrantDataCache.clear();
+ this.writeCount = 0;
+ }
+
+ public void close() {
+ this.qdrantClient.close();
+ }
+
+ private Points.PointStruct buildPoint(SeaTunnelRow element) {
+ SeaTunnelRowType seaTunnelRowType = catalogTable.getSeaTunnelRowType();
+ PrimaryKey primaryKey = catalogTable.getTableSchema().getPrimaryKey();
+
+ Points.PointStruct.Builder point = Points.PointStruct.newBuilder();
+ Points.NamedVectors.Builder namedVectors = Points.NamedVectors.newBuilder();
+ for (int i = 0; i < seaTunnelRowType.getFieldNames().length; i++) {
+ String fieldName = seaTunnelRowType.getFieldNames()[i];
+ SeaTunnelDataType<?> fieldType = seaTunnelRowType.getFieldType(i);
+ Object value = element.getField(i);
+
+ if (isPrimaryKeyField(primaryKey, fieldName)) {
+ point.setId(pointId(fieldType, value));
+ continue;
+ }
+
+ JsonWithInt.Value payloadValue = buildPayload(fieldType, value);
+ if (payloadValue != null) {
+ point.putPayload(fieldName, payloadValue);
+ continue;
+ }
+
+ Points.Vector vector = buildVector(fieldType, value);
+ if (vector != null) {
+ namedVectors.putVectors(fieldName, vector);
+ }
+ }
+
+ if (!point.hasId()) {
+ point.setId(id(UUID.randomUUID()));
+ }
+
+ point.setVectors(Points.Vectors.newBuilder().setVectors(namedVectors).build());
+ return point.build();
+ }
+
+ private void upsert() {
+ try {
+ qdrantClient
+ .upsertAsync(
+ Points.UpsertPoints.newBuilder()
+ .setCollectionName(collectionName)
+ .addAllPoints(qdrantDataCache)
+ .build())
+ .get();
+ } catch (InterruptedException | ExecutionException e) {
+ throw new RuntimeException("Upsert failed", e);
+ }
+ }
+
+ public static Points.PointId pointId(SeaTunnelDataType<?> fieldType, Object value) {
+ SqlType sqlType = fieldType.getSqlType();
+ switch (sqlType) {
+ case INT:
+ return id(Integer.parseInt(value.toString()));
+ case STRING:
+ return id(UUID.fromString(value.toString()));
+ default:
+ throw new QdrantConnectorException(
+ CommonErrorCode.UNSUPPORTED_DATA_TYPE,
+ "Unexpected value type for point ID: " + sqlType.name());
+ }
+ }
+
+ public static JsonWithInt.Value buildPayload(SeaTunnelDataType<?> fieldType, Object value) {
+ SqlType sqlType = fieldType.getSqlType();
+ switch (sqlType) {
+ case SMALLINT:
+ case INT:
+ case BIGINT:
+ return ValueFactory.value(Integer.parseInt(value.toString()));
+ case FLOAT:
+ case DOUBLE:
+ return ValueFactory.value(Long.parseLong(value.toString()));
+ case STRING:
+ case DATE:
+ return ValueFactory.value(value.toString());
+ case BOOLEAN:
+ return ValueFactory.value(Boolean.parseBoolean(value.toString()));
+ default:
+ return null;
+ }
+ }
+
+ public static Points.Vector buildVector(SeaTunnelDataType<?> fieldType, Object value) {
+ SqlType sqlType = fieldType.getSqlType();
+ switch (sqlType) {
+ case FLOAT_VECTOR:
+ case FLOAT16_VECTOR:
+ case BFLOAT16_VECTOR:
+ case BINARY_VECTOR:
+ List<Float> floats = new ArrayList<>();
+ for (Object o : (Object[]) value) {
+ floats.add(Float.parseFloat(o.toString()));
+ }
+ return VectorFactory.vector(floats);
+ default:
+ return null;
Review Comment:
I am having problems running the integration tests for now.
```
Caused by: org.testcontainers.containers.ContainerFetchException: Failed to pull image: testcontainers/ryuk:0.3.4
```
I will have to sort that.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support Qdrant sink and source connector [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#discussion_r1738458657
##########
seatunnel-connectors-v2/connector-qdrant/src/main/java/org/apache/seatunnel/connectors/seatunnel/qdrant/source/QdrantSource.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.qdrant.source;
+
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
+import org.apache.seatunnel.api.source.Boundedness;
+import org.apache.seatunnel.api.table.catalog.CatalogTable;
+import org.apache.seatunnel.api.table.catalog.CatalogTableUtil;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.connectors.seatunnel.common.source.AbstractSingleSplitReader;
+import org.apache.seatunnel.connectors.seatunnel.common.source.AbstractSingleSplitSource;
+import org.apache.seatunnel.connectors.seatunnel.common.source.SingleSplitReaderContext;
+import org.apache.seatunnel.connectors.seatunnel.qdrant.config.QdrantConfig;
+import org.apache.seatunnel.connectors.seatunnel.qdrant.config.QdrantParameters;
+
+import java.util.Collections;
+import java.util.List;
+
+public class QdrantSource extends AbstractSingleSplitSource<SeaTunnelRow> {
+ private final QdrantParameters qdrantParameters;
+ private final CatalogTable catalogTable;
+
+ @Override
+ public String getPluginName() {
+ return QdrantConfig.CONNECTOR_IDENTITY;
+ }
+
+ public QdrantSource(ReadonlyConfig readonlyConfig) {
+ this.qdrantParameters = new QdrantParameters(readonlyConfig);
+ this.catalogTable = CatalogTableUtil.buildWithConfig(readonlyConfig);
Review Comment:
I got it. Thanks for your share doc and explain!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: Qdrant sink and source [seatunnel]
Posted by "Anush008 (via GitHub)" <gi...@apache.org>.
Anush008 commented on code in PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#discussion_r1701580216
##########
docs/en/connector-v2/sink/Qdrant.md:
##########
@@ -0,0 +1,70 @@
+# Qdrant
Review Comment:
I can try that.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: Qdrant sink and source [seatunnel]
Posted by "Anush008 (via GitHub)" <gi...@apache.org>.
Anush008 commented on code in PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#discussion_r1701579554
##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-qdrant-e2e/src/test/java/org/apache/seatunnel/e2e/connector/v2/qdrant/QdrantIT.java:
##########
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.e2e.connector.v2.qdrant;
+
+import org.apache.seatunnel.e2e.common.TestResource;
+import org.apache.seatunnel.e2e.common.TestSuiteBase;
+import org.apache.seatunnel.e2e.common.container.EngineType;
+import org.apache.seatunnel.e2e.common.container.TestContainer;
+import org.apache.seatunnel.e2e.common.junit.DisabledOnContainer;
+
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.TestTemplate;
+import org.testcontainers.containers.Container;
+import org.testcontainers.lifecycle.Startables;
+import org.testcontainers.qdrant.QdrantContainer;
+
+import io.qdrant.client.QdrantClient;
+import io.qdrant.client.QdrantGrpcClient;
+import io.qdrant.client.grpc.Collections;
+import io.qdrant.client.grpc.Points;
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Stream;
+
+import static io.qdrant.client.PointIdFactory.id;
+import static io.qdrant.client.ValueFactory.value;
+import static io.qdrant.client.VectorFactory.vector;
+import static io.qdrant.client.VectorsFactory.namedVectors;
+
+@Slf4j
+@DisabledOnContainer(
+ value = {},
+ type = {EngineType.SPARK, EngineType.FLINK},
+ disabledReason = "Currently SPARK and FLINK not support adapt")
Review Comment:
TODO.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: Qdrant sink and source [seatunnel]
Posted by "Anush008 (via GitHub)" <gi...@apache.org>.
Anush008 commented on code in PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#discussion_r1701579554
##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-qdrant-e2e/src/test/java/org/apache/seatunnel/e2e/connector/v2/qdrant/QdrantIT.java:
##########
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.e2e.connector.v2.qdrant;
+
+import org.apache.seatunnel.e2e.common.TestResource;
+import org.apache.seatunnel.e2e.common.TestSuiteBase;
+import org.apache.seatunnel.e2e.common.container.EngineType;
+import org.apache.seatunnel.e2e.common.container.TestContainer;
+import org.apache.seatunnel.e2e.common.junit.DisabledOnContainer;
+
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.TestTemplate;
+import org.testcontainers.containers.Container;
+import org.testcontainers.lifecycle.Startables;
+import org.testcontainers.qdrant.QdrantContainer;
+
+import io.qdrant.client.QdrantClient;
+import io.qdrant.client.QdrantGrpcClient;
+import io.qdrant.client.grpc.Collections;
+import io.qdrant.client.grpc.Points;
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Stream;
+
+import static io.qdrant.client.PointIdFactory.id;
+import static io.qdrant.client.ValueFactory.value;
+import static io.qdrant.client.VectorFactory.vector;
+import static io.qdrant.client.VectorsFactory.namedVectors;
+
+@Slf4j
+@DisabledOnContainer(
+ value = {},
+ type = {EngineType.SPARK, EngineType.FLINK},
+ disabledReason = "Currently SPARK and FLINK not support adapt")
Review Comment:
TODO.
I have to add the primary key handling.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support Qdrant sink and source connector [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#discussion_r1738427518
##########
seatunnel-connectors-v2/connector-qdrant/src/main/java/org/apache/seatunnel/connectors/seatunnel/qdrant/source/QdrantSource.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.qdrant.source;
+
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
+import org.apache.seatunnel.api.source.Boundedness;
+import org.apache.seatunnel.api.table.catalog.CatalogTable;
+import org.apache.seatunnel.api.table.catalog.CatalogTableUtil;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.connectors.seatunnel.common.source.AbstractSingleSplitReader;
+import org.apache.seatunnel.connectors.seatunnel.common.source.AbstractSingleSplitSource;
+import org.apache.seatunnel.connectors.seatunnel.common.source.SingleSplitReaderContext;
+import org.apache.seatunnel.connectors.seatunnel.qdrant.config.QdrantConfig;
+import org.apache.seatunnel.connectors.seatunnel.qdrant.config.QdrantParameters;
+
+import java.util.Collections;
+import java.util.List;
+
+public class QdrantSource extends AbstractSingleSplitSource<SeaTunnelRow> {
+ private final QdrantParameters qdrantParameters;
+ private final CatalogTable catalogTable;
+
+ @Override
+ public String getPluginName() {
+ return QdrantConfig.CONNECTOR_IDENTITY;
+ }
+
+ public QdrantSource(ReadonlyConfig readonlyConfig) {
+ this.qdrantParameters = new QdrantParameters(readonlyConfig);
+ this.catalogTable = CatalogTableUtil.buildWithConfig(readonlyConfig);
Review Comment:
When a collection defined, can we get it schema by `payload_schema` fields with https://qdrant.tech/documentation/concepts/collections/#collection-info api?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support Qdrant sink and source connector [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#discussion_r1738406427
##########
seatunnel-connectors-v2/connector-qdrant/src/main/java/org/apache/seatunnel/connectors/seatunnel/qdrant/source/QdrantSource.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.qdrant.source;
+
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
+import org.apache.seatunnel.api.source.Boundedness;
+import org.apache.seatunnel.api.table.catalog.CatalogTable;
+import org.apache.seatunnel.api.table.catalog.CatalogTableUtil;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.connectors.seatunnel.common.source.AbstractSingleSplitReader;
+import org.apache.seatunnel.connectors.seatunnel.common.source.AbstractSingleSplitSource;
+import org.apache.seatunnel.connectors.seatunnel.common.source.SingleSplitReaderContext;
+import org.apache.seatunnel.connectors.seatunnel.qdrant.config.QdrantConfig;
+import org.apache.seatunnel.connectors.seatunnel.qdrant.config.QdrantParameters;
+
+import java.util.Collections;
+import java.util.List;
+
+public class QdrantSource extends AbstractSingleSplitSource<SeaTunnelRow> {
+ private final QdrantParameters qdrantParameters;
+ private final CatalogTable catalogTable;
+
+ @Override
+ public String getPluginName() {
+ return QdrantConfig.CONNECTOR_IDENTITY;
+ }
+
+ public QdrantSource(ReadonlyConfig readonlyConfig) {
+ this.qdrantParameters = new QdrantParameters(readonlyConfig);
+ this.catalogTable = CatalogTableUtil.buildWithConfig(readonlyConfig);
Review Comment:
Does `Qdrant` can support get catalogtable from `Catalog`? Instead of use schema options.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support Qdrant sink and source connector [seatunnel]
Posted by "hailin0 (via GitHub)" <gi...@apache.org>.
hailin0 commented on code in PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299#discussion_r1709478673
##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-qdrant-e2e/src/test/java/org/apache/seatunnel/e2e/connector/v2/qdrant/QdrantIT.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.e2e.connector.v2.qdrant;
+
+import org.apache.seatunnel.e2e.common.TestResource;
+import org.apache.seatunnel.e2e.common.TestSuiteBase;
+import org.apache.seatunnel.e2e.common.container.EngineType;
+import org.apache.seatunnel.e2e.common.container.TestContainer;
+import org.apache.seatunnel.e2e.common.junit.DisabledOnContainer;
+
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.TestTemplate;
+import org.testcontainers.containers.Container;
+import org.testcontainers.lifecycle.Startables;
+import org.testcontainers.qdrant.QdrantContainer;
+import org.testcontainers.shaded.com.google.common.collect.ImmutableMap;
+
+import io.qdrant.client.QdrantClient;
+import io.qdrant.client.QdrantGrpcClient;
+import io.qdrant.client.grpc.Collections;
+import io.qdrant.client.grpc.Points;
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Stream;
+
+import static io.qdrant.client.PointIdFactory.id;
+import static io.qdrant.client.ValueFactory.value;
+import static io.qdrant.client.VectorFactory.vector;
+import static io.qdrant.client.VectorsFactory.namedVectors;
+
+@Slf4j
+@DisabledOnContainer(
+ value = {},
+ type = {EngineType.SPARK, EngineType.FLINK})
Review Comment:
ok
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support Qdrant sink and source connector [seatunnel]
Posted by "hailin0 (via GitHub)" <gi...@apache.org>.
hailin0 merged PR #7299:
URL: https://github.com/apache/seatunnel/pull/7299
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org