Skip to content

Commit

Permalink
Merge pull request #104 from JetBrains/adopt-orientdb-support-origina…
Browse files Browse the repository at this point in the history
…l-blob-lazy-wait-for-build-for-internity

Adopt orientdb support original blob lazy wait for build for internity
  • Loading branch information
leostryuk authored Sep 9, 2024
2 parents b2b97fd + 84760eb commit 7077c28
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
package com.jetbrains.teamsys.dnq.database

import com.orientechnologies.orient.core.db.ODatabaseSession
import com.orientechnologies.orient.core.db.record.OIdentifiable
import com.orientechnologies.orient.core.id.ORID
import com.orientechnologies.orient.core.record.OVertex
import com.orientechnologies.orient.core.record.impl.ORecordBytes
import jetbrains.exodus.database.LinkChangeType
Expand Down Expand Up @@ -47,7 +49,13 @@ class TransientEntityOriginalValuesProviderImpl(private val session: TransientSt
val session = ODatabaseSession.getActiveSession()
val id = e.entity.id.asOId()
val oVertex = session.load<OVertex>(id)
val blobHolder = oVertex.getPropertyOnLoadValue<ORecordBytes?>(blobName)
val blobHolderOrId = oVertex.getPropertyOnLoadValue<OIdentifiable?>(blobName)
var blobHolder: ORecordBytes? = null
if (blobHolderOrId !is ORecordBytes && blobHolderOrId is ORID) {
blobHolder = session.load(blobHolderOrId)
} else if (blobHolderOrId is ORecordBytes) {
blobHolder = blobHolderOrId
}
return blobHolder?.toStream()?.let {
UTFUtil.readUTF((it).inputStream())
}
Expand All @@ -57,9 +65,15 @@ class TransientEntityOriginalValuesProviderImpl(private val session: TransientSt
val session = ODatabaseSession.getActiveSession()
val id = e.entity.id.asOId()
val oVertex = session.load<OVertex>(id)
val blobHolder = oVertex.getPropertyOnLoadValue<ORecordBytes?>(blobName)
return blobHolder?.let {
ByteArrayInputStream(blobHolder.toStream())
var blobHolder: ORecordBytes? = null
val blobHolderOrId = oVertex.getPropertyOnLoadValue<OIdentifiable?>(blobName)
if (blobHolderOrId !is ORecordBytes && blobHolderOrId is ORID) {
blobHolder = session.load(blobHolderOrId)
} else if (blobHolderOrId is ORecordBytes) {
blobHolder = blobHolderOrId as ORecordBytes
}
return blobHolder?.toStream()?.let {
ByteArrayInputStream(it)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ class TransientSessionImpl(

override val entitiesUpdater = TransientEntitiesUpdaterImpl(this)

override val originalValuesProvider:TransientEntityOriginalValuesProvider = TransientEntityOriginalValuesProviderImpl(this)
override val originalValuesProvider: TransientEntityOriginalValuesProvider =
TransientEntityOriginalValuesProviderImpl(this)

override val transientChangesTracker: TransientChangesTracker
get() {
Expand Down

0 comments on commit 7077c28

Please sign in to comment.