Search in sources :

Example 1 with FDBDirectory

use of com.apple.foundationdb.record.lucene.directory.FDBDirectory in project fdb-record-layer by FoundationDB.

the class LuceneIndexTest method assertEntriesAndSegmentInfoStoredInCompoundFile.

private static void assertEntriesAndSegmentInfoStoredInCompoundFile(@Nonnull Subspace subspace, @Nonnull FDBRecordContext context, @Nonnull String segment, boolean cleanFiles) {
    try (final FDBDirectory directory = new FDBDirectory(subspace, context)) {
        final FDBLuceneFileReference reference = directory.getFDBLuceneFileReference(segment).join();
        Assertions.assertNotNull(reference);
        Assertions.assertTrue(reference.getEntries().length > 0);
        Assertions.assertTrue(reference.getSegmentInfo().length > 0);
        assertOnlyCompoundFileExisting(subspace, context, directory, cleanFiles);
    }
}
Also used : FDBLuceneFileReference(com.apple.foundationdb.record.lucene.directory.FDBLuceneFileReference) FDBDirectory(com.apple.foundationdb.record.lucene.directory.FDBDirectory)

Example 2 with FDBDirectory

use of com.apple.foundationdb.record.lucene.directory.FDBDirectory in project fdb-record-layer by FoundationDB.

the class LuceneIndexTest method assertOnlyCompoundFileExisting.

private static void assertOnlyCompoundFileExisting(@Nonnull Subspace subspace, @Nonnull FDBRecordContext context, @Nullable FDBDirectory fdbDirectory, boolean cleanFiles) {
    final FDBDirectory directory = fdbDirectory == null ? new FDBDirectory(subspace, context) : fdbDirectory;
    String[] allFiles = directory.listAll();
    for (String file : allFiles) {
        Assertions.assertTrue(FDBDirectory.isCompoundFile(file) || file.startsWith(IndexFileNames.SEGMENTS));
        if (cleanFiles) {
            try {
                directory.deleteFile(file);
            } catch (IOException ex) {
                Assertions.fail("Failed to clean file: " + file);
            }
        }
    }
}
Also used : IOException(java.io.IOException) FDBDirectory(com.apple.foundationdb.record.lucene.directory.FDBDirectory)

Aggregations

FDBDirectory (com.apple.foundationdb.record.lucene.directory.FDBDirectory)2 FDBLuceneFileReference (com.apple.foundationdb.record.lucene.directory.FDBLuceneFileReference)1 IOException (java.io.IOException)1