Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Bharathwaj G <[email protected]>
  • Loading branch information
bharath-techie committed Jul 23, 2024
1 parent 0b214f7 commit fed49c9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Integer> starTreeDocumentOffsets;
private int numReadableStarTreeDocuments;
final IndexOutput segmentDocsFileOutput;
Expand Down Expand Up @@ -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));
}

Expand All @@ -336,7 +336,7 @@ public List<StarTreeDocument> 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)));
}

Expand Down Expand Up @@ -387,7 +387,7 @@ public Iterator<StarTreeDocument> 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;
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit fed49c9

Please sign in to comment.