You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by si...@apache.org on 2012/09/21 19:22:27 UTC
svn commit: r1388574 [18/45] - in /lucene/dev/branches/LUCENE-2878: ./
dev-tools/ dev-tools/eclipse/ dev-tools/eclipse/dot.settings/
dev-tools/idea/ dev-tools/idea/.idea/ dev-tools/idea/.idea/libraries/
dev-tools/idea/lucene/ dev-tools/idea/lucene/anal...
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/MutableBits.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/MutableBits.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/MutableBits.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/MutableBits.java Fri Sep 21 17:21:34 2012
@@ -21,5 +21,11 @@ package org.apache.lucene.util;
* Extension of Bits for live documents.
*/
public interface MutableBits extends Bits {
- public void clear(int bit);
+ /**
+ * Sets the bit specified by <code>index</code> to false.
+ * @param index index, should be non-negative and < {@link #length()}.
+ * The result of passing negative or out of bounds values is undefined
+ * by this interface, <b>just don't do it!</b>
+ */
+ public void clear(int index);
}
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/PriorityQueue.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/PriorityQueue.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/PriorityQueue.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/PriorityQueue.java Fri Sep 21 17:21:34 2012
@@ -101,9 +101,9 @@ public abstract class PriorityQueue<T> {
* If this method is extended to return a non-null value, then the following
* usage pattern is recommended:
*
- * <pre>
+ * <pre class="prettyprint">
* // extends getSentinelObject() to return a non-null value.
- * PriorityQueue<MyObject> pq = new MyQueue<MyObject>(numHits);
+ * PriorityQueue<MyObject> pq = new MyQueue<MyObject>(numHits);
* // save the 'top' element, which is guaranteed to not be null.
* MyObject pqTop = pq.top();
* <...>
@@ -177,11 +177,11 @@ public abstract class PriorityQueue<T> {
time. */
public final T pop() {
if (size > 0) {
- T result = heap[1]; // save first value
- heap[1] = heap[size]; // move last to first
- heap[size] = null; // permit GC of objects
+ T result = heap[1]; // save first value
+ heap[1] = heap[size]; // move last to first
+ heap[size] = null; // permit GC of objects
size--;
- downHeap(); // adjust heap
+ downHeap(); // adjust heap
return result;
} else
return null;
@@ -191,14 +191,14 @@ public abstract class PriorityQueue<T> {
* Should be called when the Object at top changes values. Still log(n) worst
* case, but it's at least twice as fast to
*
- * <pre>
+ * <pre class="prettyprint">
* pq.top().change();
* pq.updateTop();
* </pre>
*
* instead of
*
- * <pre>
+ * <pre class="prettyprint">
* o = pq.pop();
* o.change();
* pq.push(o);
@@ -226,26 +226,26 @@ public abstract class PriorityQueue<T> {
private final void upHeap() {
int i = size;
- T node = heap[i]; // save bottom node
+ T node = heap[i]; // save bottom node
int j = i >>> 1;
while (j > 0 && lessThan(node, heap[j])) {
- heap[i] = heap[j]; // shift parents down
+ heap[i] = heap[j]; // shift parents down
i = j;
j = j >>> 1;
}
- heap[i] = node; // install saved node
+ heap[i] = node; // install saved node
}
private final void downHeap() {
int i = 1;
- T node = heap[i]; // save top node
- int j = i << 1; // find smaller child
+ T node = heap[i]; // save top node
+ int j = i << 1; // find smaller child
int k = j + 1;
if (k <= size && lessThan(heap[k], heap[j])) {
j = k;
}
while (j <= size && lessThan(heap[j], node)) {
- heap[i] = heap[j]; // shift up child
+ heap[i] = heap[j]; // shift up child
i = j;
j = i << 1;
k = j + 1;
@@ -253,7 +253,7 @@ public abstract class PriorityQueue<T> {
j = k;
}
}
- heap[i] = node; // install saved node
+ heap[i] = node; // install saved node
}
/** This method returns the internal heap array as Object[].
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/SetOnce.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/SetOnce.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/SetOnce.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/SetOnce.java Fri Sep 21 17:21:34 2012
@@ -31,7 +31,7 @@ import java.util.concurrent.atomic.Atomi
public final class SetOnce<T> {
/** Thrown when {@link SetOnce#set(Object)} is called more than once. */
- public static final class AlreadySetException extends RuntimeException {
+ public static final class AlreadySetException extends IllegalStateException {
public AlreadySetException() {
super("The object cannot be set twice!");
}
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/SmallFloat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/SmallFloat.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/SmallFloat.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/SmallFloat.java Fri Sep 21 17:21:34 2012
@@ -21,6 +21,9 @@ package org.apache.lucene.util;
* @lucene.internal
*/
public class SmallFloat {
+
+ /** No instance */
+ private SmallFloat() {}
/** Converts a 32 bit float to an 8 bit float.
* <br>Values less than zero are all mapped to zero.
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/VirtualMethod.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/VirtualMethod.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/VirtualMethod.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/VirtualMethod.java Fri Sep 21 17:21:34 2012
@@ -31,7 +31,7 @@ import java.util.Set;
* The cost of reflection is minimized by the following usage of this class:</p>
* <p>Define <strong>static final</strong> fields in the base class ({@code BaseClass}),
* where the old and new method are declared:</p>
- * <pre>
+ * <pre class="prettyprint">
* static final VirtualMethod<BaseClass> newMethod =
* new VirtualMethod<BaseClass>(BaseClass.class, "newName", parameters...);
* static final VirtualMethod<BaseClass> oldMethod =
@@ -41,7 +41,7 @@ import java.util.Set;
* If you try to create a second instance of for the same method/{@code baseClass} combination, an exception is thrown.
* <p>To detect if e.g. the old method was overridden by a more far subclass on the inheritance path to the current
* instance's class, use a <strong>non-static</strong> field:</p>
- * <pre>
+ * <pre class="prettyprint">
* final boolean isDeprecatedMethodOverridden =
* oldMethod.getImplementationDistance(this.getClass()) > newMethod.getImplementationDistance(this.getClass());
*
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/WeakIdentityMap.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/WeakIdentityMap.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/WeakIdentityMap.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/WeakIdentityMap.java Fri Sep 21 17:21:34 2012
@@ -65,35 +65,51 @@ public final class WeakIdentityMap<K,V>
this.backingStore = backingStore;
}
+ /** Removes all of the mappings from this map. */
public void clear() {
backingStore.clear();
reap();
}
+ /** Returns {@code true} if this map contains a mapping for the specified key. */
public boolean containsKey(Object key) {
reap();
return backingStore.containsKey(new IdentityWeakReference(key, null));
}
+ /** Returns the value to which the specified key is mapped. */
public V get(Object key) {
reap();
return backingStore.get(new IdentityWeakReference(key, null));
}
+ /** Associates the specified value with the specified key in this map.
+ * If the map previously contained a mapping for this key, the old value
+ * is replaced. */
public V put(K key, V value) {
reap();
return backingStore.put(new IdentityWeakReference(key, queue), value);
}
+ /** Returns {@code true} if this map contains no key-value mappings. */
public boolean isEmpty() {
return size() == 0;
}
+ /** Removes the mapping for a key from this weak hash map if it is present.
+ * Returns the value to which this map previously associated the key,
+ * or {@code null} if the map contained no mapping for the key.
+ * A return value of {@code null} does not necessarily indicate that
+ * the map contained.*/
public V remove(Object key) {
reap();
return backingStore.remove(new IdentityWeakReference(key, null));
}
+ /** Returns the number of key-value mappings in this map. This result is a snapshot,
+ * and may not reflect unprocessed entries that will be removed before next
+ * attempted access because they are no longer referenced.
+ */
public int size() {
if (backingStore.isEmpty())
return 0;
@@ -107,6 +123,8 @@ public final class WeakIdentityMap<K,V>
public Iterator<K> keyIterator() {
reap();
final Iterator<IdentityWeakReference> iterator = backingStore.keySet().iterator();
+ // IMPORTANT: Don't use oal.util.FilterIterator here:
+ // We need *strong* reference to current key after setNext()!!!
return new Iterator<K>() {
// holds strong reference to next element in backing iterator:
private Object next = null;
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/automaton/createLevAutomata.py
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/automaton/createLevAutomata.py?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/automaton/createLevAutomata.py (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/automaton/createLevAutomata.py Fri Sep 21 17:21:34 2012
@@ -21,7 +21,8 @@
import math
import os
import sys
-sys.path.insert(0, 'moman/finenight/python')
+#sys.path.insert(0, 'moman/finenight/python')
+sys.path.insert(0, '../../../../../../../../build/core/moman/finenight/python')
try:
from possibleStates import genTransitions
except ImportError:
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/fst/FST.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/fst/FST.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/fst/FST.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/fst/FST.java Fri Sep 21 17:21:34 2012
@@ -158,7 +158,7 @@ public final class FST<T> {
private final boolean packed;
private PackedInts.Reader nodeRefToAddress;
- // If arc has this label then that arc is final/accepted
+ /** If arc has this label then that arc is final/accepted */
public static final int END_LABEL = -1;
private boolean allowArrayArcs = true;
@@ -174,7 +174,7 @@ public final class FST<T> {
// building an FST w/ willPackFST=true:
int node;
- // To node (ord or address):
+ /** To node (ord or address) */
public int target;
byte flags;
@@ -542,8 +542,8 @@ public final class FST<T> {
return v;
}
- // returns true if the node at this address has any
- // outgoing arcs
+ /** returns true if the node at this address has any
+ * outgoing arcs */
public static<T> boolean targetHasArcs(Arc<T> arc) {
return arc.target > 0;
}
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/fst/Util.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/fst/Util.java?rev=1388574&r1=1388573&r2=1388574&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/fst/Util.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/util/fst/Util.java Fri Sep 21 17:21:34 2012
@@ -89,7 +89,7 @@ public final class Util {
* pair where the output is equal to the target, and will
* return null if that output does not exist.
*
- * <p>NOTE: this only works with FST<Long>, only
+ * <p>NOTE: this only works with {@code FST<Long>}, only
* works when the outputs are ascending in order with
* the inputs and only works when you shared
* the outputs (pass doShare=true to {@link
@@ -767,6 +767,19 @@ public final class Util {
}
}
+ /** Just maps each UTF16 unit (char) to the ints in an
+ * IntsRef. */
+ public static IntsRef toUTF16(CharSequence s, IntsRef scratch) {
+ final int charLimit = s.length();
+ scratch.offset = 0;
+ scratch.length = charLimit;
+ scratch.grow(charLimit);
+ for (int idx = 0; idx < charLimit; idx++) {
+ scratch.ints[idx] = (int) s.charAt(idx);
+ }
+ return scratch;
+ }
+
/** Decodes the Unicode codepoints from the provided
* CharSequence and places them in the provided scratch
* IntsRef, which must not be null, returning it. */