You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bigtop.apache.org by rn...@apache.org on 2015/08/25 16:21:43 UTC
[09/11] bigtop git commit: BIGTOP-1984. Extract samplers library from
BigPetStore data generator
http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/ProductFieldValue.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/ProductFieldValue.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/ProductFieldValue.java
deleted file mode 100644
index fe4d7fa..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/ProductFieldValue.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.bigtop.bigpetstore.datagenerator.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/bigpetstore/datagenerator/generators/products/ProductFilterIterator.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/ProductFilterIterator.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/ProductFilterIterator.java
deleted file mode 100644
index c0e285d..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/ProductFilterIterator.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.bigtop.bigpetstore.datagenerator.generators.products;
-
-import java.util.Iterator;
-
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product;
-import org.apache.bigtop.bigpetstore.datagenerator.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/bigpetstore/datagenerator/generators/products/ProductIterator.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/ProductIterator.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/ProductIterator.java
deleted file mode 100644
index ccfef56..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/ProductIterator.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.bigtop.bigpetstore.datagenerator.generators.products;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product;
-import org.apache.bigtop.bigpetstore.datagenerator.generators.products.cartesian.CartesianProduct;
-import org.apache.bigtop.bigpetstore.datagenerator.generators.products.cartesian.CartesianProductBase;
-import org.apache.bigtop.bigpetstore.datagenerator.generators.products.cartesian.CartesianProductField;
-import org.apache.bigtop.bigpetstore.datagenerator.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/bigpetstore/datagenerator/generators/products/cartesian/CartesianProduct.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/cartesian/CartesianProduct.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/cartesian/CartesianProduct.java
deleted file mode 100644
index f688980..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/cartesian/CartesianProduct.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.bigtop.bigpetstore.datagenerator.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/bigpetstore/datagenerator/generators/products/cartesian/CartesianProductBase.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/cartesian/CartesianProductBase.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/cartesian/CartesianProductBase.java
deleted file mode 100644
index 7b0934c..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/cartesian/CartesianProductBase.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.bigtop.bigpetstore.datagenerator.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/bigpetstore/datagenerator/generators/products/cartesian/CartesianProductField.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/cartesian/CartesianProductField.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/cartesian/CartesianProductField.java
deleted file mode 100644
index 166efc8..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/cartesian/CartesianProductField.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.bigtop.bigpetstore.datagenerator.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()");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/collections/MediumProductCollection.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/collections/MediumProductCollection.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/collections/MediumProductCollection.java
deleted file mode 100644
index 2ec72d1..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/collections/MediumProductCollection.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.bigtop.bigpetstore.datagenerator.generators.products.collections;
-
-import java.util.List;
-
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.PetSpecies;
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ProductCategory;
-import org.apache.bigtop.bigpetstore.datagenerator.generators.products.ProductCategoryBuilder;
-import org.apache.bigtop.bigpetstore.datagenerator.generators.products.ProductFieldValue;
-import org.apache.bigtop.bigpetstore.datagenerator.generators.products.rules.AndRule;
-import org.apache.bigtop.bigpetstore.datagenerator.generators.products.rules.FieldPredicate;
-import org.apache.bigtop.bigpetstore.datagenerator.generators.products.rules.NotRule;
-import org.apache.bigtop.bigpetstore.datagenerator.generators.products.rules.OrRule;
-
-import com.google.common.collect.Lists;
-
-public class MediumProductCollection
-{
- private ProductCategory createDogFood()
- {
- ProductCategoryBuilder builder = new ProductCategoryBuilder();
-
- builder.addApplicableSpecies(PetSpecies.DOG);
- builder.setCategory("dry dog food");
- builder.setTriggerTransaction(true);
- builder.setDailyUsageRate(2.0);
- builder.setAmountUsedPetPetAverage(0.25);
- builder.setAmountUsedPetPetVariance(0.1);
- builder.setTriggerTransactionRate(2.0);
- builder.setTriggerPurchaseRate(7.0);
- builder.setBasePrice(2.0);
-
- builder.addPropertyValues("brand",
- new ProductFieldValue("Wellfed", 0.67, 1.0),
- new ProductFieldValue("Happy Pup", 0.67, 1.0),
- new ProductFieldValue("Dog Days", 1.0, 1.0),
- new ProductFieldValue("Chef Corgi", 0.0, 1.0));
-
- builder.addPropertyValues("meat",
- new ProductFieldValue("Chicken", 0.0, 1.0),
- new ProductFieldValue("Pork", 0.0, 1.0),
- new ProductFieldValue("Lamb", 0.1, 1.0),
- new ProductFieldValue("Salmon", 0.25, 1.0),
- new ProductFieldValue("Venison", 0.5, 1.0),
- new ProductFieldValue("Rabbit", 0.5, 1.0),
- new ProductFieldValue("Vegetarian", 0.0, 1.0));
-
- builder.addPropertyValues("grain",
- new ProductFieldValue("Corn", 0.0, 1.0),
- new ProductFieldValue("Potatoes", 0.1, 1.0),
- new ProductFieldValue("Barley", 0.1, 1.0),
- new ProductFieldValue("Rice", 0.0, 1.0),
- new ProductFieldValue("Soy", 0.1, 1.0));
-
- builder.addPropertyValues("lifestage",
- new ProductFieldValue("Senior", 0.0, 1.0),
- new ProductFieldValue("Puppy", 0.0, 1.0),
- new ProductFieldValue("Adult", 0.0, 1.0));
-
- builder.addPropertyValues("organic",
- new ProductFieldValue("false", 0.0, 1.0),
- new ProductFieldValue("true", 0.0, 1.1));
-
- builder.addPropertyValues("quantity",
- new ProductFieldValue(4.5, 0.0, 4.5),
- new ProductFieldValue(15.0, 0.0, 15.0),
- new ProductFieldValue(30.0, 0.0, 30.0));
-
- builder.addExclusionRule(new AndRule(
- new FieldPredicate("brand", "Chef Corgi"),
- new FieldPredicate("organic", "true")));
-
- builder.addExclusionRule(new AndRule(
- new FieldPredicate("brand", "Chef Corgi"),
- new FieldPredicate("meat", "Vegetarian")));
-
- builder.addExclusionRule(new AndRule(
- new FieldPredicate("brand", "Dog Days"),
- new FieldPredicate("organic", "false")));
-
- builder.addExclusionRule(new AndRule(
- new FieldPredicate("grain", "Corn"),
- new OrRule(
- new FieldPredicate("organic", "true"),
- new FieldPredicate("meat", "Venison"),
- new FieldPredicate("meat", "Rabbit"),
- new FieldPredicate("meat", "Lamb"),
- new FieldPredicate("meat", "Salmon"))));
-
- builder.addExclusionRule(new AndRule(
- new FieldPredicate("organic", "true"),
- new FieldPredicate("meat", "Pork")));
-
- builder.addExclusionRule(new AndRule(
- new NotRule(new FieldPredicate("grain", "Corn")),
- new FieldPredicate("meat", "Pork")));
-
- builder.addExclusionRule(new AndRule(
- new OrRule(
- new FieldPredicate("brand", "Chef Corgi"),
- new FieldPredicate("brand", "Happy Pup")),
- new OrRule(
- new FieldPredicate("meat", "Rabbit"),
- new FieldPredicate("meat", "Venison"))
- ));
-
- return builder.build();
- }
-
- private ProductCategory createCatFood()
- {
- ProductCategoryBuilder builder = new ProductCategoryBuilder();
-
- builder.addApplicableSpecies(PetSpecies.CAT);
- builder.setCategory("dry cat food");
- builder.setTriggerTransaction(true);
- builder.setDailyUsageRate(2.0);
- builder.setAmountUsedPetPetAverage(0.1);
- builder.setAmountUsedPetPetVariance(0.05);
- builder.setTriggerTransactionRate(2.0);
- builder.setTriggerPurchaseRate(7.0);
- builder.setBasePrice(2.14);
-
- builder.addPropertyValues("brand",
- new ProductFieldValue("Wellfed", 0.67, 1.0),
- new ProductFieldValue("Feisty Feline", 0.72, 1.0),
- new ProductFieldValue("Pretty Cat", 0.0, 1.0));
-
- builder.addPropertyValues("meat",
- new ProductFieldValue("Tuna", 0.0, 1.0),
- new ProductFieldValue("Chicken", 0.0, 1.0),
- new ProductFieldValue("Turkey", 0.0, 1.0),
- new ProductFieldValue("Salmon", 0.1, 1.0));
-
- builder.addPropertyValues("lifestyle",
- new ProductFieldValue("Indoor", 0.0, 1.0),
- new ProductFieldValue("Outdoor", 0.0, 1.0),
- new ProductFieldValue("Weight Management", 0.1, 1.0));
-
- builder.addPropertyValues("lifestage",
- new ProductFieldValue("Senior", 0.0, 1.0),
- new ProductFieldValue("Kitten", 0.0, 1.0),
- new ProductFieldValue("Adult", 0.0, 1.0));
-
- builder.addPropertyValues("organic",
- new ProductFieldValue("true", 0.0, 1.1),
- new ProductFieldValue("false", 0.0, 1.0));
-
- builder.addPropertyValues("quantity",
- new ProductFieldValue(7.0, 0.0, 7.0),
- new ProductFieldValue(15.0, 0.0, 15.0));
-
- builder.addPropertyValues("hairball management",
- new ProductFieldValue("true", 0.1, 1.0),
- new ProductFieldValue("false", 0.0, 1.0));
-
- builder.addExclusionRule(new AndRule(
- new FieldPredicate("brand", "Pretty Cat"),
- new FieldPredicate("organic", "true")));
-
- builder.addExclusionRule(new AndRule(
- new FieldPredicate("brand", "Feisty Feline"),
- new FieldPredicate("organic", "false")));
-
- return builder.build();
- }
-
- private ProductCategory createKittyLitter()
- {
- ProductCategoryBuilder builder = new ProductCategoryBuilder();
-
- builder.addApplicableSpecies(PetSpecies.CAT);
- builder.setCategory("kitty litter");
- builder.setTriggerTransaction(true);
- builder.setDailyUsageRate(1.0);
- builder.setAmountUsedPetPetAverage(0.1);
- builder.setAmountUsedPetPetVariance(0.05);
- builder.setTriggerTransactionRate(2.0);
- builder.setTriggerPurchaseRate(7.0);
- builder.setBasePrice(1.43);
-
- builder.addPropertyValues("brand",
- new ProductFieldValue("Pretty Cat", 0.0, 1.0),
- new ProductFieldValue("Feisty Feline", 0.1, 1.0));
-
- builder.addPropertyValues("material",
- new ProductFieldValue("clay", 0.0, 1.0),
- new ProductFieldValue("pellets", 0.1, 1.0));
-
- builder.addPropertyValues("clumping",
- new ProductFieldValue("true", 0.0, 1.0),
- new ProductFieldValue("false", 0.0, 1.0));
-
- builder.addPropertyValues("odor control",
- new ProductFieldValue("true", 0.1, 1.0),
- new ProductFieldValue("false", 0.0, 1.0));
-
- builder.addPropertyValues("quantity",
- new ProductFieldValue(7.0, 0.0, 7.0),
- new ProductFieldValue(14.0, 0.0, 14.0),
- new ProductFieldValue(28.0, 0.0, 28.0));
-
- return builder.build();
- }
-
- private ProductCategory createPoopBags()
- {
- ProductCategoryBuilder builder = new ProductCategoryBuilder();
-
- builder.addApplicableSpecies(PetSpecies.DOG);
- builder.setCategory("poop bags");
- builder.setTriggerTransaction(true);
- builder.setDailyUsageRate(2.0);
- builder.setAmountUsedPetPetAverage(1.0);
- builder.setAmountUsedPetPetVariance(0.5);
- builder.setTriggerTransactionRate(2.0);
- builder.setTriggerPurchaseRate(7.0);
- builder.setBasePrice(0.17);
-
- builder.addPropertyValues("brand",
- new ProductFieldValue("Chef Corgi", 0.0, 1.0),
- new ProductFieldValue("Happy Pup", 0.67, 1.0),
- new ProductFieldValue("Dog Days", 1.0, 1.0));
-
- builder.addPropertyValues("color",
- new ProductFieldValue("blue", 0.0, 1.0),
- new ProductFieldValue("multicolor (pastels)", 0.0, 1.0),
- new ProductFieldValue("multicolor (solids)", 0.0, 1.0),
- new ProductFieldValue("designs", 0.0, 1.0));
-
- builder.addPropertyValues("recycled material",
- new ProductFieldValue("false", 0.0, 60.0),
- new ProductFieldValue("true", 0.1, 120.0));
-
- builder.addPropertyValues("quantity",
- new ProductFieldValue(60.0, 0.0, 60.0),
- new ProductFieldValue(120.0, 0.0, 120.0));
-
- builder.addExclusionRule(new AndRule(
- new FieldPredicate("brand", "Chef Corgi"),
- new FieldPredicate("recycled material", "true")));
-
- builder.addExclusionRule(new AndRule(
- new FieldPredicate("brand", "Dog Days"),
- new FieldPredicate("recycled material", "false")));
-
- return builder.build();
- }
-
- public List<ProductCategory> generateProductCategory()
- {
- List<ProductCategory> productCategories = Lists.newArrayList();
-
- productCategories.add(this.createDogFood());
- productCategories.add(this.createCatFood());
- productCategories.add(this.createKittyLitter());
- productCategories.add(this.createPoopBags());
-
- return productCategories;
- }
-}
http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/collections/SmallProductCollection.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/collections/SmallProductCollection.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/collections/SmallProductCollection.java
deleted file mode 100644
index 8ca71ef..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/collections/SmallProductCollection.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.bigtop.bigpetstore.datagenerator.generators.products.collections;
-
-import java.util.List;
-
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.PetSpecies;
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ProductCategory;
-import org.apache.bigtop.bigpetstore.datagenerator.generators.products.ProductCategoryBuilder;
-import org.apache.bigtop.bigpetstore.datagenerator.generators.products.ProductFieldValue;
-
-import com.google.common.collect.Lists;
-
-public class SmallProductCollection
-{
- private ProductCategory createDogFood()
- {
- ProductCategoryBuilder builder = new ProductCategoryBuilder();
-
- builder.addApplicableSpecies(PetSpecies.DOG);
- builder.setCategory("dry dog food");
- builder.setTriggerTransaction(true);
- builder.setDailyUsageRate(2.0);
- builder.setAmountUsedPetPetAverage(0.25);
- builder.setAmountUsedPetPetVariance(0.1);
- builder.setTriggerTransactionRate(2.0);
- builder.setTriggerPurchaseRate(7.0);
- builder.setBasePrice(2.0);
-
- builder.addPropertyValues("brand",
- new ProductFieldValue("Wellfed", 0.0, 1.0),
- new ProductFieldValue("Happy Pup", 0.67, 1.0),
- new ProductFieldValue("Dog Days", 1.0, 1.0));
-
- builder.addPropertyValues("flavor",
- new ProductFieldValue("Chicken", 0.0, 1.0),
- new ProductFieldValue("Pork", 0.0, 1.0),
- new ProductFieldValue("Lamb & Rice", 0.0, 1.0),
- new ProductFieldValue("Fish & Potato", 0.0, 1.0));
-
- builder.addPropertyValues("quantity",
- new ProductFieldValue(4.5, 0.0, 4.5),
- new ProductFieldValue(15.0, 0.0, 15.0),
- new ProductFieldValue(30.0, 0.0, 30.0));
-
- return builder.build();
- }
-
- private ProductCategory createCatFood()
- {
- ProductCategoryBuilder builder = new ProductCategoryBuilder();
-
- builder.addApplicableSpecies(PetSpecies.CAT);
- builder.setCategory("dry cat food");
- builder.setTriggerTransaction(true);
- builder.setDailyUsageRate(2.0);
- builder.setAmountUsedPetPetAverage(0.1);
- builder.setAmountUsedPetPetVariance(0.05);
- builder.setTriggerTransactionRate(2.0);
- builder.setTriggerPurchaseRate(7.0);
- builder.setBasePrice(2.14);
-
- builder.addPropertyValues("brand",
- new ProductFieldValue("Wellfed", 0.0, 1.0),
- new ProductFieldValue("Pretty Cat", 0.72, 1.0),
- new ProductFieldValue("Feisty Feline", 0.0, 1.0));
-
- builder.addPropertyValues("flavor",
- new ProductFieldValue("Tuna", 0.0, 1.0),
- new ProductFieldValue("Chicken & Rice", 0.0, 1.0));
-
- builder.addPropertyValues("quantity",
- new ProductFieldValue(7.0, 0.0, 7.0),
- new ProductFieldValue(15.0, 0.0, 15.0));
-
- builder.addPropertyValues("hairball management",
- new ProductFieldValue("true", 0.0, 1.0),
- new ProductFieldValue("false", 0.0, 1.0));
-
- return builder.build();
- }
-
- private ProductCategory createKittyLitter()
- {
- ProductCategoryBuilder builder = new ProductCategoryBuilder();
-
- builder.addApplicableSpecies(PetSpecies.CAT);
- builder.setCategory("kitty litter");
- builder.setTriggerTransaction(true);
- builder.setDailyUsageRate(1.0);
- builder.setAmountUsedPetPetAverage(0.1);
- builder.setAmountUsedPetPetVariance(0.05);
- builder.setTriggerTransactionRate(2.0);
- builder.setTriggerPurchaseRate(7.0);
- builder.setBasePrice(1.43);
-
- builder.addPropertyValues("brand",
- new ProductFieldValue("Pretty Cat", 0.0, 1.0),
- new ProductFieldValue("Feisty Feline", 0.07, 1.0));
-
- builder.addPropertyValues("quantity",
- new ProductFieldValue(7.0, 0.0, 7.0),
- new ProductFieldValue(14.0, 0.0, 14.0),
- new ProductFieldValue(28.0, 0.0, 28.0));
-
- return builder.build();
- }
-
- private ProductCategory createPoopBags()
- {
- ProductCategoryBuilder builder = new ProductCategoryBuilder();
-
- builder.addApplicableSpecies(PetSpecies.DOG);
- builder.setCategory("poop bags");
- builder.setTriggerTransaction(true);
- builder.setDailyUsageRate(2.0);
- builder.setAmountUsedPetPetAverage(1.0);
- builder.setAmountUsedPetPetVariance(0.5);
- builder.setTriggerTransactionRate(2.0);
- builder.setTriggerPurchaseRate(7.0);
- builder.setBasePrice(0.17);
-
- builder.addPropertyValues("brand",
- new ProductFieldValue("Happy Pup", 0.0, 1.0),
- new ProductFieldValue("Dog Days", 0.04, 1.0));
-
- builder.addPropertyValues("color",
- new ProductFieldValue("blue", 0.0, 1.0),
- new ProductFieldValue("multicolor", 0.0, 1.0));
-
- builder.addPropertyValues("quantity",
- new ProductFieldValue(60.0, 0.0, 60.0),
- new ProductFieldValue(120.0, 0.0, 120.0));
-
- return builder.build();
- }
-
- public List<ProductCategory> generateProductCategory()
- {
- List<ProductCategory> productCategories = Lists.newArrayList();
-
- productCategories.add(this.createDogFood());
- productCategories.add(this.createCatFood());
- productCategories.add(this.createKittyLitter());
- productCategories.add(this.createPoopBags());
-
- return productCategories;
- }
-}
http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/AlwaysTrueRule.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/AlwaysTrueRule.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/AlwaysTrueRule.java
deleted file mode 100644
index d973346..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/AlwaysTrueRule.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.bigtop.bigpetstore.datagenerator.generators.products.rules;
-
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product;
-
-public class AlwaysTrueRule implements Rule
-{
-
- @Override
- public boolean ruleMatches(Product product) throws IllegalArgumentException
- {
- return true;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/AndRule.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/AndRule.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/AndRule.java
deleted file mode 100644
index 4be89be..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/AndRule.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.bigtop.bigpetstore.datagenerator.generators.products.rules;
-
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product;
-
-public class AndRule implements Rule
-{
- List<Rule> rules;
-
- public AndRule(Rule rule1, Rule rule2, Rule ... rules)
- {
- this.rules = new LinkedList<Rule>(Arrays.asList(rules));
- this.rules.add(rule1);
- this.rules.add(rule2);
- }
-
- @Override
- public boolean ruleMatches(Product product) throws IllegalArgumentException
- {
- boolean matches = true;
- for(Rule rule : rules)
- {
- if(! rule.ruleMatches(product))
- {
- matches = false;
- }
- }
-
- return matches;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/FieldPredicate.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/FieldPredicate.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/FieldPredicate.java
deleted file mode 100644
index 37e7c12..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/FieldPredicate.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.bigtop.bigpetstore.datagenerator.generators.products.rules;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product;
-
-public class FieldPredicate implements Rule
-{
- String fieldName;
- Collection<String> allowedValues;
-
- public FieldPredicate(String fieldName, String ... allowedValues)
- {
- this.fieldName = fieldName;
- this.allowedValues = Arrays.asList(allowedValues);
- }
-
- @Override
- public boolean ruleMatches(Product product)
- {
- if(! product.getFieldNames().contains(fieldName))
- {
- throw new IllegalArgumentException("Product (" + product.toString() +
- ") does not contain field name (" + fieldName + ")");
- }
-
- Object seenValue = product.getFieldValue(fieldName);
-
- return allowedValues.contains(seenValue);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/NotRule.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/NotRule.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/NotRule.java
deleted file mode 100644
index ffac751..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/NotRule.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.bigtop.bigpetstore.datagenerator.generators.products.rules;
-
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product;
-
-public class NotRule implements Rule
-{
- Rule rule;
-
- public NotRule(Rule rule)
- {
- this.rule = rule;
- }
-
-
- @Override
- public boolean ruleMatches(Product product) throws IllegalArgumentException
- {
- return ! rule.ruleMatches(product);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/OrRule.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/OrRule.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/OrRule.java
deleted file mode 100644
index c3ed549..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/OrRule.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.bigtop.bigpetstore.datagenerator.generators.products.rules;
-
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product;
-
-public class OrRule implements Rule
-{
- Rule[] rules;
-
- public OrRule(Rule ... rules)
- {
- this.rules = rules;
- }
-
- @Override
- public boolean ruleMatches(Product product) throws IllegalArgumentException
- {
- for(Rule rule : rules)
- {
- if(rule.ruleMatches(product))
- {
- return true;
- }
- }
-
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/Rule.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/Rule.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/Rule.java
deleted file mode 100644
index 4aa7945..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/products/rules/Rule.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.bigtop.bigpetstore.datagenerator.generators.products.rules;
-
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product;
-
-public interface Rule
-{
- public boolean ruleMatches(Product product) throws IllegalArgumentException;
-}
http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MarkovModelProductCategorySampler.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MarkovModelProductCategorySampler.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MarkovModelProductCategorySampler.java
deleted file mode 100644
index c842ff1..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MarkovModelProductCategorySampler.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.bigtop.bigpetstore.datagenerator.generators.purchase;
-
-import java.util.Map;
-
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product;
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ProductCategory;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.markovmodels.MarkovModel;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.markovmodels.MarkovModelBuilder;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
-
-import com.google.common.collect.Maps;
-
-public class MarkovModelProductCategorySampler implements Sampler<MarkovModel<Product>>
-{
- final ProductCategory productCategory;
- final Sampler<Double> fieldSimilarityWeightSampler;
- final Sampler<Double> loopbackWeightSampler;
-
- final Map<String, Double> fieldWeights;
- Map<String, Double> fieldSimilarityWeights;
- double loopbackWeight;
-
- public MarkovModelProductCategorySampler(ProductCategory productCategory,
- Map<String, Double> fieldWeights, Sampler<Double> fieldSimilarityWeightSampler,
- Sampler<Double> loopbackWeightSampler)
- {
- this.productCategory = productCategory;
-
- this.fieldSimilarityWeightSampler = fieldSimilarityWeightSampler;
- this.fieldWeights = fieldWeights;
- this.loopbackWeightSampler = loopbackWeightSampler;
- }
-
- protected void generateWeights() throws Exception
- {
- fieldSimilarityWeights = Maps.newHashMap();
-
- for(String fieldName : productCategory.getFieldNames())
- {
- fieldSimilarityWeights.put(fieldName,fieldSimilarityWeightSampler.sample());
- }
-
- loopbackWeight = loopbackWeightSampler.sample();
- }
-
- protected double productPairWeight(Product product1, Product product2)
- {
- double weightSum = 0.0;
- for(String fieldName : productCategory.getFieldNames())
- {
- double fieldWeight = this.fieldWeights.get(fieldName);
-
- if(product1.getFieldValue(fieldName).equals(product2.getFieldValue(fieldName)))
- {
- fieldWeight *= this.fieldSimilarityWeights.get(fieldName);
- }
- else
- {
- fieldWeight *= (1.0 - this.fieldSimilarityWeights.get(fieldName));
- }
-
- weightSum += fieldWeight;
- }
- return weightSum;
- }
-
- public MarkovModel<Product> sample() throws Exception
- {
- generateWeights();
-
- MarkovModelBuilder<Product> builder = new MarkovModelBuilder<Product>();
-
- for(Product product1 : productCategory.getProducts())
- {
- builder.addStartState(product1, 1.0);
-
- double weightSum = 0.0;
- for(Product product2 : productCategory.getProducts())
- {
- if(!product1.equals(product2))
- {
- weightSum += productPairWeight(product1, product2);
- }
- }
-
- for(Product product2 : productCategory.getProducts())
- {
- double weight = 0.0;
- if(!product1.equals(product2))
- {
- weight = (1.0 - loopbackWeight) * productPairWeight(product1, product2) / weightSum;
- }
- else
- { weight = loopbackWeight;
-
- }
-
- builder.addTransition(product1, product2, weight);
- }
- }
-
- return builder.build();
- }
-}
http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MarkovPurchasingModel.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MarkovPurchasingModel.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MarkovPurchasingModel.java
deleted file mode 100644
index 8b22660..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MarkovPurchasingModel.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.bigtop.bigpetstore.datagenerator.generators.purchase;
-
-import java.util.Map;
-
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.markovmodels.MarkovModel;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.markovmodels.MarkovProcess;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Maps;
-
-public class MarkovPurchasingModel implements PurchasingModel<MarkovModel<Product>>
-{
-
- private static final long serialVersionUID = 3098355461347511619L;
- ImmutableMap<String, MarkovModel<Product>> productCategoryProfiles;
-
- public MarkovPurchasingModel(Map<String, MarkovModel<Product>> productCategoryProfiles)
- {
- this.productCategoryProfiles = ImmutableMap.copyOf(productCategoryProfiles);
- }
-
- @Override
- public ImmutableSet<String> getProductCategories()
- {
- return productCategoryProfiles.keySet();
- }
-
- @Override
- public MarkovModel<Product> getProfile(String productCategory)
- {
- return productCategoryProfiles.get(productCategory);
- }
-
- @Override
- public PurchasingProcesses buildProcesses(SeedFactory seedFactory)
- {
- Map<String, Sampler<Product>> processes = Maps.newHashMap();
- for(String category : getProductCategories())
- {
- MarkovModel<Product> model = getProfile(category);
- processes.put(category, new MarkovProcess<Product>(model, seedFactory));
- }
-
- return new PurchasingProcesses(processes);
- }
-}
http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MarkovPurchasingModelSampler.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MarkovPurchasingModelSampler.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MarkovPurchasingModelSampler.java
deleted file mode 100644
index 6291213..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MarkovPurchasingModelSampler.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.bigtop.bigpetstore.datagenerator.generators.purchase;
-
-import java.util.Map;
-
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product;
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ProductCategory;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.markovmodels.MarkovModel;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
-
-import com.google.common.collect.Maps;
-
-public class MarkovPurchasingModelSampler implements Sampler<MarkovPurchasingModel>
-{
- final Map<ProductCategory, Sampler<MarkovModel<Product>>> categorySamplers;
-
- public MarkovPurchasingModelSampler(Map<ProductCategory, Sampler<MarkovModel<Product>>> categorySamplers)
- {
- this.categorySamplers = categorySamplers;
- }
-
- public MarkovPurchasingModel sample() throws Exception
- {
- Map<String, MarkovModel<Product>> markovModels = Maps.newHashMap();
- for(ProductCategory productCategory : categorySamplers.keySet())
- {
- Sampler<MarkovModel<Product>> sampler = categorySamplers.get(productCategory);
- markovModels.put(productCategory.getCategoryLabel(), sampler.sample());
- }
-
- return new MarkovPurchasingModel(markovModels);
- }
-}
http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MultinomialPurchasingModel.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MultinomialPurchasingModel.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MultinomialPurchasingModel.java
deleted file mode 100644
index 336a898..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MultinomialPurchasingModel.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.bigtop.bigpetstore.datagenerator.generators.purchase;
-
-import java.util.Map;
-
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.pdfs.MultinomialPDF;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.RouletteWheelSampler;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Maps;
-
-public class MultinomialPurchasingModel implements PurchasingModel<MultinomialPDF<Product>>
-{
-
- private static final long serialVersionUID = 5863830733003282570L;
-
- private final ImmutableMap<String, MultinomialPDF<Product>> productPDFs;
-
- public MultinomialPurchasingModel(Map<String, MultinomialPDF<Product>> productPDFs)
- {
- this.productPDFs = ImmutableMap.copyOf(productPDFs);
- }
-
- @Override
- public ImmutableSet<String> getProductCategories()
- {
- return productPDFs.keySet();
- }
-
- @Override
- public MultinomialPDF<Product> getProfile(String category)
- {
- return productPDFs.get(category);
- }
-
- @Override
- public PurchasingProcesses buildProcesses(SeedFactory seedFactory)
- {
- Map<String, Sampler<Product>> processes = Maps.newHashMap();
- for(String category : getProductCategories())
- {
- MultinomialPDF<Product> pdf = productPDFs.get(category);
- processes.put(category, RouletteWheelSampler.create(pdf, seedFactory));
- }
-
- return new PurchasingProcesses(processes);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MultinomialPurchasingModelSampler.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MultinomialPurchasingModelSampler.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MultinomialPurchasingModelSampler.java
deleted file mode 100644
index 7fcfbe5..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MultinomialPurchasingModelSampler.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.bigtop.bigpetstore.datagenerator.generators.purchase;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
-import org.apache.bigtop.bigpetstore.datagenerator.Constants;
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product;
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ProductCategory;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.pdfs.MultinomialPDF;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.UniformIntSampler;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.UniformSampler;
-import org.apache.commons.lang3.tuple.Pair;
-
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Multimap;
-
-public class MultinomialPurchasingModelSampler implements Sampler<MultinomialPurchasingModel>
-{
- private final SeedFactory seedFactory;
- private final Collection<ProductCategory> productCategories;
-
- public MultinomialPurchasingModelSampler(Collection<ProductCategory> productCategories, SeedFactory seedFactory)
- {
- this.seedFactory = seedFactory;
- this.productCategories = productCategories;
- }
-
- protected <T> List<T> shuffle(Collection<T> input) throws Exception
- {
- Vector<T> shuffled = new Vector<>(input);
- for(int i = 0; i < input.size() - 1; i++)
- {
- int swapIdx = new UniformIntSampler(i, input.size() - 1, seedFactory).sample();
- T tmp = shuffled.get(i);
- shuffled.set(i, shuffled.get(swapIdx));
- shuffled.set(swapIdx, tmp);
- }
-
- return shuffled;
- }
-
- protected Map<Pair<String, Object>, Double> generateFieldValueWeights(ProductCategory productCategory) throws Exception
- {
- // Get all values for each field by iterating over all products
- Multimap<String, Object> allFieldValues = HashMultimap.create();
- for(String fieldName : productCategory.getFieldNames())
- {
- if(!Constants.PRODUCT_MODEL_EXCLUDED_FIELDS.contains(fieldName))
- {
- for(Product p : productCategory.getProducts())
- {
- Object fieldValue = p.getFieldValue(fieldName);
- allFieldValues.put(fieldName, fieldValue);
- }
- }
- }
-
- Sampler<Double> sampler = new UniformSampler(seedFactory);
-
- // shuffle field values
- Map<Pair<String, Object>, Double> fieldValueWeights = Maps.newHashMap();
- for(Map.Entry<String, Collection<Object>> entry : allFieldValues.asMap().entrySet())
- {
- String fieldName = entry.getKey();
- List<Object> shuffled = shuffle(entry.getValue());
-
- for(int i = 0; i < shuffled.size(); i++)
- {
- double weight = Constants.PRODUCT_MULTINOMIAL_POSITIVE_WEIGHT;
- if ((i + 1) > Constants.PRODUCT_MULTINOMIAL_POSITIVE_COUNT_MIN)
- {
- double r = sampler.sample();
- if (r >= Constants.PRODUCT_MULTINOMIAL_POSITIVE_FREQUENCY)
- {
- weight = Constants.PRODUCT_MULTINOMIAL_NEGATIVE_WEIGHT;
- }
- }
-
- Object fieldValue = shuffled.get(i);
- fieldValueWeights.put(Pair.of(fieldName, fieldValue), weight);
- }
- }
-
-
- return ImmutableMap.copyOf(fieldValueWeights);
- }
-
- protected Map<Product, Double> generateProductWeights(Map<Pair<String, Object>, Double> fieldValueWeights,
- ProductCategory productCategory) throws Exception
- {
- Map<Product, Double> productWeights = Maps.newHashMap();
- for(Product p : productCategory.getProducts())
- {
- double weight = 1.0;
- for(String fieldName : productCategory.getFieldNames())
- {
- if(!Constants.PRODUCT_MODEL_EXCLUDED_FIELDS.contains(fieldName))
- {
- Object fieldValue = p.getFieldValue(fieldName);
- Pair<String, Object> key = Pair.of(fieldName, fieldValue);
- weight *= fieldValueWeights.get(key);
- }
- }
- productWeights.put(p, weight);
- }
-
- return productWeights;
- }
-
- public MultinomialPurchasingModel sample() throws Exception
- {
- Map<String, MultinomialPDF<Product>> pdfs = Maps.newHashMap();
- for(ProductCategory productCategory : productCategories)
- {
- Map<Pair<String, Object>, Double> fieldWeights = this.generateFieldValueWeights(productCategory);
- Map<Product, Double> productWeights = this.generateProductWeights(fieldWeights, productCategory);
- pdfs.put(productCategory.getCategoryLabel(), new MultinomialPDF<Product>(productWeights));
- }
-
- return new MultinomialPurchasingModel(pdfs);
- }
-}
http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/PurchasingModel.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/PurchasingModel.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/PurchasingModel.java
deleted file mode 100644
index d460c3b..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/PurchasingModel.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.bigtop.bigpetstore.datagenerator.generators.purchase;
-
-import java.io.Serializable;
-
-import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
-
-import com.google.common.collect.ImmutableSet;
-
-public interface PurchasingModel<T> extends Serializable
-{
- public ImmutableSet<String> getProductCategories();
-
- public T getProfile(String category);
-
- public PurchasingProcesses buildProcesses(SeedFactory seedFactory);
-}
http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/PurchasingModelSamplerBuilder.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/PurchasingModelSamplerBuilder.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/PurchasingModelSamplerBuilder.java
deleted file mode 100644
index 43808c7..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/PurchasingModelSamplerBuilder.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.bigtop.bigpetstore.datagenerator.generators.purchase;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.bigtop.bigpetstore.datagenerator.Constants;
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product;
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ProductCategory;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.markovmodels.MarkovModel;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.BoundedMultiModalGaussianSampler;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Maps;
-
-public class PurchasingModelSamplerBuilder
-{
- final ImmutableList<ProductCategory> productCategories;
- final SeedFactory seedFactory;
-
- public PurchasingModelSamplerBuilder(Collection<ProductCategory> productCategories, SeedFactory seedFactory)
- {
- this.productCategories = ImmutableList.copyOf(productCategories);
- this.seedFactory = seedFactory;
- }
-
- protected Map<String, Double> generateFieldWeights(Sampler<Double> fieldWeightSampler) throws Exception
- {
- Set<String> fieldNames = new HashSet<String>();
- for(ProductCategory pc : productCategories)
- {
- for(String fieldName : pc.getFieldNames())
- {
- fieldNames.add(fieldName);
- }
- }
-
- Map<String, Double> fieldWeights = Maps.newHashMap();
- for(String fieldName : fieldNames)
- {
- double weight = fieldWeightSampler.sample();
- fieldWeights.put(fieldName, weight);
- }
-
- return fieldWeights;
- }
-
- public Sampler<MarkovPurchasingModel> buildMarkovPurchasingModel() throws Exception
- {
-
- Sampler<Double> fieldWeightSampler = new BoundedMultiModalGaussianSampler(Constants.PRODUCT_MSM_FIELD_WEIGHT_GAUSSIANS,
- Constants.PRODUCT_MSM_FIELD_WEIGHT_LOWERBOUND,
- Constants.PRODUCT_MSM_FIELD_WEIGHT_UPPERBOUND,
- seedFactory);
-
- Sampler<Double> fieldSimilarityWeightSampler = new BoundedMultiModalGaussianSampler(Constants.PRODUCT_MSM_FIELD_SIMILARITY_WEIGHT_GAUSSIANS,
- Constants.PRODUCT_MSM_FIELD_SIMILARITY_WEIGHT_LOWERBOUND,
- Constants.PRODUCT_MSM_FIELD_SIMILARITY_WEIGHT_UPPERBOUND,
- seedFactory);
-
- Sampler<Double> loopbackWeightSampler = new BoundedMultiModalGaussianSampler(Constants.PRODUCT_MSM_LOOPBACK_WEIGHT_GAUSSIANS,
- Constants.PRODUCT_MSM_LOOPBACK_WEIGHT_LOWERBOUND,
- Constants.PRODUCT_MSM_LOOPBACK_WEIGHT_UPPERBOUND,
- seedFactory);
-
- Map<String, Double> fieldWeights = generateFieldWeights(fieldWeightSampler);
-
- Map<ProductCategory, Sampler<MarkovModel<Product>>> categorySamplers = Maps.newHashMap();
- for(ProductCategory productCategory : productCategories)
- {
- MarkovModelProductCategorySampler sampler = new MarkovModelProductCategorySampler(productCategory,
- fieldWeights, fieldSimilarityWeightSampler, loopbackWeightSampler);
- categorySamplers.put(productCategory, sampler);
- }
-
- return new MarkovPurchasingModelSampler(categorySamplers);
- }
-
- public Sampler<? extends PurchasingModel> build() throws Exception
- {
- if(Constants.PURCHASING_MODEL_TYPE.equals(Constants.PurchasingModelType.MARKOV))
- {
- return buildMarkovPurchasingModel();
- }
- else
- {
- return new MultinomialPurchasingModelSampler(productCategories, seedFactory);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/PurchasingProcesses.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/PurchasingProcesses.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/PurchasingProcesses.java
deleted file mode 100644
index d9a9849..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/PurchasingProcesses.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.bigtop.bigpetstore.datagenerator.generators.purchase;
-
-import java.util.Map;
-
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.ConditionalSampler;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
-
-import com.google.common.collect.ImmutableMap;
-
-public class PurchasingProcesses implements ConditionalSampler<Product, String>
-{
- ImmutableMap<String, Sampler<Product>> processes;
-
- public PurchasingProcesses(Map<String, Sampler<Product>> processes)
- {
- this.processes = ImmutableMap.copyOf(processes);
- }
-
- public Product sample(String productCategory) throws Exception
- {
- return this.processes.get(productCategory).sample();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/StoreLocationIncomePDF.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/StoreLocationIncomePDF.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/StoreLocationIncomePDF.java
deleted file mode 100644
index 345956f..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/StoreLocationIncomePDF.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.bigtop.bigpetstore.datagenerator.generators.store;
-
-import java.util.List;
-
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ZipcodeRecord;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.pdfs.ProbabilityDensityFunction;
-
-public class StoreLocationIncomePDF implements ProbabilityDensityFunction<ZipcodeRecord>
-{
- double incomeNormalizationFactor;
- double minIncome;
- double k;
-
- public StoreLocationIncomePDF(List<ZipcodeRecord> zipcodeTable, double incomeScalingFactor)
- {
-
- double maxIncome = 0.0;
- minIncome = Double.MAX_VALUE;
-
- for(ZipcodeRecord record : zipcodeTable)
- {
- maxIncome = Math.max(maxIncome, record.getMedianHouseholdIncome());
- minIncome = Math.min(minIncome, record.getMedianHouseholdIncome());
- }
-
- k = Math.log(incomeScalingFactor) / (maxIncome - minIncome);
-
- incomeNormalizationFactor = 0.0d;
- for(ZipcodeRecord record : zipcodeTable)
- {
- double weight = incomeWeight(record);
- incomeNormalizationFactor += weight;
- }
- }
-
- private double incomeWeight(ZipcodeRecord record)
- {
- return Math.exp(k * (record.getMedianHouseholdIncome() - minIncome));
- }
-
-
- @Override
- public double probability(ZipcodeRecord datum)
- {
- double weight = incomeWeight(datum);
-
- return weight / this.incomeNormalizationFactor;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/StoreLocationPopulationPDF.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/StoreLocationPopulationPDF.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/StoreLocationPopulationPDF.java
deleted file mode 100644
index 8c6f43c..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/StoreLocationPopulationPDF.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.bigtop.bigpetstore.datagenerator.generators.store;
-
-import java.util.List;
-
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ZipcodeRecord;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.pdfs.ProbabilityDensityFunction;
-
-public class StoreLocationPopulationPDF implements ProbabilityDensityFunction<ZipcodeRecord>
-{
- double populationSum = 0.0;
-
- public StoreLocationPopulationPDF(List<ZipcodeRecord> zipcodeTable)
- {
- long populationSum = 0L;
- for(ZipcodeRecord record : zipcodeTable)
- {
- populationSum += record.getPopulation();
- }
-
- this.populationSum = ((double) populationSum);
- }
-
- public double probability(ZipcodeRecord record)
- {
- return ((double) record.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/bigpetstore/datagenerator/generators/store/StoreSampler.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/StoreSampler.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/StoreSampler.java
deleted file mode 100644
index d118611..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/StoreSampler.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.bigtop.bigpetstore.datagenerator.generators.store;
-
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Store;
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ZipcodeRecord;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
-
-public class StoreSampler implements Sampler<Store>
-{
-
- private final Sampler<ZipcodeRecord> locationSampler;
- private final Sampler<Integer> idSampler;
-
- public StoreSampler(Sampler<Integer> idSampler, Sampler<ZipcodeRecord> locationSampler)
- {
- this.locationSampler = locationSampler;
- this.idSampler = idSampler;
- }
-
- public Store sample() throws Exception
- {
- Integer id = idSampler.sample();
- String name = "Store_" + id;
- ZipcodeRecord location = locationSampler.sample();
-
- Store store = new Store(id, name, location);
-
- 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/bigpetstore/datagenerator/generators/store/StoreSamplerBuilder.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/StoreSamplerBuilder.java b/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/StoreSamplerBuilder.java
deleted file mode 100644
index 68e4e57..0000000
--- a/bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/StoreSamplerBuilder.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.bigtop.bigpetstore.datagenerator.generators.store;
-
-import java.util.List;
-
-import org.apache.bigtop.bigpetstore.datagenerator.Constants;
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Store;
-import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ZipcodeRecord;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.pdfs.JointPDF;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.pdfs.ProbabilityDensityFunction;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.RouletteWheelSampler;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
-import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.SequenceSampler;
-
-public class StoreSamplerBuilder
-{
- private final List<ZipcodeRecord> zipcodeTable;
- private final SeedFactory seedFactory;
-
- public StoreSamplerBuilder(List<ZipcodeRecord> zipcodeTable, SeedFactory seedFactory)
- {
- this.zipcodeTable = zipcodeTable;
- this.seedFactory = seedFactory;
- }
-
- public Sampler<Store> build()
- {
- Sampler<Integer> idSampler = new SequenceSampler();
-
- ProbabilityDensityFunction<ZipcodeRecord> locationPopulationPDF =
- new StoreLocationPopulationPDF(zipcodeTable);
- ProbabilityDensityFunction<ZipcodeRecord> locationIncomePDF =
- new StoreLocationIncomePDF(zipcodeTable, Constants.INCOME_SCALING_FACTOR);
- ProbabilityDensityFunction<ZipcodeRecord> locationJointPDF =
- new JointPDF<ZipcodeRecord>(zipcodeTable, locationPopulationPDF, locationIncomePDF);
-
- Sampler<ZipcodeRecord> locationSampler = RouletteWheelSampler.create(zipcodeTable, locationJointPDF, seedFactory);
-
- return new StoreSampler(idSampler, locationSampler);
- }
-
-}