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

io.permazen.core.SetElementIndex 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 com.google.common.base.Preconditions;

import io.permazen.schema.SimpleSchemaField;

import java.util.NavigableSet;

/**
 * An index on the elements of a set field.
 *
 * @param  set element type
 */
public class SetElementIndex extends CollectionElementIndex, E> {

// Constructor

    SetElementIndex(Schema schema, SimpleSchemaField schemaField, ObjType objType, SetField field) {
        super(schema, schemaField, objType, field);
    }

// IndexSwitch

    @Override
    public  R visit(IndexSwitch target) {
        Preconditions.checkArgument(target != null, "null target");
        return target.caseSetElementIndex(this);
    }

// Package Methods

    @Override
    boolean isPrefixModeForIndex() {
        return false;
    }

    @Override
    void unreference(Transaction tx, boolean remove, ObjId target, ObjId referrer, byte[] prefix) {
        final NavigableSet set = tx.readSetField(referrer, this.getField().parent.name, false);
        set.remove(target);
        if (!remove)
            set.add(null);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy