This is an automated email from the ASF dual-hosted git repository. bertty pushed a commit to branch WAYANG-28 in repository https://gitbox.apache.org/repos/asf/incubator-wayang.git
commit 5e26844dc14959ffe9c57bc5d8955ab8d82475fc Author: Bertty Contreras-Rojas <[email protected]> AuthorDate: Mon May 17 12:48:34 2021 -0400 [WAYANG-28] use base java function on the tagger template --- .../core/tagger/wrapper/FlatmapWrapperHackit.java | 19 +++++----- .../core/tagger/wrapper/FunctionWrapperHackit.java | 19 +++++----- .../tagger/wrapper/PredicateWrapperHackit.java | 23 ++++++------ .../template/TaggerWrapperFlatMapTemplate.java | 41 ---------------------- .../template/TaggerWrapperFunctionTemplate.java | 36 ------------------- 5 files changed, 31 insertions(+), 107 deletions(-) diff --git a/wayang-plugins/wayang-hackit/wayang-hackit-core/src/main/java/org/apache/wayang/plugin/hackit/core/tagger/wrapper/FlatmapWrapperHackit.java b/wayang-plugins/wayang-hackit/wayang-hackit-core/src/main/java/org/apache/wayang/plugin/hackit/core/tagger/wrapper/FlatmapWrapperHackit.java index 5190f26..5d020a2 100644 --- a/wayang-plugins/wayang-hackit/wayang-hackit-core/src/main/java/org/apache/wayang/plugin/hackit/core/tagger/wrapper/FlatmapWrapperHackit.java +++ b/wayang-plugins/wayang-hackit/wayang-hackit-core/src/main/java/org/apache/wayang/plugin/hackit/core/tagger/wrapper/FlatmapWrapperHackit.java @@ -18,13 +18,13 @@ package org.apache.wayang.plugin.hackit.core.tagger.wrapper; import org.apache.wayang.plugin.hackit.core.tagger.HackitTagger; -import org.apache.wayang.plugin.hackit.core.tagger.wrapper.template.TaggerWrapperFlatMapTemplate; import org.apache.wayang.plugin.hackit.core.tuple.HackitTuple; import java.util.Iterator; +import java.util.function.Function; /** - * FlatmapWrapperHackit is an implementation of {@link TaggerWrapperFlatMapTemplate} where Hackit manage the logic + * FlatmapWrapperHackit is an implementation of {@link HackitTagger} where Hackit manage the logic * before and after of tagging process, also it perform the unwrap of the tuple to be handle by the * original function * @@ -34,27 +34,26 @@ import java.util.Iterator; */ public class FlatmapWrapperHackit<IDType, I, O> extends HackitTagger - implements TaggerWrapperFlatMapTemplate<HackitTuple<IDType, I>, HackitTuple<IDType, O>> { + implements Function<HackitTuple<IDType, I>, Iterator<HackitTuple<IDType, O>>> { /** * Original function that will transform the data */ - private TaggerWrapperFlatMapTemplate<I, O> function; + private Function<I, Iterator<O>> function; /** * Default Construct * * @param function is the function that will be Wrapped by the {@link FlatmapWrapperHackit} */ - public FlatmapWrapperHackit(TaggerWrapperFlatMapTemplate<I, O> function ) { + public FlatmapWrapperHackit(Function<I, Iterator<O>> function ) { this.function = function; } - @Override - public Iterator<HackitTuple<IDType, O>> execute(HackitTuple<IDType, I> kiHackItTuple) { - this.preTaggingTuple(kiHackItTuple); - Iterator<O> result = this.function.execute(kiHackItTuple.getValue()); - return this.postTaggingTuple(kiHackItTuple, result); + public Iterator<HackitTuple<IDType, O>> apply(HackitTuple<IDType, I> idTypeIHackitTuple) { + this.preTaggingTuple(idTypeIHackitTuple); + Iterator<O> result = this.function.apply(idTypeIHackitTuple.getValue()); + return this.postTaggingTuple(idTypeIHackitTuple, result); } } diff --git a/wayang-plugins/wayang-hackit/wayang-hackit-core/src/main/java/org/apache/wayang/plugin/hackit/core/tagger/wrapper/FunctionWrapperHackit.java b/wayang-plugins/wayang-hackit/wayang-hackit-core/src/main/java/org/apache/wayang/plugin/hackit/core/tagger/wrapper/FunctionWrapperHackit.java index 982b838..4c97b28 100644 --- a/wayang-plugins/wayang-hackit/wayang-hackit-core/src/main/java/org/apache/wayang/plugin/hackit/core/tagger/wrapper/FunctionWrapperHackit.java +++ b/wayang-plugins/wayang-hackit/wayang-hackit-core/src/main/java/org/apache/wayang/plugin/hackit/core/tagger/wrapper/FunctionWrapperHackit.java @@ -18,11 +18,12 @@ package org.apache.wayang.plugin.hackit.core.tagger.wrapper; import org.apache.wayang.plugin.hackit.core.tagger.HackitTagger; -import org.apache.wayang.plugin.hackit.core.tagger.wrapper.template.TaggerWrapperFunctionTemplate; import org.apache.wayang.plugin.hackit.core.tuple.HackitTuple; +import java.util.function.Function; + /** - * FunctionWrapperHackit is an implementation of {@link TaggerWrapperFunctionTemplate} where Hackit manage the logic + * FunctionWrapperHackit is an implementation of {@link HackitTagger} where Hackit manage the logic * before and after of tagging process, also it perform the unwrap of the tuple to be handle by the * original function * @@ -32,26 +33,26 @@ import org.apache.wayang.plugin.hackit.core.tuple.HackitTuple; */ public class FunctionWrapperHackit<IDType, I, O> extends HackitTagger - implements TaggerWrapperFunctionTemplate<HackitTuple<IDType, I>, HackitTuple<IDType, O>> { + implements Function<HackitTuple<IDType, I>, HackitTuple<IDType, O>> { /** * Original function that will transform the data */ - private TaggerWrapperFunctionTemplate<I, O> function; + private Function<I, O> function; /** * Default Construct * * @param function is the function that will be Wrapped by the {@link FunctionWrapperHackit} */ - public FunctionWrapperHackit(TaggerWrapperFunctionTemplate<I, O> function) { + public FunctionWrapperHackit(Function<I, O> function) { this.function = function; } @Override - public HackitTuple<IDType, O> execute(HackitTuple<IDType, I> v1) { - this.preTaggingTuple(v1); - O result = this.function.execute(v1.getValue()); - return this.postTaggingTuple(v1, result); + public HackitTuple<IDType, O> apply(HackitTuple<IDType, I> idTypeIHackitTuple) { + this.preTaggingTuple(idTypeIHackitTuple); + O result = this.function.apply(idTypeIHackitTuple.getValue()); + return this.postTaggingTuple(idTypeIHackitTuple, result); } } diff --git a/wayang-plugins/wayang-hackit/wayang-hackit-core/src/main/java/org/apache/wayang/plugin/hackit/core/tagger/wrapper/PredicateWrapperHackit.java b/wayang-plugins/wayang-hackit/wayang-hackit-core/src/main/java/org/apache/wayang/plugin/hackit/core/tagger/wrapper/PredicateWrapperHackit.java index f9d47cd..945cbfb 100644 --- a/wayang-plugins/wayang-hackit/wayang-hackit-core/src/main/java/org/apache/wayang/plugin/hackit/core/tagger/wrapper/PredicateWrapperHackit.java +++ b/wayang-plugins/wayang-hackit/wayang-hackit-core/src/main/java/org/apache/wayang/plugin/hackit/core/tagger/wrapper/PredicateWrapperHackit.java @@ -18,41 +18,42 @@ package org.apache.wayang.plugin.hackit.core.tagger.wrapper; import org.apache.wayang.plugin.hackit.core.tagger.HackitTagger; -import org.apache.wayang.plugin.hackit.core.tagger.wrapper.template.TaggerWrapperFunctionTemplate; import org.apache.wayang.plugin.hackit.core.tuple.HackitTuple; +import java.util.function.Predicate; + /** - * PredicateWrapperHackit is an implementation of {@link TaggerWrapperFunctionTemplate} where Hackit manage the logic + * PredicateWrapperHackit is an implementation of {@link HackitTagger} where Hackit manage the logic * before and after of tagging process, also it perform the unwrap of the tuple to be handle by the - * original function. The original {@link TaggerWrapperFunctionTemplate} it an predicate function because return a - * {@link Boolean} + * original function. The original {@link Predicate} function because return a {@link Boolean} * * @param <IDType> Type of {@link org.apache.wayang.plugin.hackit.core.tuple.header.Header} key of the {@link HackitTuple} * @param <I> Input Type of the original Tuple to be evaluated */ public class PredicateWrapperHackit<IDType, I> extends HackitTagger - implements TaggerWrapperFunctionTemplate<HackitTuple<IDType, I>, Boolean> { + implements Predicate<HackitTuple<IDType, I>> { /** * Original predicate that will evaluate the data to give a True or False value */ - private TaggerWrapperFunctionTemplate<I, Boolean> function; + private Predicate<I> function; /** * Default Construct * * @param function is the predicate that will be Wrapped by the {@link PredicateWrapperHackit} */ - public PredicateWrapperHackit(TaggerWrapperFunctionTemplate<I, Boolean> function) { + public PredicateWrapperHackit(Predicate<I> function) { this.function = function; } + @Override - public Boolean execute(HackitTuple<IDType, I> v1) { - this.preTaggingTuple(v1); - Boolean result = this.function.execute(v1.getValue()); - this.postTaggingTuple(v1); + public boolean test(HackitTuple<IDType, I> idTypeIHackitTuple) { + this.preTaggingTuple(idTypeIHackitTuple); + Boolean result = this.function.test(idTypeIHackitTuple.getValue()); + this.postTaggingTuple(idTypeIHackitTuple); return result; } } diff --git a/wayang-plugins/wayang-hackit/wayang-hackit-core/src/main/java/org/apache/wayang/plugin/hackit/core/tagger/wrapper/template/TaggerWrapperFlatMapTemplate.java b/wayang-plugins/wayang-hackit/wayang-hackit-core/src/main/java/org/apache/wayang/plugin/hackit/core/tagger/wrapper/template/TaggerWrapperFlatMapTemplate.java deleted file mode 100644 index bb05c3a..0000000 --- a/wayang-plugins/wayang-hackit/wayang-hackit-core/src/main/java/org/apache/wayang/plugin/hackit/core/tagger/wrapper/template/TaggerWrapperFlatMapTemplate.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.wayang.plugin.hackit.core.tagger.wrapper.template; - -import java.util.Iterator; - -/** - * TaggerWrapperFlatMapTemplate is the template that provide the abstraction to work with Flatmap operations and also - * allows to wrap some function made by the user. - * - * TaggerWrapperFlatMapTemplate generate as output a {@link Iterator} this could be an extension of {@link org.apache.wayang.plugin.hackit.core.iterator.HackitIterator} - * - * @param <I> Input type of the original Function - * @param <O> Output type of the original function - */ -public interface TaggerWrapperFlatMapTemplate<I, O> extends TaggerWrapperFunctionTemplate<I, Iterator<O>> { - - /** - * Execute the logic over one element and generate as output a {@link Iterator} - * - * @param input element to transform - * @return {@link Iterator} that contains the output's - */ - Iterator<O> execute(I input); -} diff --git a/wayang-plugins/wayang-hackit/wayang-hackit-core/src/main/java/org/apache/wayang/plugin/hackit/core/tagger/wrapper/template/TaggerWrapperFunctionTemplate.java b/wayang-plugins/wayang-hackit/wayang-hackit-core/src/main/java/org/apache/wayang/plugin/hackit/core/tagger/wrapper/template/TaggerWrapperFunctionTemplate.java deleted file mode 100644 index 1033d4f..0000000 --- a/wayang-plugins/wayang-hackit/wayang-hackit-core/src/main/java/org/apache/wayang/plugin/hackit/core/tagger/wrapper/template/TaggerWrapperFunctionTemplate.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wayang.plugin.hackit.core.tagger.wrapper.template; - -/** - * TaggerWrapperFunctionTemplate is the template that provide the abstraction to work with Transformation operations and also - * allows to wrap some function made by the user. - * - * @param <I> Input type of the original Function - * @param <O> Output type of the original function - */ -public interface TaggerWrapperFunctionTemplate<I, O> { - - /** - * Execute the logic over one element and generate as output <code>T</code> - * - * @param input element to transform - * @return <code>O</code> that is the transformation of the <code>input</code> - */ - public O execute(I input); -}
