diff --git a/index-common/src/main/java/com/metamx/druid/index/v1/IncrementalIndex.java b/index-common/src/main/java/com/metamx/druid/index/v1/IncrementalIndex.java index 19719755058..4141ce9d3a1 100644 --- a/index-common/src/main/java/com/metamx/druid/index/v1/IncrementalIndex.java +++ b/index-common/src/main/java/com/metamx/druid/index/v1/IncrementalIndex.java @@ -356,6 +356,11 @@ public class IncrementalIndex implements Iterable return spatialDimensions; } + public SpatialDimensionRowFormatter getSpatialDimensionRowFormatter() + { + return spatialDimensionRowFormatter; + } + public String getMetricType(String metric) { return metricTypes.get(metric); diff --git a/index-common/src/main/java/com/metamx/druid/index/v1/SpatialDimensionRowFormatter.java b/index-common/src/main/java/com/metamx/druid/index/v1/SpatialDimensionRowFormatter.java index fc5ac79cc6f..de358cb923b 100644 --- a/index-common/src/main/java/com/metamx/druid/index/v1/SpatialDimensionRowFormatter.java +++ b/index-common/src/main/java/com/metamx/druid/index/v1/SpatialDimensionRowFormatter.java @@ -122,6 +122,10 @@ public class SpatialDimensionRowFormatter }; for (SpatialDimensionSchema spatialDimension : spatialDimensions) { + if (!row.getDimension(spatialDimension.getDimName()).isEmpty()) { + continue; + } + List spatialDimVals = Lists.newArrayList(); for (String partialSpatialDim : spatialDimension.getDims()) { @@ -131,7 +135,7 @@ public class SpatialDimensionRowFormatter } } - if (!spatialDimVals.isEmpty()) { + if (spatialDimVals.size() == spatialDimNames.size()) { spatialLookup.put(spatialDimension.getDimName(), Arrays.asList(JOINER.join(spatialDimVals))); finalDims.add(spatialDimension.getDimName()); } diff --git a/index-common/src/main/java/com/metamx/druid/indexer/data/JSONDataSpec.java b/index-common/src/main/java/com/metamx/druid/indexer/data/JSONDataSpec.java index 8b12aa601e6..0f07161b4bf 100644 --- a/index-common/src/main/java/com/metamx/druid/indexer/data/JSONDataSpec.java +++ b/index-common/src/main/java/com/metamx/druid/indexer/data/JSONDataSpec.java @@ -19,6 +19,7 @@ package com.metamx.druid.indexer.data; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.collect.Lists; import com.metamx.common.parsers.JSONParser; @@ -34,6 +35,7 @@ public class JSONDataSpec implements DataSpec private final List dimensions; private final List spatialDimensions; + @JsonCreator public JSONDataSpec( @JsonProperty("dimensions") List dimensions, @JsonProperty("spatialDimensions") List spatialDimensions diff --git a/indexer/src/main/java/com/metamx/druid/indexer/IndexGeneratorJob.java b/indexer/src/main/java/com/metamx/druid/indexer/IndexGeneratorJob.java index 2c8cf82d822..45cbded7f1a 100644 --- a/indexer/src/main/java/com/metamx/druid/indexer/IndexGeneratorJob.java +++ b/indexer/src/main/java/com/metamx/druid/indexer/IndexGeneratorJob.java @@ -280,7 +280,7 @@ public class IndexGeneratorJob implements Jobby for (final Text value : values) { context.progress(); - final InputRow inputRow = parser.parse(value.toString()); + final InputRow inputRow = index.getSpatialDimensionRowFormatter().formatRow(parser.parse(value.toString())); allDimensionNames.addAll(inputRow.getDimensions()); int numRows = index.add(inputRow); diff --git a/server/src/main/java/com/metamx/druid/index/brita/SpatialFilter.java b/server/src/main/java/com/metamx/druid/index/brita/SpatialFilter.java index 52a37be7f8a..2abb55035fe 100644 --- a/server/src/main/java/com/metamx/druid/index/brita/SpatialFilter.java +++ b/server/src/main/java/com/metamx/druid/index/brita/SpatialFilter.java @@ -58,7 +58,7 @@ public class SpatialFilter implements Filter @Override public boolean hasNext() { - return dimValueIndexesIter.hasNext() || iter.hasNext(); + return dimValueIndexesIter.hasNext() || (iter != null && iter.hasNext()); } @Override