本文整理汇总了Java中org.apache.lucene.util.Counter类的典型用法代码示例。如果您正苦于以下问题:Java Counter类的具体用法?Java Counter怎么用?Java Counter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Counter类属于org.apache.lucene.util包,在下文中一共展示了Counter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DefaultSearchContext
import org.apache.lucene.util.Counter; //导入依赖的package包/类
DefaultSearchContext(long id, ShardSearchRequest request, SearchShardTarget shardTarget, Engine.Searcher engineSearcher,
IndexService indexService, IndexShard indexShard,
BigArrays bigArrays, Counter timeEstimateCounter, TimeValue timeout, FetchPhase fetchPhase) {
this.id = id;
this.request = request;
this.fetchPhase = fetchPhase;
this.searchType = request.searchType();
this.shardTarget = shardTarget;
this.engineSearcher = engineSearcher;
// SearchContexts use a BigArrays that can circuit break
this.bigArrays = bigArrays.withCircuitBreaking();
this.dfsResult = new DfsSearchResult(id, shardTarget);
this.queryResult = new QuerySearchResult(id, shardTarget);
this.fetchResult = new FetchSearchResult(id, shardTarget);
this.indexShard = indexShard;
this.indexService = indexService;
this.searcher = new ContextIndexSearcher(engineSearcher, indexService.cache().query(), indexShard.getQueryCachingPolicy());
this.timeEstimateCounter = timeEstimateCounter;
this.timeout = timeout;
queryShardContext = indexService.newQueryShardContext(request.shardId().id(), searcher.getIndexReader(), request::nowInMillis);
queryShardContext.setTypes(request.types());
queryBoost = request.indexBoost();
}
示例2: CrateSearchContext
import org.apache.lucene.util.Counter; //导入依赖的package包/类
public CrateSearchContext(long id,
final long nowInMillis,
SearchShardTarget shardTarget,
Engine.Searcher engineSearcher,
IndexService indexService,
final IndexShard indexShard,
ScriptService scriptService,
PageCacheRecycler pageCacheRecycler,
BigArrays bigArrays,
Counter timeEstimateCounter,
Optional<Scroll> scroll) {
super(id, new CrateSearchShardRequest(nowInMillis, scroll, indexShard),
shardTarget, engineSearcher, indexService,
indexShard, scriptService, pageCacheRecycler,
bigArrays, timeEstimateCounter, ParseFieldMatcher.STRICT, SearchService.NO_TIMEOUT);
this.engineSearcher = engineSearcher;
}
示例3: DefaultSearchContext
import org.apache.lucene.util.Counter; //导入依赖的package包/类
public DefaultSearchContext(long id, ShardSearchRequest request, SearchShardTarget shardTarget,
Engine.Searcher engineSearcher, IndexService indexService, IndexShard indexShard,
ScriptService scriptService, PageCacheRecycler pageCacheRecycler,
BigArrays bigArrays, Counter timeEstimateCounter, ParseFieldMatcher parseFieldMatcher,
TimeValue timeout
) {
super(parseFieldMatcher, request);
this.id = id;
this.request = request;
this.searchType = request.searchType();
this.shardTarget = shardTarget;
this.engineSearcher = engineSearcher;
this.scriptService = scriptService;
this.pageCacheRecycler = pageCacheRecycler;
// SearchContexts use a BigArrays that can circuit break
this.bigArrays = bigArrays.withCircuitBreaking();
this.dfsResult = new DfsSearchResult(id, shardTarget);
this.queryResult = new QuerySearchResult(id, shardTarget);
this.fetchResult = new FetchSearchResult(id, shardTarget);
this.indexShard = indexShard;
this.indexService = indexService;
this.searcher = new ContextIndexSearcher(engineSearcher, indexService.cache().query(), indexShard.getQueryCachingPolicy());
this.timeEstimateCounter = timeEstimateCounter;
this.timeoutInMillis = timeout.millis();
}
示例4: readFromBytes
import org.apache.lucene.util.Counter; //导入依赖的package包/类
private void readFromBytes(BytesRef bytes) {
// Read pruned flag
this.setIsPruned(bytes.bytes[bytes.offset++] == 1 ? true : false);
// Read size fo the set
int size = Bytes.readInt(bytes);
// Read terms
bytesUsed = Counter.newCounter();
pool = new ByteBlockPool(new ByteBlockPool.DirectTrackingAllocator(bytesUsed));
set = new BytesRefHash(pool);
BytesRef reusable = new BytesRef();
for (int i = 0; i < size; i++) {
Bytes.readBytesRef(bytes, reusable);
set.add(reusable);
}
}
示例5: finish
import org.apache.lucene.util.Counter; //导入依赖的package包/类
public void finish() throws IOException
{
NamedList<Object> analytics = new NamedList<>();
rb.rsp.add("analytics", analytics);
NamedList<Object> fieldCounts = new NamedList<>();
analytics.add("mimetype()", fieldCounts);
for(String key : counters.keySet())
{
Counter counter = counters.get(key);
fieldCounts.add(key, counter.get());
}
if(this.delegate instanceof DelegatingCollector) {
((DelegatingCollector)this.delegate).finish();
}
}
示例6: TermsHash
import org.apache.lucene.util.Counter; //导入依赖的package包/类
public TermsHash(final DocumentsWriterPerThread docWriter, final TermsHashConsumer consumer, boolean trackAllocations, final TermsHash nextTermsHash) {
this.docState = docWriter.docState;
this.consumer = consumer;
this.trackAllocations = trackAllocations;
this.nextTermsHash = nextTermsHash;
this.bytesUsed = trackAllocations ? docWriter.bytesUsed : Counter.newCounter();
intPool = new IntBlockPool(docWriter.intBlockAllocator);
bytePool = new ByteBlockPool(docWriter.byteBlockAllocator);
if (nextTermsHash != null) {
// We are primary
primary = true;
termBytePool = bytePool;
nextTermsHash.termBytePool = bytePool;
} else {
primary = false;
}
}
示例7: DocumentsWriterPerThread
import org.apache.lucene.util.Counter; //导入依赖的package包/类
public DocumentsWriterPerThread(Directory directory, DocumentsWriter parent,
FieldInfos.Builder fieldInfos, IndexingChain indexingChain) {
this.directoryOrig = directory;
this.directory = new TrackingDirectoryWrapper(directory);
this.parent = parent;
this.fieldInfos = fieldInfos;
this.writer = parent.indexWriter;
this.infoStream = parent.infoStream;
this.codec = parent.codec;
this.docState = new DocState(this, infoStream);
this.docState.similarity = parent.indexWriter.getConfig().getSimilarity();
bytesUsed = Counter.newCounter();
byteBlockAllocator = new DirectTrackingAllocator(bytesUsed);
pendingDeletes = new BufferedDeletes();
intBlockAllocator = new IntBlockAllocator(bytesUsed);
initialize();
// this should be the last call in the ctor
// it really sucks that we need to pull this within the ctor and pass this ref to the chain!
consumer = indexingChain.getChain(this);
}
示例8: testSortAndDedupByteRefArray
import org.apache.lucene.util.Counter; //导入依赖的package包/类
public void testSortAndDedupByteRefArray() {
SortedSet<BytesRef> set = new TreeSet<>();
final int numValues = scaledRandomIntBetween(0, 10000);
List<BytesRef> tmpList = new ArrayList<>();
BytesRefArray array = new BytesRefArray(Counter.newCounter());
for (int i = 0; i < numValues; i++) {
String s = randomRealisticUnicodeOfCodepointLengthBetween(1, 100);
set.add(new BytesRef(s));
tmpList.add(new BytesRef(s));
array.append(new BytesRef(s));
}
if (randomBoolean()) {
Collections.shuffle(tmpList, random());
for (BytesRef ref : tmpList) {
array.append(ref);
}
}
int[] indices = new int[array.size()];
for (int i = 0; i < indices.length; i++) {
indices[i] = i;
}
int numUnique = CollectionUtils.sortAndDedup(array, indices);
assertThat(numUnique, equalTo(set.size()));
Iterator<BytesRef> iterator = set.iterator();
BytesRefBuilder spare = new BytesRefBuilder();
for (int i = 0; i < numUnique; i++) {
assertThat(iterator.hasNext(), is(true));
assertThat(array.get(spare, indices[i]), equalTo(iterator.next()));
}
}
示例9: testSortByteRefArray
import org.apache.lucene.util.Counter; //导入依赖的package包/类
public void testSortByteRefArray() {
List<BytesRef> values = new ArrayList<>();
final int numValues = scaledRandomIntBetween(0, 10000);
BytesRefArray array = new BytesRefArray(Counter.newCounter());
for (int i = 0; i < numValues; i++) {
String s = randomRealisticUnicodeOfCodepointLengthBetween(1, 100);
values.add(new BytesRef(s));
array.append(new BytesRef(s));
}
if (randomBoolean()) {
Collections.shuffle(values, random());
}
int[] indices = new int[array.size()];
for (int i = 0; i < indices.length; i++) {
indices[i] = i;
}
CollectionUtils.sort(array, indices);
Collections.sort(values);
Iterator<BytesRef> iterator = values.iterator();
BytesRefBuilder spare = new BytesRefBuilder();
for (int i = 0; i < values.size(); i++) {
assertThat(iterator.hasNext(), is(true));
assertThat(array.get(spare, indices[i]), equalTo(iterator.next()));
}
}
示例10: TermsHash
import org.apache.lucene.util.Counter; //导入依赖的package包/类
TermsHash(final DocumentsWriterPerThread docWriter, boolean trackAllocations, TermsHash nextTermsHash) {
this.docState = docWriter.docState;
this.trackAllocations = trackAllocations;
this.nextTermsHash = nextTermsHash;
this.bytesUsed = trackAllocations ? docWriter.bytesUsed : Counter.newCounter();
intPool = new IntBlockPool(docWriter.intBlockAllocator);
bytePool = new ByteBlockPool(docWriter.byteBlockAllocator);
if (nextTermsHash != null) {
// We are primary
termBytePool = bytePool;
nextTermsHash.termBytePool = bytePool;
}
}
示例11: BinaryDocValuesWriter
import org.apache.lucene.util.Counter; //导入依赖的package包/类
public BinaryDocValuesWriter(FieldInfo fieldInfo, Counter iwBytesUsed) {
this.fieldInfo = fieldInfo;
this.bytes = new PagedBytes(BLOCK_BITS);
this.bytesOut = bytes.getDataOutput();
this.lengths = PackedLongValues.deltaPackedBuilder(PackedInts.COMPACT);
this.iwBytesUsed = iwBytesUsed;
this.docsWithField = new FixedBitSet(64);
this.bytesUsed = docsWithFieldBytesUsed();
iwBytesUsed.addAndGet(bytesUsed);
}
示例12: SortedSetDocValuesWriter
import org.apache.lucene.util.Counter; //导入依赖的package包/类
public SortedSetDocValuesWriter(FieldInfo fieldInfo, Counter iwBytesUsed) {
this.fieldInfo = fieldInfo;
this.iwBytesUsed = iwBytesUsed;
hash = new BytesRefHash(
new ByteBlockPool(
new ByteBlockPool.DirectTrackingAllocator(iwBytesUsed)),
BytesRefHash.DEFAULT_CAPACITY,
new DirectBytesStartArray(BytesRefHash.DEFAULT_CAPACITY, iwBytesUsed));
pending = PackedLongValues.packedBuilder(PackedInts.COMPACT);
pendingCounts = PackedLongValues.deltaPackedBuilder(PackedInts.COMPACT);
bytesUsed = pending.ramBytesUsed() + pendingCounts.ramBytesUsed();
iwBytesUsed.addAndGet(bytesUsed);
}
示例13: SortedDocValuesWriter
import org.apache.lucene.util.Counter; //导入依赖的package包/类
public SortedDocValuesWriter(FieldInfo fieldInfo, Counter iwBytesUsed) {
this.fieldInfo = fieldInfo;
this.iwBytesUsed = iwBytesUsed;
hash = new BytesRefHash(
new ByteBlockPool(
new ByteBlockPool.DirectTrackingAllocator(iwBytesUsed)),
BytesRefHash.DEFAULT_CAPACITY,
new DirectBytesStartArray(BytesRefHash.DEFAULT_CAPACITY, iwBytesUsed));
pending = PackedLongValues.deltaPackedBuilder(PackedInts.COMPACT);
bytesUsed = pending.ramBytesUsed();
iwBytesUsed.addAndGet(bytesUsed);
}
示例14: NumericDocValuesWriter
import org.apache.lucene.util.Counter; //导入依赖的package包/类
public NumericDocValuesWriter(FieldInfo fieldInfo, Counter iwBytesUsed, boolean trackDocsWithField) {
pending = PackedLongValues.deltaPackedBuilder(PackedInts.COMPACT);
docsWithField = trackDocsWithField ? new FixedBitSet(64) : null;
bytesUsed = pending.ramBytesUsed() + docsWithFieldBytesUsed();
this.fieldInfo = fieldInfo;
this.iwBytesUsed = iwBytesUsed;
iwBytesUsed.addAndGet(bytesUsed);
}
示例15: SortedNumericDocValuesWriter
import org.apache.lucene.util.Counter; //导入依赖的package包/类
public SortedNumericDocValuesWriter(FieldInfo fieldInfo, Counter iwBytesUsed) {
this.fieldInfo = fieldInfo;
this.iwBytesUsed = iwBytesUsed;
pending = PackedLongValues.deltaPackedBuilder(PackedInts.COMPACT);
pendingCounts = PackedLongValues.deltaPackedBuilder(PackedInts.COMPACT);
bytesUsed = pending.ramBytesUsed() + pendingCounts.ramBytesUsed();
iwBytesUsed.addAndGet(bytesUsed);
}