Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .idea/inspectionProfiles/Druid.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public void uncompressed(Blackhole blackhole)
{
for (int i = filter.nextSetBit(0); i >= 0; i = filter.nextSetBit(i + 1)) {
IndexedInts row = uncompressed.get(i);
for (int j = 0; j < row.size(); j++) {
for (int j = 0, rowSize = row.size(); j < rowSize; j++) {
blackhole.consume(row.get(j));
}
}
Expand All @@ -165,7 +165,7 @@ public void compressed(Blackhole blackhole)
{
for (int i = filter.nextSetBit(0); i >= 0; i = filter.nextSetBit(i + 1)) {
IndexedInts row = compressed.get(i);
for (int j = 0; j < row.size(); j++) {
for (int j = 0, rowSize = row.size(); j < rowSize; j++) {
blackhole.consume(row.get(j));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public DistinctCountAggregator(
public void aggregate()
{
IndexedInts row = selector.getRow();
for (int i = 0; i < row.size(); i++) {
for (int i = 0, rowSize = row.size(); i < rowSize; i++) {
int index = row.get(i);
mutableBitmap.add(index);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void aggregate(ByteBuffer buf, int position)
{
MutableBitmap mutableBitmap = getMutableBitmap(position);
IndexedInts row = selector.getRow();
for (int i = 0; i < row.size(); i++) {
for (int i = 0, rowSize = row.size(); i < rowSize; i++) {
int index = row.get(i);
mutableBitmap.add(index);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void hashRow(DimensionSelector dimSelector, Hasher hasher)
public void hashValues(DimensionSelector dimSelector, HyperLogLogCollector collector)
{
IndexedInts row = dimSelector.getRow();
for (int i = 0; i < row.size(); i++) {
for (int i = 0, rowSize = row.size(); i < rowSize; i++) {
int index = row.get(i);
final String value = dimSelector.lookupName(index);
collector.add(CardinalityAggregator.hashFn.hashUnencodedChars(nullToSpecial(value)).asBytes());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,13 @@ private List<ByteBuffer> updateValues(

final DimensionSelector dimSelector = dims.get(0);
final IndexedInts row = dimSelector.getRow();
if (row == null || row.size() == 0) {
final int rowSize = row.size();
if (rowSize == 0) {
ByteBuffer newKey = key.duplicate();
newKey.putInt(MISSING_VALUE);
unaggregatedBuffers = updateValues(newKey, dims.subList(1, dims.size()));
} else {
for (int i = 0; i < row.size(); i++) {
for (int i = 0; i < rowSize; i++) {
ByteBuffer newKey = key.duplicate();
int dimValue = row.get(i);
newKey.putInt(dimValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,12 +639,13 @@ private void aggregateMultiValueDims(IntGrouper grouper)
}

while (!cursor.isDone()) {
if (multiValues.size() == 0) {
int multiValuesSize = multiValues.size();
if (multiValuesSize == 0) {
if (!grouper.aggregate(GroupByColumnSelectorStrategy.GROUP_BY_MISSING_VALUE).isOk()) {
return;
}
} else {
for (; nextValIndex < multiValues.size(); nextValIndex++) {
for (; nextValIndex < multiValuesSize; nextValIndex++) {
if (!grouper.aggregate(multiValues.get(nextValIndex)).isOk()) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void initColumnValues(ColumnValueSelector selector, int columnIndex, Obje
}
int rowSize = row.size();
newRow.ensureSize(rowSize);
for (int i = 0; i < row.size(); i++) {
for (int i = 0; i < rowSize; i++) {
final String value = dimSelector.lookupName(row.get(i));
final int dictId = reverseDictionary.getInt(value);
if (dictId < 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,9 @@ public Long accumulate(Long accumulated, Cursor cursor)
}
long current = accumulated;
while (!cursor.isDone()) {
final IndexedInts vals = selector.getRow();
for (int i = 0; i < vals.size(); ++i) {
final String dimVal = selector.lookupName(vals.get(i));
final IndexedInts row = selector.getRow();
for (int i = 0, rowSize = row.size(); i < rowSize; ++i) {
final String dimVal = selector.lookupName(row.get(i));
if (dimVal != null && !dimVal.isEmpty()) {
current += StringUtils.estimatedBinaryLengthAsUTF8(dimVal);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ public void updateSearchResultSet(
)
{
if (selector != null && !isNilSelector(selector)) {
final IndexedInts vals = selector.getRow();
for (int i = 0; i < vals.size(); ++i) {
final String dimVal = selector.lookupName(vals.get(i));
final IndexedInts row = selector.getRow();
for (int i = 0, rowSize = row.size(); i < rowSize; ++i) {
final String dimVal = selector.lookupName(row.get(i));
if (searchQuerySpec.accept(dimVal)) {
set.addTo(new SearchHit(outputName, Strings.nullToEmpty(dimVal)), 1);
if (set.size() >= limit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,19 @@ public static class StringSelectColumnSelectorStrategy implements SelectColumnSe
@Override
public void addRowValuesToSelectResult(String outputName, DimensionSelector selector, Map<String, Object> resultMap)
{
if (selector == null) {
final IndexedInts row = selector.getRow();
int rowSize = row.size();
if (rowSize == 0) {
resultMap.put(outputName, null);
} else if (rowSize == 1) {
final String dimVal = selector.lookupName(row.get(0));
resultMap.put(outputName, dimVal);
} else {
final IndexedInts vals = selector.getRow();

if (vals.size() == 1) {
final String dimVal = selector.lookupName(vals.get(0));
resultMap.put(outputName, dimVal);
} else {
List<String> dimVals = new ArrayList<>(vals.size());
for (int i = 0; i < vals.size(); ++i) {
dimVals.add(selector.lookupName(vals.get(i)));
}
resultMap.put(outputName, dimVals);
List<String> dimVals = new ArrayList<>(rowSize);
for (int i = 0; i < rowSize; ++i) {
dimVals.add(selector.lookupName(row.get(i)));
}
resultMap.put(outputName, dimVals);
}
}
}
Expand Down Expand Up @@ -300,7 +298,9 @@ public static Map<String, Object> singleEvent(
theEvent.put(timestampKey, DateTimes.utc(timestampColumnSelector.getLong()));

for (ColumnSelectorPlus<SelectColumnSelectorStrategy> selectorPlus : selectorPlusList) {
selectorPlus.getColumnSelectorStrategy().addRowValuesToSelectResult(selectorPlus.getOutputName(), selectorPlus.getSelector(), theEvent);
selectorPlus
.getColumnSelectorStrategy()
.addRowValuesToSelectResult(selectorPlus.getOutputName(), selectorPlus.getSelector(), theEvent);
}

for (Map.Entry<String, BaseObjectColumnValueSelector<?>> metSelector : metSelectors.entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private long dimExtractionScanAndAggregateWithCardinalityKnown(
long processedRows = 0;
while (!cursor.isDone()) {
final IndexedInts dimValues = selector.getRow();
for (int i = 0; i < dimValues.size(); ++i) {
for (int i = 0, size = dimValues.size(); i < size; ++i) {
final int dimIndex = dimValues.get(i);
Aggregator[] theAggregators = rowSelector[dimIndex];
if (theAggregators == null) {
Expand Down Expand Up @@ -165,7 +165,7 @@ private long dimExtractionScanAndAggregateWithCardinalityUnknown(
long processedRows = 0;
while (!cursor.isDone()) {
final IndexedInts dimValues = selector.getRow();
for (int i = 0; i < dimValues.size(); ++i) {
for (int i = 0, size = dimValues.size(); i < size; ++i) {
final int dimIndex = dimValues.get(i);
final String key = selector.lookupName(dimIndex);

Expand Down
17 changes: 9 additions & 8 deletions processing/src/main/java/io/druid/segment/DimensionSelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,17 @@ default boolean isNull()
default Object defaultGetObject()
{
IndexedInts row = getRow();
if (row.size() == 0) {
int rowSize = row.size();
if (rowSize == 0) {
return null;
}
if (row.size() == 1) {
} else if (rowSize == 1) {
return lookupName(row.get(0));
} else {
final String[] strings = new String[rowSize];
for (int i = 0; i < rowSize; i++) {
strings[i] = lookupName(row.get(i));
}
return strings;
}
final String[] strings = new String[row.size()];
for (int i = 0; i < row.size(); i++) {
strings[i] = lookupName(row.get(i));
}
return strings;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public static CompressedVSizeColumnarMultiIntsSupplier fromIterable(
while (objects.hasNext()) {
IndexedInts next = objects.next();
offsetList.add(offset);
for (int i = 0; i < next.size(); i++) {
for (int i = 0, size = next.size(); i < size; i++) {
values.add(next.get(i));
}
offset += next.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static V3CompressedVSizeColumnarMultiIntsSupplier fromIterable(
while (objects.hasNext()) {
IndexedInts next = objects.next();
offsetList.add(offset);
for (int i = 0; i < next.size(); i++) {
for (int i = 0, size = next.size(); i < size; i++) {
values.add(next.get(i));
}
offset += next.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public void run()

try {
for (int i = 0; i < numRuns; ++i) {
for (int j = 0; j < columnarInts.size(); ++j) {
for (int j = 0, size = columnarInts.size(); j < size; ++j) {
final long val = vals[j];
final long indexedVal = columnarInts.get(j);
if (Longs.compare(val, indexedVal) != 0) {
Expand Down Expand Up @@ -285,7 +285,7 @@ private void assertIndexMatchesVals()

// sequential access
int[] indices = new int[vals.length];
for (int i = 0; i < columnarInts.size(); ++i) {
for (int i = 0, size = columnarInts.size(); i < size; ++i) {
Assert.assertEquals(vals[i], columnarInts.get(i), 0.0);
indices[i] = i;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public void run()

try {
for (int i = 0; i < numRuns; ++i) {
for (int j = 0; j < columnarInts.size(); ++j) {
for (int j = 0, size = columnarInts.size(); j < size; ++j) {
final long val = vals[j];
final long indexedVal = columnarInts.get(j);
if (Longs.compare(val, indexedVal) != 0) {
Expand Down Expand Up @@ -362,7 +362,7 @@ private void assertIndexMatchesVals()

// sequential access of every element
int[] indices = new int[vals.length];
for (int i = 0; i < columnarInts.size(); ++i) {
for (int i = 0, size = columnarInts.size(); i < size; ++i) {
final int expected = vals[i];
final int actual = columnarInts.get(i);
Assert.assertEquals(expected, actual);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void testIterators()
final IndexedInts vSizeIndexedInts = iterator.next();

Assert.assertEquals(ints.length, vSizeIndexedInts.size());
for (int i = 0; i < vSizeIndexedInts.size(); i++) {
for (int i = 0, size = vSizeIndexedInts.size(); i < size; i++) {
Assert.assertEquals(ints[i], vSizeIndexedInts.get(i));
}
row++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private void checkSerializedSizeAndData(int offsetChunkFactor, int valueChunkFac
for (int i = 0; i < vals.size(); ++i) {
IndexedInts subVals = columnarMultiInts.get(i);
assertEquals(subVals.size(), vals.get(i).length);
for (int j = 0; j < subVals.size(); ++j) {
for (int j = 0, size = subVals.size(); j < size; ++j) {
assertEquals(subVals.get(j), vals.get(i)[j]);
}
}
Expand Down Expand Up @@ -278,7 +278,7 @@ private void checkV2SerializedSizeAndData(int offsetChunkFactor, int valueChunkF
for (int i = 0; i < vals.size(); ++i) {
IndexedInts subVals = columnarMultiInts.get(i);
assertEquals(subVals.size(), vals.get(i).length);
for (int j = 0; j < subVals.size(); ++j) {
for (int j = 0, size = subVals.size(); j < size; ++j) {
assertEquals(subVals.get(j), vals.get(i)[j]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import com.google.common.base.Function;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import io.druid.data.input.Firehose;
import io.druid.data.input.InputRow;
Expand Down Expand Up @@ -49,6 +48,7 @@

import javax.annotation.Nullable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -139,12 +139,13 @@ public InputRow next()
final DimensionSelector selector = dimSelector.getValue();
final IndexedInts vals = selector.getRow();

if (vals.size() == 1) {
int valsSize = vals.size();
if (valsSize == 1) {
final String dimVal = selector.lookupName(vals.get(0));
theEvent.put(dim, dimVal);
} else {
List<String> dimVals = Lists.newArrayList();
for (int i = 0; i < vals.size(); ++i) {
} else if (valsSize > 1) {
List<String> dimVals = new ArrayList<>(valsSize);
for (int i = 0; i < valsSize; ++i) {
dimVals.add(selector.lookupName(vals.get(i)));
}
theEvent.put(dim, dimVals);
Expand Down