Github user paul-rogers commented on a diff in the pull request: https://github.com/apache/drill/pull/984#discussion_r144946834 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/TopN/TopNBatch.java --- @@ -335,20 +336,42 @@ private void purge() throws SchemaChangeException { logger.debug("Took {} us to purge", watch.elapsed(TimeUnit.MICROSECONDS)); } - public PriorityQueue createNewPriorityQueue(FragmentContext context, List<Ordering> orderings, - VectorAccessible batch, MappingSet mainMapping, MappingSet leftMapping, MappingSet rightMapping) - throws ClassTransformationException, IOException, SchemaChangeException{ - CodeGenerator<PriorityQueue> cg = CodeGenerator.get(PriorityQueue.TEMPLATE_DEFINITION, context.getFunctionRegistry(), context.getOptions()); + private PriorityQueue createNewPriorityQueue(VectorAccessible batch, int limit) + throws SchemaChangeException, ClassTransformationException, IOException { + return createNewPriorityQueue( + mainMapping, leftMapping, rightMapping, context.getOptionSet(), context.getFunctionRegistry(), context.getDrillbitContext().getCompiler(), + config.getOrderings(), batch, unionTypeEnabled, codegenDump, limit, oContext.getAllocator(), schema.getSelectionVectorMode()); + } + + public static MappingSet createMainMappingSet() { + return new MappingSet((String) null, null, ClassGenerator.DEFAULT_SCALAR_MAP, ClassGenerator.DEFAULT_SCALAR_MAP); + } + + public static MappingSet createLeftMappingSet() { + return new MappingSet("leftIndex", null, ClassGenerator.DEFAULT_SCALAR_MAP, ClassGenerator.DEFAULT_SCALAR_MAP); + } + + public static MappingSet createRightMappingSet() { + return new MappingSet("rightIndex", null, ClassGenerator.DEFAULT_SCALAR_MAP, ClassGenerator.DEFAULT_SCALAR_MAP); + } + + public static PriorityQueue createNewPriorityQueue( + MappingSet mainMapping, MappingSet leftMapping, MappingSet rightMapping, --- End diff -- Do we ever use more than one mapping set? If not, can we just refer to the constants inside this function? I see that a simpler form exists. Just curious why we also need the complex form. For better testing?
---