xtdb.vector.extensions.TransitVector.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.vector.extensions
import clojure.lang.IFn
import com.cognitect.transit.Reader
import org.apache.arrow.memory.BufferAllocator
import org.apache.arrow.vector.VarBinaryVector
import org.apache.arrow.vector.types.pojo.FieldType
import xtdb.util.requiringResolve
import java.io.ByteArrayInputStream
private val TRANSIT_MSGPACK_READER: IFn = requiringResolve("xtdb.serde/transit-msgpack-reader")
class TransitVector(name: String, allocator: BufferAllocator, fieldType: FieldType) :
XtExtensionVector(name, allocator, fieldType, VarBinaryVector(name, allocator)) {
private fun transitReader(v: ByteArray): Reader = TRANSIT_MSGPACK_READER.invoke(ByteArrayInputStream(v)) as Reader
override fun getObject0(index: Int): Any = transitReader(underlyingVector[index]).read()
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy