mirror of https://github.com/apache/druid.git
formatting changes
This commit is contained in:
parent
de5b1749bc
commit
c1e6f6d83e
|
@ -45,8 +45,8 @@ public class CardinalityAggregator implements Aggregator
|
|||
{
|
||||
final Hasher hasher = hashFn.newHasher();
|
||||
for (int k = 0; k < selectorList.size(); ++k) {
|
||||
if(k != 0) {
|
||||
hasher.putByte((byte)0);
|
||||
if (k != 0) {
|
||||
hasher.putByte((byte) 0);
|
||||
}
|
||||
final DimensionSelector selector = selectorList.get(k);
|
||||
final IndexedInts row = selector.getRow();
|
||||
|
@ -64,7 +64,7 @@ public class CardinalityAggregator implements Aggregator
|
|||
// Values need to be sorted to ensure consistent multi-value ordering across different segments
|
||||
Arrays.sort(values);
|
||||
for (int i = 0; i < size; ++i) {
|
||||
if(i != 0) {
|
||||
if (i != 0) {
|
||||
hasher.putChar(SEPARATOR);
|
||||
}
|
||||
hasher.putString(values[i]);
|
||||
|
@ -101,7 +101,7 @@ public class CardinalityAggregator implements Aggregator
|
|||
@Override
|
||||
public void aggregate()
|
||||
{
|
||||
if(byRow) {
|
||||
if (byRow) {
|
||||
hashRow(selectorList, collector);
|
||||
} else {
|
||||
hashValues(selectorList, collector);
|
||||
|
|
|
@ -59,7 +59,7 @@ public class CardinalityBufferAggregator implements BufferAggregator
|
|||
+ HyperLogLogCollector.getLatestNumBytesForDenseStorage()
|
||||
)
|
||||
);
|
||||
if(byRow) {
|
||||
if (byRow) {
|
||||
CardinalityAggregator.hashRow(selectorList, collector);
|
||||
} else {
|
||||
CardinalityAggregator.hashValues(selectorList, collector);
|
||||
|
|
|
@ -42,10 +42,13 @@ public class CardinalityAggregatorBenchmark extends SimpleBenchmark
|
|||
ByteBuffer buf;
|
||||
int pos;
|
||||
|
||||
@Param({"1", "5"}) int multivaluedSized;
|
||||
@Param({"true", "false"}) boolean byRow;
|
||||
@Param({"1", "5"})
|
||||
int multivaluedSized;
|
||||
@Param({"true", "false"})
|
||||
boolean byRow;
|
||||
|
||||
protected void setUp() {
|
||||
protected void setUp()
|
||||
{
|
||||
Iterable<String[]> values = FluentIterable
|
||||
.from(ContiguousSet.create(Range.closedOpen(0, 500), DiscreteDomain.integers()))
|
||||
.transform(
|
||||
|
@ -54,13 +57,14 @@ public class CardinalityAggregatorBenchmark extends SimpleBenchmark
|
|||
@Override
|
||||
public String[] apply(Integer input)
|
||||
{
|
||||
if(multivaluedSized == 1) {
|
||||
if (multivaluedSized == 1) {
|
||||
return new String[]{input.toString()};
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
String[] res = new String[multivaluedSized];
|
||||
String value = input.toString();
|
||||
for(int i = 0; i < multivaluedSized; ++i) res[i] = value + i;
|
||||
for (int i = 0; i < multivaluedSized; ++i) {
|
||||
res[i] = value + i;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
@ -96,15 +100,15 @@ public class CardinalityAggregatorBenchmark extends SimpleBenchmark
|
|||
agg.init(buf, pos);
|
||||
}
|
||||
|
||||
public Object timeBufferAggregate(int reps) throws Exception {
|
||||
public Object timeBufferAggregate(int reps) throws Exception
|
||||
{
|
||||
for (int i = 0; i < reps; ++i) {
|
||||
agg.aggregate(buf, pos);
|
||||
|
||||
for (final DimensionSelector selector : selectorList) {
|
||||
if(i % (MAX - 1) == 0) {
|
||||
if (i % (MAX - 1) == 0) {
|
||||
((CardinalityAggregatorTest.TestDimensionSelector) selector).reset();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
((CardinalityAggregatorTest.TestDimensionSelector) selector).increment();
|
||||
}
|
||||
}
|
||||
|
@ -114,11 +118,13 @@ public class CardinalityAggregatorBenchmark extends SimpleBenchmark
|
|||
|
||||
|
||||
@Override
|
||||
protected void tearDown() {
|
||||
protected void tearDown()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
Runner.main(CardinalityAggregatorBenchmark.class, args);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -159,7 +159,18 @@ public class CardinalityAggregatorTest
|
|||
"a", "b", "c", "a", "a", null, "b", "b", "b", "b", "a", "a"
|
||||
);
|
||||
private static final List<String[]> values2 = dimensionValues(
|
||||
"a", "b", "c", "x", "a", "e", "b", new String[]{null, "x"}, new String[]{"x", null}, new String[]{"y", "x"}, new String[]{"x", "y"}, new String[] {"x", "y", "a"}
|
||||
"a",
|
||||
"b",
|
||||
"c",
|
||||
"x",
|
||||
"a",
|
||||
"e",
|
||||
"b",
|
||||
new String[]{null, "x"},
|
||||
new String[]{"x", null},
|
||||
new String[]{"y", "x"},
|
||||
new String[]{"x", "y"},
|
||||
new String[]{"x", "y", "a"}
|
||||
);
|
||||
|
||||
private static List<String[]> dimensionValues(Object... values)
|
||||
|
@ -309,7 +320,7 @@ public class CardinalityAggregatorTest
|
|||
@Test
|
||||
public void testCombineRows()
|
||||
{
|
||||
List<DimensionSelector> selector1 = Lists.newArrayList((DimensionSelector)dim1);
|
||||
List<DimensionSelector> selector1 = Lists.newArrayList((DimensionSelector) dim1);
|
||||
List<DimensionSelector> selector2 = Lists.newArrayList((DimensionSelector) dim2);
|
||||
|
||||
CardinalityAggregator agg1 = new CardinalityAggregator("billy", selector1, true);
|
||||
|
@ -340,8 +351,8 @@ public class CardinalityAggregatorTest
|
|||
@Test
|
||||
public void testCombineValues()
|
||||
{
|
||||
List<DimensionSelector> selector1 = Lists.newArrayList((DimensionSelector)dim1);
|
||||
List<DimensionSelector> selector2 = Lists.newArrayList((DimensionSelector)dim2);
|
||||
List<DimensionSelector> selector1 = Lists.newArrayList((DimensionSelector) dim1);
|
||||
List<DimensionSelector> selector2 = Lists.newArrayList((DimensionSelector) dim2);
|
||||
|
||||
CardinalityAggregator agg1 = new CardinalityAggregator("billy", selector1, false);
|
||||
CardinalityAggregator agg2 = new CardinalityAggregator("billy", selector2, false);
|
||||
|
|
Loading…
Reference in New Issue