From 2771c6ebd9f25a05f8f51e46c4957ff72ff5de05 Mon Sep 17 00:00:00 2001 From: Ralph Gasser Date: Fri, 1 Dec 2023 08:38:27 +0100 Subject: [PATCH] Fixes a few warnings. --- .../org/vitrivr/cottontail/Playground.kt | 61 +++++++++++++++++++ .../grpc/services/TransactionalGrpcService.kt | 2 +- .../cottontail/server/grpc/DMLServiceTest.kt | 1 - .../vitrivr/cottontail/test/GrpcTestUtils.kt | 2 +- 4 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 cottontaildb-cli/src/main/kotlin/org/vitrivr/cottontail/Playground.kt diff --git a/cottontaildb-cli/src/main/kotlin/org/vitrivr/cottontail/Playground.kt b/cottontaildb-cli/src/main/kotlin/org/vitrivr/cottontail/Playground.kt new file mode 100644 index 000000000..1cc4cb809 --- /dev/null +++ b/cottontaildb-cli/src/main/kotlin/org/vitrivr/cottontail/Playground.kt @@ -0,0 +1,61 @@ +package org.vitrivr.cottontail + +import kotlinx.serialization.Serializable +import kotlinx.serialization.builtins.ListSerializer +import kotlinx.serialization.json.DecodeSequenceMode +import kotlinx.serialization.json.Json +import kotlinx.serialization.json.decodeToSequence +import kotlinx.serialization.json.encodeToStream +import java.nio.file.Files +import java.nio.file.Paths +import java.nio.file.StandardOpenOption +import java.util.* + +/** + * + * @author Ralph Gasser + * @version 1.0 + */ + +fun main(args: Array) { + val path = Paths.get("/Users/rgasser/Downloads/package/warren.VBSLHE.descriptor_file.0.json") + val json = Json { prettyPrint = true } + Files.newInputStream(path, StandardOpenOption.READ).use { input -> + val buffer = LinkedList() + var index = 0 + val descriptors = Json.decodeToSequence(input, FileDescriptor.serializer(), DecodeSequenceMode.ARRAY_WRAPPED) + for (descriptor in descriptors) { + buffer.add(descriptor) + if (buffer.size == 50_000) { + write(index++, buffer) + buffer.clear() + } + } + write(index, buffer) + } +} + +/** + * + */ +fun write(index: Int, buffer: LinkedList) { + val path = Paths.get("/Users/rgasser/Downloads/package/out/warren.VBSLHE.descriptor_file.$index.json") + Files.newOutputStream(path, StandardOpenOption.CREATE, StandardOpenOption.WRITE).use { output -> + Json.encodeToStream(ListSerializer(FileDescriptor.serializer()), buffer, output) + } +} + +@Serializable +data class Descriptor(val descriptorId: String, val retrievableId: String, val descriptor: FloatArray) + +@Serializable +data class Retrievable(val retrievableId: String, val type: String) + +@Serializable +data class Relationship(val objectId: String, val subjectId: String, val predicate: String) + +@Serializable +data class FileDescriptor(val descriptorId: String = UUID.randomUUID().toString(), val retrievableId: String, val size: Int, val path: String) {} + +@Serializable +data class TimeDescriptor(val descriptorId: String, val retrievableId: String, val start: Long, val end: Long) \ No newline at end of file diff --git a/cottontaildb-dbms/src/main/kotlin/org/vitrivr/cottontail/server/grpc/services/TransactionalGrpcService.kt b/cottontaildb-dbms/src/main/kotlin/org/vitrivr/cottontail/server/grpc/services/TransactionalGrpcService.kt index e64634903..93232e101 100644 --- a/cottontaildb-dbms/src/main/kotlin/org/vitrivr/cottontail/server/grpc/services/TransactionalGrpcService.kt +++ b/cottontaildb-dbms/src/main/kotlin/org/vitrivr/cottontail/server/grpc/services/TransactionalGrpcService.kt @@ -30,7 +30,7 @@ import kotlin.time.ExperimentalTime import kotlin.time.TimeSource /** - * A facility common to all service that handle [TransactionManager.TransactionImpl]s over gRPC. + * A facility common to all service that handle [TransactionManager.AbstractTransaction]s over gRPC. * * @author Ralph Gasser * @version 1.5.0 diff --git a/cottontaildb-dbms/src/test/kotlin/org/vitrivr/cottontail/server/grpc/DMLServiceTest.kt b/cottontaildb-dbms/src/test/kotlin/org/vitrivr/cottontail/server/grpc/DMLServiceTest.kt index 94cb2adb2..c5abf4fe1 100644 --- a/cottontaildb-dbms/src/test/kotlin/org/vitrivr/cottontail/server/grpc/DMLServiceTest.kt +++ b/cottontaildb-dbms/src/test/kotlin/org/vitrivr/cottontail/server/grpc/DMLServiceTest.kt @@ -325,7 +325,6 @@ class DMLServiceTest : AbstractClientTest() { fun testInvalidNullInsert() { val entries = TEST_COLLECTION_SIZE * 5 val batchSize = 1000 - val stringLength = 200 /* Start large insert. */ val txId = this.client.begin() diff --git a/cottontaildb-dbms/src/testFixtures/kotlin/org/vitrivr/cottontail/test/GrpcTestUtils.kt b/cottontaildb-dbms/src/testFixtures/kotlin/org/vitrivr/cottontail/test/GrpcTestUtils.kt index 4c11de196..7041e0436 100644 --- a/cottontaildb-dbms/src/testFixtures/kotlin/org/vitrivr/cottontail/test/GrpcTestUtils.kt +++ b/cottontaildb-dbms/src/testFixtures/kotlin/org/vitrivr/cottontail/test/GrpcTestUtils.kt @@ -115,7 +115,7 @@ object GrpcTestUtils { */ fun populateVectorEntity(client: SimpleClient) { val batch = BatchInsert(TestConstants.TEST_VECTOR_ENTITY_NAME.fqn) - .columns(ID_COLUMN_NAME, STRING_COLUMN_NAME, INT_COLUMN_NAME, TestConstants.TWOD_COLUMN_NAME) + .columns(ID_COLUMN_NAME, STRING_COLUMN_NAME, INT_COLUMN_NAME, TWOD_COLUMN_NAME) val random = Random.Default repeat(TestConstants.TEST_COLLECTION_SIZE) { val lat = random.nextFloat() + random.nextInt(0, 50)