com.carrotsearch.hppc.cursors.IntIntCursor Java Examples
The following examples show how to use
com.carrotsearch.hppc.cursors.IntIntCursor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CollapsingQParserPlugin.java From lucene-solr with Apache License 2.0 | 5 votes |
public OrdFieldValueStrategy(int maxDoc, int valueCount, int nullPolicy, boolean needsScores, IntIntHashMap boostDocsMap, SortedDocValues values) { this.ords = new IntIntDynamicMap(valueCount, -1); this.nullPolicy = nullPolicy; this.needsScores = needsScores; this.collapsedSet = new FixedBitSet(maxDoc); if(boostDocsMap != null) { this.boosts = true; this.boostOrds = new IntArrayList(); this.boostDocs = new IntArrayList(); int[] bd = new int[boostDocsMap.size()]; Iterator<IntIntCursor> it = boostDocsMap.iterator(); int index = -1; while(it.hasNext()) { IntIntCursor cursor = it.next(); bd[++index] = cursor.key; } Arrays.sort(bd); this.mergeBoost = new MergeBoost(bd); this.boosted = true; } if (this.needsScores) { this.scores = new IntFloatDynamicMap(valueCount, 0.0f); if(nullPolicy == CollapsingPostFilter.NULL_POLICY_EXPAND) { nullScores = new FloatArrayList(); } } }
Example #2
Source File: CollapsingQParserPlugin.java From lucene-solr with Apache License 2.0 | 5 votes |
public IntFieldValueStrategy(int maxDoc, int size, String collapseField, int nullValue, int nullPolicy, boolean needsScores, IntIntHashMap boostDocsMap) { this.collapseField = collapseField; this.nullValue = nullValue; this.nullPolicy = nullPolicy; this.needsScores = needsScores; this.collapsedSet = new FixedBitSet(maxDoc); this.cmap = new IntIntHashMap(size); this.docs = new IntIntDynamicMap(size, 0); if(boostDocsMap != null) { this.boosts = true; this.boostDocs = new IntArrayList(); this.boostKeys = new IntArrayList(); int[] bd = new int[boostDocsMap.size()]; Iterator<IntIntCursor> it = boostDocsMap.iterator(); int index = -1; while(it.hasNext()) { IntIntCursor cursor = it.next(); bd[++index] = cursor.key; } Arrays.sort(bd); this.mergeBoost = new MergeBoost(bd); } if(needsScores) { this.scores = new IntFloatDynamicMap(size, 0.0f); if(nullPolicy == CollapsingPostFilter.NULL_POLICY_EXPAND) { nullScores = new FloatArrayList(); } } }
Example #3
Source File: CollapsingQParserPlugin.java From lucene-solr with Apache License 2.0 | 5 votes |
public FixedBitSet getCollapsedSet() { if(nullDoc > -1) { this.collapsedSet.set(nullDoc); } //Handle the boosted docs. if(this.boostKeys != null) { int s = boostKeys.size(); for(int i=0; i<s; i++) { int key = this.boostKeys.get(i); if(key != nullValue) { cmap.remove(key); } //Add the boosted docs to the collapsedSet this.collapsedSet.set(boostDocs.get(i)); } mergeBoost.reset(); } Iterator<IntIntCursor> it1 = cmap.iterator(); while(it1.hasNext()) { IntIntCursor cursor = it1.next(); int pointer = cursor.value; collapsedSet.set(docs.get(pointer)); } return collapsedSet; }
Example #4
Source File: CFSA2Serializer.java From morfologik-stemming with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Compute the set of states that should be linearized first to minimize other * states goto length. */ private int[] computeFirstStates(IntIntHashMap inlinkCount, int maxStates, int minInlinkCount) { Comparator<IntIntHolder> comparator = new Comparator<FSAUtils.IntIntHolder>() { public int compare(IntIntHolder o1, IntIntHolder o2) { int v = o1.a - o2.a; return v == 0 ? (o1.b - o2.b) : v; } }; PriorityQueue<IntIntHolder> stateInlink = new PriorityQueue<IntIntHolder>(1, comparator); IntIntHolder scratch = new IntIntHolder(); for (IntIntCursor c : inlinkCount) { if (c.value > minInlinkCount) { scratch.a = c.value; scratch.b = c.key; if (stateInlink.size() < maxStates || comparator.compare(scratch, stateInlink.peek()) > 0) { stateInlink.add(new IntIntHolder(c.value, c.key)); if (stateInlink.size() > maxStates) { stateInlink.remove(); } } } } int [] states = new int [stateInlink.size()]; for (int position = states.length; !stateInlink.isEmpty();) { IntIntHolder i = stateInlink.remove(); states[--position] = i.b; } return states; }
Example #5
Source File: InstructionModifier.java From Bats with Apache License 2.0 | 4 votes |
@Override public void visitEnd() { if (logger.isTraceEnabled()) { final StringBuilder sb = new StringBuilder(); sb.append("InstructionModifier "); sb.append(name); sb.append(' '); sb.append(signature); sb.append('\n'); if ((desc != null) && !desc.isEmpty()) { sb.append(" desc: "); sb.append(desc); sb.append('\n'); } int idenId = 0; // used to generate unique ids for the ValueHolderIden's int itemCount = 0; // counts up the number of items found final HashMap<ValueHolderIden, Integer> seenIdens = new HashMap<>(); // iden -> idenId sb.append(" .oldToNew:\n"); for (final IntObjectCursor<ValueHolderIden.ValueHolderSub> ioc : oldToNew) { final ValueHolderIden iden = ioc.value.iden(); if (!seenIdens.containsKey(iden)) { seenIdens.put(iden, ++idenId); sb.append("ValueHolderIden[" + idenId + "]:\n"); iden.dump(sb); } sb.append(" " + ioc.key + " => " + ioc.value + '[' + seenIdens.get(iden) + "]\n"); ++itemCount; } sb.append(" .oldLocalToFirst:\n"); for (final IntIntCursor iic : oldLocalToFirst) { sb.append(" " + iic.key + " => " + iic.value + '\n'); ++itemCount; } if (itemCount > 0) { logger.debug(sb.toString()); } } super.visitEnd(); }
Example #6
Source File: CollapsingQParserPlugin.java From lucene-solr with Apache License 2.0 | 4 votes |
public OrdScoreCollector(int maxDoc, int segments, DocValuesProducer collapseValuesProducer, int nullPolicy, IntIntHashMap boostDocsMap, IndexSearcher searcher) throws IOException { this.maxDoc = maxDoc; this.contexts = new LeafReaderContext[segments]; List<LeafReaderContext> con = searcher.getTopReaderContext().leaves(); for(int i=0; i<con.size(); i++) { contexts[i] = con.get(i); } this.collapsedSet = new FixedBitSet(maxDoc); this.collapseValuesProducer = collapseValuesProducer; this.collapseValues = collapseValuesProducer.getSorted(null); int valueCount = collapseValues.getValueCount(); if(collapseValues instanceof MultiDocValues.MultiSortedDocValues) { this.multiSortedDocValues = (MultiDocValues.MultiSortedDocValues)collapseValues; this.ordinalMap = multiSortedDocValues.mapping; } this.ords = new IntIntDynamicMap(valueCount, -1); this.scores = new IntFloatDynamicMap(valueCount, -Float.MAX_VALUE); this.nullPolicy = nullPolicy; if(nullPolicy == CollapsingPostFilter.NULL_POLICY_EXPAND) { nullScores = new FloatArrayList(); } if(boostDocsMap != null) { this.boosts = true; this.boostOrds = new IntArrayList(); this.boostDocs = new IntArrayList(); int[] bd = new int[boostDocsMap.size()]; Iterator<IntIntCursor> it = boostDocsMap.iterator(); int index = -1; while(it.hasNext()) { IntIntCursor cursor = it.next(); bd[++index] = cursor.key; } Arrays.sort(bd); this.mergeBoost = new MergeBoost(bd); } }
Example #7
Source File: CollapsingQParserPlugin.java From lucene-solr with Apache License 2.0 | 4 votes |
public IntScoreCollector(int maxDoc, int segments, int nullValue, int nullPolicy, int size, String field, IntIntHashMap boostDocsMap, IndexSearcher searcher) { this.maxDoc = maxDoc; this.contexts = new LeafReaderContext[segments]; List<LeafReaderContext> con = searcher.getTopReaderContext().leaves(); for(int i=0; i<con.size(); i++) { contexts[i] = con.get(i); } this.collapsedSet = new FixedBitSet(maxDoc); this.nullValue = nullValue; this.nullPolicy = nullPolicy; if(nullPolicy == CollapsingPostFilter.NULL_POLICY_EXPAND) { nullScores = new FloatArrayList(); } this.cmap = new IntLongHashMap(size); this.field = field; if(boostDocsMap != null) { this.boosts = true; this.boostDocs = new IntArrayList(); this.boostKeys = new IntArrayList(); int[] bd = new int[boostDocsMap.size()]; Iterator<IntIntCursor> it = boostDocsMap.iterator(); int index = -1; while(it.hasNext()) { IntIntCursor cursor = it.next(); bd[++index] = cursor.key; } Arrays.sort(bd); this.mergeBoost = new MergeBoost(bd); this.boosts = true; } }