thomasmueller commented on code in PR #587:
URL: https://github.com/apache/jackrabbit-oak/pull/587#discussion_r898040359
##########
oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/writer/DefaultIndexWriter.java:
##########
@@ -160,7 +160,7 @@ public boolean close(long timestamp) throws IOException {
//~----------------------------------------< internal >
- IndexWriter getWriter() throws IOException {
+ synchronized IndexWriter getWriter() throws IOException {
Review Comment:
I have to admit I'm not 100% confident that this change has no unwanted side
effects... For example, a deadlock. Or a performance degradation, if other
methods of this class are synchronized. Something to be investigated, I
think... Unless, you have done that already?
##########
oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/FlatFileSplitter.java:
##########
@@ -0,0 +1,257 @@
+/*
+ * 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.index.indexer.document.flatfile;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.api.Type;
+import org.apache.jackrabbit.oak.commons.Compression;
+import org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry;
+import org.apache.jackrabbit.oak.plugins.index.search.Aggregate;
+import org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition;
+import org.apache.jackrabbit.oak.query.ast.NodeTypeInfo;
+import org.apache.jackrabbit.oak.query.ast.NodeTypeInfoProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.Stack;
+import java.util.stream.Collectors;
+
+import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
+import static org.apache.jackrabbit.JcrConstants.NT_BASE;
+import static
org.apache.jackrabbit.oak.index.indexer.document.flatfile.FlatFileNodeStoreBuilder.DEFAULT_NUMBER_OF_SPLIT_STORE_SIZE;
+import static
org.apache.jackrabbit.oak.index.indexer.document.flatfile.FlatFileNodeStoreBuilder.OAK_INDEXER_USE_LZ4;
+import static
org.apache.jackrabbit.oak.index.indexer.document.flatfile.FlatFileNodeStoreBuilder.OAK_INDEXER_USE_ZIP;
+import static
org.apache.jackrabbit.oak.index.indexer.document.flatfile.FlatFileNodeStoreBuilder.PROP_SPLIT_STORE_SIZE;
+import static
org.apache.jackrabbit.oak.index.indexer.document.flatfile.FlatFileStoreUtils.createReader;
+import static
org.apache.jackrabbit.oak.index.indexer.document.flatfile.FlatFileStoreUtils.createWriter;
+import static
org.apache.jackrabbit.oak.index.indexer.document.flatfile.FlatFileStoreUtils.getSortedStoreFileName;
+
+public class FlatFileSplitter {
+ private static final Logger log =
LoggerFactory.getLogger(FlatFileSplitter.class);
+
+ private static final String SPLIT_DIR_NAME = "split";
+ private static final long MINIMUM_SPLIT_THRESHOLD = 10 * FileUtils.ONE_MB;
+
+ private final File workDir;
+ private final NodeTypeInfoProvider infoProvider;
+ private final File flatFile;
+ private final NodeStateEntryReader entryReader;
+ private final Compression.Algorithm algorithm;
+ private Set<IndexDefinition> indexDefinitions;
+ private Set<String> splitNodeTypeNames;
+ private long minimumSplitThreshold = MINIMUM_SPLIT_THRESHOLD;
+ private int splitSize = Integer.getInteger(PROP_SPLIT_STORE_SIZE,
DEFAULT_NUMBER_OF_SPLIT_STORE_SIZE);
+ private boolean useCompression =
Boolean.parseBoolean(System.getProperty(OAK_INDEXER_USE_ZIP, "true"));
+ private boolean useLZ4 =
Boolean.parseBoolean(System.getProperty(OAK_INDEXER_USE_LZ4, "false"));
+
+ public FlatFileSplitter(File flatFile, File workdir, NodeTypeInfoProvider
infoProvider, NodeStateEntryReader entryReader,
+ Set<IndexDefinition> indexDefinitions) {
+ this.flatFile = flatFile;
+ this.indexDefinitions = indexDefinitions;
+ this.workDir = new File(workdir, SPLIT_DIR_NAME);
+
+ this.infoProvider = infoProvider;
+ this.entryReader = entryReader;
+
+ Compression.Algorithm algorithm = Compression.Algorithm.GZIP;
+ if (!useCompression) {
+ algorithm = Compression.Algorithm.NONE;
+ } else if (useLZ4) {
+ algorithm = Compression.Algorithm.LZ4;
+ }
+ this.algorithm = algorithm;
+ }
+
+ private List<File> returnOriginalFlatFile() {
+ return (new ArrayList<File>(1){
Review Comment:
There's List.singletonList(flatFile), I think it should work as well.
##########
oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/FlatFileSplitterTest.java:
##########
@@ -0,0 +1,428 @@
+package org.apache.jackrabbit.oak.index.indexer.document.flatfile;
Review Comment:
The license header is missing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]