You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ec...@apache.org on 2012/01/06 23:02:13 UTC
svn commit: r1228459 [1/13] - in /incubator/accumulo/branches/1.4: ./
contrib/accumulo_sample/
src/examples/src/main/java/org/apache/accumulo/examples/wikisearch/
src/trace/ src/wikisearch/ src/wikisearch/ingest/
src/wikisearch/ingest/bin/ src/wikisear...
Author: ecn
Date: Fri Jan 6 22:02:09 2012
New Revision: 1228459
URL: http://svn.apache.org/viewvc?rev=1228459&view=rev
Log:
ACCUMULO-285 move sample up as a sub-module
Added:
incubator/accumulo/branches/1.4/src/examples/src/main/java/org/apache/accumulo/examples/wikisearch/
incubator/accumulo/branches/1.4/src/wikisearch/ (with props)
incubator/accumulo/branches/1.4/src/wikisearch/README (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/ (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/bin/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/bin/ingest.sh (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/conf/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/conf/wikipedia.xml.example (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/lib/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/pom.xml (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/assembly/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/assembly/dist.xml (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/aggregator/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/aggregator/GlobalIndexUidAggregator.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/aggregator/TextIndexAggregator.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/ArticleExtractor.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/WikipediaConfiguration.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/WikipediaIngester.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/WikipediaInputFormat.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/WikipediaMapper.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/iterator/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/iterator/TotalAggregatingIterator.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/normalizer/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/normalizer/LcNoDiacriticsNormalizer.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/normalizer/NoOpNormalizer.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/normalizer/Normalizer.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/normalizer/NumberNormalizer.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/protobuf/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/protobuf/TermWeight.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/protobuf/Uid.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/reader/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/reader/AggregatingRecordReader.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/reader/LfLineReader.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/reader/LongLineRecordReader.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/util/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/util/TextUtil.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/protobuf/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/protobuf/TermWeight.proto
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/protobuf/Uid.proto
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/protobuf/compile_protos.sh (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/test/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/test/java/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/test/java/org/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/test/java/org/apache/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/test/java/org/apache/accumulo/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/test/java/org/apache/accumulo/wikisearch/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/test/java/org/apache/accumulo/wikisearch/aggregator/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/test/java/org/apache/accumulo/wikisearch/aggregator/GlobalIndexUidAggregatorTest.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/test/java/org/apache/accumulo/wikisearch/aggregator/TextIndexAggregatorTest.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/test/java/org/apache/accumulo/wikisearch/ingest/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/test/java/org/apache/accumulo/wikisearch/ingest/StandaloneStatusReporter.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/test/java/org/apache/accumulo/wikisearch/ingest/WikipediaMapperTest.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/test/java/org/apache/accumulo/wikisearch/normalizer/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/test/java/org/apache/accumulo/wikisearch/normalizer/testNumberNormalizer.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/test/java/org/apache/accumulo/wikisearch/reader/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/test/java/org/apache/accumulo/wikisearch/reader/AggregatingRecordReaderTest.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/test/resources/
incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/test/resources/enwiki-20110901-001.xml (with props)
incubator/accumulo/branches/1.4/src/wikisearch/pom.xml (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/ (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query-war/ (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query-war/pom.xml (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query-war/src/
incubator/accumulo/branches/1.4/src/wikisearch/query-war/src/main/
incubator/accumulo/branches/1.4/src/wikisearch/query-war/src/main/webapp/
incubator/accumulo/branches/1.4/src/wikisearch/query-war/src/main/webapp/WEB-INF/
incubator/accumulo/branches/1.4/src/wikisearch/query-war/src/main/webapp/WEB-INF/jboss-web.xml (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query-war/src/main/webapp/WEB-INF/web.xml (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query-war/src/main/webapp/style.xsl (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query-war/src/main/webapp/ui.jsp (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query-war/src/test/
incubator/accumulo/branches/1.4/src/wikisearch/query-war/src/test/resources/
incubator/accumulo/branches/1.4/src/wikisearch/query-war/src/test/resources/test.xml (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query-war/target/
incubator/accumulo/branches/1.4/src/wikisearch/query-war/target/test-classes/
incubator/accumulo/branches/1.4/src/wikisearch/query-war/target/test-classes/test.xml (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/lib/
incubator/accumulo/branches/1.4/src/wikisearch/query/pom.xml (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/
incubator/accumulo/branches/1.4/src/wikisearch/query/src/assembly/
incubator/accumulo/branches/1.4/src/wikisearch/query/src/assembly/dist.xml (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/function/
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/function/QueryFunctions.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/iterator/
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/iterator/AbstractEvaluatingIterator.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/iterator/AndIterator.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/iterator/BooleanLogicIterator.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/iterator/BooleanLogicTreeNode.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/iterator/DefaultIteratorEnvironment.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/iterator/EvaluatingIterator.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/iterator/FieldIndexIterator.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/iterator/OptimizedQueryIterator.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/iterator/OrIterator.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/iterator/ReadAheadIterator.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/iterator/UniqFieldNameValueIterator.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/jexl/
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/jexl/Arithmetic.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/logic/
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/logic/AbstractQueryLogic.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/logic/ContentLogic.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/logic/QueryLogic.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/parser/
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/parser/EventFields.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/parser/FieldIndexQueryReWriter.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/parser/JexlOperatorConstants.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/parser/QueryEvaluator.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/parser/QueryParser.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/parser/RangeCalculator.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/parser/TreeBuilder.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/parser/TreeNode.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/query/
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/query/IQuery.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/query/Query.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/sample/
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/sample/Document.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/sample/Field.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/sample/Results.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/util/
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/util/BaseKeyParser.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/util/FieldIndexKeyParser.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/java/org/apache/accumulo/wikisearch/util/KeyParser.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/resources/
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/resources/META-INF/
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/resources/META-INF/MANIFEST.MF (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/main/resources/META-INF/ejb-jar.xml (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/test/
incubator/accumulo/branches/1.4/src/wikisearch/query/src/test/java/
incubator/accumulo/branches/1.4/src/wikisearch/query/src/test/java/org/
incubator/accumulo/branches/1.4/src/wikisearch/query/src/test/java/org/apache/
incubator/accumulo/branches/1.4/src/wikisearch/query/src/test/java/org/apache/accumulo/
incubator/accumulo/branches/1.4/src/wikisearch/query/src/test/java/org/apache/accumulo/wikisearch/
incubator/accumulo/branches/1.4/src/wikisearch/query/src/test/java/org/apache/accumulo/wikisearch/logic/
incubator/accumulo/branches/1.4/src/wikisearch/query/src/test/java/org/apache/accumulo/wikisearch/logic/StandaloneStatusReporter.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/test/java/org/apache/accumulo/wikisearch/logic/TestQueryLogic.java (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/src/test/resources/
incubator/accumulo/branches/1.4/src/wikisearch/query/src/test/resources/enwiki-20110901-001.xml (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/target/
incubator/accumulo/branches/1.4/src/wikisearch/query/target/classes/
incubator/accumulo/branches/1.4/src/wikisearch/query/target/classes/META-INF/
incubator/accumulo/branches/1.4/src/wikisearch/query/target/classes/META-INF/MANIFEST.MF (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/target/classes/META-INF/ejb-jar.xml (with props)
incubator/accumulo/branches/1.4/src/wikisearch/query/target/test-classes/
incubator/accumulo/branches/1.4/src/wikisearch/query/target/test-classes/enwiki-20110901-001.xml (with props)
Removed:
incubator/accumulo/branches/1.4/contrib/accumulo_sample/
Modified:
incubator/accumulo/branches/1.4/pom.xml
incubator/accumulo/branches/1.4/src/trace/thrift.sh
Modified: incubator/accumulo/branches/1.4/pom.xml
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/pom.xml?rev=1228459&r1=1228458&r2=1228459&view=diff
==============================================================================
--- incubator/accumulo/branches/1.4/pom.xml (original)
+++ incubator/accumulo/branches/1.4/pom.xml Fri Jan 6 22:02:09 2012
@@ -14,8 +14,7 @@
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 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">
+--><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">
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -37,6 +36,7 @@
<module>src/server</module>
<module>src/start</module>
<module>src/examples</module>
+ <module>src/wikisearch</module>
</modules>
<build>
@@ -50,7 +50,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
- <version>1.0-beta-1</version>
+ <version>1.0.1</version>
<executions>
<execution>
<id>enforce-mvn</id>
@@ -140,7 +140,7 @@
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
- <version>2.4</version>
+ <version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
@@ -164,7 +164,7 @@
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
- <version>2.5</version>
+ <version>2.8</version>
<configuration>
<encoding>UTF-8</encoding>
<quiet>true</quiet>
@@ -176,7 +176,7 @@
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
- <version>2.0.4</version>
+ <version>2.1.2</version>
<configuration>
<outputDirectory>../../lib</outputDirectory>
</configuration>
@@ -283,7 +283,7 @@
</mapping>
<mapping>
<directory>/opt/accumulo/accumulo-${project.version}/lib</directory>
- <dependency />
+ <dependency/>
<sources>
<source>
<location>lib</location>
@@ -334,7 +334,7 @@
</goals>
</pluginExecutionFilter>
<action>
- <ignore />
+ <ignore/>
</action>
</pluginExecution>
<pluginExecution>
@@ -347,7 +347,7 @@
</goals>
</pluginExecutionFilter>
<action>
- <ignore />
+ <ignore/>
</action>
</pluginExecution>
</pluginExecutions>
Modified: incubator/accumulo/branches/1.4/src/trace/thrift.sh
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/trace/thrift.sh?rev=1228459&r1=1228458&r2=1228459&view=diff
==============================================================================
--- incubator/accumulo/branches/1.4/src/trace/thrift.sh (original)
+++ incubator/accumulo/branches/1.4/src/trace/thrift.sh Fri Jan 6 22:02:09 2012
@@ -18,6 +18,8 @@
thrift0.6 -o target -gen java src/main/thrift/cloudtrace.thrift
+find target/gen-java -name '*.java' -print | xargs sed -i.orig -e 's/public class /@SuppressWarnings("all") public class /'
+
mkdir -p src/main/java/cloudtrace/thrift
for f in target/gen-java/cloudtrace/thrift/*
do
Propchange: incubator/accumulo/branches/1.4/src/wikisearch/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Jan 6 22:02:09 2012
@@ -0,0 +1 @@
+.project
Added: incubator/accumulo/branches/1.4/src/wikisearch/README
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/wikisearch/README?rev=1228459&view=auto
==============================================================================
--- incubator/accumulo/branches/1.4/src/wikisearch/README (added)
+++ incubator/accumulo/branches/1.4/src/wikisearch/README Fri Jan 6 22:02:09 2012
@@ -0,0 +1,65 @@
+
+ This project contains a sample application for ingesting and querying wikipedia data.
+
+
+ Ingest
+ ------
+
+ Prerequisites
+ -------------
+ 1. ACCUMULO, Hadoop, and ZooKeeper must be installed and running
+ 2. ACCUMULO_HOME and ZOOKEEPER_HOME are defined in the environment
+ 3. One or more wikipedia dump files (http://dumps.wikimedia.org/backup-index.html) placed in an HDFS directory.
+ You will want to grab the files with the link name of pages-articles.xml.bz2
+
+
+ INSTRUCTIONS
+ ------------
+ 1. Build the ingest assembly by running 'mvn assembly:assembly' in the ingest directory.
+ 2. Untar the distribution in some directory.
+ 3. Modify the conf/wikipedia.xml file to specify ACCUMULO information.
+ 4. Copy the lib/accumulo-sample*.jar and lib/protobuf*.jar to $ACCUMULO_HOME/lib/ext
+ 5. Then run bin/ingest.sh with one argument (the name of the directory in HDFS where the wikipedia XML files reside)
+ and this will kick off a MapReduce job to ingest the data into ACCUMULO.
+
+ Query
+ -----
+
+ Prerequisites
+ -------------
+ 1. The query software was tested using JBoss AS 6. Install this unless you feel like messing with the installation.
+
+ NOTE: Ran into a bug (https://issues.jboss.org/browse/RESTEASY-531) that did not allow an EJB3.1 war file. I was able
+ to workaround this by separating the RESTEasy servlet from the EJBs by creating an EJB jar and a WAR file.
+
+ INSTRUCTIONS
+ -------------
+ 1. Modify the query/src/main/resources/META-INF/ejb-jar.xml file with the same information that you put into the wikipedia.xml
+ file from the Ingest step above.
+ 2. Build the query distribution by running 'mvn assembly:assembly' in the query directory.
+ 3. Untar the resulting file from the $JBOSS_HOME/server/default directory. This will place the dependent jars in the lib
+ directory and the EJB jar into the deploy directory.
+ 4. Next, run 'mvn clean package' in the query-war directory and copy the war to $JBOSS_HOME/server/default/deploy.
+ 5. Start JBoss ($JBOSS_HOME/bin/run.sh)
+ 6. Login to Accumulo and give the user permissions for the wikis that you loaded, for example:
+ setauths -u <user> -s all,enwiki,eswiki,frwiki,fawiki
+ 7. Copy the following jars to the $ACCUMULO_HOME/lib/ext directory from the $JBOSS_HOME/server/default/lib directory:
+
+ commons-lang*.jar
+ kryo*.jar
+ minlog*.jar
+ reflectasm*.jar
+ asm*.jar
+ commons-jexl*.jar
+ google-collections*.jar
+
+ 8. Copy the $JBOSS_HOME/server/default/deploy/accumulo-sample-query*.jar to $ACCUMULO_HOME/lib/ext.
+
+
+ 9. At this point you should be able to open a browser and view the page: http://localhost:8080/accumulo-sample/ui/ui.jsp.
+ You can issue the queries using this user interface or via the following REST urls: <host>/accumulo-sample/rest/Query/xml,
+ <host>/accumulo-sample/rest/Query/html, <host>/accumulo-sample/rest/Query/yaml, or <host>/accumulo-sample/rest/Query/json.
+ There are two parameters to the REST service, query and auths. The query parameter is the same string that you would type
+ into the search box at ui.jsp, and the auths parameter is a comma-separated list of wikis that you want to search (i.e.
+ enwiki,frwiki,dewiki, etc. Or you can use all)
+
Propchange: incubator/accumulo/branches/1.4/src/wikisearch/README
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/accumulo/branches/1.4/src/wikisearch/ingest/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Jan 6 22:02:09 2012
@@ -0,0 +1,5 @@
+target
+
+.project
+
+.classpath
Added: incubator/accumulo/branches/1.4/src/wikisearch/ingest/bin/ingest.sh
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/wikisearch/ingest/bin/ingest.sh?rev=1228459&view=auto
==============================================================================
--- incubator/accumulo/branches/1.4/src/wikisearch/ingest/bin/ingest.sh (added)
+++ incubator/accumulo/branches/1.4/src/wikisearch/ingest/bin/ingest.sh Fri Jan 6 22:02:09 2012
@@ -0,0 +1,74 @@
+#!/bin/bash
+
+# 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.
+
+
+
+THIS_SCRIPT="$0"
+SCRIPT_DIR="${THIS_SCRIPT%/*}"
+SCRIPT_DIR=`cd $SCRIPT_DIR ; pwd`
+echo $SCRIPT_DIR
+
+ACCUMULO_HOME=${ACCUMULO_HOME}
+ZOOKEEPER_HOME=${ZOOKEEPER_HOME}
+
+#
+# Check ZOOKEEPER_HOME
+#
+if [[ -z $ZOOKEEPER_HOME ]]; then
+ echo "You must set ZOOKEEPER_HOME environment variable"
+ exit -1;
+else
+ for f in $ZOOKEEPER_HOME/zookeeper-*.jar; do
+ CLASSPATH=$f
+ break
+ done
+fi
+
+#
+# Check ACCUMULO_HOME
+#
+if [[ -z $ACCUMULO_HOME ]]; then
+ echo "You must set ACCUMULO_HOME environment variable"
+ exit -1;
+else
+ for f in $ACCUMULO_HOME/lib/*.jar; do
+ CLASSPATH=${CLASSPATH}:$f
+ done
+fi
+
+#
+# Add our jars
+#
+for f in $SCRIPT_DIR/../lib/*.jar; do
+ CLASSPATH=${CLASSPATH}:$f
+done
+
+#
+# Transform the classpath into a comma-separated list also
+#
+LIBJARS=`echo $CLASSPATH | sed 's/:/,/g'`
+
+
+#
+# Map/Reduce job
+#
+JAR=$SCRIPT_DIR/../lib/accumulo-sample-ingest-1.5.0-incubating-SNAPSHOT.jar
+CONF=$SCRIPT_DIR/../conf/wikipedia.xml
+HDFS_DATA_DIR=$1
+export HADOOP_CLASSPATH=$CLASSPATH
+echo "hadoop jar $JAR ingest.WikipediaIngester -libjars $LIBJARS -conf $CONF -Dwikipedia.input=${HDFS_DATA_DIR}"
+hadoop jar $JAR ingest.WikipediaIngester -libjars $LIBJARS -conf $CONF -Dwikipedia.input=${HDFS_DATA_DIR}
Propchange: incubator/accumulo/branches/1.4/src/wikisearch/ingest/bin/ingest.sh
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/accumulo/branches/1.4/src/wikisearch/ingest/bin/ingest.sh
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/accumulo/branches/1.4/src/wikisearch/ingest/conf/wikipedia.xml.example
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/wikisearch/ingest/conf/wikipedia.xml.example?rev=1228459&view=auto
==============================================================================
--- incubator/accumulo/branches/1.4/src/wikisearch/ingest/conf/wikipedia.xml.example (added)
+++ incubator/accumulo/branches/1.4/src/wikisearch/ingest/conf/wikipedia.xml.example Fri Jan 6 22:02:09 2012
@@ -0,0 +1,43 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<configuration>
+ <property>
+ <name>wikipedia.accumulo.zookeepers</name>
+ <value><!--zookeeper servers --></value>
+ </property>
+ <property>
+ <name>wikipedia.accumulo.instance_name</name>
+ <value><!--instance name --></value>
+ </property>
+ <property>
+ <name>wikipedia.accumulo.user</name>
+ <value><!--user name --></value>
+ </property>
+ <property>
+ <name>wikipedia.accumulo.password</name>
+ <value><!-- password --></value>
+ </property>
+ <property>
+ <name>wikipedia.accumulo.table</name>
+ <value><!--table name --></value>
+ </property>
+ <property>
+ <name>wikipedia.ingest.partitions</name>
+ <value><!--number of partitions --></value>
+ </property>
+</configuration>
Propchange: incubator/accumulo/branches/1.4/src/wikisearch/ingest/conf/wikipedia.xml.example
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/accumulo/branches/1.4/src/wikisearch/ingest/pom.xml
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/wikisearch/ingest/pom.xml?rev=1228459&view=auto
==============================================================================
--- incubator/accumulo/branches/1.4/src/wikisearch/ingest/pom.xml (added)
+++ incubator/accumulo/branches/1.4/src/wikisearch/ingest/pom.xml Fri Jan 6 22:02:09 2012
@@ -0,0 +1,114 @@
+<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/xsd/maven-4.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>
+ <artifactId>accumulo-wikisearch</artifactId>
+ <groupId>org.apache.accumulo</groupId>
+ <version>1.4.0-incubating-SNAPSHOT</version>
+ <relativePath>../</relativePath>
+ </parent>
+
+ <artifactId>wikisearch-ingest</artifactId>
+ <name>wikisearch-ingest</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>hadoop-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>zookeeper</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.accumulo</groupId>
+ <artifactId>accumulo-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.accumulo</groupId>
+ <artifactId>accumulo-start</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.google.collections</groupId>
+ <artifactId>google-collections</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-analyzers</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-wikipedia</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.google.protobuf</groupId>
+ <artifactId>protobuf-java</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-server</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>lib</outputDirectory>
+ <!-- just grab the non-provided runtime dependencies -->
+ <includeArtifactIds>commons-lang,google-collections,lucene-core,lucene-analyzers,lucene-wikipedia,protobuf-java</includeArtifactIds>
+ <excludeTransitive>true</excludeTransitive>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptors>
+ <descriptor>src/assembly/dist.xml</descriptor>
+ </descriptors>
+ <tarLongFileMode>gnu</tarLongFileMode>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Propchange: incubator/accumulo/branches/1.4/src/wikisearch/ingest/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/assembly/dist.xml
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/assembly/dist.xml?rev=1228459&view=auto
==============================================================================
--- incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/assembly/dist.xml (added)
+++ incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/assembly/dist.xml Fri Jan 6 22:02:09 2012
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<assembly>
+ <id>dist</id>
+ <formats>
+ <format>tar.gz</format>
+ </formats>
+ <baseDirectory></baseDirectory>
+ <fileSets>
+ <fileSet>
+ <directory>lib</directory>
+ <fileMode>0644</fileMode>
+ </fileSet>
+ <fileSet>
+ <directory>bin</directory>
+ <fileMode>0744</fileMode>
+ </fileSet>
+ <fileSet>
+ <directory>conf</directory>
+ <fileMode>0644</fileMode>
+ </fileSet>
+ </fileSets>
+</assembly>
Propchange: incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/assembly/dist.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/aggregator/GlobalIndexUidAggregator.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/aggregator/GlobalIndexUidAggregator.java?rev=1228459&view=auto
==============================================================================
--- incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/aggregator/GlobalIndexUidAggregator.java (added)
+++ incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/aggregator/GlobalIndexUidAggregator.java Fri Jan 6 22:02:09 2012
@@ -0,0 +1,86 @@
+/*
+ * 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.accumulo.wikisearch.aggregator;
+
+import java.util.HashSet;
+
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.iterators.aggregation.Aggregator;
+import org.apache.accumulo.wikisearch.protobuf.Uid;
+import org.apache.log4j.Logger;
+
+import com.google.protobuf.InvalidProtocolBufferException;
+
+/**
+ * Implementation of an Aggregator that aggregates objects of the type Uid.List. This is an optimization for the global index and global reverse index, where
+ * the list of UIDs for events will be maintained in the index for low cardinality terms (Low in this case being less than 20).
+ *
+ */
+public class GlobalIndexUidAggregator implements Aggregator {
+
+ private static final Logger log = Logger.getLogger(GlobalIndexUidAggregator.class);
+ private Uid.List.Builder builder = Uid.List.newBuilder();
+ // Using a set instead of a list so that duplicate IDs are filtered out of the list.
+ private HashSet<String> uids = new HashSet<String>();
+ private boolean seenIgnore = false;
+ public static final int MAX = 20;
+ private long count = 0;
+
+ @Override
+ public Value aggregate() {
+ // Special case logic
+ // If we have aggregated more than MAX UIDs, then null out the UID list and set IGNORE to true
+ // However, always maintain the count
+ if (uids.size() > MAX || seenIgnore) {
+ builder.setCOUNT(count);
+ builder.setIGNORE(true);
+ builder.clearUID();
+ } else {
+ builder.setCOUNT(count);
+ builder.setIGNORE(false);
+ builder.addAllUID(uids);
+ }
+ return new Value(builder.build().toByteArray());
+ }
+
+ @Override
+ public void collect(Value value) {
+ if (null == value || value.get().length == 0)
+ return;
+ // Collect the values, which are serialized Uid.List objects
+ try {
+ Uid.List v = Uid.List.parseFrom(value.get());
+ count = count + v.getCOUNT();
+ if (v.getIGNORE()) {
+ seenIgnore = true;
+ }
+ // Add the incoming list to this list
+ uids.addAll(v.getUIDList());
+ } catch (InvalidProtocolBufferException e) {
+ log.error("Value passed to aggregator was not of type Uid.List", e);
+ }
+ }
+
+ @Override
+ public void reset() {
+ count = 0;
+ seenIgnore = false;
+ builder = Uid.List.newBuilder();
+ uids.clear();
+ }
+
+}
Propchange: incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/aggregator/GlobalIndexUidAggregator.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/aggregator/TextIndexAggregator.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/aggregator/TextIndexAggregator.java?rev=1228459&view=auto
==============================================================================
--- incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/aggregator/TextIndexAggregator.java (added)
+++ incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/aggregator/TextIndexAggregator.java Fri Jan 6 22:02:09 2012
@@ -0,0 +1,94 @@
+/*
+ * 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.accumulo.wikisearch.aggregator;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.iterators.aggregation.Aggregator;
+import org.apache.accumulo.wikisearch.protobuf.TermWeight;
+
+import com.google.protobuf.InvalidProtocolBufferException;
+
+/**
+ * An Aggregator to merge together a list of term offsets and one normalized term frequency
+ *
+ */
+public class TextIndexAggregator implements Aggregator {
+ private static final Logger log = Logger.getLogger(TextIndexAggregator.class);
+
+ private List<Integer> offsets = new ArrayList<Integer>();
+ private TermWeight.Info.Builder builder = TermWeight.Info.newBuilder();
+ private float normalizedTermFrequency = 0f;
+
+ @Override
+ public Value aggregate() {
+ // Keep the sorted order we tried to maintain
+ for (int i = 0; i < offsets.size(); ++i) {
+ builder.addWordOffset(offsets.get(i));
+ }
+
+ builder.setNormalizedTermFrequency(normalizedTermFrequency);
+
+ return new Value(builder.build().toByteArray());
+ }
+
+ @Override
+ public void collect(Value value) {
+ // Make sure we don't aggregate something else
+ if (value == null || value.get().length == 0) {
+ return;
+ }
+
+ TermWeight.Info info;
+
+ try {
+ info = TermWeight.Info.parseFrom(value.get());
+ } catch (InvalidProtocolBufferException e) {
+ log.error("Value passed to aggregator was not of type TermWeight.Info", e);
+ return;
+ }
+
+ // Add each offset into the list maintaining sorted order
+ for (int offset : info.getWordOffsetList()) {
+ int pos = Collections.binarySearch(offsets, offset);
+
+ if (pos < 0) {
+ // Undo the transform on the insertion point
+ offsets.add((-1 * pos) - 1, offset);
+ } else {
+ offsets.add(pos, offset);
+ }
+ }
+
+ if (info.getNormalizedTermFrequency() > 0) {
+ this.normalizedTermFrequency += info.getNormalizedTermFrequency();
+ }
+ }
+
+ @Override
+ public void reset() {
+ this.offsets.clear();
+ this.normalizedTermFrequency = 0f;
+ this.builder = TermWeight.Info.newBuilder();
+ }
+
+}
Propchange: incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/aggregator/TextIndexAggregator.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/ArticleExtractor.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/ArticleExtractor.java?rev=1228459&view=auto
==============================================================================
--- incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/ArticleExtractor.java (added)
+++ incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/ArticleExtractor.java Fri Jan 6 22:02:09 2012
@@ -0,0 +1,173 @@
+/*
+ * 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.accumulo.wikisearch.ingest;
+
+import java.io.Reader;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.accumulo.wikisearch.normalizer.LcNoDiacriticsNormalizer;
+import org.apache.accumulo.wikisearch.normalizer.NumberNormalizer;
+
+
+public class ArticleExtractor {
+
+ public final static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'Z");
+ private static NumberNormalizer nn = new NumberNormalizer();
+ private static LcNoDiacriticsNormalizer lcdn = new LcNoDiacriticsNormalizer();
+
+ public static class Article {
+ int id;
+ String title;
+ long timestamp;
+ String comments;
+ String text;
+
+ private Article(int id, String title, long timestamp, String comments, String text) {
+ super();
+ this.id = id;
+ this.title = title;
+ this.timestamp = timestamp;
+ this.comments = comments;
+ this.text = text;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public String getComments() {
+ return comments;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ public Map<String,Object> getFieldValues() {
+ Map<String,Object> fields = new HashMap<String,Object>();
+ fields.put("ID", this.id);
+ fields.put("TITLE", this.title);
+ fields.put("TIMESTAMP", this.timestamp);
+ fields.put("COMMENTS", this.comments);
+ return fields;
+ }
+
+ public Map<String,String> getNormalizedFieldValues() {
+ Map<String,String> fields = new HashMap<String,String>();
+ fields.put("ID", nn.normalizeFieldValue("ID", this.id));
+ fields.put("TITLE", lcdn.normalizeFieldValue("TITLE", this.title));
+ fields.put("TIMESTAMP", nn.normalizeFieldValue("TIMESTAMP", this.timestamp));
+ fields.put("COMMENTS", lcdn.normalizeFieldValue("COMMENTS", this.comments));
+ return fields;
+ }
+
+ }
+
+ public ArticleExtractor() {}
+
+ public Article extract(Reader reader) {
+ XMLInputFactory xmlif = XMLInputFactory.newInstance();
+ xmlif.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.TRUE);
+
+ XMLStreamReader xmlr = null;
+
+ try {
+ xmlr = xmlif.createXMLStreamReader(reader);
+ } catch (XMLStreamException e1) {
+ throw new RuntimeException(e1);
+ }
+
+ QName titleName = QName.valueOf("title");
+ QName textName = QName.valueOf("text");
+ QName revisionName = QName.valueOf("revision");
+ QName timestampName = QName.valueOf("timestamp");
+ QName commentName = QName.valueOf("comment");
+ QName idName = QName.valueOf("id");
+
+ Map<QName,StringBuilder> tags = new HashMap<QName,StringBuilder>();
+ for (QName tag : new QName[] {titleName, textName, timestampName, commentName, idName}) {
+ tags.put(tag, new StringBuilder());
+ }
+
+ StringBuilder articleText = tags.get(textName);
+ StringBuilder titleText = tags.get(titleName);
+ StringBuilder timestampText = tags.get(timestampName);
+ StringBuilder commentText = tags.get(commentName);
+ StringBuilder idText = tags.get(idName);
+
+ StringBuilder current = null;
+ boolean inRevision = false;
+ while (true) {
+ try {
+ if (!xmlr.hasNext())
+ break;
+ xmlr.next();
+ } catch (XMLStreamException e) {
+ throw new RuntimeException(e);
+ }
+ QName currentName = null;
+ if (xmlr.hasName()) {
+ currentName = xmlr.getName();
+ }
+ if (xmlr.isStartElement() && tags.containsKey(currentName)) {
+ if (!inRevision || (!currentName.equals(revisionName) && !currentName.equals(idName))) {
+ current = tags.get(currentName);
+ current.setLength(0);
+ }
+ } else if (xmlr.isStartElement() && currentName.equals(revisionName)) {
+ inRevision = true;
+ } else if (xmlr.isEndElement() && currentName.equals(revisionName)) {
+ inRevision = false;
+ } else if (xmlr.isEndElement() && current != null) {
+ if (textName.equals(currentName)) {
+
+ String title = titleText.toString();
+ String text = articleText.toString();
+ String comment = commentText.toString();
+ int id = Integer.parseInt(idText.toString());
+ long timestamp;
+ try {
+ timestamp = dateFormat.parse(timestampText.append("+0000").toString()).getTime();
+ return new Article(id, title, timestamp, comment, text);
+ } catch (ParseException e) {
+ return null;
+ }
+ }
+ current = null;
+ } else if (current != null && xmlr.hasText()) {
+ current.append(xmlr.getText());
+ }
+ }
+ return null;
+ }
+}
Propchange: incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/ArticleExtractor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/WikipediaConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/WikipediaConfiguration.java?rev=1228459&view=auto
==============================================================================
--- incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/WikipediaConfiguration.java (added)
+++ incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/WikipediaConfiguration.java Fri Jan 6 22:02:09 2012
@@ -0,0 +1,149 @@
+/*
+ * 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.accumulo.wikisearch.ingest;
+
+import java.io.IOException;
+
+import org.apache.accumulo.core.client.AccumuloException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.Instance;
+import org.apache.accumulo.core.client.ZooKeeperInstance;
+import org.apache.commons.lang.StringUtils;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.util.ReflectionUtils;
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.SimpleAnalyzer;
+
+public class WikipediaConfiguration {
+ public final static String INSTANCE_NAME = "wikipedia.accumulo.instance_name";
+ public final static String USER = "wikipedia.accumulo.user";
+ public final static String PASSWORD = "wikipedia.accumulo.password";
+ public final static String TABLE_NAME = "wikipedia.accumulo.table";
+
+ public final static String ZOOKEEPERS = "wikipedia.accumulo.zookeepers";
+
+ public final static String NAMESPACES_FILENAME = "wikipedia.namespaces.filename";
+ public final static String LANGUAGES_FILENAME = "wikipedia.languages.filename";
+ public final static String WORKING_DIRECTORY = "wikipedia.ingest.working";
+
+ public final static String ANALYZER = "wikipedia.index.analyzer";
+
+ public final static String NUM_PARTITIONS = "wikipedia.ingest.partitions";
+
+ public static String getUser(Configuration conf) {
+ return conf.get(USER);
+ };
+
+ public static byte[] getPassword(Configuration conf) {
+ String pass = conf.get(PASSWORD);
+ if (pass == null) {
+ return null;
+ }
+ return pass.getBytes();
+ }
+
+ public static String getTableName(Configuration conf) {
+ String tablename = conf.get(TABLE_NAME);
+ if (tablename == null) {
+ throw new RuntimeException("No data table name specified in " + TABLE_NAME);
+ }
+ return tablename;
+ }
+
+ public static String getInstanceName(Configuration conf) {
+ return conf.get(INSTANCE_NAME);
+ }
+
+ public static String getZookeepers(Configuration conf) {
+ String zookeepers = conf.get(ZOOKEEPERS);
+ if (zookeepers == null) {
+ throw new RuntimeException("No zookeepers specified in " + ZOOKEEPERS);
+ }
+ return zookeepers;
+ }
+
+ public static Path getNamespacesFile(Configuration conf) {
+ String filename = conf.get(NAMESPACES_FILENAME, new Path(getWorkingDirectory(conf), "namespaces.dat").toString());
+ return new Path(filename);
+ }
+
+ public static Path getLanguagesFile(Configuration conf) {
+ String filename = conf.get(LANGUAGES_FILENAME, new Path(getWorkingDirectory(conf), "languages.txt").toString());
+ return new Path(filename);
+ }
+
+ public static Path getWorkingDirectory(Configuration conf) {
+ String filename = conf.get(WORKING_DIRECTORY);
+ return new Path(filename);
+ }
+
+ public static Analyzer getAnalyzer(Configuration conf) throws IOException {
+ Class<? extends Analyzer> analyzerClass = conf.getClass(ANALYZER, SimpleAnalyzer.class, Analyzer.class);
+ return ReflectionUtils.newInstance(analyzerClass, conf);
+ }
+
+ public static Connector getConnector(Configuration conf) throws AccumuloException, AccumuloSecurityException {
+ return getInstance(conf).getConnector(getUser(conf), getPassword(conf));
+ }
+
+ public static Instance getInstance(Configuration conf) {
+ return new ZooKeeperInstance(getInstanceName(conf), getZookeepers(conf));
+ }
+
+ public static int getNumPartitions(Configuration conf) {
+ return conf.getInt(NUM_PARTITIONS, 25);
+ }
+
+ /**
+ * Helper method to get properties from Hadoop configuration
+ *
+ * @param <T>
+ * @param conf
+ * @param propertyName
+ * @param resultClass
+ * @throws IllegalArgumentException
+ * if property is not defined, null, or empty. Or if resultClass is not handled.
+ * @return value of property
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> T isNull(Configuration conf, String propertyName, Class<T> resultClass) {
+ String p = conf.get(propertyName);
+ if (StringUtils.isEmpty(p))
+ throw new IllegalArgumentException(propertyName + " must be specified");
+
+ if (resultClass.equals(String.class))
+ return (T) p;
+ else if (resultClass.equals(String[].class))
+ return (T) conf.getStrings(propertyName);
+ else if (resultClass.equals(Boolean.class))
+ return (T) Boolean.valueOf(p);
+ else if (resultClass.equals(Long.class))
+ return (T) Long.valueOf(p);
+ else if (resultClass.equals(Integer.class))
+ return (T) Integer.valueOf(p);
+ else if (resultClass.equals(Float.class))
+ return (T) Float.valueOf(p);
+ else if (resultClass.equals(Double.class))
+ return (T) Double.valueOf(p);
+ else
+ throw new IllegalArgumentException(resultClass.getSimpleName() + " is unhandled.");
+
+ }
+
+}
Propchange: incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/WikipediaConfiguration.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/WikipediaIngester.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/WikipediaIngester.java?rev=1228459&view=auto
==============================================================================
--- incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/WikipediaIngester.java (added)
+++ incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/WikipediaIngester.java Fri Jan 6 22:02:09 2012
@@ -0,0 +1,210 @@
+/*
+ * 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.accumulo.wikisearch.ingest;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.accumulo.core.client.AccumuloException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.TableExistsException;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.client.admin.TableOperations;
+import org.apache.accumulo.core.client.mapreduce.AccumuloOutputFormat;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
+import org.apache.accumulo.core.iterators.aggregation.NumSummation;
+import org.apache.accumulo.core.iterators.aggregation.conf.AggregatorConfiguration;
+import org.apache.accumulo.wikisearch.reader.AggregatingRecordReader;
+import org.apache.commons.lang.StringUtils;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.conf.Configured;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.PathFilter;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapreduce.Job;
+import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
+import org.apache.hadoop.util.Tool;
+import org.apache.hadoop.util.ToolRunner;
+
+
+@SuppressWarnings("deprecation")
+public class WikipediaIngester extends Configured implements Tool {
+
+ public final static String INGEST_LANGUAGE = "wikipedia.ingest_language";
+ public final static String SPLIT_FILE = "wikipedia.split_file";
+ public final static String TABLE_NAME = "wikipedia.table";
+
+ public static void main(String[] args) throws Exception {
+ int res = ToolRunner.run(new Configuration(), new WikipediaIngester(), args);
+ System.exit(res);
+ }
+
+ private void createTables(TableOperations tops, String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException,
+ TableExistsException {
+ // Create the shard table
+ String indexTableName = tableName + "Index";
+ String reverseIndexTableName = tableName + "ReverseIndex";
+ String metadataTableName = tableName + "Metadata";
+
+ // create the shard table
+ if (!tops.exists(tableName)) {
+ // Set a text index aggregator on the given field names. No aggregator is set if the option is not supplied
+ String textIndexFamilies = WikipediaMapper.TOKENS_FIELD_NAME;
+
+ if (textIndexFamilies.length() > 0) {
+ System.out.println("Adding content aggregator on the fields: " + textIndexFamilies);
+
+ // Create and set the aggregators in one shot
+ List<AggregatorConfiguration> aggregators = new ArrayList<AggregatorConfiguration>();
+
+ for (String family : StringUtils.split(textIndexFamilies, ',')) {
+ aggregators.add(new AggregatorConfiguration(new Text("fi\0" + family), org.apache.accumulo.wikisearch.aggregator.TextIndexAggregator.class.getName()));
+ }
+
+ tops.create(tableName);
+ tops.addAggregators(tableName, aggregators);
+ } else {
+ tops.create(tableName);
+ }
+
+ // Set the locality group for the full content column family
+ tops.setLocalityGroups(tableName, Collections.singletonMap("WikipediaDocuments", Collections.singleton(new Text(WikipediaMapper.DOCUMENT_COLUMN_FAMILY))));
+
+ }
+
+ if (!tops.exists(indexTableName)) {
+ tops.create(indexTableName);
+ // Add the UID aggregator
+ for (IteratorScope scope : IteratorScope.values()) {
+ String stem = String.format("%s%s.%s", Property.TABLE_ITERATOR_PREFIX, scope.name(), "UIDAggregator");
+ tops.setProperty(indexTableName, stem, "19,iterator.TotalAggregatingIterator");
+ stem += ".opt.";
+ tops.setProperty(indexTableName, stem + "*", "aggregator.GlobalIndexUidAggregator");
+
+ }
+ }
+
+ if (!tops.exists(reverseIndexTableName)) {
+ tops.create(reverseIndexTableName);
+ // Add the UID aggregator
+ for (IteratorScope scope : IteratorScope.values()) {
+ String stem = String.format("%s%s.%s", Property.TABLE_ITERATOR_PREFIX, scope.name(), "UIDAggregator");
+ tops.setProperty(reverseIndexTableName, stem, "19,iterator.TotalAggregatingIterator");
+ stem += ".opt.";
+ tops.setProperty(reverseIndexTableName, stem + "*", "aggregator.GlobalIndexUidAggregator");
+
+ }
+ }
+
+ if (!tops.exists(metadataTableName)) {
+ // Add the NumSummation aggregator for the frequency column
+ List<AggregatorConfiguration> aggregators = new ArrayList<AggregatorConfiguration>();
+ aggregators.add(new AggregatorConfiguration(new Text("f"), NumSummation.class.getName()));
+ tops.create(metadataTableName);
+ tops.addAggregators(metadataTableName, aggregators);
+ }
+ }
+
+ @Override
+ public int run(String[] args) throws Exception {
+ Job job = new Job(getConf(), "Ingest Wikipedia");
+ Configuration conf = job.getConfiguration();
+
+ String tablename = WikipediaConfiguration.getTableName(conf);
+
+ String zookeepers = WikipediaConfiguration.getZookeepers(conf);
+ String instanceName = WikipediaConfiguration.getInstanceName(conf);
+
+ String user = WikipediaConfiguration.getUser(conf);
+ byte[] password = WikipediaConfiguration.getPassword(conf);
+ Connector connector = WikipediaConfiguration.getConnector(conf);
+
+ TableOperations tops = connector.tableOperations();
+
+ createTables(tops, tablename);
+
+ configureJob(job);
+
+ List<Path> inputPaths = new ArrayList<Path>();
+ SortedSet<String> languages = new TreeSet<String>();
+ FileSystem fs = FileSystem.get(conf);
+ Path parent = new Path(conf.get("wikipedia.input"));
+ listFiles(parent, fs, inputPaths, languages);
+
+ System.out.println("Input files in " + parent + ":" + inputPaths.size());
+ Path[] inputPathsArray = new Path[inputPaths.size()];
+ inputPaths.toArray(inputPathsArray);
+
+ System.out.println("Languages:" + languages.size());
+
+ FileInputFormat.setInputPaths(job, inputPathsArray);
+
+ job.setMapperClass(WikipediaMapper.class);
+ job.setNumReduceTasks(0);
+ job.setMapOutputKeyClass(Text.class);
+ job.setMapOutputValueClass(Mutation.class);
+ job.setOutputFormatClass(AccumuloOutputFormat.class);
+ AccumuloOutputFormat.setOutputInfo(job, user, password, true, tablename);
+ AccumuloOutputFormat.setZooKeeperInstance(job, instanceName, zookeepers);
+
+ return job.waitForCompletion(true) ? 0 : 1;
+ }
+
+ public final static PathFilter partFilter = new PathFilter() {
+ @Override
+ public boolean accept(Path path) {
+ return path.getName().startsWith("part");
+ };
+ };
+
+ protected void configureJob(Job job) {
+ Configuration conf = job.getConfiguration();
+ job.setJarByClass(WikipediaIngester.class);
+ job.setInputFormatClass(WikipediaInputFormat.class);
+ conf.set(AggregatingRecordReader.START_TOKEN, "<page>");
+ conf.set(AggregatingRecordReader.END_TOKEN, "</page>");
+ }
+
+ protected static final Pattern filePattern = Pattern.compile("([a-z_]+).*.xml(.bz2)?");
+
+ protected void listFiles(Path path, FileSystem fs, List<Path> files, Set<String> languages) throws IOException {
+ for (FileStatus status : fs.listStatus(path)) {
+ if (status.isDir()) {
+ listFiles(status.getPath(), fs, files, languages);
+ } else {
+ Path p = status.getPath();
+ Matcher matcher = filePattern.matcher(p.getName());
+ if (matcher.matches()) {
+ languages.add(matcher.group(1));
+ files.add(p);
+ }
+ }
+ }
+ }
+}
Propchange: incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/WikipediaIngester.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/WikipediaInputFormat.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/WikipediaInputFormat.java?rev=1228459&view=auto
==============================================================================
--- incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/WikipediaInputFormat.java (added)
+++ incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/WikipediaInputFormat.java Fri Jan 6 22:02:09 2012
@@ -0,0 +1,42 @@
+/*
+ * 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.accumulo.wikisearch.ingest;
+
+import org.apache.accumulo.wikisearch.reader.AggregatingRecordReader;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapreduce.InputSplit;
+import org.apache.hadoop.mapreduce.JobContext;
+import org.apache.hadoop.mapreduce.RecordReader;
+import org.apache.hadoop.mapreduce.TaskAttemptContext;
+import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
+
+
+public class WikipediaInputFormat extends TextInputFormat {
+
+ @Override
+ public RecordReader<LongWritable,Text> createRecordReader(InputSplit split, TaskAttemptContext context) {
+ return new AggregatingRecordReader();
+ }
+
+ @Override
+ protected boolean isSplitable(JobContext context, Path file) {
+ return false;
+ }
+
+}
Propchange: incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/WikipediaInputFormat.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/WikipediaMapper.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/WikipediaMapper.java?rev=1228459&view=auto
==============================================================================
--- incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/WikipediaMapper.java (added)
+++ incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/WikipediaMapper.java Fri Jan 6 22:02:09 2012
@@ -0,0 +1,258 @@
+/*
+ * 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.accumulo.wikisearch.ingest;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.nio.charset.Charset;
+import java.util.HashSet;
+import java.util.IllegalFormatException;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.security.ColumnVisibility;
+import org.apache.accumulo.wikisearch.ingest.ArticleExtractor.Article;
+import org.apache.accumulo.wikisearch.normalizer.LcNoDiacriticsNormalizer;
+import org.apache.accumulo.wikisearch.protobuf.Uid;
+import org.apache.accumulo.wikisearch.protobuf.Uid.List.Builder;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.lang.StringUtils;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapreduce.Mapper;
+import org.apache.hadoop.mapreduce.lib.input.FileSplit;
+import org.apache.log4j.Logger;
+import org.apache.lucene.analysis.StopAnalyzer;
+import org.apache.lucene.analysis.StopFilter;
+import org.apache.lucene.analysis.ar.ArabicAnalyzer;
+import org.apache.lucene.analysis.br.BrazilianAnalyzer;
+import org.apache.lucene.analysis.cjk.CJKAnalyzer;
+import org.apache.lucene.analysis.de.GermanAnalyzer;
+import org.apache.lucene.analysis.el.GreekAnalyzer;
+import org.apache.lucene.analysis.fa.PersianAnalyzer;
+import org.apache.lucene.analysis.fr.FrenchAnalyzer;
+import org.apache.lucene.analysis.nl.DutchAnalyzer;
+import org.apache.lucene.analysis.tokenattributes.TermAttribute;
+import org.apache.lucene.wikipedia.analysis.WikipediaTokenizer;
+
+
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Multimap;
+
+public class WikipediaMapper extends Mapper<LongWritable,Text,Text,Mutation> {
+
+ private static final Logger log = Logger.getLogger(WikipediaMapper.class);
+
+ public final static Charset UTF8 = Charset.forName("UTF-8");
+ public static final String DOCUMENT_COLUMN_FAMILY = "d";
+ public static final String METADATA_EVENT_COLUMN_FAMILY = "e";
+ public static final String METADATA_INDEX_COLUMN_FAMILY = "i";
+ public static final String TOKENS_FIELD_NAME = "TEXT";
+
+ private final static Pattern languagePattern = Pattern.compile("([a-z_]+).*.xml(.bz2)?");
+ private static final Value NULL_VALUE = new Value(new byte[0]);
+ private static final String cvPrefix = "all|";
+
+ private ArticleExtractor extractor;
+ private String language;
+ private int numPartitions = 0;
+ private Set<?> stopwords = null;
+ private ColumnVisibility cv = null;
+
+ private Text tablename = null;
+ private Text indexTableName = null;
+ private Text reverseIndexTableName = null;
+ private Text metadataTableName = null;
+
+ @Override
+ public void setup(Context context) {
+ Configuration conf = context.getConfiguration();
+ tablename = new Text(WikipediaConfiguration.getTableName(conf));
+ indexTableName = new Text(tablename + "Index");
+ reverseIndexTableName = new Text(tablename + "ReverseIndex");
+ metadataTableName = new Text(tablename + "Metadata");
+
+ FileSplit split = (FileSplit) context.getInputSplit();
+ String fileName = split.getPath().getName();
+ Matcher matcher = languagePattern.matcher(fileName);
+ if (matcher.matches()) {
+ language = matcher.group(1).replace('_', '-').toLowerCase();
+ if (language.equals("arwiki"))
+ stopwords = ArabicAnalyzer.getDefaultStopSet();
+ else if (language.equals("brwiki"))
+ stopwords = BrazilianAnalyzer.getDefaultStopSet();
+ else if (language.startsWith("zh"))
+ stopwords = CJKAnalyzer.getDefaultStopSet();
+ else if (language.equals("dewiki"))
+ stopwords = GermanAnalyzer.getDefaultStopSet();
+ else if (language.equals("elwiki"))
+ stopwords = GreekAnalyzer.getDefaultStopSet();
+ else if (language.equals("fawiki"))
+ stopwords = PersianAnalyzer.getDefaultStopSet();
+ else if (language.equals("frwiki"))
+ stopwords = FrenchAnalyzer.getDefaultStopSet();
+ else if (language.equals("nlwiki"))
+ stopwords = DutchAnalyzer.getDefaultStopSet();
+ else
+ stopwords = StopAnalyzer.ENGLISH_STOP_WORDS_SET;
+
+ } else {
+ throw new RuntimeException("Unknown ingest language! " + fileName);
+ }
+ extractor = new ArticleExtractor();
+ numPartitions = WikipediaConfiguration.getNumPartitions(conf);
+ cv = new ColumnVisibility(cvPrefix + language);
+
+ }
+
+ /**
+ * We will partition the documents based on the document id
+ *
+ * @param article
+ * @param numPartitions
+ * @return
+ * @throws IllegalFormatException
+ */
+ public static int getPartitionId(Article article, int numPartitions) throws IllegalFormatException {
+ return article.getId() % numPartitions;
+ }
+
+ @Override
+ protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
+ Article article = extractor.extract(new InputStreamReader(new ByteArrayInputStream(value.getBytes()), UTF8));
+ String NULL_BYTE = "\u0000";
+ String colfPrefix = language + NULL_BYTE;
+ String indexPrefix = "fi" + NULL_BYTE;
+ if (article != null) {
+ Text partitionId = new Text(Integer.toString(WikipediaMapper.getPartitionId(article, numPartitions)));
+
+ // Create the mutations for the document.
+ // Row is partition id, colf is language0articleid, colq is fieldName\0fieldValue
+ Mutation m = new Mutation(partitionId);
+ for (Entry<String,Object> entry : article.getFieldValues().entrySet()) {
+ m.put(colfPrefix + article.getId(), entry.getKey() + NULL_BYTE + entry.getValue().toString(), cv, article.getTimestamp(), NULL_VALUE);
+ // Create mutations for the metadata table.
+ Mutation mm = new Mutation(entry.getKey());
+ mm.put(METADATA_EVENT_COLUMN_FAMILY, language, cv, article.getTimestamp(), NULL_VALUE);
+ context.write(metadataTableName, mm);
+ }
+
+ // Tokenize the content
+ Set<String> tokens = getTokens(article);
+
+ // We are going to put the fields to be indexed into a multimap. This allows us to iterate
+ // over the entire set once.
+ Multimap<String,String> indexFields = HashMultimap.create();
+ // Add the normalized field values
+ LcNoDiacriticsNormalizer normalizer = new LcNoDiacriticsNormalizer();
+ for (Entry<String,String> index : article.getNormalizedFieldValues().entrySet())
+ indexFields.put(index.getKey(), index.getValue());
+ // Add the tokens
+ for (String token : tokens)
+ indexFields.put(TOKENS_FIELD_NAME, normalizer.normalizeFieldValue("", token));
+
+ for (Entry<String,String> index : indexFields.entries()) {
+ // Create mutations for the in partition index
+ // Row is partition id, colf is 'fi'\0fieldName, colq is fieldValue\0language\0article id
+ m.put(indexPrefix + index.getKey(), index.getValue() + NULL_BYTE + colfPrefix + article.getId(), cv, article.getTimestamp(), NULL_VALUE);
+
+ // Create mutations for the global index
+ // Create a UID object for the Value
+ Builder uidBuilder = Uid.List.newBuilder();
+ uidBuilder.setIGNORE(false);
+ uidBuilder.setCOUNT(1);
+ uidBuilder.addUID(Integer.toString(article.getId()));
+ Uid.List uidList = uidBuilder.build();
+ Value val = new Value(uidList.toByteArray());
+
+ // Create mutations for the global index
+ // Row is field value, colf is field name, colq is partitionid\0language, value is Uid.List object
+ Mutation gm = new Mutation(index.getValue());
+ gm.put(index.getKey(), partitionId + NULL_BYTE + language, cv, article.getTimestamp(), val);
+ context.write(indexTableName, gm);
+
+ // Create mutations for the global reverse index
+ Mutation grm = new Mutation(StringUtils.reverse(index.getValue()));
+ grm.put(index.getKey(), partitionId + NULL_BYTE + language, cv, article.getTimestamp(), val);
+ context.write(reverseIndexTableName, grm);
+
+ // Create mutations for the metadata table.
+ Mutation mm = new Mutation(index.getKey());
+ mm.put(METADATA_INDEX_COLUMN_FAMILY, language + NULL_BYTE + LcNoDiacriticsNormalizer.class.getName(), cv, article.getTimestamp(), NULL_VALUE);
+ context.write(metadataTableName, mm);
+
+ }
+ // Add the entire text to the document section of the table.
+ // row is the partition, colf is 'd', colq is language\0articleid, value is Base64 encoded GZIP'd document
+ m.put(DOCUMENT_COLUMN_FAMILY, colfPrefix + article.getId(), cv, article.getTimestamp(), new Value(Base64.encodeBase64(article.getText().getBytes())));
+ context.write(tablename, m);
+
+ } else {
+ context.getCounter("wikipedia", "invalid articles").increment(1);
+ }
+ context.progress();
+ }
+
+ /**
+ * Tokenize the wikipedia content
+ *
+ * @param article
+ * @return
+ * @throws IOException
+ */
+ private Set<String> getTokens(Article article) throws IOException {
+ Set<String> tokenList = new HashSet<String>();
+ WikipediaTokenizer tok = new WikipediaTokenizer(new StringReader(article.getText()));
+ TermAttribute term = tok.addAttribute(TermAttribute.class);
+ StopFilter filter = new StopFilter(false, tok, stopwords, true);
+ try {
+ while (filter.incrementToken()) {
+ String token = term.term();
+ if (!StringUtils.isEmpty(token))
+ tokenList.add(token);
+ }
+ } catch (IOException e) {
+ log.error("Error tokenizing text", e);
+ } finally {
+ try {
+ tok.end();
+ } catch (IOException e) {
+ log.error("Error calling end()", e);
+ } finally {
+ try {
+ tok.close();
+ } catch (IOException e) {
+ log.error("Error closing tokenizer", e);
+ }
+ }
+ }
+ return tokenList;
+ }
+
+}
Propchange: incubator/accumulo/branches/1.4/src/wikisearch/ingest/src/main/java/org/apache/accumulo/wikisearch/ingest/WikipediaMapper.java
------------------------------------------------------------------------------
svn:eol-style = native