tihom88 commented on code in PR #1123:
URL: https://github.com/apache/jackrabbit-oak/pull/1123#discussion_r1330588714
##########
oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/FlatFileNodeStoreBuilder.java:
##########
@@ -244,73 +255,83 @@ public FlatFileStore build() throws IOException,
CompositeException {
}
public List<FlatFileStore> buildList(IndexHelper indexHelper,
IndexerSupport indexerSupport,
- Set<IndexDefinition> indexDefinitions) throws IOException,
CompositeException {
+ Set<IndexDefinition>
indexDefinitions) throws IOException, CompositeException {
logFlags();
comparator = new PathElementComparator(preferredPathElements);
entryWriter = new NodeStateEntryWriter(blobStore);
- List<File> fileList = createdSortedStoreFiles();
-
+ Pair<List<File>, List<File>> pair = createdSortedStoreFiles();
+ List<File> fileList = pair.getKey();
+ File metadataFile = pair.getValue() == null || pair.getValue().size()
== 0 ? null : pair.getValue().get(0);
+
long start = System.currentTimeMillis();
// If not already split, split otherwise skip splitting
if (!fileList.stream().allMatch(FlatFileSplitter.IS_SPLIT)) {
NodeStore nodeStore = new
MemoryNodeStore(indexerSupport.retrieveNodeStateForCheckpoint());
FlatFileSplitter splitter = new FlatFileSplitter(fileList.get(0),
indexHelper.getWorkDir(),
- new NodeStateNodeTypeInfoProvider(nodeStore.getRoot()), new
NodeStateEntryReader(blobStore),
- indexDefinitions);
+ new NodeStateNodeTypeInfoProvider(nodeStore.getRoot()),
new NodeStateEntryReader(blobStore),
+ indexDefinitions);
fileList = splitter.split();
log.info("Split flat file to result files '{}' is done, took {}
ms", fileList, System.currentTimeMillis() - start);
}
List<FlatFileStore> storeList = new ArrayList<>();
for (File flatFileItem : fileList) {
- FlatFileStore store = new FlatFileStore(blobStore, flatFileItem,
new NodeStateEntryReader(blobStore),
+ FlatFileStore store = new FlatFileStore(blobStore, flatFileItem,
metadataFile, new NodeStateEntryReader(blobStore),
unmodifiableSet(preferredPathElements), algorithm);
storeList.add(store);
}
return storeList;
}
/**
- * Returns the existing list of store files if it can read from system
property OAK_INDEXER_SORTED_FILE_PATH which
- * defines the existing folder where the flat file store files are
present. Will throw an exception if it cannot
+ * Returns the existing list of store files if it can read from system
property OAK_INDEXER_SORTED_FILE_PATH which
+ * defines the existing folder where the flat file store files are
present. Will throw an exception if it cannot
* read or the path in the system property is not a directory.
- * If the system property OAK_INDEXER_SORTED_FILE_PATH in undefined, or it
cannot read relevant files it
+ * If the system property OAK_INDEXER_SORTED_FILE_PATH in undefined, or it
cannot read relevant files it
* initializes the flat file store.
- *
- * @return list of flat files
- * @throws IOException
+ *
+ * @return pair of "list of flat files" and metadata file
+ * @throws IOException
* @throws CompositeException
*/
- private List<File> createdSortedStoreFiles() throws IOException,
CompositeException {
+ private Pair<List<File>, List<File>> createdSortedStoreFiles() throws
IOException, CompositeException {
// Check system property defined path
String sortedFilePath =
System.getProperty(OAK_INDEXER_SORTED_FILE_PATH);
if (StringUtils.isNotBlank(sortedFilePath)) {
File sortedDir = new File(sortedFilePath);
log.info("Attempting to read from provided sorted files directory
[{}] (via system property '{}')",
- sortedDir.getAbsolutePath(), OAK_INDEXER_SORTED_FILE_PATH);
- List<File> files = getFiles(sortedDir);
- if (files != null) {
- return files;
+ sortedDir.getAbsolutePath(), OAK_INDEXER_SORTED_FILE_PATH);
+ // List of storefiles, List of metadatafile
+ Pair<List<File>, List<File>> storeFiles =
getIndexStoreFiles(sortedDir);
+ if (storeFiles != null) {
+ return storeFiles;
}
}
// Initialize the flat file store again
createStoreDir();
- SortStrategy strategy = createSortStrategy(flatFileStoreDir);
+ IndexStoreSortStrategy strategy = createSortStrategy(flatFileStoreDir);
File result = strategy.createSortedStoreFile();
+ File metadata = strategy.createMetadataFile();
entryCount = strategy.getEntryCount();
- return Collections.singletonList(result);
+ return new ImmutablePair<>(Collections.singletonList(result),
Collections.singletonList(metadata));
}
@Nullable
- private List<File> getFiles(File sortedDir) {
+ private Pair<List<File>, List<File>> getIndexStoreFiles(File sortedDir) {
Review Comment:
created an inner class.
--
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]