diff --git a/src/main/java/teetime/framework/CompositeStage.java b/src/main/java/teetime/framework/CompositeStage.java index 556f6fd77438c2010f8aa6624f01fce89cf0b654..672ab25c7cf5242a239379456f33c423bbefb633 100644 --- a/src/main/java/teetime/framework/CompositeStage.java +++ b/src/main/java/teetime/framework/CompositeStage.java @@ -18,6 +18,7 @@ package teetime.framework; import java.util.Collection; import java.util.List; +import teetime.framework.pipe.PipeFactoryRegistry; import teetime.framework.signal.ISignal; import teetime.framework.validation.InvalidPortConnection; @@ -31,6 +32,8 @@ import teetime.framework.validation.InvalidPortConnection; @SuppressWarnings("PMD.AbstractNaming") public abstract class CompositeStage extends Stage { + private static PipeFactoryRegistry PIPEFACTORY_REGISTRY = PipeFactoryRegistry.INSTANCE; + protected abstract Stage getFirstStage(); protected abstract Collection<? extends Stage> getLastStages(); diff --git a/src/main/java/teetime/stage/CountingmapMerger.java b/src/main/java/teetime/stage/CountingMapMerger.java similarity index 52% rename from src/main/java/teetime/stage/CountingmapMerger.java rename to src/main/java/teetime/stage/CountingMapMerger.java index 1a4d2fc51af49130cc27cf54b2c4b9390e1ebe5a..99225cfb92bb9e0e21135371b053575af7411a1e 100644 --- a/src/main/java/teetime/stage/CountingmapMerger.java +++ b/src/main/java/teetime/stage/CountingMapMerger.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2015 TeeTime (http://teetime.sourceforge.net) + * + * Licensed 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 teetime.stage; import java.util.Map; @@ -17,14 +32,16 @@ import teetime.stage.util.CountingMap; * @param <T> * Key type of the map to be sent */ -public class CountingmapMerger<T> extends AbstractConsumerStage<CountingMap<T>> { +public class CountingMapMerger<T> extends AbstractConsumerStage<CountingMap<T>> { private final CountingMap<T> result = new CountingMap<T>(); private final OutputPort<Map<T, Integer>> port = createOutputPort(); + @SuppressWarnings("unused") + // May be needed to identify, if all stages before this one terminated private final int numberOfInputPorts; - public CountingmapMerger(final int numberOfInputPorts) { + public CountingMapMerger(final int numberOfInputPorts) { for (int i = 1; i < numberOfInputPorts; i++) { createInputPort(); } @@ -35,15 +52,7 @@ public class CountingmapMerger<T> extends AbstractConsumerStage<CountingMap<T>> protected void execute(final CountingMap<T> element) { Set<Map.Entry<T, Integer>> entries = element.entrySet(); for (Entry<T, Integer> entry : entries) { - Integer resultValue = result.get(entry.getKey()); - if (resultValue == null) { - result.put(entry.getKey(), entry.getValue()); - } - else { - Integer temp = result.get(entry.getKey()); - temp += entry.getValue(); - result.put(entry.getKey(), temp); - } + result.add(entry.getKey(), entry.getValue()); } } @@ -53,4 +62,8 @@ public class CountingmapMerger<T> extends AbstractConsumerStage<CountingMap<T>> super.onTerminating(); } + public CountingMap<T> getResult() { + return result; + } + } diff --git a/src/main/java/teetime/stage/DistributedMapCounter.java b/src/main/java/teetime/stage/DistributedMapCounter.java index de7b7b7f19cba41889d33ebec41a1e90bff52155..ebb3c0c3a0186512f01fe7f686da4821fed9bd64 100644 --- a/src/main/java/teetime/stage/DistributedMapCounter.java +++ b/src/main/java/teetime/stage/DistributedMapCounter.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2015 TeeTime (http://teetime.sourceforge.net) + * + * Licensed 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 teetime.stage; import teetime.framework.AbstractConsumerStage; @@ -6,11 +21,12 @@ import teetime.stage.util.CountingMap; /** * This counts how many of different elements are sent to this stage. Nothing is forwarded. - * On termination a Map of T's and counter value is sent to its outputport. + * On termination a CountingMap is sent to its outputport. * * @author Nelson Tavares de Sousa * * @param <T> + * Type to be count */ public class DistributedMapCounter<T> extends AbstractConsumerStage<T> { diff --git a/src/main/java/teetime/stage/string/ToLowerCase.java b/src/main/java/teetime/stage/string/ToLowerCase.java index fb0edfe5020f9de9c5d8356f9ae1f5d38e9a3971..5f5bc840fe6f9a5692c401c376c23d4cf212bbb1 100644 --- a/src/main/java/teetime/stage/string/ToLowerCase.java +++ b/src/main/java/teetime/stage/string/ToLowerCase.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2015 TeeTime (http://teetime.sourceforge.net) + * + * Licensed 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 teetime.stage.string; import teetime.framework.AbstractConsumerStage; diff --git a/src/main/java/teetime/stage/util/CountingMap.java b/src/main/java/teetime/stage/util/CountingMap.java index 0e6ae4effac893221c1dc17eb1c3729106cd1fdc..fcd0ed661ff1a519dc628da9b22d5dc892f3df53 100644 --- a/src/main/java/teetime/stage/util/CountingMap.java +++ b/src/main/java/teetime/stage/util/CountingMap.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2015 TeeTime (http://teetime.sourceforge.net) + * + * Licensed 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 teetime.stage.util; import java.util.HashMap;