/** * Builds a new selectivity estimator with the given data. * * @param counterFactory the counter factory. */ public AbstractSelectivityEstimator(final CounterFactory counterFactory) { _triple_counter = counterFactory.getCounter("TRIPLE_COUNTER"); }
/** * Builds a new selectivity estimator with the given data. * * @param counterFactory the counter factory. */ public AbstractSelectivityEstimator(final CounterFactory counterFactory) { _triple_counter = counterFactory.getCounter("TRIPLE_COUNTER"); }
@Test public void updateSingleTest() throws Exception { for (int i = 0; i < _test_ids.size(); i++) { Counter c = _counter_factory.getCounter(_test_ids.get(i)); Client client = new Client(c, _test_numOfIncrements.get(i)); client.start(); client.join(); assertEquals((int) _test_numOfIncrements.get(i), client .getCollectedValues().size()); assertEquals((int) _test_numOfIncrements.get(i), c.current()); } }
@Test public void updateMultiTest() throws InterruptedException { for (int i = 0; i < _test_ids.size(); i++) { Counter c = _counter_factory.getCounter(_test_ids.get(i)); List<Client> clients = new LinkedList<Client>(); for (int j = 0; j < NUM_OF_CLIENTS; j++) { Client client = new Client(c, _test_numOfIncrements.get(i)); client.start(); clients.add(client); } for (Client client : clients) { client.join(); } Set<Long> collectedValues = new HashSet<Long>(); for (Client client : clients) { collectedValues.addAll(client.getCollectedValues()); assertEquals((int) _test_numOfIncrements.get(i), client .getCollectedValues().size()); } assertEquals(_test_numOfIncrements.get(i) * NUM_OF_CLIENTS, collectedValues.size()); } }
@Test public void createCounterTest() throws Exception { for (String id : _test_ids) { final Counter c = _counter_factory.getCounter(id); assertNotNull(c); assertEquals(0l, c.current()); } }