Search in sources :

Example 1 with StringTrimmer

use of org.apache.asterix.runtime.evaluators.functions.utils.StringTrimmer in project asterixdb by apache.

the class StringTrim2Descriptor method createEvaluatorFactory.

@Override
public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
    return new IScalarEvaluatorFactory() {

        private static final long serialVersionUID = 1L;

        @Override
        public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws HyracksDataException {
            return new AbstractBinaryStringStringEval(ctx, args[0], args[1], StringTrim2Descriptor.this.getIdentifier()) {

                private StringTrimmer stringTrimmer = new StringTrimmer(resultBuilder, resultArray);

                @Override
                protected void compute(UTF8StringPointable srcPtr, UTF8StringPointable patternPtr, UTF8StringPointable resultStrPtr) throws IOException {
                    stringTrimmer.build(patternPtr);
                    stringTrimmer.trim(srcPtr, resultStrPtr, true, true);
                }
            };
        }
    };
}
Also used : UTF8StringPointable(org.apache.hyracks.data.std.primitive.UTF8StringPointable) IHyracksTaskContext(org.apache.hyracks.api.context.IHyracksTaskContext) StringTrimmer(org.apache.asterix.runtime.evaluators.functions.utils.StringTrimmer) IScalarEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory)

Example 2 with StringTrimmer

use of org.apache.asterix.runtime.evaluators.functions.utils.StringTrimmer in project asterixdb by apache.

the class StringRTrim2Descriptor method createEvaluatorFactory.

@Override
public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
    return new IScalarEvaluatorFactory() {

        private static final long serialVersionUID = 1L;

        @Override
        public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws HyracksDataException {
            return new AbstractBinaryStringStringEval(ctx, args[0], args[1], StringRTrim2Descriptor.this.getIdentifier()) {

                private StringTrimmer stringTrimmer = new StringTrimmer(resultBuilder, resultArray);

                @Override
                protected void compute(UTF8StringPointable srcPtr, UTF8StringPointable patternPtr, UTF8StringPointable resultStrPtr) throws IOException {
                    stringTrimmer.build(patternPtr);
                    stringTrimmer.trim(srcPtr, resultStrPtr, false, true);
                }
            };
        }
    };
}
Also used : UTF8StringPointable(org.apache.hyracks.data.std.primitive.UTF8StringPointable) IHyracksTaskContext(org.apache.hyracks.api.context.IHyracksTaskContext) StringTrimmer(org.apache.asterix.runtime.evaluators.functions.utils.StringTrimmer) IScalarEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory)

Example 3 with StringTrimmer

use of org.apache.asterix.runtime.evaluators.functions.utils.StringTrimmer in project asterixdb by apache.

the class StringLTrim2Descriptor method createEvaluatorFactory.

@Override
public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
    return new IScalarEvaluatorFactory() {

        private static final long serialVersionUID = 1L;

        @Override
        public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws HyracksDataException {
            return new AbstractBinaryStringStringEval(ctx, args[0], args[1], StringLTrim2Descriptor.this.getIdentifier()) {

                private StringTrimmer stringTrimmer = new StringTrimmer(resultBuilder, resultArray);

                @Override
                protected void compute(UTF8StringPointable srcPtr, UTF8StringPointable patternPtr, UTF8StringPointable resultStrPtr) throws IOException {
                    stringTrimmer.build(patternPtr);
                    stringTrimmer.trim(srcPtr, resultStrPtr, true, false);
                }
            };
        }
    };
}
Also used : UTF8StringPointable(org.apache.hyracks.data.std.primitive.UTF8StringPointable) IHyracksTaskContext(org.apache.hyracks.api.context.IHyracksTaskContext) StringTrimmer(org.apache.asterix.runtime.evaluators.functions.utils.StringTrimmer) IScalarEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory)

Aggregations

StringTrimmer (org.apache.asterix.runtime.evaluators.functions.utils.StringTrimmer)3 IScalarEvaluatorFactory (org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory)3 IHyracksTaskContext (org.apache.hyracks.api.context.IHyracksTaskContext)3 UTF8StringPointable (org.apache.hyracks.data.std.primitive.UTF8StringPointable)3