All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mapdb.StoreReadOnlyWrapper.kt Maven / Gradle / Ivy

Go to download

MapDB provides concurrent Maps, Sets and Queues backed by disk storage or off-heap memory. It is a fast, scalable and easy to use embedded Java database.

There is a newer version: 3.1.0
Show newest version
package org.mapdb

/**
 * Wraps Store and throws `UnsupportedOperationException("Read-only")` on operations which would modify it
 */
class StoreReadOnlyWrapper(protected val store:Store):Store{

    override fun close() {
        store.close()
    }

    override fun commit() {
        throw UnsupportedOperationException("Read-only")
    }

    override fun compact() {
        throw UnsupportedOperationException("Read-only")
    }

    override fun  compareAndSwap(recid: Long, expectedOldRecord: R?, newRecord: R?, serializer: Serializer): Boolean {
        throw UnsupportedOperationException("Read-only")
    }

    override fun  delete(recid: Long, serializer: Serializer) {
        throw UnsupportedOperationException("Read-only")
    }

    override val isClosed: Boolean
        get() = store.isClosed

    override val isThreadSafe: Boolean
        get() = store.isThreadSafe

    override val isReadOnly = true

    override fun preallocate(): Long {
        throw UnsupportedOperationException("Read-only")
    }

    override fun  put(record: R?, serializer: Serializer): Long {
        throw UnsupportedOperationException("Read-only")
    }

    override fun  update(recid: Long, record: R?, serializer: Serializer) {
        throw UnsupportedOperationException("Read-only")
    }

    override fun verify() {
        store.verify()
    }

    override fun  get(recid: Long, serializer: Serializer): R? {
        return store.get(recid, serializer)
    }

    override fun getAllRecids(): LongIterator {
        return store.getAllRecids()
    }

    override fun fileLoad() = store.fileLoad()

    override fun getAllFiles() = store.getAllFiles()

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy