Skip to content

Commit

Permalink
Merge pull request #244 from JetBrains/issue-226-ytdb-upgrade
Browse files Browse the repository at this point in the history
YTDB upgrade.
  • Loading branch information
andrii0lomakin authored Jan 21, 2025
2 parents 0e450d4 + 3a5d36a commit b9e348b
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion entity-store/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies {
api(project(":xodus-openAPI"))
api("io.youtrackdb:youtrackdb-core:1.0.0-20250116.142259-7")
api("io.youtrackdb:youtrackdb-core:1.0.0-20250120.134920-10")

implementation(project(":xodus-utils"))
implementation(project(":xodus-environment"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class OSchemaBuddyImpl(

override fun initialize(session: DatabaseSession) {
session.createClassIdSequenceIfAbsent()
for (oClass in session.schema.classes) {
for (oClass in session.schema.getClasses(session)) {
if (oClass.isVertexType && !INTERNAL_CLASS_NAMES.contains(oClass.name)) {
classIdToOClassId[oClass.requireClassId()] = oClass.clusterIds[0] to oClass.name
}
Expand Down Expand Up @@ -199,7 +199,7 @@ class OSchemaBuddyImpl(
entityTypeId: Int
): String {
val (_, typeName) = classIdToOClassId.computeIfAbsent(entityTypeId) {
val oClass = session.schema.classes.find { oClass ->
val oClass = session.schema.getClasses(session).find { oClass ->
oClass.getCustom(CLASS_ID_CUSTOM_PROPERTY_NAME)?.toInt() == entityTypeId
} ?: throw EntityRemovedInDatabaseException("Invalid type ID $entityTypeId")
oClass.requireClassId() to oClass.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class OStoreTransactionImpl(

override fun getEntityTypes(): MutableList<String> {
requireActiveTransaction()
return session.schema.classes.map { it.name }.toMutableList()
return session.schema.getClasses(session).map { it.name }.toMutableList()
}

override fun getAll(entityType: String): EntityIterable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ class XodusToOrientDataMigratorLauncher(
val dbProvider = orient.databaseProvider

val dbName = orient.orientConfig.databaseName
val classesCount = dbProvider.withSession {
it.schema.classes.filter { !it.name.startsWith("O") }.size
val classesCount = dbProvider.withSession { session ->
session.schema.getClasses(session).filter { schemaClass -> !schemaClass.name.startsWith("O") }.size
}
if (classesCount > VERTEX_CLASSES_TO_SKIP_MIGRATION) {
log.info { "There are already $classesCount classes in the database so it's considered as migrated" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import com.jetbrains.youtrack.db.api.DatabaseSession
import com.jetbrains.youtrack.db.api.record.Direction
import com.jetbrains.youtrack.db.api.record.Edge
import com.jetbrains.youtrack.db.api.record.Vertex
import com.jetbrains.youtrack.db.api.schema.Property
import com.jetbrains.youtrack.db.api.schema.SchemaProperty
import com.jetbrains.youtrack.db.api.schema.PropertyType
import com.jetbrains.youtrack.db.api.schema.SchemaClass
import com.jetbrains.youtrack.db.internal.core.collate.CaseInsensitiveCollate
Expand Down Expand Up @@ -456,7 +456,7 @@ internal class YouTrackDbSchemaInitializer(
appendLine()
}

private fun Property.applyCardinality(cardinality: AssociationEndCardinality) {
private fun SchemaProperty.applyCardinality(cardinality: AssociationEndCardinality) {
when (cardinality) {
AssociationEndCardinality._0_1 -> {
setRequirement(false)
Expand Down Expand Up @@ -484,7 +484,7 @@ internal class YouTrackDbSchemaInitializer(
}
}

private fun Property.setMaxIfDifferent(max: String?) {
private fun SchemaProperty.setMaxIfDifferent(max: String?) {
append(", max $max")
if (this.max == max) {
append(" already set")
Expand All @@ -494,7 +494,7 @@ internal class YouTrackDbSchemaInitializer(
}
}

private fun Property.setMinIfDifferent(min: String?) {
private fun SchemaProperty.setMinIfDifferent(min: String?) {
append(", min $min")
if (this.min == min) {
append(" already set")
Expand Down Expand Up @@ -668,7 +668,7 @@ internal class YouTrackDbSchemaInitializer(
appendLine()
}

private fun Property.setRequirement(required: Boolean) {
private fun SchemaProperty.setRequirement(required: Boolean) {
if (required) {
append(", required")
if (!isMandatory) {
Expand All @@ -683,7 +683,7 @@ internal class YouTrackDbSchemaInitializer(
}
}

private fun Property.setNotNullIfDifferent(notNull: Boolean) {
private fun SchemaProperty.setNotNullIfDifferent(notNull: Boolean) {
if (notNull) {
append(", not nullable")
if (!isNotNull) {
Expand All @@ -700,7 +700,7 @@ internal class YouTrackDbSchemaInitializer(
private fun SchemaClass.createPropertyIfAbsent(
propertyName: String,
oType: PropertyType
): Property {
): SchemaProperty {
append(", type is $oType")
val oProperty = if (existsProperty(propertyName)) {
append(", already created")
Expand Down Expand Up @@ -734,7 +734,7 @@ internal class YouTrackDbSchemaInitializer(
*
* But we still can set linkedClassType for direct link out-properties.
* */
private fun SchemaClass.createLinkPropertyIfAbsent(propertyName: String): Property {
private fun SchemaClass.createLinkPropertyIfAbsent(propertyName: String): SchemaProperty {
val oProperty = if (existsProperty(propertyName)) {
append(", already created")
getProperty(propertyName)
Expand All @@ -751,7 +751,7 @@ internal class YouTrackDbSchemaInitializer(
private fun SchemaClass.createEmbeddedSetPropertyIfAbsent(
propertyName: String,
oType: PropertyType
): Property {
): SchemaProperty {
append(", type of the set is $oType")
val oProperty = if (existsProperty(propertyName)) {
append(", already created")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import com.jetbrains.youtrack.db.api.DatabaseSession
import com.jetbrains.youtrack.db.api.record.Direction
import com.jetbrains.youtrack.db.api.record.Edge
import com.jetbrains.youtrack.db.api.record.Vertex
import com.jetbrains.youtrack.db.api.schema.Property
import com.jetbrains.youtrack.db.api.schema.SchemaProperty
import com.jetbrains.youtrack.db.api.schema.SchemaClass
import com.jetbrains.youtrack.db.internal.core.metadata.schema.SchemaClassInternal
import jetbrains.exodus.entitystore.orientdb.*
Expand Down Expand Up @@ -74,7 +74,7 @@ internal fun DatabaseSession.assertAssociationExists(
}
}

private fun Property.assertCardinality(cardinality: AssociationEndCardinality) {
private fun SchemaProperty.assertCardinality(cardinality: AssociationEndCardinality) {
when (cardinality) {
AssociationEndCardinality._0_1 -> {
assertTrue(!this.isMandatory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package jetbrains.exodus.query.metadata

import com.jetbrains.youtrack.db.api.exception.RecordDuplicatedException
import com.jetbrains.youtrack.db.api.schema.Property
import com.jetbrains.youtrack.db.api.schema.SchemaProperty
import com.jetbrains.youtrack.db.api.schema.PropertyType
import com.jetbrains.youtrack.db.internal.core.db.DatabaseSessionInternal
import jetbrains.exodus.entitystore.orientdb.OVertexEntity.Companion.LOCAL_ENTITY_ID_PROPERTY_NAME
Expand Down Expand Up @@ -576,7 +576,7 @@ class YouTrackDbSchemaInitializerTest {
}
}

private fun Property.check(required: Boolean, notNull: Boolean) {
private fun SchemaProperty.check(required: Boolean, notNull: Boolean) {
assertEquals(required, isMandatory)
assertEquals(notNull, isNotNull)
}
Expand Down

0 comments on commit b9e348b

Please sign in to comment.