forked from opensearch-project/OpenSearch
-
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.
Signed-off-by: bharath-techie <[email protected]>
- Loading branch information
1 parent
e9f77e3
commit 15a58b4
Showing
12 changed files
with
165 additions
and
24 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
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
82 changes: 82 additions & 0 deletions
82
server/src/main/java/org/opensearch/index/compositeindex/datacube/IpDimension.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,82 @@ | ||
/* | ||
* 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.apache.lucene.index.DocValuesType; | ||
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; | ||
import java.util.function.Consumer; | ||
|
||
/** | ||
* Composite index keyword dimension class | ||
* | ||
* @opensearch.experimental | ||
*/ | ||
@ExperimentalApi | ||
public class IpDimension implements Dimension { | ||
public static final String IP = "ip"; | ||
private final String field; | ||
|
||
public IpDimension(String field) { | ||
this.field = field; | ||
} | ||
|
||
@Override | ||
public String getField() { | ||
return field; | ||
} | ||
|
||
@Override | ||
public int getNumSubDimensions() { | ||
return 1; | ||
} | ||
|
||
@Override | ||
public void setDimensionValues(Long value, Consumer<Long> dimSetter) { | ||
// This will set the keyword dimension value's ordinal | ||
dimSetter.accept(value); | ||
} | ||
|
||
@Override | ||
public List<String> getSubDimensionNames() { | ||
return List.of(field); | ||
} | ||
|
||
@Override | ||
public DocValuesType getDocValuesType() { | ||
return DocValuesType.SORTED_SET; | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject(); | ||
builder.field(CompositeDataCubeFieldType.NAME, field); | ||
builder.field(CompositeDataCubeFieldType.TYPE, IP); | ||
builder.endObject(); | ||
return builder; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
IpDimension dimension = (IpDimension) 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.