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

io.deephaven.engine.table.impl.updateby.hashing.UpdateByStateManager Maven / Gradle / Ivy

There is a newer version: 0.37.1
Show newest version
package io.deephaven.engine.table.impl.updateby.hashing;

import io.deephaven.chunk.WritableIntChunk;
import io.deephaven.engine.rowset.RowSequence;
import io.deephaven.engine.rowset.chunkattributes.RowKeys;
import io.deephaven.engine.table.ColumnSource;
import io.deephaven.util.SafeCloseable;
import org.apache.commons.lang3.mutable.MutableInt;
import org.jetbrains.annotations.NotNull;

import java.util.Arrays;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * The basis for operators that participate in an updateBy operation.
 */
public abstract class UpdateByStateManager {

    protected final ColumnSource[] keySourcesForErrorMessages;

    protected UpdateByStateManager(ColumnSource[] keySourcesForErrorMessages) {
        this.keySourcesForErrorMessages = keySourcesForErrorMessages;
    }

    // produce a pretty key for error messages
    protected String extractKeyStringFromSourceTable(long leftKey) {
        if (keySourcesForErrorMessages.length == 1) {
            return Objects.toString(keySourcesForErrorMessages[0].get(leftKey));
        }
        return "[" + Arrays.stream(keySourcesForErrorMessages).map(ls -> Objects.toString(ls.get(leftKey))).collect(Collectors.joining(", ")) + "]";
    }

    public abstract void add(final boolean initialBuild,
             final SafeCloseable bc,
             final RowSequence orderedKeys,
             final ColumnSource[] sources,
             final MutableInt nextOutputPosition,
             final WritableIntChunk outputPositions);

    public void remove(@NotNull final SafeCloseable pc,
                        @NotNull final RowSequence indexToRemove,
                        @NotNull final ColumnSource[] sources,
                        @NotNull final WritableIntChunk outputPositions)  {
        throw new UnsupportedOperationException("Remove is not supported");
    }

    public void findModifications(@NotNull final SafeCloseable pc,
                                   @NotNull final RowSequence modifiedIndex,
                                   @NotNull final ColumnSource [] keySources,
                                   @NotNull final WritableIntChunk outputPositions)  {
        throw new UnsupportedOperationException("Find is not supported");
    }

    public abstract SafeCloseable makeUpdateByBuildContext(ColumnSource[] keySources, long updateSize);

    public SafeCloseable makeUpdateByProbeContext(ColumnSource[] buildSources, long maxSize) {
        throw new UnsupportedOperationException("Cannot make a probe context.");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy