Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First draft of LUCENE-5317 #82

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dev-tools/idea/.idea/ant.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dev-tools/idea/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 39 additions & 30 deletions dev-tools/idea/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions dev-tools/idea/lucene/concordance/concordance.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/../../idea-build/lucene/concordance/classes/java" />
<output-test url="file://$MODULE_DIR$/../../idea-build/lucene/concordance/classes/test" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="JUnit" level="project" />
<orderEntry type="module" scope="TEST" module-name="lucene-test-framework" />
<orderEntry type="module" module-name="lucene-core" />
<orderEntry type="module" module-name="queries" />
</component>
</module>


69 changes: 69 additions & 0 deletions dev-tools/maven/lucene/concordance/pom.xml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<!--
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.
-->
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-parent</artifactId>
<version>@version@</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-concordance</artifactId>
<packaging>jar</packaging>
<name>Lucene Concordance</name>
<description>Lucene Concordance Module</description>
<properties>
<module-directory>lucene/concordance</module-directory>
<relative-top-level>../../..</relative-top-level>
<module-path>${relative-top-level}/${module-directory}</module-path>
</properties>
<scm>
<connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
<developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
<url>${vc-browse-base-url}/${module-directory}</url>
</scm>
<dependencies>
<dependency>
<!-- lucene-test-framework dependency must be declared before lucene-core -->
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-test-framework</artifactId>
<scope>test</scope>
</dependency>
@lucene-concordance.internal.dependencies@
@lucene-concordance.external.dependencies@
@lucene-concordance.internal.test.dependencies@
@lucene-concordance.external.test.dependencies@
</dependencies>
<build>
<sourceDirectory>${module-path}/src/java</sourceDirectory>
<testSourceDirectory>${module-path}/src/test</testSourceDirectory>
<testResources>
<testResource>
<directory>${project.build.testSourceDirectory}</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
</testResources>
</build>
</project>

1 change: 1 addition & 0 deletions dev-tools/maven/lucene/pom.xml.template
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<module>analysis</module>
<module>benchmark</module>
<module>classification</module>
<module>concordance</module>
<module>demo</module>
<module>expressions</module>
<module>facet</module>
Expand Down
1 change: 1 addition & 0 deletions lucene/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
<check-missing-javadocs dir="build/docs/spatial" level="method"/>
<!-- spatial-extras: problems -->
<check-missing-javadocs dir="build/docs/suggest" level="method"/>
<check-missing-javadocs dir="build/docs/concordance" level="method"/>
<!-- test-framework: problems -->

<!-- too much to fix core/ for now, but enforce full javadocs for key packages -->
Expand Down
40 changes: 40 additions & 0 deletions lucene/concordance/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!--
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.
-->

<project name="concordance" default="default">

<description>
Executes concordance search
</description>

<import file="../module-build.xml"/>

<path id="classpath">
<pathelement path="${queries.jar}"/>
<path refid="base.classpath"/>
</path>

<target name="compile-core" depends="jar-queries,common.compile-core"/>
<target name="javadocs" depends="javadocs-queries,compile-core,check-javadocs-uptodate"
unless="javadocs-uptodate-${name}">
<invoke-module-javadoc>
<links>
<link href="../queries"/>
</links>
</invoke-module-javadoc>
</target>
</project>
21 changes: 21 additions & 0 deletions lucene/concordance/ivy.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!--
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.
-->
<ivy-module version="2.0">
<info organisation="org.apache.lucene" module="concordance"/>
</ivy-module>
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* 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.lucene.concordance.charoffsets;

import java.util.ArrayList;
import java.util.List;

import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
import org.apache.lucene.analysis.tokenattributes.OffsetAttributeImpl;
import org.apache.lucene.document.Document;



/**
* Simple class to store a document id (atomic and unique), a StoredDocument,
* and the offsets for a SpanQuery hit
*/
public class DocTokenOffsets {
private int atomicDocId = -1;
private long uniqueId = -1;
private Document document = null;
private List<OffsetAttribute> offsets = new ArrayList<>();

public void addOffset(int start, int end) {
OffsetAttributeImpl offset = new OffsetAttributeImpl();
offset.setOffset(start, end);
offsets.add(offset);
}

public void reset(int base, int atomicDocId, Document d) {
this.atomicDocId = atomicDocId;
this.uniqueId = base + atomicDocId;
setDocument(d);
offsets.clear();
}

public List<OffsetAttribute> getOffsets() {
return offsets;
}

public Document getDocument() {
return document;
}

public void setDocument(Document d) {
this.document = d;
}

/*
* required by DocTokenOffsetsIterator
*/
protected int getAtomicDocId() {
return atomicDocId;
}

public long getUniqueDocId() {
return uniqueId;
}

public DocTokenOffsets deepishCopy() {
DocTokenOffsets copy = new DocTokenOffsets();
copy.atomicDocId = atomicDocId;
copy.uniqueId = uniqueId;
copy.document = document;
List<OffsetAttribute> copyOffsets = new ArrayList<OffsetAttribute>();
copyOffsets.addAll(offsets);
copy.offsets = copyOffsets;
return copy;
}

public boolean isEmpty() {
if (atomicDocId < 0)
return true;
return false;
}

public void pseudoEmpty() {
atomicDocId = -1;
}
}
Loading