Hussain Towaileb has submitted this change and it was merged. ( https://asterix-gerrit.ics.uci.edu/3403 )
Change subject: [NO ISSUE][FUN] Remove unnecessary inner classes ...................................................................... [NO ISSUE][FUN] Remove unnecessary inner classes - user model changes: no - storage format changes: no - interface changes: no Details: - Remove unnecessary inner classes. Use the evaluator factories length to check if the end position argument is passed. Change-Id: I5cc8c57888e62b26684082dd07a4314b45f9fa7f Reviewed-on: https://asterix-gerrit.ics.uci.edu/3403 Contrib: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Sonar-Qube: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Tested-by: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Reviewed-by: Dmitry Lychagin <dmitry.lycha...@couchbase.com> --- R asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySliceEvaluator.java M asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySliceWithEndPositionDescriptor.java M asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySliceWithoutEndPositionDescriptor.java 3 files changed, 23 insertions(+), 59 deletions(-) Approvals: Jenkins: Verified; No violations found; ; Verified Dmitry Lychagin: Looks good to me, approved Objections: Anon. E. Moose (1000171): Violations found diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractArraySliceEval.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySliceEvaluator.java similarity index 90% rename from asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractArraySliceEval.java rename to asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySliceEvaluator.java index 036447a..c907720 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractArraySliceEval.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySliceEvaluator.java @@ -75,32 +75,31 @@ * </pre> */ -public abstract class AbstractArraySliceEval extends AbstractScalarEval { +class ArraySliceEvaluator extends AbstractScalarEval { + // List type private final IAType inputListType; // Storage - private final ArrayBackedValueStorage storage = new ArrayBackedValueStorage(); + private final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage(); - // Evaluators + // Evaluators and pointables private final IScalarEvaluator listEval; private final IScalarEvaluator startPositionEval; - private final IScalarEvaluator endPositionEval; - - // Pointables + private IScalarEvaluator endPositionEval; private final IPointable listPointable = new VoidPointable(); private final IPointable startPositionPointable = new VoidPointable(); - private final IPointable endPositionPointable = new VoidPointable(); + private IPointable endPositionPointable; // Accessors private final ListAccessor listAccessor = new ListAccessor(); // List Builders - private IAsterixListBuilder orderedListBuilder = new OrderedListBuilder(); - private IAsterixListBuilder unorderedListBuilder = new UnorderedListBuilder(); + private final IAsterixListBuilder orderedListBuilder = new OrderedListBuilder(); + private final IAsterixListBuilder unorderedListBuilder = new UnorderedListBuilder(); // Constructor - public AbstractArraySliceEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx, SourceLocation sourceLoc, + ArraySliceEvaluator(IScalarEvaluatorFactory[] argEvalFactories, IHyracksTaskContext ctx, SourceLocation sourceLoc, FunctionIdentifier functionIdentifier, IAType inputListType) throws HyracksDataException { // Source location super(sourceLoc, functionIdentifier); @@ -109,20 +108,18 @@ this.inputListType = inputListType; // Evaluators - listEval = args[0].createScalarEvaluator(ctx); - startPositionEval = args[1].createScalarEvaluator(ctx); + listEval = argEvalFactories[0].createScalarEvaluator(ctx); + startPositionEval = argEvalFactories[1].createScalarEvaluator(ctx); // Check for optional parameter - endPositionEval = getEndPositionEval(args, ctx); + if (argEvalFactories.length > 2) { + endPositionEval = argEvalFactories[2].createScalarEvaluator(ctx); + endPositionPointable = new VoidPointable(); + } } - - protected abstract IScalarEvaluator getEndPositionEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) - throws HyracksDataException; @Override public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException { - // Reset storage - storage.reset(); // Evaluate listEval.evaluate(tuple, listPointable); @@ -231,18 +228,18 @@ try { // Create the subset list based on the positions for (int i = startPositionValue; i < endPositionValue; i++) { - storage.reset(); - listAccessor.writeItem(i, storage.getDataOutput()); - listBuilder.addItem(storage); + resultStorage.reset(); + listAccessor.writeItem(i, resultStorage.getDataOutput()); + listBuilder.addItem(resultStorage); } } catch (IOException ex) { throw HyracksDataException.create(ex); } // Final result - storage.reset(); - listBuilder.write(storage.getDataOutput(), true); - result.set(storage); + resultStorage.reset(); + listBuilder.write(resultStorage.getDataOutput(), true); + result.set(resultStorage); } // Get the value diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySliceWithEndPositionDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySliceWithEndPositionDescriptor.java index 81833b6..04e93dd 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySliceWithEndPositionDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySliceWithEndPositionDescriptor.java @@ -32,7 +32,6 @@ import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory; import org.apache.hyracks.api.context.IHyracksTaskContext; import org.apache.hyracks.api.exceptions.HyracksDataException; -import org.apache.hyracks.api.exceptions.SourceLocation; /** * array_slice(array, start, end) This function takes 3 arguments, {@code array}, {@code start} and {@code end} and @@ -75,24 +74,8 @@ @Override public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException { - return new ArraySliceEval(args, ctx, sourceLoc); + return new ArraySliceEvaluator(args, ctx, sourceLoc, getIdentifier(), inputListType); } }; - } - - public class ArraySliceEval extends AbstractArraySliceEval { - - // Constructor - public ArraySliceEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx, SourceLocation sourceLoc) - throws HyracksDataException { - super(args, ctx, sourceLoc, ArraySliceWithEndPositionDescriptor.this.getIdentifier(), inputListType); - } - - // Return end position evaluator - @Override - protected IScalarEvaluator getEndPositionEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) - throws HyracksDataException { - return args[2].createScalarEvaluator(ctx); - } } } diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySliceWithoutEndPositionDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySliceWithoutEndPositionDescriptor.java index 3fab75b..7a3889f 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySliceWithoutEndPositionDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySliceWithoutEndPositionDescriptor.java @@ -32,7 +32,6 @@ import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory; import org.apache.hyracks.api.context.IHyracksTaskContext; import org.apache.hyracks.api.exceptions.HyracksDataException; -import org.apache.hyracks.api.exceptions.SourceLocation; /** * array_slice(array, start) This function takes 2 arguments, {@code array} and {@code start} and returns @@ -75,23 +74,8 @@ @Override public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException { - return new ArraySliceEval(args, ctx, sourceLoc); + return new ArraySliceEvaluator(args, ctx, sourceLoc, getIdentifier(), inputListType); } }; - } - - public class ArraySliceEval extends AbstractArraySliceEval { - - // Constructor - public ArraySliceEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx, SourceLocation sourceLoc) - throws HyracksDataException { - super(args, ctx, sourceLoc, ArraySliceWithoutEndPositionDescriptor.this.getIdentifier(), inputListType); - } - - // Return null, no end position - @Override - protected IScalarEvaluator getEndPositionEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) { - return null; - } } } -- To view, visit https://asterix-gerrit.ics.uci.edu/3403 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-MessageType: merged Gerrit-Change-Id: I5cc8c57888e62b26684082dd07a4314b45f9fa7f Gerrit-Change-Number: 3403 Gerrit-PatchSet: 2 Gerrit-Owner: Hussain Towaileb <hussai...@gmail.com> Gerrit-Reviewer: Ali Alsuliman <ali.al.solai...@gmail.com> Gerrit-Reviewer: Anon. E. Moose (1000171) Gerrit-Reviewer: Dmitry Lychagin <dmitry.lycha...@couchbase.com> Gerrit-Reviewer: Hussain Towaileb <hussai...@gmail.com> Gerrit-Reviewer: Jenkins <jenk...@fulliautomatix.ics.uci.edu>