You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2015/12/21 12:40:14 UTC
svn commit: r1721134 [27/48] - in /lucene/dev/branches/lucene6835: ./
dev-tools/ dev-tools/eclipse/dot.settings/ dev-tools/idea/.idea/libraries/
dev-tools/maven/ dev-tools/maven/lucene/analysis/morfologik/
dev-tools/scripts/ lucene/ lucene/analysis/ lu...
Modified: lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/IndexSchema.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/IndexSchema.java (original)
+++ lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/IndexSchema.java Mon Dec 21 11:39:57 2015
@@ -17,28 +17,14 @@
package org.apache.solr.schema;
-import java.io.IOException;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedMap;
-import java.util.SortedSet;
-import java.util.TreeMap;
-import java.util.TreeSet;
-import java.util.regex.Pattern;
-
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
+import java.io.IOException;
+import java.io.Writer;
+import java.lang.invoke.MethodHandles;
+import java.util.*;
+import java.util.regex.Pattern;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.DelegatingAnalyzerWrapper;
@@ -53,10 +39,10 @@ import org.apache.lucene.index.StoredDoc
import org.apache.lucene.search.similarities.Similarity;
import org.apache.lucene.uninverting.UninvertingReader;
import org.apache.lucene.util.Version;
-import org.apache.solr.cloud.CloudUtil;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.core.Config;
@@ -65,7 +51,8 @@ import org.apache.solr.core.SolrResource
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.response.SchemaXmlWriter;
import org.apache.solr.response.SolrQueryResponse;
-import org.apache.solr.search.similarities.DefaultSimilarityFactory;
+import org.apache.solr.search.similarities.ClassicSimilarityFactory;
+import org.apache.solr.search.similarities.SchemaSimilarityFactory;
import org.apache.solr.util.DOMUtil;
import org.apache.solr.util.plugin.SolrCoreAware;
import org.slf4j.Logger;
@@ -122,7 +109,7 @@ public class IndexSchema {
private static final String TEXT_FUNCTION = "text()";
private static final String XPATH_OR = " | ";
- final static Logger log = LoggerFactory.getLogger(IndexSchema.class);
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
protected final SolrConfig solrConfig;
protected String resourceName;
protected String name;
@@ -448,9 +435,6 @@ public class IndexSchema {
}
protected void readSchema(InputSource is) {
- String resourcePath = CloudUtil.unifiedResourcePath(loader) + resourceName;
- log.info("Reading Solr Schema from " + resourcePath);
-
try {
// pass the config resource loader to avoid building an empty one for no reason:
// in the current case though, the stream is valid so we wont load the resource by name
@@ -497,10 +481,11 @@ public class IndexSchema {
Node node = (Node) xpath.evaluate(expression, document, XPathConstants.NODE);
similarityFactory = readSimilarity(loader, node);
if (similarityFactory == null) {
- similarityFactory = new DefaultSimilarityFactory();
- final NamedList similarityParams = new NamedList();
- Version luceneVersion = getDefaultLuceneMatchVersion();
- similarityFactory.init(SolrParams.toSolrParams(similarityParams));
+ final boolean modernSim = getDefaultLuceneMatchVersion().onOrAfter(Version.LUCENE_6_0_0);
+ final Class simClass = modernSim ? SchemaSimilarityFactory.class : ClassicSimilarityFactory.class;
+ // use the loader to ensure proper SolrCoreAware handling
+ similarityFactory = loader.newInstance(simClass.getName(), SimilarityFactory.class);
+ similarityFactory.init(new ModifiableSolrParams());
} else {
isExplicitSimilarity = true;
}
@@ -592,13 +577,12 @@ public class IndexSchema {
postReadInform();
} catch (SolrException e) {
- throw new SolrException(ErrorCode.getErrorCode(e.code()), e.getMessage() + ". Schema file is " +
- resourcePath, e);
+ throw new SolrException(ErrorCode.getErrorCode(e.code()),
+ "Can't load schema " + loader.resourceLocation(resourceName) + ": " + e.getMessage(), e);
} catch(Exception e) {
// unexpected exception...
throw new SolrException(ErrorCode.SERVER_ERROR,
- "Schema Parsing Failed: " + e.getMessage() + ". Schema file is " + resourcePath,
- e);
+ "Can't load schema " + loader.resourceLocation(resourceName) + ": " + e.getMessage(), e);
}
// create the field analyzers
Modified: lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/IndexSchemaFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/IndexSchemaFactory.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/IndexSchemaFactory.java (original)
+++ lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/IndexSchemaFactory.java Mon Dec 21 11:39:57 2015
@@ -16,6 +16,7 @@ package org.apache.solr.schema;
* limitations under the License.
*/
+import org.apache.lucene.util.Version;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.core.PluginInfo;
@@ -29,10 +30,11 @@ import org.xml.sax.InputSource;
import java.io.File;
import java.io.InputStream;
+import java.lang.invoke.MethodHandles;
/** Base class for factories for IndexSchema implementations */
public abstract class IndexSchemaFactory implements NamedListInitializedPlugin {
- private static final Logger log = LoggerFactory.getLogger(IndexSchemaFactory.class);
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
/** Returns an index schema created from a local resource */
public IndexSchema create(String resourceName, SolrConfig config) {
@@ -64,7 +66,12 @@ public abstract class IndexSchemaFactory
factory = config.getResourceLoader().newInstance(info.className, IndexSchemaFactory.class);
factory.init(info.initArgs);
} else {
- factory = new ClassicIndexSchemaFactory();
+ if (config.luceneMatchVersion.onOrAfter(Version.LUCENE_6_0_0)) {
+ // ManagedIndexSchemaFactory is SolrCoreAware so we must create using the resource loader
+ factory = config.getResourceLoader().newInstance(ManagedIndexSchemaFactory.class.getName(), IndexSchemaFactory.class);
+ } else {
+ factory = new ClassicIndexSchemaFactory();
+ }
}
IndexSchema schema = factory.create(resourceName, config);
return schema;
Modified: lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/JsonPreAnalyzedParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/JsonPreAnalyzedParser.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/JsonPreAnalyzedParser.java (original)
+++ lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/JsonPreAnalyzedParser.java Mon Dec 21 11:39:57 2015
@@ -2,6 +2,7 @@ package org.apache.solr.schema;
import java.io.IOException;
import java.io.Reader;
+import java.lang.invoke.MethodHandles;
import java.util.LinkedHashMap;
import java.util.Iterator;
import java.util.LinkedList;
@@ -50,7 +51,7 @@ import org.slf4j.LoggerFactory;
*/
public class JsonPreAnalyzedParser implements PreAnalyzedParser {
- private static final Logger LOG = LoggerFactory.getLogger(JsonPreAnalyzedParser.class);
+ private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
public static final String VERSION = "1";
Modified: lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/LatLonType.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/LatLonType.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/LatLonType.java (original)
+++ lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/LatLonType.java Mon Dec 21 11:39:57 2015
@@ -31,6 +31,7 @@ import org.apache.lucene.queries.functio
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.ConstantScoreWeight;
+import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.Explanation;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
@@ -219,7 +220,7 @@ public class LatLonType extends Abstract
public ValueSource getValueSource(SchemaField field, QParser parser) {
ArrayList<ValueSource> vs = new ArrayList<>(2);
for (int i = 0; i < 2; i++) {
- SchemaField sub = subField(field, i, parser.getReq().getSchema());
+ SchemaField sub = subField(field, i, schema);
vs.add(sub.getType().getValueSource(sub, parser));
}
return new LatLonValueSource(field, vs);
@@ -427,27 +428,44 @@ class SpatialDistanceQuery extends Exten
return doc;
}
- // instead of matching all docs, we could also embed a query.
- // the score could either ignore the subscore, or boost it.
- // Containment: floatline(foo:myTerm, "myFloatField", 1.0, 0.0f)
- // Boost: foo:myTerm^floatline("myFloatField",1.0,0.0f)
@Override
- public int nextDoc() throws IOException {
- for(;;) {
- ++doc;
- if (doc>=maxDoc) {
- return doc=NO_MORE_DOCS;
+ public DocIdSetIterator iterator() {
+ return new DocIdSetIterator() {
+
+ @Override
+ public int docID() {
+ return doc;
}
- if (!match()) continue;
- return doc;
- }
- }
- @Override
- public int advance(int target) throws IOException {
- // this will work even if target==NO_MORE_DOCS
- doc=target-1;
- return nextDoc();
+ // instead of matching all docs, we could also embed a query.
+ // the score could either ignore the subscore, or boost it.
+ // Containment: floatline(foo:myTerm, "myFloatField", 1.0, 0.0f)
+ // Boost: foo:myTerm^floatline("myFloatField",1.0,0.0f)
+ @Override
+ public int nextDoc() throws IOException {
+ for(;;) {
+ ++doc;
+ if (doc>=maxDoc) {
+ return doc=NO_MORE_DOCS;
+ }
+ if (!match()) continue;
+ return doc;
+ }
+ }
+
+ @Override
+ public int advance(int target) throws IOException {
+ // this will work even if target==NO_MORE_DOCS
+ doc=target-1;
+ return nextDoc();
+ }
+
+ @Override
+ public long cost() {
+ return maxDoc;
+ }
+
+ };
}
@Override
@@ -461,11 +479,6 @@ class SpatialDistanceQuery extends Exten
return 1;
}
- @Override
- public long cost() {
- return maxDoc;
- }
-
public Explanation explain(Explanation base, int doc) throws IOException {
if (base.isMatch() == false) {
return base;
Modified: lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java (original)
+++ lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java Mon Dec 21 11:39:57 2015
@@ -21,6 +21,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
+import java.lang.invoke.MethodHandles;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
@@ -72,6 +73,8 @@ import org.apache.solr.util.RTimer;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.data.Stat;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.xml.sax.InputSource;
/** Solr-managed schema - non-user-editable, but can be mutable via internal and external REST API requests. */
@@ -86,6 +89,8 @@ public final class ManagedIndexSchema ex
int schemaZkVersion;
final Object schemaUpdateLock;
+
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
/**
* Constructs a schema using the specified resource name and stream.
Modified: lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchemaFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchemaFactory.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchemaFactory.java (original)
+++ lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchemaFactory.java Mon Dec 21 11:39:57 2015
@@ -16,6 +16,12 @@ package org.apache.solr.schema;
* limitations under the License.
*/
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.invoke.MethodHandles;
+
import org.apache.commons.io.IOUtils;
import org.apache.solr.cloud.ZkController;
import org.apache.solr.cloud.ZkSolrResourceLoader;
@@ -36,22 +42,17 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.InputSource;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-
/** Factory for ManagedIndexSchema */
public class ManagedIndexSchemaFactory extends IndexSchemaFactory implements SolrCoreAware {
- private static final Logger log = LoggerFactory.getLogger(ManagedIndexSchemaFactory.class);
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private static final String UPGRADED_SCHEMA_EXTENSION = ".bak";
private static final String SCHEMA_DOT_XML = "schema.xml";
public static final String DEFAULT_MANAGED_SCHEMA_RESOURCE_NAME = "managed-schema";
public static final String MANAGED_SCHEMA_RESOURCE_NAME = "managedSchemaResourceName";
- private boolean isMutable;
- private String managedSchemaResourceName;
+ private boolean isMutable = true;
+ private String managedSchemaResourceName = DEFAULT_MANAGED_SCHEMA_RESOURCE_NAME;
public String getManagedSchemaResourceName() { return managedSchemaResourceName; }
private SolrConfig config;
private SolrResourceLoader loader;
@@ -68,7 +69,7 @@ public class ManagedIndexSchemaFactory e
@Override
public void init(NamedList args) {
SolrParams params = SolrParams.toSolrParams(args);
- isMutable = params.getBool("mutable", false);
+ isMutable = params.getBool("mutable", true);
args.remove("mutable");
managedSchemaResourceName = params.get(MANAGED_SCHEMA_RESOURCE_NAME, DEFAULT_MANAGED_SCHEMA_RESOURCE_NAME);
args.remove(MANAGED_SCHEMA_RESOURCE_NAME);
@@ -284,7 +285,7 @@ public class ManagedIndexSchemaFactory e
+ "nor under SolrConfig.getConfigDir() or the current directory."
+ " PLEASE REMOVE THIS FILE.");
} else {
- File upgradedSchemaFile = new File(nonManagedSchemaFile.getPath() + UPGRADED_SCHEMA_EXTENSION);
+ File upgradedSchemaFile = new File(nonManagedSchemaFile + UPGRADED_SCHEMA_EXTENSION);
if (nonManagedSchemaFile.renameTo(upgradedSchemaFile)) {
// Set the resource name to the managed schema so that the CoreAdminHandler returns a findable filename
schema.setResourceName(managedSchemaResourceName);
@@ -309,25 +310,10 @@ public class ManagedIndexSchemaFactory e
*@return the File for the named resource, or null if it can't be found
*/
private File locateConfigFile(String resource) {
- File located = null;
- File file = new File(resource);
- if (file.isAbsolute()) {
- if (file.isFile() && file.canRead()) {
- located = file;
- }
- } else {
- // try $configDir/$resource
- File fileUnderConfigDir = new File(config.getResourceLoader().getConfigDir() + resource);
- if (fileUnderConfigDir.isFile() && fileUnderConfigDir.canRead()) {
- located = fileUnderConfigDir;
- } else {
- // no success with $configDir/$resource - try $CWD/$resource
- if (file.isFile() && file.canRead()) {
- located = file;
- }
- }
- }
- return located;
+ String location = config.getResourceLoader().resourceLocation(resource);
+ if (location.equals(resource) || location.startsWith("classpath:"))
+ return null;
+ return new File(location);
}
/**
Modified: lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/OpenExchangeRatesOrgProvider.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/OpenExchangeRatesOrgProvider.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/OpenExchangeRatesOrgProvider.java (original)
+++ lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/OpenExchangeRatesOrgProvider.java Mon Dec 21 11:39:57 2015
@@ -19,6 +19,7 @@ package org.apache.solr.schema;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.lang.invoke.MethodHandles;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
@@ -54,7 +55,7 @@ import org.slf4j.LoggerFactory;
* @see <a href="https://openexchangerates.org/documentation">openexchangerates.org JSON Data Format</a>
*/
public class OpenExchangeRatesOrgProvider implements ExchangeRateProvider {
- public static Logger log = LoggerFactory.getLogger(OpenExchangeRatesOrgProvider.class);
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
protected static final String PARAM_RATES_FILE_LOCATION = "ratesFileLocation";
protected static final String PARAM_REFRESH_INTERVAL = "refreshInterval";
protected static final String DEFAULT_REFRESH_INTERVAL = "1440";
Modified: lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/PreAnalyzedField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/PreAnalyzedField.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/PreAnalyzedField.java (original)
+++ lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/PreAnalyzedField.java Mon Dec 21 11:39:57 2015
@@ -19,6 +19,7 @@ package org.apache.solr.schema;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
+import java.lang.invoke.MethodHandles;
import java.lang.reflect.Constructor;
import java.util.Iterator;
import java.util.LinkedList;
@@ -51,7 +52,7 @@ import static org.apache.solr.common.par
* optionally with an independent stored value of a field.
*/
public class PreAnalyzedField extends FieldType {
- private static final Logger LOG = LoggerFactory.getLogger(PreAnalyzedField.class);
+ private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
/** Init argument name. Value is a fully-qualified class name of the parser
* that implements {@link PreAnalyzedParser}.
@@ -159,8 +160,8 @@ public class PreAnalyzedField extends Fi
*/
public static org.apache.lucene.document.FieldType createFieldType(SchemaField field) {
if (!field.indexed() && !field.stored()) {
- if (log.isTraceEnabled())
- log.trace("Ignoring unindexed/unstored field: " + field);
+ if (LOG.isTraceEnabled())
+ LOG.trace("Ignoring unindexed/unstored field: " + field);
return null;
}
org.apache.lucene.document.FieldType newType = new org.apache.lucene.document.FieldType();
Modified: lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/SchemaField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/SchemaField.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/SchemaField.java (original)
+++ lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/SchemaField.java Mon Dec 21 11:39:57 2015
@@ -28,7 +28,6 @@ import org.apache.lucene.search.SortFiel
import org.apache.solr.common.SolrException;
import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.response.TextResponseWriter;
-import org.apache.solr.search.QParser;
/**
* Encapsulates all information about a Field in a Solr Schema
@@ -177,7 +176,7 @@ public final class SchemaField extends F
* getValueSource implementation
* @see FieldType#getValueSource
*/
- public void checkFieldCacheSource(QParser parser) throws SolrException {
+ public void checkFieldCacheSource() throws SolrException {
if (! (indexed() || hasDocValues()) ) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
"can not use FieldCache on a field which is neither indexed nor has doc values: "
Modified: lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/SchemaManager.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/SchemaManager.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/SchemaManager.java (original)
+++ lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/SchemaManager.java Mon Dec 21 11:39:57 2015
@@ -36,6 +36,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.io.StringWriter;
+import java.lang.invoke.MethodHandles;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.HashMap;
@@ -59,7 +60,7 @@ import static org.apache.solr.schema.Ind
* It is an all or nothing operation.
*/
public class SchemaManager {
- private static final Logger log = LoggerFactory.getLogger(SchemaManager.class);
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
final SolrQueryRequest req;
ManagedIndexSchema managedIndexSchema;
Modified: lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/StrField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/StrField.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/StrField.java (original)
+++ lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/StrField.java Mon Dec 21 11:39:57 2015
@@ -79,7 +79,7 @@ public class StrField extends PrimitiveF
@Override
public ValueSource getValueSource(SchemaField field, QParser parser) {
- field.checkFieldCacheSource(parser);
+ field.checkFieldCacheSource();
return new StrFieldSource(field.getName());
}
Modified: lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/TrieDoubleField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/TrieDoubleField.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/TrieDoubleField.java (original)
+++ lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/TrieDoubleField.java Mon Dec 21 11:39:57 2015
@@ -30,7 +30,7 @@ import org.apache.lucene.queries.functio
import org.apache.lucene.queries.function.valuesource.SortedSetFieldSource;
import org.apache.lucene.search.SortedSetSelector;
import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.NumericUtils;
+import org.apache.lucene.util.LegacyNumericUtils;
import org.apache.lucene.util.mutable.MutableValue;
import org.apache.lucene.util.mutable.MutableValueDouble;
@@ -56,6 +56,14 @@ public class TrieDoubleField extends Tri
}
@Override
+ public Object toNativeType(Object val) {
+ if(val==null) return null;
+ if (val instanceof Number) return ((Number) val).doubleValue();
+ if (val instanceof String) return Double.parseDouble((String) val);
+ return super.toNativeType(val);
+ }
+
+ @Override
protected ValueSource getSingleValueSource(SortedSetSelector.Type choice, SchemaField f) {
return new SortedSetFieldSource(f.getName(), choice) {
@@ -75,7 +83,7 @@ public class TrieDoubleField extends Tri
assert !exists(doc) : "zero bytes for doc, but exists is true";
return 0D;
}
- return NumericUtils.sortableLongToDouble(NumericUtils.prefixCodedToLong(bytes));
+ return LegacyNumericUtils.sortableLongToDouble(LegacyNumericUtils.prefixCodedToLong(bytes));
}
@Override
@@ -100,7 +108,7 @@ public class TrieDoubleField extends Tri
//mval.value = mval.exists ? doubleVal(doc) : 0.0D;
BytesRef bytes = view.get(doc);
mval.exists = (0 == bytes.length);
- mval.value = mval.exists ? NumericUtils.sortableLongToDouble(NumericUtils.prefixCodedToLong(bytes)) : 0D;
+ mval.value = mval.exists ? LegacyNumericUtils.sortableLongToDouble(LegacyNumericUtils.prefixCodedToLong(bytes)) : 0D;
}
};
}
Modified: lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/TrieField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/TrieField.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/TrieField.java (original)
+++ lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/TrieField.java Mon Dec 21 11:39:57 2015
@@ -17,6 +17,7 @@
package org.apache.solr.schema;
import java.io.IOException;
+import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@@ -24,12 +25,12 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
-import org.apache.lucene.document.DoubleField;
+import org.apache.lucene.document.LegacyDoubleField;
import org.apache.lucene.document.FieldType;
-import org.apache.lucene.document.FieldType.NumericType;
-import org.apache.lucene.document.FloatField;
-import org.apache.lucene.document.IntField;
-import org.apache.lucene.document.LongField;
+import org.apache.lucene.document.FieldType.LegacyNumericType;
+import org.apache.lucene.document.LegacyFloatField;
+import org.apache.lucene.document.LegacyIntField;
+import org.apache.lucene.document.LegacyLongField;
import org.apache.lucene.document.NumericDocValuesField;
import org.apache.lucene.document.SortedSetDocValuesField;
import org.apache.lucene.index.IndexOptions;
@@ -40,7 +41,7 @@ import org.apache.lucene.queries.functio
import org.apache.lucene.queries.function.valuesource.IntFieldSource;
import org.apache.lucene.queries.function.valuesource.LongFieldSource;
import org.apache.lucene.search.DocValuesRangeQuery;
-import org.apache.lucene.search.NumericRangeQuery;
+import org.apache.lucene.search.LegacyNumericRangeQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.SortedSetSelector;
import org.apache.lucene.search.SortField;
@@ -49,19 +50,21 @@ import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.BytesRefBuilder;
import org.apache.lucene.util.CharsRef;
import org.apache.lucene.util.CharsRefBuilder;
-import org.apache.lucene.util.NumericUtils;
+import org.apache.lucene.util.LegacyNumericUtils;
import org.apache.lucene.util.mutable.MutableValueDate;
import org.apache.lucene.util.mutable.MutableValueLong;
import org.apache.solr.common.SolrException;
import org.apache.solr.response.TextResponseWriter;
import org.apache.solr.search.QParser;
import org.apache.solr.util.DateFormatUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Provides field types to support for Lucene's {@link
- * IntField}, {@link LongField}, {@link FloatField} and
- * {@link DoubleField}.
- * See {@link org.apache.lucene.search.NumericRangeQuery} for more details.
+ * org.apache.lucene.document.LegacyIntField}, {@link org.apache.lucene.document.LegacyLongField}, {@link org.apache.lucene.document.LegacyFloatField} and
+ * {@link org.apache.lucene.document.LegacyDoubleField}.
+ * See {@link org.apache.lucene.search.LegacyNumericRangeQuery} for more details.
* It supports integer, float, long, double and date types.
* <p>
* For each number being added to this field, multiple terms are generated as per the algorithm described in the above
@@ -74,7 +77,7 @@ import org.apache.solr.util.DateFormatUt
* generated, range search will be no faster than any other number field, but sorting will still be possible.
*
*
- * @see org.apache.lucene.search.NumericRangeQuery
+ * @see org.apache.lucene.search.LegacyNumericRangeQuery
* @since solr 1.4
*/
public class TrieField extends PrimitiveFieldType {
@@ -84,6 +87,8 @@ public class TrieField extends Primitive
protected int precisionStep; // normalized
protected TrieTypes type;
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
@Override
protected void init(IndexSchema schema, Map<String, String> args) {
super.init(schema, args);
@@ -228,7 +233,7 @@ public class TrieField extends Primitive
@Override
public ValueSource getValueSource(SchemaField field, QParser qparser) {
- field.checkFieldCacheSource(qparser);
+ field.checkFieldCacheSource();
switch (type) {
case INTEGER:
return new IntFieldSource( field.getName());
@@ -319,17 +324,17 @@ public class TrieField extends Primitive
}
@Override
- public NumericType getNumericType() {
+ public FieldType.LegacyNumericType getNumericType() {
switch (type) {
case INTEGER:
- return NumericType.INT;
+ return FieldType.LegacyNumericType.INT;
case LONG:
case DATE:
- return NumericType.LONG;
+ return FieldType.LegacyNumericType.LONG;
case FLOAT:
- return NumericType.FLOAT;
+ return FieldType.LegacyNumericType.FLOAT;
case DOUBLE:
- return NumericType.DOUBLE;
+ return FieldType.LegacyNumericType.DOUBLE;
default:
throw new AssertionError();
}
@@ -352,23 +357,23 @@ public class TrieField extends Primitive
max == null ? null : (long) Integer.parseInt(max),
minInclusive, maxInclusive);
} else {
- query = NumericRangeQuery.newIntRange(field.getName(), ps,
- min == null ? null : Integer.parseInt(min),
- max == null ? null : Integer.parseInt(max),
- minInclusive, maxInclusive);
+ query = LegacyNumericRangeQuery.newIntRange(field.getName(), ps,
+ min == null ? null : Integer.parseInt(min),
+ max == null ? null : Integer.parseInt(max),
+ minInclusive, maxInclusive);
}
break;
case FLOAT:
if (matchOnly) {
query = DocValuesRangeQuery.newLongRange(field.getName(),
- min == null ? null : (long) NumericUtils.floatToSortableInt(Float.parseFloat(min)),
- max == null ? null : (long) NumericUtils.floatToSortableInt(Float.parseFloat(max)),
+ min == null ? null : (long) LegacyNumericUtils.floatToSortableInt(Float.parseFloat(min)),
+ max == null ? null : (long) LegacyNumericUtils.floatToSortableInt(Float.parseFloat(max)),
minInclusive, maxInclusive);
} else {
- query = NumericRangeQuery.newFloatRange(field.getName(), ps,
- min == null ? null : Float.parseFloat(min),
- max == null ? null : Float.parseFloat(max),
- minInclusive, maxInclusive);
+ query = LegacyNumericRangeQuery.newFloatRange(field.getName(), ps,
+ min == null ? null : Float.parseFloat(min),
+ max == null ? null : Float.parseFloat(max),
+ minInclusive, maxInclusive);
}
break;
case LONG:
@@ -378,23 +383,23 @@ public class TrieField extends Primitive
max == null ? null : Long.parseLong(max),
minInclusive, maxInclusive);
} else {
- query = NumericRangeQuery.newLongRange(field.getName(), ps,
- min == null ? null : Long.parseLong(min),
- max == null ? null : Long.parseLong(max),
- minInclusive, maxInclusive);
+ query = LegacyNumericRangeQuery.newLongRange(field.getName(), ps,
+ min == null ? null : Long.parseLong(min),
+ max == null ? null : Long.parseLong(max),
+ minInclusive, maxInclusive);
}
break;
case DOUBLE:
if (matchOnly) {
query = DocValuesRangeQuery.newLongRange(field.getName(),
- min == null ? null : NumericUtils.doubleToSortableLong(Double.parseDouble(min)),
- max == null ? null : NumericUtils.doubleToSortableLong(Double.parseDouble(max)),
+ min == null ? null : LegacyNumericUtils.doubleToSortableLong(Double.parseDouble(min)),
+ max == null ? null : LegacyNumericUtils.doubleToSortableLong(Double.parseDouble(max)),
minInclusive, maxInclusive);
} else {
- query = NumericRangeQuery.newDoubleRange(field.getName(), ps,
- min == null ? null : Double.parseDouble(min),
- max == null ? null : Double.parseDouble(max),
- minInclusive, maxInclusive);
+ query = LegacyNumericRangeQuery.newDoubleRange(field.getName(), ps,
+ min == null ? null : Double.parseDouble(min),
+ max == null ? null : Double.parseDouble(max),
+ minInclusive, maxInclusive);
}
break;
case DATE:
@@ -404,10 +409,10 @@ public class TrieField extends Primitive
max == null ? null : DateFormatUtil.parseMath(null, max).getTime(),
minInclusive, maxInclusive);
} else {
- query = NumericRangeQuery.newLongRange(field.getName(), ps,
- min == null ? null : DateFormatUtil.parseMath(null, min).getTime(),
- max == null ? null : DateFormatUtil.parseMath(null, max).getTime(),
- minInclusive, maxInclusive);
+ query = LegacyNumericRangeQuery.newLongRange(field.getName(), ps,
+ min == null ? null : DateFormatUtil.parseMath(null, min).getTime(),
+ max == null ? null : DateFormatUtil.parseMath(null, max).getTime(),
+ minInclusive, maxInclusive);
}
break;
default:
@@ -458,19 +463,19 @@ public class TrieField extends Primitive
try {
switch (type) {
case INTEGER:
- NumericUtils.intToPrefixCodedBytes(Integer.parseInt(s), 0, result);
+ LegacyNumericUtils.intToPrefixCodedBytes(Integer.parseInt(s), 0, result);
break;
case FLOAT:
- NumericUtils.intToPrefixCodedBytes(NumericUtils.floatToSortableInt(Float.parseFloat(s)), 0, result);
+ LegacyNumericUtils.intToPrefixCodedBytes(LegacyNumericUtils.floatToSortableInt(Float.parseFloat(s)), 0, result);
break;
case LONG:
- NumericUtils.longToPrefixCodedBytes(Long.parseLong(s), 0, result);
+ LegacyNumericUtils.longToPrefixCodedBytes(Long.parseLong(s), 0, result);
break;
case DOUBLE:
- NumericUtils.longToPrefixCodedBytes(NumericUtils.doubleToSortableLong(Double.parseDouble(s)), 0, result);
+ LegacyNumericUtils.longToPrefixCodedBytes(LegacyNumericUtils.doubleToSortableLong(Double.parseDouble(s)), 0, result);
break;
case DATE:
- NumericUtils.longToPrefixCodedBytes(DateFormatUtil.parseMath(null, s).getTime(), 0, result);
+ LegacyNumericUtils.longToPrefixCodedBytes(DateFormatUtil.parseMath(null, s).getTime(), 0, result);
break;
default:
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + type);
@@ -503,15 +508,15 @@ public class TrieField extends Primitive
final BytesRef indexedForm = new BytesRef(_indexedForm);
switch (type) {
case INTEGER:
- return Integer.toString( NumericUtils.prefixCodedToInt(indexedForm) );
+ return Integer.toString( LegacyNumericUtils.prefixCodedToInt(indexedForm) );
case FLOAT:
- return Float.toString( NumericUtils.sortableIntToFloat(NumericUtils.prefixCodedToInt(indexedForm)) );
+ return Float.toString( LegacyNumericUtils.sortableIntToFloat(LegacyNumericUtils.prefixCodedToInt(indexedForm)) );
case LONG:
- return Long.toString( NumericUtils.prefixCodedToLong(indexedForm) );
+ return Long.toString( LegacyNumericUtils.prefixCodedToLong(indexedForm) );
case DOUBLE:
- return Double.toString( NumericUtils.sortableLongToDouble(NumericUtils.prefixCodedToLong(indexedForm)) );
+ return Double.toString( LegacyNumericUtils.sortableLongToDouble(LegacyNumericUtils.prefixCodedToLong(indexedForm)) );
case DATE:
- return DateFormatUtil.formatExternal(new Date(NumericUtils.prefixCodedToLong(indexedForm)));
+ return DateFormatUtil.formatExternal(new Date(LegacyNumericUtils.prefixCodedToLong(indexedForm)));
default:
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + type);
}
@@ -522,19 +527,19 @@ public class TrieField extends Primitive
final String value;
switch (type) {
case INTEGER:
- value = Integer.toString( NumericUtils.prefixCodedToInt(indexedForm) );
+ value = Integer.toString( LegacyNumericUtils.prefixCodedToInt(indexedForm) );
break;
case FLOAT:
- value = Float.toString( NumericUtils.sortableIntToFloat(NumericUtils.prefixCodedToInt(indexedForm)) );
+ value = Float.toString( LegacyNumericUtils.sortableIntToFloat(LegacyNumericUtils.prefixCodedToInt(indexedForm)) );
break;
case LONG:
- value = Long.toString( NumericUtils.prefixCodedToLong(indexedForm) );
+ value = Long.toString( LegacyNumericUtils.prefixCodedToLong(indexedForm) );
break;
case DOUBLE:
- value = Double.toString( NumericUtils.sortableLongToDouble(NumericUtils.prefixCodedToLong(indexedForm)) );
+ value = Double.toString( LegacyNumericUtils.sortableLongToDouble(LegacyNumericUtils.prefixCodedToLong(indexedForm)) );
break;
case DATE:
- value = DateFormatUtil.formatExternal(new Date(NumericUtils.prefixCodedToLong(indexedForm)));
+ value = DateFormatUtil.formatExternal(new Date(LegacyNumericUtils.prefixCodedToLong(indexedForm)));
break;
default:
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + type);
@@ -549,15 +554,15 @@ public class TrieField extends Primitive
public Object toObject(SchemaField sf, BytesRef term) {
switch (type) {
case INTEGER:
- return NumericUtils.prefixCodedToInt(term);
+ return LegacyNumericUtils.prefixCodedToInt(term);
case FLOAT:
- return NumericUtils.sortableIntToFloat(NumericUtils.prefixCodedToInt(term));
+ return LegacyNumericUtils.sortableIntToFloat(LegacyNumericUtils.prefixCodedToInt(term));
case LONG:
- return NumericUtils.prefixCodedToLong(term);
+ return LegacyNumericUtils.prefixCodedToLong(term);
case DOUBLE:
- return NumericUtils.sortableLongToDouble(NumericUtils.prefixCodedToLong(term));
+ return LegacyNumericUtils.sortableLongToDouble(LegacyNumericUtils.prefixCodedToLong(term));
case DATE:
- return new Date(NumericUtils.prefixCodedToLong(term));
+ return new Date(LegacyNumericUtils.prefixCodedToLong(term));
default:
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + type);
}
@@ -575,17 +580,17 @@ public class TrieField extends Primitive
if (val != null) {
switch (type) {
case INTEGER:
- NumericUtils.intToPrefixCodedBytes(val.intValue(), 0, bytes);
+ LegacyNumericUtils.intToPrefixCodedBytes(val.intValue(), 0, bytes);
break;
case FLOAT:
- NumericUtils.intToPrefixCodedBytes(NumericUtils.floatToSortableInt(val.floatValue()), 0, bytes);
+ LegacyNumericUtils.intToPrefixCodedBytes(LegacyNumericUtils.floatToSortableInt(val.floatValue()), 0, bytes);
break;
case LONG: //fallthrough!
case DATE:
- NumericUtils.longToPrefixCodedBytes(val.longValue(), 0, bytes);
+ LegacyNumericUtils.longToPrefixCodedBytes(val.longValue(), 0, bytes);
break;
case DOUBLE:
- NumericUtils.longToPrefixCodedBytes(NumericUtils.doubleToSortableLong(val.doubleValue()), 0, bytes);
+ LegacyNumericUtils.longToPrefixCodedBytes(LegacyNumericUtils.doubleToSortableLong(val.doubleValue()), 0, bytes);
break;
default:
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + f.name());
@@ -597,28 +602,28 @@ public class TrieField extends Primitive
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Invalid field contents: "+f.name());
switch (type) {
case INTEGER:
- NumericUtils.intToPrefixCodedBytes(toInt(bytesRef.bytes, bytesRef.offset), 0, bytes);
+ LegacyNumericUtils.intToPrefixCodedBytes(toInt(bytesRef.bytes, bytesRef.offset), 0, bytes);
break;
case FLOAT: {
- // WARNING: Code Duplication! Keep in sync with o.a.l.util.NumericUtils!
- // copied from NumericUtils to not convert to/from float two times
- // code in next 2 lines is identical to: int v = NumericUtils.floatToSortableInt(Float.intBitsToFloat(toInt(arr)));
+ // WARNING: Code Duplication! Keep in sync with o.a.l.util.LegacyNumericUtils!
+ // copied from LegacyNumericUtils to not convert to/from float two times
+ // code in next 2 lines is identical to: int v = LegacyNumericUtils.floatToSortableInt(Float.intBitsToFloat(toInt(arr)));
int v = toInt(bytesRef.bytes, bytesRef.offset);
if (v<0) v ^= 0x7fffffff;
- NumericUtils.intToPrefixCodedBytes(v, 0, bytes);
+ LegacyNumericUtils.intToPrefixCodedBytes(v, 0, bytes);
break;
}
case LONG: //fallthrough!
case DATE:
- NumericUtils.longToPrefixCodedBytes(toLong(bytesRef.bytes, bytesRef.offset), 0, bytes);
+ LegacyNumericUtils.longToPrefixCodedBytes(toLong(bytesRef.bytes, bytesRef.offset), 0, bytes);
break;
case DOUBLE: {
- // WARNING: Code Duplication! Keep in sync with o.a.l.util.NumericUtils!
- // copied from NumericUtils to not convert to/from double two times
- // code in next 2 lines is identical to: long v = NumericUtils.doubleToSortableLong(Double.longBitsToDouble(toLong(arr)));
+ // WARNING: Code Duplication! Keep in sync with o.a.l.util.LegacyNumericUtils!
+ // copied from LegacyNumericUtils to not convert to/from double two times
+ // code in next 2 lines is identical to: long v = LegacyNumericUtils.doubleToSortableLong(Double.longBitsToDouble(toLong(arr)));
long v = toLong(bytesRef.bytes, bytesRef.offset);
if (v<0) v ^= 0x7fffffffffffffffL;
- NumericUtils.longToPrefixCodedBytes(v, 0, bytes);
+ LegacyNumericUtils.longToPrefixCodedBytes(v, 0, bytes);
break;
}
default:
@@ -647,19 +652,19 @@ public class TrieField extends Primitive
switch (type) {
case INTEGER:
- ft.setNumericType(NumericType.INT);
+ ft.setNumericType(LegacyNumericType.INT);
break;
case FLOAT:
- ft.setNumericType(NumericType.FLOAT);
+ ft.setNumericType(FieldType.LegacyNumericType.FLOAT);
break;
case LONG:
- ft.setNumericType(NumericType.LONG);
+ ft.setNumericType(FieldType.LegacyNumericType.LONG);
break;
case DOUBLE:
- ft.setNumericType(NumericType.DOUBLE);
+ ft.setNumericType(FieldType.LegacyNumericType.DOUBLE);
break;
case DATE:
- ft.setNumericType(NumericType.LONG);
+ ft.setNumericType(FieldType.LegacyNumericType.LONG);
break;
default:
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + type);
@@ -673,31 +678,31 @@ public class TrieField extends Primitive
int i = (value instanceof Number)
? ((Number)value).intValue()
: Integer.parseInt(value.toString());
- f = new org.apache.lucene.document.IntField(field.getName(), i, ft);
+ f = new LegacyIntField(field.getName(), i, ft);
break;
case FLOAT:
float fl = (value instanceof Number)
? ((Number)value).floatValue()
: Float.parseFloat(value.toString());
- f = new org.apache.lucene.document.FloatField(field.getName(), fl, ft);
+ f = new LegacyFloatField(field.getName(), fl, ft);
break;
case LONG:
long l = (value instanceof Number)
? ((Number)value).longValue()
: Long.parseLong(value.toString());
- f = new org.apache.lucene.document.LongField(field.getName(), l, ft);
+ f = new LegacyLongField(field.getName(), l, ft);
break;
case DOUBLE:
double d = (value instanceof Number)
? ((Number)value).doubleValue()
: Double.parseDouble(value.toString());
- f = new org.apache.lucene.document.DoubleField(field.getName(), d, ft);
+ f = new LegacyDoubleField(field.getName(), d, ft);
break;
case DATE:
Date date = (value instanceof Date)
? ((Date)value)
: DateFormatUtil.parseMath(null, value.toString());
- f = new org.apache.lucene.document.LongField(field.getName(), date.getTime(), ft);
+ f = new LegacyLongField(field.getName(), date.getTime(), ft);
break;
default:
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + type);
@@ -746,8 +751,8 @@ public class TrieField extends Primitive
}
- static final String INT_PREFIX = new String(new char[]{NumericUtils.SHIFT_START_INT});
- static final String LONG_PREFIX = new String(new char[]{NumericUtils.SHIFT_START_LONG});
+ static final String INT_PREFIX = new String(new char[]{LegacyNumericUtils.SHIFT_START_INT});
+ static final String LONG_PREFIX = new String(new char[]{LegacyNumericUtils.SHIFT_START_LONG});
/** expert internal use, subject to change.
* Returns null if no prefix or prefix not needed, or the prefix of the main value of a trie field
Modified: lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/TrieFloatField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/TrieFloatField.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/TrieFloatField.java (original)
+++ lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/TrieFloatField.java Mon Dec 21 11:39:57 2015
@@ -30,7 +30,7 @@ import org.apache.lucene.queries.functio
import org.apache.lucene.queries.function.valuesource.SortedSetFieldSource;
import org.apache.lucene.search.SortedSetSelector;
import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.NumericUtils;
+import org.apache.lucene.util.LegacyNumericUtils;
import org.apache.lucene.util.mutable.MutableValue;
import org.apache.lucene.util.mutable.MutableValueFloat;
@@ -83,7 +83,7 @@ public class TrieFloatField extends Trie
assert !exists(doc) : "zero bytes for doc, but exists is true";
return 0F;
}
- return NumericUtils.sortableIntToFloat(NumericUtils.prefixCodedToInt(bytes));
+ return LegacyNumericUtils.sortableIntToFloat(LegacyNumericUtils.prefixCodedToInt(bytes));
}
@Override
@@ -109,7 +109,7 @@ public class TrieFloatField extends Trie
//
BytesRef bytes = view.get(doc);
mval.exists = (0 == bytes.length);
- mval.value = mval.exists ? NumericUtils.sortableIntToFloat(NumericUtils.prefixCodedToInt(bytes)) : 0F;
+ mval.value = mval.exists ? LegacyNumericUtils.sortableIntToFloat(LegacyNumericUtils.prefixCodedToInt(bytes)) : 0F;
}
};
}
Modified: lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/TrieIntField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/TrieIntField.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/TrieIntField.java (original)
+++ lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/TrieIntField.java Mon Dec 21 11:39:57 2015
@@ -30,7 +30,7 @@ import org.apache.lucene.queries.functio
import org.apache.lucene.queries.function.valuesource.SortedSetFieldSource;
import org.apache.lucene.search.SortedSetSelector;
import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.NumericUtils;
+import org.apache.lucene.util.LegacyNumericUtils;
import org.apache.lucene.util.mutable.MutableValue;
import org.apache.lucene.util.mutable.MutableValueInt;
@@ -82,7 +82,7 @@ public class TrieIntField extends TrieFi
assert !exists(doc) : "zero bytes for doc, but exists is true";
return 0;
}
- return NumericUtils.prefixCodedToInt(bytes);
+ return LegacyNumericUtils.prefixCodedToInt(bytes);
}
@Override
@@ -108,7 +108,7 @@ public class TrieIntField extends TrieFi
//
BytesRef bytes = view.get(doc);
mval.exists = (0 == bytes.length);
- mval.value = mval.exists ? NumericUtils.prefixCodedToInt(bytes) : 0;
+ mval.value = mval.exists ? LegacyNumericUtils.prefixCodedToInt(bytes) : 0;
}
};
}
Modified: lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/TrieLongField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/TrieLongField.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/TrieLongField.java (original)
+++ lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/TrieLongField.java Mon Dec 21 11:39:57 2015
@@ -30,7 +30,7 @@ import org.apache.lucene.queries.functio
import org.apache.lucene.queries.function.valuesource.SortedSetFieldSource;
import org.apache.lucene.search.SortedSetSelector;
import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.NumericUtils;
+import org.apache.lucene.util.LegacyNumericUtils;
import org.apache.lucene.util.mutable.MutableValue;
import org.apache.lucene.util.mutable.MutableValueLong;
@@ -50,6 +50,19 @@ public class TrieLongField extends TrieF
}
@Override
+ public Object toNativeType(Object val) {
+ if(val==null) return null;
+ if (val instanceof Number) return ((Number) val).longValue();
+ try {
+ if (val instanceof String) return Long.parseLong((String) val);
+ } catch (NumberFormatException e) {
+ Double v = Double.parseDouble((String) val);
+ return v.longValue();
+ }
+ return super.toNativeType(val);
+ }
+
+ @Override
protected ValueSource getSingleValueSource(SortedSetSelector.Type choice, SchemaField f) {
return new SortedSetFieldSource(f.getName(), choice) {
@@ -69,7 +82,7 @@ public class TrieLongField extends TrieF
assert !exists(doc) : "zero bytes for doc, but exists is true";
return 0L;
}
- return NumericUtils.prefixCodedToLong(bytes);
+ return LegacyNumericUtils.prefixCodedToLong(bytes);
}
@Override
@@ -95,7 +108,7 @@ public class TrieLongField extends TrieF
//
BytesRef bytes = view.get(doc);
mval.exists = (0 == bytes.length);
- mval.value = mval.exists ? NumericUtils.prefixCodedToLong(bytes) : 0L;
+ mval.value = mval.exists ? LegacyNumericUtils.prefixCodedToLong(bytes) : 0L;
}
};
}
Modified: lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/ZkIndexSchemaReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/ZkIndexSchemaReader.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/ZkIndexSchemaReader.java (original)
+++ lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/schema/ZkIndexSchemaReader.java Mon Dec 21 11:39:57 2015
@@ -30,11 +30,12 @@ import org.slf4j.LoggerFactory;
import org.xml.sax.InputSource;
import java.io.ByteArrayInputStream;
+import java.lang.invoke.MethodHandles;
import java.util.concurrent.TimeUnit;
/** Keeps a ManagedIndexSchema up-to-date when changes are made to the serialized managed schema in ZooKeeper */
public class ZkIndexSchemaReader implements OnReconnect {
- private static final Logger log = LoggerFactory.getLogger(ZkIndexSchemaReader.class);
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private final ManagedIndexSchemaFactory managedIndexSchemaFactory;
private SolrZkClient zkClient;
private String managedSchemaPath;
Modified: lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/search/CacheConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/search/CacheConfig.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/search/CacheConfig.java (original)
+++ lucene/dev/branches/lucene6835/solr/core/src/java/org/apache/solr/search/CacheConfig.java Mon Dec 21 11:39:57 2015
@@ -18,6 +18,8 @@
package org.apache.solr.search;
import javax.xml.xpath.XPathConstants;
+
+import java.lang.invoke.MethodHandles;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -29,6 +31,8 @@ import org.apache.solr.core.MapSerializa
import org.apache.solr.core.SolrConfig;
import org.apache.solr.core.SolrResourceLoader;
import org.apache.solr.util.DOMUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -42,6 +46,8 @@ import static org.apache.solr.common.par
*
*/
public class CacheConfig implements MapSerializable{
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
private String nodeName;
private Class<? extends SolrCache> clazz;
@@ -129,7 +135,7 @@ public class CacheConfig implements MapS
persistence[0] = cache.init(args, persistence[0], regenerator);
return cache;
} catch (Exception e) {
- SolrException.log(SolrCache.log,"Error instantiating cache",e);
+ SolrException.log(log,"Error instantiating cache",e);
// we can carry on without a cache... but should we?
// in some cases (like an OOM) we probably should try to continue.
return null;