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

io.deephaven.engine.table.impl.replay.ReplayGroupedFullTable 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.replay;

import io.deephaven.engine.rowset.RowSet;
import io.deephaven.engine.rowset.RowSetBuilderRandom;
import io.deephaven.engine.rowset.RowSetFactory;
import io.deephaven.engine.rowset.TrackingRowSet;
import io.deephaven.engine.table.ColumnSource;
import io.deephaven.engine.table.impl.util.*;
import io.deephaven.time.DateTimeUtils;

import java.util.Map;

public class ReplayGroupedFullTable extends QueryReplayGroupedTable {
    private int redirIndexSize;

    public ReplayGroupedFullTable(TrackingRowSet rowSet, Map> input,
            String timeColumn,
            Replayer replayer, String groupingColumn) {
        super("ReplayGroupedFullTable", rowSet, input, timeColumn, replayer,
                WritableRowRedirection.FACTORY.createRowRedirection((int) rowSet.size()),
                new String[] {groupingColumn});
        redirIndexSize = 0;
        // We do not modify existing entries in the WritableRowRedirection (we only add at the end), so there's no need
        // to ask the WritableRowRedirection to track previous values.
    }

    @Override
    public void run() {
        if (allIterators.isEmpty()) {
            return;
        }
        RowSetBuilderRandom rowSetBuilder = RowSetFactory.builderRandom();
        while (!allIterators.isEmpty()
                && DateTimeUtils.epochNanos(allIterators.peek().lastTime) < replayer.clock().currentTimeNanos()) {
            IteratorsAndNextTime currentIt = allIterators.poll();
            final long key = redirIndexSize++;
            rowRedirection.put(key, currentIt.lastIndex);
            rowSetBuilder.addKey(key);
            currentIt = currentIt.next();
            if (currentIt != null) {
                allIterators.add(currentIt);
            }
        }
        final RowSet added = rowSetBuilder.build();
        if (!added.isEmpty()) {
            getRowSet().writableCast().insert(added);
            notifyListeners(added, RowSetFactory.empty(), RowSetFactory.empty());
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy