forked from apache/gravitino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[apache#1339] feat(table): Add index for tables.
- Loading branch information
Showing
5 changed files
with
78 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
api/src/main/java/com/datastrato/gravitino/rel/expressions/Indexes/Indexes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.datastrato.gravitino.rel.expressions.Indexes; | ||
|
||
/** Helper methods to create index to pass into Gravitino. */ | ||
public class Indexes { | ||
|
||
public static Index[] EMPTY_INDEXES = new Index[0]; | ||
|
||
public static final class IndexImpl implements Index { | ||
private final IndexType indexType; | ||
private final String name; | ||
private final String[][] fieldNames; | ||
|
||
public IndexImpl(IndexType indexType, String name, String[][] fieldNames) { | ||
this.indexType = indexType; | ||
this.name = name; | ||
this.fieldNames = fieldNames; | ||
} | ||
|
||
@Override | ||
public IndexType type() { | ||
return indexType; | ||
} | ||
|
||
@Override | ||
public String name() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public String[][] fieldNames() { | ||
return fieldNames; | ||
} | ||
|
||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
/** Builder to create a index. */ | ||
public static class Builder { | ||
protected IndexType indexType; | ||
|
||
protected String name; | ||
protected String[][] fieldNames; | ||
|
||
public Indexes.IndexImpl.Builder withIndexType(IndexType indexType) { | ||
this.indexType = indexType; | ||
return this; | ||
} | ||
|
||
public Indexes.IndexImpl.Builder withName(String name) { | ||
this.name = name; | ||
return this; | ||
} | ||
|
||
public Indexes.IndexImpl.Builder withFieldNames(String[][] fieldNames) { | ||
this.fieldNames = fieldNames; | ||
return this; | ||
} | ||
|
||
public Index build() { | ||
return new IndexImpl(indexType, name, fieldNames); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters