From 27d39e992a78923895aebac4249f52115a24da3a Mon Sep 17 00:00:00 2001 From: Chungmin Lee Date: Fri, 2 Jul 2021 15:42:30 +0900 Subject: [PATCH] Make CoveringIndexConfig available in Python --- python/hyperspace/__init__.py | 4 ++-- python/hyperspace/hyperspace.py | 14 +++++++------- python/hyperspace/indexconfig.py | 11 +++++++---- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/python/hyperspace/__init__.py b/python/hyperspace/__init__.py index f5671ab72..cb9599cdb 100644 --- a/python/hyperspace/__init__.py +++ b/python/hyperspace/__init__.py @@ -1,6 +1,6 @@ from .hyperspace import Hyperspace -from .indexconfig import IndexConfig +from .indexconfig import CoveringIndexConfig, IndexConfig __all__ = [ - 'Hyperspace', 'IndexConfig' + 'Hyperspace', 'CoveringIndexConfig', 'IndexConfig' ] diff --git a/python/hyperspace/hyperspace.py b/python/hyperspace/hyperspace.py index aacae1ab2..e5c1173e0 100644 --- a/python/hyperspace/hyperspace.py +++ b/python/hyperspace/hyperspace.py @@ -19,13 +19,13 @@ def __init__(self, spark): self.jvm = spark._jvm self.hyperspace = self.jvm.com.microsoft.hyperspace.Hyperspace(spark._jsparkSession) - def _getJavaIndexConfig(self, index_config): + def _getJavaCoveringIndexConfig(self, index_config): """ - Constructs IndexConfig Java object from python wrapper IndexConfig object. - :param index_config: IndexConfig java object - :return: IndexConfig python object + Constructs CoveringIndexConfig Java object from python wrapper CoveringIndexConfig object. + :param index_config: CoveringIndexConfig java object + :return: CoveringIndexConfig python object - >>> _getJavaIndexConfig(idx_config) + >>> _getJavaCoveringIndexConfig(idx_config) """ indexed_columns = self._getScalaSeqFromList(index_config.indexedColumns) included_columns = self._getScalaSeqFromList(index_config.includedColumns) @@ -67,11 +67,11 @@ def createIndex(self, dataFrame, indexConfig): :param indexConfig: indexConfig >>> hyperspace = Hyperspace(spark) - >>> idxConfig = IndexConfig("indexName", ["c1"], ["c2","c3"]) + >>> idxConfig = CoveringIndexConfig("indexName", ["c1"], ["c2","c3"]) >>> df = spark.read.parquet("./sample.parquet").toDF("c1", "c2", "c3") >>> hyperspace.createIndex(df, indexConfig) """ - self.hyperspace.createIndex(dataFrame._jdf, self._getJavaIndexConfig(indexConfig)) + self.hyperspace.createIndex(dataFrame._jdf, self._getJavaCoveringIndexConfig(indexConfig)) def deleteIndex(self, indexName): """ diff --git a/python/hyperspace/indexconfig.py b/python/hyperspace/indexconfig.py index 7c4f26bef..9c5eed81e 100644 --- a/python/hyperspace/indexconfig.py +++ b/python/hyperspace/indexconfig.py @@ -1,14 +1,17 @@ -class IndexConfig: +class CoveringIndexConfig: def __init__(self, indexName, indexedColumns, includedColumns): """ - Initializes IndexConfig object. + Initializes CoveringIndexConfig object. :param indexName: index name :param indexedColumns: indexed columns :param includedColumns: included columns - :return: IndexConfig object + :return: CoveringIndexConfig object - >>> idxConfig = IndexConfig("indexName", ["c1"], ["c2","c3"]) + >>> idxConfig = CoveringIndexConfig("indexName", ["c1"], ["c2","c3"]) """ self.indexName = indexName self.indexedColumns = indexedColumns self.includedColumns = includedColumns + +# TODO(ChungminL): Add deprecation warning +IndexConfig = CoveringIndexConfig