-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
Signed-off-by: Sarthak Aggarwal <[email protected]>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* 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; | ||
|
||
/** | ||
* This class contains constants used in the Composite Index implementation. | ||
*/ | ||
public class CompositeIndexConstants { | ||
Check warning on line 14 in server/src/main/java/org/opensearch/index/compositeindex/CompositeIndexConstants.java Codecov / codecov/patchserver/src/main/java/org/opensearch/index/compositeindex/CompositeIndexConstants.java#L14
|
||
|
||
/** | ||
* The magic marker value used for sanity checks in the Composite Index implementation. | ||
*/ | ||
public static final long COMPOSITE_FIELD_MARKER = 0xC0950513F1E1DL; // Composite Field | ||
|
||
/** | ||
* Represents the key to fetch number of documents in a segment. | ||
*/ | ||
public static final String SEGMENT_DOCS_COUNT = "segmentDocsCount"; | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* 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; | ||
|
||
import org.opensearch.index.mapper.CompositeMappedFieldType; | ||
|
||
/** | ||
* This class represents the metadata of a Composite Index, which includes information about | ||
* the composite field name, type, and the specific metadata for the type of composite field | ||
* (e.g., Tree metadata). | ||
* | ||
* @opensearch.experimental | ||
*/ | ||
public class CompositeIndexMetadata { | ||
|
||
private final String compositeFieldName; | ||
private final CompositeMappedFieldType.CompositeFieldType compositeFieldType; | ||
|
||
/** | ||
* Constructs a CompositeIndexMetadata object with the provided composite field name and type. | ||
* | ||
* @param compositeFieldName the name of the composite field | ||
* @param compositeFieldType the type of the composite field | ||
*/ | ||
public CompositeIndexMetadata(String compositeFieldName, CompositeMappedFieldType.CompositeFieldType compositeFieldType) { | ||
this.compositeFieldName = compositeFieldName; | ||
this.compositeFieldType = compositeFieldType; | ||
} | ||
|
||
/** | ||
* Returns the name of the composite field. | ||
* | ||
* @return the composite field name | ||
*/ | ||
public String getCompositeFieldName() { | ||
return compositeFieldName; | ||
} | ||
|
||
/** | ||
* Returns the type of the composite field. | ||
* | ||
* @return the composite field type | ||
*/ | ||
public CompositeMappedFieldType.CompositeFieldType getCompositeFieldType() { | ||
return compositeFieldType; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* 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.core.xcontent.XContentBuilder; | ||
import org.opensearch.index.mapper.CompositeDataCubeFieldType; | ||
|
||
import java.io.IOException; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Composite index merge dimension class | ||
* | ||
* @opensearch.experimental | ||
*/ | ||
public class ReadDimension implements Dimension { | ||
public static final String READ = "read"; | ||
private final String field; | ||
|
||
public ReadDimension(String field) { | ||
this.field = field; | ||
} | ||
Check warning on line 28 in server/src/main/java/org/opensearch/index/compositeindex/datacube/ReadDimension.java Codecov / codecov/patchserver/src/main/java/org/opensearch/index/compositeindex/datacube/ReadDimension.java#L26-L28
|
||
|
||
public String getField() { | ||
return field; | ||
Check warning on line 31 in server/src/main/java/org/opensearch/index/compositeindex/datacube/ReadDimension.java Codecov / codecov/patchserver/src/main/java/org/opensearch/index/compositeindex/datacube/ReadDimension.java#L31
|
||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject(); | ||
builder.field(CompositeDataCubeFieldType.NAME, field); | ||
builder.field(CompositeDataCubeFieldType.TYPE, READ); | ||
builder.endObject(); | ||
return builder; | ||
Check warning on line 40 in server/src/main/java/org/opensearch/index/compositeindex/datacube/ReadDimension.java Codecov / codecov/patchserver/src/main/java/org/opensearch/index/compositeindex/datacube/ReadDimension.java#L36-L40
|
||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
ReadDimension dimension = (ReadDimension) o; | ||
return Objects.equals(field, dimension.getField()); | ||
Check warning on line 48 in server/src/main/java/org/opensearch/index/compositeindex/datacube/ReadDimension.java Codecov / codecov/patchserver/src/main/java/org/opensearch/index/compositeindex/datacube/ReadDimension.java#L47-L48
|
||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(field); | ||
Check warning on line 53 in server/src/main/java/org/opensearch/index/compositeindex/datacube/ReadDimension.java Codecov / codecov/patchserver/src/main/java/org/opensearch/index/compositeindex/datacube/ReadDimension.java#L53
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* 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.startree.fileformats; | ||
|
||
import org.apache.lucene.store.IndexOutput; | ||
import org.opensearch.index.compositeindex.datacube.startree.StarTreeField; | ||
import org.opensearch.index.compositeindex.datacube.startree.aggregators.MetricAggregatorInfo; | ||
import org.opensearch.index.compositeindex.datacube.startree.fileformats.data.StarTreeDataWriter; | ||
import org.opensearch.index.compositeindex.datacube.startree.fileformats.meta.StarTreeMetaWriter; | ||
import org.opensearch.index.compositeindex.datacube.startree.node.InMemoryTreeNode; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
/** | ||
* Util class for building star tree | ||
* | ||
* @opensearch.experimental | ||
*/ | ||
public class StarTreeWriter { | ||
|
||
/** Initial version for the star tree writer */ | ||
public static final int VERSION_START = 0; | ||
|
||
/** Current version for the star tree writer */ | ||
public static final int VERSION_CURRENT = VERSION_START; | ||
|
||
private StarTreeWriter() {} | ||
|
||
/** | ||
* Write star tree to index output stream | ||
* | ||
* @param dataOut data index output | ||
* @param rootNode root star-tree node | ||
* @param numNodes number of nodes in the tree | ||
* @param name name of the star-tree field | ||
* @return total size of the three | ||
* @throws IOException when star-tree data serialization fails | ||
*/ | ||
public static long writeStarTree(IndexOutput dataOut, InMemoryTreeNode rootNode, int numNodes, String name) throws IOException { | ||
return StarTreeDataWriter.writeStarTree(dataOut, rootNode, numNodes, name); | ||
} | ||
|
||
/** | ||
* Write star tree metadata to index output stream | ||
* | ||
* @param metaOut meta index output | ||
* @param starTreeField star tree field | ||
* @param metricAggregatorInfos metric aggregator infos | ||
* @param segmentAggregatedCount segment aggregated count | ||
* @param dataFilePointer data file pointer | ||
* @param dataFileLength data file length | ||
* @throws IOException when star-tree data serialization fails | ||
*/ | ||
public static void writeStarTreeMetadata( | ||
IndexOutput metaOut, | ||
StarTreeField starTreeField, | ||
List<MetricAggregatorInfo> metricAggregatorInfos, | ||
Integer segmentAggregatedCount, | ||
long dataFilePointer, | ||
long dataFileLength | ||
) throws IOException { | ||
StarTreeMetaWriter.writeStarTreeMetadata( | ||
metaOut, | ||
starTreeField, | ||
metricAggregatorInfos, | ||
segmentAggregatedCount, | ||
dataFilePointer, | ||
dataFileLength | ||
); | ||
} | ||
|
||
} |