You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by fr...@apache.org on 2016/05/24 09:52:04 UTC
svn commit: r1745342 - in
/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/plugins/tika:
SegmentTarUtils.java SegmentUtils.java TextExtractorMain.java
Author: frm
Date: Tue May 24 09:52:04 2016
New Revision: 1745342
URL: http://svn.apache.org/viewvc?rev=1745342&view=rev
Log:
OAK-4339 - Add a flag to choose between segment store implementations in the "tika" command
Added:
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/plugins/tika/SegmentTarUtils.java (with props)
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/plugins/tika/SegmentUtils.java (with props)
Modified:
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/plugins/tika/TextExtractorMain.java
Added: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/plugins/tika/SegmentTarUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/plugins/tika/SegmentTarUtils.java?rev=1745342&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/plugins/tika/SegmentTarUtils.java (added)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/plugins/tika/SegmentTarUtils.java Tue May 24 09:52:04 2016
@@ -0,0 +1,47 @@
+/*
+ * 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.jackrabbit.oak.plugins.tika;
+
+import java.io.File;
+import java.io.IOException;
+
+import com.google.common.io.Closer;
+import org.apache.jackrabbit.oak.segment.SegmentNodeStore;
+import org.apache.jackrabbit.oak.segment.file.FileStore;
+import org.apache.jackrabbit.oak.spi.blob.BlobStore;
+import org.apache.jackrabbit.oak.spi.state.NodeStore;
+
+class SegmentTarUtils {
+
+ private SegmentTarUtils() {
+ // Prevent instantiation
+ }
+
+ static NodeStore bootstrap(String path, BlobStore store, Closer closer) throws IOException {
+ return SegmentNodeStore.builder(fileStore(path, store, closer)).build();
+ }
+
+ private static FileStore fileStore(String path, BlobStore store, Closer closer) throws IOException {
+ return closer.register(fileStore(path, store));
+ }
+
+ private static FileStore fileStore(String path, BlobStore store) throws IOException {
+ return FileStore.builder(new File(path)).withBlobStore(store).build();
+ }
+
+}
Propchange: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/plugins/tika/SegmentTarUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/plugins/tika/SegmentUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/plugins/tika/SegmentUtils.java?rev=1745342&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/plugins/tika/SegmentUtils.java (added)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/plugins/tika/SegmentUtils.java Tue May 24 09:52:04 2016
@@ -0,0 +1,47 @@
+/*
+ * 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.jackrabbit.oak.plugins.tika;
+
+import java.io.File;
+import java.io.IOException;
+
+import com.google.common.io.Closer;
+import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStore;
+import org.apache.jackrabbit.oak.plugins.segment.file.FileStore;
+import org.apache.jackrabbit.oak.spi.blob.BlobStore;
+import org.apache.jackrabbit.oak.spi.state.NodeStore;
+
+class SegmentUtils {
+
+ private SegmentUtils() {
+ // Prevent instantiation
+ }
+
+ static NodeStore bootstrap(String path, BlobStore store, Closer closer) throws IOException {
+ return SegmentNodeStore.builder(fileStore(path, store, closer)).build();
+ }
+
+ private static FileStore fileStore(String path, BlobStore store, Closer closer) throws IOException {
+ return closer.register(fileStore(path, store));
+ }
+
+ private static FileStore fileStore(String path, BlobStore store) throws IOException {
+ return FileStore.builder(new File(path)).withBlobStore(store).build();
+ }
+
+}
Propchange: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/plugins/tika/SegmentUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/plugins/tika/TextExtractorMain.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/plugins/tika/TextExtractorMain.java?rev=1745342&r1=1745341&r2=1745342&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/plugins/tika/TextExtractorMain.java (original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/plugins/tika/TextExtractorMain.java Tue May 24 09:52:04 2016
@@ -19,6 +19,10 @@
package org.apache.jackrabbit.oak.plugins.tika;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Arrays.asList;
+
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
@@ -47,18 +51,12 @@ import org.apache.jackrabbit.oak.plugins
import org.apache.jackrabbit.oak.plugins.document.DocumentMK;
import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore;
import org.apache.jackrabbit.oak.plugins.document.util.MongoConnection;
-import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStore;
import org.apache.jackrabbit.oak.plugins.segment.file.FileStore;
import org.apache.jackrabbit.oak.spi.blob.BlobStore;
import org.apache.jackrabbit.oak.spi.state.NodeStore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.Arrays.asList;
-import static org.apache.jackrabbit.oak.plugins.segment.FileStoreHelper.openFileStore;
-
public class TextExtractorMain {
private static final Logger log = LoggerFactory.getLogger(TextExtractorMain.class);
@@ -79,6 +77,9 @@ public class TextExtractorMain {
.withRequiredArg()
.ofType(String.class);
+ OptionSpec segmentTar = parser
+ .accepts("segment-tar", "Use oak-segment-tar instead of oak-segment");
+
OptionSpec<String> pathSpec = parser
.accepts("path", "Path in repository under which the binaries would be searched")
.withRequiredArg()
@@ -215,7 +216,7 @@ public class TextExtractorMain {
checkNotNull(blobStore, "BlobStore found to be null. FileDataStore directory " +
"must be specified via %s", fdsDirSpec.options());
checkNotNull(dataFile, "Data file path not provided");
- NodeStore nodeStore = bootStrapNodeStore(src, blobStore, closer);
+ NodeStore nodeStore = bootStrapNodeStore(src, options.has(segmentTar), blobStore, closer);
BinaryResourceProvider brp = new NodeStoreBinaryResourceProvider(nodeStore, blobStore);
CSVFileGenerator generator = new CSVFileGenerator(dataFile);
generator.generate(brp.getBinaries(path));
@@ -285,8 +286,7 @@ public class TextExtractorMain {
return props;
}
- private static NodeStore bootStrapNodeStore(String src, BlobStore blobStore,
- Closer closer) throws IOException {
+ private static NodeStore bootStrapNodeStore(String src, boolean segmentTar, BlobStore blobStore, Closer closer) throws IOException {
if (src.startsWith(MongoURI.MONGODB_PREFIX)) {
MongoClientURI uri = new MongoClientURI(src);
if (uri.getDatabase() == null) {
@@ -302,9 +302,12 @@ public class TextExtractorMain {
closer.register(asCloseable(store));
return store;
}
- FileStore fs = openFileStore(src, false, blobStore);
- closer.register(asCloseable(fs));
- return SegmentNodeStore.builder(fs).build();
+
+ if (segmentTar) {
+ return SegmentTarUtils.bootstrap(src, blobStore, closer);
+ }
+
+ return SegmentUtils.bootstrap(src, blobStore, closer);
}
private static Closeable asCloseable(final FileStore fs) {