xtdb.watermark.IWatermark.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xtdb-core Show documentation
Show all versions of xtdb-core Show documentation
An open source document database with bitemporal graph queries
The newest version!
package xtdb.watermark
import org.apache.arrow.vector.types.pojo.Field
import xtdb.api.TransactionKey
import xtdb.trie.MemoryHashTrie
import xtdb.vector.RelationReader
import java.util.concurrent.atomic.AtomicInteger
interface ILiveTableWatermark : AutoCloseable {
fun columnField(col: String): Field
fun columnFields(): Map
fun liveRelation(): RelationReader
fun liveTrie(): MemoryHashTrie
}
interface ILiveIndexWatermark : AutoCloseable {
fun allColumnFields(): Map>
fun liveTable(tableName: String): ILiveTableWatermark
}
class Watermark(
@JvmField val txBasis: TransactionKey?,
@JvmField val liveIndex: ILiveIndexWatermark?,
@JvmField val schema: Map
) : AutoCloseable {
private val refCount = AtomicInteger(1)
fun retain() {
if (0 == refCount.getAndIncrement()) throw IllegalStateException("watermark closed")
}
/**
* releases a reference to the Watermark.
* if this was the last reference, close it.
*/
override fun close() {
if (0 == refCount.decrementAndGet()) liveIndex?.close()
}
}
interface IWatermarkSource {
fun openWatermark(): Watermark
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy