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 2011/02/09 10:36:03 UTC
svn commit: r1068809 [31/36] - in /lucene/dev/branches/docvalues: ./
dev-tools/eclipse/ dev-tools/idea/.idea/ dev-tools/idea/.idea/copyright/
dev-tools/idea/lucene/ dev-tools/idea/lucene/contrib/ant/
dev-tools/idea/lucene/contrib/queryparser/ dev-tools...
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/ValueSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/ValueSource.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/ValueSource.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/ValueSource.java Wed Feb 9 09:35:27 2011
@@ -18,6 +18,7 @@
package org.apache.solr.search.function;
import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
import org.apache.lucene.search.FieldComparator;
import org.apache.lucene.search.FieldComparatorSource;
import org.apache.lucene.search.Scorer;
@@ -25,12 +26,13 @@ import org.apache.lucene.search.IndexSea
import org.apache.lucene.search.SortField;
import org.apache.lucene.util.Bits;
import org.apache.lucene.index.MultiFields;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.search.SolrSortField;
import java.io.IOException;
import java.io.Serializable;
import java.util.IdentityHashMap;
import java.util.Map;
-import java.util.Collections;
/**
* Instantiates {@link org.apache.solr.search.function.DocValues} for a particular reader.
@@ -45,10 +47,12 @@ public abstract class ValueSource implem
* Gets the values for this reader and the context that was previously
* passed to createWeight()
*/
- public abstract DocValues getValues(Map context, IndexReader reader) throws IOException;
+ public abstract DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException;
+ @Override
public abstract boolean equals(Object o);
+ @Override
public abstract int hashCode();
/**
@@ -56,54 +60,80 @@ public abstract class ValueSource implem
*/
public abstract String description();
+ @Override
public String toString() {
return description();
}
+
+ /**
+ * Implementations should propagate createWeight to sub-ValueSources which can optionally store
+ * weight info in the context. The context object will be passed to getValues()
+ * where this info can be retrieved.
+ */
+ public void createWeight(Map context, IndexSearcher searcher) throws IOException {
+ }
+
+ /**
+ * Returns a new non-threadsafe context map.
+ */
+ public static Map newContext(IndexSearcher searcher) {
+ Map context = new IdentityHashMap();
+ context.put("searcher", searcher);
+ return context;
+ }
+
+
+ //
+ // Sorting by function
+ //
+
/**
* EXPERIMENTAL: This method is subject to change.
* <br>WARNING: Sorted function queries are not currently weighted.
* <p>
- * Get the SortField for this ValueSource. Uses the {@link #getValues(java.util.Map, org.apache.lucene.index.IndexReader)}
+ * Get the SortField for this ValueSource. Uses the {@link #getValues(java.util.Map, IndexReader.AtomicReaderContext)}
* to populate the SortField.
- *
+ *
* @param reverse true if this is a reverse sort.
* @return The {@link org.apache.lucene.search.SortField} for the ValueSource
* @throws IOException if there was a problem reading the values.
*/
public SortField getSortField(boolean reverse) throws IOException {
- //should we pass in the description for the field name?
- //Hmm, Lucene is going to intern whatever we pass in, not sure I like that
- //and we can't pass in null, either, as that throws an illegal arg. exception
- return new SortField(description(), new ValueSourceComparatorSource(), reverse);
+ return new ValueSourceSortField(reverse);
}
+ private static FieldComparatorSource dummyComparator = new FieldComparatorSource() {
+ @Override
+ public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException {
+ throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unweighted use of sort " + fieldname);
+ }
+ };
- /**
- * Implementations should propagate createWeight to sub-ValueSources which can optionally store
- * weight info in the context. The context object will be passed to getValues()
- * where this info can be retrieved.
- */
- public void createWeight(Map context, IndexSearcher searcher) throws IOException {
- }
+ class ValueSourceSortField extends SortField implements SolrSortField {
+ public ValueSourceSortField(boolean reverse) {
+ super(description(), dummyComparator, reverse);
+ }
- /**
- * Returns a new non-threadsafe context map.
- */
- public static Map newContext() {
- return new IdentityHashMap();
+ @Override
+ public SortField weight(IndexSearcher searcher) throws IOException {
+ Map context = newContext(searcher);
+ createWeight(context, searcher);
+ return new SortField(getField(), new ValueSourceComparatorSource(context), getReverse());
+ }
}
class ValueSourceComparatorSource extends FieldComparatorSource {
+ private final Map context;
-
- public ValueSourceComparatorSource() {
-
+ public ValueSourceComparatorSource(Map context) {
+ this.context = context;
}
+ @Override
public FieldComparator newComparator(String fieldname, int numHits,
int sortPos, boolean reversed) throws IOException {
- return new ValueSourceComparator(numHits);
+ return new ValueSourceComparator(context, numHits);
}
}
@@ -116,11 +146,14 @@ public abstract class ValueSource implem
private final double[] values;
private DocValues docVals;
private double bottom;
+ private Map fcontext;
- ValueSourceComparator(int numHits) {
+ ValueSourceComparator(Map fcontext, int numHits) {
+ this.fcontext = fcontext;
values = new double[numHits];
}
+ @Override
public int compare(int slot1, int slot2) {
final double v1 = values[slot1];
final double v2 = values[slot2];
@@ -134,6 +167,7 @@ public abstract class ValueSource implem
}
+ @Override
public int compareBottom(int doc) {
final double v2 = docVals.doubleVal(doc);
if (bottom > v2) {
@@ -145,21 +179,25 @@ public abstract class ValueSource implem
}
}
+ @Override
public void copy(int slot, int doc) {
values[slot] = docVals.doubleVal(doc);
}
- public FieldComparator setNextReader(IndexReader reader, int docBase) throws IOException {
- docVals = getValues(Collections.emptyMap(), reader);
+ @Override
+ public FieldComparator setNextReader(AtomicReaderContext context) throws IOException {
+ docVals = getValues(fcontext, context);
return this;
}
+ @Override
public void setBottom(final int bottom) {
this.bottom = values[bottom];
}
+ @Override
public Comparable value(int slot) {
- return Double.valueOf(values[slot]);
+ return values[slot];
}
}
}
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/ValueSourceRangeFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/ValueSourceRangeFilter.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/ValueSourceRangeFilter.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/ValueSourceRangeFilter.java Wed Feb 9 09:35:27 2011
@@ -20,7 +20,7 @@ package org.apache.solr.search.function;
import org.apache.lucene.search.DocIdSet;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
import org.apache.solr.search.SolrFilter;
import java.io.IOException;
@@ -49,10 +49,12 @@ public class ValueSourceRangeFilter exte
this.includeUpper = upperVal != null && includeUpper;
}
- public DocIdSet getDocIdSet(final Map context, final IndexReader reader) throws IOException {
+ @Override
+ public DocIdSet getDocIdSet(final Map context, final AtomicReaderContext readerContext) throws IOException {
return new DocIdSet() {
- public DocIdSetIterator iterator() throws IOException {
- return valueSource.getValues(context, reader).getRangeScorer(reader, lowerVal, upperVal, includeLower, includeUpper);
+ @Override
+ public DocIdSetIterator iterator() throws IOException {
+ return valueSource.getValues(context, readerContext).getRangeScorer(readerContext.reader, lowerVal, upperVal, includeLower, includeUpper);
}
};
}
@@ -62,6 +64,7 @@ public class ValueSourceRangeFilter exte
valueSource.createWeight(context, searcher);
}
+ @Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("frange(");
@@ -75,6 +78,7 @@ public class ValueSourceRangeFilter exte
return sb.toString();
}
+ @Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof ValueSourceRangeFilter)) return false;
@@ -89,6 +93,7 @@ public class ValueSourceRangeFilter exte
return true;
}
+ @Override
public int hashCode() {
int h = valueSource.hashCode();
h += lowerVal != null ? lowerVal.hashCode() : 0x572353db;
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/VectorValueSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/VectorValueSource.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/VectorValueSource.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/VectorValueSource.java Wed Feb 9 09:35:27 2011
@@ -16,7 +16,7 @@ package org.apache.solr.search.function;
* limitations under the License.
*/
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
import org.apache.lucene.search.IndexSearcher;
import org.apache.solr.search.function.MultiValueSource;
import org.apache.solr.search.function.DocValues;
@@ -44,6 +44,7 @@ public class VectorValueSource extends M
return sources;
}
+ @Override
public int dimension() {
return sources.size();
}
@@ -53,13 +54,13 @@ public class VectorValueSource extends M
}
@Override
- public DocValues getValues(Map context, IndexReader reader) throws IOException {
+ public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
int size = sources.size();
// special-case x,y and lat,lon since it's so common
if (size==2) {
- final DocValues x = sources.get(0).getValues(context, reader);
- final DocValues y = sources.get(1).getValues(context, reader);
+ final DocValues x = sources.get(0).getValues(context, readerContext);
+ final DocValues y = sources.get(1).getValues(context, readerContext);
return new DocValues() {
@Override
public void byteVal(int doc, byte[] vals) {
@@ -97,6 +98,7 @@ public class VectorValueSource extends M
vals[0] = x.strVal(doc);
vals[1] = y.strVal(doc);
}
+ @Override
public String toString(int doc) {
return name() + "(" + x.toString(doc) + "," + y.toString(doc) + ")";
}
@@ -106,7 +108,7 @@ public class VectorValueSource extends M
final DocValues[] valsArr = new DocValues[size];
for (int i = 0; i < size; i++) {
- valsArr[i] = sources.get(i).getValues(context, reader);
+ valsArr[i] = sources.get(i).getValues(context, readerContext);
}
return new DocValues() {
@@ -178,12 +180,14 @@ public class VectorValueSource extends M
};
}
+ @Override
public void createWeight(Map context, IndexSearcher searcher) throws IOException {
for (ValueSource source : sources)
source.createWeight(context, searcher);
}
+ @Override
public String description() {
StringBuilder sb = new StringBuilder();
sb.append(name()).append('(');
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/distance/GeohashFunction.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/distance/GeohashFunction.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/distance/GeohashFunction.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/distance/GeohashFunction.java Wed Feb 9 09:35:27 2011
@@ -18,7 +18,7 @@ package org.apache.solr.search.function.
import org.apache.solr.search.function.ValueSource;
import org.apache.solr.search.function.DocValues;
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
import org.apache.lucene.spatial.geohash.GeoHashUtils;
import java.util.Map;
@@ -46,9 +46,9 @@ public class GeohashFunction extends Val
}
@Override
- public DocValues getValues(Map context, IndexReader reader) throws IOException {
- final DocValues latDV = lat.getValues(context, reader);
- final DocValues lonDV = lon.getValues(context, reader);
+ public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
+ final DocValues latDV = lat.getValues(context, readerContext);
+ final DocValues lonDV = lon.getValues(context, readerContext);
return new DocValues() {
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/distance/GeohashHaversineFunction.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/distance/GeohashHaversineFunction.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/distance/GeohashHaversineFunction.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/distance/GeohashHaversineFunction.java Wed Feb 9 09:35:27 2011
@@ -20,7 +20,7 @@ package org.apache.solr.search.function.
import org.apache.lucene.spatial.DistanceUtils;
import org.apache.solr.search.function.ValueSource;
import org.apache.solr.search.function.DocValues;
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.spatial.geohash.GeoHashUtils;
@@ -54,27 +54,32 @@ public class GeohashHaversineFunction ex
}
@Override
- public DocValues getValues(Map context, IndexReader reader) throws IOException {
- final DocValues gh1DV = geoHash1.getValues(context, reader);
- final DocValues gh2DV = geoHash2.getValues(context, reader);
+ public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
+ final DocValues gh1DV = geoHash1.getValues(context, readerContext);
+ final DocValues gh2DV = geoHash2.getValues(context, readerContext);
return new DocValues() {
+ @Override
public float floatVal(int doc) {
return (float) doubleVal(doc);
}
+ @Override
public int intVal(int doc) {
return (int) doubleVal(doc);
}
+ @Override
public long longVal(int doc) {
return (long) doubleVal(doc);
}
+ @Override
public double doubleVal(int doc) {
return distance(doc, gh1DV, gh2DV);
}
+ @Override
public String strVal(int doc) {
return Double.toString(doubleVal(doc));
}
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/distance/HaversineConstFunction.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/distance/HaversineConstFunction.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/distance/HaversineConstFunction.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/distance/HaversineConstFunction.java Wed Feb 9 09:35:27 2011
@@ -16,7 +16,7 @@ package org.apache.solr.search.function.
* limitations under the License.
*/
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.spatial.DistanceUtils;
@@ -39,6 +39,7 @@ import java.util.Map;
public class HaversineConstFunction extends ValueSource {
public static ValueSourceParser parser = new ValueSourceParser() {
+ @Override
public ValueSource parse(FunctionQParser fp) throws ParseException
{
// TODO: dispatch through SpatialQueriable in the future?
@@ -190,26 +191,30 @@ public class HaversineConstFunction exte
}
@Override
- public DocValues getValues(Map context, IndexReader reader) throws IOException {
- final DocValues latVals = latSource.getValues(context, reader);
- final DocValues lonVals = lonSource.getValues(context, reader);
+ public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
+ final DocValues latVals = latSource.getValues(context, readerContext);
+ final DocValues lonVals = lonSource.getValues(context, readerContext);
final double latCenterRad = this.latCenter * DistanceUtils.DEGREES_TO_RADIANS;
final double lonCenterRad = this.lonCenter * DistanceUtils.DEGREES_TO_RADIANS;
final double latCenterRad_cos = this.latCenterRad_cos;
return new DocValues() {
+ @Override
public float floatVal(int doc) {
return (float) doubleVal(doc);
}
+ @Override
public int intVal(int doc) {
return (int) doubleVal(doc);
}
+ @Override
public long longVal(int doc) {
return (long) doubleVal(doc);
}
+ @Override
public double doubleVal(int doc) {
double latRad = latVals.doubleVal(doc) * DistanceUtils.DEGREES_TO_RADIANS;
double lonRad = lonVals.doubleVal(doc) * DistanceUtils.DEGREES_TO_RADIANS;
@@ -222,6 +227,7 @@ public class HaversineConstFunction exte
return (EARTH_MEAN_DIAMETER * Math.atan2(Math.sqrt(h), Math.sqrt(1 - h)));
}
+ @Override
public String strVal(int doc) {
return Double.toString(doubleVal(doc));
}
@@ -260,6 +266,7 @@ public class HaversineConstFunction exte
return result;
}
+ @Override
public String description() {
return name() + '(' + p2 + ',' + latCenter + ',' + lonCenter + ')';
}
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/distance/HaversineFunction.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/distance/HaversineFunction.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/distance/HaversineFunction.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/distance/HaversineFunction.java Wed Feb 9 09:35:27 2011
@@ -16,7 +16,7 @@ package org.apache.solr.search.function.
* limitations under the License.
*/
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.spatial.DistanceUtils;
import org.apache.solr.common.SolrException;
@@ -95,27 +95,32 @@ public class HaversineFunction extends V
@Override
- public DocValues getValues(Map context, IndexReader reader) throws IOException {
- final DocValues vals1 = p1.getValues(context, reader);
+ public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
+ final DocValues vals1 = p1.getValues(context, readerContext);
- final DocValues vals2 = p2.getValues(context, reader);
+ final DocValues vals2 = p2.getValues(context, readerContext);
return new DocValues() {
+ @Override
public float floatVal(int doc) {
return (float) doubleVal(doc);
}
+ @Override
public int intVal(int doc) {
return (int) doubleVal(doc);
}
+ @Override
public long longVal(int doc) {
return (long) doubleVal(doc);
}
+ @Override
public double doubleVal(int doc) {
return distance(doc, vals1, vals2);
}
+ @Override
public String strVal(int doc) {
return Double.toString(doubleVal(doc));
}
@@ -159,6 +164,7 @@ public class HaversineFunction extends V
return result;
}
+ @Override
public String description() {
StringBuilder sb = new StringBuilder();
sb.append(name()).append('(');
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/distance/SquaredEuclideanFunction.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/distance/SquaredEuclideanFunction.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/distance/SquaredEuclideanFunction.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/distance/SquaredEuclideanFunction.java Wed Feb 9 09:35:27 2011
@@ -33,6 +33,7 @@ public class SquaredEuclideanFunction ex
}
+ @Override
protected String name() {
return name;
@@ -41,6 +42,7 @@ public class SquaredEuclideanFunction ex
/**
* @param doc The doc to score
*/
+ @Override
protected double distance(int doc, DocValues dv1, DocValues dv2) {
double[] vals1 = new double[source1.dimension()];
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/distance/StringDistanceFunction.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/distance/StringDistanceFunction.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/distance/StringDistanceFunction.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/distance/StringDistanceFunction.java Wed Feb 9 09:35:27 2011
@@ -1,6 +1,23 @@
package org.apache.solr.search.function.distance;
-import org.apache.lucene.index.IndexReader;
+/**
+ * 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 org.apache.lucene.index.IndexReader.AtomicReaderContext;
import org.apache.lucene.search.spell.StringDistance;
import org.apache.solr.search.function.DocValues;
import org.apache.solr.search.function.ValueSource;
@@ -31,23 +48,27 @@ public class StringDistanceFunction exte
}
@Override
- public DocValues getValues(Map context, IndexReader reader) throws IOException {
- final DocValues str1DV = str1.getValues(context, reader);
- final DocValues str2DV = str2.getValues(context, reader);
+ public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
+ final DocValues str1DV = str1.getValues(context, readerContext);
+ final DocValues str2DV = str2.getValues(context, readerContext);
return new DocValues() {
+ @Override
public float floatVal(int doc) {
return dist.getDistance(str1DV.strVal(doc), str2DV.strVal(doc));
}
+ @Override
public int intVal(int doc) {
return (int) doubleVal(doc);
}
+ @Override
public long longVal(int doc) {
return (long) doubleVal(doc);
}
+ @Override
public double doubleVal(int doc) {
return (double) floatVal(doc);
}
@@ -64,6 +85,7 @@ public class StringDistanceFunction exte
};
}
+ @Override
public String description() {
StringBuilder sb = new StringBuilder();
sb.append("strdist").append('(');
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/distance/VectorDistanceFunction.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/distance/VectorDistanceFunction.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/distance/VectorDistanceFunction.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/distance/VectorDistanceFunction.java Wed Feb 9 09:35:27 2011
@@ -16,7 +16,7 @@ package org.apache.solr.search.function.
* limitations under the License.
*/
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.spatial.DistanceUtils;
import org.apache.solr.common.SolrException;
@@ -78,11 +78,11 @@ public class VectorDistanceFunction exte
}
@Override
- public DocValues getValues(Map context, IndexReader reader) throws IOException {
+ public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
- final DocValues vals1 = source1.getValues(context, reader);
+ final DocValues vals1 = source1.getValues(context, readerContext);
- final DocValues vals2 = source2.getValues(context, reader);
+ final DocValues vals2 = source2.getValues(context, readerContext);
return new DocValues() {
@@ -96,22 +96,27 @@ public class VectorDistanceFunction exte
return (short) doubleVal(doc);
}
+ @Override
public float floatVal(int doc) {
return (float) doubleVal(doc);
}
+ @Override
public int intVal(int doc) {
return (int) doubleVal(doc);
}
+ @Override
public long longVal(int doc) {
return (long) doubleVal(doc);
}
+ @Override
public double doubleVal(int doc) {
return distance(doc, vals1, vals2);
}
+ @Override
public String strVal(int doc) {
return Double.toString(doubleVal(doc));
}
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java Wed Feb 9 09:35:27 2011
@@ -91,6 +91,7 @@ public abstract class AbstractLuceneSpel
protected StringDistance sd;
+ @Override
public String init(NamedList config, SolrCore core) {
super.init(config, core);
indexDir = (String) config.get(INDEX_DIR);
@@ -213,6 +214,7 @@ public abstract class AbstractLuceneSpel
return reader;
}
+ @Override
public void reload(SolrCore core, SolrIndexSearcher searcher) throws IOException {
spellChecker.setSpellIndex(index);
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/FileBasedSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/FileBasedSpellChecker.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/FileBasedSpellChecker.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/FileBasedSpellChecker.java Wed Feb 9 09:35:27 2011
@@ -50,12 +50,14 @@ public class FileBasedSpellChecker exten
private String characterEncoding;
public static final String WORD_FIELD_NAME = "word";
+ @Override
public String init(NamedList config, SolrCore core) {
super.init(config, core);
characterEncoding = (String) config.get(SOURCE_FILE_CHAR_ENCODING);
return name;
}
+ @Override
public void build(SolrCore core, SolrIndexSearcher searcher) {
try {
loadExternalFileDictionary(core);
@@ -74,7 +76,6 @@ public class FileBasedSpellChecker exten
return null;
}
- @SuppressWarnings("unchecked")
private void loadExternalFileDictionary(SolrCore core) {
try {
@@ -92,7 +93,6 @@ public class FileBasedSpellChecker exten
new IndexWriterConfig(core.getSolrConfig().luceneMatchVersion, fieldType.getAnalyzer()).
setMaxBufferedDocs(150).
setMergePolicy(mp).
- setMaxFieldLength(IndexWriterConfig.UNLIMITED_FIELD_LENGTH).
setOpenMode(IndexWriterConfig.OpenMode.CREATE)
);
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/IndexBasedSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/IndexBasedSpellChecker.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/IndexBasedSpellChecker.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/IndexBasedSpellChecker.java Wed Feb 9 09:35:27 2011
@@ -49,6 +49,7 @@ public class IndexBasedSpellChecker exte
protected float threshold;
protected IndexReader reader;
+ @Override
public String init(NamedList config, SolrCore core) {
super.init(config, core);
threshold = config.get(THRESHOLD_TOKEN_FREQUENCY) == null ? 0.0f
@@ -68,12 +69,13 @@ public class IndexBasedSpellChecker exte
}
}
+ @Override
public void build(SolrCore core, SolrIndexSearcher searcher) {
IndexReader reader = null;
try {
if (sourceLocation == null) {
// Load from Solr's index
- reader = searcher.getReader();
+ reader = searcher.getIndexReader();
} else {
// Load from Lucene index at given sourceLocation
reader = this.reader;
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/SpellingQueryConverter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/SpellingQueryConverter.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/SpellingQueryConverter.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/SpellingQueryConverter.java Wed Feb 9 09:35:27 2011
@@ -91,6 +91,7 @@ public class SpellingQueryConverter exte
* @param original the original query string
* @return a Collection of Lucene Tokens
*/
+ @Override
public Collection<Token> convert(String original) {
if (original == null) { // this can happen with q.alt = and no query
return Collections.emptyList();
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/suggest/Lookup.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/suggest/Lookup.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/suggest/Lookup.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/suggest/Lookup.java Wed Feb 9 09:35:27 2011
@@ -25,6 +25,7 @@ public abstract class Lookup {
this.value = value;
}
+ @Override
public String toString() {
return key + "/" + value;
}
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/suggest/Suggester.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/suggest/Suggester.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/suggest/Suggester.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/suggest/Suggester.java Wed Feb 9 09:35:27 2011
@@ -100,7 +100,7 @@ public class Suggester extends SolrSpell
public void build(SolrCore core, SolrIndexSearcher searcher) {
LOG.info("build()");
if (sourceLocation == null) {
- reader = searcher.getReader();
+ reader = searcher.getIndexReader();
dictionary = new HighFrequencyDictionary(reader, field, threshold);
} else {
try {
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/CommitUpdateCommand.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/CommitUpdateCommand.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/CommitUpdateCommand.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/CommitUpdateCommand.java Wed Feb 9 09:35:27 2011
@@ -39,6 +39,7 @@ public class CommitUpdateCommand extends
super("commit", req);
this.optimize=optimize;
}
+ @Override
public String toString() {
return "commit(optimize="+optimize
+",waitFlush="+waitFlush
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/DeleteUpdateCommand.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/DeleteUpdateCommand.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/DeleteUpdateCommand.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/DeleteUpdateCommand.java Wed Feb 9 09:35:27 2011
@@ -30,6 +30,7 @@ public class DeleteUpdateCommand extends
super("delete", req);
}
+ @Override
public String toString() {
StringBuilder sb = new StringBuilder(commandName);
sb.append(':');
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/DirectUpdateHandler2.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/DirectUpdateHandler2.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/DirectUpdateHandler2.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/DirectUpdateHandler2.java Wed Feb 9 09:35:27 2011
@@ -134,6 +134,7 @@ public class DirectUpdateHandler2 extend
}
}
+ @Override
public int addDoc(AddUpdateCommand cmd) throws IOException {
addCommands.incrementAndGet();
addCommandsCumulative.incrementAndGet();
@@ -202,6 +203,7 @@ public class DirectUpdateHandler2 extend
// could return the number of docs deleted, but is that always possible to know???
+ @Override
public void delete(DeleteUpdateCommand cmd) throws IOException {
deleteByIdCommands.incrementAndGet();
deleteByIdCommandsCumulative.incrementAndGet();
@@ -221,6 +223,7 @@ public class DirectUpdateHandler2 extend
// why not return number of docs deleted?
// Depending on implementation, we may not be able to immediately determine the num...
+ @Override
public void deleteByQuery(DeleteUpdateCommand cmd) throws IOException {
deleteByQueryCommands.incrementAndGet();
deleteByQueryCommandsCumulative.incrementAndGet();
@@ -263,6 +266,7 @@ public class DirectUpdateHandler2 extend
}
}
+ @Override
public int mergeIndexes(MergeIndexesCommand cmd) throws IOException {
mergeIndexesCommands.incrementAndGet();
int rc = -1;
@@ -300,6 +304,7 @@ public class DirectUpdateHandler2 extend
}
}
+ @Override
public void commit(CommitUpdateCommand cmd) throws IOException {
if (cmd.optimize) {
@@ -369,6 +374,7 @@ public class DirectUpdateHandler2 extend
/**
* @since Solr 1.4
*/
+ @Override
public void rollback(RollbackUpdateCommand cmd) throws IOException {
rollbackCommands.incrementAndGet();
@@ -402,6 +408,7 @@ public class DirectUpdateHandler2 extend
}
+ @Override
public void close() throws IOException {
log.info("closing " + this);
iwCommit.lock();
@@ -547,6 +554,7 @@ public class DirectUpdateHandler2 extend
// to facilitate testing: blocks if called during commit
public synchronized int getCommitCount() { return autoCommitCount; }
+ @Override
public String toString() {
if(timeUpperBound > 0 || docsUpperBound > 0) {
return
@@ -619,6 +627,7 @@ public class DirectUpdateHandler2 extend
return lst;
}
+ @Override
public String toString() {
return "DirectUpdateHandler2" + getStatistics();
}
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/SolrIndexConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/SolrIndexConfig.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/SolrIndexConfig.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/SolrIndexConfig.java Wed Feb 9 09:35:27 2011
@@ -53,7 +53,6 @@ public class SolrIndexConfig {
maxMergeDocs = -1;
mergeFactor = -1;
ramBufferSizeMB = 16;
- maxFieldLength = -1;
writeLockTimeout = -1;
commitLockTimeout = -1;
lockType = null;
@@ -71,7 +70,6 @@ public class SolrIndexConfig {
public final double ramBufferSizeMB;
- public final int maxFieldLength;
public final int writeLockTimeout;
public final int commitLockTimeout;
public final String lockType;
@@ -95,7 +93,6 @@ public class SolrIndexConfig {
mergeFactor=solrConfig.getInt(prefix+"/mergeFactor",def.mergeFactor);
ramBufferSizeMB = solrConfig.getDouble(prefix+"/ramBufferSizeMB", def.ramBufferSizeMB);
- maxFieldLength=solrConfig.getInt(prefix+"/maxFieldLength",def.maxFieldLength);
writeLockTimeout=solrConfig.getInt(prefix+"/writeLockTimeout", def.writeLockTimeout);
commitLockTimeout=solrConfig.getInt(prefix+"/commitLockTimeout", def.commitLockTimeout);
lockType=solrConfig.get(prefix+"/lockType", def.lockType);
@@ -153,13 +150,10 @@ public class SolrIndexConfig {
if (termIndexInterval != -1)
iwc.setTermIndexInterval(termIndexInterval);
- if (maxFieldLength != -1)
- iwc.setMaxFieldLength(maxFieldLength);
-
if (writeLockTimeout != -1)
iwc.setWriteLockTimeout(writeLockTimeout);
- iwc.setSimilarity(schema.getSimilarity());
+ iwc.setSimilarityProvider(schema.getSimilarityProvider());
iwc.setMergePolicy(buildMergePolicy(schema));
iwc.setMergeScheduler(buildMergeScheduler(schema));
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/SolrIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/SolrIndexWriter.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/SolrIndexWriter.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/SolrIndexWriter.java Wed Feb 9 09:35:27 2011
@@ -132,6 +132,7 @@ public class SolrIndexWriter extends Ind
* ****
*/
private volatile boolean isClosed = false;
+ @Override
public void close() throws IOException {
log.debug("Closing Writer " + name);
try {
@@ -178,6 +179,7 @@ public class SolrIndexWriter extends Ind
// We might ideally want to override print(String) as well, but
// looking through the code that writes to infoStream, it appears
// that all the classes except CheckIndex just use println.
+ @Override
public void println(String x) {
print(dateFormat.format(new Date()) + " ");
super.println(x);
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/UpdateCommand.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/UpdateCommand.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/UpdateCommand.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/UpdateCommand.java Wed Feb 9 09:35:27 2011
@@ -33,6 +33,7 @@ import org.apache.solr.request.SolrQuery
this.commandName = commandName;
}
+ @Override
public String toString() {
return commandName;
}
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/UpdateHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/UpdateHandler.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/UpdateHandler.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/UpdateHandler.java Wed Feb 9 09:35:27 2011
@@ -18,7 +18,7 @@
package org.apache.solr.update;
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
import org.apache.lucene.index.Term;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@@ -152,7 +152,7 @@ public abstract class UpdateHandler impl
@Override
public void collect(int doc) {
try {
- searcher.getReader().deleteDocument(doc + docBase);
+ searcher.getIndexReader().deleteDocument(doc + docBase);
deleted++;
} catch (IOException e) {
// don't try to close the searcher on failure for now...
@@ -167,8 +167,8 @@ public abstract class UpdateHandler impl
}
@Override
- public void setNextReader(IndexReader arg0, int docBase) throws IOException {
- this.docBase = docBase;
+ public void setNextReader(AtomicReaderContext context) throws IOException {
+ docBase = context.docBase;
}
@Override
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/processor/Lookup3Signature.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/processor/Lookup3Signature.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/processor/Lookup3Signature.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/processor/Lookup3Signature.java Wed Feb 9 09:35:27 2011
@@ -25,10 +25,12 @@ public class Lookup3Signature extends Si
public Lookup3Signature() {
}
+ @Override
public void add(String content) {
hash = Hash.lookup3ycs64(content,0,content.length(),hash);
}
+ @Override
public byte[] getSignature() {
return new byte[]{(byte)(hash>>56),(byte)(hash>>48),(byte)(hash>>40),(byte)(hash>>32),(byte)(hash>>24),(byte)(hash>>16),(byte)(hash>>8),(byte)(hash>>0)};
}
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/processor/MD5Signature.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/processor/MD5Signature.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/processor/MD5Signature.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/processor/MD5Signature.java Wed Feb 9 09:35:27 2011
@@ -26,6 +26,7 @@ import org.slf4j.LoggerFactory;
public class MD5Signature extends Signature {
protected final static Logger log = LoggerFactory.getLogger(MD5Signature.class);
private static ThreadLocal<MessageDigest> DIGESTER_FACTORY = new ThreadLocal<MessageDigest>() {
+ @Override
protected MessageDigest initialValue() {
try {
return MessageDigest.getInstance("MD5");
@@ -41,6 +42,7 @@ public class MD5Signature extends Signat
digester.reset();
}
+ @Override
public void add(String content) {
try {
digester.update(content.getBytes("UTF-8"));
@@ -51,6 +53,7 @@ public class MD5Signature extends Signat
}
}
+ @Override
public byte[] getSignature() {
return digester.digest();
}
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/processor/TextProfileSignature.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/processor/TextProfileSignature.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/processor/TextProfileSignature.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/update/processor/TextProfileSignature.java Wed Feb 9 09:35:27 2011
@@ -51,12 +51,14 @@ public class TextProfileSignature extend
private float quantRate;
private float minTokenLen;
+ @Override
public void init(SolrParams params) {
quantRate = params.getFloat("quantRate", 0.01f);
minTokenLen = params.getInt("minTokenLen", 2);
}
+ @Override
public byte[] getSignature() {
return super.getSignature();
}
@@ -144,6 +146,7 @@ public class TextProfileSignature extend
this.val = val;
}
+ @Override
public String toString() {
return val + " " + cnt;
}
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/util/BoundedTreeSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/util/BoundedTreeSet.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/util/BoundedTreeSet.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/util/BoundedTreeSet.java Wed Feb 9 09:35:27 2011
@@ -55,11 +55,13 @@ public class BoundedTreeSet<E> extends T
remove(last());
}
}
+ @Override
public boolean add(E item) {
boolean out = super.add(item);
adjust();
return out;
}
+ @Override
public boolean addAll(Collection<? extends E> c) {
boolean out = super.addAll(c);
adjust();
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/util/HighFrequencyDictionary.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/util/HighFrequencyDictionary.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/util/HighFrequencyDictionary.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/util/HighFrequencyDictionary.java Wed Feb 9 09:35:27 2011
@@ -76,7 +76,11 @@ public class HighFrequencyDictionary imp
}
public float freq() {
- return termsEnum.docFreq();
+ try {
+ return termsEnum.docFreq();
+ } catch (IOException ioe) {
+ throw new RuntimeException(ioe);
+ }
}
public String next() {
@@ -112,8 +116,12 @@ public class HighFrequencyDictionary imp
}
// got a valid term, does it pass the threshold?
- if (isFrequent(termsEnum.docFreq())) {
- return true;
+ try {
+ if (isFrequent(termsEnum.docFreq())) {
+ return true;
+ }
+ } catch (IOException ioe) {
+ throw new RuntimeException(ioe);
}
}
}
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/util/SentinelIntSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/util/SentinelIntSet.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/util/SentinelIntSet.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/util/SentinelIntSet.java Wed Feb 9 09:35:27 2011
@@ -1,134 +1,134 @@
-/**
- * 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.
- */
-
-package org.apache.solr.util;
-
-import java.util.Arrays;
-
-/** A native int set where one value is reserved to mean "EMPTY" */
-public class SentinelIntSet {
- public int[] keys;
- public int count;
- public final int emptyVal;
- public int rehashCount; // the count at which a rehash should be done
-
- public SentinelIntSet(int size, int emptyVal) {
- this.emptyVal = emptyVal;
- int tsize = Math.max(org.apache.lucene.util.BitUtil.nextHighestPowerOfTwo(size), 1);
- rehashCount = tsize - (tsize>>2);
- if (size >= rehashCount) { // should be able to hold "size" w/o rehashing
- tsize <<= 1;
- rehashCount = tsize - (tsize>>2);
- }
- keys = new int[tsize];
- if (emptyVal != 0)
- clear();
- }
-
- public void clear() {
- Arrays.fill(keys, emptyVal);
- count = 0;
- }
-
- public int hash(int key) {
- return key;
- }
-
- public int size() { return count; }
-
- /** returns the slot for this key */
- public int getSlot(int key) {
- assert key != emptyVal;
- int h = hash(key);
- int s = h & (keys.length-1);
- if (keys[s] == key || keys[s]== emptyVal) return s;
-
- int increment = (h>>7)|1;
- do {
- s = (s + increment) & (keys.length-1);
- } while (keys[s] != key && keys[s] != emptyVal);
- return s;
- }
-
- /** returns the slot for this key, or -slot-1 if not found */
- public int find(int key) {
- assert key != emptyVal;
- int h = hash(key);
- int s = h & (keys.length-1);
- if (keys[s] == key) return s;
- if (keys[s] == emptyVal) return -s-1;
-
- int increment = (h>>7)|1;
- for(;;) {
- s = (s + increment) & (keys.length-1);
- if (keys[s] == key) return s;
- if (keys[s] == emptyVal) return -s-1;
- }
- }
-
-
- public boolean exists(int key) {
- return find(key) >= 0;
- }
-
-
- public int put(int key) {
- int s = find(key);
- if (s < 0) {
- if (count >= rehashCount) {
- rehash();
- s = getSlot(key);
- } else {
- s = -s-1;
- }
- count++;
- keys[s] = key;
- putKey(key, s);
- } else {
- overwriteKey(key, s);
- }
- return s;
- }
-
-
- protected void putKey(int key, int slot) {}
- protected void overwriteKey(int key, int slot) {}
-
- protected void startRehash(int newSize) {}
- protected void moveKey(int key, int oldSlot, int newSlot) {}
- protected void endRehash() {}
-
- public void rehash() {
- int newSize = keys.length << 1;
- startRehash(newSize);
- int[] oldKeys = keys;
- keys = new int[newSize];
- if (emptyVal != 0) Arrays.fill(keys, emptyVal);
-
- for (int i=0; i<oldKeys.length; i++) {
- int key = oldKeys[i];
- if (key == emptyVal) continue;
- int newSlot = getSlot(key);
- keys[newSlot] = key;
- moveKey(key, i, newSlot);
- }
- endRehash();
- rehashCount = newSize - (newSize>>2);
-
- }
-
-}
+/**
+ * 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.
+ */
+
+package org.apache.solr.util;
+
+import java.util.Arrays;
+
+/** A native int set where one value is reserved to mean "EMPTY" */
+public class SentinelIntSet {
+ public int[] keys;
+ public int count;
+ public final int emptyVal;
+ public int rehashCount; // the count at which a rehash should be done
+
+ public SentinelIntSet(int size, int emptyVal) {
+ this.emptyVal = emptyVal;
+ int tsize = Math.max(org.apache.lucene.util.BitUtil.nextHighestPowerOfTwo(size), 1);
+ rehashCount = tsize - (tsize>>2);
+ if (size >= rehashCount) { // should be able to hold "size" w/o rehashing
+ tsize <<= 1;
+ rehashCount = tsize - (tsize>>2);
+ }
+ keys = new int[tsize];
+ if (emptyVal != 0)
+ clear();
+ }
+
+ public void clear() {
+ Arrays.fill(keys, emptyVal);
+ count = 0;
+ }
+
+ public int hash(int key) {
+ return key;
+ }
+
+ public int size() { return count; }
+
+ /** returns the slot for this key */
+ public int getSlot(int key) {
+ assert key != emptyVal;
+ int h = hash(key);
+ int s = h & (keys.length-1);
+ if (keys[s] == key || keys[s]== emptyVal) return s;
+
+ int increment = (h>>7)|1;
+ do {
+ s = (s + increment) & (keys.length-1);
+ } while (keys[s] != key && keys[s] != emptyVal);
+ return s;
+ }
+
+ /** returns the slot for this key, or -slot-1 if not found */
+ public int find(int key) {
+ assert key != emptyVal;
+ int h = hash(key);
+ int s = h & (keys.length-1);
+ if (keys[s] == key) return s;
+ if (keys[s] == emptyVal) return -s-1;
+
+ int increment = (h>>7)|1;
+ for(;;) {
+ s = (s + increment) & (keys.length-1);
+ if (keys[s] == key) return s;
+ if (keys[s] == emptyVal) return -s-1;
+ }
+ }
+
+
+ public boolean exists(int key) {
+ return find(key) >= 0;
+ }
+
+
+ public int put(int key) {
+ int s = find(key);
+ if (s < 0) {
+ if (count >= rehashCount) {
+ rehash();
+ s = getSlot(key);
+ } else {
+ s = -s-1;
+ }
+ count++;
+ keys[s] = key;
+ putKey(key, s);
+ } else {
+ overwriteKey(key, s);
+ }
+ return s;
+ }
+
+
+ protected void putKey(int key, int slot) {}
+ protected void overwriteKey(int key, int slot) {}
+
+ protected void startRehash(int newSize) {}
+ protected void moveKey(int key, int oldSlot, int newSlot) {}
+ protected void endRehash() {}
+
+ public void rehash() {
+ int newSize = keys.length << 1;
+ startRehash(newSize);
+ int[] oldKeys = keys;
+ keys = new int[newSize];
+ if (emptyVal != 0) Arrays.fill(keys, emptyVal);
+
+ for (int i=0; i<oldKeys.length; i++) {
+ int key = oldKeys[i];
+ if (key == emptyVal) continue;
+ int newSlot = getSlot(key);
+ keys[newSlot] = key;
+ moveKey(key, i, newSlot);
+ }
+ endRehash();
+ rehashCount = newSize - (newSize>>2);
+
+ }
+
+}
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/util/SimplePostTool.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/util/SimplePostTool.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/util/SimplePostTool.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/util/SimplePostTool.java Wed Feb 9 09:35:27 2011
@@ -22,14 +22,9 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
+import java.io.ByteArrayInputStream;
import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-import java.io.StringReader;
-import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
-import java.io.Writer;
import java.util.Set;
import java.util.HashSet;
import java.net.HttpURLConnection;
@@ -44,12 +39,14 @@ import java.net.URL;
*/
public class SimplePostTool {
public static final String DEFAULT_POST_URL = "http://localhost:8983/solr/update";
- public static final String POST_ENCODING = "UTF-8";
- public static final String VERSION_OF_THIS_TOOL = "1.2";
+ public static final String VERSION_OF_THIS_TOOL = "1.3";
private static final String SOLR_OK_RESPONSE_EXCERPT = "<int name=\"status\">0</int>";
private static final String DEFAULT_COMMIT = "yes";
-
+ private static final String DEFAULT_OUT = "no";
+
+ private static final String DEFAULT_DATA_TYPE = "application/xml";
+
private static final String DATA_MODE_FILES = "files";
private static final String DATA_MODE_ARGS = "args";
private static final String DATA_MODE_STDIN = "stdin";
@@ -61,37 +58,35 @@ public class SimplePostTool {
DATA_MODES.add(DATA_MODE_ARGS);
DATA_MODES.add(DATA_MODE_STDIN);
}
-
+
protected URL solrUrl;
- private class PostException extends RuntimeException {
- PostException(String reason,Throwable cause) {
- super(reason + " (POST URL=" + solrUrl + ")",cause);
- }
- }
-
public static void main(String[] args) {
info("version " + VERSION_OF_THIS_TOOL);
if (0 < args.length && "-help".equals(args[0])) {
System.out.println
- ("This is a simple command line tool for POSTing raw XML to a Solr\n"+
- "port. XML data can be read from files specified as commandline\n"+
- "args; as raw commandline arg strings; or via STDIN.\n"+
+ ("This is a simple command line tool for POSTing raw data to a Solr\n"+
+ "port. Data can be read from files specified as commandline args,\n"+
+ "as raw commandline arg strings, or via STDIN.\n"+
"Examples:\n"+
" java -Ddata=files -jar post.jar *.xml\n"+
" java -Ddata=args -jar post.jar '<delete><id>42</id></delete>'\n"+
" java -Ddata=stdin -jar post.jar < hd.xml\n"+
"Other options controlled by System Properties include the Solr\n"+
- "URL to POST to, and whether a commit should be executed. These\n"+
- "are the defaults for all System Properties...\n"+
+ "URL to POST to, the Content-Type of the data, whether a commit\n"+
+ "should be executed, and whether the response should be written\n"+
+ "to STDOUT. These are the defaults for all System Properties...\n"+
" -Ddata=" + DEFAULT_DATA_MODE + "\n"+
+ " -Dtype=" + DEFAULT_DATA_TYPE + "\n"+
" -Durl=" + DEFAULT_POST_URL + "\n"+
- " -Dcommit=" + DEFAULT_COMMIT + "\n");
+ " -Dcommit=" + DEFAULT_COMMIT + "\n"+
+ " -Dout=" + DEFAULT_OUT + "\n");
return;
}
-
+ OutputStream out = null;
+
URL u = null;
try {
u = new URL(System.getProperty("url", DEFAULT_POST_URL));
@@ -105,53 +100,49 @@ public class SimplePostTool {
fatal("System Property 'data' is not valid for this tool: " + mode);
}
+ final String doOut = System.getProperty("out", DEFAULT_OUT);
+ if ("yes".equals(System.getProperty("out", DEFAULT_OUT))) {
+ out = System.out;
+ }
+
try {
if (DATA_MODE_FILES.equals(mode)) {
if (0 < args.length) {
info("POSTing files to " + u + "..");
- final int posted = t.postFiles(args,0);
+ final int posted = t.postFiles(args, 0, out);
}
} else if (DATA_MODE_ARGS.equals(mode)) {
if (0 < args.length) {
info("POSTing args to " + u + "..");
for (String a : args) {
- final StringWriter sw = new StringWriter();
- t.postData(new StringReader(a), sw);
- warnIfNotExpectedResponse(sw.toString(),SOLR_OK_RESPONSE_EXCERPT);
+ t.postData(t.stringToStream(a), null, out);
}
}
} else if (DATA_MODE_STDIN.equals(mode)) {
info("POSTing stdin to " + u + "..");
- final StringWriter sw = new StringWriter();
- t.postData(new InputStreamReader(System.in,POST_ENCODING), sw);
- warnIfNotExpectedResponse(sw.toString(),SOLR_OK_RESPONSE_EXCERPT);
+ t.postData(System.in, null, out);
}
if ("yes".equals(System.getProperty("commit",DEFAULT_COMMIT))) {
info("COMMITting Solr index changes..");
- final StringWriter sw = new StringWriter();
- t.commit(sw);
- warnIfNotExpectedResponse(sw.toString(),SOLR_OK_RESPONSE_EXCERPT);
+ t.commit(out);
}
- } catch(IOException ioe) {
- fatal("Unexpected IOException " + ioe);
+ } catch(RuntimeException e) {
+ fatal("RuntimeException " + e);
}
}
/** Post all filenames provided in args, return the number of files posted*/
- int postFiles(String [] args,int startIndexInArgs) throws IOException {
+ int postFiles(String [] args,int startIndexInArgs, OutputStream out) {
int filesPosted = 0;
for (int j = startIndexInArgs; j < args.length; j++) {
File srcFile = new File(args[j]);
- final StringWriter sw = new StringWriter();
-
if (srcFile.canRead()) {
info("POSTing file " + srcFile.getName());
- postFile(srcFile, sw);
+ postFile(srcFile, out);
filesPosted++;
- warnIfNotExpectedResponse(sw.toString(),SOLR_OK_RESPONSE_EXCERPT);
} else {
warn("Cannot read input file: " + srcFile);
}
@@ -159,15 +150,6 @@ public class SimplePostTool {
return filesPosted;
}
- /** Check what Solr replied to a POST, and complain if it's not what we expected.
- * TODO: parse the response and check it XMLwise, here we just check it as an unparsed String
- */
- static void warnIfNotExpectedResponse(String actual,String expected) {
- if(actual.indexOf(expected) < 0) {
- warn("Unexpected response from Solr: '" + actual + "' does not contain '" + expected + "'");
- }
- }
-
static void warn(String msg) {
System.err.println("SimplePostTool: WARNING: " + msg);
}
@@ -187,15 +169,13 @@ public class SimplePostTool {
*/
public SimplePostTool(URL solrUrl) {
this.solrUrl = solrUrl;
- warn("Make sure your XML documents are encoded in " + POST_ENCODING
- + ", other encodings are not currently supported");
}
/**
* Does a simple commit operation
*/
- public void commit(Writer output) throws IOException {
- postData(new StringReader("<commit/>"), output);
+ public void commit(OutputStream output) {
+ postData(stringToStream("<commit/>"), null, output);
}
/**
@@ -203,85 +183,103 @@ public class SimplePostTool {
* writes to response to output.
* @throws UnsupportedEncodingException
*/
- public void postFile(File file, Writer output)
- throws FileNotFoundException, UnsupportedEncodingException {
+ public void postFile(File file, OutputStream output) {
- // FIXME; use a real XML parser to read files, so as to support various encodings
- // (and we can only post well-formed XML anyway)
- Reader reader = new InputStreamReader(new FileInputStream(file),POST_ENCODING);
+ InputStream is = null;
try {
- postData(reader, output);
+ is = new FileInputStream(file);
+ postData(is, (int)file.length(), output);
+ } catch (IOException e) {
+ fatal("Can't open/read file: " + file);
} finally {
try {
- if(reader!=null) reader.close();
+ if(is!=null) is.close();
} catch (IOException e) {
- throw new PostException("IOException while closing file", e);
+ fatal("IOException while closing file: "+ e);
}
}
}
/**
- * Reads data from the data reader and posts it to solr,
+ * Reads data from the data stream and posts it to solr,
* writes to the response to output
*/
- public void postData(Reader data, Writer output) {
+ public void postData(InputStream data, Integer length, OutputStream output) {
+
+ final String type = System.getProperty("type", DEFAULT_DATA_TYPE);
HttpURLConnection urlc = null;
try {
- urlc = (HttpURLConnection) solrUrl.openConnection();
try {
- urlc.setRequestMethod("POST");
- } catch (ProtocolException e) {
- throw new PostException("Shouldn't happen: HttpURLConnection doesn't support POST??", e);
+ urlc = (HttpURLConnection) solrUrl.openConnection();
+ try {
+ urlc.setRequestMethod("POST");
+ } catch (ProtocolException e) {
+ fatal("Shouldn't happen: HttpURLConnection doesn't support POST??"+e);
+
+ }
+ urlc.setDoOutput(true);
+ urlc.setDoInput(true);
+ urlc.setUseCaches(false);
+ urlc.setAllowUserInteraction(false);
+ urlc.setRequestProperty("Content-type", type);
+
+ if (null != length) urlc.setFixedLengthStreamingMode(length);
+
+ } catch (IOException e) {
+ fatal("Connection error (is Solr running at " + solrUrl + " ?): " + e);
}
- urlc.setDoOutput(true);
- urlc.setDoInput(true);
- urlc.setUseCaches(false);
- urlc.setAllowUserInteraction(false);
- urlc.setRequestProperty("Content-type", "text/xml; charset=" + POST_ENCODING);
-
- OutputStream out = urlc.getOutputStream();
+ OutputStream out = null;
try {
- Writer writer = new OutputStreamWriter(out, POST_ENCODING);
- pipe(data, writer);
- writer.close();
+ out = urlc.getOutputStream();
+ pipe(data, out);
} catch (IOException e) {
- throw new PostException("IOException while posting data", e);
+ fatal("IOException while posting data: " + e);
} finally {
- if(out!=null) out.close();
+ try { if(out!=null) out.close(); } catch (IOException x) { /*NOOP*/ }
}
- InputStream in = urlc.getInputStream();
+ InputStream in = null;
try {
- Reader reader = new InputStreamReader(in);
- pipe(reader, output);
- reader.close();
+ if (HttpURLConnection.HTTP_OK != urlc.getResponseCode()) {
+ fatal("Solr returned an error #" + urlc.getResponseCode() +
+ " " + urlc.getResponseMessage());
+ }
+
+ in = urlc.getInputStream();
+ pipe(in, output);
} catch (IOException e) {
- throw new PostException("IOException while reading response", e);
+ fatal("IOException while reading response: " + e);
} finally {
- if(in!=null) in.close();
+ try { if(in!=null) in.close(); } catch (IOException x) { /*NOOP*/ }
}
- } catch (IOException e) {
- try {
- fatal("Solr returned an error: " + urlc.getResponseMessage());
- } catch (IOException f) { }
- fatal("Connection error (is Solr running at " + solrUrl + " ?): " + e);
} finally {
if(urlc!=null) urlc.disconnect();
}
}
+ private static InputStream stringToStream(String s) {
+ InputStream is = null;
+ try {
+ is = new ByteArrayInputStream(s.getBytes("UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ fatal("Shouldn't happen: UTF-8 not supported?!?!?!");
+ }
+ return is;
+ }
+
/**
- * Pipes everything from the reader to the writer via a buffer
+ * Pipes everything from the source to the dest. If dest is null,
+ * then everything is read fro msource and thrown away.
*/
- private static void pipe(Reader reader, Writer writer) throws IOException {
- char[] buf = new char[1024];
+ private static void pipe(InputStream source, OutputStream dest) throws IOException {
+ byte[] buf = new byte[1024];
int read = 0;
- while ( (read = reader.read(buf) ) >= 0) {
- writer.write(buf, 0, read);
+ while ( (read = source.read(buf) ) >= 0) {
+ if (null != dest) dest.write(buf, 0, read);
}
- writer.flush();
+ if (null != dest) dest.flush();
}
}
Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/util/SolrPluginUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/util/SolrPluginUtils.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/util/SolrPluginUtils.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/util/SolrPluginUtils.java Wed Feb 9 09:35:27 2011
@@ -703,6 +703,7 @@ public class SolrPluginUtils {
* DisjunctionMaxQuery. (so yes: aliases which point at other
* aliases should work)
*/
+ @Override
protected Query getFieldQuery(String field, String queryText, boolean quoted)
throws ParseException {
Modified: lucene/dev/branches/docvalues/solr/src/site/src/documentation/skins/lucene/css/screen.css
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/site/src/documentation/skins/lucene/css/screen.css?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/site/src/documentation/skins/lucene/css/screen.css (original)
+++ lucene/dev/branches/docvalues/solr/src/site/src/documentation/skins/lucene/css/screen.css Wed Feb 9 09:35:27 2011
@@ -95,7 +95,7 @@ html>body #top .searchbox {
#top .searchbox {
position: absolute;
right: 10px;
- height: 42px;
+ height: 28px;
font-size: 70%;
white-space: nowrap;
text-align: right;
Modified: lucene/dev/branches/docvalues/solr/src/site/src/documentation/skins/lucene/xslt/html/site-to-xhtml.xsl
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/site/src/documentation/skins/lucene/xslt/html/site-to-xhtml.xsl?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/site/src/documentation/skins/lucene/xslt/html/site-to-xhtml.xsl (original)
+++ lucene/dev/branches/docvalues/solr/src/site/src/documentation/skins/lucene/xslt/html/site-to-xhtml.xsl Wed Feb 9 09:35:27 2011
@@ -215,15 +215,20 @@ footer, searchbar, css etc. As input, i
</form>
</xsl:when>
<xsl:otherwise>
- <form class="roundtopsmall" method="get" action="http://search.lucidimagination.com/p:solr">
+ <form class="roundtopsmall" method="get" action="http://search.lucidimagination.com/p:solr" id="searchform">
<input type="text" id="query" name="q" size="25" onFocus="getBlank (this, '{$search-prompt}');">
<xsl:attribute name="value">
<xsl:value-of select="$search-prompt"/>
</xsl:attribute>
</input> 
- <input type="submit" value="Search" name="Search" i18n:attr="value"/>
+ <input type="submit" value="Search" name="Search" onclick="selectProvider(this.form)"/>
+ @
+ <select name="searchProvider" id="searchProvider">
+ <option value="any">select provider</option>
+ <option value="lucid">Lucid Find</option>
+ <option value="sl">Search-Lucene</option>
+ </select>
</form>
- <div style="position: relative; top: -5px; left: -10px">Powered by <a style="color: #033268" href="http://www.lucidimagination.com">Lucid Imagination</a></div>
</xsl:otherwise>
</xsl:choose>
<!--div id="roundbottomsmall">
@@ -472,13 +477,19 @@ document.write("]]><i18n:text >Last Publ
</form>
</xsl:when>
<xsl:otherwise>
- <form class="roundtopsmall" method="get" action="http://search.lucidimagination.com/p:solr">
+ <form class="roundtopsmall" method="get" action="http://search.lucidimagination.com/p:solr" id="searchform">
<input type="text" id="query" name="q" size="25" onFocus="getBlank (this, '{$search-prompt}');">
<xsl:attribute name="value">
<xsl:value-of select="$search-prompt"/>
</xsl:attribute>
</input> 
- <input type="submit" value="Search" name="Search" i18n:attr="value"/>
+ <input type="submit" value="Search" name="Search" onclick="selectProvider(this.form)"/>
+ @
+ <select name="searchProvider" id="searchProvider">
+ <option value="any">select provider</option>
+ <option value="lucid">Lucid Find</option>
+ <option value="sl">Search-Lucene</option>
+ </select>
</form>
</xsl:otherwise>
</xsl:choose>
@@ -487,6 +498,51 @@ document.write("]]><i18n:text >Last Publ
|end search
+</xsl:comment>
</xsl:if>
+ <xsl:if test="$config/search">
+ <xsl:choose>
+ <xsl:when test="$config/search/@provider = 'lucene'">
+ </xsl:when>
+ <xsl:otherwise>
+ <script type="text/javascript">
+ function selectProvider(form) {
+ provider = form.elements['searchProvider'].value;
+ if (provider == "any") {
+ if (Math.random() > 0.5) {
+ provider = "lucid";
+ } else {
+ provider = "sl";
+ }
+ }
+
+ if (provider == "lucid") {
+ form.action = "http://search.lucidimagination.com/p:solr";
+ } else if (provider == "sl") {
+ form.action = "http://search-lucene.com/solr";
+ }
+
+ days = 365; // cookie will be valid for a year
+ date = new Date();
+ date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
+ expires = "; expires=" + date.toGMTString();
+ document.cookie = "searchProvider=" + provider + expires + "; path=/";
+ }
+
+ if (document.cookie.length>0) {
+ cStart=document.cookie.indexOf("searchProvider=");
+ if (cStart!=-1) {
+ cStart=cStart + "searchProvider=".length;
+ cEnd=document.cookie.indexOf(";", cStart);
+ if (cEnd==-1) {
+ cEnd=document.cookie.length;
+ }
+ provider = unescape(document.cookie.substring(cStart,cEnd));
+ document.forms['searchform'].elements['searchProvider'].value = provider;
+ }
+ }
+ </script>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
<!--credits in alternative location-->
<div id="credit">
<xsl:if test="$filename = 'index.html' and $config/credits and ($config/credits/credit/@box-location = 'alt')">
Modified: lucene/dev/branches/docvalues/solr/src/solrj/org/apache/solr/client/solrj/impl/BinaryRequestWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/solrj/org/apache/solr/client/solrj/impl/BinaryRequestWriter.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/solrj/org/apache/solr/client/solrj/impl/BinaryRequestWriter.java (original)
+++ lucene/dev/branches/docvalues/solr/src/solrj/org/apache/solr/client/solrj/impl/BinaryRequestWriter.java Wed Feb 9 09:35:27 2011
@@ -36,6 +36,7 @@ import java.util.List;
*/
public class BinaryRequestWriter extends RequestWriter {
+ @Override
public Collection<ContentStream> getContentStreams(SolrRequest req) throws IOException {
if (req instanceof UpdateRequest) {
UpdateRequest updateRequest = (UpdateRequest) req;
@@ -55,10 +56,12 @@ public class BinaryRequestWriter extends
}
+ @Override
public String getUpdateContentType() {
return "application/octet-stream";
}
+ @Override
public ContentStream getContentStream(final UpdateRequest request) throws IOException {
final BAOS baos = new BAOS();
new JavaBinUpdateRequestCodec().marshal(request, baos);
@@ -91,6 +94,7 @@ public class BinaryRequestWriter extends
}
+ @Override
public void write(SolrRequest request, OutputStream os) throws IOException {
if (request instanceof UpdateRequest) {
UpdateRequest updateRequest = (UpdateRequest) request;
@@ -106,6 +110,7 @@ public class BinaryRequestWriter extends
}
}
+ @Override
public String getPath(SolrRequest req) {
if (req instanceof UpdateRequest) {
return "/update/javabin";
Modified: lucene/dev/branches/docvalues/solr/src/solrj/org/apache/solr/client/solrj/impl/BinaryResponseParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/solrj/org/apache/solr/client/solrj/impl/BinaryResponseParser.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/solrj/org/apache/solr/client/solrj/impl/BinaryResponseParser.java (original)
+++ lucene/dev/branches/docvalues/solr/src/solrj/org/apache/solr/client/solrj/impl/BinaryResponseParser.java Wed Feb 9 09:35:27 2011
@@ -30,10 +30,12 @@ import java.io.Reader;
* @since solr 1.3
*/
public class BinaryResponseParser extends ResponseParser {
+ @Override
public String getWriterType() {
return "javabin";
}
+ @Override
public NamedList<Object> processResponse(InputStream body, String encoding) {
try {
return (NamedList<Object>) new JavaBinCodec().unmarshal(body);
@@ -44,10 +46,12 @@ public class BinaryResponseParser extend
}
+ @Override
public String getVersion() {
return "2";
}
+ @Override
public NamedList<Object> processResponse(Reader reader) {
throw new RuntimeException("Cannot handle character stream");
}
Modified: lucene/dev/branches/docvalues/solr/src/solrj/org/apache/solr/client/solrj/impl/CloudSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/solrj/org/apache/solr/client/solrj/impl/CloudSolrServer.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/solrj/org/apache/solr/client/solrj/impl/CloudSolrServer.java (original)
+++ lucene/dev/branches/docvalues/solr/src/solrj/org/apache/solr/client/solrj/impl/CloudSolrServer.java Wed Feb 9 09:35:27 2011
@@ -1,5 +1,22 @@
package org.apache.solr.client.solrj.impl;
+/**
+ * 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.io.IOException;
import java.net.MalformedURLException;
import java.util.ArrayList;
Modified: lucene/dev/branches/docvalues/solr/src/solrj/org/apache/solr/client/solrj/impl/CommonsHttpSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/solrj/org/apache/solr/client/solrj/impl/CommonsHttpSolrServer.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/solrj/org/apache/solr/client/solrj/impl/CommonsHttpSolrServer.java (original)
+++ lucene/dev/branches/docvalues/solr/src/solrj/org/apache/solr/client/solrj/impl/CommonsHttpSolrServer.java Wed Feb 9 09:35:27 2011
@@ -20,7 +20,6 @@ package org.apache.solr.client.solrj.imp
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.io.Reader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
@@ -62,6 +61,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
+ * The {@link CommonsHttpSolrServer} uses the Apache Commons HTTP Client to connect to solr.
+ * <pre class="prettyprint" >SolrServer server = new CommonsHttpSolrServer( url );</pre>
*
* @version $Id$
* @since solr 1.3
@@ -335,11 +336,11 @@ public class CommonsHttpSolrServer exten
@Override
protected void sendData(OutputStream out)
throws IOException {
- Reader reader = c.getReader();
+ InputStream in = c.getStream();
try {
- IOUtils.copy(reader, out);
+ IOUtils.copy(in, out);
} finally {
- reader.close();
+ in.close();
}
}
});
Modified: lucene/dev/branches/docvalues/solr/src/solrj/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/solrj/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/solrj/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java (original)
+++ lucene/dev/branches/docvalues/solr/src/solrj/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java Wed Feb 9 09:35:27 2011
@@ -105,6 +105,7 @@ public class LBHttpSolrServer extends So
this.solrServer = solrServer;
}
+ @Override
public String toString() {
return solrServer.getBaseURL();
}
@@ -149,7 +150,7 @@ public class LBHttpSolrServer extends So
return numDeadServersToTry;
}
- /** @return The number of dead servers to try if there are no live servers left.
+ /** @param numDeadServersToTry The number of dead servers to try if there are no live servers left.
* Defaults to the number of servers in this request. */
public void setNumDeadServersToTry(int numDeadServersToTry) {
this.numDeadServersToTry = numDeadServersToTry;
@@ -376,6 +377,7 @@ public class LBHttpSolrServer extends So
* @throws SolrServerException
* @throws IOException
*/
+ @Override
public NamedList<Object> request(final SolrRequest request)
throws SolrServerException, IOException {
Exception ex = null;
@@ -535,6 +537,7 @@ public class LBHttpSolrServer extends So
return httpClient;
}
+ @Override
protected void finalize() throws Throwable {
try {
if(this.aliveCheckExecutor!=null)
Modified: lucene/dev/branches/docvalues/solr/src/solrj/org/apache/solr/client/solrj/impl/StreamingBinaryResponseParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/solrj/org/apache/solr/client/solrj/impl/StreamingBinaryResponseParser.java?rev=1068809&r1=1068808&r2=1068809&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/solrj/org/apache/solr/client/solrj/impl/StreamingBinaryResponseParser.java (original)
+++ lucene/dev/branches/docvalues/solr/src/solrj/org/apache/solr/client/solrj/impl/StreamingBinaryResponseParser.java Wed Feb 9 09:35:27 2011
@@ -48,12 +48,14 @@ public class StreamingBinaryResponsePars
try {
JavaBinCodec codec = new JavaBinCodec() {
+ @Override
public SolrDocument readSolrDocument(FastInputStream dis) throws IOException {
SolrDocument doc = super.readSolrDocument(dis);
callback.streamSolrDocument( doc );
return null;
}
+ @Override
public SolrDocumentList readSolrDocumentList(FastInputStream dis) throws IOException {
SolrDocumentList solrDocs = new SolrDocumentList();
List list = (List) readVal(dis);