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
|
||||
{
|
||||
private static final byte CACHE_TYPE_ID = 0x6;
|
||||
|
||||
private static final IdentityExtractionFn instance = new IdentityExtractionFn();
|
||||
|
||||
private IdentityExtractionFn()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getCacheKey()
|
||||
{
|
||||
|
@ -71,4 +79,9 @@ public class IdentityExtractionFn implements ExtractionFn
|
|||
{
|
||||
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'");
|
||||
this.value = value;
|
||||
if (extractionFn != null) {
|
||||
this.extractionFn = extractionFn;
|
||||
} else {
|
||||
this.extractionFn = new IdentityExtractionFn();
|
||||
}
|
||||
this.extractionFn = extractionFn != null ? extractionFn : IdentityExtractionFn.getInstance();
|
||||
}
|
||||
|
||||
@JsonProperty("value")
|
||||
|
|
|
@ -121,7 +121,7 @@ public class SearchQueryRunner implements QueryRunner<Result<SearchResultValue>>
|
|||
final BitmapIndex bitmapIndex = column.getBitmapIndex();
|
||||
ExtractionFn extractionFn = dimension.getExtractionFn();
|
||||
if (extractionFn == null) {
|
||||
extractionFn = new IdentityExtractionFn();
|
||||
extractionFn = IdentityExtractionFn.getInstance();
|
||||
}
|
||||
if (bitmapIndex != null) {
|
||||
for (int i = 0; i < bitmapIndex.getCardinality(); ++i) {
|
||||
|
|
|
@ -35,13 +35,13 @@ public class ExtractionDimFilterTest
|
|||
ExtractionDimFilter extractionDimFilter = new ExtractionDimFilter(
|
||||
"abc",
|
||||
"d",
|
||||
new IdentityExtractionFn(),
|
||||
IdentityExtractionFn.getInstance(),
|
||||
null
|
||||
);
|
||||
ExtractionDimFilter extractionDimFilter2 = new ExtractionDimFilter(
|
||||
"ab",
|
||||
"cd",
|
||||
new IdentityExtractionFn(),
|
||||
IdentityExtractionFn.getInstance(),
|
||||
null
|
||||
);
|
||||
|
||||
|
|
|
@ -162,7 +162,7 @@ public class DimensionSelectorHavingSpecTest
|
|||
@Test
|
||||
public void testGetCacheKey()
|
||||
{
|
||||
ExtractionFn extractionFn = new IdentityExtractionFn();
|
||||
ExtractionFn extractionFn = IdentityExtractionFn.getInstance();
|
||||
byte[] dimBytes = "dimension".getBytes(Charsets.UTF_8);
|
||||
byte[] valBytes = "v".getBytes(Charsets.UTF_8);
|
||||
byte[] extFunKey = extractionFn.getCacheKey();
|
||||
|
|
Loading…
Reference in New Issue