Encapsulate lucene index dir name structure inside LuceneVersionManager.getDir
Instead of expecting every caller to know the folder name structure <name>_<version> and care to pass the underscore as part of the prefix parameter, let the getDir method insert the underscore. Change-Id: I702450b67d78af0e0c5d2808908aaacc27d59586
This commit is contained in:
parent
bee7de7ee4
commit
b37af76beb
|
@ -81,7 +81,7 @@ public class LuceneAccountIndex extends AbstractLuceneIndex<Account.Id, AccountS
|
|||
if (LuceneIndexModule.isInMemoryTest(cfg)) {
|
||||
return new RAMDirectory();
|
||||
}
|
||||
Path indexDir = LuceneVersionManager.getDir(sitePaths, ACCOUNTS + "_", schema);
|
||||
Path indexDir = LuceneVersionManager.getDir(sitePaths, ACCOUNTS, schema);
|
||||
return FSDirectory.open(indexDir);
|
||||
}
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ public class LuceneChangeIndex implements ChangeIndex {
|
|||
static final String UPDATED_SORT_FIELD = sortFieldName(ChangeField.UPDATED);
|
||||
static final String ID_SORT_FIELD = sortFieldName(ChangeField.LEGACY_ID);
|
||||
|
||||
private static final String CHANGES_PREFIX = "changes_";
|
||||
private static final String CHANGES = "changes";
|
||||
private static final String CHANGES_OPEN = "open";
|
||||
private static final String CHANGES_CLOSED = "closed";
|
||||
private static final String ADDED_FIELD = ChangeField.ADDED.getName();
|
||||
|
@ -178,7 +178,7 @@ public class LuceneChangeIndex implements ChangeIndex {
|
|||
new ChangeSubIndex(
|
||||
schema, sitePaths, new RAMDirectory(), "ramClosed", closedConfig, searcherFactory);
|
||||
} else {
|
||||
Path dir = LuceneVersionManager.getDir(sitePaths, CHANGES_PREFIX, schema);
|
||||
Path dir = LuceneVersionManager.getDir(sitePaths, CHANGES, schema);
|
||||
openIndex =
|
||||
new ChangeSubIndex(
|
||||
schema, sitePaths, dir.resolve(CHANGES_OPEN), openConfig, searcherFactory);
|
||||
|
|
|
@ -80,7 +80,7 @@ public class LuceneGroupIndex extends AbstractLuceneIndex<AccountGroup.UUID, Acc
|
|||
if (LuceneIndexModule.isInMemoryTest(cfg)) {
|
||||
return new RAMDirectory();
|
||||
}
|
||||
Path indexDir = LuceneVersionManager.getDir(sitePaths, GROUPS + "_", schema);
|
||||
Path indexDir = LuceneVersionManager.getDir(sitePaths, GROUPS, schema);
|
||||
return FSDirectory.open(indexDir);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,8 +48,8 @@ public class LuceneVersionManager extends AbstractVersionManager implements Life
|
|||
}
|
||||
}
|
||||
|
||||
static Path getDir(SitePaths sitePaths, String prefix, Schema<?> schema) {
|
||||
return sitePaths.index_dir.resolve(String.format("%s%04d", prefix, schema.getVersion()));
|
||||
static Path getDir(SitePaths sitePaths, String name, Schema<?> schema) {
|
||||
return sitePaths.index_dir.resolve(String.format("%s_%04d", name, schema.getVersion()));
|
||||
}
|
||||
|
||||
@Inject
|
||||
|
@ -74,7 +74,7 @@ public class LuceneVersionManager extends AbstractVersionManager implements Life
|
|||
TreeMap<Integer, AbstractVersionManager.Version<V>> versions = new TreeMap<>();
|
||||
for (Schema<V> schema : def.getSchemas().values()) {
|
||||
// This part is Lucene-specific.
|
||||
Path p = getDir(sitePaths, def.getName() + "_", schema);
|
||||
Path p = getDir(sitePaths, def.getName(), schema);
|
||||
boolean isDir = Files.isDirectory(p);
|
||||
if (Files.exists(p) && !isDir) {
|
||||
log.warn("Not a directory: %s", p.toAbsolutePath());
|
||||
|
|
Loading…
Reference in New Issue