http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/cli/Simulation.java
----------------------------------------------------------------------
diff --git 
a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/cli/Simulation.java
 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/cli/Simulation.java
new file mode 100644
index 0000000..16aabf0
--- /dev/null
+++ 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/cli/Simulation.java
@@ -0,0 +1,188 @@
+/**
+ * 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.bigtop.datagenerators.bigpetstore.cli;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Vector;
+
+import org.apache.bigtop.datagenerators.bigpetstore.Constants;
+import org.apache.bigtop.datagenerators.bigpetstore.CustomerGenerator;
+import org.apache.bigtop.datagenerators.bigpetstore.ProductGenerator;
+import org.apache.bigtop.datagenerators.bigpetstore.PurchasingModelGenerator;
+import org.apache.bigtop.datagenerators.bigpetstore.StoreGenerator;
+import org.apache.bigtop.datagenerators.bigpetstore.TransactionGenerator;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Customer;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Store;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Transaction;
+import 
org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.InputData;
+import 
org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.ProductCategory;
+import 
org.apache.bigtop.datagenerators.bigpetstore.generators.purchase.PurchasingModel;
+import org.apache.bigtop.datagenerators.samplers.SeedFactory;
+import org.apache.bigtop.datagenerators.samplers.samplers.RouletteWheelSampler;
+import org.apache.bigtop.datagenerators.samplers.samplers.Sampler;
+
+import com.google.common.collect.Lists;
+
+public class Simulation
+{
+       InputData inputData;
+       SeedFactory seedFactory;
+       int nStores;
+       int nCustomers;
+       int nPurchasingModels;
+       double simulationTime;
+
+       List<Store> stores;
+       List<Customer> customers;
+       Sampler<PurchasingModel> purchasingModelSampler;
+       List<PurchasingModel> purchasingProfiles;
+       List<Transaction> transactions;
+       List<ProductCategory> productCategories;
+
+       public Simulation(InputData inputData, int nStores, int nCustomers, int 
nPurchasingModels, double simulationTime, long seed)
+       {
+               this.inputData = inputData;
+               this.nStores = nStores;
+               this.nCustomers = nCustomers;
+               this.nPurchasingModels = nPurchasingModels;
+               this.simulationTime = simulationTime;
+               seedFactory = new SeedFactory(seed);
+       }
+
+       public void generateStores() throws Exception
+       {
+               System.out.println("Generating stores");
+               StoreGenerator storeGenerator = new StoreGenerator(inputData, 
seedFactory);
+
+               stores = new Vector<Store>();
+               for(int i = 0; i < nStores; i++)
+               {
+                       Store store = storeGenerator.generate();
+                       stores.add(store);
+               }
+
+               stores = Collections.unmodifiableList(stores);
+
+               System.out.println("Generated " + stores.size() + " stores");
+       }
+
+       public void generateCustomers() throws Exception
+       {
+               System.out.println("Generating customers");
+               CustomerGenerator generator = new CustomerGenerator(inputData, 
stores, seedFactory);
+
+               customers = new Vector<Customer>();
+               for(int i = 0; i < nCustomers; i++)
+               {
+                       Customer customer = generator.generate();
+                       customers.add(customer);
+               }
+
+               customers = Collections.unmodifiableList(customers);
+
+               System.out.println("Generated " + customers.size() + " 
customers");
+       }
+
+       public void generateProducts()
+       {
+               System.out.println("Generating products");
+               ProductGenerator generator = new 
ProductGenerator(Constants.PRODUCTS_COLLECTION);
+               productCategories = generator.generate();
+       }
+
+       public void generatePurchasingProfiles() throws Exception
+       {
+               System.out.println("Generating purchasing profiles");
+               PurchasingModelGenerator generator = new 
PurchasingModelGenerator(productCategories, seedFactory);
+
+               purchasingProfiles = new Vector<PurchasingModel>();
+               for(int i = 0; i < nPurchasingModels; i++)
+               {
+                       PurchasingModel profile = generator.generate();
+                       purchasingProfiles.add(profile);
+               }
+
+               System.out.println("Generated " + purchasingProfiles.size() + " 
purchasing profiles");
+
+               purchasingModelSampler = 
RouletteWheelSampler.createUniform(purchasingProfiles, seedFactory);
+       }
+
+       public void generateTransactions() throws Exception
+       {
+               System.out.println("Generating transactions");
+               transactions = Lists.newArrayList();
+
+               for(int i = 0; i < nCustomers; i++)
+               {
+                       Customer customer = customers.get(i);
+                       PurchasingModel profile = 
purchasingModelSampler.sample();
+
+                       TransactionGenerator generator = new 
TransactionGenerator(customer,
+                                       profile, productCategories, 
seedFactory);
+
+                       while(true)
+                       {
+                               Transaction transaction = generator.generate();
+
+                               if(transaction.getDateTime() > simulationTime)
+                                       break;
+                               transactions.add(transaction);
+                       }
+               }
+
+               System.out.println("Generated " + transactions.size() + " 
transactions");
+       }
+
+       public void simulate() throws Exception
+       {
+               generateStores();
+               generateCustomers();
+               generateProducts();
+               generatePurchasingProfiles();
+               generateTransactions();
+       }
+
+       public List<Store> getStores()
+       {
+               return stores;
+       }
+
+       public List<Customer> getCustomers()
+       {
+               return customers;
+       }
+
+       public List<Transaction> getTransactions()
+       {
+               return transactions;
+       }
+
+       public InputData getInputData()
+       {
+               return inputData;
+       }
+
+       public List<ProductCategory> getProductCategories()
+       {
+               return this.productCategories;
+       }
+
+       public List<PurchasingModel> getPurchasingProfiles()
+       {
+               return this.purchasingProfiles;
+       }
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/Customer.java
----------------------------------------------------------------------
diff --git 
a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/Customer.java
 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/Customer.java
new file mode 100644
index 0000000..8847a36
--- /dev/null
+++ 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/Customer.java
@@ -0,0 +1,59 @@
+/**
+ * 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.bigtop.datagenerators.bigpetstore.datamodels;
+
+import java.io.Serializable;
+
+import 
org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.ZipcodeRecord;
+import org.apache.commons.lang3.tuple.Pair;
+
+public class Customer implements Serializable
+{
+       private static final long serialVersionUID = 5739806281335931258L;
+
+       int id;
+       Pair<String, String> name;
+       ZipcodeRecord location;
+       Store store;
+
+       public Customer(int id, Pair<String, String> name, Store store, 
ZipcodeRecord location)
+       {
+               this.id = id;
+               this.name = name;
+               this.location = location;
+               this.store = store;
+       }
+
+       public int getId()
+       {
+               return id;
+       }
+
+       public Pair<String, String> getName()
+       {
+               return name;
+       }
+
+       public ZipcodeRecord getLocation()
+       {
+               return location;
+       }
+
+       public Store getStore()
+       {
+               return store;
+       }
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/PetSpecies.java
----------------------------------------------------------------------
diff --git 
a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/PetSpecies.java
 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/PetSpecies.java
new file mode 100644
index 0000000..393626c
--- /dev/null
+++ 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/PetSpecies.java
@@ -0,0 +1,22 @@
+/**
+ * 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.bigtop.datagenerators.bigpetstore.datamodels;
+
+public enum PetSpecies
+{
+       DOG,
+       CAT;
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/Product.java
----------------------------------------------------------------------
diff --git 
a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/Product.java
 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/Product.java
new file mode 100644
index 0000000..da82647
--- /dev/null
+++ 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/Product.java
@@ -0,0 +1,96 @@
+/**
+ * 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.bigtop.datagenerators.bigpetstore.datamodels;
+
+import java.io.Serializable;
+import java.util.Map;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+
+public class Product implements Serializable
+{
+       private static final long serialVersionUID = 4519472063058037956L;
+
+       ImmutableMap<String, Object> fields;
+
+       public Product(Map<String, Object> fields)
+       {
+               this.fields = ImmutableMap.copyOf(fields);
+       }
+
+       public ImmutableSet<String> getFieldNames()
+       {
+               return fields.keySet();
+       }
+
+       public Object getFieldValue(String fieldName)
+       {
+               return fields.get(fieldName);
+       }
+
+       public String getFieldValueAsString(String fieldName)
+       {
+               return fields.get(fieldName).toString();
+       }
+
+       public Double getFieldValueAsDouble(String fieldName)
+       {
+               Object value = getFieldValue(fieldName);
+               try
+               {
+                       Double doubleValue = (Double) value;
+                       return doubleValue;
+               }
+               catch(ClassCastException e)
+               {
+                       return null;
+               }
+       }
+
+       public Long getFieldValueAsLong(String fieldName)
+       {
+               Object value = getFieldValue(fieldName);
+               try
+               {
+                       Long longValue = (Long) value;
+                       return longValue;
+               }
+               catch(ClassCastException e)
+               {
+                       try
+                       {
+                               Integer intValue = (Integer) value;
+                               return new Long(intValue);
+                       }
+                       catch(ClassCastException f)
+                       {
+                               return null;
+                       }
+               }
+       }
+
+       public String toString()
+       {
+               String str = "";
+               for(Map.Entry<String, Object> entry : fields.entrySet())
+               {
+                       str += entry.getKey() + "=" + entry.getValue() + ";";
+               }
+
+               return str;
+       }
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/Store.java
----------------------------------------------------------------------
diff --git 
a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/Store.java
 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/Store.java
new file mode 100644
index 0000000..61730dd
--- /dev/null
+++ 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/Store.java
@@ -0,0 +1,51 @@
+/**
+ * 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.bigtop.datagenerators.bigpetstore.datamodels;
+
+import java.io.Serializable;
+
+import 
org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.ZipcodeRecord;
+
+public class Store implements Serializable
+{
+       private static final long serialVersionUID = 2347066623022747969L;
+
+       int id;
+       String name;
+       ZipcodeRecord location;
+
+       public Store(int id, String name, ZipcodeRecord location)
+       {
+               this.id = id;
+               this.name = name;
+               this.location = location;
+       }
+
+       public int getId()
+       {
+               return id;
+       }
+
+       public String getName()
+       {
+               return name;
+       }
+
+       public ZipcodeRecord getLocation()
+       {
+               return location;
+       }
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/Transaction.java
----------------------------------------------------------------------
diff --git 
a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/Transaction.java
 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/Transaction.java
new file mode 100644
index 0000000..0ea8a66
--- /dev/null
+++ 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/Transaction.java
@@ -0,0 +1,68 @@
+/**
+ * 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.bigtop.datagenerators.bigpetstore.datamodels;
+
+import java.io.Serializable;
+import java.util.List;
+
+import com.google.common.collect.ImmutableList;
+
+public class Transaction implements Serializable
+{
+       private static final long serialVersionUID = 103133601154354349L;
+
+       final int id;
+       final Customer customer;
+       final Store store;
+       final Double dateTime;
+       final ImmutableList<Product> products;
+
+       public Transaction(int id, Customer customer, Store store, Double 
dateTime, List<Product> products)
+       {
+               this.id = id;
+               this.customer = customer;
+               this.store = store;
+               this.dateTime = dateTime;
+               this.products = ImmutableList.copyOf(products);
+       }
+
+       public int getId()
+       {
+               return id;
+       }
+
+       public Customer getCustomer()
+       {
+               return customer;
+       }
+
+       public Store getStore()
+       {
+               return store;
+       }
+
+       public Double getDateTime()
+       {
+               return dateTime;
+       }
+
+       public ImmutableList<Product> getProducts()
+       {
+               return products;
+       }
+
+
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/inputs/InputData.java
----------------------------------------------------------------------
diff --git 
a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/inputs/InputData.java
 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/inputs/InputData.java
new file mode 100644
index 0000000..7f5eddf
--- /dev/null
+++ 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/inputs/InputData.java
@@ -0,0 +1,45 @@
+/**
+ * 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.bigtop.datagenerators.bigpetstore.datamodels.inputs;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.List;
+
+public class InputData implements Serializable
+{
+       private static final long serialVersionUID = 9078989799806707788L;
+
+       List<ZipcodeRecord> zipcodeTable;
+       Names names;
+
+       public InputData(List<ZipcodeRecord> zipcodeTable,
+                       Names names)
+       {
+               this.zipcodeTable = Collections.unmodifiableList(zipcodeTable);
+               this.names = names;
+       }
+
+       public List<ZipcodeRecord> getZipcodeTable()
+       {
+               return zipcodeTable;
+       }
+
+       public Names getNames()
+       {
+               return names;
+       }
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/inputs/Names.java
----------------------------------------------------------------------
diff --git 
a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/inputs/Names.java
 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/inputs/Names.java
new file mode 100644
index 0000000..2d6da89
--- /dev/null
+++ 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/inputs/Names.java
@@ -0,0 +1,46 @@
+/**
+ * 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.bigtop.datagenerators.bigpetstore.datamodels.inputs;
+
+import java.io.Serializable;
+import java.util.Map;
+
+import com.google.common.collect.ImmutableMap;
+
+public class Names implements Serializable
+{
+       private static final long serialVersionUID = 2731634747628534453L;
+
+       final ImmutableMap<String, Double> firstNames;
+       final ImmutableMap<String, Double> lastNames;
+
+       public Names(Map<String, Double> firstNames,
+                       Map<String, Double> lastNames)
+       {
+               this.firstNames = ImmutableMap.copyOf(firstNames);
+               this.lastNames = ImmutableMap.copyOf(lastNames);
+       }
+
+       public ImmutableMap<String, Double> getFirstNames()
+       {
+               return firstNames;
+       }
+
+       public ImmutableMap<String, Double> getLastNames()
+       {
+               return lastNames;
+       }
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/inputs/ProductCategory.java
----------------------------------------------------------------------
diff --git 
a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/inputs/ProductCategory.java
 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/inputs/ProductCategory.java
new file mode 100644
index 0000000..c14d499
--- /dev/null
+++ 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/inputs/ProductCategory.java
@@ -0,0 +1,108 @@
+/**
+ * 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.bigtop.datagenerators.bigpetstore.datamodels.inputs;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.PetSpecies;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Product;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+
+public class ProductCategory implements Serializable
+{
+       private static final long serialVersionUID = -7638076590334497836L;
+
+       String categoryLabel;
+       ImmutableSet<PetSpecies> applicableSpecies;
+       ImmutableSet<String> fieldNames;
+       boolean triggerTransaction;
+       double dailyUsageRate;
+       double amountUsedPerPetAverage;
+       double amountUsedPerPetVariance;
+       double triggerTransactionRate;
+       double triggerPurchaseRate;
+       ImmutableList<Product> products;
+
+       public ProductCategory(String categoryLabel, Set<PetSpecies> species, 
Set<String> fieldNames,
+                       boolean triggerTransaction, double dailyUsageRate, 
double amountUsedPerPetAverage,
+                               double amountUsedPerPetVariance, double 
triggerTransactionRate,
+                               double triggerPurchaseRate, List<Product> 
products)
+       {
+               this.categoryLabel = categoryLabel;
+               this.applicableSpecies = ImmutableSet.copyOf(species);
+               this.fieldNames = ImmutableSet.copyOf(fieldNames);
+               this.triggerTransaction = triggerTransaction;
+               this.dailyUsageRate = dailyUsageRate;
+               this.amountUsedPerPetAverage = amountUsedPerPetAverage;
+               this.amountUsedPerPetVariance = amountUsedPerPetVariance;
+               this.triggerTransactionRate = triggerTransactionRate;
+               this.triggerPurchaseRate = triggerPurchaseRate;
+               this.products = ImmutableList.copyOf(products);
+       }
+
+       public String getCategoryLabel()
+       {
+               return categoryLabel;
+       }
+
+       public ImmutableSet<PetSpecies> getApplicableSpecies()
+       {
+               return applicableSpecies;
+       }
+
+       public ImmutableSet<String> getFieldNames()
+       {
+               return fieldNames;
+       }
+       public Boolean getTriggerTransaction()
+       {
+               return triggerTransaction;
+       }
+
+       public Double getDailyUsageRate()
+       {
+               return dailyUsageRate;
+       }
+
+       public Double getBaseAmountUsedAverage()
+       {
+               return amountUsedPerPetAverage;
+       }
+
+       public Double getBaseAmountUsedVariance()
+       {
+               return amountUsedPerPetVariance;
+       }
+
+       public Double getTransactionTriggerRate()
+       {
+               return triggerTransactionRate;
+       }
+
+       public Double getPurchaseTriggerRate()
+       {
+               return triggerPurchaseRate;
+       }
+
+       public ImmutableList<Product> getProducts()
+       {
+               return products;
+       }
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/inputs/ZipcodeRecord.java
----------------------------------------------------------------------
diff --git 
a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/inputs/ZipcodeRecord.java
 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/inputs/ZipcodeRecord.java
new file mode 100644
index 0000000..e5eeb60
--- /dev/null
+++ 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/inputs/ZipcodeRecord.java
@@ -0,0 +1,90 @@
+/**
+ * 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.bigtop.datagenerators.bigpetstore.datamodels.inputs;
+
+import java.io.Serializable;
+
+import org.apache.commons.lang3.tuple.Pair;
+
+public class ZipcodeRecord implements Serializable
+{
+       private static final long serialVersionUID = 1769986686070108470L;
+
+       final String zipcode;
+       final Pair<Double, Double> coordinates;
+       final String city;
+       final String state;
+       final double medianHouseholdIncome;
+       final long population;
+
+       public ZipcodeRecord(String zipcode, Pair<Double, Double> coordinates,
+                       String city, String state, double 
medianHouseholdIncome, long population)
+       {
+               this.city = city;
+               this.state = state;
+               this.zipcode = zipcode;
+               this.coordinates = coordinates;
+               this.medianHouseholdIncome = medianHouseholdIncome;
+               this.population = population;
+       }
+
+       public String getZipcode()
+       {
+               return zipcode;
+       }
+
+       public Pair<Double, Double> getCoordinates()
+       {
+               return coordinates;
+       }
+
+       public double getMedianHouseholdIncome()
+       {
+               return medianHouseholdIncome;
+       }
+
+       public long getPopulation()
+       {
+               return population;
+       }
+
+       public double distance(ZipcodeRecord other)
+       {
+               if(other.getZipcode().equals(zipcode))
+                       return 0.0;
+
+               Pair<Double, Double> otherCoords = other.getCoordinates();
+
+               double dist = Math.sin(Math.toRadians(coordinates.getLeft())) *
+                               Math.sin(Math.toRadians(otherCoords.getLeft())) 
+
+                               Math.cos(Math.toRadians(coordinates.getLeft())) 
*
+                               Math.cos(Math.toRadians(otherCoords.getLeft())) 
*
+                               Math.cos(Math.toRadians(coordinates.getRight() 
- otherCoords.getRight()));
+               dist = Math.toDegrees(Math.acos(dist)) * 69.09;
+
+               return dist;
+       }
+
+       public String getCity()
+       {
+               return city;
+       }
+
+       public String getState()
+       {
+               return state;
+       }
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datareaders/NameReader.java
----------------------------------------------------------------------
diff --git 
a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datareaders/NameReader.java
 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datareaders/NameReader.java
new file mode 100644
index 0000000..ec5412a
--- /dev/null
+++ 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datareaders/NameReader.java
@@ -0,0 +1,62 @@
+/**
+ * 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.bigtop.datagenerators.bigpetstore.datareaders;
+
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.Scanner;
+
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.Names;
+
+import com.google.common.collect.Maps;
+
+public class NameReader
+{
+       InputStream path;
+
+       public NameReader(InputStream path)
+       {
+               this.path = path;
+       }
+
+       public Names readData() throws FileNotFoundException
+       {
+               Scanner scanner = new Scanner(path);
+
+               Map<String, Double> firstNames = Maps.newHashMap();
+               Map<String, Double> lastNames = Maps.newHashMap();
+
+               while(scanner.hasNextLine())
+               {
+                       String line = scanner.nextLine();
+                       String[] cols = line.trim().split(",");
+
+                       String name = cols[0];
+                       double weight = Double.parseDouble(cols[5]);
+
+                       if(cols[4].equals("1"))
+                               firstNames.put(name, weight);
+                       if(cols[3].equals("1"))
+                               lastNames.put(name, weight);
+               }
+
+               scanner.close();
+
+               return new Names(firstNames, lastNames);
+
+       }
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datareaders/ZipcodeReader.java
----------------------------------------------------------------------
diff --git 
a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datareaders/ZipcodeReader.java
 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datareaders/ZipcodeReader.java
new file mode 100644
index 0000000..2478c8e
--- /dev/null
+++ 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/datareaders/ZipcodeReader.java
@@ -0,0 +1,193 @@
+/**
+ * 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.bigtop.datagenerators.bigpetstore.datareaders;
+
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Scanner;
+import java.util.Set;
+import java.util.Vector;
+
+import 
org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.ZipcodeRecord;
+import org.apache.commons.lang3.tuple.Pair;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+
+public class ZipcodeReader
+{
+       private static class ZipcodeLocationRecord
+       {
+               public final Pair<Double, Double> coordinates;
+               public final String state;
+               public final String city;
+
+               public ZipcodeLocationRecord(Pair<Double, Double> coordinates,
+                               String city, String state)
+               {
+                       this.coordinates = coordinates;
+                       this.city = city;
+                       this.state = state;
+               }
+       }
+
+       InputStream zipcodeIncomesFile = null;
+       InputStream zipcodePopulationFile = null;
+       InputStream zipcodeCoordinatesFile = null;
+
+       public void setIncomesFile(InputStream path)
+       {
+               this.zipcodeIncomesFile = path;
+       }
+
+       public void setPopulationFile(InputStream path)
+       {
+               this.zipcodePopulationFile = path;
+       }
+
+       public void setCoordinatesFile(InputStream path)
+       {
+               this.zipcodeCoordinatesFile = path;
+       }
+
+       private ImmutableMap<String, Double> readIncomeData(InputStream path) 
throws FileNotFoundException
+       {
+               Scanner scanner = new Scanner(path);
+
+               // skip headers
+               scanner.nextLine();
+               scanner.nextLine();
+
+               Map<String, Double> entries = Maps.newHashMap();
+               while(scanner.hasNextLine())
+               {
+                       String line = scanner.nextLine().trim();
+                       String[] cols = line.split(",");
+                       // zipcodes are in the form "ZCTA5 XXXXX"
+                       String zipcode = cols[2].split(" ")[1].trim();
+                       try
+                       {
+                               double medianHouseholdIncome = 
Integer.parseInt(cols[5].trim());
+                               entries.put(zipcode, medianHouseholdIncome);
+                       }
+                       catch(NumberFormatException e)
+                       {
+
+                       }
+               }
+
+               scanner.close();
+
+               return ImmutableMap.copyOf(entries);
+       }
+
+       private ImmutableMap<String, Long> readPopulationData(InputStream path) 
throws FileNotFoundException
+       {
+               Scanner scanner = new Scanner(path);
+
+               // skip header
+               scanner.nextLine();
+
+               Map<String, Long> entries = Maps.newHashMap();
+               while(scanner.hasNextLine())
+               {
+                       String line = scanner.nextLine().trim();
+
+                       if(line.length() == 0)
+                               continue;
+
+                       String[] cols = line.split(",");
+
+                       String zipcode = cols[0].trim();
+                       Long population = Long.parseLong(cols[1].trim());
+
+                       if(entries.containsKey(zipcode))
+                       {
+                               entries.put(zipcode, 
Math.max(entries.get(zipcode), population));
+                       }
+                       else
+                       {
+                               entries.put(zipcode, population);
+                       }
+               }
+
+               scanner.close();
+
+               return ImmutableMap.copyOf(entries);
+       }
+
+       private ImmutableMap<String, ZipcodeLocationRecord> 
readCoordinates(InputStream path) throws FileNotFoundException
+       {
+               Scanner scanner = new Scanner(path);
+
+               // skip header
+               scanner.nextLine();
+
+               Map<String, ZipcodeLocationRecord> entries = Maps.newHashMap();
+               while(scanner.hasNextLine())
+               {
+                       String line = scanner.nextLine().trim();
+
+                       String[] cols = line.split(", ");
+
+                       // remove quote marks
+                       String zipcode = cols[0].substring(1, cols[0].length() 
- 1);
+                       String state = cols[1].substring(1, cols[1].length() - 
1);
+                       Double latitude = 
Double.parseDouble(cols[2].substring(1, cols[2].length() - 1));
+                       Double longitude = 
Double.parseDouble(cols[3].substring(1, cols[3].length() - 1));
+                       String city = cols[4].substring(1, cols[4].length() - 
1);
+
+                       Pair<Double, Double> coords = Pair.of(latitude, 
longitude);
+
+                       ZipcodeLocationRecord record = new 
ZipcodeLocationRecord(coords, city, state);
+
+                       entries.put(zipcode, record);
+               }
+
+               scanner.close();
+
+               return ImmutableMap.copyOf(entries);
+       }
+
+       public ImmutableList<ZipcodeRecord> readData() throws 
FileNotFoundException
+       {
+               ImmutableMap<String, Double> incomes = 
readIncomeData(this.zipcodeIncomesFile);
+               ImmutableMap<String, Long> populations = 
readPopulationData(this.zipcodePopulationFile);
+               ImmutableMap<String, ZipcodeLocationRecord> coordinates = 
readCoordinates(this.zipcodeCoordinatesFile);
+
+               Set<String> zipcodeSubset = new 
HashSet<String>(incomes.keySet());
+               zipcodeSubset.retainAll(populations.keySet());
+               zipcodeSubset.retainAll(coordinates.keySet());
+
+               List<ZipcodeRecord> table = new Vector<ZipcodeRecord>();
+               for(String zipcode : zipcodeSubset)
+               {
+                       ZipcodeRecord record = new ZipcodeRecord(zipcode,
+                                       coordinates.get(zipcode).coordinates,
+                                       coordinates.get(zipcode).city,
+                                       coordinates.get(zipcode).state,
+                                       incomes.get(zipcode),
+                                       populations.get(zipcode));
+                       table.add(record);
+               }
+
+               return ImmutableList.copyOf(table);
+       }
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/customer/CustomerLocationPDF.java
----------------------------------------------------------------------
diff --git 
a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/customer/CustomerLocationPDF.java
 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/customer/CustomerLocationPDF.java
new file mode 100644
index 0000000..08cbc81
--- /dev/null
+++ 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/customer/CustomerLocationPDF.java
@@ -0,0 +1,69 @@
+/**
+ * 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.bigtop.datagenerators.bigpetstore.generators.customer;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Store;
+import 
org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.ZipcodeRecord;
+import 
org.apache.bigtop.datagenerators.samplers.pdfs.ProbabilityDensityFunction;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+
+public class CustomerLocationPDF implements 
ProbabilityDensityFunction<ZipcodeRecord>
+{
+       private final Map<ZipcodeRecord, Double> pdf;
+
+       public CustomerLocationPDF(List<ZipcodeRecord> zipcodes, Store store, 
double averageDistance)
+       {
+               this.pdf = build(zipcodes, store, averageDistance);
+       }
+
+       protected ImmutableMap<ZipcodeRecord, Double> build(List<ZipcodeRecord> 
zipcodeTable,
+                       Store store, double averageDistance)
+       {
+               double lambda = 1.0 / averageDistance;
+
+               Map<ZipcodeRecord, Double> zipcodeWeights = Maps.newHashMap();
+               double totalWeight = 0.0;
+               for(ZipcodeRecord record : zipcodeTable)
+               {
+                       double dist = record.distance(store.getLocation());
+
+                       double weight = lambda * Math.exp(-1.0 * lambda * dist);
+                       totalWeight += weight;
+                       zipcodeWeights.put(record, weight);
+               }
+
+               Map<ZipcodeRecord, Double> pdf = Maps.newHashMap();
+               for(ZipcodeRecord record : zipcodeTable)
+               {
+                       pdf.put(record, zipcodeWeights.get(record) / 
totalWeight);
+               }
+
+               return ImmutableMap.copyOf(pdf);
+       }
+
+       public double probability(ZipcodeRecord record)
+       {
+               if(!this.pdf.containsKey(record))
+                       return 0.0;
+
+               return this.pdf.get(record);
+       }
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/customer/CustomerSampler.java
----------------------------------------------------------------------
diff --git 
a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/customer/CustomerSampler.java
 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/customer/CustomerSampler.java
new file mode 100644
index 0000000..13b69a3
--- /dev/null
+++ 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/customer/CustomerSampler.java
@@ -0,0 +1,56 @@
+/**
+ * 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.bigtop.datagenerators.bigpetstore.generators.customer;
+
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Customer;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Store;
+import 
org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.ZipcodeRecord;
+import org.apache.bigtop.datagenerators.samplers.samplers.ConditionalSampler;
+import org.apache.bigtop.datagenerators.samplers.samplers.Sampler;
+import org.apache.commons.lang3.tuple.Pair;
+
+public class CustomerSampler implements Sampler<Customer>
+{
+       private final Sampler<Integer> idSampler;
+       private final Sampler<String> firstNameSampler;
+       private final Sampler<String> lastNameSampler;
+       private final Sampler<Store> storeSampler;
+       private final ConditionalSampler<ZipcodeRecord, Store> locationSampler;
+
+
+       public CustomerSampler(Sampler<Integer> idSampler, Sampler<String> 
firstNameSampler,
+                       Sampler<String> lastNameSampler, Sampler<Store> 
storeSampler,
+                       ConditionalSampler<ZipcodeRecord, Store> 
locationSampler)
+       {
+               this.idSampler = idSampler;
+               this.firstNameSampler = firstNameSampler;
+               this.lastNameSampler = lastNameSampler;
+               this.storeSampler = storeSampler;
+               this.locationSampler = locationSampler;
+       }
+
+       public Customer sample() throws Exception
+       {
+               Integer id = idSampler.sample();
+               Pair<String, String> name = Pair.of(firstNameSampler.sample(),
+                               lastNameSampler.sample());
+               Store store = storeSampler.sample();
+               ZipcodeRecord location = locationSampler.sample(store);
+
+               return new Customer(id, name, store, location);
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/customer/CustomerSamplerBuilder.java
----------------------------------------------------------------------
diff --git 
a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/customer/CustomerSamplerBuilder.java
 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/customer/CustomerSamplerBuilder.java
new file mode 100644
index 0000000..56ab761
--- /dev/null
+++ 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/customer/CustomerSamplerBuilder.java
@@ -0,0 +1,80 @@
+/**
+ * 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.bigtop.datagenerators.bigpetstore.generators.customer;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.bigtop.datagenerators.bigpetstore.Constants;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Customer;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Store;
+import 
org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.InputData;
+import 
org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.ZipcodeRecord;
+import org.apache.bigtop.datagenerators.samplers.SeedFactory;
+import 
org.apache.bigtop.datagenerators.samplers.pdfs.ProbabilityDensityFunction;
+import org.apache.bigtop.datagenerators.samplers.samplers.ConditionalSampler;
+import org.apache.bigtop.datagenerators.samplers.samplers.RouletteWheelSampler;
+import org.apache.bigtop.datagenerators.samplers.samplers.Sampler;
+import org.apache.bigtop.datagenerators.samplers.samplers.SequenceSampler;
+
+import com.google.common.collect.Maps;
+
+public class CustomerSamplerBuilder
+{
+       private final List<Store> stores;
+       private final InputData inputData;
+       private final SeedFactory seedFactory;
+
+       public CustomerSamplerBuilder(List<Store> stores, InputData inputData, 
SeedFactory seedFactory)
+       {
+               this.stores = stores;
+               this.seedFactory = seedFactory;
+               this.inputData = inputData;
+       }
+
+       protected ConditionalSampler<ZipcodeRecord, Store> 
buildLocationSampler()
+       {
+               final Map<Store, Sampler<ZipcodeRecord>> locationSamplers = 
Maps.newHashMap();
+               for(Store store : stores)
+               {
+                       ProbabilityDensityFunction<ZipcodeRecord> locationPDF = 
new CustomerLocationPDF(inputData.getZipcodeTable(),
+                                       store, 
Constants.AVERAGE_CUSTOMER_STORE_DISTANCE);
+                       Sampler<ZipcodeRecord> locationSampler = 
RouletteWheelSampler.create(inputData.getZipcodeTable(), locationPDF, 
seedFactory);
+                       locationSamplers.put(store, locationSampler);
+               }
+
+               return new ConditionalSampler<ZipcodeRecord, Store>()
+                               {
+                                       public ZipcodeRecord sample(Store 
store) throws Exception
+                                       {
+                                               return 
locationSamplers.get(store).sample();
+                                       }
+                               };
+       }
+
+       public Sampler<Customer> build()
+       {
+               ProbabilityDensityFunction<Store> storePDF = new 
CustomerStorePDF(stores);
+
+               Sampler<Integer> idSampler = new SequenceSampler();
+               Sampler<String> firstNameSampler = 
RouletteWheelSampler.create(inputData.getNames().getFirstNames(), seedFactory);
+               Sampler<String> lastNameSampler = 
RouletteWheelSampler.create(inputData.getNames().getLastNames(), seedFactory);
+               Sampler<Store> storeSampler = 
RouletteWheelSampler.create(stores, storePDF, seedFactory);
+
+               return new CustomerSampler(idSampler, firstNameSampler, 
lastNameSampler, storeSampler, buildLocationSampler());
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/customer/CustomerStorePDF.java
----------------------------------------------------------------------
diff --git 
a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/customer/CustomerStorePDF.java
 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/customer/CustomerStorePDF.java
new file mode 100644
index 0000000..6131454
--- /dev/null
+++ 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/customer/CustomerStorePDF.java
@@ -0,0 +1,41 @@
+/**
+ * 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.bigtop.datagenerators.bigpetstore.generators.customer;
+
+import java.util.List;
+
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Store;
+import 
org.apache.bigtop.datagenerators.samplers.pdfs.ProbabilityDensityFunction;
+
+public class CustomerStorePDF implements ProbabilityDensityFunction<Store>
+{
+       double populationSum = 0.0;
+
+       public CustomerStorePDF(List<Store> stores)
+       {
+               for(Store store : stores)
+               {
+                       populationSum += (double) 
store.getLocation().getPopulation();
+               }
+       }
+
+       @Override
+       public double probability(Store store)
+       {
+               return ((double) store.getLocation().getPopulation()) / 
populationSum;
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/ProductBuilderIterator.java
----------------------------------------------------------------------
diff --git 
a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/ProductBuilderIterator.java
 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/ProductBuilderIterator.java
new file mode 100644
index 0000000..bf64ea7
--- /dev/null
+++ 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/ProductBuilderIterator.java
@@ -0,0 +1,80 @@
+/**
+ * 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.bigtop.datagenerators.bigpetstore.generators.products;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.bigtop.datagenerators.bigpetstore.Constants;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Product;
+
+import com.google.common.collect.Maps;
+
+public class ProductBuilderIterator implements Iterator<Product>
+{
+       Iterator<Map<String, ProductFieldValue>> productIterator;
+       double basePrice;
+       String productCategory;
+
+       public ProductBuilderIterator(double basePrice, String productCategory,
+                       Iterator<Map<String, ProductFieldValue>> 
productIterator)
+       {
+               this.productIterator = productIterator;
+               this.basePrice = basePrice;
+               this.productCategory = productCategory;
+       }
+
+       @Override
+       public boolean hasNext()
+       {
+               return productIterator != null && productIterator.hasNext();
+       }
+
+       @Override
+       public Product next()
+       {
+               Map<String, ProductFieldValue> productComponents = 
productIterator.next();
+
+               double sum = 0.0;
+               double product = 1.0;
+
+               Map<String, Object> productFields = Maps.newHashMap();
+
+               for(Map.Entry<String, ProductFieldValue> entry : 
productComponents.entrySet())
+               {
+                       productFields.put(entry.getKey(), 
entry.getValue().getValue());
+                       sum += entry.getValue().getAdd();
+                       product *= entry.getValue().getMultiply();
+               }
+
+               double quantity = (Double) 
productFields.get(Constants.PRODUCT_QUANTITY);
+               double price = product * (sum + basePrice);
+               double unitPrice = price / quantity;
+
+               productFields.put(Constants.PRODUCT_UNIT_PRICE, unitPrice);
+               productFields.put(Constants.PRODUCT_PRICE, price);
+               productFields.put(Constants.PRODUCT_CATEGORY, productCategory);
+
+               return new Product(productFields);
+       }
+
+       @Override
+       public void remove()
+       {
+               throw new UnsupportedOperationException("ProductBuilder does 
not support remove()");
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/ProductCategoryBuilder.java
----------------------------------------------------------------------
diff --git 
a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/ProductCategoryBuilder.java
 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/ProductCategoryBuilder.java
new file mode 100644
index 0000000..d105ec3
--- /dev/null
+++ 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/ProductCategoryBuilder.java
@@ -0,0 +1,195 @@
+/**
+ * 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.bigtop.datagenerators.bigpetstore.generators.products;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Vector;
+
+import org.apache.bigtop.datagenerators.bigpetstore.Constants;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.PetSpecies;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Product;
+import 
org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.ProductCategory;
+import 
org.apache.bigtop.datagenerators.bigpetstore.generators.products.rules.AlwaysTrueRule;
+import 
org.apache.bigtop.datagenerators.bigpetstore.generators.products.rules.NotRule;
+import 
org.apache.bigtop.datagenerators.bigpetstore.generators.products.rules.OrRule;
+import 
org.apache.bigtop.datagenerators.bigpetstore.generators.products.rules.Rule;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+public class ProductCategoryBuilder
+{
+       String categoryLabel;
+       Set<PetSpecies> applicableSpecies;
+       Boolean triggerTransaction;
+       Double dailyUsageRate;
+       Double amountUsedPerPetAverage;
+       Double amountUsedPerPetVariance;
+       Double triggerTransactionRate;
+       Double triggerPurchaseRate;
+       List<Rule> exclusionRules;
+       Map<String, Collection<ProductFieldValue>> productFieldValues;
+       Double basePrice;
+       List<Product> products;
+
+       public ProductCategoryBuilder()
+       {
+               applicableSpecies = Sets.newHashSet();
+
+               dailyUsageRate = 0.0;
+               amountUsedPerPetAverage = 0.0;
+               amountUsedPerPetVariance = 0.0;
+               triggerTransactionRate = 0.0;
+               triggerPurchaseRate = 0.0;
+               triggerTransaction = false;
+               categoryLabel = null;
+               exclusionRules = new Vector<Rule>();
+               productFieldValues = Maps.newHashMap();
+               basePrice = 1.0;
+               products = Lists.newArrayList();
+       }
+
+       public void setCategory(String category)
+       {
+               this.categoryLabel = category;
+       }
+
+       public void setTriggerTransaction(Boolean triggerTransaction)
+       {
+               this.triggerTransaction = triggerTransaction;
+       }
+
+       public void setDailyUsageRate(Double dailyUsageRate)
+       {
+               this.dailyUsageRate = dailyUsageRate;
+       }
+
+       public void setAmountUsedPetPetAverage(Double baseAmountUsedAverage)
+       {
+               this.amountUsedPerPetAverage = baseAmountUsedAverage;
+       }
+
+       public void setAmountUsedPetPetVariance(Double baseAmountUsedVariance)
+       {
+               this.amountUsedPerPetVariance = baseAmountUsedVariance;
+       }
+
+       public void setTriggerTransactionRate(Double triggerTransactionRate)
+       {
+               this.triggerTransactionRate = triggerTransactionRate;
+       }
+
+       public void setTriggerPurchaseRate(Double triggerPurchaseRate)
+       {
+               this.triggerPurchaseRate = triggerPurchaseRate;
+       }
+
+       public void addApplicableSpecies(PetSpecies species)
+       {
+               this.applicableSpecies.add(species);
+       }
+
+       public void addProduct(Product product)
+       {
+               products.add(product);
+       }
+
+       public void addExclusionRule(Rule rule)
+       {
+               this.exclusionRules.add(rule);
+       }
+
+       public void addPropertyValues(String fieldName, ProductFieldValue ... 
values)
+       {
+               this.productFieldValues.put(fieldName,  Arrays.asList(values));
+       }
+
+       public void setBasePrice(double basePrice)
+       {
+               this.basePrice = basePrice;
+       }
+
+
+       protected List<Product> generateProducts()
+       {
+               Rule combinedRules = new NotRule(new AlwaysTrueRule());
+               if(exclusionRules.size() == 1)
+               {
+                       combinedRules = exclusionRules.get(0);
+               }
+               else if(exclusionRules.size() > 1)
+               {
+                        combinedRules = new OrRule(exclusionRules.toArray(new 
Rule[] {}));
+               }
+
+               Iterator<Product> productIterator = new 
ProductIterator(productFieldValues, combinedRules,
+                               basePrice, categoryLabel);
+
+               while(productIterator.hasNext())
+               {
+                       products.add(productIterator.next());
+               }
+
+               return products;
+       }
+
+       public void validateProducts()
+       {
+               for(Product product : products)
+               {
+                       
if(!product.getFieldNames().contains(Constants.PRODUCT_CATEGORY))
+                       {
+                               throw new IllegalStateException("Product must 
have field " + Constants.PRODUCT_CATEGORY);
+                       }
+
+                       
if(!product.getFieldNames().contains(Constants.PRODUCT_QUANTITY))
+                       {
+                               throw new IllegalStateException("Product must 
have field " + Constants.PRODUCT_QUANTITY);
+                       }
+
+                       
if(!product.getFieldNames().contains(Constants.PRODUCT_PRICE))
+                       {
+                               throw new IllegalStateException("Product must 
have field " + Constants.PRODUCT_PRICE);
+                       }
+
+                       
if(!product.getFieldNames().contains(Constants.PRODUCT_UNIT_PRICE))
+                       {
+                               throw new IllegalStateException("Product must 
have field " + Constants.PRODUCT_UNIT_PRICE);
+                       }
+               }
+       }
+
+       public ProductCategory build()
+       {
+               List<Product> products = generateProducts();
+
+               Set<String> fieldNames = Sets.newHashSet();
+               for(Product product : products)
+               {
+                       fieldNames.addAll(product.getFieldNames());
+               }
+
+               return new ProductCategory(categoryLabel, applicableSpecies, 
fieldNames, triggerTransaction,
+                               dailyUsageRate, amountUsedPerPetAverage, 
amountUsedPerPetVariance, triggerTransactionRate,
+                                       triggerPurchaseRate, products);
+       }
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/ProductFieldValue.java
----------------------------------------------------------------------
diff --git 
a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/ProductFieldValue.java
 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/ProductFieldValue.java
new file mode 100644
index 0000000..1499fcd
--- /dev/null
+++ 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/ProductFieldValue.java
@@ -0,0 +1,45 @@
+/**
+ * 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.bigtop.datagenerators.bigpetstore.generators.products;
+
+public class ProductFieldValue
+{
+       Object value;
+       double add;
+       double multiply;
+
+       public ProductFieldValue(Object value, double add, double multiply)
+       {
+               this.value = value;
+               this.add = add;
+               this.multiply = multiply;
+       }
+
+       public Object getValue()
+       {
+               return value;
+       }
+
+       public double getAdd()
+       {
+               return add;
+       }
+
+       public double getMultiply()
+       {
+               return multiply;
+       }
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/ProductFilterIterator.java
----------------------------------------------------------------------
diff --git 
a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/ProductFilterIterator.java
 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/ProductFilterIterator.java
new file mode 100644
index 0000000..10a5f3a
--- /dev/null
+++ 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/ProductFilterIterator.java
@@ -0,0 +1,72 @@
+/**
+ * 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.bigtop.datagenerators.bigpetstore.generators.products;
+
+import java.util.Iterator;
+
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Product;
+import 
org.apache.bigtop.datagenerators.bigpetstore.generators.products.rules.Rule;
+
+public class ProductFilterIterator implements Iterator<Product>
+{
+       Rule rule;
+       Iterator<Product> products;
+       Product buffer;
+
+       public ProductFilterIterator(Rule rule, Iterator<Product> products)
+       {
+               this.rule = rule;
+               this.products = products;
+               this.buffer = getNext();
+       }
+
+       private Product getNext()
+       {
+               while(products.hasNext())
+               {
+                       Product product = products.next();
+
+                       if(!rule.ruleMatches(product))
+                       {
+                               return product;
+                       }
+               }
+
+               return null;
+       }
+
+       @Override
+       public boolean hasNext()
+       {
+               return buffer != null;
+       }
+
+       @Override
+       public Product next()
+       {
+               Product previous = buffer;
+               buffer = getNext();
+
+               return previous;
+       }
+
+       @Override
+       public void remove()
+       {
+               throw new UnsupportedOperationException("ProductFilter does not 
support remove()");
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/ProductIterator.java
----------------------------------------------------------------------
diff --git 
a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/ProductIterator.java
 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/ProductIterator.java
new file mode 100644
index 0000000..032b0e4
--- /dev/null
+++ 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/ProductIterator.java
@@ -0,0 +1,78 @@
+/**
+ * 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.bigtop.datagenerators.bigpetstore.generators.products;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Product;
+import 
org.apache.bigtop.datagenerators.bigpetstore.generators.products.cartesian.CartesianProduct;
+import 
org.apache.bigtop.datagenerators.bigpetstore.generators.products.cartesian.CartesianProductBase;
+import 
org.apache.bigtop.datagenerators.bigpetstore.generators.products.cartesian.CartesianProductField;
+import 
org.apache.bigtop.datagenerators.bigpetstore.generators.products.rules.Rule;
+
+public class ProductIterator implements Iterator<Product>
+{
+
+       Iterator<Product> productIterator;
+
+       public ProductIterator(Map<String, Collection<ProductFieldValue>> 
fieldValues, Rule matcher,
+                       double basePrice, String productCategory)
+       {
+               productIterator = new ProductFilterIterator(matcher,
+                               new ProductBuilderIterator(basePrice, 
productCategory,
+                                               
buildCartesianProductIterator(fieldValues)));
+       }
+
+       public Iterator<Map<String, ProductFieldValue>>
+               buildCartesianProductIterator(Map<String, 
Collection<ProductFieldValue>> fieldValues)
+       {
+               CartesianProduct<ProductFieldValue> product = null;
+               for(Map.Entry<String, Collection<ProductFieldValue>> pair : 
fieldValues.entrySet())
+               {
+                       if(product == null)
+                       {
+                               product = new 
CartesianProductBase<ProductFieldValue>(pair.getKey(), pair.getValue());
+                       } else
+                       {
+                               product = new 
CartesianProductField<ProductFieldValue>(pair.getKey(), pair.getValue(), 
product);
+                       }
+
+               }
+
+               return product;
+       }
+
+       @Override
+       public boolean hasNext()
+       {
+               return productIterator.hasNext();
+       }
+
+       @Override
+       public Product next()
+       {
+               return productIterator.next();
+       }
+
+       @Override
+       public void remove()
+       {
+               throw new UnsupportedOperationException("ProductIterator does 
not support remove()");
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/cartesian/CartesianProduct.java
----------------------------------------------------------------------
diff --git 
a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/cartesian/CartesianProduct.java
 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/cartesian/CartesianProduct.java
new file mode 100644
index 0000000..2d1c005
--- /dev/null
+++ 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/cartesian/CartesianProduct.java
@@ -0,0 +1,24 @@
+/**
+ * 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.bigtop.datagenerators.bigpetstore.generators.products.cartesian;
+
+import java.util.Iterator;
+import java.util.Map;
+
+public interface CartesianProduct<T> extends Iterator<Map<String, T>>
+{
+
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/cartesian/CartesianProductBase.java
----------------------------------------------------------------------
diff --git 
a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/cartesian/CartesianProductBase.java
 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/cartesian/CartesianProductBase.java
new file mode 100644
index 0000000..7765469
--- /dev/null
+++ 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/cartesian/CartesianProductBase.java
@@ -0,0 +1,56 @@
+/**
+ * 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.bigtop.datagenerators.bigpetstore.generators.products.cartesian;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+
+public class CartesianProductBase<T> implements CartesianProduct<T>
+{
+       String fieldName;
+       Iterator<T> fieldValues;
+
+       public CartesianProductBase(String fieldName, Collection<T> fieldValues)
+       {
+               this.fieldName = fieldName;
+               this.fieldValues = fieldValues.iterator();
+       }
+
+
+       @Override
+       public boolean hasNext()
+       {
+               return fieldValues.hasNext();
+       }
+
+       @Override
+       public Map<String, T> next()
+       {
+               Map<String, T> map = new HashMap<String, T>();
+               map.put(fieldName, fieldValues.next());
+
+               return map;
+       }
+
+       @Override
+       public void remove()
+       {
+               throw new UnsupportedOperationException("CartesianProductBase 
does not support remove()");
+       }
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/cartesian/CartesianProductField.java
----------------------------------------------------------------------
diff --git 
a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/cartesian/CartesianProductField.java
 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/cartesian/CartesianProductField.java
new file mode 100644
index 0000000..38939f6
--- /dev/null
+++ 
b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/cartesian/CartesianProductField.java
@@ -0,0 +1,79 @@
+/**
+ * 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.bigtop.datagenerators.bigpetstore.generators.products.cartesian;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+public class CartesianProductField<T> implements CartesianProduct<T>
+{
+       String fieldName;
+       Iterator<T> fieldValuesIterator;
+       Collection<T> fieldValues;
+       CartesianProduct<T> previous;
+       Map<String, T> baseValue;
+
+       public CartesianProductField(String fieldName, Collection<T> 
fieldValues, CartesianProduct<T> previous)
+       {
+               this.fieldValues = fieldValues;
+               this.fieldName = fieldName;
+               this.previous = previous;
+       }
+
+       @Override
+       public boolean hasNext()
+       {
+               return previous.hasNext() || (fieldValuesIterator != null && 
fieldValuesIterator.hasNext());
+       }
+
+       @Override
+       public Map<String, T> next()
+       {
+               if(fieldValuesIterator != null)
+               {
+                       Map<String, T> map = new HashMap<String, T>(baseValue);
+                       map.put(fieldName, fieldValuesIterator.next());
+
+                       if(!fieldValuesIterator.hasNext())
+                       {
+                               fieldValuesIterator = null;
+                       }
+
+                       return map;
+               } else if(previous.hasNext())
+               {
+                       baseValue = previous.next();
+                       fieldValuesIterator = fieldValues.iterator();
+
+                       Map<String, T> map = new HashMap<String, T>(baseValue);
+                       map.put(fieldName, fieldValuesIterator.next());
+
+                       return map;
+               }
+
+               throw new NoSuchElementException();
+       }
+
+       @Override
+       public void remove()
+       {
+               throw new UnsupportedOperationException("CartesianProductBase 
does not support remove()");
+       }
+
+}

Reply via email to