.getVariable(cursorVariable)
.invokeInterface(BlockCursor.class, "advanceNextPosition", boolean.class)
.invokeStatic(Preconditions.class, "checkState", void.class, boolean.class);
}
IfStatementBuilder ifStatement = new IfStatementBuilder(compilerContext)
.comment("if (filter(cursors...)");
Block condition = new Block(compilerContext);
condition.pushThis();
for (int channel : inputChannels) {
condition.getVariable("cursor_" + channel);
}
condition.invokeVirtual(classDefinition.getType(), "filter", type(boolean.class), nCopies(inputChannels.size(), type(BlockCursor.class)));
ifStatement.condition(condition);
Block trueBlock = new Block(compilerContext);
if (projections.isEmpty()) {
trueBlock
.comment("pageBuilder.declarePosition()")
.getVariable("pageBuilder")
.invokeVirtual(PageBuilder.class, "declarePosition", void.class);
}
else {
// pageBuilder.getBlockBuilder(0).append(cursor.getDouble(0);
for (int projectionIndex = 0; projectionIndex < projections.size(); projectionIndex++) {
trueBlock.comment("project_%s(cursors..., pageBuilder.getBlockBuilder(%s))", projectionIndex, projectionIndex);
trueBlock.pushThis();
for (int channel : inputChannels) {
trueBlock.getVariable("cursor_" + channel);
}
// pageBuilder.getBlockBuilder(0)
trueBlock.getVariable("pageBuilder")
.push(projectionIndex)
.invokeVirtual(PageBuilder.class, "getBlockBuilder", BlockBuilder.class, int.class);
// project(cursor_0, cursor_1, blockBuilder)
trueBlock.invokeVirtual(classDefinition.getType(),
"project_" + projectionIndex,
type(void.class),
ImmutableList.<ParameterizedType>builder().addAll(nCopies(inputChannels.size(), type(BlockCursor.class))).add(type(BlockBuilder.class)).build());
}
}
ifStatement.ifTrue(trueBlock);
forLoopBody.append(ifStatement.build());
filterAndProjectMethod.getBody().append(forLoop.body(forLoopBody).build());
//
// Verify all cursors ended together
//