Skip to content

Commit

Permalink
Precompute aggregation support
Browse files Browse the repository at this point in the history
Signed-off-by: Bharathwaj G <bharath78910@gmail.com>
  • Loading branch information
bharath-techie committed Mar 1, 2024
1 parent 90cdd10 commit c993b9a
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 12 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ apply from: file('gradle/globals.gradle')
// Calculate project version:
version = {
// Release manager: update base version here after release:
String baseVersion = '9.7.1'
String baseVersion = '9.7.0'

// On a release explicitly set release version in one go:
// -Dversion.release=x.y.z

// Jenkins can just set just a suffix, overriding SNAPSHOT, e.g. using build id:
// -Dversion.suffix=jenkins123

String versionSuffix = propertyOrDefault('version.suffix', 'SNAPSHOT')
return propertyOrDefault('version.release', "${baseVersion}-${versionSuffix}")
//String versionSuffix = propertyOrDefault('version.suffix', '')
return propertyOrDefault('version.release', "${baseVersion}")
}()
description = 'Grandparent project for Apache Lucene Core'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ public abstract void addSortedNumericField(FieldInfo field, DocValuesProducer va
public abstract void addSortedSetField(FieldInfo field, DocValuesProducer valuesProducer)
throws IOException;

/**
* Aggregate doc values
*
* @throws IOException if an I/O error occurred
*/
public void aggregate() throws IOException {
// default no op
}
/**
* Merges in the fields from the readers in <code>mergeState</code>. The default implementation
* calls {@link #mergeNumericField}, {@link #mergeBinaryField}, {@link #mergeSortedField}, {@link
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,13 @@ protected DocValuesProducer() {}
public DocValuesProducer getMergeInstance() {
return this;
}

/** StarTreeAggregatedValues is the return type
* Todo : don't return object
*
*/
public Object getAggregatedDocValues() throws IOException {
// No-op by default
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public KnnVectorsFormat getKnnVectorsFormatForField(String field) {
}

@Override
public final DocValuesFormat docValuesFormat() {
public DocValuesFormat docValuesFormat() {
return docValuesFormat;
}

Expand Down
5 changes: 5 additions & 0 deletions lucene/core/src/java/org/apache/lucene/index/CodecReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ public final SortedDocValues getSortedDocValues(String field) throws IOException
return getDocValuesReader().getSorted(fi);
}

@Override
public final Object getAggregatedDocValues() throws IOException {
return getDocValuesReader().getAggregatedDocValues();
}

@Override
public final SortedNumericDocValues getSortedNumericDocValues(String field) throws IOException {
ensureOpen();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,13 @@ public NumericDocValues getNumericDocValues(String field) throws IOException {
return in.getNumericDocValues(field);
}

@Override
public Object getAggregatedDocValues() throws IOException {
ensureOpen();
return in.getAggregatedDocValues();
}


@Override
public BinaryDocValues getBinaryDocValues(String field) throws IOException {
ensureOpen();
Expand Down
15 changes: 14 additions & 1 deletion lucene/core/src/java/org/apache/lucene/index/IndexingChain.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ public SortedDocValues getSortedDocValues(String field) throws IOException {
return null;
}

@Override
public Object getAggregatedDocValues()
throws IOException {
return null;
}

@Override
public SortedNumericDocValues getSortedNumericDocValues(String field) throws IOException {
PerField pf = getPerField(field);
Expand Down Expand Up @@ -413,7 +419,8 @@ private void writeDocValues(SegmentWriteState state, Sorter.DocMap sortMap) thro
perField = perField.next;
}
}

// IMPORTANT : This call creates the star tree data structures along with the associated doc values in the POC
if (dvConsumer != null) dvConsumer.aggregate();
// TODO: catch missing DV fields here? else we have
// null/"" depending on how docs landed in segments?
// but we can't detect all cases, and we should leave
Expand Down Expand Up @@ -885,6 +892,12 @@ public SortedDocValues getSortedDocValues(String field) {
return DocValues.emptySorted();
}

@Override
public Object getAggregatedDocValues()
throws IOException {
return null;
}

@Override
public SortedNumericDocValues getSortedNumericDocValues(String field) {
if (Objects.equals(field, fieldToValidate)
Expand Down
7 changes: 7 additions & 0 deletions lucene/core/src/java/org/apache/lucene/index/LeafReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ public final PostingsEnum postings(Term term) throws IOException {
*/
public abstract SortedDocValues getSortedDocValues(String field) throws IOException;

/**
* Aggregate doc values
*
* @throws IOException if an I/O error occurred
*/
public abstract Object getAggregatedDocValues() throws IOException;

/**
* Returns {@link SortedNumericDocValues} for this field, or null if no {@link
* SortedNumericDocValues} were indexed for this field. The returned instance should only be used
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,12 @@ public SortedDocValues getSortedDocValues(String field) throws IOException {
return reader == null ? null : reader.getSortedDocValues(field);
}

@Override
public Object getAggregatedDocValues()
throws IOException {
return null;
}

@Override
public SortedNumericDocValues getSortedNumericDocValues(String field) throws IOException {
ensureOpen();
Expand Down
9 changes: 2 additions & 7 deletions lucene/core/src/java/org/apache/lucene/util/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,17 +263,12 @@ public final class Version {
*/
@Deprecated public static final Version LUCENE_9_6_0 = new Version(9, 6, 0);

/**
* @deprecated (9.7.1) Use latest
*/
@Deprecated public static final Version LUCENE_9_7_0 = new Version(9, 7, 0);

/**
* Match settings and bugs in Lucene's 9.7.1 release.
*
* <p>Use this to get the latest &amp; greatest settings, bug fixes, etc, for Lucene.
*/
public static final Version LUCENE_9_7_1 = new Version(9, 7, 1);
public static final Version LUCENE_9_7_0 = new Version(9, 7, 0);

// To add a new version:
// * Only add above this comment
Expand All @@ -289,7 +284,7 @@ public final class Version {
* <b>re-test your entire application</b> to ensure it behaves as expected, as some defaults may
* have changed and may break functionality in your application.
*/
public static final Version LATEST = LUCENE_9_7_1;
public static final Version LATEST = LUCENE_9_7_0;

/**
* Constant for backwards compatibility.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ public SortedDocValues getSortedDocValues(String field) throws IOException {
return docValues.getSorted(fi);
}

@Override
public Object getAggregatedDocValues()
throws IOException {
return null;
}

@Override
public SortedNumericDocValues getSortedNumericDocValues(String field) throws IOException {
ensureOpen();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ public SortedDocValues getSortedDocValues(String field) throws IOException {
return null;
}

@Override
public Object getAggregatedDocValues()
throws IOException {
return null;
}

@Override
public SortedNumericDocValues getSortedNumericDocValues(String field) throws IOException {
return null;
Expand Down

0 comments on commit c993b9a

Please sign in to comment.