[Rename] ElasticsearchLeafReader class in server module (#177)
This commit refactors the ElasticsearchleafReader class located in the server module to OpenSearchLeafReader. References and usages throughout the rest of the codebase are fully refactored. Signed-off-by: Nicholas Knize <nknize@amazon.com>
This commit is contained in:
parent
c42c2101a8
commit
ce7864efdc
|
@ -29,7 +29,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link org.apache.lucene.index.FilterDirectoryReader} that exposes
|
* A {@link org.apache.lucene.index.FilterDirectoryReader} that exposes
|
||||||
* Elasticsearch internal per shard / index information like the shard ID.
|
* OpenSearch internal per shard / index information like the shard ID.
|
||||||
*/
|
*/
|
||||||
public final class OpenSearchDirectoryReader extends FilterDirectoryReader {
|
public final class OpenSearchDirectoryReader extends FilterDirectoryReader {
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ public final class OpenSearchDirectoryReader extends FilterDirectoryReader {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wraps the given reader in a {@link OpenSearchDirectoryReader} as
|
* Wraps the given reader in a {@link OpenSearchDirectoryReader} as
|
||||||
* well as all it's sub-readers in {@link ElasticsearchLeafReader} to
|
* well as all it's sub-readers in {@link OpenSearchLeafReader} to
|
||||||
* expose the given shard Id.
|
* expose the given shard Id.
|
||||||
*
|
*
|
||||||
* @param reader the reader to wrap
|
* @param reader the reader to wrap
|
||||||
|
@ -80,7 +80,7 @@ public final class OpenSearchDirectoryReader extends FilterDirectoryReader {
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public LeafReader wrap(LeafReader reader) {
|
public LeafReader wrap(LeafReader reader) {
|
||||||
return new ElasticsearchLeafReader(reader, shardId);
|
return new OpenSearchLeafReader(reader, shardId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ public final class OpenSearchDirectoryReader extends FilterDirectoryReader {
|
||||||
OpenSearchDirectoryReader openSearchDirectoryReader = getOpenSearchDirectoryReader(reader);
|
OpenSearchDirectoryReader openSearchDirectoryReader = getOpenSearchDirectoryReader(reader);
|
||||||
if (openSearchDirectoryReader == null) {
|
if (openSearchDirectoryReader == null) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Can't install close listener reader is not an OpenSearchDirectoryReader/ElasticsearchLeafReader");
|
"Can't install close listener reader is not an OpenSearchDirectoryReader/OpenSearchLeafReader");
|
||||||
}
|
}
|
||||||
IndexReader.CacheHelper cacheHelper = openSearchDirectoryReader.getReaderCacheHelper();
|
IndexReader.CacheHelper cacheHelper = openSearchDirectoryReader.getReaderCacheHelper();
|
||||||
if (cacheHelper == null) {
|
if (cacheHelper == null) {
|
||||||
|
@ -120,7 +120,7 @@ public final class OpenSearchDirectoryReader extends FilterDirectoryReader {
|
||||||
// We need to use FilterDirectoryReader#getDelegate and not FilterDirectoryReader#unwrap, because
|
// We need to use FilterDirectoryReader#getDelegate and not FilterDirectoryReader#unwrap, because
|
||||||
// If there are multiple levels of filtered leaf readers then with the unwrap() method it immediately
|
// If there are multiple levels of filtered leaf readers then with the unwrap() method it immediately
|
||||||
// returns the most inner leaf reader and thus skipping of over any other filtered leaf reader that
|
// returns the most inner leaf reader and thus skipping of over any other filtered leaf reader that
|
||||||
// may be instance of ElasticsearchLeafReader. This can cause us to miss the shardId.
|
// may be instance of OpenSearchLeafReader. This can cause us to miss the shardId.
|
||||||
return getOpenSearchDirectoryReader(((FilterDirectoryReader) reader).getDelegate());
|
return getOpenSearchDirectoryReader(((FilterDirectoryReader) reader).getDelegate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,9 @@ import org.elasticsearch.index.shard.ShardId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link org.apache.lucene.index.FilterLeafReader} that exposes
|
* A {@link org.apache.lucene.index.FilterLeafReader} that exposes
|
||||||
* Elasticsearch internal per shard / index information like the shard ID.
|
* OpenSearch internal per shard / index information like the shard ID.
|
||||||
*/
|
*/
|
||||||
public final class ElasticsearchLeafReader extends SequentialStoredFieldsLeafReader {
|
public final class OpenSearchLeafReader extends SequentialStoredFieldsLeafReader {
|
||||||
|
|
||||||
private final ShardId shardId;
|
private final ShardId shardId;
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ public final class ElasticsearchLeafReader extends SequentialStoredFieldsLeafRea
|
||||||
*
|
*
|
||||||
* @param in specified base reader.
|
* @param in specified base reader.
|
||||||
*/
|
*/
|
||||||
public ElasticsearchLeafReader(LeafReader in, ShardId shardId) {
|
public OpenSearchLeafReader(LeafReader in, ShardId shardId) {
|
||||||
super(in);
|
super(in);
|
||||||
this.shardId = shardId;
|
this.shardId = shardId;
|
||||||
}
|
}
|
||||||
|
@ -59,16 +59,16 @@ public final class ElasticsearchLeafReader extends SequentialStoredFieldsLeafRea
|
||||||
return in.getReaderCacheHelper();
|
return in.getReaderCacheHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ElasticsearchLeafReader getElasticsearchLeafReader(LeafReader reader) {
|
public static OpenSearchLeafReader getOpenSearchLeafReader(LeafReader reader) {
|
||||||
if (reader instanceof FilterLeafReader) {
|
if (reader instanceof FilterLeafReader) {
|
||||||
if (reader instanceof ElasticsearchLeafReader) {
|
if (reader instanceof OpenSearchLeafReader) {
|
||||||
return (ElasticsearchLeafReader) reader;
|
return (OpenSearchLeafReader) reader;
|
||||||
} else {
|
} else {
|
||||||
// We need to use FilterLeafReader#getDelegate and not FilterLeafReader#unwrap, because
|
// We need to use FilterLeafReader#getDelegate and not FilterLeafReader#unwrap, because
|
||||||
// If there are multiple levels of filtered leaf readers then with the unwrap() method it immediately
|
// If there are multiple levels of filtered leaf readers then with the unwrap() method it immediately
|
||||||
// returns the most inner leaf reader and thus skipping of over any other filtered leaf reader that
|
// returns the most inner leaf reader and thus skipping of over any other filtered leaf reader that
|
||||||
// may be instance of ElasticsearchLeafReader. This can cause us to miss the shardId.
|
// may be instance of OpenSearchLeafReader. This can cause us to miss the shardId.
|
||||||
return getElasticsearchLeafReader(((FilterLeafReader) reader).getDelegate());
|
return getOpenSearchLeafReader(((FilterLeafReader) reader).getDelegate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
|
@ -23,7 +23,7 @@ import org.apache.lucene.index.DirectoryReader;
|
||||||
import org.apache.lucene.index.LeafReader;
|
import org.apache.lucene.index.LeafReader;
|
||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.lucene.index.OpenSearchDirectoryReader;
|
import org.elasticsearch.common.lucene.index.OpenSearchDirectoryReader;
|
||||||
import org.elasticsearch.common.lucene.index.ElasticsearchLeafReader;
|
import org.elasticsearch.common.lucene.index.OpenSearchLeafReader;
|
||||||
|
|
||||||
public final class ShardUtils {
|
public final class ShardUtils {
|
||||||
|
|
||||||
|
@ -35,9 +35,9 @@ public final class ShardUtils {
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public static ShardId extractShardId(LeafReader reader) {
|
public static ShardId extractShardId(LeafReader reader) {
|
||||||
final ElasticsearchLeafReader esReader = ElasticsearchLeafReader.getElasticsearchLeafReader(reader);
|
final OpenSearchLeafReader esReader = OpenSearchLeafReader.getOpenSearchLeafReader(reader);
|
||||||
if (esReader != null) {
|
if (esReader != null) {
|
||||||
assert reader.getRefCount() > 0 : "ElasticsearchLeafReader is already closed";
|
assert reader.getRefCount() > 0 : "OpenSearchLeafReader is already closed";
|
||||||
return esReader.shardId();
|
return esReader.shardId();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -55,7 +55,4 @@ public final class ShardUtils {
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException("can't extract shard ID, can't unwrap OpenSearchDirectoryReader");
|
throw new IllegalArgumentException("can't extract shard ID, can't unwrap OpenSearchDirectoryReader");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue