1
0
Эх сурвалжийг харах

Remove unused docidset-related code.

Adrien Grand 10 жил өмнө
parent
commit
66921ffa50

+ 0 - 67
src/main/java/org/elasticsearch/common/lucene/docset/BitsDocIdSetIterator.java

@@ -1,67 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch 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.elasticsearch.common.lucene.docset;
-
-import org.apache.lucene.search.DocIdSetIterator;
-import org.apache.lucene.search.FilteredDocIdSetIterator;
-import org.apache.lucene.util.Bits;
-
-/**
- * A {@link Bits} based iterator.
- */
-public class BitsDocIdSetIterator extends MatchDocIdSetIterator {
-
-    private final Bits bits;
-
-    public BitsDocIdSetIterator(Bits bits) {
-        super(bits.length());
-        this.bits = bits;
-    }
-
-    public BitsDocIdSetIterator(int maxDoc, Bits bits) {
-        super(maxDoc);
-        this.bits = bits;
-    }
-
-    @Override
-    protected boolean matchDoc(int doc) {
-        return bits.get(doc);
-    }
-
-    public static class FilteredIterator extends FilteredDocIdSetIterator {
-
-        private final Bits bits;
-
-        FilteredIterator(DocIdSetIterator innerIter, Bits bits) {
-            super(innerIter);
-            this.bits = bits;
-        }
-
-        @Override
-        protected boolean match(int doc) {
-            return bits.get(doc);
-        }
-    }
-
-    @Override
-    public long cost() {
-        return this.bits.length();
-    }
-}

+ 0 - 37
src/main/java/org/elasticsearch/common/lucene/docset/ContextDocIdSet.java

@@ -1,37 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch 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.elasticsearch.common.lucene.docset;
-
-import org.apache.lucene.index.LeafReaderContext;
-import org.apache.lucene.search.DocIdSet;
-
-/**
- * A holder for a {@link DocIdSet} and the {@link LeafReaderContext} it is associated with.
- */
-public class ContextDocIdSet {
-
-    public final LeafReaderContext context;
-    public final DocIdSet docSet;
-
-    public ContextDocIdSet(LeafReaderContext context, DocIdSet docSet) {
-        this.context = context;
-        this.docSet = docSet;
-    }
-}

+ 0 - 80
src/main/java/org/elasticsearch/common/lucene/docset/DocIdSets.java

@@ -19,17 +19,11 @@
 
 package org.elasticsearch.common.lucene.docset;
 
-import org.apache.lucene.index.LeafReader;
 import org.apache.lucene.search.DocIdSet;
 import org.apache.lucene.search.DocIdSetIterator;
 import org.apache.lucene.search.Scorer;
 import org.apache.lucene.search.TwoPhaseIterator;
-import org.apache.lucene.util.BitDocIdSet;
-import org.apache.lucene.util.BitSet;
 import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.RamUsageEstimator;
-import org.apache.lucene.util.RoaringDocIdSet;
-import org.apache.lucene.util.SparseFixedBitSet;
 import org.elasticsearch.common.Nullable;
 
 import java.io.IOException;
@@ -38,13 +32,6 @@ import java.io.IOException;
  */
 public class DocIdSets {
 
-    /**
-     * Return the size of the doc id set, plus a reference to it.
-     */
-    public static long sizeInBytes(DocIdSet docIdSet) {
-        return RamUsageEstimator.NUM_BYTES_OBJECT_REF + docIdSet.ramBytesUsed();
-    }
-
     /**
      * Is it an empty {@link DocIdSet}?
      */
@@ -52,59 +39,6 @@ public class DocIdSets {
         return set == null || set == DocIdSet.EMPTY;
     }
 
-    /**
-     * Converts to a cacheable {@link DocIdSet}
-     * <p/>
-     * This never returns <code>null</code>.
-     */
-    public static DocIdSet toCacheable(LeafReader reader, @Nullable DocIdSet set) throws IOException {
-        if (set == null || set == DocIdSet.EMPTY) {
-            return DocIdSet.EMPTY;
-        }
-        final DocIdSetIterator it = set.iterator();
-        if (it == null) {
-            return DocIdSet.EMPTY;
-        }
-        final int firstDoc = it.nextDoc();
-        if (firstDoc == DocIdSetIterator.NO_MORE_DOCS) {
-            return DocIdSet.EMPTY;
-        }
-        if (set instanceof BitDocIdSet) {
-            return set;
-        }
-
-        final RoaringDocIdSet.Builder builder = new RoaringDocIdSet.Builder(reader.maxDoc());
-        builder.add(firstDoc);
-        for (int doc = it.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = it.nextDoc()) {
-           builder.add(doc);
-        }
-
-        return builder.build();
-    }
-
-    /**
-     * Get a build a {@link Bits} instance that will match all documents
-     * contained in {@code set}. Note that this is a potentially heavy
-     * operation as this might require to consume an iterator of this set
-     * entirely and to load it into a {@link BitSet}. Prefer using
-     * {@link #asSequentialAccessBits} if you only need to consume the
-     * {@link Bits} once and in order.
-     */
-    public static Bits toSafeBits(int maxDoc, @Nullable DocIdSet set) throws IOException {
-        if (set == null) {
-            return new Bits.MatchNoBits(maxDoc);
-        }
-        Bits bits = set.bits();
-        if (bits != null) {
-            return bits;
-        }
-        DocIdSetIterator iterator = set.iterator();
-        if (iterator == null) {
-            return new Bits.MatchNoBits(maxDoc);
-        }
-        return toBitSet(iterator, maxDoc);
-    }
-
     /**
      * Given a {@link Scorer}, return a {@link Bits} instance that will match
      * all documents contained in the set. Note that the returned {@link Bits}
@@ -168,18 +102,4 @@ public class DocIdSets {
         };
     }
 
-    /**
-     * Creates a {@link BitSet} from an iterator.
-     */
-    public static BitSet toBitSet(DocIdSetIterator iterator, int numBits) throws IOException {
-        BitDocIdSet.Builder builder = new BitDocIdSet.Builder(numBits);
-        builder.or(iterator);
-        BitDocIdSet result = builder.build();
-        if (result != null) {
-            return result.bits();
-        } else {
-            return new SparseFixedBitSet(numBits);
-        }
-    }
-
 }

+ 0 - 68
src/main/java/org/elasticsearch/common/lucene/docset/MatchDocIdSetIterator.java

@@ -1,68 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch 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.elasticsearch.common.lucene.docset;
-
-import org.apache.lucene.search.DocIdSetIterator;
-
-import java.io.IOException;
-
-/**
- */
-public abstract class MatchDocIdSetIterator extends DocIdSetIterator {
-    private final int maxDoc;
-    private int doc = -1;
-
-    public MatchDocIdSetIterator(int maxDoc) {
-        this.maxDoc = maxDoc;
-    }
-
-    protected abstract boolean matchDoc(int doc);
-
-    @Override
-    public int docID() {
-        return doc;
-    }
-
-    @Override
-    public int nextDoc() throws IOException {
-        do {
-            doc++;
-            if (doc >= maxDoc) {
-                return doc = NO_MORE_DOCS;
-            }
-        } while (!matchDoc(doc));
-        return doc;
-    }
-
-    @Override
-    public int advance(int target) throws IOException {
-        if (target >= maxDoc) {
-            return doc = NO_MORE_DOCS;
-        }
-        doc = target;
-        while (!matchDoc(doc)) {
-            doc++;
-            if (doc >= maxDoc) {
-                return doc = NO_MORE_DOCS;
-            }
-        }
-        return doc;
-    }
-}