From fed49c9a451d6e8316bb32379681afd93c019e14 Mon Sep 17 00:00:00 2001 From: Bharathwaj G Date: Tue, 23 Jul 2024 23:32:41 +0530 Subject: [PATCH] fixes Signed-off-by: Bharathwaj G --- .../startree/builder/OffHeapStarTreeBuilder.java | 14 +++++++------- .../startree/StarTreeDocValuesFormatTests.java | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/server/src/main/java/org/opensearch/index/compositeindex/datacube/startree/builder/OffHeapStarTreeBuilder.java b/server/src/main/java/org/opensearch/index/compositeindex/datacube/startree/builder/OffHeapStarTreeBuilder.java index a97e05cfb6446..ca8a6c4f6bdf3 100644 --- a/server/src/main/java/org/opensearch/index/compositeindex/datacube/startree/builder/OffHeapStarTreeBuilder.java +++ b/server/src/main/java/org/opensearch/index/compositeindex/datacube/startree/builder/OffHeapStarTreeBuilder.java @@ -73,7 +73,7 @@ public class OffHeapStarTreeBuilder extends BaseStarTreeBuilder { private static final String SEGMENT_DOC_FILE_NAME = "segment.documents"; private static final String STAR_TREE_DOC_FILE_NAME = "star-tree.documents"; // TODO : Should this be via settings ? - private static final int FILE_COUNT_THRESHOLD = 10; + private static final int FILE_COUNT_THRESHOLD = 5; private final List starTreeDocumentOffsets; private int numReadableStarTreeDocuments; final IndexOutput segmentDocsFileOutput; @@ -319,7 +319,7 @@ public StarTreeDocument getSegmentStarTreeDocument(int docID, long documentBytes @Override public StarTreeDocument getStarTreeDocument(int docId) throws IOException { - ensureBufferReadable(docId); + ensureDocReadable(docId); return readStarTreeDocument(starTreeDocsFileRandomInput, starTreeDocumentOffsets.get(docId)); } @@ -336,7 +336,7 @@ public List getStarTreeDocuments() throws IOException { // TODO: should this be just long? @Override public Long getDimensionValue(int docId, int dimensionId) throws IOException { - ensureBufferReadable(docId); + ensureDocReadable(docId); return starTreeDocsFileRandomInput.readLong((starTreeDocumentOffsets.get(docId) + ((long) dimensionId * Long.BYTES))); } @@ -387,7 +387,7 @@ public Iterator generateStarTreeDocumentsForStarNode(int start throws IOException { // End doc id is not inclusive but start doc is inclusive // Hence we need to check if buffer is readable till endDocId - 1 - ensureBufferReadable(endDocId - 1); + ensureDocReadable(endDocId - 1); // Sort all documents using an int array int numDocs = endDocId - startDocId; @@ -650,11 +650,11 @@ private StarTreeDocument readStarTreeDocument(RandomAccessInput input, long offs return new StarTreeDocument(dimensions, metrics); } - private void ensureBufferReadable(int docId) throws IOException { - ensureBufferReadable(docId, true); + private void ensureDocReadable(int docId) throws IOException { + ensureDocReadable(docId, true); } - private void ensureBufferReadable(int docId, boolean shouldCreateFileOutput) throws IOException { + private void ensureDocReadable(int docId, boolean shouldCreateFileOutput) throws IOException { if (docId >= prevStartDocId && docId < numReadableStarTreeDocuments) { return; } diff --git a/server/src/test/java/org/opensearch/index/codec/composite/datacube/startree/StarTreeDocValuesFormatTests.java b/server/src/test/java/org/opensearch/index/codec/composite/datacube/startree/StarTreeDocValuesFormatTests.java index 049d91bc42d9c..739935779d414 100644 --- a/server/src/test/java/org/opensearch/index/codec/composite/datacube/startree/StarTreeDocValuesFormatTests.java +++ b/server/src/test/java/org/opensearch/index/codec/composite/datacube/startree/StarTreeDocValuesFormatTests.java @@ -68,7 +68,7 @@ protected Codec getCodec() { final Logger testLogger = LogManager.getLogger(StarTreeDocValuesFormatTests.class); try { - createMapperService(getExpandedMapping("status", "size")); + createMapperService(getExpandedMapping()); } catch (IOException e) { throw new RuntimeException(e); } @@ -106,7 +106,7 @@ public void testStarTreeDocValues() throws IOException { directory.close(); } - private XContentBuilder getExpandedMapping(String dim, String metric) throws IOException { + private XContentBuilder getExpandedMapping() throws IOException { return topMapping(b -> { b.startObject("composite"); b.startObject("startree");