// Path: src/main/java/storm/benchmark/lib/spout/FileReadSpout.java
// public class FileReadSpout extends BaseRichSpout {
//   private static final Logger LOG = Logger.getLogger(FileReadSpout.class);
//   private static final long serialVersionUID = -2582705611472467172L;
// 
// 	public static final String DEFAULT_FILE = "/resources/A_Tale_of_Two_City.txt";
//   public static final boolean DEFAULT_ACK = false;
//   public static final String FIELDS = "sentence";
// 
//   public final boolean ackEnabled;
//   public final FileReader reader;
// 	private SpoutOutputCollector collector;
// 
//   private long count = 0;
// 
// 
//   public FileReadSpout() {
//     this(DEFAULT_ACK, DEFAULT_FILE);
//   }
// 
// 
//   public FileReadSpout(boolean ackEnabled) {
//     this(ackEnabled, DEFAULT_FILE);
//   }
// 
//   public FileReadSpout(boolean ackEnabled, String file) {
//     this(ackEnabled, new FileReader(file));
//   }
// 
//   public FileReadSpout(boolean ackEnabled, FileReader reader) {
//     this.ackEnabled = ackEnabled;
//     this.reader = reader;
//   }
// 
// 	@Override
// 	public void open(Map conf, TopologyContext context,
// 			SpoutOutputCollector collector) {
// 		this.collector = collector;
// 	}
// 
// 	@Override
// 	public void nextTuple() {
//     if (ackEnabled) {
//       collector.emit(new Values(reader.nextLine()), count);
//       count++;
//     } else {
//       collector.emit(new Values(reader.nextLine()));
//     }
// 	}
// 
// 	@Override
// 	public void declareOutputFields(OutputFieldsDeclarer declarer) {
// 		declarer.declare(new Fields(FIELDS));
// 	}
// }
// 
// Path: src/main/java/storm/benchmark/util/BenchmarkUtils.java
// public final class BenchmarkUtils {
//   private static final Logger LOG = Logger.getLogger(BenchmarkUtils.class);
// 
//   private BenchmarkUtils() {
//   }
// 
//   public static double max(Iterable<Double> iterable) {
//     Iterator<Double> iterator = iterable.iterator();
//     double max = Double.MIN_VALUE;
//     while (iterator.hasNext()) {
//       double d = iterator.next();
//       if (d > max) {
//         max = d;
//       }
//     }
//     return max;
//   }
// 
//   public static double avg(Iterable<Double> iterable) {
//     Iterator<Double> iterator = iterable.iterator();
//     double total = 0.0;
//     int num = 0;
//     while (iterator.hasNext()) {
//       total += iterator.next();
//       num++;
//     }
//     return total / num;
//   }
// 
//   public static void putIfAbsent(Map map, Object key, Object val) {
//     if (!map.containsKey(key)) {
//       map.put(key, val);
//     }
//   }
// 
//   public static int getInt(Map map, Object key, int def) {
//     return Utils.getInt(Utils.get(map, key, def));
//   }
// 
//   public static boolean ifAckEnabled(Config config) {
//     Object ackers = config.get(Config.TOPOLOGY_ACKER_EXECUTORS);
//     if (null == ackers) {
//       LOG.warn("acker executors are null");
//       return false;
//     }
//     return Utils.getInt(ackers) > 0;
//   }}


import backtype.storm.Config;
import backtype.storm.generated.StormTopology;
import storm.benchmark.benchmarks.common.WordCount;
import storm.benchmark.lib.spout.FileReadSpout;
import storm.benchmark.util.BenchmarkUtils;
/*
 * 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 storm.benchmark.benchmarks;


public class FileReadWordCount extends WordCount {

  @Override
  public StormTopology getTopology(Config config) {
// Path: src/main/java/storm/benchmark/lib/spout/FileReadSpout.java
// public class FileReadSpout extends BaseRichSpout {
//   private static final Logger LOG = Logger.getLogger(FileReadSpout.class);
//   private static final long serialVersionUID = -2582705611472467172L;
// 
// 	public static final String DEFAULT_FILE = "/resources/A_Tale_of_Two_City.txt";
//   public static final boolean DEFAULT_ACK = false;
//   public static final String FIELDS = "sentence";
// 
//   public final boolean ackEnabled;
//   public final FileReader reader;
// 	private SpoutOutputCollector collector;
// 
//   private long count = 0;
// 
// 
//   public FileReadSpout() {
//     this(DEFAULT_ACK, DEFAULT_FILE);
//   }
// 
// 
//   public FileReadSpout(boolean ackEnabled) {
//     this(ackEnabled, DEFAULT_FILE);
//   }
// 
//   public FileReadSpout(boolean ackEnabled, String file) {
//     this(ackEnabled, new FileReader(file));
//   }
// 
//   public FileReadSpout(boolean ackEnabled, FileReader reader) {
//     this.ackEnabled = ackEnabled;
//     this.reader = reader;
//   }
// 
// 	@Override
// 	public void open(Map conf, TopologyContext context,
// 			SpoutOutputCollector collector) {
// 		this.collector = collector;
// 	}
// 
// 	@Override
// 	public void nextTuple() {
//     if (ackEnabled) {
//       collector.emit(new Values(reader.nextLine()), count);
//       count++;
//     } else {
//       collector.emit(new Values(reader.nextLine()));
//     }
// 	}
// 
// 	@Override
// 	public void declareOutputFields(OutputFieldsDeclarer declarer) {
// 		declarer.declare(new Fields(FIELDS));
// 	}
// }
// 
// Path: src/main/java/storm/benchmark/util/BenchmarkUtils.java
// public final class BenchmarkUtils {
//   private static final Logger LOG = Logger.getLogger(BenchmarkUtils.class);
// 
//   private BenchmarkUtils() {
//   }
// 
//   public static double max(Iterable<Double> iterable) {
//     Iterator<Double> iterator = iterable.iterator();
//     double max = Double.MIN_VALUE;
//     while (iterator.hasNext()) {
//       double d = iterator.next();
//       if (d > max) {
//         max = d;
//       }
//     }
//     return max;
//   }
// 
//   public static double avg(Iterable<Double> iterable) {
//     Iterator<Double> iterator = iterable.iterator();
//     double total = 0.0;
//     int num = 0;
//     while (iterator.hasNext()) {
//       total += iterator.next();
//       num++;
//     }
//     return total / num;
//   }
// 
//   public static void putIfAbsent(Map map, Object key, Object val) {
//     if (!map.containsKey(key)) {
//       map.put(key, val);
//     }
//   }
// 
//   public static int getInt(Map map, Object key, int def) {
//     return Utils.getInt(Utils.get(map, key, def));
//   }
// 
//   public static boolean ifAckEnabled(Config config) {
//     Object ackers = config.get(Config.TOPOLOGY_ACKER_EXECUTORS);
//     if (null == ackers) {
//       LOG.warn("acker executors are null");
//       return false;
//     }
//     return Utils.getInt(ackers) > 0;
//   }}


// Path: src/main/java/storm/benchmark/benchmarks/FileReadWordCount.java
import backtype.storm.Config;
import backtype.storm.generated.StormTopology;
import storm.benchmark.benchmarks.common.WordCount;
import storm.benchmark.lib.spout.FileReadSpout;
import storm.benchmark.util.BenchmarkUtils;

/*
 * 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 storm.benchmark.benchmarks;


public class FileReadWordCount extends WordCount {

  @Override
  public StormTopology getTopology(Config config) {
    spout = new FileReadSpout(BenchmarkUtils.ifAckEnabled(config));