Repository: incubator-apex-core Updated Branches: refs/heads/master 99466a3ad -> c2eb06c68
APEXCORE-254 rename DefaultReservoir.java to AbstractReservoir.java Project: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/commit/2d175ff0 Tree: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/tree/2d175ff0 Diff: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/diff/2d175ff0 Branch: refs/heads/master Commit: 2d175ff0f79302ebba3fab0d16fd55d787dfc3ba Parents: 9ffbc73 Author: Vlad Rozov <[email protected]> Authored: Tue Nov 10 17:42:11 2015 -0800 Committer: Vlad Rozov <[email protected]> Committed: Tue Feb 2 12:42:49 2016 -0800 ---------------------------------------------------------------------- .../stram/engine/AbstractReservoir.java | 106 +++++++++++++++++++ .../stram/engine/DefaultReservoir.java | 106 ------------------- 2 files changed, 106 insertions(+), 106 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/2d175ff0/engine/src/main/java/com/datatorrent/stram/engine/AbstractReservoir.java ---------------------------------------------------------------------- diff --git a/engine/src/main/java/com/datatorrent/stram/engine/AbstractReservoir.java b/engine/src/main/java/com/datatorrent/stram/engine/AbstractReservoir.java new file mode 100644 index 0000000..2dd0dad --- /dev/null +++ b/engine/src/main/java/com/datatorrent/stram/engine/AbstractReservoir.java @@ -0,0 +1,106 @@ +/** + * 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 com.datatorrent.stram.engine; + + +import com.datatorrent.api.Sink; + +import com.datatorrent.netlet.util.CircularBuffer; +import com.datatorrent.stram.tuple.Tuple; + +/** + * <p>DefaultReservoir class.</p> + * + * @since 0.3.2 + */ +public class DefaultReservoir extends CircularBuffer<Object> implements SweepableReservoir +{ + private Sink<Object> sink; + private String id; + private int count; + + public DefaultReservoir(String id, int capacity) + { + super(capacity); + this.id = id; + } + + @Override + public Sink<Object> setSink(Sink<Object> sink) + { + try { + return this.sink; + } + finally { + this.sink = sink; + } + } + + @Override + public Tuple sweep() + { + final int size = size(); + for (int i = 0; i < size; i++) { + if (peekUnsafe() instanceof Tuple) { + count += i; + return (Tuple)peekUnsafe(); + } + sink.put(pollUnsafe()); + } + + count += size; + return null; + } + + @Override + public String toString() + { + return "DefaultReservoir{" + "sink=" + sink + ", id=" + id + ", count=" + count + '}'; + } + + /** + * @return the id + */ + public String getId() + { + return id; + } + + /** + * @param id the id to set + */ + public void setId(String id) + { + this.id = id; + } + + @Override + public int getCount(boolean reset) + { + try { + return count; + } + finally { + if (reset) { + count = 0; + } + } + } + +} http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/2d175ff0/engine/src/main/java/com/datatorrent/stram/engine/DefaultReservoir.java ---------------------------------------------------------------------- diff --git a/engine/src/main/java/com/datatorrent/stram/engine/DefaultReservoir.java b/engine/src/main/java/com/datatorrent/stram/engine/DefaultReservoir.java deleted file mode 100644 index 2dd0dad..0000000 --- a/engine/src/main/java/com/datatorrent/stram/engine/DefaultReservoir.java +++ /dev/null @@ -1,106 +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 com.datatorrent.stram.engine; - - -import com.datatorrent.api.Sink; - -import com.datatorrent.netlet.util.CircularBuffer; -import com.datatorrent.stram.tuple.Tuple; - -/** - * <p>DefaultReservoir class.</p> - * - * @since 0.3.2 - */ -public class DefaultReservoir extends CircularBuffer<Object> implements SweepableReservoir -{ - private Sink<Object> sink; - private String id; - private int count; - - public DefaultReservoir(String id, int capacity) - { - super(capacity); - this.id = id; - } - - @Override - public Sink<Object> setSink(Sink<Object> sink) - { - try { - return this.sink; - } - finally { - this.sink = sink; - } - } - - @Override - public Tuple sweep() - { - final int size = size(); - for (int i = 0; i < size; i++) { - if (peekUnsafe() instanceof Tuple) { - count += i; - return (Tuple)peekUnsafe(); - } - sink.put(pollUnsafe()); - } - - count += size; - return null; - } - - @Override - public String toString() - { - return "DefaultReservoir{" + "sink=" + sink + ", id=" + id + ", count=" + count + '}'; - } - - /** - * @return the id - */ - public String getId() - { - return id; - } - - /** - * @param id the id to set - */ - public void setId(String id) - { - this.id = id; - } - - @Override - public int getCount(boolean reset) - { - try { - return count; - } - finally { - if (reset) { - count = 0; - } - } - } - -}
