From 40e595c7a0825b10f0074e221f09b07e51862b3e Mon Sep 17 00:00:00 2001 From: Gian Merlino Date: Tue, 3 May 2016 11:10:25 -0700 Subject: [PATCH] Remove types from TimeAndDims, they aren't needed. (#2865) --- .../segment/incremental/IncrementalIndex.java | 30 ++++--------------- .../IncrementalIndexStorageAdapter.java | 8 ++--- 2 files changed, 8 insertions(+), 30 deletions(-) diff --git a/processing/src/main/java/io/druid/segment/incremental/IncrementalIndex.java b/processing/src/main/java/io/druid/segment/incremental/IncrementalIndex.java index f2e1b7348bd..b0a4dd1fafd 100644 --- a/processing/src/main/java/io/druid/segment/incremental/IncrementalIndex.java +++ b/processing/src/main/java/io/druid/segment/incremental/IncrementalIndex.java @@ -588,17 +588,15 @@ public abstract class IncrementalIndex implements Iterable, final List rowDimensions = row.getDimensions(); int[][] dims; - ValueType[] types; List overflow = null; List overflowTypes = null; synchronized (dimensionDescs) { dims = new int[dimensionDescs.size()][]; - types = new ValueType[dimensionDescs.size()]; for (String dimension : rowDimensions) { List dimensionValues; ColumnCapabilitiesImpl capabilities; - ValueType valType = null; + final ValueType valType; DimensionDesc desc = dimensionDescs.get(dimension); if (desc != null) { capabilities = desc.getCapabilities(); @@ -607,11 +605,7 @@ public abstract class IncrementalIndex implements Iterable, if (capabilities == null) { capabilities = new ColumnCapabilitiesImpl(); // For schemaless type discovery, assume everything is a String for now, can change later. - //valType = getTypeFromDimVal(row.getRaw(dimension)); - if (valType == null) { - valType = ValueType.STRING; - } - capabilities.setType(valType); + capabilities.setType(ValueType.STRING); columnCapabilities.put(dimension, capabilities); } } @@ -645,7 +639,6 @@ public abstract class IncrementalIndex implements Iterable, throw new ISE("Dimension[%s] occurred more than once in InputRow", dimension); } else { dims[desc.getIndex()] = getDimVals(desc.getValues(), dimensionValues); - types[desc.getIndex()] = valType; } } } @@ -653,19 +646,15 @@ public abstract class IncrementalIndex implements Iterable, if (overflow != null) { // Merge overflow and non-overflow int[][] newDims = new int[dims.length + overflow.size()][]; - ValueType[] newTypes = new ValueType[dims.length + overflow.size()]; System.arraycopy(dims, 0, newDims, 0, dims.length); - System.arraycopy(types, 0, newTypes, 0, dims.length); for (int i = 0; i < overflow.size(); ++i) { newDims[dims.length + i] = overflow.get(i); - newTypes[dims.length + i] = overflowTypes.get(i); } dims = newDims; - types = newTypes; } long truncated = gran.truncate(row.getTimestampFromEpoch()); - return new TimeAndDims(Math.max(truncated, minTimestamp), dims, types); + return new TimeAndDims(Math.max(truncated, minTimestamp), dims); } private synchronized void updateMaxIngestedTime(DateTime eventTime) @@ -907,16 +896,15 @@ public abstract class IncrementalIndex implements Iterable, final int rowOffset = input.getValue(); int[][] theDims = timeAndDims.getDims(); //TODO: remove dictionary encoding for numerics later - ValueType[] types = timeAndDims.getTypes(); Map theVals = Maps.newLinkedHashMap(); for (int i = 0; i < theDims.length; ++i) { int[] dim = theDims[i]; - ValueType type = types[i]; DimensionDesc dimensionDesc = dimensions.get(i); if (dimensionDesc == null) { continue; } + ValueType type = dimensionDesc.getCapabilities().getType(); String dimensionName = dimensionDesc.getName(); if (dim == null || dim.length == 0) { theVals.put(dimensionName, null); @@ -1173,17 +1161,14 @@ public abstract class IncrementalIndex implements Iterable, { private final long timestamp; private final int[][] dims; - private final ValueType[] types; TimeAndDims( long timestamp, - int[][] dims, - ValueType[] types + int[][] dims ) { this.timestamp = timestamp; this.dims = dims; - this.types = types; } long getTimestamp() @@ -1196,11 +1181,6 @@ public abstract class IncrementalIndex implements Iterable, return dims; } - public ValueType[] getTypes() - { - return types; - } - @Override public String toString() { diff --git a/processing/src/main/java/io/druid/segment/incremental/IncrementalIndexStorageAdapter.java b/processing/src/main/java/io/druid/segment/incremental/IncrementalIndexStorageAdapter.java index 64acece175e..ca2b22db7c6 100644 --- a/processing/src/main/java/io/druid/segment/incremental/IncrementalIndexStorageAdapter.java +++ b/processing/src/main/java/io/druid/segment/incremental/IncrementalIndexStorageAdapter.java @@ -27,7 +27,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterators; import com.google.common.collect.Lists; import com.google.common.primitives.Ints; -import com.metamx.collections.spatial.search.Bound; import com.metamx.common.guava.Sequence; import com.metamx.common.guava.Sequences; import io.druid.granularity.QueryGranularity; @@ -235,11 +234,10 @@ public class IncrementalIndexStorageAdapter implements StorageAdapter { cursorMap = index.getSubMap( + new IncrementalIndex.TimeAndDims(timeStart, new int[][]{}), new IncrementalIndex.TimeAndDims( - timeStart, new int[][]{}, null - ), - new IncrementalIndex.TimeAndDims( - Math.min(actualInterval.getEndMillis(), gran.next(input)), new int[][]{}, null + Math.min(actualInterval.getEndMillis(), gran.next(input)), + new int[][]{} ) ); if (descending) {