### Question:
FilterAndProjectOperator implements WorkProcessorOperator { public static OperatorFactory createOperatorFactory( int operatorId, PlanNodeId planNodeId, Supplier<PageProcessor> processor, List<Type> types, DataSize minOutputPageSize, int minOutputPageRowCount) { return createAdapterOperatorFactory(new Factory( operatorId, planNodeId, processor, types, minOutputPageSize, minOutputPageRowCount)); } private  FilterAndProjectOperator(
            Session session,
            MemoryTrackingContext memoryTrackingContext,
            DriverYieldSignal yieldSignal,
            WorkProcessor<Page> sourcePages,
            PageProcessor pageProcessor,
            List<Type> types,
            DataSize minOutputPageSize,
            int minOutputPageRowCount,
            boolean avoidPageMaterialization); @Override WorkProcessor<Page> getOutputPages(); static OperatorFactory createOperatorFactory(
            int operatorId,
            PlanNodeId planNodeId,
            Supplier<PageProcessor> processor,
            List<Type> types,
            DataSize minOutputPageSize,
            int minOutputPageRowCount);  }### Answer:
@Test public void test() { List<Page> input = rowPagesBuilder(VARCHAR, BIGINT) .addSequencePage(100, 0, 0) .build(); Metadata metadata = createTestMetadataManager(); RowExpression filter = call( metadata.resolveOperator(LESS_THAN_OR_EQUAL, ImmutableList.of(BIGINT, BIGINT)), field(1, BIGINT), constant(9L, BIGINT)); RowExpression field0 = field(0, VARCHAR); RowExpression add5 = call( metadata.resolveOperator(ADD, ImmutableList.of(BIGINT, BIGINT)), field(1, BIGINT), constant(5L, BIGINT)); ExpressionCompiler compiler = new ExpressionCompiler(metadata, new PageFunctionCompiler(metadata, 0)); Supplier<PageProcessor> processor = compiler.compilePageProcessor(Optional.of(filter), ImmutableList.of(field0, add5)); OperatorFactory operatorFactory = FilterAndProjectOperator.createOperatorFactory( 0, new PlanNodeId("test"), processor, ImmutableList.of(VARCHAR, BIGINT), DataSize.ofBytes(0), 0); MaterializedResult expected = MaterializedResult.resultBuilder(driverContext.getSession(), VARCHAR, BIGINT) .row("0", 5L) .row("1", 6L) .row("2", 7L) .row("3", 8L) .row("4", 9L) .row("5", 10L) .row("6", 11L) .row("7", 12L) .row("8", 13L) .row("9", 14L) .build(); assertOperatorEquals(operatorFactory, driverContext, input, expected); }
@Test public void testMergeOutput() { List<Page> input = rowPagesBuilder(VARCHAR, BIGINT) .addSequencePage(100, 0, 0) .addSequencePage(100, 0, 0) .addSequencePage(100, 0, 0) .addSequencePage(100, 0, 0) .build(); Metadata metadata = createTestMetadataManager(); RowExpression filter = call( metadata.resolveOperator(EQUAL, ImmutableList.of(BIGINT, BIGINT)), field(1, BIGINT), constant(10L, BIGINT)); ExpressionCompiler compiler = new ExpressionCompiler(metadata, new PageFunctionCompiler(metadata, 0)); Supplier<PageProcessor> processor = compiler.compilePageProcessor(Optional.of(filter), ImmutableList.of(field(1, BIGINT))); OperatorFactory operatorFactory = FilterAndProjectOperator.createOperatorFactory( 0, new PlanNodeId("test"), processor, ImmutableList.of(BIGINT), DataSize.of(64, KILOBYTE), 2); List<Page> expected = rowPagesBuilder(BIGINT) .row(10L) .row(10L) .row(10L) .row(10L) .build(); assertOperatorEquals(operatorFactory, ImmutableList.of(BIGINT), driverContext, input, expected); }