Skip to content

Commit

Permalink
Merge pull request #205 from JetBrains/graph-store-fix-empty-iterable
Browse files Browse the repository at this point in the history
Replace link to EIB.EMPTY to OEIB.EMPTY
  • Loading branch information
leostryuk authored Sep 12, 2024
2 parents 5e9ca43 + e2d6dee commit 816b98f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
10 changes: 4 additions & 6 deletions query/src/main/kotlin/jetbrains/exodus/query/QueryEngine.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import jetbrains.exodus.entitystore.EntityIterable
import jetbrains.exodus.entitystore.PersistentEntityStore
import jetbrains.exodus.entitystore.StoreTransaction
import jetbrains.exodus.entitystore.iterate.EntityIdSet
import jetbrains.exodus.entitystore.iterate.EntityIterableBase
import jetbrains.exodus.entitystore.iterate.EntityIterableBase.EMPTY
import jetbrains.exodus.entitystore.iterate.SingleEntityIterable
import jetbrains.exodus.entitystore.orientdb.OEntityIterable
import jetbrains.exodus.entitystore.orientdb.OEntityStore
Expand Down Expand Up @@ -91,7 +89,7 @@ open class QueryEngine(val modelMetaData: ModelMetaData?, val persistentStore: P
return left
}
if (left.isEmpty || right.isEmpty) {
return EMPTY
return OEntityIterableBase.EMPTY
}
return if (left is EntityIterable && right is EntityIterable) {
@Suppress("USELESS_CAST")
Expand Down Expand Up @@ -137,7 +135,7 @@ open class QueryEngine(val modelMetaData: ModelMetaData?, val persistentStore: P

open fun exclude(left: Iterable<Entity>, right: Iterable<Entity>): Iterable<Entity> {
if (left.isEmpty || left === right) {
return EMPTY
return OEntityIterableBase.EMPTY
}
if (right.isEmpty) {
return left
Expand Down Expand Up @@ -269,9 +267,9 @@ open class QueryEngine(val modelMetaData: ModelMetaData?, val persistentStore: P

private val Iterable<Entity>?.isEmpty: Boolean
get() {
return this == null || this === EMPTY || this is StaticTypedIterableDecorator && decorated === EMPTY
return this == null || this === OEntityIterableBase.EMPTY || this is StaticTypedIterableDecorator && decorated === OEntityIterableBase.EMPTY
}

private val Iterable<Entity>?.isPersistent: Boolean get() = this is EntityIterableBase
private val Iterable<Entity>?.isPersistent: Boolean get() = this is OEntityIterableBase


7 changes: 3 additions & 4 deletions query/src/main/kotlin/jetbrains/exodus/query/SortEngine.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package jetbrains.exodus.query
import jetbrains.exodus.entitystore.ComparableGetter
import jetbrains.exodus.entitystore.Entity
import jetbrains.exodus.entitystore.EntityIterable
import jetbrains.exodus.entitystore.iterate.EntityIterableBase
import jetbrains.exodus.entitystore.orientdb.OEntityIterable
import jetbrains.exodus.entitystore.orientdb.OVertexEntity
import jetbrains.exodus.entitystore.orientdb.iterate.OEntityIterableBase
Expand Down Expand Up @@ -46,7 +45,7 @@ open class SortEngine {
}
val i = queryEngine.toEntityIterable(source)
if (queryEngine.isPersistentIterable(i)) {
val it = (i as EntityIterableBase).source
val it = (i as OEntityIterableBase).unwrap()
if (it === OEntityIterableBase.EMPTY) {
OEntityIterableBase.EMPTY
}
Expand Down Expand Up @@ -122,7 +121,7 @@ open class SortEngine {
queryEngine.assertOperational()
val emd = mmd?.getEntityMetaData(entityType)
var it = if (emd != null && emd.isAbstract)
EntityIterableBase.EMPTY
OEntityIterableBase.EMPTY
else
queryEngine.instantiateGetAll(entityType)
if (emd != null) {
Expand All @@ -138,7 +137,7 @@ open class SortEngine {
}

private interface IterableGetter {
fun getIterable(type: String): EntityIterableBase
fun getIterable(type: String): OEntityIterableBase
}

private class EntityComparator(private val selector: ComparableGetter) : Comparator<Entity> {
Expand Down

0 comments on commit 816b98f

Please sign in to comment.