You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by bu...@apache.org on 2011/02/22 02:01:11 UTC
svn commit: r1073192 [13/32] - in /lucene/dev/branches/realtime_search: ./
dev-tools/eclipse/ dev-tools/idea/.idea/ dev-tools/idea/lucene/contrib/ant/
dev-tools/idea/lucene/contrib/demo/
dev-tools/idea/lucene/contrib/highlighter/ dev-tools/idea/lucene/...
Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/CollectionUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/CollectionUtil.java?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/CollectionUtil.java (original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/CollectionUtil.java Tue Feb 22 01:00:39 2011
@@ -140,7 +140,7 @@ public final class CollectionUtil {
/**
* Sorts the given random access {@link List} using the {@link Comparator}.
* The list must implement {@link RandomAccess}. This method uses the insertion sort
- * algorithm. It is only recommened to use this algorithm for partially sorted small lists!
+ * algorithm. It is only recommended to use this algorithm for partially sorted small lists!
* @throws IllegalArgumentException if list is e.g. a linked list without random access.
*/
public static <T> void insertionSort(List<T> list, Comparator<? super T> comp) {
@@ -150,7 +150,7 @@ public final class CollectionUtil {
/**
* Sorts the given random access {@link List} in natural order.
* The list must implement {@link RandomAccess}. This method uses the insertion sort
- * algorithm. It is only recommened to use this algorithm for partially sorted small lists!
+ * algorithm. It is only recommended to use this algorithm for partially sorted small lists!
* @throws IllegalArgumentException if list is e.g. a linked list without random access.
*/
public static <T extends Comparable<? super T>> void insertionSort(List<T> list) {
Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/DoubleBarrelLRUCache.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/DoubleBarrelLRUCache.java?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/DoubleBarrelLRUCache.java (original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/DoubleBarrelLRUCache.java Tue Feb 22 01:00:39 2011
@@ -45,6 +45,7 @@ import java.util.Map;
final public class DoubleBarrelLRUCache<K extends DoubleBarrelLRUCache.CloneableKey,V> {
public static abstract class CloneableKey {
+ @Override
abstract public Object clone();
}
@@ -73,7 +74,7 @@ final public class DoubleBarrelLRUCache<
secondary = cache2;
}
- // Try primary frist
+ // Try primary first
V result = primary.get(key);
if (result == null) {
// Not found -- try secondary
Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/IOUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/IOUtils.java?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/IOUtils.java (original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/IOUtils.java Tue Feb 22 01:00:39 2011
@@ -34,7 +34,7 @@ public final class IOUtils {
* Closeable resource1 = null, resource2 = null, resource3 = null;
* ExpectedException priorE = null;
* try {
- * resource1 = ...; resource2 = ...; resource3 = ...; // Aquisition may throw ExpectedException
+ * resource1 = ...; resource2 = ...; resource3 = ...; // Acquisition may throw ExpectedException
* ..do..stuff.. // May throw ExpectedException
* } catch (ExpectedException e) {
* priorE = e;
Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/IntsRef.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/IntsRef.java?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/IntsRef.java (original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/IntsRef.java Tue Feb 22 01:00:39 2011
@@ -123,6 +123,7 @@ public final class IntsRef implements Co
}
}
+ @Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append('[');
Added: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/MapBackedSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/MapBackedSet.java?rev=1073192&view=auto
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/MapBackedSet.java (added)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/MapBackedSet.java Tue Feb 22 01:00:39 2011
@@ -0,0 +1,69 @@
+package org.apache.lucene.util;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.AbstractSet;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * A Set implementation that wraps an actual Map based
+ * implementation.
+ *
+ * @lucene.internal
+ */
+public final class MapBackedSet<E> extends AbstractSet<E> {
+ private final Map<E, Boolean> map;
+
+ /**
+ * Creates a new instance which wraps the specified {@code map}.
+ */
+ public MapBackedSet(Map<E, Boolean> map) {
+ this.map = map;
+ }
+
+ @Override
+ public int size() {
+ return map.size();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ return map.containsKey(o);
+ }
+
+ @Override
+ public boolean add(E o) {
+ return map.put(o, Boolean.TRUE) == null;
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ return map.remove(o) != null;
+ }
+
+ @Override
+ public void clear() {
+ map.clear();
+ }
+
+ @Override
+ public Iterator<E> iterator() {
+ return map.keySet().iterator();
+ }
+}
Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/NumericUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/NumericUtils.java?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/NumericUtils.java (original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/NumericUtils.java Tue Feb 22 01:00:39 2011
@@ -22,8 +22,6 @@ import org.apache.lucene.document.Numeri
import org.apache.lucene.search.NumericRangeFilter;
import org.apache.lucene.search.NumericRangeQuery; // for javadocs
-// TODO: Remove the commented out methods before release!
-
/**
* This is a helper class to generate prefix-encoded representations for numerical values
* and supplies converters to represent float/double values as sortable integers/longs.
Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/OpenBitSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/OpenBitSet.java?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/OpenBitSet.java (original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/OpenBitSet.java Tue Feb 22 01:00:39 2011
@@ -18,7 +18,6 @@
package org.apache.lucene.util;
import java.util.Arrays;
-import java.io.Serializable;
import org.apache.lucene.search.DocIdSet;
import org.apache.lucene.search.DocIdSetIterator;
@@ -75,7 +74,7 @@ Test system: AMD Opteron, 64 bit linux,
</table>
*/
-public class OpenBitSet extends DocIdSet implements Bits, Cloneable, Serializable {
+public class OpenBitSet extends DocIdSet implements Bits, Cloneable {
protected long[] bits;
protected int wlen; // number of words (elements) used in the array
Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/PriorityQueue.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/PriorityQueue.java?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/PriorityQueue.java (original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/PriorityQueue.java Tue Feb 22 01:00:39 2011
@@ -32,7 +32,9 @@ public abstract class PriorityQueue<T> {
protected T[] heap;
/** Determines the ordering of objects in this priority queue. Subclasses
- must define this one method. */
+ * must define this one method.
+ * @return <code>true</code> iff parameter <tt>a</tt> is less than parameter <tt>b</tt>.
+ */
protected abstract boolean lessThan(T a, T b);
/**
Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/ReaderUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/ReaderUtil.java?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/ReaderUtil.java (original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/ReaderUtil.java Tue Feb 22 01:00:39 2011
@@ -47,6 +47,7 @@ public final class ReaderUtil {
this.readerIndex = readerIndex;
}
+ @Override
public String toString() {
return "slice start=" + start + " length=" + length + " readerIndex=" + readerIndex;
}
Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/SetOnce.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/SetOnce.java?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/SetOnce.java (original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/SetOnce.java Tue Feb 22 01:00:39 2011
@@ -49,7 +49,7 @@ public final class SetOnce<T> {
}
/**
- * Creates a new instnace with the internal object set to the given object.
+ * Creates a new instance with the internal object set to the given object.
* Note that any calls to {@link #set(Object)} afterwards will result in
* {@link AlreadySetException}
*
Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/Automaton.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/Automaton.java?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/Automaton.java (original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/Automaton.java Tue Feb 22 01:00:39 2011
@@ -29,7 +29,6 @@
package org.apache.lucene.util.automaton;
-import java.io.Serializable;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collection;
@@ -66,9 +65,16 @@ import org.apache.lucene.util.RamUsageEs
* assumed by the built-in automata operations.
*
* <p>
+ * <p>
+ * Note: This class has internal mutable state and is not thread safe. It is
+ * the caller's responsibility to ensure any necessary synchronization if you
+ * wish to use the same Automaton from multiple threads. In general it is instead
+ * recommended to use a {@link RunAutomaton} for multithreaded matching: it is immutable,
+ * thread safe, and much faster.
+ * </p>
* @lucene.experimental
*/
-public class Automaton implements Serializable, Cloneable {
+public class Automaton implements Cloneable {
/**
* Minimize using Hopcroft's O(n log n) algorithm. This is regarded as one of
Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/BasicOperations.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/BasicOperations.java?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/BasicOperations.java (original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/BasicOperations.java Tue Feb 22 01:00:39 2011
@@ -483,10 +483,12 @@ final public class BasicOperations {
starts.count = 0;
}
+ @Override
public boolean equals(Object other) {
return ((PointTransitions) other).point == point;
}
+ @Override
public int hashCode() {
return point;
}
@@ -563,6 +565,7 @@ final public class BasicOperations {
find(1+t.max).ends.add(t);
}
+ @Override
public String toString() {
StringBuilder s = new StringBuilder();
for(int i=0;i<count;i++) {
Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/ByteRunAutomaton.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/ByteRunAutomaton.java?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/ByteRunAutomaton.java (original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/ByteRunAutomaton.java Tue Feb 22 01:00:39 2011
@@ -20,7 +20,12 @@ package org.apache.lucene.util.automaton
public class ByteRunAutomaton extends RunAutomaton {
public ByteRunAutomaton(Automaton a) {
- super(new UTF32ToUTF8().convert(a), 256, true);
+ this(a, false);
+ }
+
+ /** expert: if utf8 is true, the input is already byte-based */
+ public ByteRunAutomaton(Automaton a, boolean utf8) {
+ super(utf8 ? a : new UTF32ToUTF8().convert(a), 256, true);
}
/**
Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/RunAutomaton.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/RunAutomaton.java?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/RunAutomaton.java (original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/RunAutomaton.java Tue Feb 22 01:00:39 2011
@@ -29,14 +29,12 @@
package org.apache.lucene.util.automaton;
-import java.io.Serializable;
-
/**
* Finite-state automaton with fast run operation.
*
* @lucene.experimental
*/
-public abstract class RunAutomaton implements Serializable {
+public abstract class RunAutomaton {
final int maxInterval;
final int size;
final boolean[] accept;
@@ -45,7 +43,6 @@ public abstract class RunAutomaton imple
// getCharClass(c)]
final int[] points; // char interval start points
final int[] classmap; // map from char number to class class
- final Automaton automaton;
/**
* Returns a string representation of this automaton.
@@ -113,13 +110,6 @@ public abstract class RunAutomaton imple
final int getCharClass(int c) {
return SpecialOperations.findIndex(c, points);
}
-
- /**
- * @return the automaton
- */
- public Automaton getAutomaton() {
- return automaton;
- }
/**
* Constructs a new <code>RunAutomaton</code> from a deterministic
@@ -160,7 +150,6 @@ public abstract class RunAutomaton imple
} else {
classmap = null;
}
- this.automaton = a;
}
/**
Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/SortedIntSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/SortedIntSet.java?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/SortedIntSet.java (original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/SortedIntSet.java Tue Feb 22 01:00:39 2011
@@ -159,10 +159,12 @@ final class SortedIntSet {
return new FrozenIntSet(c, hashCode, state);
}
+ @Override
public int hashCode() {
return hashCode;
}
+ @Override
public boolean equals(Object _other) {
if (_other == null) {
return false;
@@ -186,6 +188,7 @@ final class SortedIntSet {
return true;
}
+ @Override
public String toString() {
StringBuilder sb = new StringBuilder().append('[');
for(int i=0;i<upto;i++) {
@@ -215,10 +218,12 @@ final class SortedIntSet {
this.hashCode = 683+num;
}
+ @Override
public int hashCode() {
return hashCode;
}
+ @Override
public boolean equals(Object _other) {
if (_other == null) {
return false;
@@ -256,6 +261,7 @@ final class SortedIntSet {
return false;
}
+ @Override
public String toString() {
StringBuilder sb = new StringBuilder().append('[');
for(int i=0;i<values.length;i++) {
Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/State.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/State.java?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/State.java (original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/State.java Tue Feb 22 01:00:39 2011
@@ -31,7 +31,6 @@ package org.apache.lucene.util.automaton
import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.RamUsageEstimator;
-import java.io.Serializable;
import java.util.Collection;
import java.util.Comparator;
import java.util.Iterator;
@@ -41,7 +40,7 @@ import java.util.Iterator;
*
* @lucene.experimental
*/
-public class State implements Serializable, Comparable<State> {
+public class State implements Comparable<State> {
boolean accept;
public Transition[] transitionsArray;
Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/Transition.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/Transition.java?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/Transition.java (original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/Transition.java Tue Feb 22 01:00:39 2011
@@ -29,7 +29,6 @@
package org.apache.lucene.util.automaton;
-import java.io.Serializable;
import java.util.Comparator;
/**
@@ -40,7 +39,7 @@ import java.util.Comparator;
*
* @lucene.experimental
*/
-public class Transition implements Serializable, Cloneable {
+public class Transition implements Cloneable {
/*
* CLASS INVARIANT: min<=max
Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/UTF32ToUTF8.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/UTF32ToUTF8.java?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/UTF32ToUTF8.java (original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/UTF32ToUTF8.java Tue Feb 22 01:00:39 2011
@@ -26,7 +26,8 @@ import java.util.ArrayList;
// TODO
// - do we really need the .bits...? if not we can make util in UnicodeUtil to convert 1 char into a BytesRef
-final class UTF32ToUTF8 {
+/** @lucene.internal */
+public final class UTF32ToUTF8 {
// Unicode boundaries for UTF8 bytes 1,2,3,4
private static final int[] startCodes = new int[] {0, 128, 2048, 65536};
@@ -105,6 +106,7 @@ final class UTF32ToUTF8 {
}
}
+ @Override
public String toString() {
StringBuilder b = new StringBuilder();
for(int i=0;i<len;i++) {
Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/fst/FST.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/fst/FST.java?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/fst/FST.java (original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/fst/FST.java Tue Feb 22 01:00:39 2011
@@ -467,9 +467,13 @@ public class FST<T> {
return arc;
}
- /** Follow the follow arc and read the first arc of its
- * target; this changes the provide arc (2nd arg) in-place
- * and returns it. */
+ /**
+ * Follow the <code>follow</code> arc and read the first arc of its target;
+ * this changes the provided <code>arc</code> (2nd arg) in-place and returns
+ * it.
+ *
+ * @returns Returns the second argument (<code>arc</code>).
+ */
public Arc<T> readFirstTargetArc(Arc<T> follow, Arc<T> arc) throws IOException {
//int pos = address;
//System.out.println(" readFirstTarget follow.target=" + follow.target + " isFinal=" + follow.isFinal());
@@ -490,7 +494,7 @@ public class FST<T> {
}
}
- // Not private beacaus NodeHash needs access:
+ // Not private because NodeHash needs access:
Arc<T> readFirstRealArc(int address, Arc<T> arc) throws IOException {
final BytesReader in = getBytesReader(address);
Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/fst/PairOutputs.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/fst/PairOutputs.java?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/fst/PairOutputs.java (original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/fst/PairOutputs.java Tue Feb 22 01:00:39 2011
@@ -55,6 +55,7 @@ public class PairOutputs<A,B> extends Ou
}
}
+ @Override
public int hashCode() {
return output1.hashCode() + output2.hashCode();
}
Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/fst/Util.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/fst/Util.java?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/fst/Util.java (original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/fst/Util.java Tue Feb 22 01:00:39 2011
@@ -17,12 +17,8 @@ package org.apache.lucene.util.automaton
* limitations under the License.
*/
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Set;
-import java.util.HashSet;
+import java.io.*;
+import java.util.*;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.IntsRef;
@@ -160,90 +156,165 @@ public final class Util {
return output;
}
}
+
+ /**
+ * Dumps an {@link FST} to a GraphViz's <code>dot</code> language description
+ * for visualization. Example of use:
+ *
+ * <pre>
+ * PrintStream ps = new PrintStream("out.dot");
+ * fst.toDot(ps);
+ * ps.close();
+ * </pre>
+ *
+ * and then, from command line:
+ *
+ * <pre>
+ * dot -Tpng -o out.png out.dot
+ * </pre>
+ *
+ * <p>
+ * Note: larger FSTs (a few thousand nodes) won't even render, don't bother.
+ *
+ * @param sameRank
+ * If <code>true</code>, the resulting <code>dot</code> file will try
+ * to order states in layers of breadth-first traversal. This may
+ * mess up arcs, but makes the output FST's structure a bit clearer.
+ *
+ * @param labelStates
+ * If <code>true</code> states will have labels equal to their offsets in their
+ * binary format. Expands the graph considerably.
+ *
+ * @see "http://www.graphviz.org/"
+ */
+ public static <T> void toDot(FST<T> fst, Writer out, boolean sameRank, boolean labelStates)
+ throws IOException {
+ // This is the start arc in the automaton (from the epsilon state to the first state
+ // with outgoing transitions.
+ final FST.Arc<T> startArc = fst.getFirstArc(new FST.Arc<T>());
+ // A queue of transitions to consider for the next level.
+ final List<FST.Arc<T>> thisLevelQueue = new ArrayList<FST.Arc<T>>();
- // NOTE: this consumes alot of RAM!
- // arcs w/ NEXT opto are in blue
- /*
- eg:
- PrintStream ps = new PrintStream("out.dot");
- fst.toDot(ps);
- ps.close();
- System.out.println("SAVED out.dot");
-
- then dot -Tpng out.dot > /x/tmp/out.png
- */
-
- public static<T> void toDot(FST<T> fst, PrintStream out) throws IOException {
+ // A queue of transitions to consider when processing the next level.
+ final List<FST.Arc<T>> nextLevelQueue = new ArrayList<FST.Arc<T>>();
+ nextLevelQueue.add(startArc);
- final FST.Arc<T> startArc = fst.getFirstArc(new FST.Arc<T>());
+ // A list of states on the same level (for ranking).
+ final List<Integer> sameLevelStates = new ArrayList<Integer>();
- final List<FST.Arc<T>> queue = new ArrayList<FST.Arc<T>>();
- queue.add(startArc);
+ // A bitset of already seen states (target offset).
+ final BitSet seen = new BitSet();
+ seen.set(startArc.target);
+
+ // Shape for states.
+ final String stateShape = "circle";
+
+ // Emit DOT prologue.
+ out.write("digraph FST {\n");
+ out.write(" rankdir = LR; splines=true; concentrate=true; ordering=out; ranksep=2.5; \n");
- final Set<Integer> seen = new HashSet<Integer>();
- seen.add(startArc.target);
-
- out.println("digraph FST {");
- out.println(" rankdir = LR;");
- //out.println(" " + startNode + " [shape=circle label=" + startNode + "];");
- out.println(" " + startArc.target + " [label=\"\" shape=circle];");
- out.println(" initial [shape=point color=white label=\"\"];");
- out.println(" initial -> " + startArc.target);
+ if (!labelStates) {
+ out.write(" node [shape=circle, width=.2, height=.2, style=filled]\n");
+ }
+
+ emitDotState(out, "initial", "point", "white", "");
+ emitDotState(out, Integer.toString(startArc.target), stateShape, null, "");
+ out.write(" initial -> " + startArc.target + "\n");
final T NO_OUTPUT = fst.outputs.getNoOutput();
+ int level = 0;
- while(queue.size() != 0) {
- FST.Arc<T> arc = queue.get(queue.size()-1);
- queue.remove(queue.size()-1);
- //System.out.println("dot cycle target=" + arc.target);
-
- if (fst.targetHasArcs(arc)) {
-
- // scan all arcs
- final int node = arc.target;
- fst.readFirstTargetArc(arc, arc);
- while(true) {
-
- //System.out.println(" cycle label=" + arc.label + " (" + (char) arc.label + ") target=" + arc.target);
- if (!seen.contains(arc.target)) {
- final String shape;
- if (arc.target == -1) {
- shape = "doublecircle";
+ while (!nextLevelQueue.isEmpty()) {
+ // we could double buffer here, but it doesn't matter probably.
+ thisLevelQueue.addAll(nextLevelQueue);
+ nextLevelQueue.clear();
+
+ level++;
+ out.write("\n // Transitions and states at level: " + level + "\n");
+ while (!thisLevelQueue.isEmpty()) {
+ final FST.Arc<T> arc = thisLevelQueue.remove(thisLevelQueue.size() - 1);
+
+ if (fst.targetHasArcs(arc)) {
+ // scan all arcs
+ final int node = arc.target;
+ fst.readFirstTargetArc(arc, arc);
+
+ while (true) {
+ // Emit the unseen state and add it to the queue for the next level.
+ if (arc.target >= 0 && !seen.get(arc.target)) {
+ emitDotState(out, Integer.toString(arc.target), stateShape, null,
+ labelStates ? Integer.toString(arc.target) : "");
+ seen.set(arc.target);
+ nextLevelQueue.add(new FST.Arc<T>().copyFrom(arc));
+ sameLevelStates.add(arc.target);
+ }
+
+ String outs;
+ if (arc.output != NO_OUTPUT) {
+ outs = "/" + fst.outputs.outputToString(arc.output);
} else {
- shape = "circle";
+ outs = "";
+ }
+
+ final String cl;
+ if (arc.label == FST.END_LABEL) {
+ cl = "~";
+ } else {
+ cl = printableLabel(arc.label);
+ }
+
+ out.write(" " + node + " -> " + arc.target + " [label=\"" + cl + outs + "\"]\n");
+
+ // Break the loop if we're on the last arc of this state.
+ if (arc.isLast()) {
+ break;
}
- out.println(" " + arc.target + " [shape=" + shape + "];");
- seen.add(arc.target);
- queue.add(new FST.Arc<T>().copyFrom(arc));
- //System.out.println(" new!");
- }
- String outs;
- if (arc.output != NO_OUTPUT) {
- outs = "/" + fst.outputs.outputToString(arc.output);
- } else {
- outs = "";
- }
- final char cl;
- if (arc.label == FST.END_LABEL) {
- cl = '~';
- } else {
- cl = (char) arc.label;
- }
- out.println(" " + node + " -> " + arc.target + " [label=\"" + cl + outs + "\"]");
- //if (arc.flag(FST.BIT_TARGET_NEXT)) {
- //out.print(" color=blue");
- //}
- //out.println("];");
-
- if (arc.isLast()) {
- break;
- } else {
fst.readNextArc(arc);
}
}
}
+
+ // Emit state ranking information.
+ if (sameRank && sameLevelStates.size() > 1) {
+ out.write(" {rank=same; ");
+ for (int state : sameLevelStates) {
+ out.write(state + "; ");
+ }
+ out.write(" }\n");
+ }
+ sameLevelStates.clear();
+ }
+
+ // Emit terminating state (always there anyway).
+ out.write(" -1 [style=filled, color=black, shape=circle, label=\"\"]\n\n");
+ out.write(" {rank=sink; -1 } ");
+
+ out.write("}\n");
+ out.flush();
+ }
+
+ /**
+ * Emit a single state in the <code>dot</code> language.
+ */
+ private static void emitDotState(Writer out, String name, String shape,
+ String color, String label) throws IOException {
+ out.write(" " + name
+ + " ["
+ + (shape != null ? "shape=" + shape : "") + " "
+ + (color != null ? "color=" + color : "") + " "
+ + (label != null ? "label=\"" + label + "\"" : "label=\"\"") + " "
+ + "]\n");
+ }
+
+ /**
+ * Ensures an arc's label is indeed printable (dot uses US-ASCII).
+ */
+ private static String printableLabel(int label) {
+ if (label >= 0x20 && label <= 0x7d) {
+ return Character.toString((char) label);
+ } else {
+ return "0x" + Integer.toHexString(label);
}
- out.println("}");
}
}
Added: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/fst/package.html
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/fst/package.html?rev=1073192&view=auto
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/fst/package.html (added)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/automaton/fst/package.html Tue Feb 22 01:00:39 2011
@@ -0,0 +1,25 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+</head>
+<body>
+Finite state transducers
+</body>
+</html>
Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/packed/Packed32.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/packed/Packed32.java?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/packed/Packed32.java (original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/packed/Packed32.java Tue Feb 22 01:00:39 2011
@@ -214,6 +214,7 @@ class Packed32 extends PackedInts.Reader
Arrays.fill(blocks, 0);
}
+ @Override
public String toString() {
return "Packed32(bitsPerValue=" + bitsPerValue + ", maxPos=" + maxPos
+ ", elements.length=" + blocks.length + ")";
Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/packed/Packed64.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/packed/Packed64.java?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/packed/Packed64.java (original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/packed/Packed64.java Tue Feb 22 01:00:39 2011
@@ -199,6 +199,7 @@ class Packed64 extends PackedInts.Reader
| ((value << shifts[base + 2]) & writeMasks[base+2]);
}
+ @Override
public String toString() {
return "Packed64(bitsPerValue=" + bitsPerValue + ", size="
+ size() + ", maxPos=" + maxPos
Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/packed/PackedInts.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/packed/PackedInts.java?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/packed/PackedInts.java (original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/packed/PackedInts.java Tue Feb 22 01:00:39 2011
@@ -251,7 +251,7 @@ public class PackedInts {
/** Returns how many bits are required to hold values up
* to and including maxValue
- * @param maxValue the maximum value tha should be representable.
+ * @param maxValue the maximum value that should be representable.
* @return the amount of bits needed to represent values from 0 to maxValue.
* @lucene.internal
*/
Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/packed/PackedWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/packed/PackedWriter.java?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/packed/PackedWriter.java (original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/packed/PackedWriter.java Tue Feb 22 01:00:39 2011
@@ -106,6 +106,7 @@ class PackedWriter extends PackedInts.Wr
}
}
+ @Override
public String toString() {
return "PackedWriter(written " + written + "/" + valueCount + " with "
+ bitsPerValue + " bits/value)";
Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/packed/package.html
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/packed/package.html?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/packed/package.html (original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/util/packed/package.html Tue Feb 22 01:00:39 2011
@@ -1,4 +1,20 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
<html>
<head></head>
<body bgcolor="white">
Modified: lucene/dev/branches/realtime_search/lucene/src/java/overview.html
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/overview.html?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/overview.html (original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/overview.html Tue Feb 22 01:00:39 2011
@@ -45,48 +45,36 @@ to check if the results are what we expe
<!-- = Java Sourcecode to HTML automatically converted code = -->
<!-- = Java2Html Converter 5.0 [2006-03-04] by Markus Gebhard markus@jave.de = -->
<!-- = Further information: http://www.java2html.de = -->
-<div align="left" class="java">
-<table border="0" cellpadding="3" cellspacing="0" bgcolor="#ffffff">
- <tr>
- <!-- start source code -->
- <td nowrap="nowrap" valign="top" align="left">
- <code>
-<font color="#ffffff"> </font><font color="#000000">Analyzer analyzer = </font><font color="#7f0055"><b>new </b></font><font color="#000000">StandardAnalyzer</font><font color="#000000">(</font><font color="#000000">Version.LUCENE_CURRENT</font><font color="#000000">)</font><font color="#000000">;</font><br />
-<font color="#ffffff"></font><br />
-<font color="#ffffff"> </font><font color="#3f7f5f">// Store the index in memory:</font><br />
-<font color="#ffffff"> </font><font color="#000000">Directory directory = </font><font color="#7f0055"><b>new </b></font><font color="#000000">RAMDirectory</font><font color="#000000">()</font><font color="#000000">;</font><br />
-<font color="#ffffff"> </font><font color="#3f7f5f">// To store an index on disk, use this instead:</font><br />
-<font color="#ffffff"> </font><font color="#3f7f5f">//Directory directory = FSDirectory.open("/tmp/testindex");</font><br />
-<font color="#ffffff"> </font><font color="#000000">IndexWriter iwriter = </font><font color="#7f0055"><b>new </b></font><font color="#000000">IndexWriter</font><font color="#000000">(</font><font color="#000000">directory, analyzer, true,</font><br />
-<font color="#ffffff"> </font><font color="#7f0055"><b>new </b></font><font color="#000000">IndexWriter.MaxFieldLength</font><font color="#000000">(</font><font color="#990000">25000</font><font color="#000000">))</font><font color="#000000">;</font><br />
-<font color="#ffffff"> </font><font color="#000000">Document doc = </font><font color="#7f0055"><b>new </b></font><font color="#000000">Document</font><font color="#000000">()</font><font color="#000000">;</font><br />
-<font color="#ffffff"> </font><font color="#000000">String text = </font><font color="#2a00ff">"This is the text to be indexed."</font><font color="#000000">;</font><br />
-<font color="#ffffff"> </font><font color="#000000">doc.add</font><font color="#000000">(</font><font color="#7f0055"><b>new </b></font><font color="#000000">Field</font><font color="#000000">(</font><font color="#2a00ff">"fieldname"</font><font color="#000000">, text, Field.Store.YES,</font><br />
-<font color="#ffffff"> </font><font color="#000000">Field.Index.ANALYZED</font><font color="#000000">))</font><font color="#000000">;</font><br />
-<font color="#ffffff"> </font><font color="#000000">iwriter.addDocument</font><font color="#000000">(</font><font color="#000000">doc</font><font color="#000000">)</font><font color="#000000">;</font><br />
-<font color="#ffffff"> </font><font color="#000000">iwriter.close</font><font color="#000000">()</font><font color="#000000">;</font><br />
-<font color="#ffffff"> </font><br />
-<font color="#ffffff"> </font><font color="#3f7f5f">// Now search the index:</font><br />
-<font color="#ffffff"> </font><font color="#000000">IndexSearcher isearcher = </font><font color="#7f0055"><b>new </b></font><font color="#000000">IndexSearcher</font><font color="#000000">(</font><font color="#000000">directory, </font><font color="#7f0055"><b>true</b></font><font color="#000000">)</font><font color="#000000">; </font><font color="#3f7f5f">// read-only=true</font><br />
-<font color="#ffffff"> </font><font color="#3f7f5f">// Parse a simple query that searches for "text":</font><br />
-<font color="#ffffff"> </font><font color="#000000">QueryParser parser = </font><font color="#7f0055"><b>new </b></font><font color="#000000">QueryParser</font><font color="#000000">(</font><font color="#2a00ff">"fieldname"</font><font color="#000000">, analyzer</font><font color="#000000">)</font><font color="#000000">;</font><br />
-<font color="#ffffff"> </font><font color="#000000">Query query = parser.parse</font><font color="#000000">(</font><font color="#2a00ff">"text"</font><font color="#000000">)</font><font color="#000000">;</font><br />
-<font color="#ffffff"> </font><font color="#000000">ScoreDoc</font><font color="#000000">[] </font><font color="#000000">hits = isearcher.search</font><font color="#000000">(</font><font color="#000000">query, null, </font><font color="#990000">1000</font><font color="#000000">)</font><font color="#000000">.scoreDocs;</font><br />
-<font color="#ffffff"> </font><font color="#000000">assertEquals</font><font color="#000000">(</font><font color="#990000">1</font><font color="#000000">, hits.length</font><font color="#000000">)</font><font color="#000000">;</font><br />
-<font color="#ffffff"> </font><font color="#3f7f5f">// Iterate through the results:</font><br />
-<font color="#ffffff"> </font><font color="#7f0055"><b>for </b></font><font color="#000000">(</font><font color="#7f0055"><b>int </b></font><font color="#000000">i = </font><font color="#990000">0</font><font color="#000000">; i < hits.length; i++</font><font color="#000000">) {</font><br />
-<font color="#ffffff"> </font><font color="#000000">Document hitDoc = isearcher.doc</font><font color="#000000">(</font><font color="#000000">hits</font><font color="#000000">[</font><font color="#000000">i</font><font color="#000000">]</font><font color="#000000">.doc</font><font color="#000000">)</font><font color="#000000">;</font><br />
-<font color="#ffffff"> </font><font color="#000000">assertEquals</font><font color="#000000">(</font><font color="#2a00ff">"This is the text to be indexed."</font><font color="#000000">, hitDoc.get</font><font color="#000000">(</font><font color="#2a00ff">"fieldname"</font><font color="#000000">))</font><font color="#000000">;</font><br />
-<font color="#ffffff"> </font><font color="#000000">}</font><br />
-<font color="#ffffff"> </font><font color="#000000">isearcher.close</font><font color="#000000">()</font><font color="#000000">;</font><br />
-<font color="#ffffff"> </font><font color="#000000">directory.close</font><font color="#000000">()</font><font color="#000000">;</font></code>
-
- </td>
- <!-- end source code -->
- </tr>
+<pre class="prettyprint">
+ Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT);
-</table>
-</div>
+ // Store the index in memory:
+ Directory directory = new RAMDirectory();
+ // To store an index on disk, use this instead:
+ //Directory directory = FSDirectory.open("/tmp/testindex");
+ IndexWriter iwriter = new IndexWriter(directory, analyzer, true,
+ new IndexWriter.MaxFieldLength(25000));
+ Document doc = new Document();
+ String text = "This is the text to be indexed.";
+ doc.add(new Field("fieldname", text, Field.Store.YES,
+ Field.Index.ANALYZED));
+ iwriter.addDocument(doc);
+ iwriter.close();
+
+ // Now search the index:
+ IndexSearcher isearcher = new IndexSearcher(directory, true); // read-only=true
+ // Parse a simple query that searches for "text":
+ QueryParser parser = new QueryParser("fieldname", analyzer);
+ Query query = parser.parse("text");
+ ScoreDoc[] hits = isearcher.search(query, null, 1000).scoreDocs;
+ assertEquals(1, hits.length);
+ // Iterate through the results:
+ for (int i = 0; i < hits.length; i++) {
+ Document hitDoc = isearcher.doc(hits[i].doc);
+ assertEquals("This is the text to be indexed.", hitDoc.get("fieldname"));
+ }
+ isearcher.close();
+ directory.close();</pre>
<!-- = END of automatically generated HTML code = -->
<!-- ======================================================== -->
@@ -171,27 +159,19 @@ method.</li>
Some simple examples of code which does this are:
<ul>
<li>
- <a href="http://svn.apache.org/repos/asf/lucene/dev/trunk/lucene/src/demo/org/apache/lucene/demo/FileDocument.java">FileDocument.java</a> contains
-code to create a Document for a file.</li>
-
-<li>
- <a href="http://svn.apache.org/repos/asf/lucene/dev/trunk/lucene/src/demo/org/apache/lucene/demo/IndexFiles.java">IndexFiles.java</a> creates an
+ <a href="http://svn.apache.org/repos/asf/lucene/dev/trunk/lucene/contrib/demo/src/java/org/apache/lucene/demo/IndexFiles.java">IndexFiles.java</a> creates an
index for all the files contained in a directory.</li>
<li>
- <a href="http://svn.apache.org/repos/asf/lucene/dev/trunk/lucene/src/demo/org/apache/lucene/demo/DeleteFiles.java">DeleteFiles.java</a> deletes some
-of these files from the index.</li>
-
-<li>
- <a href="http://svn.apache.org/repos/asf/lucene/dev/trunk/lucene/src/demo/org/apache/lucene/demo/SearchFiles.java">SearchFiles.java</a> prompts for
+ <a href="http://svn.apache.org/repos/asf/lucene/dev/trunk/lucene/demo/src/java/org/apache/lucene/demo/SearchFiles.java">SearchFiles.java</a> prompts for
queries and searches an index.</li>
</ul>
To demonstrate these, try something like:
-<blockquote><tt>> <b>java -cp lucene.jar:lucene-demo.jar org.apache.lucene.demo.IndexFiles rec.food.recipes/soups</b></tt>
+<blockquote><tt>> <b>java -cp lucene.jar:lucene-demo.jar:lucene-analyzers-common.jar org.apache.lucene.demo.IndexFiles rec.food.recipes/soups</b></tt>
<br><tt>adding rec.food.recipes/soups/abalone-chowder</tt>
<br><tt> </tt>[ ... ]
-<p><tt>> <b>java -cp lucene.jar:lucene-demo.jar org.apache.lucene.demo.SearchFiles</b></tt>
+<p><tt>> <b>java -cp lucene.jar:lucene-demo.jar:lucene-analyzers-common.jar org.apache.lucene.demo.SearchFiles</b></tt>
<br><tt>Query: <b>chowder</b></tt>
<br><tt>Searching for: chowder</tt>
<br><tt>34 total matching documents</tt>
@@ -207,16 +187,5 @@ and the word "manhattan" ... ]
<br> [ Note: "+" and "-" are canonical, but "AND", "OR"
and "NOT" may be used. ]</blockquote>
-The <a href="http://svn.apache.org/repos/asf/lucene/dev/trunk/lucene/src/demo/org/apache/lucene/demo/IndexHTML.java">IndexHTML</a> demo is more sophisticated.
-It incrementally maintains an index of HTML files, adding new files as
-they appear, deleting old files as they disappear and re-indexing files
-as they change.
-<blockquote><tt>> <b>java -cp lucene.jar:lucene-demo.jar org.apache.lucene.demo.IndexHTML -create java/jdk1.1.6/docs/relnotes</b></tt>
-<br><tt>adding java/jdk1.1.6/docs/relnotes/SMICopyright.html</tt>
-<br><tt> </tt>[ ... create an index containing all the relnotes ]
-<p><tt>> <b>rm java/jdk1.1.6/docs/relnotes/smicopyright.html</b></tt>
-<p><tt>> <b>java -cp lucene.jar:lucene-demo.jar org.apache.lucene.demo.IndexHTML java/jdk1.1.6/docs/relnotes</b></tt>
-<br><tt>deleting java/jdk1.1.6/docs/relnotes/SMICopyright.html</tt></blockquote>
-
</body>
</html>
Modified: lucene/dev/branches/realtime_search/lucene/src/site/src/documentation/content/xdocs/demo.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/site/src/documentation/content/xdocs/demo.xml?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/site/src/documentation/content/xdocs/demo.xml (original)
+++ lucene/dev/branches/realtime_search/lucene/src/site/src/documentation/content/xdocs/demo.xml Tue Feb 22 01:00:39 2011
@@ -18,10 +18,10 @@ It walks you through some basic installa
</section>
-<section id="About the Demos"><title>About the Demos</title>
+<section id="About the Demo"><title>About the Demo</title>
<p>
-The Lucene command-line demo code consists of two applications that demonstrate various
-functionalities of Lucene and how one should go about adding Lucene to their applications.
+The Lucene command-line demo code consists of an application that demonstrates various
+functionalities of Lucene and how you can add Lucene to your applications.
</p>
</section>
@@ -30,14 +30,23 @@ functionalities of Lucene and how one sh
First, you should <a href="http://www.apache.org/dyn/closer.cgi/lucene/java/">download</a> the
latest Lucene distribution and then extract it to a working directory. Alternatively, you can <a
href="http://wiki.apache.org/lucene-java/SourceRepository">check out the sources from
-Subversion</a>, and then run <code>ant war-demo</code> to generate the JARs and WARs.
+Subversion</a>, and then run <code>ant</code> in the <code>lucene/contrib/demo/</code>
+directory to generate the JARs.
</p>
<p>
-You should see the Lucene JAR file in the directory you created when you extracted the archive. It
-should be named something like <code>lucene-core-{version}.jar</code>. You should also see a file
-called <code>lucene-demos-{version}.jar</code>. If you checked out the sources from Subversion then
-the JARs are located under the <code>build</code> subdirectory (after running <code>ant</code>
-successfully). Put both of these files in your Java CLASSPATH.
+You need three JARs: the Lucene JAR, the common analysis JAR, and the Lucene demo JAR. You should
+see the Lucene JAR file in the directory you created when you extracted the archive -- it
+should be named something like <code>lucene-core-{version}.jar</code>. You should also see files
+called <code>lucene-analysis-common-{version}.jar</code> and <code>lucene-demos-{version}.jar</code>.
+If you checked out the sources from Subversion then the JARs are located at:
+</p>
+<ul>
+ <li><code>lucene/build/lucene-core-4.0-SNAPSHOT.jar</code></li>
+ <li><code>modules/analysis/build/common/lucene-analyzers-common-4.0-SNAPSHOT.jar</code></li>
+ <li><code>lucene/build/contrib/demo/lucene-demo-4.0-SNAPSHOT.jar</code></li>
+</ul>
+<p>
+Put all three of these files in your Java CLASSPATH.
</p>
</section>
@@ -47,7 +56,7 @@ Once you've gotten this far you're proba
you've set your CLASSPATH correctly, just type:
<pre>
- java org.apache.lucene.demo.IndexFiles {full-path-to-lucene}/src
+ java org.apache.lucene.demo.IndexFiles -docs {path-to-lucene}/src
</pre>
This will produce a subdirectory called <code>index</code> which will contain an index of all of the
Modified: lucene/dev/branches/realtime_search/lucene/src/site/src/documentation/content/xdocs/demo2.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/site/src/documentation/content/xdocs/demo2.xml?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/site/src/documentation/content/xdocs/demo2.xml (original)
+++ lucene/dev/branches/realtime_search/lucene/src/site/src/documentation/content/xdocs/demo2.xml Tue Feb 22 01:00:39 2011
@@ -23,9 +23,9 @@ how to use Lucene in their applications.
<p>
Relative to the directory created when you extracted Lucene or retrieved it from Subversion, you
-should see a directory called <code>src</code> which in turn contains a directory called
-<code>demo</code>. This is the root for all of the Lucene demos. Under this directory is
-<code>org/apache/lucene/demo</code>. This is where all the Java sources for the demos live.
+should see a directory called <code>lucene/contrib/demo/</code>. This is the root for the Lucene
+demo. Under this directory is <code>src/java/org/apache/lucene/demo/</code>. This is where all
+the Java sources for the demo live.
</p>
<p>
@@ -39,62 +39,80 @@ Bring it up in <code>vi</code> or your e
<p>
As we discussed in the previous walk-through, the <a
-href="api/demo/org/apache/lucene/demo/IndexFiles.html">IndexFiles</a> class creates a Lucene
+href="api/contrib-demo/org/apache/lucene/demo/IndexFiles.html">IndexFiles</a> class creates a Lucene
Index. Let's take a look at how it does this.
</p>
<p>
-The first substantial thing the <code>main</code> function does is instantiate <a
-href="api/core/org/apache/lucene/index/IndexWriter.html">IndexWriter</a>. It passes the string
-"<code>index</code>" and a new instance of a class called <a
-href="api/core/org/apache/lucene/analysis/standard/StandardAnalyzer.html">StandardAnalyzer</a>.
-The "<code>index</code>" string is the name of the filesystem directory where all index information
-should be stored. Because we're not passing a full path, this will be created as a subdirectory of
-the current working directory (if it does not already exist). On some platforms, it may be created
-in other directories (such as the user's home directory).
+The <code>main()</code> method parses the command-line parameters, then in preparation for
+instantiating <a href="api/core/org/apache/lucene/index/IndexWriter.html">IndexWriter</a>, opens a
+<a href="api/core/org/apache/lucene/store/Directory.html">Directory</a> and instantiates
+<a href="api/module-analysis-common/org/apache/lucene/analysis/standard/StandardAnalyzer.html"
+>StandardAnalyzer</a> and
+<a href="api/core/org/apache/lucene/index/IndexWriterConfig.html">IndexWriterConfig</a>.
</p>
<p>
-The <a href="api/core/org/apache/lucene/index/IndexWriter.html">IndexWriter</a> is the main
-class responsible for creating indices. To use it you must instantiate it with a path that it can
-write the index into. If this path does not exist it will first create it. Otherwise it will
-refresh the index at that path. You can also create an index using one of the subclasses of <a
-href="api/core/org/apache/lucene/store/Directory.html">Directory</a>. In any case, you must also pass an
-instance of <a
-href="api/core/org/apache/lucene/analysis/Analyzer.html">org.apache.lucene.analysis.Analyzer</a>.
+The value of the <code>-index</code> command-line parameter is the name of the filesystem directory
+where all index information should be stored. If <code>IndexFiles</code> is invoked with a
+relative path given in the <code>-index</code> command-line parameter, or if the <code>-index</code>
+command-line parameter is not given, causing the default relative index path "<code>index</code>"
+to be used, the index path will be created as a subdirectory of the current working directory
+(if it does not already exist). On some platforms, the index path may be created in a different
+directory (such as the user's home directory).
</p>
<p>
-The particular <a href="api/core/org/apache/lucene/analysis/Analyzer.html">Analyzer</a> we
-are using, <a
-href="api/core/org/apache/lucene/analysis/standard/StandardAnalyzer.html">StandardAnalyzer</a>, is
-little more than a standard Java Tokenizer, converting all strings to lowercase and filtering out
-stop words and characters from the index. By stop words and characters I mean common language
-words such as articles (a, an, the, etc.) and other strings that may have less value for searching
-(e.g. <b>'s</b>) . It should be noted that there are different rules for every language, and you
-should use the proper analyzer for each. Lucene currently provides Analyzers for a number of
-different languages (see the <code>*Analyzer.java</code> sources under <a
-href="http://svn.apache.org/repos/asf/lucene/dev/trunk/modules/analysis/common/src/java/org/apache/lucene/analysis/">modules/analysis/common/src/java/org/apache/lucene/analysis</a>).
+The <code>-docs</code> command-line parameter value is the location of the directory containing
+files to be indexed.
+</p>
+
+<p>
+The <code>-update</code> command-line parameter tells <code>IndexFiles</code> not to delete the
+index if it already exists. When <code>-update</code> is not given, <code>IndexFiles</code> will
+first wipe the slate clean before indexing any documents.
</p>
<p>
-Looking further down in the file, you should see the <code>indexDocs()</code> code. This recursive
-function simply crawls the directories and uses <a
-href="api/demo/org/apache/lucene/demo/FileDocument.html">FileDocument</a> to create <a
-href="api/core/org/apache/lucene/document/Document.html">Document</a> objects. The <a
-href="api/core/org/apache/lucene/document/Document.html">Document</a> is simply a data object to
-represent the content in the file as well as its creation time and location. These instances are
-added to the <code>indexWriter</code>. Take a look inside <a
-href="api/demo/org/apache/lucene/demo/FileDocument.html">FileDocument</a>. It's not particularly
-complicated. It just adds fields to the <a
-href="api/core/org/apache/lucene/document/Document.html">Document</a>.
+Lucene <a href="api/core/org/apache/lucene/store/Directory.html">Directory</a>s are used by the
+<code>IndexWriter</code> to store information in the index. In addition to the
+<a href="api/core/org/apache/lucen/store/FSDirectory.html">FSDirectory</a> implementation we are using,
+there are several other <code>Directory</code> subclasses that can write to RAM, to databases, etc.
+</p>
+
+<p>
+Lucene <a href="api/core/org/apache/lucene/analysis/Analyzer.html">Analyzer</a>s are processing pipelines
+that break up text into indexed tokens, a.k.a. terms, and optionally perform other operations on these
+tokens, e.g. downcasing, synonym insertion, filtering out unwanted tokens, etc. The <code>Analyzer</code>
+we are using is <code>StandardAnalyzer</code>, which creates tokens using the Word Break rules from the
+Unicode Text Segmentation algorithm specified in <a href="http://unicode.org/reports/tr29/">Unicode
+Standard Annex #29</a>; converts tokens to lowercase; and then filters out stopwords. Stopwords are
+common language words such as articles (a, an, the, etc.) and other tokens that may have less value for
+searching. It should be noted that there are different rules for every language, and you should use the
+proper analyzer for each. Lucene currently provides Analyzers for a number of different languages (see
+the <code>*Analyzer.java</code> sources under
+<a href="http://svn.apache.org/repos/asf/lucene/dev/trunk/modules/analysis/common/src/java/org/apache/lucene/analysis/"
+>modules/analysis/common/src/java/org/apache/lucene/analysis</a>).
</p>
<p>
-As you can see there isn't much to creating an index. The devil is in the details. You may also
-wish to examine the other samples in this directory, particularly the <a
-href="api/demo/org/apache/lucene/demo/IndexHTML.html">IndexHTML</a> class. It is a bit more
-complex but builds upon this example.
+The <code>IndexWriterConfig</code> instance holds all configuration for <code>IndexWriter</code>. For
+example, we set the <code>OpenMode</code> to use here based on the value of the <code>-update</code>
+command-line parameter.
+</p>
+
+<p>
+Looking further down in the file, after <code>IndexWriter</code> is instantiated, you should see the
+<code>indexDocs()</code> code. This recursive function crawls the directories and creates
+<a href="api/core/org/apache/lucene/document/Document.html">Document</a> objects. The
+<code>Document</code> is simply a data object to represent the text content from the file as well as
+its creation time and location. These instances are added to the <code>IndexWriter</code>. If
+the <code>-update</code> command-line parameter is given, the <code>IndexWriter</code>
+<code>OpenMode</code> will be set to <code>OpenMode.CREATE_OR_APPEND</code>, and rather than
+adding documents to the index, the <code>IndexWriter</code> will <strong>update</strong> them
+in the index by attempting to find an already-indexed document with the same identifier (in our
+case, the file path serves as the identifier); deleting it from the index if it exists; and then
+adding the new document to the index.
</p>
</section>
@@ -102,43 +120,30 @@ complex but builds upon this example.
<section id="Searching Files"><title>Searching Files</title>
<p>
-The <a href="api/demo/org/apache/lucene/demo/SearchFiles.html">SearchFiles</a> class is
-quite simple. It primarily collaborates with an <a
-href="api/core/org/apache/lucene/search/IndexSearcher.html">IndexSearcher</a>, <a
-href="api/core/org/apache/lucene/analysis/standard/StandardAnalyzer.html">StandardAnalyzer</a>
-(which is used in the <a
-href="api/core/org/apache/lucene/demo/IndexFiles.html">IndexFiles</a> class as well) and a
-<a href="api/core/org/apache/lucene/queryParser/QueryParser.html">QueryParser</a>. The
+The <a href="api/contrib-demo/org/apache/lucene/demo/SearchFiles.html">SearchFiles</a> class is
+quite simple. It primarily collaborates with an
+<a href="api/core/org/apache/lucene/search/IndexSearcher.html">IndexSearcher</a>,
+<a href="api/modules-analysis-common/org/apache/lucene/analysis/standard/StandardAnalyzer.html"
+>StandardAnalyzer</a> (which is used in the
+<a href="api/contrib-demo/org/apache/lucene/demo/IndexFiles.html">IndexFiles</a> class as well)
+and a <a href="api/core/org/apache/lucene/queryParser/QueryParser.html">QueryParser</a>. The
query parser is constructed with an analyzer used to interpret your query text in the same way the
-documents are interpreted: finding the end of words and removing useless words like 'a', 'an' and
-'the'. The <a href="api/core/org/apache/lucene/search/Query.html">Query</a> object contains
-the results from the <a
-href="api/core/org/apache/lucene/queryParser/QueryParser.html">QueryParser</a> which is passed to
-the searcher. Note that it's also possible to programmatically construct a rich <a
-href="api/core/org/apache/lucene/search/Query.html">Query</a> object without using the query
+documents are interpreted: finding word boundaries, downcasing, and removing useless words like
+'a', 'an' and 'the'. The <a href="api/core/org/apache/lucene/search/Query.html">Query</a>
+object contains the results from the
+<a href="api/core/org/apache/lucene/queryParser/QueryParser.html">QueryParser</a> which is passed
+to the searcher. Note that it's also possible to programmatically construct a rich
+<a href="api/core/org/apache/lucene/search/Query.html">Query</a> object without using the query
parser. The query parser just enables decoding the <a href="queryparsersyntax.html">Lucene query
-syntax</a> into the corresponding <a
-href="api/core/org/apache/lucene/search/Query.html">Query</a> object. Search can be executed in
-two different ways:
-<ul>
-<li>Streaming: A <a href="api/core/org/apache/lucene/search/Collector.html">Collector</a> subclass
-simply prints out the document ID and score for each matching document.</li>
-<li>Paging: Using a <a href="api/core/org/apache/lucene/search/TopScoreDocCollector.html">TopScoreDocCollector</a>
- the search results are printed in pages, sorted by score (i. e. relevance).</li>
-</ul>
+syntax</a> into the corresponding <a href="api/core/org/apache/lucene/search/Query.html">Query</a>
+object.
</p>
-</section>
-
-<section id="The Web example..."><title>The Web example...</title>
-
<p>
-<a href="demo3.html">read on>>></a>
+<code>SearchFiles</code> uses the <code>IndexSearcher.search(query,n)</code> method that returns
+<a href="api/core/org/apache/lucene/search/TopDocs.html">TopDocs</a> with max <code>n</code> hits.
+The results are printed in pages, sorted by score (i.e. relevance).
</p>
-
</section>
-
</body>
</document>
-
-
Modified: lucene/dev/branches/realtime_search/lucene/src/site/src/documentation/content/xdocs/gettingstarted.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/site/src/documentation/content/xdocs/gettingstarted.xml?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/site/src/documentation/content/xdocs/gettingstarted.xml (original)
+++ lucene/dev/branches/realtime_search/lucene/src/site/src/documentation/content/xdocs/gettingstarted.xml Tue Feb 22 01:00:39 2011
@@ -14,7 +14,7 @@
<title>Getting Started</title>
<p>
This document is intended as a "getting started" guide. It has three audiences: first-time users
-looking to install Apache Lucene in their application or web server; developers looking to modify or base
+looking to install Apache Lucene in their application; developers looking to modify or base
the applications they develop on Lucene; and developers looking to become involved in and contribute
to the development of Lucene. This document is written in tutorial and walk-through format. The
goal is to help you "get started". It does not go into great depth on some of the conceptual or
@@ -33,20 +33,6 @@ may wish to skip sections.
<li><a href="demo2.html">About the sources and implementation for the command-line Lucene
demo</a>. This section walks through the implementation details (sources) of the
command-line Lucene demo. This section is intended for developers.</li> <p/>
-
- <li><a href="demo3.html">About installing and configuring the demo template web
- application</a>. While this walk-through assumes Tomcat as your container of choice,
- there is no reason you can't (provided you have the requisite knowledge) adapt the
- instructions to your container. This section is intended for those responsible for the
- development or deployment of Lucene-based web applications.</li> <p/>
-
- <li><a href="demo4.html">About the sources used to construct the demo template web
- application</a>. Please note the template application is designed to highlight features of
- Lucene and is <b>not</b> an example of best practices. (One would hopefully use MVC
- architecture such as provided by Jakarta Struts and taglibs, but showing you how to do that
- would be WAY beyond the scope of this guide.) This section is intended for developers and
- those wishing to customize the demo template web application to their needs. </li>
-
</ul>
</section>
Modified: lucene/dev/branches/realtime_search/lucene/src/site/src/documentation/content/xdocs/lucene-contrib/index.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/site/src/documentation/content/xdocs/lucene-contrib/index.xml?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/site/src/documentation/content/xdocs/lucene-contrib/index.xml (original)
+++ lucene/dev/branches/realtime_search/lucene/src/site/src/documentation/content/xdocs/lucene-contrib/index.xml Tue Feb 22 01:00:39 2011
@@ -59,6 +59,12 @@
<p>The benchmark contribution contains tools for benchmarking Lucene using standard, freely available corpora.</p>
<p>See <a href="../api/contrib-benchmark/index.html">benchmark javadoc</a></p>
</section>
+
+ <section id="demo"><title>demo</title>
+ <p>The demo contrib contains the Lucene demo: IndexFiles and SearchFiles, described under
+ <a href="../gettingstarted.html">Getting Started</a>.</p>
+ <p>See <a href="../api/contrib-demo/index.html">demo javadoc</a></p>
+ </section>
<section id="db"><title>db</title>
<p>Provides integration with Berkley DB.</p>
Modified: lucene/dev/branches/realtime_search/lucene/src/site/src/documentation/content/xdocs/site.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/site/src/documentation/content/xdocs/site.xml?rev=1073192&r1=1073191&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/site/src/documentation/content/xdocs/site.xml (original)
+++ lucene/dev/branches/realtime_search/lucene/src/site/src/documentation/content/xdocs/site.xml Tue Feb 22 01:00:39 2011
@@ -50,12 +50,12 @@ See http://forrest.apache.org/docs/linki
<javadoc label="Javadocs">
<javadoc-all label="All" href="ext:javadocs-all"/>
<javadoc-core label="Core" href="ext:javadocs-core"/>
- <javadoc-demo label="Demo" href="ext:javadocs-demo"/>
<javadoc-contrib label="Contrib">
<javadoc-contrib-ant label="Ant" href="ext:javadocs-contrib-ant"/>
<javadoc-contrib-bdb label="Bdb" href="ext:javadocs-contrib-bdb"/>
<javadoc-contrib-bdb-je label="Bdb-je" href="ext:javadocs-contrib-bdb-je"/>
<javadoc-contrib-benchmark label="Benchmark" href="ext:javadocs-contrib-benchmark"/>
+ <javadoc-contrib-demo label="Demo" href="ext:javadocs-contrib-demo"/>
<javadoc-contrib-highlighter label="Highlighter" href="ext:javadocs-contrib-highlighter"/>
<javadoc-contrib-instantiated label="Instantiated" href="ext:javadocs-contrib-instantiated"/>
<javadoc-contrib-lucli label="Lucli" href="ext:javadocs-contrib-lucli"/>
@@ -98,11 +98,11 @@ See http://forrest.apache.org/docs/linki
<changes-contrib href="changes/Contrib-Changes.html" />
<javadocs-all href="api/all/index.html"/>
<javadocs-core href="api/core/index.html"/>
- <javadocs-demo href="api/demo/index.html"/>
<javadocs-contrib-ant href="api/contrib-ant/index.html"/>
<javadocs-contrib-bdb href="api/contrib-bdb/index.html"/>
<javadocs-contrib-bdb-je href="api/contrib-bdb-je/index.html"/>
<javadocs-contrib-benchmark href="api/contrib-benchmark/index.html"/>
+ <javadocs-contrib-demo href="api/contrib-demo/index.html"/>
<javadocs-contrib-highlighter href="api/contrib-highlighter/index.html"/>
<javadocs-contrib-instantiated href="api/contrib-instantiated/index.html"/>
<javadocs-contrib-lucli href="api/contrib-lucli/index.html"/>
Modified: lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/analysis/BaseTokenStreamTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/analysis/BaseTokenStreamTestCase.java?rev=1073192&r1=1073113&r2=1073192&view=diff
==============================================================================
(empty)
Modified: lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/analysis/MockAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/analysis/MockAnalyzer.java?rev=1073192&r1=1073113&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/analysis/MockAnalyzer.java (original)
+++ lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/analysis/MockAnalyzer.java Tue Feb 22 01:00:39 2011
@@ -36,10 +36,6 @@ public final class MockAnalyzer extends
private final boolean payload;
private int positionIncrementGap;
- /**
- * Calls {@link #MockAnalyzer(CharacterRunAutomaton, boolean, CharacterRunAutomaton, boolean, boolean)
- * MockAnalyzer(runAutomaton, lowerCase, filter, enablePositionIncrements, true}).
- */
public MockAnalyzer(CharacterRunAutomaton runAutomaton, boolean lowerCase, CharacterRunAutomaton filter, boolean enablePositionIncrements) {
this(runAutomaton, lowerCase, filter, enablePositionIncrements, true);
}
@@ -51,7 +47,7 @@ public final class MockAnalyzer extends
* @param lowerCase true if the tokenizer should lowercase terms
* @param filter DFA describing how terms should be filtered (set of stopwords, etc)
* @param enablePositionIncrements true if position increments should reflect filtered terms.
- * @param payload if payloads should be added containing the positions (for testing)
+ * @param payload if payloads should be added
*/
public MockAnalyzer(CharacterRunAutomaton runAutomaton, boolean lowerCase, CharacterRunAutomaton filter, boolean enablePositionIncrements, boolean payload) {
this.runAutomaton = runAutomaton;
@@ -62,26 +58,21 @@ public final class MockAnalyzer extends
}
/**
- * Calls {@link #MockAnalyzer(CharacterRunAutomaton, boolean, CharacterRunAutomaton, boolean, boolean)
- * MockAnalyzer(runAutomaton, lowerCase, MockTokenFilter.EMPTY_STOPSET, false, true}).
+ * Creates a new MockAnalyzer, with no filtering.
+ *
+ * @param runAutomaton DFA describing how tokenization should happen (e.g. [a-zA-Z]+)
+ * @param lowerCase true if the tokenizer should lowercase terms
*/
public MockAnalyzer(CharacterRunAutomaton runAutomaton, boolean lowerCase) {
this(runAutomaton, lowerCase, MockTokenFilter.EMPTY_STOPSET, false, true);
}
- /**
- * Calls {@link #MockAnalyzer(CharacterRunAutomaton, boolean, CharacterRunAutomaton, boolean, boolean)
- * MockAnalyzer(runAutomaton, lowerCase, MockTokenFilter.EMPTY_STOPSET, false, payload}).
- */
public MockAnalyzer(CharacterRunAutomaton runAutomaton, boolean lowerCase, boolean payload) {
this(runAutomaton, lowerCase, MockTokenFilter.EMPTY_STOPSET, false, payload);
}
/**
- * Create a Whitespace-lowercasing analyzer with no stopwords removal.
- * <p>
- * Calls {@link #MockAnalyzer(CharacterRunAutomaton, boolean, CharacterRunAutomaton, boolean, boolean)
- * MockAnalyzer(MockTokenizer.WHITESPACE, true, MockTokenFilter.EMPTY_STOPSET, false, true}).
+ * Create a Whitespace-lowercasing analyzer with no stopwords removal
*/
public MockAnalyzer() {
this(MockTokenizer.WHITESPACE, true);
Modified: lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/analysis/MockPayloadAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/analysis/MockPayloadAnalyzer.java?rev=1073192&r1=1073113&r2=1073192&view=diff
==============================================================================
(empty)
Modified: lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/analysis/MockTokenFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/analysis/MockTokenFilter.java?rev=1073192&r1=1073113&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/analysis/MockTokenFilter.java (original)
+++ lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/analysis/MockTokenFilter.java Tue Feb 22 01:00:39 2011
@@ -60,13 +60,6 @@ public final class MockTokenFilter exten
private final CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);
private final PositionIncrementAttribute posIncrAtt = addAttribute(PositionIncrementAttribute.class);
- /**
- * Create a new MockTokenFilter.
- *
- * @param input TokenStream to filter
- * @param filter DFA representing the terms that should be removed.
- * @param enablePositionIncrements true if the removal should accumulate position increments.
- */
public MockTokenFilter(TokenStream input, CharacterRunAutomaton filter, boolean enablePositionIncrements) {
super(input);
this.filter = filter;
Modified: lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/analysis/MockTokenizer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/analysis/MockTokenizer.java?rev=1073192&r1=1073113&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/analysis/MockTokenizer.java (original)
+++ lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/analysis/MockTokenizer.java Tue Feb 22 01:00:39 2011
@@ -20,7 +20,7 @@ package org.apache.lucene.analysis;
import java.io.IOException;
import java.io.Reader;
-import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.Version;
import org.apache.lucene.util.automaton.CharacterRunAutomaton;
import org.apache.lucene.util.automaton.RegExp;
@@ -46,14 +46,14 @@ public class MockTokenizer extends CharT
private int state;
public MockTokenizer(AttributeFactory factory, Reader input, CharacterRunAutomaton runAutomaton, boolean lowerCase) {
- super(LuceneTestCase.TEST_VERSION_CURRENT, factory, input);
+ super(Version.LUCENE_CURRENT, factory, input);
this.runAutomaton = runAutomaton;
this.lowerCase = lowerCase;
this.state = runAutomaton.getInitialState();
}
public MockTokenizer(Reader input, CharacterRunAutomaton runAutomaton, boolean lowerCase) {
- super(LuceneTestCase.TEST_VERSION_CURRENT, input);
+ super(Version.LUCENE_CURRENT, input);
this.runAutomaton = runAutomaton;
this.lowerCase = lowerCase;
this.state = runAutomaton.getInitialState();
Modified: lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/index/DocHelper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/index/DocHelper.java?rev=1073192&r1=1073113&r2=1073192&view=diff
==============================================================================
(empty)
Modified: lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/index/MockIndexInput.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/index/MockIndexInput.java?rev=1073192&r1=1073113&r2=1073192&view=diff
==============================================================================
(empty)
Modified: lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/index/MockRandomMergePolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/index/MockRandomMergePolicy.java?rev=1073192&r1=1073113&r2=1073192&view=diff
==============================================================================
(empty)
Modified: lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/index/RandomIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/index/RandomIndexWriter.java?rev=1073192&r1=1073113&r2=1073192&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/index/RandomIndexWriter.java (original)
+++ lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/index/RandomIndexWriter.java Tue Feb 22 01:00:39 2011
@@ -91,10 +91,6 @@ public class RandomIndexWriter implement
}
}
- /**
- * Adds a Document.
- * @see IndexWriter#addDocument(Document)
- */
public void addDocument(Document doc) throws IOException {
w.addDocument(doc);
if (docCount++ == flushAt) {
@@ -106,21 +102,6 @@ public class RandomIndexWriter implement
}
}
- /**
- * Updates a document.
- * @see IndexWriter#updateDocument(Term, Document)
- */
- public void updateDocument(Term t, Document doc) throws IOException {
- w.updateDocument(t, doc);
- if (docCount++ == flushAt) {
- if (LuceneTestCase.VERBOSE) {
- System.out.println("RIW.updateDocument: now doing a commit");
- }
- w.commit();
- flushAt += _TestUtil.nextInt(r, 10, 1000);
- }
- }
-
public void addIndexes(Directory... dirs) throws CorruptIndexException, IOException {
w.addIndexes(dirs);
}
@@ -146,21 +127,17 @@ public class RandomIndexWriter implement
}
public IndexReader getReader() throws IOException {
- return getReader(true);
- }
-
- public IndexReader getReader(boolean applyDeletions) throws IOException {
getReaderCalled = true;
if (r.nextInt(4) == 2)
w.optimize();
// If we are writing with PreFlexRW, force a full
// IndexReader.open so terms are sorted in codepoint
// order during searching:
- if (!applyDeletions || !w.codecs.getDefaultFieldCodec().equals("PreFlex") && r.nextBoolean()) {
+ if (!w.codecs.getDefaultFieldCodec().equals("PreFlex") && r.nextBoolean()) {
if (LuceneTestCase.VERBOSE) {
System.out.println("RIW.getReader: use NRT reader");
}
- return w.getReader(applyDeletions);
+ return w.getReader();
} else {
if (LuceneTestCase.VERBOSE) {
System.out.println("RIW.getReader: open new reader");
@@ -170,10 +147,6 @@ public class RandomIndexWriter implement
}
}
- /**
- * Close this writer.
- * @see IndexWriter#close()
- */
public void close() throws IOException {
// if someone isn't using getReader() API, we want to be sure to
// maybeOptimize since presumably they might open a reader on the dir.
@@ -183,13 +156,6 @@ public class RandomIndexWriter implement
w.close();
}
- /**
- * Forces an optimize.
- * <p>
- * NOTE: this should be avoided in tests unless absolutely necessary,
- * as it will result in less test coverage.
- * @see IndexWriter#optimize()
- */
public void optimize() throws IOException {
w.optimize();
}
Modified: lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockCodec.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockCodec.java?rev=1073192&r1=1073113&r2=1073192&view=diff
==============================================================================
(empty)
Modified: lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/index/codecs/mockintblock/MockVariableIntBlockCodec.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/test-framework/org/apache/lucene/index/codecs/mockintblock/MockVariableIntBlockCodec.java?rev=1073192&r1=1073113&r2=1073192&view=diff
==============================================================================
(empty)