@Override public Integer apply(InetAddress input) { return occurrencesByHost.count(input); } });
@Override public Integer apply(InetAddress input) { return occurrencesByHost.count(input); } });
vector.set(foundIndex, set.count(s)); } else if (oovIndex >= 0) { vector.set(oovIndex, 1);
for (final Integer ti : sumCount[k].elementSet()) { final int topicCount = sumCount[k].count(ti); for (int k = 0; k < nTopics; k++) cumFreqs.get(k).add(f, cumFreqs.get(k).count(f + 1) + freqs.get(k).count(f)); V[k] = cumFreqs.get(k).count(1); G[k] += ((double) cumFreqs.get(k).count(f)) / ((double) (f - 1)); H[k] += ((double) cumFreqs.get(k).count(f)) / ((double) (f - 1) * (f - 1));
int index = Arrays.binarySearch(dictionary, token); if (index >= 0) { double tfIdf = termFrequencySet.count(token)
err.append (". "+ StringUtils.rightPad(code,45) + " : "+ importExceptionCodes.count(code) +"\n");
@Test public void multiNodeCluster2() throws Exception { final Wrapper wrapper = newWrapper(200, 1, 20, ImmutableList.of( new EndpointAffinity(N1_EP2, 0.15, true, 50), new EndpointAffinity(N2_EP2, 0.15, true, 50), new EndpointAffinity(N3_EP1, 0.10, true, 50), new EndpointAffinity(N4_EP2, 0.20, true, 50), new EndpointAffinity(N1_EP1, 0.20, true, 50) )); INSTANCE.parallelizeFragment(wrapper, newParameters(1, 5, 20), null); // Expect the fragment parallelization to be 20 because: // 1. the cost (200) is above the threshold (SLICE_TARGET_DEFAULT) (which gives 200/1=200 width) and // 2. Number of mandatory node assignments are 5 (current width 200 satisfies the requirement) // 3. max fragment width is 20 which limits the width assertEquals(20, wrapper.getWidth()); final List<NodeEndpoint> assignedEps = wrapper.getAssignedEndpoints(); assertEquals(20, assignedEps.size()); final HashMultiset<NodeEndpoint> counts = HashMultiset.create(); for(final NodeEndpoint ep : assignedEps) { counts.add(ep); } // Each node gets at max 5. assertTrue(counts.count(N1_EP2) <= 5); assertTrue(counts.count(N2_EP2) <= 5); assertTrue(counts.count(N3_EP1) <= 5); assertTrue(counts.count(N4_EP2) <= 5); assertTrue(counts.count(N1_EP1) <= 5); }
@Test public void multiNodeClusterNonNormalizedAffinities() throws Exception { final Wrapper wrapper = newWrapper(2000, 1, 250, ImmutableList.of( new EndpointAffinity(N1_EP2, 15, true, 50), new EndpointAffinity(N2_EP2, 15, true, 50), new EndpointAffinity(N3_EP1, 10, true, 50), new EndpointAffinity(N4_EP2, 20, true, 50), new EndpointAffinity(N1_EP1, 20, true, 50) )); INSTANCE.parallelizeFragment(wrapper, newParameters(100, 20, 80), null); // Expect the fragment parallelization to be 20 because: // 1. the cost (2000) is above the threshold (SLICE_TARGET_DEFAULT) (which gives 2000/100=20 width) and // 2. Number of mandatory node assignments are 5 (current width 200 satisfies the requirement) // 3. max width per node is 20 which limits the width to 100, but existing width (20) is already less assertEquals(20, wrapper.getWidth()); final List<NodeEndpoint> assignedEps = wrapper.getAssignedEndpoints(); assertEquals(20, assignedEps.size()); final HashMultiset<NodeEndpoint> counts = HashMultiset.create(); for(final NodeEndpoint ep : assignedEps) { counts.add(ep); } // Each node gets at max 5. assertThat(counts.count(N1_EP2), CoreMatchers.allOf(greaterThan(1), lessThanOrEqualTo(5))); assertThat(counts.count(N2_EP2), CoreMatchers.allOf(greaterThan(1), lessThanOrEqualTo(5))); assertThat(counts.count(N3_EP1), CoreMatchers.allOf(greaterThan(1), lessThanOrEqualTo(5))); assertThat(counts.count(N4_EP2), CoreMatchers.allOf(greaterThan(1), lessThanOrEqualTo(5))); assertThat(counts.count(N1_EP1), CoreMatchers.allOf(greaterThan(1), lessThanOrEqualTo(5))); }