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

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


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

package io.permazen.core;

import io.permazen.kv.KeyFilter;
import io.permazen.util.UnsignedIntEncoder;

/**
 * A view of an index on a single value.
 */
class IndexView extends AbstractIndexView {

    /**
     * Normal constructor.
     *
     * @param storageId field storage ID
     * @param valueType index value type
     * @param targetType index target type
     * @throws IllegalArgumentException if any parameter is null is null or empty
     */
    IndexView(int storageId, FieldType valueType, FieldType targetType) {
        this(UnsignedIntEncoder.encode(storageId), false, valueType, targetType);
    }

    /**
     * Constructor for views formed from larger composite indexes.
     *
     * @param prefix key prefix
     * @param prefixMode true if {@code targetType} is not the final field in the index
     * @param valueType index value type
     * @param targetType index target type
     * @throws IllegalArgumentException if any parameter is null is null or empty
     */
    IndexView(byte[] prefix, boolean prefixMode, FieldType valueType, FieldType targetType) {
        super(prefix, prefixMode, valueType, targetType);
    }

    // Internal copy constructor
    private IndexView(IndexView original) {
        super(original);
    }

    @SuppressWarnings("unchecked")
    public FieldType getValueType() {
        return (FieldType)this.fieldTypes[0];
    }

    @SuppressWarnings("unchecked")
    public FieldType getTargetType() {
        return (FieldType)this.fieldTypes[1];
    }

    @Override
    @SuppressWarnings("unchecked")
    public IndexView filter(int index, KeyFilter keyFilter) {
        return (IndexView)super.filter(index, keyFilter);
    }

    @Override
    protected IndexView copy() {
        return new IndexView<>(this);
    }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy