org.apache.lucene.util.BitSet.prevSetBit()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(11.3k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中org.apache.lucene.util.BitSet.prevSetBit()方法的一些代码示例,展示了BitSet.prevSetBit()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BitSet.prevSetBit()方法的具体详情如下:
包路径:org.apache.lucene.util.BitSet
类名称:BitSet
方法名:prevSetBit

BitSet.prevSetBit介绍

[英]Returns the index of the last set bit before or on the index specified. -1 is returned if there are no more set bits.
[中]

代码示例

代码示例来源:origin: org.elasticsearch/elasticsearch

  1. private void markChildDocs(BitSet parentDocs, BitSet matchingDocs) {
  2. int currentDeleted = 0;
  3. while (currentDeleted < matchingDocs.length() &&
  4. (currentDeleted = matchingDocs.nextSetBit(currentDeleted)) != DocIdSetIterator.NO_MORE_DOCS) {
  5. int previousParent = parentDocs.prevSetBit(Math.max(0, currentDeleted-1));
  6. for (int i = previousParent + 1; i < currentDeleted; i++) {
  7. matchingDocs.set(i);
  8. }
  9. currentDeleted++;
  10. }
  11. }

代码示例来源:origin: org.elasticsearch/elasticsearch

  1. @Override
  2. public void collect(int parentDoc, long bucket) throws IOException {
  3. // if parentDoc is 0 then this means that this parent doesn't have child docs (b/c these appear always before the parent
  4. // doc), so we can skip:
  5. if (parentDoc == 0 || parentDocs == null || childDocs == null) {
  6. return;
  7. }
  8. final int prevParentDoc = parentDocs.prevSetBit(parentDoc - 1);
  9. int childDocId = childDocs.docID();
  10. if (childDocId <= prevParentDoc) {
  11. childDocId = childDocs.advance(prevParentDoc + 1);
  12. }
  13. for (; childDocId < parentDoc; childDocId = childDocs.nextDoc()) {
  14. collectBucket(sub, childDocId, bucket);
  15. }
  16. }
  17. };

代码示例来源:origin: org.elasticsearch/elasticsearch

  1. @Override
  2. public boolean advanceExact(int parentDoc) throws IOException {
  3. assert parentDoc >= lastSeenParentDoc : "can only evaluate current and upcoming parent docs";
  4. if (parentDoc == lastSeenParentDoc) {
  5. return true;
  6. }
  7. final int prevParentDoc = parentDocs.prevSetBit(parentDoc - 1);
  8. final int firstChildDoc;
  9. if (childDocs.docID() > prevParentDoc) {
  10. firstChildDoc = childDocs.docID();
  11. } else {
  12. firstChildDoc = childDocs.advance(prevParentDoc + 1);
  13. }
  14. lastSeenParentDoc = parentDoc;
  15. lastEmittedValue = pick(values, missingValue, childDocs, firstChildDoc, parentDoc, maxChildren);
  16. return true;
  17. }

代码示例来源:origin: org.elasticsearch/elasticsearch

  1. @Override
  2. public boolean advanceExact(int parentDoc) throws IOException {
  3. assert parentDoc >= lastSeenParentDoc : "can only evaluate current and upcoming root docs";
  4. if (parentDoc == lastSeenParentDoc) {
  5. return lastEmittedOrd != -1;
  6. }
  7. final int prevParentDoc = parentDocs.prevSetBit(parentDoc - 1);
  8. final int firstChildDoc;
  9. if (childDocs.docID() > prevParentDoc) {
  10. firstChildDoc = childDocs.docID();
  11. } else {
  12. firstChildDoc = childDocs.advance(prevParentDoc + 1);
  13. }
  14. docID = lastSeenParentDoc = parentDoc;
  15. lastEmittedOrd = pick(selectedValues, childDocs, firstChildDoc, parentDoc, maxChildren);
  16. return lastEmittedOrd != -1;
  17. }

