Skip to content

Commit

Permalink
Per Slack w/Charles
Browse files Browse the repository at this point in the history
  • Loading branch information
nbauernfeind committed Nov 3, 2023
1 parent ecdf5eb commit aeb2478
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1525,9 +1525,8 @@ this, mode, columns, rowSet, getModifiedColumnSetForUpdates(), publishTheseSourc
}
}

final TrackingRowSet resultRowSet = analyzer.flattenedResult() && !rowSet.isFlat()
? RowSetFactory.flat(rowSet.size()).toTracking()
: rowSet;
final TrackingRowSet resultRowSet =
analyzer.flattenedResult() ? RowSetFactory.flat(rowSet.size()).toTracking() : rowSet;
resultTable = new QueryTable(resultRowSet, analyzerWrapper.getPublishedColumnResources());
if (liveResultCapture != null) {
analyzer.startTrackingPrev();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@
*/
final public class PreserveColumnLayer extends DependencyLayerBase {
private final BitSet dependencyBitSet;
private final boolean flattenedResult;

PreserveColumnLayer(SelectAndViewAnalyzer inner, String name, SelectColumn sc, ColumnSource<?> cs, String[] deps,
ModifiedColumnSet mcsBuilder, boolean flattenedResult) {
ModifiedColumnSet mcsBuilder) {
super(inner, name, sc, cs, deps, mcsBuilder);
this.dependencyBitSet = new BitSet();
this.flattenedResult = flattenedResult;
Arrays.stream(deps).mapToInt(inner::getLayerIndexFor).forEach(dependencyBitSet::set);
}

Expand Down Expand Up @@ -79,13 +77,14 @@ public LogOutput append(LogOutput logOutput) {

@Override
public boolean flattenedResult() {
return flattenedResult;
// a preserve layer is only flattened if the inner is flattened
return inner.flattenedResult();
}

@Override
public boolean alreadyFlattenedSources() {
// we can only preserve a flat source if it was already made flat
return flattenedResult;
// a preserve layer is only already flattened if the inner is already flattened
return inner.alreadyFlattenedSources();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public static SelectAndViewAnalyzerWrapper create(
}

analyzer = analyzer.createLayerForPreserve(
sc.getName(), sc, sc.getDataView(), distinctDeps, mcsBuilder, flatResult && flattenedResult);
sc.getName(), sc, sc.getDataView(), distinctDeps, mcsBuilder);

if (!sourceIsNew) {
// we can not flatten future columns because we are preserving a column that may not be flat
Expand All @@ -195,8 +195,7 @@ public static SelectAndViewAnalyzerWrapper create(
if (realColumn != null) {
final ColumnSource<?> alias = resultAlias.get(realColumn.getSourceName());
if (alias != null) {
analyzer = analyzer.createLayerForPreserve(
sc.getName(), sc, alias, distinctDeps, mcsBuilder, flatResult);
analyzer = analyzer.createLayerForPreserve(sc.getName(), sc, alias, distinctDeps, mcsBuilder);
continue;
}
}
Expand Down Expand Up @@ -387,8 +386,8 @@ private SelectAndViewAnalyzer createLayerForView(String name, SelectColumn sc, C
}

private SelectAndViewAnalyzer createLayerForPreserve(String name, SelectColumn sc, ColumnSource<?> cs,
String[] parentColumnDependencies, ModifiedColumnSet mcsBuilder, boolean flatResult) {
return new PreserveColumnLayer(this, name, sc, cs, parentColumnDependencies, mcsBuilder, flatResult);
String[] parentColumnDependencies, ModifiedColumnSet mcsBuilder) {
return new PreserveColumnLayer(this, name, sc, cs, parentColumnDependencies, mcsBuilder);
}

abstract void populateModifiedColumnSetRecurse(ModifiedColumnSet mcsBuilder, Set<String> remainingDepsToSatisfy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,16 @@ public LogOutput append(LogOutput logOutput) {
public boolean allowCrossColumnParallelization() {
return inner.allowCrossColumnParallelization();
}

@Override
public boolean flattenedResult() {
// this layer performs a flatten, so the result is flattened
return true;
}

@Override
public boolean alreadyFlattenedSources() {
// this layer performs a flatten, so the sources are now flattened
return true;
}
}

0 comments on commit aeb2478

Please sign in to comment.