-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
269 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,88 @@ | ||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
|
||
apply plugin: 'maven-publish' | ||
apply plugin: 'signing' | ||
|
||
repositories { | ||
mavenCentral() | ||
maven { url "https://kotlin.bintray.com/kotlinx" } | ||
} | ||
|
||
/** Source & target compatibility is Java 11. */ | ||
sourceCompatibility = 11 | ||
targetCompatibility = 11 | ||
|
||
compileKotlin { | ||
compilerOptions.jvmTarget = JvmTarget.JVM_11 | ||
} | ||
|
||
compileTestKotlin { | ||
compilerOptions.jvmTarget = JvmTarget.JVM_11 | ||
} | ||
|
||
java { | ||
withJavadocJar() | ||
withSourcesJar() | ||
} | ||
|
||
configurations { | ||
clientLibrary { | ||
canBeConsumed = true | ||
canBeResolved = false | ||
} | ||
} | ||
|
||
publishing { | ||
publications { | ||
mavenJava(MavenPublication) { | ||
groupId = 'org.vitrivr' | ||
artifactId = 'cottontaildb-core' | ||
version = System.getenv().getOrDefault("MAVEN_PUBLICATION_VERSION", version.toString()) | ||
pom { | ||
name = 'Cottontail DB Core Library' | ||
description = 'The Cottontail DB core library, which is a collection of classes that are used by different Cottontail DB components.' | ||
url = 'https://github.com/vitrivr/cottontaildb/' | ||
licenses { | ||
license { | ||
name = 'MIT License' | ||
} | ||
} | ||
developers { | ||
developer { | ||
id = 'ppanopticon' | ||
name = 'Ralph Gasser' | ||
email = '[email protected]' | ||
} | ||
} | ||
scm { | ||
connection = 'scm:git:https://github.com/vitrivr/cottontaildb.git' | ||
url = 'https://github.com/vitrivr/cottontaildb' | ||
} | ||
} | ||
from components.java | ||
} | ||
} | ||
repositories { | ||
maven { | ||
def releasesRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' | ||
def snapshotsRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots/' | ||
name = "OSSRH" | ||
url = (publishing.publications.mavenJava.version.endsWith('SNAPSHOT')) ? snapshotsRepoUrl : releasesRepoUrl | ||
credentials { | ||
username = System.getenv("MAVEN_USERNAME") | ||
password = System.getenv("MAVEN_PASSWORD") | ||
} | ||
} | ||
} | ||
} | ||
|
||
signing { | ||
def signingKey = findProperty("signingKey") | ||
def signingPassword = findProperty("signingPassword") | ||
useInMemoryPgpKeys(signingKey, signingPassword) | ||
sign publishing.publications.mavenJava | ||
} | ||
|
||
dependencies { | ||
/* The Cottontail DB client library. */ | ||
api project(':cottontaildb-client') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...-dbms/src/test/kotlin/org/vitrivr/cottontail/dbms/entity/sequence/AbstractSequenceTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package org.vitrivr.cottontail.dbms.entity.sequence | ||
|
||
import org.junit.jupiter.api.Assertions | ||
import org.junit.jupiter.api.Test | ||
import org.vitrivr.cottontail.core.tuple.StandaloneTuple | ||
import org.vitrivr.cottontail.core.types.Value | ||
import org.vitrivr.cottontail.core.values.IntValue | ||
import org.vitrivr.cottontail.core.values.LongValue | ||
import org.vitrivr.cottontail.core.values.generators.StringValueGenerator | ||
import org.vitrivr.cottontail.dbms.entity.AbstractEntityTest | ||
import org.vitrivr.cottontail.dbms.execution.transactions.TransactionType | ||
import org.vitrivr.cottontail.dbms.queries.context.DefaultQueryContext | ||
import org.vitrivr.cottontail.test.TestConstants | ||
import java.util.* | ||
|
||
/** | ||
* An abstract class for test cases that test for correctness of sequences | ||
* | ||
* @author Ralph Gasser | ||
* @version 1.0.0 | ||
*/ | ||
abstract class AbstractSequenceTest: AbstractEntityTest() { | ||
/** [SplittableRandom] used to generate random values. */ | ||
protected val random = SplittableRandom() | ||
|
||
@Test | ||
fun testSequence() { | ||
val txn1 = this.manager.startTransaction(TransactionType.SYSTEM_EXCLUSIVE) | ||
val ctx1 = DefaultQueryContext("test-sequence-insert", this.catalogue, txn1) | ||
|
||
/* Insert all entries. */ | ||
val catalogueTx1 = this.catalogue.newTx(ctx1) | ||
val schema1 = catalogueTx1.schemaForName(this.schemaName) | ||
val schemaTx1 = schema1.newTx(ctx1) | ||
val entity1 = schemaTx1.entityForName(TestConstants.TEST_ENTITY_NAME) | ||
val entityTx1 = entity1.newTx(ctx1) | ||
repeat(TestConstants.TEST_COLLECTION_SIZE - 1) { | ||
entityTx1.insert(this.nextRecord()) | ||
} | ||
txn1.commit() | ||
|
||
/* Iterate over entries and read IDs. */ | ||
val txn2 = this.manager.startTransaction(TransactionType.USER_READONLY) | ||
val ctx2 = DefaultQueryContext("test-sequence-read", this.catalogue, txn2) | ||
|
||
/* Insert all entries. */ | ||
val catalogueTx2 = this.catalogue.newTx(ctx2) | ||
val schema2 = catalogueTx2.schemaForName(this.schemaName) | ||
val schemaTx2 = schema2.newTx(ctx2) | ||
val entity2 = schemaTx2.entityForName(TestConstants.TEST_ENTITY_NAME) | ||
val entityTx2 = entity2.newTx(ctx2) | ||
val cursor = entityTx2.cursor(this.entities[0].second.toTypedArray()) | ||
for ((i, record) in cursor.withIndex()) { | ||
test(record[this.entities[0].second[0]], i) | ||
} | ||
txn2.commit() | ||
} | ||
|
||
/** We start with an empty entity. */ | ||
override fun populateDatabase() { | ||
/* No op */ | ||
} | ||
|
||
/** | ||
* Generates the next [StandaloneTuple] and returns it. | ||
*/ | ||
fun nextRecord(): StandaloneTuple { | ||
val string = StringValueGenerator.random(this.random) | ||
return StandaloneTuple(0L, columns = arrayOf(this.entities[0].second[1]), values = arrayOf(string)) | ||
} | ||
|
||
abstract fun test(value: Value?, index: Int) | ||
} |
21 changes: 21 additions & 0 deletions
21
...aildb-dbms/src/test/kotlin/org/vitrivr/cottontail/dbms/entity/sequence/IntSequenceTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.vitrivr.cottontail.dbms.entity.sequence | ||
|
||
import org.junit.jupiter.api.Assertions | ||
import org.vitrivr.cottontail.core.database.ColumnDef | ||
import org.vitrivr.cottontail.core.database.Name | ||
import org.vitrivr.cottontail.core.types.Types | ||
import org.vitrivr.cottontail.core.types.Value | ||
import org.vitrivr.cottontail.core.values.IntValue | ||
import org.vitrivr.cottontail.test.TestConstants | ||
|
||
class IntSequenceTest: AbstractSequenceTest() { | ||
/** The test entity. */ | ||
override val entities: List<Pair<Name.EntityName, List<ColumnDef<*>>>> = listOf( | ||
TestConstants.TEST_ENTITY_NAME to listOf( | ||
ColumnDef(TestConstants.TEST_ENTITY_NAME.column(TestConstants.ID_COLUMN_NAME), Types.Int, nullable = false, primary = true, autoIncrement = true), | ||
ColumnDef(TestConstants.TEST_ENTITY_NAME.column(TestConstants.STRING_COLUMN_NAME), Types.String, nullable = false, primary = false, autoIncrement = false), | ||
) | ||
) | ||
|
||
override fun test(value: Value?, index: Int) = Assertions.assertEquals(index+1, (value as? IntValue)!!.value) | ||
} |
21 changes: 21 additions & 0 deletions
21
...ildb-dbms/src/test/kotlin/org/vitrivr/cottontail/dbms/entity/sequence/LongSequenceTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.vitrivr.cottontail.dbms.entity.sequence | ||
|
||
import org.junit.jupiter.api.Assertions | ||
import org.vitrivr.cottontail.core.database.ColumnDef | ||
import org.vitrivr.cottontail.core.database.Name | ||
import org.vitrivr.cottontail.core.types.Types | ||
import org.vitrivr.cottontail.core.types.Value | ||
import org.vitrivr.cottontail.core.values.LongValue | ||
import org.vitrivr.cottontail.test.TestConstants | ||
|
||
class LongSequenceTest: AbstractSequenceTest() { | ||
/** The test entity. */ | ||
override val entities: List<Pair<Name.EntityName, List<ColumnDef<*>>>> = listOf( | ||
TestConstants.TEST_ENTITY_NAME to listOf( | ||
ColumnDef(TestConstants.TEST_ENTITY_NAME.column(TestConstants.ID_COLUMN_NAME), Types.Long, nullable = false, primary = true, autoIncrement = true), | ||
ColumnDef(TestConstants.TEST_ENTITY_NAME.column(TestConstants.STRING_COLUMN_NAME), Types.String, nullable = false, primary = false, autoIncrement = false), | ||
) | ||
) | ||
|
||
override fun test(value: Value?, index: Int) = Assertions.assertEquals(index+1L, (value as? LongValue)!!.value) | ||
} |