Skip to content

Commit

Permalink
Simplify the build (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
romanchyla committed Oct 21, 2016
1 parent 32a3d44 commit 3310002
Show file tree
Hide file tree
Showing 34 changed files with 250 additions and 121 deletions.
1 change: 0 additions & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<classpathentry kind="src" path="contrib/adsabs/src/test"/>
<classpathentry kind="src" path="contrib/examples/src/java"/>
<classpathentry kind="src" path="contrib/examples/src/test"/>
<classpathentry kind="src" path="src/test"/>
<classpathentry kind="con" path="build/solr-download/apache-solr-4.0.0-SVN/org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="build/solrjars-extracted/lucene/lucene-analyzers-common-6.1.0-SNAPSHOT-javadoc.jar"/>
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
MontySolr 0.1, 2011-05-19
-------------------------
- Initial release
- Initial release

MontySolr 1.0, 2016-10-12
-------------------------
- Upgrade to SOLR 6.x
52 changes: 26 additions & 26 deletions common-build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@

<!-- Give user a chance to override without editing this file
(and without typing -D each time it compiles it -->
<property file="${user.home}/lucene.build.properties"/>
<property file="${user.home}/build.properties"/>
<property file="${user.home}/montysolr.build.properties"/>
<property file="${basedir}/build.properties"/>
<property file="${common.dir}/build.properties"/>
<property name="montysolr.dependencies.dir" location="${common.dir}/build/solrjars-extracted" />
Expand All @@ -52,8 +51,8 @@

<property name="name" value="${ant.project.name}"/>
<property name="Name" value="MontySolr"/>
<property name="dev.version" value="4.0-SNAPSHOT"/>
<property name="tests.luceneMatchVersion" value="4.0"/>
<property name="dev.version" value="6.x-SNAPSHOT"/>
<property name="tests.luceneMatchVersion" value="6.0"/>
<property name="version" value="${dev.version}"/>
<property name="spec.version" value="${version}"/>
<property name="year" value="2000-${current.year}"/>
Expand All @@ -62,14 +61,14 @@
<property name="common.classpath.excludes" value="**/*.txt,**/*.template,**/*.sha1" />

<property name="ivy.bootstrap.version" value="2.3.0" />
<property name="ivy.default.configuration" value="*"/>
<property name="ivy.sync" value="true"/>
<property name="ivy.default.configuration" value="*"/>
<property name="ivy.sync" value="true"/>

<property name="junit.jar" value="junit-4.10.jar"/>
<property name="junit-location.jar" value="${common.dir}/lib/${junit.jar}"/>

<path id="junit-path">
<fileset dir="${montysolr.dependencies.dir}/test-framework/lib">
<fileset dir="${montysolr.dependencies.dir}/solr/test-framework/lib">
<include name="junit-*.jar" />
<include name="randomizedtesting-runner-*.jar" />
</fileset>
Expand Down Expand Up @@ -100,14 +99,13 @@
<property name="tests.verbose" value="false"/>
<property name="tests.infostream" value="${tests.verbose}"/>

<condition property="tests.heapsize" value="768M">
<isset property="run.clover"/>
</condition>
<property name="tests.heapsize" value="512M"/>

<condition property="tests.clover.args" value="-XX:ReservedCodeCacheSize=128m">
<isset property="run.clover"/>
</condition>
<condition property="tests.heapsize" value="768M" else="512M">
<isset property="run.clover"/>
</condition>

<condition property="tests.clover.args" value="-XX:ReservedCodeCacheSize=128m -XX:MaxPermSize=192m" else="">
<isset property="run.clover"/>
</condition>
<property name="tests.clover.args" value=""/>

<property name="tests.tempDir" value="${build.dir}/test"/>
Expand Down Expand Up @@ -142,10 +140,10 @@

<property name="javac.deprecation" value="off"/>
<property name="javac.debug" value="on"/>
<property name="javac.source" value="1.7"/>
<property name="javac.target" value="1.7"/>
<property name="javac.source.backwards" value="1.7"/>
<property name="javac.target.backwards" value="1.7"/>
<property name="javac.source" value="1.8"/>
<property name="javac.target" value="1.8"/>
<property name="javac.source.backwards" value="1.8"/>
<property name="javac.target.backwards" value="1.8"/>
<property name="javac.args" value="-Xlint -Xlint:-deprecation -Xlint:-serial"/>
<property name="bootclasspath" value=""/>
<property name="javadoc.link" value="http://download.oracle.com/javase/6/docs/api/"/>
Expand Down Expand Up @@ -249,13 +247,15 @@
</fileset>
<!-- lucene/solr jars -->
<fileset dir="${common.dir}/build">
<include name = "*solrjars-extracted/lucene-test*.jar" />
<include name = "*solrjars-extracted/apache-solr-test*.jar" />
<include name = "*solrjars-extracted/lucene/lucene-test*.jar" />
<include name = "*solrjars-extracted/solr/solr-test*.jar" />
</fileset>
<fileset dir="${common.dir}/build">
<include name = "*solrjars-extracted/*.jar" />
<include name = "*solrjars-extracted/solrj-lib/*.jar" />
<include name = "*solrjars-extracted/example-lib/ext/*.jar" />
<include name = "*solrjars-extracted/lucene/*.jar" />
<include name = "*solrjars-extracted/solr/*.jar" />
<include name = "*solrjars-extracted/solr/solrj-lib/*.jar" />
<include name = "*solrjars-extracted/jetty/ext/*.jar" />
</fileset>
<!-- montysolr lib jars -->
<fileset dir="${common.dir}/lib">
Expand All @@ -277,7 +277,7 @@
<!-- these classes cannot be found in solr/lucene jars, they are needed
for proper compilation of unittests -->
<fileset dir="${common.dir}/build">
<include name="solrjars-extracted/test-framework/**.jar" />
<include name="solrjars-extracted/solr/test-framework/**.jar" />
</fileset>

<path refid="common.classpath"/>
Expand Down Expand Up @@ -839,8 +839,8 @@
<target name="install-junit4-taskdef" depends="ivy-configure">
<!-- JUnit4 taskdef. -->
<ivy:resolve file="${common.dir}/build/solr-download/apache-solr-${solr.version}/lucene/test-framework/ivy.xml" type="jar" log="quiet" />
<ivy:cachepath file="${common.dir}/build/solr-download/apache-solr-${solr.version}/lucene/test-framework/ivy.xml" conf="junit4-stdalone" type="jar" transitive="false" pathid="path.junit4" />

<ivy:cachepath organisation="com.carrotsearch.randomizedtesting" module="junit4-ant" revision="${/com.carrotsearch.randomizedtesting/junit4-ant}"
type="jar" inline="true" log="download-only" pathid="path.junit4" />
<taskdef uri="antlib:com.carrotsearch.junit4">
<classpath refid="path.junit4" />
</taskdef>
Expand Down
Binary file not shown.
11 changes: 7 additions & 4 deletions contrib/adsabs/ivy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@
under the License.
-->
<ivy-module version="2.0">
<info organisation="montysolr" module="adsabs"/>
<configurations>
<conf name="default" description="jetty jars"/>
<conf name="servlet" description="servlet-api jar"/>
<info organisation="org.apache.solr" module="adsabs"/>
<configurations defaultconfmapping="compile->master;test->master">
<conf name="compile" transitive="false"/> <!-- keep unused 'compile' configuration to allow build to succeed -->
<conf name="test" transitive="false"/>
<conf name="default" description="jetty jars"/>
<conf name="servlet" description="servlet-api jar"/>
</configurations>

<dependencies>
<dependency org="org.antlr" name="antlr-runtime" rev="3.4"/>
<dependency org="org.antlr" name="antlr" rev="3.4" transitive="false"/>
<dependency org="org.python" name="jython-standalone" rev="2.7-b1" transitive="false"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ public class BatchHandler extends RequestHandlerBase {
private long sleepTime;
private Map<String, BatchProvider> providers;
private Thread thread;
private File tmpDir;
private File tmpDir = null;
private String defaultWorkdir = null;


public BatchHandler() {
Expand Down Expand Up @@ -123,46 +124,48 @@ public void init(NamedList args) {
if (defs.get("sleepTime") != null) {
sleepTime = Long.parseLong((String) defs.get("sleepTime"));
}

defaultWorkdir = defs.get("workdir") != null ? (String) defs.get("workdir") : null;
}

// we cannot get the solr indexdir at this point, so let's hope for best :)
String startDir = System.getProperty("user.dir");

if (defs.get("workdir") != null) {
File wdir = new File((String) defs.get("workdir"));
if (wdir.isAbsolute() && wdir.canWrite()) {
tmpDir = wdir;
}
else if (!wdir.isAbsolute() && wdir.canWrite()) {
log.info("Batch handler will write into: {}", wdir.getAbsolutePath());
tmpDir = wdir;
}
else if (!wdir.exists()) {
if (!wdir.isAbsolute()) {
wdir = new File(startDir + "/" + wdir.toString());
}
// sadly, available only for java 7
//Files.createDirectory(wdir.toPath(),
// PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwxr-----")));

private void checkHomeDir() {
if (tmpDir != null)
return;

// we cannot get the solr indexdir at this point, so let's hope for best :)
String startDir = System.getProperty("user.dir");

if (defaultWorkdir != null) {
File wdir = new File(defaultWorkdir);
if (wdir.isAbsolute() && wdir.canWrite()) {
tmpDir = wdir;
}
else if (!wdir.isAbsolute() && wdir.exists() && wdir.canWrite()) {
log.info("Batch handler will write into: {}", wdir.getAbsolutePath());
tmpDir = wdir;
}
else if (!wdir.exists()) {
if (!wdir.isAbsolute()) {
wdir = new File(startDir + "/" + wdir.toString());
}
wdir.mkdir();
tmpDir = wdir;
}
else {
throw new RuntimeException("The folder is not readable: " + wdir.toString());
}
}
else {
//tmpDir = Files.createTempDirectory("montysolr-batch-handler",
// PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwxr-----")));
tmpDir = wdir;
}
else {
throw new RuntimeException("The folder is not readable: " + wdir.toString());
}
}
else {
createTempDir("montysolr-batch-handler");
}
}

}



public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp)
throws IOException, InterruptedException {

checkHomeDir();

SolrParams params = req.getParams();
String command = params.get("command","info");

Expand Down
134 changes: 134 additions & 0 deletions contrib/adsabs/src/java/org/apache/solr/schema/AqpStrField.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
package org.apache.solr.schema;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.lucene.analysis.core.LowerCaseFilterFactory;
import org.apache.lucene.analysis.miscellaneous.ASCIIFoldingFilterFactory;
import org.apache.lucene.analysis.miscellaneous.RemoveDuplicatesTokenFilterFactory;
import org.apache.lucene.analysis.miscellaneous.TrimFilterFactory;
import org.apache.lucene.analysis.pattern.PatternReplaceFilterFactory;
import org.apache.lucene.analysis.util.TokenFilterFactory;
import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.IndexableField;
import org.apache.solr.analysis.DiagnoseFilterFactory;
import org.apache.solr.common.SolrException;

/**
* StrField with configurable tokenizer chain.
*
* @author rchyla
*
*/
public class AqpStrField extends StrField {

public AqpStrField() {
Map<String, String> replArgs = new HashMap<String, String>();
replArgs.put("pattern", "(doi:|arxiv:|\\-)");

List<TokenFilterFactory> filters = new ArrayList<TokenFilterFactory>();
filters.add(new DiagnoseFilterFactory(new HashMap<String, String>()));
filters.add(new RemoveDuplicatesTokenFilterFactory(new HashMap<String, String>()));
filters.add(new TrimFilterFactory(new HashMap<String, String>()));
filters.add(new PatternReplaceFilterFactory(replArgs));
filters.add(new LowerCaseFilterFactory(new HashMap<String, String>()));
filters.add(new ASCIIFoldingFilterFactory(new HashMap<String, String>()));

TokenFilterFactory[] filterArr = new TokenFilterFactory[filters.size()];
filters.toArray(filterArr);

}


@Override
public boolean isTokenized() {
return true;
}

protected boolean supportsAnalyzers() {
return true;
}
/**
@Override
public Analyzer getIndexAnalyzer() {
return indexAnalyzer;
}
@Override
public Analyzer getQueryAnalyzer() {
return queryAnalyzer;
}
@Override
public String toInternal(String val) {
// - used in delete when a Term needs to be created.
// - used by the default getTokenizer() and createField()
return val;
}
**/

@Override
public IndexableField createField(SchemaField field, Object value, float boost) {
if (!field.indexed() && !field.stored()) {
return null;
}

String val;
try {
val = toInternal(value.toString());
} catch (RuntimeException e) {
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "Error while creating field '" + field + "' from value '" + value + "'", e);
}
if (val==null) return null;

org.apache.lucene.document.FieldType newType = new org.apache.lucene.document.FieldType();
newType.setTokenized(true); // force it
newType.setStored(field.stored());
newType.setOmitNorms(field.omitNorms());
newType.setIndexOptions(field.indexed() ? getIndexOptions(field, val) : IndexOptions.NONE);
newType.setStoreTermVectors(field.storeTermVector());
newType.setStoreTermVectorOffsets(field.storeTermOffsets());
newType.setStoreTermVectorPositions(field.storeTermPositions());
newType.setStoreTermVectorPayloads(field.storeTermPayloads());

return createField(field.getName(), val, newType, boost);
}

/**
@Override
public List<IndexableField> createFields(SchemaField field, Object value, float boost) {
//if (!field.multiValued())
// return super.createFields(field, value, boost);
List<IndexableField> output = new ArrayList<IndexableField>();
for (String v: value.toString().split("\\s")) {
IndexableField fval = createField(field, v, boost);
if (field.hasDocValues()) {
IndexableField docval;
final BytesRef bytes = new BytesRef(v.toString());
if (field.multiValued()) {
docval = new SortedSetDocValuesField(field.getName(), bytes);
} else {
docval = new SortedDocValuesField(field.getName(), bytes);
}
// Only create a list of we have 2 values...
if (fval != null) {
List<IndexableField> fields = new ArrayList<>(2);
fields.add(fval);
fields.add(docval);
return fields;
}
fval = docval;
}
output.add(fval);
}
return output;
}
**/
}

Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ static String determineMontySourceHome() {
public static String getMontySolrHome() {
File base = new File(System.getProperty("user.dir"));
// File base = getFile("solr/conf").getAbsoluteFile();
while (!new File(base, "contrib/contrib-build.xml").exists()) {
while (!new File(base, "contrib/montysolr.md").exists()) {
base = base.getParentFile();
}
return base.getAbsolutePath().replace('\\', '/');
Expand Down
Loading

0 comments on commit 3310002

Please sign in to comment.