Skip to content

Commit

Permalink
2 methods AutoIndexer
Browse files Browse the repository at this point in the history
  • Loading branch information
osopardo1 authored and osopardo1 committed Dec 7, 2023
1 parent 80629c5 commit b48074e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
10 changes: 9 additions & 1 deletion core/src/main/scala/io/qbeast/core/model/AutoIndexer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ trait AutoIndexer[DATA] {
*/
def MAX_COLUMNS_TO_INDEX: Int

/**
* Chooses the columns to index without limiting the number of columns.
* @param data
* the data to index
* @return
*/
def chooseColumnsToIndex(data: DATA): Seq[String]

/**
* Chooses the columns to index.
* @param data
Expand All @@ -23,6 +31,6 @@ trait AutoIndexer[DATA] {
* @return
* A sequence with the names of the columns to index
*/
def chooseColumnsToIndex(data: DATA, numColumnsToIndex: Int = MAX_COLUMNS_TO_INDEX): Seq[String]
def chooseColumnsToIndex(data: DATA, numColumnsToIndex: Int): Seq[String]

}
17 changes: 16 additions & 1 deletion src/main/scala/io/qbeast/spark/index/SparkAutoIndexer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,26 @@ import org.apache.spark.sql.DataFrame

object SparkAutoIndexer extends AutoIndexer[DataFrame] with Serializable {

/**
* The maximum number of columns to index.
*
* @return
*/
override def MAX_COLUMNS_TO_INDEX: Int = MAX_NUM_COLUMNS_TO_INDEX

/**
* Chooses the columns to index without limiting the number of columns.
*
* @param data
* the data to index
* @return
*/
override def chooseColumnsToIndex(data: DataFrame): Seq[String] =
chooseColumnsToIndex(data, MAX_COLUMNS_TO_INDEX)

override def chooseColumnsToIndex(
data: DataFrame,
numColumnsToIndex: Int = MAX_COLUMNS_TO_INDEX): Seq[String] = {
numColumnsToIndex: Int = MAX_NUM_COLUMNS_TO_INDEX): Seq[String] = {

// IF there's no data to write, we return all the columns to index
if (data.isEmpty) {
Expand Down

0 comments on commit b48074e

Please sign in to comment.