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

com.protonail.leveldb.jna.LevelDBReadOptions Maven / Gradle / Ivy

There is a newer version: 1.20.0
Show newest version
package com.protonail.leveldb.jna;

public class LevelDBReadOptions implements AutoCloseable {
    protected LevelDBNative.ReadOptions readOptions;

    private boolean verifyChecksum = false;
    private boolean fillCache = true;

    public LevelDBReadOptions() {
        readOptions = LevelDBNative.leveldb_readoptions_create();
        setVerifyChecksum(verifyChecksum);
        setFillCache(fillCache);
    }

    public void close() {
        checkReadOptionsOpen();

        LevelDBNative.leveldb_readoptions_destroy(readOptions);
        readOptions = null;
    }

    public boolean isVerifyChecksum() {
        return verifyChecksum;
    }

    public void setVerifyChecksum(boolean verifyChecksum) {
        checkReadOptionsOpen();

        this.verifyChecksum = verifyChecksum;
        LevelDBNative.leveldb_readoptions_set_verify_checksums(readOptions, (byte) (verifyChecksum ? 1 : 0));
    }

    public boolean isFillCache() {
        return fillCache;
    }

    public void setFillCache(boolean fillCache) {
        checkReadOptionsOpen();

        this.fillCache = fillCache;
        LevelDBNative.leveldb_readoptions_set_fill_cache(readOptions, (byte) (fillCache ? 1 : 0));
    }

    protected void checkReadOptionsOpen() {
        if (readOptions == null) {
            throw new LevelDBException("LevelDB read options was closed.");
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy