Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datacube format changes to support materialized views #13342

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ public SegmentInfo read(
} else {
indexSort = new Sort(sortField);
}
// TODO

SimpleTextUtil.checkFooter(input);

Expand Down
5 changes: 5 additions & 0 deletions lucene/core/src/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

import org.apache.lucene.codecs.lucene99.Lucene99Codec;
import org.apache.lucene.index.DataCubeField;

/** Lucene Core. */
@SuppressWarnings("module") // the test framework is compiled after the core...
Expand All @@ -32,6 +33,7 @@
exports org.apache.lucene.codecs.lucene94;
exports org.apache.lucene.codecs.lucene95;
exports org.apache.lucene.codecs.lucene99;
exports org.apache.lucene.codecs.lucene910;
exports org.apache.lucene.codecs.lucene90.blocktree;
exports org.apache.lucene.codecs.lucene90.compressing;
exports org.apache.lucene.codecs.perfield;
Expand Down Expand Up @@ -80,6 +82,8 @@
org.apache.lucene.search.SortField.Provider,
org.apache.lucene.search.SortedNumericSortField.Provider,
org.apache.lucene.search.SortedSetSortField.Provider;
provides org.apache.lucene.index.DataCubeFieldProvider with
DataCubeField.Provider;

uses org.apache.lucene.analysis.CharFilterFactory;
uses org.apache.lucene.analysis.TokenFilterFactory;
Expand All @@ -89,4 +93,5 @@
uses org.apache.lucene.codecs.KnnVectorsFormat;
uses org.apache.lucene.codecs.PostingsFormat;
uses org.apache.lucene.index.SortFieldProvider;
uses org.apache.lucene.index.DataCubeFieldProvider;
}
5 changes: 5 additions & 0 deletions lucene/core/src/java/org/apache/lucene/codecs/Codec.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ public final String getName() {
/** Encodes/decodes numeric vector fields */
public abstract KnnVectorsFormat knnVectorsFormat();

/** Encodes/decodes multi-field data cubes index TODO : remove this default impl later */
public DataCubesFormat dataCubesFormat() {
return DataCubesFormat.EMPTY;
}

/** looks up a codec by name */
public static Codec forName(String name) {
return Holder.getLoader().lookup(name);
Expand Down
70 changes: 70 additions & 0 deletions lucene/core/src/java/org/apache/lucene/codecs/DataCubesFormat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.lucene.codecs;

import java.io.IOException;
import org.apache.lucene.index.DataCubesConfig;
import org.apache.lucene.index.DataCubesConsumer;
import org.apache.lucene.index.SegmentReadState;
import org.apache.lucene.index.SegmentWriteState;
import org.apache.lucene.util.NamedSPILoader;

/** Encodes/decodes indexing structures required to support data cubes */
public abstract class DataCubesFormat implements NamedSPILoader.NamedSPI {

private final String name;

/** Sole constructor. */
protected DataCubesFormat(String name) {
NamedSPILoader.checkServiceName(name);
this.name = name;
}

@Override
public String getName() {
return name;
}

/** Returns a {@link DataCubesProducer} to read dataCubesValues from the index. */
public abstract DataCubesProducer<?> fieldsProducer(SegmentReadState state) throws IOException;

/**
* Returns a {@link DataCubesConsumer} to write dataCubesValues to the index based on docValues
* NOTE: by the time this call returns, it must hold open any files it will need to use; else,
* those files may be deleted. Additionally, required files may be deleted during the execution of
* this call before there is a chance to open them. Under these circumstances an IOException
* should be thrown by the implementation. IOExceptions are expected and will automatically cause
* a retry of the segment opening logic with the newly revised segments
*/
public abstract DataCubesConsumer fieldsConsumer(
SegmentWriteState state, DataCubesConfig dataCubesConfig) throws IOException;

/** A {@code DataCubesFormat} that has nothing indexed */
public static final DataCubesFormat EMPTY =
new DataCubesFormat("EMPTY") {
@Override
public DataCubesProducer<?> fieldsProducer(SegmentReadState state) throws IOException {
return null;
}

@Override
public DataCubesConsumer fieldsConsumer(
SegmentWriteState state, DataCubesConfig dataCubesConfig) throws IOException {
throw new UnsupportedOperationException("Attempt to write EMPTY DataCube values");
}
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.lucene.codecs;

import java.io.Closeable;
import java.io.IOException;
import org.apache.lucene.index.DataCubeValues;

/** Reads DataCubes structures from an index */
public abstract class DataCubesProducer<T> implements Closeable {

/** Sole constructor */
protected DataCubesProducer() {}

/**
* Checks consistency of this reader.
*
* <p>Note that this may be costly in terms of I/O, e.g. may involve computing a checksum value
* against large data files.
*
* @lucene.internal
*/
public abstract void checkIntegrity() throws IOException;

/**
* Returns {@link DataCubeValues} for this field, or null if no data cube values were indexed for
* this field. The returned instance should only be used by a single thread.
*/
public abstract DataCubeValues<?> getDataCubeValues(String field) throws IOException;

/**
* Returns an instance optimized for merging. This instance may only be consumed in the thread
* that called {@link #getMergeInstance()}.
*
* <p>The default implementation returns {@code this}
*/
public DataCubesProducer<T> getMergeInstance() {
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,9 @@ public PointsFormat pointsFormat() {
public KnnVectorsFormat knnVectorsFormat() {
return delegate.knnVectorsFormat();
}

@Override
public DataCubesFormat dataCubesFormat() {
return delegate.dataCubesFormat();
}
}