Package org.apache.lucene.util

Examples of org.apache.lucene.util.BitSet


                    if (nativeOrdinal != RandomAccessOrds.NO_MORE_ORDS) {
                        sLat.set(i, lat.get(nativeOrdinal));
                        sLon.set(i, lon.get(nativeOrdinal));
                    }
                }
                BitSet set = builder.buildDocsWithValuesSet();
                data = new GeoPointDoubleArrayAtomicFieldData.Single(sLon, sLat, set);
            } else {
                data = new GeoPointDoubleArrayAtomicFieldData.WithOrdinals(lon, lat, build, reader.maxDoc());
            }
            success = true;
View Full Code Here


                        final SortedNumericDoubleValues distanceValues = GeoDistance.distanceValues(geoPointValues, distances);
                        final NumericDoubleValues selectedValues;
                        if (nested == null) {
                            selectedValues = finalSortMode.select(distanceValues, Double.MAX_VALUE);
                        } else {
                            final BitSet rootDocs = nested.rootDocs(context).bits();
                            final BitSet innerDocs = nested.innerDocs(context).bits();
                            selectedValues = finalSortMode.select(distanceValues, Double.MAX_VALUE, rootDocs, innerDocs, context.reader().maxDoc());
                        }
                        return selectedValues.getRawDoubleValues();
                    }
                };
View Full Code Here

                    } else {
                        sLat.set(i, missing);
                        sLon.set(i, missing);
                    }
                }
                BitSet set = builder.buildDocsWithValuesSet();
                data = new GeoPointCompressedAtomicFieldData.Single(encoding, sLon, sLat, set);
            }
            success = true;
            return data;
        } finally {
View Full Code Here

                final SortedNumericDocValues values = indexFieldData.load(context).getLongValues();
                final NumericDocValues selectedValues;
                if (nested == null) {
                    selectedValues = sortMode.select(values, dMissingValue);
                } else {
                    final BitSet rootDocs = nested.rootDocs(context).bits();
                    final BitSet innerDocs = nested.innerDocs(context).bits();
                    selectedValues = sortMode.select(values, dMissingValue, rootDocs, innerDocs, context.reader().maxDoc());
                }
                return selectedValues;
            }
View Full Code Here

                final SortedNumericDoubleValues values = indexFieldData.load(context).getDoubleValues();
                final NumericDoubleValues selectedValues;
                if (nested == null) {
                    selectedValues = sortMode.select(values, dMissingValue);
                } else {
                    final BitSet rootDocs = nested.rootDocs(context).bits();
                    final BitSet innerDocs = nested.innerDocs(context).bits();
                    selectedValues = sortMode.select(values, dMissingValue, rootDocs, innerDocs, context.reader().maxDoc());
                }
                return selectedValues.getRawFloatValues();
            }
        };
View Full Code Here

                    final RandomAccessOrds values = ((IndexOrdinalsFieldData) indexFieldData).load(context).getOrdinalsValues();
                    final SortedDocValues selectedValues;
                    if (nested == null) {
                        selectedValues = sortMode.select(values);
                    } else {
                        final BitSet rootDocs = nested.rootDocs(context).bits();
                        final BitSet innerDocs = nested.innerDocs(context).bits();
                        selectedValues = sortMode.select(values, rootDocs, innerDocs);
                    }
                    if (sortMissingFirst(missingValue) || sortMissingLast(missingValue)) {
                        return selectedValues;
                    } else {
                        return new ReplaceMissing(selectedValues, missingBytes);
                    }
                }
               
                public BytesRef value(int slot) {
                    // TODO: When serializing the response to the coordinating node, we lose the information about
                    // whether the comparator sorts missing docs first or last. We should fix it and let
                    // TopDocs.merge deal with it (it knows how to)
                    BytesRef value = super.value(slot);
                    if (value == null) {
                        value = missingBytes;
                    }
                    return value;
                }
               
            };
        }

        final BytesRef nullPlaceHolder = new BytesRef();
        final BytesRef nonNullMissingBytes = missingBytes == null ? nullPlaceHolder : missingBytes;
        return new FieldComparator.TermValComparator(numHits, null, sortMissingLast) {

            @Override
            protected BinaryDocValues getBinaryDocValues(LeafReaderContext context, String field) throws IOException {
                final SortedBinaryDocValues values = getValues(context);
                final BinaryDocValues selectedValues;
                if (nested == null) {
                    selectedValues = sortMode.select(values, nonNullMissingBytes);
                } else {
                    final BitSet rootDocs = nested.rootDocs(context).bits();
                    final BitSet innerDocs = nested.innerDocs(context).bits();
                    selectedValues = sortMode.select(values, nonNullMissingBytes, rootDocs, innerDocs, context.reader().maxDoc());
                }
                return selectedValues;
            }
View Full Code Here

        if (acceptDocs == null) {
            acceptDocs = context.reader().getLiveDocs();
        }

        BitSet nonNestedDocs = null;
        if (nonNestedDocsFilter != null) {
            nonNestedDocs = nonNestedDocsFilter.getDocIdSet(context).bits();
        }

        DocsEnum docsEnum = null;
        BitSet result = null;
        int size = (int) parentIds.size();
        for (int i = 0; i < size; i++) {
            parentIds.get(i, idSpare);
            BytesRef uid = Uid.createUidAsBytes(parentTypeBr, idSpare, uidSpare);
            if (termsEnum.seekExact(uid)) {
                int docId;
                docsEnum = termsEnum.docs(acceptDocs, docsEnum, DocsEnum.FLAG_NONE);
                if (result == null) {
                    docId = docsEnum.nextDoc();
                    if (docId != DocIdSetIterator.NO_MORE_DOCS) {
                        // very rough heuristic that tries to get an idea of the number of documents
                        // in the set based on the number of parent ids that we didn't find in this segment
                        final int expectedCardinality = size / (i + 1);
                        // similar heuristic to BitDocIdSet.Builder
                        if (expectedCardinality >= (context.reader().maxDoc() >>> 10)) {
                            result = new FixedBitSet(context.reader().maxDoc());
                        } else {
                            result = new SparseFixedBitSet(context.reader().maxDoc());
                        }
                    } else {
                        continue;
                    }
                } else {
                    docId = docsEnum.nextDoc();
                    if (docId == DocIdSetIterator.NO_MORE_DOCS) {
                        continue;
                    }
                }
                if (nonNestedDocs != null) {
                    docId = nonNestedDocs.nextSetBit(docId);
                }
                result.set(docId);
                assert docsEnum.advance(docId + 1) == DocIdSetIterator.NO_MORE_DOCS : "DocId " + docId + " should have been the last one but docId " + docsEnum.docID() + " exists.";
            }
        }
        return result == null ? null : new BitDocIdSet(result);
    }
