[NO ISSUE][STO]Ensure Bloom filters are not built for secondary indexes
- user model changes: no
- storage format changes: no
- interface changes: no
Details:
- Calculate bloom filter fields properly based on the index type
so that we do not build unnecessary bloom filters for secondary indexes.
Change-Id: Ib4272e5278bf76fa78af36ccf10d516da12c4810
Reviewed-on: https://asterix-gerrit.ics.uci.edu/3366
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Murtadha Hubail <mhubail@apache.org>
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/TestLsmBTreeResourceFactoryProvider.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/TestLsmBTreeResourceFactoryProvider.java
index 8d37878..9a0cd5a 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/TestLsmBTreeResourceFactoryProvider.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/dataflow/TestLsmBTreeResourceFactoryProvider.java
@@ -22,6 +22,7 @@
import java.util.Map;
import org.apache.asterix.common.config.DatasetConfig.DatasetType;
+import org.apache.asterix.common.config.DatasetConfig.IndexType;
import org.apache.asterix.common.context.AsterixVirtualBufferCacheProvider;
import org.apache.asterix.common.context.IStorageComponentProvider;
import org.apache.asterix.external.indexing.FilesIndexDescription;
@@ -155,7 +156,8 @@
}
private static int[] getBloomFilterFields(Dataset dataset, Index index) throws AlgebricksException {
- if (index.isPrimaryIndex()) {
+ // both the Primary index and the Primary Key index have bloom filters
+ if (index.isPrimaryIndex() || index.isPrimaryKeyIndex()) {
return dataset.getPrimaryBloomFilterFields();
} else if (dataset.getDatasetType() == DatasetType.EXTERNAL) {
if (index.getIndexName().equals(IndexingConstants.getFilesIndexName(dataset.getDatasetName()))) {
@@ -163,12 +165,17 @@
} else {
return new int[] { index.getKeyFieldNames().size() };
}
+ } else if (index.getIndexType() == IndexType.BTREE || index.getIndexType() == IndexType.RTREE) {
+ // secondary btrees and rtrees do not have bloom filters
+ return null;
+ } else {
+ // inverted indexes have bloom filters on deleted-key btrees
+ int numKeys = index.getKeyFieldNames().size();
+ int[] bloomFilterKeyFields = new int[numKeys];
+ for (int i = 0; i < numKeys; i++) {
+ bloomFilterKeyFields[i] = i;
+ }
+ return bloomFilterKeyFields;
}
- int numKeys = index.getKeyFieldNames().size();
- int[] bloomFilterKeyFields = new int[numKeys];
- for (int i = 0; i < numKeys; i++) {
- bloomFilterKeyFields[i] = i;
- }
- return bloomFilterKeyFields;
}
}
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/BTreeResourceFactoryProvider.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/BTreeResourceFactoryProvider.java
index 883da84..21fafaf6a 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/BTreeResourceFactoryProvider.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/BTreeResourceFactoryProvider.java
@@ -22,6 +22,7 @@
import java.util.Map;
import org.apache.asterix.common.config.DatasetConfig.DatasetType;
+import org.apache.asterix.common.config.DatasetConfig.IndexType;
import org.apache.asterix.common.context.AsterixVirtualBufferCacheProvider;
import org.apache.asterix.common.context.IStorageComponentProvider;
import org.apache.asterix.common.exceptions.CompilationException;
@@ -194,12 +195,17 @@
} else {
return new int[] { index.getKeyFieldNames().size() };
}
+ } else if (index.getIndexType() == IndexType.BTREE || index.getIndexType() == IndexType.RTREE) {
+ // secondary btrees and rtrees do not have bloom filters
+ return null;
+ } else {
+ // inverted indexes have bloom filters on deleted-key btrees
+ int numKeys = index.getKeyFieldNames().size();
+ int[] bloomFilterKeyFields = new int[numKeys];
+ for (int i = 0; i < numKeys; i++) {
+ bloomFilterKeyFields[i] = i;
+ }
+ return bloomFilterKeyFields;
}
- int numKeys = index.getKeyFieldNames().size();
- int[] bloomFilterKeyFields = new int[numKeys];
- for (int i = 0; i < numKeys; i++) {
- bloomFilterKeyFields[i] = i;
- }
- return bloomFilterKeyFields;
}
}