代码示例来源:origin: org.elasticsearch/elasticsearch

  1. @Override
  2. public boolean advanceExact(int parentDoc) throws IOException {
  3. assert parentDoc >= lastSeenParentDoc : "can only evaluate current and upcoming parent docs";
  4. if (parentDoc == lastSeenParentDoc) {
  5. return true;
  6. } else if (parentDoc == 0) {
  7. lastEmittedValue = missingValue;
  8. return true;
  9. }
  10. final int prevParentDoc = parentDocs.prevSetBit(parentDoc - 1);
  11. final int firstChildDoc;
  12. if (childDocs.docID() > prevParentDoc) {
  13. firstChildDoc = childDocs.docID();
  14. } else {
  15. firstChildDoc = childDocs.advance(prevParentDoc + 1);
  16. }
  17. lastSeenParentDoc = parentDoc;
  18. lastEmittedValue = pick(values, missingValue, childDocs, firstChildDoc, parentDoc, maxChildren);
  19. return true;
  20. }

代码示例来源:origin: org.elasticsearch/elasticsearch

  1. @Override
  2. public boolean advanceExact(int parentDoc) throws IOException {
  3. assert parentDoc >= lastSeenParentDoc : "can only evaluate current and upcoming root docs";
  4. if (parentDoc == lastSeenParentDoc) {
  5. return true;
  6. }
  7. final int prevParentDoc = parentDocs.prevSetBit(parentDoc - 1);
  8. final int firstChildDoc;
  9. if (childDocs.docID() > prevParentDoc) {
  10. firstChildDoc = childDocs.docID();
  11. } else {
  12. firstChildDoc = childDocs.advance(prevParentDoc + 1);
  13. }
  14. lastSeenParentDoc = parentDoc;
  15. lastEmittedValue = pick(selectedValues, builder, childDocs, firstChildDoc, parentDoc, maxChildren);
  16. if (lastEmittedValue == null) {
  17. lastEmittedValue = missingValue;
  18. }
  19. return true;
  20. }

代码示例来源:origin: org.elasticsearch/elasticsearch

  1. void processBufferedChildBuckets() throws IOException {
  2. if (bucketBuffer.isEmpty()) {
  3. return;
  4. }
  5. final int prevParentDoc = parentDocs.prevSetBit(currentParentDoc - 1);
  6. int childDocId = childDocs.docID();
  7. if (childDocId <= prevParentDoc) {
  8. childDocId = childDocs.advance(prevParentDoc + 1);
  9. }
  10. for (; childDocId < currentParentDoc; childDocId = childDocs.nextDoc()) {
  11. cachedScorer.doc = childDocId;
  12. final long[] buffer = bucketBuffer.buffer;
  13. final int size = bucketBuffer.size();
  14. for (int i = 0; i < size; i++) {
  15. collectBucket(sub, childDocId, buffer[i]);
  16. }
  17. }
  18. bucketBuffer.clear();
  19. }
  20. }

代码示例来源:origin: org.elasticsearch/elasticsearch

  1. int previousParent = parentBits.prevSetBit(currentParent);
  2. for (int docId = childIter.advance(previousParent + 1); docId < nestedSubDocId && docId != DocIdSetIterator.NO_MORE_DOCS;
  3. docId = childIter.nextDoc()) {

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

  1. private void markChildDocs(BitSet parentDocs, BitSet matchingDocs) {
  2. int currentDeleted = 0;
  3. while (currentDeleted < matchingDocs.length() &&
  4. (currentDeleted = matchingDocs.nextSetBit(currentDeleted)) != DocIdSetIterator.NO_MORE_DOCS) {
  5. int previousParent = parentDocs.prevSetBit(Math.max(0, currentDeleted-1));
  6. for (int i = previousParent + 1; i < currentDeleted; i++) {
  7. matchingDocs.set(i);
  8. }
  9. currentDeleted++;
  10. }
  11. }

代码示例来源:origin: apache/servicemix-bundles

  1. private void markChildDocs(BitSet parentDocs, BitSet matchingDocs) {
  2. int currentDeleted = 0;
  3. while (currentDeleted < matchingDocs.length() &&
  4. (currentDeleted = matchingDocs.nextSetBit(currentDeleted)) != DocIdSetIterator.NO_MORE_DOCS) {
  5. int previousParent = parentDocs.prevSetBit(Math.max(0, currentDeleted-1));
  6. for (int i = previousParent + 1; i < currentDeleted; i++) {
  7. matchingDocs.set(i);
  8. }
  9. currentDeleted++;
  10. }
  11. }

代码示例来源:origin: apache/servicemix-bundles

  1. @Override
  2. public boolean advanceExact(int parentDoc) throws IOException {
  3. assert parentDoc >= lastSeenParentDoc : "can only evaluate current and upcoming parent docs";
  4. if (parentDoc == lastSeenParentDoc) {
  5. return true;
  6. }
  7. final int prevParentDoc = parentDocs.prevSetBit(parentDoc - 1);
  8. final int firstChildDoc;
  9. if (childDocs.docID() > prevParentDoc) {
  10. firstChildDoc = childDocs.docID();
  11. } else {
  12. firstChildDoc = childDocs.advance(prevParentDoc + 1);
  13. }
  14. lastSeenParentDoc = parentDoc;
  15. lastEmittedValue = pick(values, missingValue, childDocs, firstChildDoc, parentDoc);
  16. return true;
  17. }

代码示例来源:origin: apache/servicemix-bundles

  1. @Override
  2. public boolean advanceExact(int parentDoc) throws IOException {
  3. assert parentDoc >= lastSeenParentDoc : "can only evaluate current and upcoming root docs";
  4. if (parentDoc == lastSeenParentDoc) {
  5. return lastEmittedOrd != -1;
  6. }
  7. final int prevParentDoc = parentDocs.prevSetBit(parentDoc - 1);
  8. final int firstChildDoc;
  9. if (childDocs.docID() > prevParentDoc) {
  10. firstChildDoc = childDocs.docID();
  11. } else {
  12. firstChildDoc = childDocs.advance(prevParentDoc + 1);
  13. }
  14. docID = lastSeenParentDoc = parentDoc;
  15. lastEmittedOrd = pick(selectedValues, childDocs, firstChildDoc, parentDoc);
  16. return lastEmittedOrd != -1;
  17. }

代码示例来源:origin: harbby/presto-connectors

  1. @Override
  2. public boolean get(int docID) {
  3. assert parents.get(docID) : "this selector may only be used on parent documents";
  4. if (docID == 0) {
  5. // no children
  6. return false;
  7. }
  8. final int firstChild = parents.prevSetBit(docID - 1) + 1;
  9. for (int child = children.nextSetBit(firstChild); child < docID; child = children.nextSetBit(child + 1)) {
  10. if (docsWithValue.get(child)) {
  11. return true;
  12. }
  13. }
  14. return false;
  15. }

代码示例来源:origin: org.codelibs/elasticsearch-querybuilders

  1. @Override
  2. public void collect(int parentDoc, long bucket) throws IOException {
  3. // if parentDoc is 0 then this means that this parent doesn't have child docs (b/c these appear always before the parent
  4. // doc), so we can skip:
  5. if (parentDoc == 0 || parentDocs == null || childDocs == null) {
  6. return;
  7. }
  8. final int prevParentDoc = parentDocs.prevSetBit(parentDoc - 1);
  9. int childDocId = childDocs.docID();
  10. if (childDocId <= prevParentDoc) {
  11. childDocId = childDocs.advance(prevParentDoc + 1);
  12. }
  13. for (; childDocId < parentDoc; childDocId = childDocs.nextDoc()) {
  14. collectBucket(sub, childDocId, bucket);
  15. }
  16. }
  17. };

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

  1. @Override
  2. public void collect(int parentDoc, long bucket) throws IOException {
  3. // if parentDoc is 0 then this means that this parent doesn't have child docs (b/c these appear always before the parent
  4. // doc), so we can skip:
  5. if (parentDoc == 0 || parentDocs == null || childDocs == null) {
  6. return;
  7. }
  8. final int prevParentDoc = parentDocs.prevSetBit(parentDoc - 1);
  9. int childDocId = childDocs.docID();
  10. if (childDocId <= prevParentDoc) {
  11. childDocId = childDocs.advance(prevParentDoc + 1);
  12. }
  13. for (; childDocId < parentDoc; childDocId = childDocs.nextDoc()) {
  14. collectBucket(sub, childDocId, bucket);
  15. }
  16. }
  17. };

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

  1. @Override
  2. public boolean advanceExact(int parentDoc) throws IOException {
  3. assert parentDoc >= lastSeenParentDoc : "can only evaluate current and upcoming parent docs";
  4. if (parentDoc == lastSeenParentDoc) {
  5. return true;
  6. }
  7. final int prevParentDoc = parentDocs.prevSetBit(parentDoc - 1);
  8. final int firstChildDoc;
  9. if (childDocs.docID() > prevParentDoc) {
  10. firstChildDoc = childDocs.docID();
  11. } else {
  12. firstChildDoc = childDocs.advance(prevParentDoc + 1);
  13. }
  14. lastSeenParentDoc = parentDoc;
  15. lastEmittedValue = pick(values, missingValue, childDocs, firstChildDoc, parentDoc, maxChildren);
  16. return true;
  17. }

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

  1. @Override
  2. public void collect(int parentDoc, long bucket) throws IOException {
  3. // if parentDoc is 0 then this means that this parent doesn't have child docs (b/c these appear always before the parent
  4. // doc), so we can skip:
  5. if (parentDoc == 0 || parentDocs == null || childDocs == null) {
  6. return;
  7. }
  8. final int prevParentDoc = parentDocs.prevSetBit(parentDoc - 1);
  9. int childDocId = childDocs.docID();
  10. if (childDocId <= prevParentDoc) {
  11. childDocId = childDocs.advance(prevParentDoc + 1);
  12. }
  13. for (; childDocId < parentDoc; childDocId = childDocs.nextDoc()) {
  14. collectBucket(sub, childDocId, bucket);
  15. }
  16. }
  17. };

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

  1. @Override
  2. public boolean advanceExact(int parentDoc) throws IOException {
  3. assert parentDoc >= lastSeenParentDoc : "can only evaluate current and upcoming root docs";
  4. if (parentDoc == lastSeenParentDoc) {
  5. return lastEmittedOrd != -1;
  6. }
  7. final int prevParentDoc = parentDocs.prevSetBit(parentDoc - 1);
  8. final int firstChildDoc;
  9. if (childDocs.docID() > prevParentDoc) {
  10. firstChildDoc = childDocs.docID();
  11. } else {
  12. firstChildDoc = childDocs.advance(prevParentDoc + 1);
  13. }
  14. docID = lastSeenParentDoc = parentDoc;
  15. lastEmittedOrd = pick(selectedValues, childDocs, firstChildDoc, parentDoc, maxChildren);
  16. return lastEmittedOrd != -1;
  17. }

代码示例来源:origin: apache/servicemix-bundles

  1. @Override
  2. public void collect(int parentDoc, long bucket) throws IOException {
  3. // if parentDoc is 0 then this means that this parent doesn't have child docs (b/c these appear always before the parent
  4. // doc), so we can skip:
  5. if (parentDoc == 0 || parentDocs == null || childDocs == null) {
  6. return;
  7. }
  8. final int prevParentDoc = parentDocs.prevSetBit(parentDoc - 1);
  9. int childDocId = childDocs.docID();
  10. if (childDocId <= prevParentDoc) {
  11. childDocId = childDocs.advance(prevParentDoc + 1);
  12. }
  13. for (; childDocId < parentDoc; childDocId = childDocs.nextDoc()) {
  14. collectBucket(sub, childDocId, bucket);
  15. }
  16. }
  17. };

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

  1. void processBufferedChildBuckets() throws IOException {
  2. if (bucketBuffer.isEmpty()) {
  3. return;
  4. }
  5. final int prevParentDoc = parentDocs.prevSetBit(currentParentDoc - 1);
  6. int childDocId = childDocs.docID();
  7. if (childDocId <= prevParentDoc) {
  8. childDocId = childDocs.advance(prevParentDoc + 1);
  9. }
  10. for (; childDocId < currentParentDoc; childDocId = childDocs.nextDoc()) {
  11. final long[] buffer = bucketBuffer.buffer;
  12. final int size = bucketBuffer.size();
  13. for (int i = 0; i < size; i++) {
  14. collectBucket(sub, childDocId, buffer[i]);
  15. }
  16. }
  17. bucketBuffer.clear();
  18. }

相关文章