Skip to content

Commit

Permalink
revertIble-testing-related-trial-stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
kgyrtkirk committed Jan 16, 2024
1 parent 11d7061 commit fd09d9f
Showing 1 changed file with 97 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,69 +121,19 @@ public static Sequence<ResultRow> process(
);

return cursors.flatMap(
cursor -> new BaseSequence<>(
new BaseSequence.IteratorMaker<ResultRow, GroupByEngineIterator<?>>()
{
@Override
public GroupByEngineIterator<?> make()
{
final ColumnSelectorFactory columnSelectorFactory = cursor.getColumnSelectorFactory();
final ColumnSelectorPlus<GroupByColumnSelectorStrategy>[] selectorPlus = DimensionHandlerUtils
.createColumnSelectorPluses(
STRATEGY_FACTORY,
query.getDimensions(),
columnSelectorFactory
);
GroupByColumnSelectorPlus[] dims = new GroupByColumnSelectorPlus[selectorPlus.length];
int curPos = 0;
for (int i = 0; i < dims.length; i++) {
dims[i] = new GroupByColumnSelectorPlus(
selectorPlus[i],
curPos,
query.getResultRowDimensionStart() + i
);
curPos += dims[i].getColumnSelectorStrategy().getGroupingKeySize();
}

final int cardinalityForArrayAggregation = GroupingEngine.getCardinalityForArrayAggregation(
querySpecificConfig,
query,
storageAdapter,
processingBuffer
);

if (cardinalityForArrayAggregation >= 0) {
return new ArrayAggregateIterator(
query,
querySpecificConfig,
processingConfig,
cursor,
processingBuffer,
fudgeTimestamp,
dims,
hasNoImplicitUnnestDimensions(columnSelectorFactory, query.getDimensions()),
cardinalityForArrayAggregation
);
} else {
return new HashAggregateIterator(
query,
querySpecificConfig,
processingConfig,
cursor,
processingBuffer,
fudgeTimestamp,
dims,
hasNoImplicitUnnestDimensions(columnSelectorFactory, query.getDimensions())
);
}
}
cursor -> extracted(
query, storageAdapter, processingBuffer, fudgeTimestamp, querySpecificConfig, processingConfig, cursor
)
);
}

@Override
public void cleanup(GroupByEngineIterator<?> iterFromMake)
{
iterFromMake.close();
}
}
private static BaseSequence<ResultRow, GroupByEngineIterator<?>> extracted(final GroupByQuery query,
final StorageAdapter storageAdapter, final ByteBuffer processingBuffer, final DateTime fudgeTimestamp,
final GroupByQueryConfig querySpecificConfig, final DruidProcessingConfig processingConfig, Cursor cursor)
{
return new BaseSequence<>(
new IteratorMakerImplementation(
querySpecificConfig, query, cursor, storageAdapter, processingBuffer, fudgeTimestamp, processingConfig
)
);
}
Expand Down Expand Up @@ -239,6 +189,91 @@ private static boolean hasNoImplicitUnnestDimensions(
});
}

private static final class IteratorMakerImplementation
implements BaseSequence.IteratorMaker<ResultRow, GroupByEngineIterator<?>>
{
private final GroupByQueryConfig querySpecificConfig;
private final GroupByQuery query;
private final Cursor cursor;
private final StorageAdapter storageAdapter;
private final ByteBuffer processingBuffer;
private final DateTime fudgeTimestamp;
private final DruidProcessingConfig processingConfig;

private IteratorMakerImplementation(GroupByQueryConfig querySpecificConfig, GroupByQuery query, Cursor cursor,
StorageAdapter storageAdapter, ByteBuffer processingBuffer, DateTime fudgeTimestamp,
DruidProcessingConfig processingConfig)
{
this.querySpecificConfig = querySpecificConfig;
this.query = query;
this.cursor = cursor;
this.storageAdapter = storageAdapter;
this.processingBuffer = processingBuffer;
this.fudgeTimestamp = fudgeTimestamp;
this.processingConfig = processingConfig;
}

@Override
public GroupByEngineIterator<?> make()
{
final ColumnSelectorFactory columnSelectorFactory = cursor.getColumnSelectorFactory();
final ColumnSelectorPlus<GroupByColumnSelectorStrategy>[] selectorPlus = DimensionHandlerUtils
.createColumnSelectorPluses(
STRATEGY_FACTORY,
query.getDimensions(),
columnSelectorFactory
);
GroupByColumnSelectorPlus[] dims = new GroupByColumnSelectorPlus[selectorPlus.length];
int curPos = 0;
for (int i = 0; i < dims.length; i++) {
dims[i] = new GroupByColumnSelectorPlus(
selectorPlus[i],
curPos,
query.getResultRowDimensionStart() + i
);
curPos += dims[i].getColumnSelectorStrategy().getGroupingKeySize();
}

final int cardinalityForArrayAggregation = GroupingEngine.getCardinalityForArrayAggregation(
querySpecificConfig,
query,
storageAdapter,
processingBuffer
);

if (cardinalityForArrayAggregation >= 0) {
return new ArrayAggregateIterator(
query,
querySpecificConfig,
processingConfig,
cursor,
processingBuffer,
fudgeTimestamp,
dims,
hasNoImplicitUnnestDimensions(columnSelectorFactory, query.getDimensions()),
cardinalityForArrayAggregation
);
} else {
return new HashAggregateIterator(
query,
querySpecificConfig,
processingConfig,
cursor,
processingBuffer,
fudgeTimestamp,
dims,
hasNoImplicitUnnestDimensions(columnSelectorFactory, query.getDimensions())
);
}
}

@Override
public void cleanup(GroupByEngineIterator<?> iterFromMake)
{
iterFromMake.close();
}
}

private static class GroupByStrategyFactory implements ColumnSelectorStrategyFactory<GroupByColumnSelectorStrategy>
{
@Override
Expand Down

0 comments on commit fd09d9f

Please sign in to comment.