View Full Code Here

                final SortedNumericDoubleValues values = getValues(context);
                final NumericDoubleValues selectedValues;
                if (nested == null) {
                    selectedValues = sortMode.select(values, dMissingValue);
                } else {
                    final BitSet rootDocs = nested.rootDocs(context).bits();
                    final BitSet innerDocs = nested.innerDocs(context).bits();
                    selectedValues = sortMode.select(values, dMissingValue, rootDocs, innerDocs, context.reader().maxDoc());
                }
                return selectedValues.getRawDoubleValues();
            }
            @Override
View Full Code Here

        TermFilter tf = new TermFilter(new Term(fieldName, "19"));
        assertNull(tf.getDocIdSet(reader.getContext(), reader.getLiveDocs()));

        tf = new TermFilter(new Term(fieldName, "20"));
        DocIdSet result = tf.getDocIdSet(reader.getContext(), reader.getLiveDocs());
        BitSet bits = DocIdSets.toBitSet(result.iterator(), reader.maxDoc());
        assertThat(bits.cardinality(), equalTo(1));

        tf = new TermFilter(new Term("all", "xxx"));
        result = tf.getDocIdSet(reader.getContext(), reader.getLiveDocs());
        bits = DocIdSets.toBitSet(result.iterator(), reader.maxDoc());
        assertThat(bits.cardinality(), equalTo(100));

        reader.close();
        rd.close();
    }
View Full Code Here

        TermsFilter tf = new TermsFilter(new Term[]{new Term(fieldName, "19")});
        assertNull(tf.getDocIdSet(reader.getContext(), reader.getLiveDocs()));

        tf = new TermsFilter(new Term[]{new Term(fieldName, "19"), new Term(fieldName, "20")});
        DocIdSet result = tf.getDocIdSet(reader.getContext(), reader.getLiveDocs());
        BitSet bits = DocIdSets.toBitSet(result.iterator(), reader.maxDoc());
        assertThat(bits.cardinality(), equalTo(1));

        tf = new TermsFilter(new Term[]{new Term(fieldName, "19"), new Term(fieldName, "20"), new Term(fieldName, "10")});
        result = tf.getDocIdSet(reader.getContext(), reader.getLiveDocs());
        bits = DocIdSets.toBitSet(result.iterator(), reader.maxDoc());
        assertThat(bits.cardinality(), equalTo(2));

        tf = new TermsFilter(new Term[]{new Term(fieldName, "19"), new Term(fieldName, "20"), new Term(fieldName, "10"), new Term(fieldName, "00")});
        result = tf.getDocIdSet(reader.getContext(), reader.getLiveDocs());
        bits = DocIdSets.toBitSet(result.iterator(), reader.maxDoc());
        assertThat(bits.cardinality(), equalTo(2));

        reader.close();
        rd.close();
    }
View Full Code Here

TOP

Related Classes of org.apache.lucene.util.BitSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.