fix some interval bugs

This commit is contained in:
fjy 2013-04-23 16:53:57 -07:00
parent 7184e528fd
commit 13b617cfa9
4 changed files with 21 additions and 10 deletions

View File

@ -59,7 +59,7 @@
<dependency> <dependency>
<groupId>com.metamx</groupId> <groupId>com.metamx</groupId>
<artifactId>emitter</artifactId> <artifactId>emitter</artifactId>
<version>0.2.0</version> <version>0.2.3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.metamx</groupId> <groupId>com.metamx</groupId>

View File

@ -115,11 +115,14 @@ public class IncrementalIndexStorageAdapter implements StorageAdapter
public Iterable<Cursor> makeCursors(final Filter filter, final Interval interval, final QueryGranularity gran) public Iterable<Cursor> makeCursors(final Filter filter, final Interval interval, final QueryGranularity gran)
{ {
Interval actualIntervalTmp = interval; Interval actualIntervalTmp = interval;
Interval dataInterval = getInterval(); final Interval indexInterval = getInterval();
if (!actualIntervalTmp.overlaps(dataInterval)) {
if (!actualIntervalTmp.overlaps(indexInterval)) {
return ImmutableList.of(); return ImmutableList.of();
} }
final Interval dataInterval = new Interval(getMinTime().getMillis(), gran.next(getMaxTime().getMillis()));
if (actualIntervalTmp.getStart().isBefore(dataInterval.getStart())) { if (actualIntervalTmp.getStart().isBefore(dataInterval.getStart())) {
actualIntervalTmp = actualIntervalTmp.withStart(dataInterval.getStart()); actualIntervalTmp = actualIntervalTmp.withStart(dataInterval.getStart());
} }
@ -367,7 +370,7 @@ public class IncrementalIndexStorageAdapter implements StorageAdapter
final String columnName = column.toLowerCase(); final String columnName = column.toLowerCase();
final Integer metricIndexInt = index.getMetricIndex(columnName); final Integer metricIndexInt = index.getMetricIndex(columnName);
if(metricIndexInt != null) { if (metricIndexInt != null) {
final int metricIndex = metricIndexInt; final int metricIndex = metricIndexInt;
final ComplexMetricSerde serde = ComplexMetrics.getSerdeForType(index.getMetricType(columnName)); final ComplexMetricSerde serde = ComplexMetrics.getSerdeForType(index.getMetricType(columnName));
@ -390,7 +393,7 @@ public class IncrementalIndexStorageAdapter implements StorageAdapter
final Integer dimensionIndexInt = index.getDimensionIndex(columnName); final Integer dimensionIndexInt = index.getDimensionIndex(columnName);
if(dimensionIndexInt != null) { if (dimensionIndexInt != null) {
final int dimensionIndex = dimensionIndexInt; final int dimensionIndex = dimensionIndexInt;
return new ObjectColumnSelector<String>() return new ObjectColumnSelector<String>()
{ {
@ -404,10 +407,14 @@ public class IncrementalIndexStorageAdapter implements StorageAdapter
public String get() public String get()
{ {
final String[] dimVals = currEntry.getKey().getDims()[dimensionIndex]; final String[] dimVals = currEntry.getKey().getDims()[dimensionIndex];
if(dimVals.length == 1) return dimVals[0]; if (dimVals.length == 1) {
if(dimVals.length == 0) return null; return dimVals[0];
}
if (dimVals.length == 0) {
return null;
}
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"makeObjectColumnSelector does not support multivalued columns" "makeObjectColumnSelector does not support multivalued columns"
); );
} }
}; };

View File

@ -137,11 +137,14 @@ public class QueryableIndexStorageAdapter extends BaseStorageAdapter
public Iterable<Cursor> makeCursors(Filter filter, Interval interval, QueryGranularity gran) public Iterable<Cursor> makeCursors(Filter filter, Interval interval, QueryGranularity gran)
{ {
Interval actualInterval = interval; Interval actualInterval = interval;
final Interval dataInterval = getInterval(); final Interval indexInterval = getInterval();
if (!actualInterval.overlaps(dataInterval)) {
if (!actualInterval.overlaps(indexInterval)) {
return ImmutableList.of(); return ImmutableList.of();
} }
final Interval dataInterval = new Interval(getMinTime().getMillis(), gran.next(getMaxTime().getMillis()));
if (actualInterval.getStart().isBefore(dataInterval.getStart())) { if (actualInterval.getStart().isBefore(dataInterval.getStart())) {
actualInterval = actualInterval.withStart(dataInterval.getStart()); actualInterval = actualInterval.withStart(dataInterval.getStart());
} }

View File

@ -21,6 +21,7 @@ package com.metamx.druid.query;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.primitives.Longs;
import com.metamx.common.guava.FunctionalIterable; import com.metamx.common.guava.FunctionalIterable;
import com.metamx.common.logger.Logger; import com.metamx.common.logger.Logger;
import com.metamx.druid.QueryGranularity; import com.metamx.druid.QueryGranularity;