io.deephaven.engine.table.impl.select.analyzers.BaseLayer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of deephaven-engine-table Show documentation
Show all versions of deephaven-engine-table Show documentation
Engine Table: Implementation and closely-coupled utilities
/**
* Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending
*/
package io.deephaven.engine.table.impl.select.analyzers;
import io.deephaven.base.log.LogOutput;
import io.deephaven.datastructures.util.CollectionUtil;
import io.deephaven.engine.liveness.LivenessNode;
import io.deephaven.engine.table.ColumnDefinition;
import io.deephaven.engine.table.TableUpdate;
import io.deephaven.engine.table.ModifiedColumnSet;
import io.deephaven.engine.table.ColumnSource;
import io.deephaven.engine.rowset.RowSet;
import io.deephaven.engine.table.impl.util.JobScheduler;
import org.jetbrains.annotations.Nullable;
import java.util.*;
public class BaseLayer extends SelectAndViewAnalyzer {
private final Map> sources;
private final boolean publishTheseSources;
BaseLayer(Map> sources, boolean publishTheseSources) {
super(BASE_LAYER_INDEX);
this.sources = sources;
this.publishTheseSources = publishTheseSources;
}
@Override
int getLayerIndexFor(String column) {
if (sources.containsKey(column)) {
return BASE_LAYER_INDEX;
}
throw new IllegalArgumentException("Unknown column: " + column);
}
@Override
void setBaseBits(BitSet bitset) {
bitset.set(BASE_LAYER_INDEX);
}
@Override
public void setAllNewColumns(BitSet bitset) {
bitset.set(BASE_LAYER_INDEX);
}
@Override
void populateModifiedColumnSetRecurse(ModifiedColumnSet mcsBuilder, Set remainingDepsToSatisfy) {
mcsBuilder.setAll(remainingDepsToSatisfy.toArray(CollectionUtil.ZERO_LENGTH_STRING_ARRAY));
}
@Override
final Map> getColumnSourcesRecurse(GetMode mode) {
// We specifically return a LinkedHashMap so the columns get populated in order
final Map> result = new LinkedHashMap<>();
if (mode == GetMode.All || (mode == GetMode.Published && publishTheseSources)) {
result.putAll(sources);
}
return result;
}
@Override
public void updateColumnDefinitionsFromTopLayer(Map> columnDefinitions) {
for (Map.Entry> entry : sources.entrySet()) {
final String name = entry.getKey();
final ColumnSource> cs = entry.getValue();
final ColumnDefinition> cd = ColumnDefinition.fromGenericType(name, cs.getType(), cs.getComponentType());
columnDefinitions.put(name, cd);
}
}
@Override
public void applyUpdate(TableUpdate upstream, RowSet toClear, UpdateHelper helper, JobScheduler jobScheduler,
@Nullable LivenessNode liveResultOwner, SelectLayerCompletionHandler onCompletion) {
// nothing to do at the base layer
onCompletion.onLayerCompleted(BASE_LAYER_INDEX);
}
@Override
final Map> calcDependsOnRecurse(boolean forcePublishAllSources) {
final Map> result = new HashMap<>();
if (publishTheseSources || forcePublishAllSources) {
for (final String col : sources.keySet()) {
result.computeIfAbsent(col, dummy -> new HashSet<>()).add(col);
}
}
return result;
}
@Override
public SelectAndViewAnalyzer getInner() {
return null;
}
@Override
public void startTrackingPrev() {
// nothing to do
}
@Override
public LogOutput append(LogOutput logOutput) {
return logOutput.append("{BaseLayer").append(", layerIndex=").append(getLayerIndex()).append("}");
}
@Override
public boolean allowCrossColumnParallelization() {
return true;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy