新闻资讯

新闻资讯 媒体报道

Java Bits类代码示例

编辑:016     时间:2021-12-16

Java Bits类代码示例

本文整理汇总了Java中org.apache.lucene.util.Bits类的典型用法代码示例。如果您正苦于以下问题:Java Bits类的具体用法?Java Bits怎么用?Java Bits使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

Bits类属于org.apache.lucene.util包,在下文中一共展示了Bits类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getLeafCollector

 点赞 3 
import org.apache.lucene.util.Bits; //导入依赖的package包/类 @Override public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, final LeafBucketCollector sub) throws IOException { final Bits docsWithValue; if (valuesSource != null) {
        docsWithValue = valuesSource.docsWithValue(ctx);
    } else {
        docsWithValue = new Bits.MatchNoBits(ctx.reader().maxDoc());
    } return new LeafBucketCollectorBase(sub, docsWithValue) { @Override public void collect(int doc, long bucket) throws IOException { if (docsWithValue != null && !docsWithValue.get(doc)) {
                collectBucket(sub, doc, bucket);
            }
        }
    };
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:MissingAggregator.java


示例2: getLeafCollector

 点赞 3 
import org.apache.lucene.util.Bits; //导入依赖的package包/类 @Override public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, final LeafBucketCollector sub) throws IOException { // no need to provide deleted docs to the filter final Bits[] bits = new Bits[filters.length]; for (int i = 0; i < filters.length; ++i) {
        bits[i] = Lucene.asSequentialAccessBits(ctx.reader().maxDoc(), filters[i].scorer(ctx));
    } return new LeafBucketCollectorBase(sub, null) { @Override public void collect(int doc, long bucket) throws IOException { boolean matched = false; for (int i = 0; i < bits.length; i++) { if (bits[i].get(doc)) {
                    collectBucket(sub, doc, bucketOrd(bucket, i));
                    matched = true;
                }
            } if (showOtherBucket && !matched) {
                collectBucket(sub, doc, bucketOrd(bucket, bits.length));
            }
        }
    };
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:FiltersAggregator.java

示例3: NearSpansOrdered

 点赞 3 
import org.apache.lucene.util.Bits; //导入依赖的package包/类 public NearSpansOrdered(SpanNearQuery spanNearQuery, AtomicReaderContext context, Bits acceptDocs, Map<Term,TermContext> termContexts, boolean collectPayloads) throws IOException { if (spanNearQuery.getClauses().length < 2) { throw new IllegalArgumentException("Less than 2 clauses: " + spanNearQuery);
  } this.collectPayloads = collectPayloads;
  allowedSlop = spanNearQuery.getSlop();
  SpanQuery[] clauses = spanNearQuery.getClauses();
  subSpans = new Spans[clauses.length];
  matchPayload = new LinkedList<>();
  subSpansByDoc = new Spans[clauses.length]; for (int i = 0; i < clauses.length; i++) {
    subSpans[i] = clauses[i].getSpans(context, acceptDocs, termContexts);
    subSpansByDoc[i] = subSpans[i]; // used in toSameDoc() }
  query = spanNearQuery; // kept for toString() only. }
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:NearSpansOrdered.java

示例4: exists

 点赞 3 
import org.apache.lucene.util.Bits; //导入依赖的package包/类 /**
 * Check whether there is one or more documents matching the provided query.
 */ public static boolean exists(IndexSearcher searcher, Query query) throws IOException { final Weight weight = searcher.createNormalizedWeight(query, false); // the scorer API should be more efficient at stopping after the first // match than the bulk scorer API for (LeafReaderContext context : searcher.getIndexReader().leaves()) { final Scorer scorer = weight.scorer(context); if (scorer == null) { continue;
        } final Bits liveDocs = context.reader().getLiveDocs(); final DocIdSetIterator iterator = scorer.iterator(); for (int doc = iterator.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = iterator.nextDoc()) { if (liveDocs == null || liveDocs.get(doc)) { return true;
            }
        }
    } return false;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:Lucene.java

示例5: getMissingBits

 点赞 3 
import org.apache.lucene.util.Bits; //导入依赖的package包/类 private Bits getMissingBits(final long offset) throws IOException { if (offset == -1) { return new Bits.MatchAllBits(maxDoc);
  } else { final IndexInput in = data.clone(); return new Bits() { @Override public boolean get(int index) { try {
          in.seek(offset + (index >> 3)); return (in.readByte() & (1 << (index & 7))) != 0;
        } catch (IOException e) { throw new RuntimeException(e);
        }
      } @Override public int length() { return maxDoc;
      }
    };
  }
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:Lucene45DocValuesProducer.java


示例6: getDocsWithField

 点赞 3 
import org.apache.lucene.util.Bits; //导入依赖的package包/类 @Override public Bits getDocsWithField(FieldInfo field) throws IOException { switch(field.getDocValuesType()) { case SORTED_SET: return DocValues.docsWithValue(getSortedSet(field), maxDoc); case SORTED: return DocValues.docsWithValue(getSorted(field), maxDoc); case BINARY:
      BinaryEntry be = binaries.get(field.number); return getMissingBits(be.missingOffset); case NUMERIC:
      NumericEntry ne = numerics.get(field.number); return getMissingBits(ne.missingOffset); default: throw new AssertionError();
  }
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:Lucene45DocValuesProducer.java

示例7: getMissingBits

 点赞 3 
import org.apache.lucene.util.Bits; //导入依赖的package包/类 private Bits getMissingBits(final long offset) throws IOException { if (offset == -1) { return new Bits.MatchAllBits(maxDoc);
  } else { int length = (int) ((maxDoc + 7L) >>> 3); final RandomAccessInput in = data.randomAccessSlice(offset, length); return new Bits() { @Override public boolean get(int index) { try { return (in.readByte(index >> 3) & (1 << (index & 7))) != 0;
        } catch (IOException e) { throw new RuntimeException(e);
        }
      } @Override public int length() { return maxDoc;
      }
    };
  }
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:Lucene49DocValuesProducer.java

示例8: getDocsWithField

 点赞 3 
import org.apache.lucene.util.Bits; //导入依赖的package包/类 @Override public Bits getDocsWithField(FieldInfo field) throws IOException { switch(field.getDocValuesType()) { case SORTED_SET: return DocValues.docsWithValue(getSortedSet(field), maxDoc); case SORTED_NUMERIC: return DocValues.docsWithValue(getSortedNumeric(field), maxDoc); case SORTED: return DocValues.docsWithValue(getSorted(field), maxDoc); case BINARY:
      BinaryEntry be = binaries.get(field.number); return getMissingBits(be.missingOffset); case NUMERIC:
      NumericEntry ne = numerics.get(field.number); return getMissingBits(ne.missingOffset); default: throw new AssertionError();
  }
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:Lucene49DocValuesProducer.java

示例9: UnionDocsAndPositionsEnum

 点赞 3 
import org.apache.lucene.util.Bits; //导入依赖的package包/类 public UnionDocsAndPositionsEnum(Bits liveDocs, AtomicReaderContext context, Term[] terms, Map<Term,TermContext> termContexts, TermsEnum termsEnum) throws IOException {
  List<DocsAndPositionsEnum> docsEnums = new LinkedList<>(); for (int i = 0; i < terms.length; i++) { final Term term = terms[i];
    TermState termState = termContexts.get(term).get(context.ord); if (termState == null) { // Term doesn't exist in reader continue;
    }
    termsEnum.seekExact(term.bytes(), termState);
    DocsAndPositionsEnum postings = termsEnum.docsAndPositions(liveDocs, null, DocsEnum.FLAG_NONE); if (postings == null) { // term does exist, but has no positions throw new IllegalStateException("field \"" + term.field() + "\" was indexed without position data; cannot run PhraseQuery (term=" + term.text() + ")");
    }
    cost += postings.cost();
    docsEnums.add(postings);
  }

  _queue = new DocsQueue(docsEnums);
  _posList = new IntQueue();
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:MultiPhraseQuery.java

示例10: merge

 点赞 3 
import org.apache.lucene.util.Bits; //导入依赖的package包/类 /** Merges in the term vectors from the readers in 
 *  <code>mergeState</code>. The default implementation skips
 *  over deleted documents, and uses {@link #startDocument(int)},
 *  {@link #startField(FieldInfo, int, boolean, boolean, boolean)}, 
 *  {@link #startTerm(BytesRef, int)}, {@link #addPosition(int, int, int, BytesRef)},
 *  and {@link #finish(FieldInfos, int)},
 *  returning the number of documents that were written.
 *  Implementations can override this method for more sophisticated
 *  merging (bulk-byte copying, etc). */ public int merge(MergeState mergeState) throws IOException { int docCount = 0; for (int i = 0; i < mergeState.readers.size(); i++) { final AtomicReader reader = mergeState.readers.get(i); final int maxDoc = reader.maxDoc(); final Bits liveDocs = reader.getLiveDocs(); for (int docID = 0; docID < maxDoc; docID++) { if (liveDocs != null && !liveDocs.get(docID)) { // skip deleted docs continue;
      } // NOTE: it's very important to first assign to vectors then pass it to // termVectorsWriter.addAllDocVectors; see LUCENE-1282 Fields vectors = reader.getTermVectors(docID);
      addAllDocVectors(vectors, mergeState);
      docCount++;
      mergeState.checkAbort.work(300);
    }
  }
  finish(mergeState.fieldInfos, docCount); return docCount;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:33,代码来源:TermVectorsWriter.java

示例11: docsWithValue

 点赞 2 
import org.apache.lucene.util.Bits; //导入依赖的package包/类 @Override public Bits docsWithValue(LeafReaderContext context) throws IOException { final SortedBinaryDocValues bytes = bytesValues(context); if (org.elasticsearch.index.fielddata.FieldData.unwrapSingleton(bytes) != null) { return org.elasticsearch.index.fielddata.FieldData.unwrapSingletonBits(bytes);
    } else { return org.elasticsearch.index.fielddata.FieldData.docsWithValue(bytes, context.reader().maxDoc());
    }
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:ValuesSource.java

示例12: bulkScorer

 点赞 2 
import org.apache.lucene.util.Bits; //导入依赖的package包/类 @Override public BulkScorer bulkScorer(AtomicReaderContext context, boolean scoreDocsInOrder, Bits acceptDocs) throws IOException { final DocIdSetIterator disi; if (filter != null) { assert query == null; return super.bulkScorer(context, scoreDocsInOrder, acceptDocs);
  } else { assert query != null && innerWeight != null;
    BulkScorer bulkScorer = innerWeight.bulkScorer(context, scoreDocsInOrder, acceptDocs); if (bulkScorer == null) { return null;
    } return new ConstantBulkScorer(bulkScorer, this, queryWeight);
  }
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:ConstantScoreQuery.java

示例13: docsWithValue

 点赞 2 
import org.apache.lucene.util.Bits; //导入依赖的package包/类 @Override public Bits docsWithValue(LeafReaderContext context) { final MultiGeoPointValues geoPoints = geoPointValues(context); if (org.elasticsearch.index.fielddata.FieldData.unwrapSingleton(geoPoints) != null) { return org.elasticsearch.index.fielddata.FieldData.unwrapSingletonBits(geoPoints);
    } else { return org.elasticsearch.index.fielddata.FieldData.docsWithValue(geoPoints, context.reader().maxDoc());
    }
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:10,代码来源:ValuesSource.java

示例14: createWeight

 点赞 2 
import org.apache.lucene.util.Bits; //导入依赖的package包/类 @Override public Weight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException { return new RandomAccessWeight(this) { @Override protected Bits getMatchingDocs(final LeafReaderContext context) throws IOException { final LeafSearchScript leafScript = searchScript.getLeafSearchScript(context); return new Bits() { @Override public boolean get(int doc) {
                    leafScript.setDocument(doc);
                    Object val = leafScript.run(); if (val == null) { return false;
                    } if (val instanceof Boolean) { return (Boolean) val;
                    } if (val instanceof Number) { return ((Number) val).longValue() != 0;
                    } throw new IllegalArgumentException("Can't handle type [" + val + "] in script filter");
                } @Override public int length() { return context.reader().maxDoc();
                }

            };
        }
    };
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:34,代码来源:ScriptQueryBuilder.java

示例15: getReadOnlyLiveDocs

 点赞 2 
import org.apache.lucene.util.Bits; //导入依赖的package包/类 public synchronized Bits getReadOnlyLiveDocs() { //System.out.println("getROLiveDocs seg=" + info); assert Thread.holdsLock(writer);
  liveDocsShared = true; //if (liveDocs != null) { //System.out.println("  liveCount=" + liveDocs.count()); //} return liveDocs;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:ReadersAndUpdates.java

示例16: getLeafCollector

 点赞 2 
import org.apache.lucene.util.Bits; //导入依赖的package包/类 @Override public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException { final Scorer filterScorer = filter.scorer(context); final LeafCollector in = collector.getLeafCollector(context); final Bits bits = Lucene.asSequentialAccessBits(context.reader().maxDoc(), filterScorer); return new FilterLeafCollector(in) { @Override public void collect(int doc) throws IOException { if (bits.get(doc)) {
                in.collect(doc);
            }
        }
    };
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:16,代码来源:FilteredCollector.java

示例17: FiltersFunctionFactorScorer

 点赞 2 
import org.apache.lucene.util.Bits; //导入依赖的package包/类 private FiltersFunctionFactorScorer(CustomBoostFactorWeight w, Scorer scorer, ScoreMode scoreMode, FilterFunction[] filterFunctions, float maxBoost, LeafScoreFunction[] functions, Bits[] docSets, CombineFunction scoreCombiner, boolean needsScores) throws IOException { super(scorer, w); this.scoreMode = scoreMode; this.filterFunctions = filterFunctions; this.functions = functions; this.docSets = docSets; this.scoreCombiner = scoreCombiner; this.maxBoost = maxBoost; this.needsScores = needsScores;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:FiltersFunctionScoreQuery.java

示例18: build

 点赞 2 
import org.apache.lucene.util.Bits; //导入依赖的package包/类 static DocMap build(final int maxDoc, final Bits liveDocs) { assert liveDocs != null; final PackedLongValues.Builder docMapBuilder = PackedLongValues.monotonicBuilder(PackedInts.COMPACT); int del = 0; for (int i = 0; i < maxDoc; ++i) {
    docMapBuilder.add(i - del); if (!liveDocs.get(i)) {
      ++del;
    }
  } final PackedLongValues docMap = docMapBuilder.build(); final int numDeletedDocs = del; assert docMap.size() == maxDoc; return new DocMap() { @Override public int get(int docID) { if (!liveDocs.get(docID)) { return -1;
      } return (int) docMap.get(docID);
    } @Override public int maxDoc() { return maxDoc;
    } @Override public int numDeletedDocs() { return numDeletedDocs;
    }

  };
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:36,代码来源:MergeState.java

示例19: ramBytesUsed

 点赞 2 
import org.apache.lucene.util.Bits; //导入依赖的package包/类 @Override public long ramBytesUsed() { long base = RamUsageEstimator.NUM_BYTES_OBJECT_REF; if (bits instanceof Bits.MatchAllBits || bits instanceof Bits.MatchNoBits) { return base;
  } else { return base + (bits.length() >>> 3);
  }
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:FieldCacheImpl.java

示例20: testTwoDocuments

 点赞 2 
import org.apache.lucene.util.Bits; //导入依赖的package包/类 /** 
 * test version lookup with two documents matching the ID
 */ public void testTwoDocuments() throws Exception {
    Directory dir = newDirectory();
    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(Lucene.STANDARD_ANALYZER));
    Document doc = new Document();
    doc.add(new Field(UidFieldMapper.NAME, "6", UidFieldMapper.Defaults.FIELD_TYPE));
    doc.add(new NumericDocValuesField(VersionFieldMapper.NAME, 87));
    writer.addDocument(doc);
    writer.addDocument(doc);
    DirectoryReader reader = DirectoryReader.open(writer);
    LeafReaderContext segment = reader.leaves().get(0);
    PerThreadIDAndVersionLookup lookup = new PerThreadIDAndVersionLookup(segment.reader()); // return the last doc when there are duplicates DocIdAndVersion result = lookup.lookup(new BytesRef("6"), null, segment);
    assertNotNull(result);
    assertEquals(87, result.version);
    assertEquals(1, result.docId); // delete the first doc only FixedBitSet live = new FixedBitSet(2);
    live.set(1);
    result = lookup.lookup(new BytesRef("6"), live, segment);
    assertNotNull(result);
    assertEquals(87, result.version);
    assertEquals(1, result.docId); // delete the second doc only live.clear(1);
    live.set(0);
    result = lookup.lookup(new BytesRef("6"), live, segment);
    assertNotNull(result);
    assertEquals(87, result.version);
    assertEquals(0, result.docId); // delete both docs assertNull(lookup.lookup(new BytesRef("6"), new Bits.MatchNoBits(2), segment));
    reader.close();
    writer.close();
    dir.close();
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:40,代码来源:VersionLookupTests.java

郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。

回复列表

相关推荐