Skip to content

Commit

Permalink
Two minor optimisations.
Browse files Browse the repository at this point in the history
  • Loading branch information
ppanopticon committed Nov 4, 2023
1 parent 6264dc6 commit 0742940
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ class DefaultEntity(override val name: Name.EntityName, override val parent: Def
if (it.getSearchKeyRange(NameBinding.Entity.toEntry(this@DefaultEntity.name)) != null) {
do {
val indexName = NameBinding.Index.fromEntry(it.key)
if (indexName.entity() != this@DefaultEntity.name) {
break
}
val indexEntry = IndexMetadata.fromEntry(it.value)
this.indexes[indexName] = indexEntry.type.descriptor.open(indexName, this.dbo)
} while (it.next)
Expand Down Expand Up @@ -239,7 +242,8 @@ class DefaultEntity(override val name: Name.EntityName, override val parent: Def

/* Prepare index entry and persist it. */
val store = IndexMetadata.store(this@DefaultEntity.catalogue, this.context.txn.xodusTx)
val indexEntry = IndexMetadata(type, IndexState.DIRTY, columns.map { it.columnName }, configuration)
val state = if (this.count() == 0L) { IndexState.CLEAN } else { IndexState.DIRTY }
val indexEntry = IndexMetadata(type, state, columns.map { it.columnName }, configuration)
if (!store.add(this.context.txn.xodusTx, NameBinding.Index.toEntry(name), IndexMetadata.toEntry(indexEntry))) {
throw DatabaseException.IndexAlreadyExistsException(name)
}
Expand Down

0 comments on commit 0742940

Please sign in to comment.