Skip to content

Commit

Permalink
Replace BTree with Map and List...
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksey Zhidkov committed Jan 11, 2019
1 parent ab878fe commit cdbf347
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 996 deletions.
7 changes: 1 addition & 6 deletions src/main/kotlin/qbit/IndexDb.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ interface Db {

fun attr(attr: String): Attr<Any>?

fun <T : Any> get(eid: EID, attr: Attr<T>): Set<T>
}

class IndexDb(internal val index: Index) : Db {
Expand All @@ -63,18 +62,14 @@ class IndexDb(internal val index: Index) : Db {

override fun pull(eid: EID): StoredEntity? {
val entity = index.entityById(eid) ?: return null
val attrValues = entity.map {
val attrValues = entity.entries.map {
val attr = schema.find(it.key)
require(attr != null)
attr to it.value
}
return Entity(eid, attrValues, this)
}

override fun <T : Any> get(eid: EID, attr: Attr<T>): Set<T> {
return index.valueByEidAttr(eid, attr)
}

override fun query(vararg preds: QueryPred): List<StoredEntity> {
val eidSets = ArrayList<Set<EID>>(preds.size)
var minSet: Set<EID>? = null
Expand Down
Loading

0 comments on commit cdbf347

Please sign in to comment.