mirror of https://github.com/apache/druid.git
Merge pull request #2101 from himanshug/fix_extraction_dim_filter_cache_key
add extractionFn bytes to cache key in ExtractionDimFilter
This commit is contained in:
commit
71f554bf80
|
@ -78,12 +78,14 @@ public class ExtractionDimFilter implements DimFilter
|
|||
{
|
||||
byte[] dimensionBytes = StringUtils.toUtf8(dimension);
|
||||
byte[] valueBytes = StringUtils.toUtf8(value);
|
||||
|
||||
return ByteBuffer.allocate(2 + dimensionBytes.length + valueBytes.length)
|
||||
byte[] extractionFnBytes = extractionFn.getCacheKey();
|
||||
return ByteBuffer.allocate(3 + dimensionBytes.length + valueBytes.length + extractionFnBytes.length)
|
||||
.put(DimFilterCacheHelper.EXTRACTION_CACHE_ID)
|
||||
.put(dimensionBytes)
|
||||
.put(DimFilterCacheHelper.STRING_SEPARATOR)
|
||||
.put(valueBytes)
|
||||
.put(DimFilterCacheHelper.STRING_SEPARATOR)
|
||||
.put(extractionFnBytes)
|
||||
.array();
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
|
||||
package io.druid.query.filter;
|
||||
|
||||
import io.druid.query.extraction.ExtractionFn;
|
||||
import org.easymock.EasyMock;
|
||||
import io.druid.query.extraction.IdentityExtractionFn;
|
||||
import io.druid.query.extraction.RegexDimExtractionFn;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -35,15 +35,25 @@ public class ExtractionDimFilterTest
|
|||
ExtractionDimFilter extractionDimFilter = new ExtractionDimFilter(
|
||||
"abc",
|
||||
"d",
|
||||
EasyMock.createMock(ExtractionFn.class),
|
||||
new IdentityExtractionFn(),
|
||||
null
|
||||
);
|
||||
ExtractionDimFilter extractionDimFilter2 = new ExtractionDimFilter(
|
||||
"ab",
|
||||
"cd",
|
||||
EasyMock.createMock(ExtractionFn.class),
|
||||
new IdentityExtractionFn(),
|
||||
null
|
||||
);
|
||||
|
||||
Assert.assertFalse(Arrays.equals(extractionDimFilter.getCacheKey(), extractionDimFilter2.getCacheKey()));
|
||||
|
||||
ExtractionDimFilter extractionDimFilter3 = new ExtractionDimFilter(
|
||||
"ab",
|
||||
"cd",
|
||||
new RegexDimExtractionFn("xx", null, null),
|
||||
null
|
||||
);
|
||||
|
||||
Assert.assertFalse(Arrays.equals(extractionDimFilter2.getCacheKey(), extractionDimFilter3.getCacheKey()));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue