-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Bharathwaj G <[email protected]>
- Loading branch information
1 parent
5279d21
commit bc6fe9b
Showing
8 changed files
with
215 additions
and
35 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
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
75 changes: 75 additions & 0 deletions
75
server/src/main/java/org/opensearch/index/compositeindex/datacube/KeywordDimension.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,75 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.index.compositeindex.datacube; | ||
|
||
import org.opensearch.common.annotation.ExperimentalApi; | ||
import org.opensearch.core.xcontent.XContentBuilder; | ||
import org.opensearch.index.mapper.CompositeDataCubeFieldType; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Composite index keyword dimension class | ||
* | ||
* @opensearch.experimental | ||
*/ | ||
@ExperimentalApi | ||
public class KeywordDimension implements Dimension { | ||
public static final String KEYWORD = "keyword"; | ||
private final String field; | ||
|
||
public KeywordDimension(String field) { | ||
this.field = field; | ||
} | ||
|
||
@Override | ||
public String getField() { | ||
return field; | ||
} | ||
|
||
@Override | ||
public int getNumSubDimensions() { | ||
return 1; | ||
} | ||
|
||
@Override | ||
public int setDimensionValues(Long value, Long[] dims, int index) { | ||
dims[index++] = value; | ||
return index; | ||
} | ||
|
||
@Override | ||
public List<String> getDimensionFieldsNames() { | ||
return List.of(field); | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject(); | ||
builder.field(CompositeDataCubeFieldType.NAME, field); | ||
builder.field(CompositeDataCubeFieldType.TYPE, KEYWORD); | ||
builder.endObject(); | ||
return builder; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
KeywordDimension dimension = (KeywordDimension) o; | ||
return Objects.equals(field, dimension.getField()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(field); | ||
} | ||
} |
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
Oops, something went wrong.