Repository: bigtop Updated Branches: refs/heads/master d6b8d836a -> a9e2d4f9e
BIGTOP-1976. Replace Pair type with Apache Commons Lang Pair type Project: http://git-wip-us.apache.org/repos/asf/bigtop/repo Commit: http://git-wip-us.apache.org/repos/asf/bigtop/commit/a9e2d4f9 Tree: http://git-wip-us.apache.org/repos/asf/bigtop/tree/a9e2d4f9 Diff: http://git-wip-us.apache.org/repos/asf/bigtop/diff/a9e2d4f9 Branch: refs/heads/master Commit: a9e2d4f9e2d12d0f81a9def633e9789321c359e6 Parents: d6b8d83 Author: RJ Nowling <[email protected]> Authored: Sat Aug 22 11:35:33 2015 -0500 Committer: RJ Nowling <[email protected]> Committed: Sat Aug 22 11:35:33 2015 -0500 ---------------------------------------------------------------------- .../bigpetstore-data-generator/build.gradle | 1 + .../bigpetstore/datagenerator/Constants.java | 12 +-- .../bigpetstore/datagenerator/cli/Driver.java | 6 +- .../datagenerator/datamodels/Customer.java | 1 + .../datagenerator/datamodels/Pair.java | 84 -------------------- .../datamodels/inputs/ZipcodeRecord.java | 12 +-- .../datareaders/ZipcodeReader.java | 4 +- .../BoundedMultiModalGaussianSampler.java | 6 +- .../samplers/RouletteWheelSampler.java | 8 +- .../generators/customer/CustomerSampler.java | 4 +- .../MultinomialPurchasingModelSampler.java | 6 +- .../ProductCategoryUsageTrajectory.java | 12 +-- .../TestBoundedMultiModalGaussianSampler.java | 6 +- .../customer/TestCustomerLocationPDF.java | 9 +-- .../customer/TestCustomerSampler.java | 18 ++--- .../customer/TestCustomerSamplerBuilder.java | 12 +-- .../store/TestStoreLocationIncomePDF.java | 9 +-- .../store/TestStoreLocationPopulationPDF.java | 9 +-- .../generators/store/TestStoreSampler.java | 9 +-- .../store/TestStoreSamplerBuilder.java | 9 +-- .../TestProductCategoryUsageSimulator.java | 8 +- .../TestProductCategoryUsageTrajectory.java | 11 ++- 22 files changed, 81 insertions(+), 175 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/bigtop/blob/a9e2d4f9/bigtop-bigpetstore/bigpetstore-data-generator/build.gradle ---------------------------------------------------------------------- diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/build.gradle b/bigtop-bigpetstore/bigpetstore-data-generator/build.gradle index 5728b9b..8c2ea57 100644 --- a/bigtop-bigpetstore/bigpetstore-data-generator/build.gradle +++ b/bigtop-bigpetstore/bigpetstore-data-generator/build.gradle @@ -58,6 +58,7 @@ test { dependencies { compile 'com.google.guava:guava:18.0' compile 'com.google.code.gson:gson:2.3' + compile 'org.apache.commons:commons-lang3:3.4' testCompile 'junit:junit:4.+' } http://git-wip-us.apache.org/repos/asf/bigtop/blob/a9e2d4f9/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/Constants.java ---------------------------------------------------------------------- diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/Constants.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/Constants.java index be7b6a9..ff87c2e 100644 --- a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/Constants.java +++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/Constants.java @@ -19,7 +19,7 @@ import java.io.File; import java.util.List; import java.util.Set; -import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Pair; +import org.apache.commons.lang3.tuple.Pair; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; @@ -51,8 +51,8 @@ public class Constants public static final int MIN_PETS = 1; public static final int MAX_PETS = 10; - public static final List<Pair<Double, Double>> TRANSACTION_TRIGGER_TIME_GAUSSIANS = ImmutableList.of(Pair.create(5.0, 2.0)); - public static final List<Pair<Double, Double>> PURCHASE_TRIGGER_TIME_GAUSSIANS = ImmutableList.of(Pair.create(10.0, 4.0)); + public static final List<Pair<Double, Double>> TRANSACTION_TRIGGER_TIME_GAUSSIANS = ImmutableList.of(Pair.of(5.0, 2.0)); + public static final List<Pair<Double, Double>> PURCHASE_TRIGGER_TIME_GAUSSIANS = ImmutableList.of(Pair.of(10.0, 4.0)); public static final double TRANSACTION_TRIGGER_TIME_MAX = 10.0; public static final double TRANSACTION_TRIGGER_TIME_MIN = 1.0; @@ -64,15 +64,15 @@ public class Constants public static final PurchasingModelType PURCHASING_MODEL_TYPE = PurchasingModelType.MULTINOMIAL; - public static final List<Pair<Double, Double>> PRODUCT_MSM_FIELD_WEIGHT_GAUSSIANS = ImmutableList.of(Pair.create(0.15, 0.1), Pair.create(0.85, 0.1)); + public static final List<Pair<Double, Double>> PRODUCT_MSM_FIELD_WEIGHT_GAUSSIANS = ImmutableList.of(Pair.of(0.15, 0.1), Pair.of(0.85, 0.1)); public static final double PRODUCT_MSM_FIELD_WEIGHT_LOWERBOUND = 0.05; public static final double PRODUCT_MSM_FIELD_WEIGHT_UPPERBOUND = 0.95; - public static final List<Pair<Double, Double>> PRODUCT_MSM_FIELD_SIMILARITY_WEIGHT_GAUSSIANS = ImmutableList.of(Pair.create(0.15, 0.1), Pair.create(0.85, 0.1)); + public static final List<Pair<Double, Double>> PRODUCT_MSM_FIELD_SIMILARITY_WEIGHT_GAUSSIANS = ImmutableList.of(Pair.of(0.15, 0.1), Pair.of(0.85, 0.1)); public static final double PRODUCT_MSM_FIELD_SIMILARITY_WEIGHT_LOWERBOUND = 0.05; public static final double PRODUCT_MSM_FIELD_SIMILARITY_WEIGHT_UPPERBOUND = 0.95; - public static final List<Pair<Double, Double>> PRODUCT_MSM_LOOPBACK_WEIGHT_GAUSSIANS = ImmutableList.of(Pair.create(0.25, 0.1), Pair.create(0.75, 0.1)); + public static final List<Pair<Double, Double>> PRODUCT_MSM_LOOPBACK_WEIGHT_GAUSSIANS = ImmutableList.of(Pair.of(0.25, 0.1), Pair.of(0.75, 0.1)); public static final double PRODUCT_MSM_LOOPBACK_WEIGHT_LOWERBOUND = 0.05; public static final double PRODUCT_MSM_LOOPBACK_WEIGHT_UPPERBOUND = 0.95; http://git-wip-us.apache.org/repos/asf/bigtop/blob/a9e2d4f9/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/cli/Driver.java ---------------------------------------------------------------------- diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/cli/Driver.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/cli/Driver.java index 5b222cc..3fdef68 100644 --- a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/cli/Driver.java +++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/cli/Driver.java @@ -24,13 +24,13 @@ import java.util.List; import org.apache.bigtop.bigpetstore.datagenerator.DataLoader; import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Customer; -import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Pair; import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product; import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Store; import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Transaction; import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.InputData; import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ProductCategory; import org.apache.bigtop.bigpetstore.datagenerator.generators.purchase.PurchasingModel; +import org.apache.commons.lang3.tuple.Pair; public class Driver @@ -159,7 +159,7 @@ public class Driver record += transaction.getStore().getLocation().getState() + ","; record += transaction.getCustomer().getId() + ","; Pair<String, String> name = transaction.getCustomer().getName(); - record += name.getFirst() + " " + name.getSecond() + ","; + record += name.getLeft() + " " + name.getRight() + ","; record += transaction.getCustomer().getLocation().getZipcode() + ","; record += transaction.getCustomer().getLocation().getCity() + ","; record += transaction.getCustomer().getLocation().getState() + ","; @@ -182,7 +182,7 @@ public class Driver { String record = customer.getId() + ","; Pair<String, String> name = customer.getName(); - record += name.getFirst() + "," + name.getSecond() + ","; + record += name.getLeft() + "," + name.getRight() + ","; record += customer.getLocation().getZipcode() + ","; record += customer.getLocation().getCity() + ","; record += customer.getLocation().getState() + "\n"; http://git-wip-us.apache.org/repos/asf/bigtop/blob/a9e2d4f9/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/datamodels/Customer.java ---------------------------------------------------------------------- diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/datamodels/Customer.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/datamodels/Customer.java index cda0656..704c965 100644 --- a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/datamodels/Customer.java +++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/datamodels/Customer.java @@ -18,6 +18,7 @@ package org.apache.bigtop.bigpetstore.datagenerator.datamodels; import java.io.Serializable; import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ZipcodeRecord; +import org.apache.commons.lang3.tuple.Pair; public class Customer implements Serializable { http://git-wip-us.apache.org/repos/asf/bigtop/blob/a9e2d4f9/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/datamodels/Pair.java ---------------------------------------------------------------------- diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/datamodels/Pair.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/datamodels/Pair.java deleted file mode 100644 index c9e7361..0000000 --- a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/datamodels/Pair.java +++ /dev/null @@ -1,84 +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.datamodels; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -import com.google.common.collect.Lists; - -public class Pair<A, B> implements Serializable -{ - private static final long serialVersionUID = -105021821052665898L; - - A first; - B second; - - public Pair(A first, B second) - { - this.first = first; - this.second = second; - } - - public A getFirst() - { - return first; - } - - public B getSecond() - { - return second; - } - - public static <A, B> Pair<A, B> create(A first, B second) - { - return new Pair<A, B>(first, second); - } - - public static <A, B> List<Pair<A, B>> create(Map<A, B> map) - { - List<Pair<A, B>> list = Lists.newArrayListWithExpectedSize(map.size()); - for(Map.Entry<A, B> entry : map.entrySet()) - list.add(Pair.create(entry.getKey(), entry.getValue())); - return list; - } - - @Override - public boolean equals(Object o) - { - if(!this.getClass().isInstance(o)) - { - return false; - } - - Pair other = (Pair) o; - - return other.getFirst().equals(first) && - other.getSecond().equals(second); - } - - @Override - public int hashCode() - { - return toString().hashCode(); - } - - public String toString() - { - return "Pair(" + first + ", " + second + ")"; - } -} http://git-wip-us.apache.org/repos/asf/bigtop/blob/a9e2d4f9/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/datamodels/inputs/ZipcodeRecord.java ---------------------------------------------------------------------- diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/datamodels/inputs/ZipcodeRecord.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/datamodels/inputs/ZipcodeRecord.java index e74df22..ef54712 100644 --- a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/datamodels/inputs/ZipcodeRecord.java +++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/datamodels/inputs/ZipcodeRecord.java @@ -17,7 +17,7 @@ package org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs; import java.io.Serializable; -import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Pair; +import org.apache.commons.lang3.tuple.Pair; public class ZipcodeRecord implements Serializable { @@ -68,11 +68,11 @@ public class ZipcodeRecord implements Serializable Pair<Double, Double> otherCoords = other.getCoordinates(); - double dist = Math.sin(Math.toRadians(coordinates.getFirst())) * - Math.sin(Math.toRadians(otherCoords.getFirst())) + - Math.cos(Math.toRadians(coordinates.getFirst())) * - Math.cos(Math.toRadians(otherCoords.getFirst())) * - Math.cos(Math.toRadians(coordinates.getSecond() - otherCoords.getSecond())); + 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; http://git-wip-us.apache.org/repos/asf/bigtop/blob/a9e2d4f9/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/datareaders/ZipcodeReader.java ---------------------------------------------------------------------- diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/datareaders/ZipcodeReader.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/datareaders/ZipcodeReader.java index a4ccdd6..1612a92 100644 --- a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/datareaders/ZipcodeReader.java +++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/datareaders/ZipcodeReader.java @@ -24,8 +24,8 @@ import java.util.Scanner; import java.util.Set; import java.util.Vector; -import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Pair; import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ZipcodeRecord; +import org.apache.commons.lang3.tuple.Pair; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -154,7 +154,7 @@ public class ZipcodeReader 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 = new Pair<Double, Double>(latitude, longitude); + Pair<Double, Double> coords = Pair.of(latitude, longitude); ZipcodeLocationRecord record = new ZipcodeLocationRecord(coords, city, state); http://git-wip-us.apache.org/repos/asf/bigtop/blob/a9e2d4f9/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/BoundedMultiModalGaussianSampler.java ---------------------------------------------------------------------- diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/BoundedMultiModalGaussianSampler.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/BoundedMultiModalGaussianSampler.java index 83ec666..348f080 100644 --- a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/BoundedMultiModalGaussianSampler.java +++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/BoundedMultiModalGaussianSampler.java @@ -18,8 +18,8 @@ package org.apache.bigtop.bigpetstore.datagenerator.framework.samplers; import java.util.List; import java.util.Random; -import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Pair; import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory; +import org.apache.commons.lang3.tuple.Pair; import com.google.common.collect.ImmutableList; @@ -46,8 +46,8 @@ public class BoundedMultiModalGaussianSampler implements Sampler<Double> { int idx = rng.nextInt(distributions.size()); - double mean = distributions.get(idx).getFirst(); - double std = distributions.get(idx).getSecond(); + double mean = distributions.get(idx).getLeft(); + double std = distributions.get(idx).getRight(); double value = mean + rng.nextGaussian() * std; http://git-wip-us.apache.org/repos/asf/bigtop/blob/a9e2d4f9/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/RouletteWheelSampler.java ---------------------------------------------------------------------- diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/RouletteWheelSampler.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/RouletteWheelSampler.java index 0537966..0353708 100644 --- a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/RouletteWheelSampler.java +++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/RouletteWheelSampler.java @@ -19,10 +19,10 @@ import java.util.Collection; import java.util.Map; import java.util.Random; -import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Pair; import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory; import org.apache.bigtop.bigpetstore.datagenerator.framework.pdfs.MultinomialPDF; import org.apache.bigtop.bigpetstore.datagenerator.framework.pdfs.ProbabilityDensityFunction; +import org.apache.commons.lang3.tuple.Pair; import com.google.common.collect.ImmutableList; import com.google.common.collect.Maps; @@ -93,7 +93,7 @@ public class RouletteWheelSampler<T> implements Sampler<T> double prob = entry.getValue() / weightSum; cumProb += prob; - builder.add(Pair.create(entry.getKey(), cumProb)); + builder.add(Pair.of(entry.getKey(), cumProb)); } return builder.build(); @@ -103,8 +103,8 @@ public class RouletteWheelSampler<T> implements Sampler<T> { double r = rng.nextDouble(); for(Pair<T, Double> cumProbPair : wheel) - if(r < cumProbPair.getSecond()) - return cumProbPair.getFirst(); + if(r < cumProbPair.getValue()) + return cumProbPair.getKey(); throw new IllegalStateException("Invalid state -- RouletteWheelSampler should never fail to sample!"); } http://git-wip-us.apache.org/repos/asf/bigtop/blob/a9e2d4f9/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/CustomerSampler.java ---------------------------------------------------------------------- diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/CustomerSampler.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/CustomerSampler.java index 4e5689c..8ef96f0 100644 --- a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/CustomerSampler.java +++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/CustomerSampler.java @@ -16,11 +16,11 @@ package org.apache.bigtop.bigpetstore.datagenerator.generators.customer; import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Customer; -import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Pair; 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.ConditionalSampler; import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler; +import org.apache.commons.lang3.tuple.Pair; public class CustomerSampler implements Sampler<Customer> { @@ -45,7 +45,7 @@ public class CustomerSampler implements Sampler<Customer> public Customer sample() throws Exception { Integer id = idSampler.sample(); - Pair<String, String> name = Pair.create(firstNameSampler.sample(), + Pair<String, String> name = Pair.of(firstNameSampler.sample(), lastNameSampler.sample()); Store store = storeSampler.sample(); ZipcodeRecord location = locationSampler.sample(store); http://git-wip-us.apache.org/repos/asf/bigtop/blob/a9e2d4f9/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MultinomialPurchasingModelSampler.java ---------------------------------------------------------------------- diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MultinomialPurchasingModelSampler.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MultinomialPurchasingModelSampler.java index bea39ba..7fcfbe5 100644 --- a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MultinomialPurchasingModelSampler.java +++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/MultinomialPurchasingModelSampler.java @@ -21,7 +21,6 @@ import java.util.Map; import java.util.Vector; import org.apache.bigtop.bigpetstore.datagenerator.Constants; -import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Pair; 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; @@ -29,6 +28,7 @@ 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; @@ -98,7 +98,7 @@ public class MultinomialPurchasingModelSampler implements Sampler<MultinomialPur } Object fieldValue = shuffled.get(i); - fieldValueWeights.put(new Pair<String,Object>(fieldName, fieldValue), weight); + fieldValueWeights.put(Pair.of(fieldName, fieldValue), weight); } } @@ -118,7 +118,7 @@ public class MultinomialPurchasingModelSampler implements Sampler<MultinomialPur if(!Constants.PRODUCT_MODEL_EXCLUDED_FIELDS.contains(fieldName)) { Object fieldValue = p.getFieldValue(fieldName); - Pair<String, Object> key = Pair.create(fieldName, fieldValue); + Pair<String, Object> key = Pair.of(fieldName, fieldValue); weight *= fieldValueWeights.get(key); } } http://git-wip-us.apache.org/repos/asf/bigtop/blob/a9e2d4f9/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/ProductCategoryUsageTrajectory.java ---------------------------------------------------------------------- diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/ProductCategoryUsageTrajectory.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/ProductCategoryUsageTrajectory.java index 665d524..f3c20c7 100644 --- a/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/ProductCategoryUsageTrajectory.java +++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/main/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/ProductCategoryUsageTrajectory.java @@ -17,7 +17,7 @@ package org.apache.bigtop.bigpetstore.datagenerator.generators.transaction; import java.util.List; -import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Pair; +import org.apache.commons.lang3.tuple.Pair; import com.google.common.collect.Lists; @@ -33,17 +33,17 @@ public class ProductCategoryUsageTrajectory public void append(double time, double amount) { - trajectory.add(Pair.create(time, amount)); + trajectory.add(Pair.of(time, amount)); } public double getLastAmount() { - return trajectory.get(trajectory.size() - 1).getSecond(); + return trajectory.get(trajectory.size() - 1).getValue(); } public double getLastTime() { - return trajectory.get(trajectory.size() - 1).getFirst(); + return trajectory.get(trajectory.size() - 1).getKey(); } public double amountAtTime(double time) @@ -51,7 +51,7 @@ public class ProductCategoryUsageTrajectory Pair<Double, Double> previous = null; for(Pair<Double, Double> entry : trajectory) { - if(entry.getFirst() > time) + if(entry.getKey() > time) break; previous = entry; } @@ -59,7 +59,7 @@ public class ProductCategoryUsageTrajectory if(previous == null) return 0.0; - return previous.getSecond(); + return previous.getValue(); } public Pair<Double, Double> getStep(int idx) http://git-wip-us.apache.org/repos/asf/bigtop/blob/a9e2d4f9/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestBoundedMultiModalGaussianSampler.java ---------------------------------------------------------------------- diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestBoundedMultiModalGaussianSampler.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestBoundedMultiModalGaussianSampler.java index fd85d08..9300d08 100644 --- a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestBoundedMultiModalGaussianSampler.java +++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestBoundedMultiModalGaussianSampler.java @@ -19,10 +19,8 @@ import static org.junit.Assert.assertTrue; import java.util.List; -import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Pair; import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory; -import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.BoundedMultiModalGaussianSampler; -import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler; +import org.apache.commons.lang3.tuple.Pair; import org.junit.Test; import com.google.common.collect.Lists; @@ -36,7 +34,7 @@ public class TestBoundedMultiModalGaussianSampler double upperbound = 10.0; double lowerbound = 1.0; - List<Pair<Double, Double>> distributions = Lists.newArrayList(Pair.create(2.0, 2.0), Pair.create(7.5, 2.0)); + List<Pair<Double, Double>> distributions = Lists.newArrayList(Pair.of(2.0, 2.0), Pair.of(7.5, 2.0)); SeedFactory seedFactory = new SeedFactory(1234); http://git-wip-us.apache.org/repos/asf/bigtop/blob/a9e2d4f9/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/TestCustomerLocationPDF.java ---------------------------------------------------------------------- diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/TestCustomerLocationPDF.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/TestCustomerLocationPDF.java index 849fead..0800c58 100644 --- a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/TestCustomerLocationPDF.java +++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/TestCustomerLocationPDF.java @@ -22,10 +22,9 @@ import java.util.Arrays; import java.util.List; import org.apache.bigtop.bigpetstore.datagenerator.Constants; -import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Pair; import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Store; import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ZipcodeRecord; -import org.apache.bigtop.bigpetstore.datagenerator.generators.customer.CustomerLocationPDF; +import org.apache.commons.lang3.tuple.Pair; import org.junit.Test; public class TestCustomerLocationPDF @@ -35,9 +34,9 @@ public class TestCustomerLocationPDF public void testProbability() throws Exception { List<ZipcodeRecord> zipcodes = Arrays.asList(new ZipcodeRecord[] { - new ZipcodeRecord("11111", Pair.create(1.0, 1.0), "AZ", "Tempte", 30000.0, 100), - new ZipcodeRecord("22222", Pair.create(2.0, 2.0), "AZ", "Phoenix", 45000.0, 200), - new ZipcodeRecord("33333", Pair.create(3.0, 3.0), "AZ", "Flagstaff", 60000.0, 300) + new ZipcodeRecord("11111", Pair.of(1.0, 1.0), "AZ", "Tempte", 30000.0, 100), + new ZipcodeRecord("22222", Pair.of(2.0, 2.0), "AZ", "Phoenix", 45000.0, 200), + new ZipcodeRecord("33333", Pair.of(3.0, 3.0), "AZ", "Flagstaff", 60000.0, 300) }); List<Store> stores = new ArrayList<Store>(); http://git-wip-us.apache.org/repos/asf/bigtop/blob/a9e2d4f9/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/TestCustomerSampler.java ---------------------------------------------------------------------- diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/TestCustomerSampler.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/TestCustomerSampler.java index 380d9f0..639b2af 100644 --- a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/TestCustomerSampler.java +++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/TestCustomerSampler.java @@ -26,7 +26,6 @@ import java.util.Map; import org.apache.bigtop.bigpetstore.datagenerator.Constants; import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Customer; -import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Pair; 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; @@ -35,8 +34,7 @@ import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Conditiona 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; -import org.apache.bigtop.bigpetstore.datagenerator.generators.customer.CustomerLocationPDF; -import org.apache.bigtop.bigpetstore.datagenerator.generators.customer.CustomerSampler; +import org.apache.commons.lang3.tuple.Pair; import org.junit.Test; import com.google.common.collect.Maps; @@ -71,9 +69,9 @@ public class TestCustomerSampler Collection<String> nameList = Arrays.asList(new String[] {"Fred", "Gary", "George", "Fiona"}); List<ZipcodeRecord> zipcodes = Arrays.asList(new ZipcodeRecord[] { - new ZipcodeRecord("11111", Pair.create(1.0, 1.0), "AZ", "Tempte", 30000.0, 100), - new ZipcodeRecord("22222", Pair.create(2.0, 2.0), "AZ", "Phoenix", 45000.0, 200), - new ZipcodeRecord("33333", Pair.create(3.0, 3.0), "AZ", "Flagstaff", 60000.0, 300) + new ZipcodeRecord("11111", Pair.of(1.0, 1.0), "AZ", "Tempte", 30000.0, 100), + new ZipcodeRecord("22222", Pair.of(2.0, 2.0), "AZ", "Phoenix", 45000.0, 200), + new ZipcodeRecord("33333", Pair.of(3.0, 3.0), "AZ", "Flagstaff", 60000.0, 300) }); List<Store> stores = new ArrayList<Store>(); @@ -96,10 +94,10 @@ public class TestCustomerSampler assertNotNull(customer); assertTrue(customer.getId() >= 0); assertNotNull(customer.getName()); - assertNotNull(customer.getName().getFirst()); - assertTrue(nameList.contains(customer.getName().getFirst())); - assertNotNull(customer.getName().getSecond()); - assertTrue(nameList.contains(customer.getName().getSecond())); + assertNotNull(customer.getName().getLeft()); + assertTrue(nameList.contains(customer.getName().getLeft())); + assertNotNull(customer.getName().getRight()); + assertTrue(nameList.contains(customer.getName().getRight())); assertNotNull(customer.getLocation()); assertTrue(zipcodes.contains(customer.getLocation())); http://git-wip-us.apache.org/repos/asf/bigtop/blob/a9e2d4f9/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/TestCustomerSamplerBuilder.java ---------------------------------------------------------------------- diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/TestCustomerSamplerBuilder.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/TestCustomerSamplerBuilder.java index fdff826..74c8348 100644 --- a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/TestCustomerSamplerBuilder.java +++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/TestCustomerSamplerBuilder.java @@ -23,13 +23,13 @@ import java.util.List; import java.util.Map; import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Customer; -import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Pair; import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Store; import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.InputData; import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.Names; import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ZipcodeRecord; import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory; import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler; +import org.apache.commons.lang3.tuple.Pair; import org.junit.Test; import com.google.common.collect.ImmutableMap; @@ -42,9 +42,9 @@ public class TestCustomerSamplerBuilder { Map<String, Double> nameList = ImmutableMap.of("Fred", 1.0, "George", 1.0, "Gary", 1.0, "Fiona", 1.0); List<ZipcodeRecord> zipcodes = Arrays.asList(new ZipcodeRecord[] { - new ZipcodeRecord("11111", Pair.create(1.0, 1.0), "AZ", "Tempte", 30000.0, 100), - new ZipcodeRecord("22222", Pair.create(2.0, 2.0), "AZ", "Phoenix", 45000.0, 200), - new ZipcodeRecord("33333", Pair.create(3.0, 3.0), "AZ", "Flagstaff", 60000.0, 300) + new ZipcodeRecord("11111", Pair.of(1.0, 1.0), "AZ", "Tempte", 30000.0, 100), + new ZipcodeRecord("22222", Pair.of(2.0, 2.0), "AZ", "Phoenix", 45000.0, 200), + new ZipcodeRecord("33333", Pair.of(3.0, 3.0), "AZ", "Flagstaff", 60000.0, 300) }); Names names = new Names(nameList, nameList); @@ -67,8 +67,8 @@ public class TestCustomerSamplerBuilder assertNotNull(customer); assertTrue(customer.getId() >= 0); assertNotNull(customer.getName()); - assertNotNull(customer.getName().getFirst()); - assertNotNull(customer.getName().getSecond()); + assertNotNull(customer.getName().getLeft()); + assertNotNull(customer.getName().getRight()); assertNotNull(customer.getLocation()); } http://git-wip-us.apache.org/repos/asf/bigtop/blob/a9e2d4f9/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreLocationIncomePDF.java ---------------------------------------------------------------------- diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreLocationIncomePDF.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreLocationIncomePDF.java index ee27af7..f9b8126 100644 --- a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreLocationIncomePDF.java +++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreLocationIncomePDF.java @@ -20,9 +20,8 @@ import static org.junit.Assert.assertTrue; import java.util.Arrays; import java.util.List; -import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Pair; import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ZipcodeRecord; -import org.apache.bigtop.bigpetstore.datagenerator.generators.store.StoreLocationIncomePDF; +import org.apache.commons.lang3.tuple.Pair; import org.junit.Test; public class TestStoreLocationIncomePDF @@ -32,9 +31,9 @@ public class TestStoreLocationIncomePDF public void testProbability() throws Exception { List<ZipcodeRecord> zipcodes = Arrays.asList(new ZipcodeRecord[] { - new ZipcodeRecord("11111", Pair.create(1.0, 1.0), "AZ", "Tempte", 30000.0, 100), - new ZipcodeRecord("22222", Pair.create(2.0, 2.0), "AZ", "Phoenix", 45000.0, 200), - new ZipcodeRecord("33333", Pair.create(3.0, 3.0), "AZ", "Flagstaff", 60000.0, 300) + new ZipcodeRecord("11111", Pair.of(1.0, 1.0), "AZ", "Tempte", 30000.0, 100), + new ZipcodeRecord("22222", Pair.of(2.0, 2.0), "AZ", "Phoenix", 45000.0, 200), + new ZipcodeRecord("33333", Pair.of(3.0, 3.0), "AZ", "Flagstaff", 60000.0, 300) }); StoreLocationIncomePDF pdf = new StoreLocationIncomePDF(zipcodes, 100.0); http://git-wip-us.apache.org/repos/asf/bigtop/blob/a9e2d4f9/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreLocationPopulationPDF.java ---------------------------------------------------------------------- diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreLocationPopulationPDF.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreLocationPopulationPDF.java index 7c4f522..792f6d0 100644 --- a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreLocationPopulationPDF.java +++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreLocationPopulationPDF.java @@ -20,9 +20,8 @@ import static org.junit.Assert.assertTrue; import java.util.Arrays; import java.util.List; -import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Pair; import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ZipcodeRecord; -import org.apache.bigtop.bigpetstore.datagenerator.generators.store.StoreLocationPopulationPDF; +import org.apache.commons.lang3.tuple.Pair; import org.junit.Test; public class TestStoreLocationPopulationPDF @@ -32,9 +31,9 @@ public class TestStoreLocationPopulationPDF public void testProbability() throws Exception { List<ZipcodeRecord> zipcodes = Arrays.asList(new ZipcodeRecord[] { - new ZipcodeRecord("11111", Pair.create(1.0, 1.0), "AZ", "Tempte", 30000.0, 100), - new ZipcodeRecord("22222", Pair.create(2.0, 2.0), "AZ", "Phoenix", 45000.0, 200), - new ZipcodeRecord("33333", Pair.create(3.0, 3.0), "AZ", "Flagstaff", 60000.0, 300) + new ZipcodeRecord("11111", Pair.of(1.0, 1.0), "AZ", "Tempte", 30000.0, 100), + new ZipcodeRecord("22222", Pair.of(2.0, 2.0), "AZ", "Phoenix", 45000.0, 200), + new ZipcodeRecord("33333", Pair.of(3.0, 3.0), "AZ", "Flagstaff", 60000.0, 300) }); StoreLocationPopulationPDF pdf = new StoreLocationPopulationPDF(zipcodes); http://git-wip-us.apache.org/repos/asf/bigtop/blob/a9e2d4f9/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreSampler.java ---------------------------------------------------------------------- diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreSampler.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreSampler.java index 9efaef6..64589f4 100644 --- a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreSampler.java +++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreSampler.java @@ -21,14 +21,13 @@ import static org.junit.Assert.assertTrue; import java.util.Arrays; import java.util.Collection; -import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Pair; 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.samplers.RouletteWheelSampler; import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler; import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.SequenceSampler; -import org.apache.bigtop.bigpetstore.datagenerator.generators.store.StoreSampler; +import org.apache.commons.lang3.tuple.Pair; import org.junit.Test; public class TestStoreSampler @@ -38,9 +37,9 @@ public class TestStoreSampler public void testSampler() throws Exception { Collection<ZipcodeRecord> zipcodes = Arrays.asList(new ZipcodeRecord[] { - new ZipcodeRecord("11111", Pair.create(1.0, 1.0), "AZ", "Tempte", 30000.0, 100), - new ZipcodeRecord("22222", Pair.create(2.0, 2.0), "AZ", "Phoenix", 45000.0, 200), - new ZipcodeRecord("33333", Pair.create(3.0, 3.0), "AZ", "Flagstaff", 60000.0, 300) + new ZipcodeRecord("11111", Pair.of(1.0, 1.0), "AZ", "Tempte", 30000.0, 100), + new ZipcodeRecord("22222", Pair.of(2.0, 2.0), "AZ", "Phoenix", 45000.0, 200), + new ZipcodeRecord("33333", Pair.of(3.0, 3.0), "AZ", "Flagstaff", 60000.0, 300) }); SeedFactory factory = new SeedFactory(1234); http://git-wip-us.apache.org/repos/asf/bigtop/blob/a9e2d4f9/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreSamplerBuilder.java ---------------------------------------------------------------------- diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreSamplerBuilder.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreSamplerBuilder.java index cc896ea..b7b0a52 100644 --- a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreSamplerBuilder.java +++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreSamplerBuilder.java @@ -21,12 +21,11 @@ import static org.junit.Assert.assertTrue; import java.util.Arrays; import java.util.List; -import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Pair; 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.samplers.Sampler; -import org.apache.bigtop.bigpetstore.datagenerator.generators.store.StoreSamplerBuilder; +import org.apache.commons.lang3.tuple.Pair; import org.junit.Test; public class TestStoreSamplerBuilder @@ -36,9 +35,9 @@ public class TestStoreSamplerBuilder public void testBuild() throws Exception { List<ZipcodeRecord> zipcodes = Arrays.asList(new ZipcodeRecord[] { - new ZipcodeRecord("11111", Pair.create(1.0, 1.0), "AZ", "Tempte", 30000.0, 100), - new ZipcodeRecord("22222", Pair.create(2.0, 2.0), "AZ", "Phoenix", 45000.0, 200), - new ZipcodeRecord("33333", Pair.create(3.0, 3.0), "AZ", "Flagstaff", 60000.0, 300) + new ZipcodeRecord("11111", Pair.of(1.0, 1.0), "AZ", "Tempte", 30000.0, 100), + new ZipcodeRecord("22222", Pair.of(2.0, 2.0), "AZ", "Phoenix", 45000.0, 200), + new ZipcodeRecord("33333", Pair.of(3.0, 3.0), "AZ", "Flagstaff", 60000.0, 300) }); assertTrue(zipcodes.size() > 0); http://git-wip-us.apache.org/repos/asf/bigtop/blob/a9e2d4f9/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TestProductCategoryUsageSimulator.java ---------------------------------------------------------------------- diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TestProductCategoryUsageSimulator.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TestProductCategoryUsageSimulator.java index 267cd00..6c093df 100644 --- a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TestProductCategoryUsageSimulator.java +++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TestProductCategoryUsageSimulator.java @@ -18,10 +18,8 @@ package org.apache.bigtop.bigpetstore.datagenerator.generators.transaction; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Pair; import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory; -import org.apache.bigtop.bigpetstore.datagenerator.generators.transaction.ProductCategoryUsageSimulator; -import org.apache.bigtop.bigpetstore.datagenerator.generators.transaction.ProductCategoryUsageTrajectory; +import org.apache.commons.lang3.tuple.Pair; import org.junit.Test; public class TestProductCategoryUsageSimulator @@ -43,9 +41,9 @@ public class TestProductCategoryUsageSimulator { Pair<Double, Double> entry = trajectory.getStep(i); // time should move forward - assertTrue(previousEntry.getFirst() <= entry.getFirst()); + assertTrue(previousEntry.getLeft() <= entry.getLeft()); // remaining amounts should go down - assertTrue(previousEntry.getSecond() >= entry.getSecond()); + assertTrue(previousEntry.getRight() >= entry.getRight()); previousEntry = entry; } } http://git-wip-us.apache.org/repos/asf/bigtop/blob/a9e2d4f9/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TestProductCategoryUsageTrajectory.java ---------------------------------------------------------------------- diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TestProductCategoryUsageTrajectory.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TestProductCategoryUsageTrajectory.java index e7bb982..5462de2 100644 --- a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TestProductCategoryUsageTrajectory.java +++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TestProductCategoryUsageTrajectory.java @@ -17,8 +17,7 @@ package org.apache.bigtop.bigpetstore.datagenerator.generators.transaction; import static org.junit.Assert.assertEquals; -import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Pair; -import org.apache.bigtop.bigpetstore.datagenerator.generators.transaction.ProductCategoryUsageTrajectory; +import org.apache.commons.lang3.tuple.Pair; import org.junit.Test; public class TestProductCategoryUsageTrajectory @@ -35,16 +34,16 @@ public class TestProductCategoryUsageTrajectory assertEquals(trajectory.size(), 1); Pair<Double, Double> entry = trajectory.getStep(0); - assertEquals(initialTime, entry.getFirst(), 0.0001); - assertEquals(initialAmount, entry.getSecond(), 0.0001); + assertEquals(initialTime, entry.getLeft(), 0.0001); + assertEquals(initialAmount, entry.getRight(), 0.0001); trajectory.append(1.0, 25.0); assertEquals(2, trajectory.size()); entry = trajectory.getStep(1); - assertEquals(1.0, entry.getFirst(), 0.0001); - assertEquals(25.0, entry.getSecond(), 0.0001); + assertEquals(1.0, entry.getLeft(), 0.0001); + assertEquals(25.0, entry.getRight(), 0.0001); assertEquals(1.0, trajectory.getLastTime(), 0.0001); assertEquals(25.0, trajectory.getLastAmount(), 0.0001);
