This is an automated email from the ASF dual-hosted git repository. kharekartik pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push: new 1d02d0eb50 Index spi: all types (#10193) 1d02d0eb50 is described below commit 1d02d0eb50da0cc32d08dfee3676f98c3cdbe8f4 Author: Gonzalo Ortiz Jaureguizar <gor...@users.noreply.github.com> AuthorDate: Tue Mar 28 08:47:08 2023 +0200 Index spi: all types (#10193) * Draft commit with the IndexType draft * Draft commit with the IndexService draft * Draft commit with simplified version of all index types * Simplify IndexType with tons of UnsupportedOperationException * Remove BloomIndexType to make this code compile * Recover simplified BloomIndexType * Fix an error on IndexService * Add all types to StandardIndexes * Fix two checkstyle issues * supress unchecked cast warning in StandardIndexes.java * Remove segment dir param from IndexReaderFactory.read * Improve javadoc on IndexType.deserialize * Declare a constant before attributes * Remove unused @JsonIgnore annotation * Remove IndexDeclaration. Use the single config deserialize method instead * Improve BloomIndexType example * remove alternativeSingleValue method from IndexCreator * Change FieldIndexConfigs.Builder to do not accept null configs * Rename add methods in IndexCreator as `add` * Rename IndexType.deserialize as IndexType.getConfig * Rename IndexReaderFactory.read as IndexReaderFactory.createIndexReader * Remove copy of IndexHandler * Move IndexHandler to org.apache.pinot.segment.spi.index from org.apache.pinot.segment.local.segment.index.loader * Add FieldIndexConfigs.toString * Add javadoc * Remove indexName concept * Update code to index-spi * Update all index types to have implementation all required methods * Apply some stetical changes recommended in the PR * Improve javadoc * Fix typo in javadoc * Add some changes included in index-spi-all-types * Add javadoc to StandardIndexes * Add javadoc and make _allIndexes immutable * Add javadoc on IndexPlugin * Remove unused import * Add more javadoc * Define standard index ids in StandardIndexes * Add a map from id to index types * Add exit_criteria to TODO comment in OnHeapGuavaBloomFilterCreator * Changed javadoc for IndexService * Rename get and getOrThrow as getOptional or get * Cache reader factory instance * Make DEFAULT final class public * Make IndexService private * make constructor private * add DEFAULT_RANGE_INDEX_VERSION * add empty lines between class decl, contant and constructor --- .../local/segment/index/bloom/BloomIndexType.java | 3 +- .../index/dictionary/DictionaryIndexPlugin.java | 32 +++++++ .../index/dictionary/DictionaryIndexType.java | 92 ++++++++++++++++++ .../segment/index/forward/ForwardIndexPlugin.java | 32 +++++++ .../segment/index/forward/ForwardIndexType.java | 105 +++++++++++++++++++++ .../local/segment/index/fst/FstIndexPlugin.java | 32 +++++++ .../local/segment/index/fst/FstIndexType.java | 92 ++++++++++++++++++ .../local/segment/index/h3/H3IndexPlugin.java | 32 +++++++ .../local/segment/index/h3/H3IndexType.java | 93 ++++++++++++++++++ .../index/inverted/InvertedIndexPlugin.java | 32 +++++++ .../segment/index/inverted/InvertedIndexType.java | 92 ++++++++++++++++++ .../local/segment/index/json/JsonIndexPlugin.java | 32 +++++++ .../local/segment/index/json/JsonIndexType.java | 92 ++++++++++++++++++ .../index/nullvalue/NullValueIndexPlugin.java | 32 +++++++ .../index/nullvalue/NullValueIndexType.java | 93 ++++++++++++++++++ .../segment/index/range/RangeIndexPlugin.java | 32 +++++++ .../local/segment/index/range/RangeIndexType.java | 99 +++++++++++++++++++ .../local/segment/index/text/TextIndexPlugin.java | 32 +++++++ .../local/segment/index/text/TextIndexType.java | 93 ++++++++++++++++++ .../pinot/segment/spi/index/StandardIndexes.java | 53 ++++++++++- 20 files changed, 1189 insertions(+), 6 deletions(-) diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/bloom/BloomIndexType.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/bloom/BloomIndexType.java index 4d8ae842e9..402f39b380 100644 --- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/bloom/BloomIndexType.java +++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/bloom/BloomIndexType.java @@ -31,6 +31,7 @@ import org.apache.pinot.segment.spi.index.FieldIndexConfigs; import org.apache.pinot.segment.spi.index.IndexHandler; import org.apache.pinot.segment.spi.index.IndexReaderFactory; import org.apache.pinot.segment.spi.index.IndexType; +import org.apache.pinot.segment.spi.index.StandardIndexes; import org.apache.pinot.segment.spi.index.creator.BloomFilterCreator; import org.apache.pinot.segment.spi.index.reader.BloomFilterReader; import org.apache.pinot.segment.spi.memory.PinotDataBuffer; @@ -44,7 +45,7 @@ public class BloomIndexType implements IndexType<BloomFilterConfig, BloomFilterR @Override public String getId() { - return "bloom_filter"; + return StandardIndexes.BLOOM_FILTER_ID; } @Override diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/dictionary/DictionaryIndexPlugin.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/dictionary/DictionaryIndexPlugin.java new file mode 100644 index 0000000000..ccb3a63bf0 --- /dev/null +++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/dictionary/DictionaryIndexPlugin.java @@ -0,0 +1,32 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.pinot.segment.local.segment.index.dictionary; + +import com.google.auto.service.AutoService; +import org.apache.pinot.segment.spi.index.IndexPlugin; + + +@AutoService(IndexPlugin.class) +public class DictionaryIndexPlugin implements IndexPlugin<DictionaryIndexType> { + @Override + public DictionaryIndexType getIndexType() { + return DictionaryIndexType.INSTANCE; + } +} diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/dictionary/DictionaryIndexType.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/dictionary/DictionaryIndexType.java new file mode 100644 index 0000000000..23eaf046e1 --- /dev/null +++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/dictionary/DictionaryIndexType.java @@ -0,0 +1,92 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.pinot.segment.local.segment.index.dictionary; + +import java.util.Map; +import javax.annotation.Nullable; +import org.apache.pinot.segment.spi.ColumnMetadata; +import org.apache.pinot.segment.spi.V1Constants; +import org.apache.pinot.segment.spi.creator.IndexCreationContext; +import org.apache.pinot.segment.spi.index.FieldIndexConfigs; +import org.apache.pinot.segment.spi.index.IndexCreator; +import org.apache.pinot.segment.spi.index.IndexHandler; +import org.apache.pinot.segment.spi.index.IndexReader; +import org.apache.pinot.segment.spi.index.IndexReaderFactory; +import org.apache.pinot.segment.spi.index.IndexType; +import org.apache.pinot.segment.spi.index.StandardIndexes; +import org.apache.pinot.segment.spi.store.SegmentDirectory; +import org.apache.pinot.spi.config.table.IndexConfig; +import org.apache.pinot.spi.config.table.TableConfig; +import org.apache.pinot.spi.data.Schema; + + +public class DictionaryIndexType implements IndexType<IndexConfig, IndexReader, IndexCreator> { + public static final DictionaryIndexType INSTANCE = new DictionaryIndexType(); + + private DictionaryIndexType() { + } + + @Override + public String getId() { + return StandardIndexes.DICTIONARY_ID; + } + + @Override + public Class<IndexConfig> getIndexConfigClass() { + return IndexConfig.class; + } + + @Override + public IndexConfig getDefaultConfig() { + return IndexConfig.DISABLED; + } + + @Override + public IndexConfig getConfig(TableConfig tableConfig, Schema schema) { + throw new UnsupportedOperationException(); + } + + @Override + public IndexCreator createIndexCreator(IndexCreationContext context, IndexConfig indexConfig) + throws Exception { + throw new UnsupportedOperationException(); + } + + @Override + public IndexReaderFactory<IndexReader> getReaderFactory() { + throw new UnsupportedOperationException(); + } + + @Override + public IndexHandler createIndexHandler(SegmentDirectory segmentDirectory, Map<String, FieldIndexConfigs> configsByCol, + @Nullable Schema schema, @Nullable TableConfig tableConfig) { + throw new UnsupportedOperationException(); + } + + @Override + public String getFileExtension(ColumnMetadata columnMetadata) { + return V1Constants.Dict.FILE_EXTENSION; + } + + @Override + public String toString() { + return getId(); + } +} diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/forward/ForwardIndexPlugin.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/forward/ForwardIndexPlugin.java new file mode 100644 index 0000000000..486d4dc359 --- /dev/null +++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/forward/ForwardIndexPlugin.java @@ -0,0 +1,32 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.pinot.segment.local.segment.index.forward; + +import com.google.auto.service.AutoService; +import org.apache.pinot.segment.spi.index.IndexPlugin; + + +@AutoService(IndexPlugin.class) +public class ForwardIndexPlugin implements IndexPlugin<ForwardIndexType> { + @Override + public ForwardIndexType getIndexType() { + return ForwardIndexType.INSTANCE; + } +} diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/forward/ForwardIndexType.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/forward/ForwardIndexType.java new file mode 100644 index 0000000000..5cdb7de8e2 --- /dev/null +++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/forward/ForwardIndexType.java @@ -0,0 +1,105 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.pinot.segment.local.segment.index.forward; + +import java.util.Map; +import javax.annotation.Nullable; +import org.apache.pinot.segment.spi.ColumnMetadata; +import org.apache.pinot.segment.spi.V1Constants; +import org.apache.pinot.segment.spi.creator.IndexCreationContext; +import org.apache.pinot.segment.spi.index.FieldIndexConfigs; +import org.apache.pinot.segment.spi.index.IndexCreator; +import org.apache.pinot.segment.spi.index.IndexHandler; +import org.apache.pinot.segment.spi.index.IndexReader; +import org.apache.pinot.segment.spi.index.IndexReaderFactory; +import org.apache.pinot.segment.spi.index.IndexType; +import org.apache.pinot.segment.spi.index.StandardIndexes; +import org.apache.pinot.segment.spi.store.SegmentDirectory; +import org.apache.pinot.spi.config.table.IndexConfig; +import org.apache.pinot.spi.config.table.TableConfig; +import org.apache.pinot.spi.data.Schema; + + +public class ForwardIndexType implements IndexType<IndexConfig, IndexReader, IndexCreator> { + + public static final ForwardIndexType INSTANCE = new ForwardIndexType(); + + private ForwardIndexType() { + } + + @Override + public String getId() { + return StandardIndexes.FORWARD_ID; + } + + @Override + public Class<IndexConfig> getIndexConfigClass() { + return null; + } + + @Override + public IndexConfig getDefaultConfig() { + return IndexConfig.ENABLED; + } + + @Override + public IndexConfig getConfig(TableConfig tableConfig, Schema schema) { + throw new UnsupportedOperationException(); + } + + @Override + public IndexCreator createIndexCreator(IndexCreationContext context, IndexConfig indexConfig) + throws Exception { + throw new UnsupportedOperationException(); + } + + @Override + public IndexReaderFactory<IndexReader> getReaderFactory() { + throw new UnsupportedOperationException(); + } + + @Override + public String getFileExtension(ColumnMetadata columnMetadata) { + if (columnMetadata.isSingleValue()) { + if (!columnMetadata.hasDictionary()) { + return V1Constants.Indexes.RAW_SV_FORWARD_INDEX_FILE_EXTENSION; + } else if (columnMetadata.isSorted()) { + return V1Constants.Indexes.SORTED_SV_FORWARD_INDEX_FILE_EXTENSION; + } else { + return V1Constants.Indexes.UNSORTED_SV_FORWARD_INDEX_FILE_EXTENSION; + } + } else if (!columnMetadata.hasDictionary()) { + return V1Constants.Indexes.RAW_MV_FORWARD_INDEX_FILE_EXTENSION; + } else { + return V1Constants.Indexes.UNSORTED_MV_FORWARD_INDEX_FILE_EXTENSION; + } + } + + @Override + public IndexHandler createIndexHandler(SegmentDirectory segmentDirectory, Map<String, FieldIndexConfigs> configsByCol, + @Nullable Schema schema, @Nullable TableConfig tableConfig) { + throw new UnsupportedOperationException(); + } + + @Override + public String toString() { + return getId(); + } +} diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/fst/FstIndexPlugin.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/fst/FstIndexPlugin.java new file mode 100644 index 0000000000..fec6c05057 --- /dev/null +++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/fst/FstIndexPlugin.java @@ -0,0 +1,32 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.pinot.segment.local.segment.index.fst; + +import com.google.auto.service.AutoService; +import org.apache.pinot.segment.spi.index.IndexPlugin; + + +@AutoService(IndexPlugin.class) +public class FstIndexPlugin implements IndexPlugin<FstIndexType> { + @Override + public FstIndexType getIndexType() { + return FstIndexType.INSTANCE; + } +} diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/fst/FstIndexType.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/fst/FstIndexType.java new file mode 100644 index 0000000000..227b7f6f96 --- /dev/null +++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/fst/FstIndexType.java @@ -0,0 +1,92 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.pinot.segment.local.segment.index.fst; + +import java.util.Map; +import javax.annotation.Nullable; +import org.apache.pinot.segment.spi.ColumnMetadata; +import org.apache.pinot.segment.spi.V1Constants; +import org.apache.pinot.segment.spi.creator.IndexCreationContext; +import org.apache.pinot.segment.spi.index.FieldIndexConfigs; +import org.apache.pinot.segment.spi.index.IndexCreator; +import org.apache.pinot.segment.spi.index.IndexHandler; +import org.apache.pinot.segment.spi.index.IndexReader; +import org.apache.pinot.segment.spi.index.IndexReaderFactory; +import org.apache.pinot.segment.spi.index.IndexType; +import org.apache.pinot.segment.spi.index.StandardIndexes; +import org.apache.pinot.segment.spi.store.SegmentDirectory; +import org.apache.pinot.spi.config.table.IndexConfig; +import org.apache.pinot.spi.config.table.TableConfig; +import org.apache.pinot.spi.data.Schema; + + +public class FstIndexType implements IndexType<IndexConfig, IndexReader, IndexCreator> { + public static final FstIndexType INSTANCE = new FstIndexType(); + + private FstIndexType() { + } + + @Override + public String getId() { + return StandardIndexes.FST_ID; + } + + @Override + public Class<IndexConfig> getIndexConfigClass() { + return IndexConfig.class; + } + + @Override + public IndexConfig getDefaultConfig() { + return IndexConfig.DISABLED; + } + + @Override + public IndexConfig getConfig(TableConfig tableConfig, Schema schema) { + throw new UnsupportedOperationException(); + } + + @Override + public IndexCreator createIndexCreator(IndexCreationContext context, IndexConfig indexConfig) + throws Exception { + throw new UnsupportedOperationException(); + } + + @Override + public IndexReaderFactory<IndexReader> getReaderFactory() { + throw new UnsupportedOperationException(); + } + + @Override + public IndexHandler createIndexHandler(SegmentDirectory segmentDirectory, Map<String, FieldIndexConfigs> configsByCol, + @Nullable Schema schema, @Nullable TableConfig tableConfig) { + throw new UnsupportedOperationException(); + } + + @Override + public String getFileExtension(ColumnMetadata columnMetadata) { + return V1Constants.Indexes.FST_INDEX_FILE_EXTENSION; + } + + @Override + public String toString() { + return getId(); + } +} diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/h3/H3IndexPlugin.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/h3/H3IndexPlugin.java new file mode 100644 index 0000000000..854bcda08a --- /dev/null +++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/h3/H3IndexPlugin.java @@ -0,0 +1,32 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.pinot.segment.local.segment.index.h3; + +import com.google.auto.service.AutoService; +import org.apache.pinot.segment.spi.index.IndexPlugin; + + +@AutoService(IndexPlugin.class) +public class H3IndexPlugin implements IndexPlugin<H3IndexType> { + @Override + public H3IndexType getIndexType() { + return H3IndexType.INSTANCE; + } +} diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/h3/H3IndexType.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/h3/H3IndexType.java new file mode 100644 index 0000000000..7438e7b08a --- /dev/null +++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/h3/H3IndexType.java @@ -0,0 +1,93 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.pinot.segment.local.segment.index.h3; + +import java.util.Map; +import javax.annotation.Nullable; +import org.apache.pinot.segment.spi.ColumnMetadata; +import org.apache.pinot.segment.spi.V1Constants; +import org.apache.pinot.segment.spi.creator.IndexCreationContext; +import org.apache.pinot.segment.spi.index.FieldIndexConfigs; +import org.apache.pinot.segment.spi.index.IndexCreator; +import org.apache.pinot.segment.spi.index.IndexHandler; +import org.apache.pinot.segment.spi.index.IndexReader; +import org.apache.pinot.segment.spi.index.IndexReaderFactory; +import org.apache.pinot.segment.spi.index.IndexType; +import org.apache.pinot.segment.spi.index.StandardIndexes; +import org.apache.pinot.segment.spi.store.SegmentDirectory; +import org.apache.pinot.spi.config.table.IndexConfig; +import org.apache.pinot.spi.config.table.TableConfig; +import org.apache.pinot.spi.data.Schema; + + +public class H3IndexType implements IndexType<IndexConfig, IndexReader, IndexCreator> { + + public static final H3IndexType INSTANCE = new H3IndexType(); + + private H3IndexType() { + } + + @Override + public String getId() { + return StandardIndexes.H3_ID; + } + + @Override + public Class<IndexConfig> getIndexConfigClass() { + return IndexConfig.class; + } + + @Override + public IndexConfig getDefaultConfig() { + return IndexConfig.DISABLED; + } + + @Override + public IndexConfig getConfig(TableConfig tableConfig, Schema schema) { + throw new UnsupportedOperationException(); + } + + @Override + public IndexCreator createIndexCreator(IndexCreationContext context, IndexConfig indexConfig) + throws Exception { + throw new UnsupportedOperationException(); + } + + @Override + public IndexReaderFactory<IndexReader> getReaderFactory() { + throw new UnsupportedOperationException(); + } + + @Override + public IndexHandler createIndexHandler(SegmentDirectory segmentDirectory, Map<String, FieldIndexConfigs> configsByCol, + @Nullable Schema schema, @Nullable TableConfig tableConfig) { + throw new UnsupportedOperationException(); + } + + @Override + public String getFileExtension(ColumnMetadata columnMetadata) { + return V1Constants.Indexes.H3_INDEX_FILE_EXTENSION; + } + + @Override + public String toString() { + return getId(); + } +} diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/inverted/InvertedIndexPlugin.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/inverted/InvertedIndexPlugin.java new file mode 100644 index 0000000000..6fc4b3f54f --- /dev/null +++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/inverted/InvertedIndexPlugin.java @@ -0,0 +1,32 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.pinot.segment.local.segment.index.inverted; + +import com.google.auto.service.AutoService; +import org.apache.pinot.segment.spi.index.IndexPlugin; + + +@AutoService(IndexPlugin.class) +public class InvertedIndexPlugin implements IndexPlugin<InvertedIndexType> { + @Override + public InvertedIndexType getIndexType() { + return InvertedIndexType.INSTANCE; + } +} diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/inverted/InvertedIndexType.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/inverted/InvertedIndexType.java new file mode 100644 index 0000000000..31761c208b --- /dev/null +++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/inverted/InvertedIndexType.java @@ -0,0 +1,92 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.pinot.segment.local.segment.index.inverted; + +import java.util.Map; +import javax.annotation.Nullable; +import org.apache.pinot.segment.spi.ColumnMetadata; +import org.apache.pinot.segment.spi.V1Constants; +import org.apache.pinot.segment.spi.creator.IndexCreationContext; +import org.apache.pinot.segment.spi.index.FieldIndexConfigs; +import org.apache.pinot.segment.spi.index.IndexCreator; +import org.apache.pinot.segment.spi.index.IndexHandler; +import org.apache.pinot.segment.spi.index.IndexReader; +import org.apache.pinot.segment.spi.index.IndexReaderFactory; +import org.apache.pinot.segment.spi.index.IndexType; +import org.apache.pinot.segment.spi.index.StandardIndexes; +import org.apache.pinot.segment.spi.store.SegmentDirectory; +import org.apache.pinot.spi.config.table.IndexConfig; +import org.apache.pinot.spi.config.table.TableConfig; +import org.apache.pinot.spi.data.Schema; + + +public class InvertedIndexType implements IndexType<IndexConfig, IndexReader, IndexCreator> { + public static final InvertedIndexType INSTANCE = new InvertedIndexType(); + + private InvertedIndexType() { + } + + @Override + public String getId() { + return StandardIndexes.INVERTED_ID; + } + + @Override + public Class<IndexConfig> getIndexConfigClass() { + return IndexConfig.class; + } + + @Override + public IndexConfig getDefaultConfig() { + return IndexConfig.DISABLED; + } + + @Override + public IndexConfig getConfig(TableConfig tableConfig, Schema schema) { + throw new UnsupportedOperationException(); + } + + @Override + public IndexCreator createIndexCreator(IndexCreationContext context, IndexConfig indexConfig) + throws Exception { + throw new UnsupportedOperationException(); + } + + @Override + public IndexReaderFactory<IndexReader> getReaderFactory() { + throw new UnsupportedOperationException(); + } + + @Override + public IndexHandler createIndexHandler(SegmentDirectory segmentDirectory, Map<String, FieldIndexConfigs> configsByCol, + @Nullable Schema schema, @Nullable TableConfig tableConfig) { + throw new UnsupportedOperationException(); + } + + @Override + public String getFileExtension(ColumnMetadata columnMetadata) { + return V1Constants.Indexes.BITMAP_INVERTED_INDEX_FILE_EXTENSION; + } + + @Override + public String toString() { + return getId(); + } +} diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/json/JsonIndexPlugin.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/json/JsonIndexPlugin.java new file mode 100644 index 0000000000..9e05af6046 --- /dev/null +++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/json/JsonIndexPlugin.java @@ -0,0 +1,32 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.pinot.segment.local.segment.index.json; + +import com.google.auto.service.AutoService; +import org.apache.pinot.segment.spi.index.IndexPlugin; + + +@AutoService(IndexPlugin.class) +public class JsonIndexPlugin implements IndexPlugin<JsonIndexType> { + @Override + public JsonIndexType getIndexType() { + return JsonIndexType.INSTANCE; + } +} diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/json/JsonIndexType.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/json/JsonIndexType.java new file mode 100644 index 0000000000..e7ab2f74ee --- /dev/null +++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/json/JsonIndexType.java @@ -0,0 +1,92 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.pinot.segment.local.segment.index.json; + +import java.util.Map; +import javax.annotation.Nullable; +import org.apache.pinot.segment.spi.ColumnMetadata; +import org.apache.pinot.segment.spi.V1Constants; +import org.apache.pinot.segment.spi.creator.IndexCreationContext; +import org.apache.pinot.segment.spi.index.FieldIndexConfigs; +import org.apache.pinot.segment.spi.index.IndexCreator; +import org.apache.pinot.segment.spi.index.IndexHandler; +import org.apache.pinot.segment.spi.index.IndexReader; +import org.apache.pinot.segment.spi.index.IndexReaderFactory; +import org.apache.pinot.segment.spi.index.IndexType; +import org.apache.pinot.segment.spi.index.StandardIndexes; +import org.apache.pinot.segment.spi.store.SegmentDirectory; +import org.apache.pinot.spi.config.table.IndexConfig; +import org.apache.pinot.spi.config.table.TableConfig; +import org.apache.pinot.spi.data.Schema; + + +public class JsonIndexType implements IndexType<IndexConfig, IndexReader, IndexCreator> { + public static final JsonIndexType INSTANCE = new JsonIndexType(); + + private JsonIndexType() { + } + + @Override + public String getId() { + return StandardIndexes.JSON_ID; + } + + @Override + public Class<IndexConfig> getIndexConfigClass() { + return IndexConfig.class; + } + + @Override + public IndexConfig getDefaultConfig() { + return IndexConfig.DISABLED; + } + + @Override + public IndexConfig getConfig(TableConfig tableConfig, Schema schema) { + throw new UnsupportedOperationException(); + } + + @Override + public IndexCreator createIndexCreator(IndexCreationContext context, IndexConfig indexConfig) + throws Exception { + throw new UnsupportedOperationException(); + } + + @Override + public IndexReaderFactory<IndexReader> getReaderFactory() { + throw new UnsupportedOperationException(); + } + + @Override + public String getFileExtension(ColumnMetadata columnMetadata) { + return V1Constants.Indexes.JSON_INDEX_FILE_EXTENSION; + } + + @Override + public IndexHandler createIndexHandler(SegmentDirectory segmentDirectory, Map<String, FieldIndexConfigs> configsByCol, + @Nullable Schema schema, @Nullable TableConfig tableConfig) { + throw new UnsupportedOperationException(); + } + + @Override + public String toString() { + return getId(); + } +} diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/nullvalue/NullValueIndexPlugin.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/nullvalue/NullValueIndexPlugin.java new file mode 100644 index 0000000000..56d322ae8b --- /dev/null +++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/nullvalue/NullValueIndexPlugin.java @@ -0,0 +1,32 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.pinot.segment.local.segment.index.nullvalue; + +import com.google.auto.service.AutoService; +import org.apache.pinot.segment.spi.index.IndexPlugin; + + +@AutoService(IndexPlugin.class) +public class NullValueIndexPlugin implements IndexPlugin<NullValueIndexType> { + @Override + public NullValueIndexType getIndexType() { + return NullValueIndexType.INSTANCE; + } +} diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/nullvalue/NullValueIndexType.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/nullvalue/NullValueIndexType.java new file mode 100644 index 0000000000..e66088fea0 --- /dev/null +++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/nullvalue/NullValueIndexType.java @@ -0,0 +1,93 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.pinot.segment.local.segment.index.nullvalue; + +import java.util.Map; +import javax.annotation.Nullable; +import org.apache.pinot.segment.spi.ColumnMetadata; +import org.apache.pinot.segment.spi.V1Constants; +import org.apache.pinot.segment.spi.creator.IndexCreationContext; +import org.apache.pinot.segment.spi.index.FieldIndexConfigs; +import org.apache.pinot.segment.spi.index.IndexCreator; +import org.apache.pinot.segment.spi.index.IndexHandler; +import org.apache.pinot.segment.spi.index.IndexReader; +import org.apache.pinot.segment.spi.index.IndexReaderFactory; +import org.apache.pinot.segment.spi.index.IndexType; +import org.apache.pinot.segment.spi.index.StandardIndexes; +import org.apache.pinot.segment.spi.store.SegmentDirectory; +import org.apache.pinot.spi.config.table.IndexConfig; +import org.apache.pinot.spi.config.table.TableConfig; +import org.apache.pinot.spi.data.Schema; + + +public class NullValueIndexType implements IndexType<IndexConfig, IndexReader, IndexCreator> { + + public static final NullValueIndexType INSTANCE = new NullValueIndexType(); + + private NullValueIndexType() { + } + + @Override + public String getId() { + return StandardIndexes.NULL_VALUE_VECTOR_ID; + } + + @Override + public Class<IndexConfig> getIndexConfigClass() { + return IndexConfig.class; + } + + @Override + public IndexConfig getDefaultConfig() { + return IndexConfig.DISABLED; + } + + @Override + public IndexConfig getConfig(TableConfig tableConfig, Schema schema) { + throw new UnsupportedOperationException(); + } + + @Override + public IndexCreator createIndexCreator(IndexCreationContext context, IndexConfig indexConfig) + throws Exception { + throw new UnsupportedOperationException(); + } + + @Override + public IndexReaderFactory<IndexReader> getReaderFactory() { + throw new UnsupportedOperationException(); + } + + @Override + public IndexHandler createIndexHandler(SegmentDirectory segmentDirectory, Map<String, FieldIndexConfigs> configsByCol, + @Nullable Schema schema, @Nullable TableConfig tableConfig) { + throw new UnsupportedOperationException(); + } + + @Override + public String getFileExtension(ColumnMetadata columnMetadata) { + return V1Constants.Indexes.NULLVALUE_VECTOR_FILE_EXTENSION; + } + + @Override + public String toString() { + return getId(); + } +} diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/range/RangeIndexPlugin.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/range/RangeIndexPlugin.java new file mode 100644 index 0000000000..d838495c68 --- /dev/null +++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/range/RangeIndexPlugin.java @@ -0,0 +1,32 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.pinot.segment.local.segment.index.range; + +import com.google.auto.service.AutoService; +import org.apache.pinot.segment.spi.index.IndexPlugin; + + +@AutoService(IndexPlugin.class) +public class RangeIndexPlugin implements IndexPlugin<RangeIndexType> { + @Override + public RangeIndexType getIndexType() { + return RangeIndexType.INSTANCE; + } +} diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/range/RangeIndexType.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/range/RangeIndexType.java new file mode 100644 index 0000000000..3b6c960e69 --- /dev/null +++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/range/RangeIndexType.java @@ -0,0 +1,99 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.pinot.segment.local.segment.index.range; + +import java.util.Map; +import javax.annotation.Nullable; +import org.apache.pinot.segment.spi.ColumnMetadata; +import org.apache.pinot.segment.spi.V1Constants; +import org.apache.pinot.segment.spi.creator.IndexCreationContext; +import org.apache.pinot.segment.spi.index.FieldIndexConfigs; +import org.apache.pinot.segment.spi.index.IndexCreator; +import org.apache.pinot.segment.spi.index.IndexHandler; +import org.apache.pinot.segment.spi.index.IndexReader; +import org.apache.pinot.segment.spi.index.IndexReaderFactory; +import org.apache.pinot.segment.spi.index.IndexType; +import org.apache.pinot.segment.spi.index.StandardIndexes; +import org.apache.pinot.segment.spi.store.SegmentDirectory; +import org.apache.pinot.spi.config.table.IndexConfig; +import org.apache.pinot.spi.config.table.TableConfig; +import org.apache.pinot.spi.data.Schema; + + +public class RangeIndexType implements IndexType<IndexConfig, IndexReader, IndexCreator> { + + /** + * The default range index version used when not specified in the TableConfig. + * + * This value should be equal to the one used in {@link org.apache.pinot.spi.config.table.IndexingConfig} + */ + public static final int DEFAULT_RANGE_INDEX_VERSION = 2; + public static final RangeIndexType INSTANCE = new RangeIndexType(); + + private RangeIndexType() { + } + + @Override + public String getId() { + return StandardIndexes.RANGE_ID; + } + + @Override + public Class<IndexConfig> getIndexConfigClass() { + return IndexConfig.class; + } + + @Override + public IndexConfig getDefaultConfig() { + return IndexConfig.DISABLED; + } + + @Override + public IndexConfig getConfig(TableConfig tableConfig, Schema schema) { + throw new UnsupportedOperationException(); + } + + @Override + public IndexCreator createIndexCreator(IndexCreationContext context, IndexConfig indexConfig) + throws Exception { + throw new UnsupportedOperationException(); + } + + @Override + public IndexReaderFactory<IndexReader> getReaderFactory() { + throw new UnsupportedOperationException(); + } + + @Override + public String getFileExtension(ColumnMetadata columnMetadata) { + return V1Constants.Indexes.BITMAP_RANGE_INDEX_FILE_EXTENSION; + } + + @Override + public IndexHandler createIndexHandler(SegmentDirectory segmentDirectory, Map<String, FieldIndexConfigs> configsByCol, + @Nullable Schema schema, @Nullable TableConfig tableConfig) { + throw new UnsupportedOperationException(); + } + + @Override + public String toString() { + return getId(); + } +} diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/text/TextIndexPlugin.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/text/TextIndexPlugin.java new file mode 100644 index 0000000000..ec509f7ab4 --- /dev/null +++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/text/TextIndexPlugin.java @@ -0,0 +1,32 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.pinot.segment.local.segment.index.text; + +import com.google.auto.service.AutoService; +import org.apache.pinot.segment.spi.index.IndexPlugin; + + +@AutoService(IndexPlugin.class) +public class TextIndexPlugin implements IndexPlugin<TextIndexType> { + @Override + public TextIndexType getIndexType() { + return TextIndexType.INSTANCE; + } +} diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/text/TextIndexType.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/text/TextIndexType.java new file mode 100644 index 0000000000..53a9700869 --- /dev/null +++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/text/TextIndexType.java @@ -0,0 +1,93 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.pinot.segment.local.segment.index.text; + +import java.util.Map; +import javax.annotation.Nullable; +import org.apache.pinot.segment.spi.ColumnMetadata; +import org.apache.pinot.segment.spi.V1Constants; +import org.apache.pinot.segment.spi.creator.IndexCreationContext; +import org.apache.pinot.segment.spi.index.FieldIndexConfigs; +import org.apache.pinot.segment.spi.index.IndexCreator; +import org.apache.pinot.segment.spi.index.IndexHandler; +import org.apache.pinot.segment.spi.index.IndexReader; +import org.apache.pinot.segment.spi.index.IndexReaderFactory; +import org.apache.pinot.segment.spi.index.IndexType; +import org.apache.pinot.segment.spi.index.StandardIndexes; +import org.apache.pinot.segment.spi.store.SegmentDirectory; +import org.apache.pinot.spi.config.table.IndexConfig; +import org.apache.pinot.spi.config.table.TableConfig; +import org.apache.pinot.spi.data.Schema; + + +public class TextIndexType implements IndexType<IndexConfig, IndexReader, IndexCreator> { + + public static final TextIndexType INSTANCE = new TextIndexType(); + + private TextIndexType() { + } + + @Override + public String getId() { + return StandardIndexes.TEXT_ID; + } + + @Override + public Class<IndexConfig> getIndexConfigClass() { + return IndexConfig.class; + } + + @Override + public IndexConfig getDefaultConfig() { + return IndexConfig.DISABLED; + } + + @Override + public IndexConfig getConfig(TableConfig tableConfig, Schema schema) { + throw new UnsupportedOperationException(); + } + + @Override + public IndexCreator createIndexCreator(IndexCreationContext context, IndexConfig indexConfig) + throws Exception { + throw new UnsupportedOperationException(); + } + + @Override + public IndexReaderFactory<IndexReader> getReaderFactory() { + throw new UnsupportedOperationException(); + } + + @Override + public IndexHandler createIndexHandler(SegmentDirectory segmentDirectory, Map<String, FieldIndexConfigs> configsByCol, + @Nullable Schema schema, @Nullable TableConfig tableConfig) { + throw new UnsupportedOperationException(); + } + + @Override + public String getFileExtension(ColumnMetadata columnMetadata) { + return V1Constants.Indexes.LUCENE_TEXT_INDEX_FILE_EXTENSION; + } + + @Override + public String toString() { + return getId(); + } +} diff --git a/pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/index/StandardIndexes.java b/pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/index/StandardIndexes.java index caad4606fe..ec790ca6da 100644 --- a/pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/index/StandardIndexes.java +++ b/pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/index/StandardIndexes.java @@ -39,21 +39,64 @@ import org.apache.pinot.spi.config.table.BloomFilterConfig; * included in a Pinot distribution. {@link StandardIndexes} contains one get method for each standard index, * providing a typesafe way to get these references. Instead of having to write something like * {@code (IndexType<BloomFilterConfig, BloomFilterReader, IndexCreator>) - * IndexService.getInstance().getOrThrow("bloom_filter")}, + * IndexService.getInstance().get("bloom_filter")}, * a caller can simply use {@link StandardIndexes#bloomFilter()} * </p> */ @SuppressWarnings("unchecked") public class StandardIndexes { + public static final String FORWARD_ID = "forward_index"; + public static final String DICTIONARY_ID = "dictionary"; + public static final String NULL_VALUE_VECTOR_ID = "nullvalue_vector"; + public static final String BLOOM_FILTER_ID = "bloom_filter"; + public static final String FST_ID = "fst_index"; + public static final String INVERTED_ID = "inverted_index"; + public static final String JSON_ID = "json_index"; + public static final String RANGE_ID = "range_index"; + public static final String TEXT_ID = "text_index"; + public static final String H3_ID = "h3_index"; + private StandardIndexes() { } - // Other methods like bloomFilter() should be created for each index. - // This class may be changed in the future by adding a way to override index implementations in needed, like - // current IndexOverrides + public static IndexType<?, ?, ?> forward() { + return IndexService.getInstance().get(FORWARD_ID); + } + + public static IndexType<?, ?, ?> dictionary() { + return IndexService.getInstance().get(DICTIONARY_ID); + } + + public static IndexType<?, ?, ?> nullValueVector() { + return IndexService.getInstance().get(NULL_VALUE_VECTOR_ID); + } public static IndexType<BloomFilterConfig, BloomFilterReader, IndexCreator> bloomFilter() { return (IndexType<BloomFilterConfig, BloomFilterReader, IndexCreator>) - IndexService.getInstance().get("bloom_filter"); + IndexService.getInstance().get(BLOOM_FILTER_ID); + } + + public static IndexType<?, ?, ?> fst() { + return IndexService.getInstance().get(FST_ID); + } + + public static IndexType<?, ?, ?> inverted() { + return IndexService.getInstance().get(INVERTED_ID); + } + + public static IndexType<?, ?, ?> json() { + return IndexService.getInstance().get(JSON_ID); + } + + public static IndexType<?, ?, ?> range() { + return IndexService.getInstance().get(RANGE_ID); + } + + public static IndexType<?, ?, ?> text() { + return IndexService.getInstance().get(TEXT_ID); + } + + public static IndexType<?, ?, ?> h3() { + return IndexService.getInstance().get(H3_ID); } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org