mirror of https://github.com/apache/druid.git
Merge pull request #2219 from himanshug/identity_extraction_fn_singleton
make IdentityExtractionFn singleton
This commit is contained in:
commit
4ecd901a1a
|
@ -24,6 +24,14 @@ import com.google.common.base.Strings;
|
||||||
public class IdentityExtractionFn implements ExtractionFn
|
public class IdentityExtractionFn implements ExtractionFn
|
||||||
{
|
{
|
||||||
private static final byte CACHE_TYPE_ID = 0x6;
|
private static final byte CACHE_TYPE_ID = 0x6;
|
||||||
|
|
||||||
|
private static final IdentityExtractionFn instance = new IdentityExtractionFn();
|
||||||
|
|
||||||
|
private IdentityExtractionFn()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] getCacheKey()
|
public byte[] getCacheKey()
|
||||||
{
|
{
|
||||||
|
@ -71,4 +79,9 @@ public class IdentityExtractionFn implements ExtractionFn
|
||||||
{
|
{
|
||||||
return o != null && o instanceof IdentityExtractionFn;
|
return o != null && o instanceof IdentityExtractionFn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final IdentityExtractionFn getInstance()
|
||||||
|
{
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,11 +48,7 @@ public class DimensionSelectorHavingSpec implements HavingSpec
|
||||||
{
|
{
|
||||||
dimension = Preconditions.checkNotNull(dimName, "Must have attribute 'dimension'");
|
dimension = Preconditions.checkNotNull(dimName, "Must have attribute 'dimension'");
|
||||||
this.value = value;
|
this.value = value;
|
||||||
if (extractionFn != null) {
|
this.extractionFn = extractionFn != null ? extractionFn : IdentityExtractionFn.getInstance();
|
||||||
this.extractionFn = extractionFn;
|
|
||||||
} else {
|
|
||||||
this.extractionFn = new IdentityExtractionFn();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonProperty("value")
|
@JsonProperty("value")
|
||||||
|
|
|
@ -121,7 +121,7 @@ public class SearchQueryRunner implements QueryRunner<Result<SearchResultValue>>
|
||||||
final BitmapIndex bitmapIndex = column.getBitmapIndex();
|
final BitmapIndex bitmapIndex = column.getBitmapIndex();
|
||||||
ExtractionFn extractionFn = dimension.getExtractionFn();
|
ExtractionFn extractionFn = dimension.getExtractionFn();
|
||||||
if (extractionFn == null) {
|
if (extractionFn == null) {
|
||||||
extractionFn = new IdentityExtractionFn();
|
extractionFn = IdentityExtractionFn.getInstance();
|
||||||
}
|
}
|
||||||
if (bitmapIndex != null) {
|
if (bitmapIndex != null) {
|
||||||
for (int i = 0; i < bitmapIndex.getCardinality(); ++i) {
|
for (int i = 0; i < bitmapIndex.getCardinality(); ++i) {
|
||||||
|
|
|
@ -35,13 +35,13 @@ public class ExtractionDimFilterTest
|
||||||
ExtractionDimFilter extractionDimFilter = new ExtractionDimFilter(
|
ExtractionDimFilter extractionDimFilter = new ExtractionDimFilter(
|
||||||
"abc",
|
"abc",
|
||||||
"d",
|
"d",
|
||||||
new IdentityExtractionFn(),
|
IdentityExtractionFn.getInstance(),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
ExtractionDimFilter extractionDimFilter2 = new ExtractionDimFilter(
|
ExtractionDimFilter extractionDimFilter2 = new ExtractionDimFilter(
|
||||||
"ab",
|
"ab",
|
||||||
"cd",
|
"cd",
|
||||||
new IdentityExtractionFn(),
|
IdentityExtractionFn.getInstance(),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -162,7 +162,7 @@ public class DimensionSelectorHavingSpecTest
|
||||||
@Test
|
@Test
|
||||||
public void testGetCacheKey()
|
public void testGetCacheKey()
|
||||||
{
|
{
|
||||||
ExtractionFn extractionFn = new IdentityExtractionFn();
|
ExtractionFn extractionFn = IdentityExtractionFn.getInstance();
|
||||||
byte[] dimBytes = "dimension".getBytes(Charsets.UTF_8);
|
byte[] dimBytes = "dimension".getBytes(Charsets.UTF_8);
|
||||||
byte[] valBytes = "v".getBytes(Charsets.UTF_8);
|
byte[] valBytes = "v".getBytes(Charsets.UTF_8);
|
||||||
byte[] extFunKey = extractionFn.getCacheKey();
|
byte[] extFunKey = extractionFn.getCacheKey();
|
||||||
|
|
Loading…
Reference in New Issue