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

io.deephaven.engine.table.impl.sources.ReverseLookupColumnSource Maven / Gradle / Ivy

There is a newer version: 0.37.1
Show newest version
/**
 * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending
 */
package io.deephaven.engine.table.impl.sources;

import io.deephaven.stringset.LongBitmapStringSet;
import io.deephaven.engine.table.ColumnSource;

import java.util.function.ToIntFunction;

/**
 * Common interface for column sources that provide a reverse-lookup function (value to int key). Note that int keys are
 * used because this is intended for column sources with a small, contiguous key range starting from 0 and well shorter
 * than Integer.MAX_VALUE.
 */
public interface ReverseLookupColumnSource extends ColumnSource,
        LongBitmapStringSet.ReversibleLookup {
    /**
     * Get a reverse-lookup function for all non-null values stored in this column source at
     * {@code keys <= highestKeyNeeded}.
     *
     * @param highestKeyNeeded The highest key needed in the result map
     * @return A reverse-lookup function that has all values defined for keys in [0, highestKeyNeeded]
     */
    ToIntFunction getReverseLookup(final int highestKeyNeeded);

    /**
     * Get an implementation-defined "extra value" associated with this column source.
     */
    EXTRA_VALUE_TYPE getExtra();

    /**
     * Perform a reverse lookup
     *
     * @param highestIndex The highest key needed for the lookup
     * @param value The value we are looking up
     * @return The key, between 0 and highestIndex, for the value. A value outside this range if the value has no
     *         mapping in the range.
     */

    default int rget(int highestIndex, DATA_TYPE value) {
        return getReverseLookup(highestIndex).applyAsInt(value);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy