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

io.permazen.core.IndexSet Maven / Gradle / Ivy

Go to download

Permazen core API classes which provide objects, fields, indexes, queries, and schema management on top of a key/value store.

The newest version!

/*
 * Copyright (C) 2015 Archie L. Cobbs. All rights reserved.
 */

package io.permazen.core;

import io.permazen.encoding.Encoding;
import io.permazen.kv.KVStore;
import io.permazen.kv.KeyFilter;
import io.permazen.kv.KeyRange;
import io.permazen.util.Bounds;
import io.permazen.util.ByteUtil;

import java.util.NavigableSet;

/**
 * Implements the {@link NavigableSet} view of an index.
 *
 * @param  type of the values being indexed
 */
class IndexSet extends EncodingSet {

    // Primary constructor
    IndexSet(KVStore kv, Encoding entryType, boolean prefixMode, byte[] prefix) {
        super(kv, entryType, prefixMode, prefix);
    }

    // Internal constructor
    private IndexSet(KVStore kv, Encoding entryType, boolean prefixMode, boolean reversed,
      byte[] prefix, KeyRange keyRange, KeyFilter keyFilter, Bounds bounds) {
        super(kv, entryType, prefixMode, reversed, prefix, keyRange, keyFilter, bounds);
    }

    public String getDescription() {
        return "IndexSet"
          + "[prefix=" + ByteUtil.toString(this.prefix)
          + ",encoding=" + this.encoding
          + (this.bounds != null ? ",bounds=" + this.bounds : "")
          + (this.keyRange != null ? ",keyRange=" + this.keyRange : "")
          + (this.keyFilter != null ? ",keyFilter=" + this.keyFilter : "")
          + (this.reversed ? ",reversed" : "")
          + "]";
    }

// AbstractKVNavigableSet

    @Override
    protected NavigableSet createSubSet(boolean newReversed, KeyRange newKeyRange, KeyFilter newKeyFilter, Bounds newBounds) {
        return new IndexSet<>(this.kv, this.encoding,
          this.prefixMode, newReversed, this.prefix, newKeyRange, newKeyFilter, newBounds);
    }

    @Override
    public IndexSet filterKeys(KeyFilter keyFilter) {
        return (IndexSet)super.filterKeys(keyFilter);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy