use of com.orientechnologies.orient.core.db.ODatabaseDocumentInternal in project orientdb by orientechnologies.
the class OLuceneFacetManager method buildFacetIndexIfNeeded.
protected void buildFacetIndexIfNeeded() throws IOException {
if (metadata != null && metadata.containsField(FACET_FIELDS)) {
ODatabaseDocumentInternal database = owner.getDatabase();
Iterable<String> iterable = metadata.field(FACET_FIELDS);
if (iterable != null) {
Directory dir = getTaxDirectory(database);
taxonomyWriter = new DirectoryTaxonomyWriter(dir, IndexWriterConfig.OpenMode.CREATE_OR_APPEND);
for (String s : iterable) {
facetField = s;
// facetField = "facet_" + s;
// facetDim = s;
// config.setIndexFieldName(s, "facet_" + s);
config.setHierarchical(s, true);
}
}
}
}
use of com.orientechnologies.orient.core.db.ODatabaseDocumentInternal in project orientdb by orientechnologies.
the class OLuceneStorage method reOpen.
private void reOpen() throws IOException {
if (mgrWriter != null) {
OLogManager.instance().info(this, "index storage is open don't reopen");
return;
}
ODatabaseDocumentInternal database = ODatabaseRecordThreadLocal.INSTANCE.get();
final OAbstractPaginatedStorage storageLocalAbstract = (OAbstractPaginatedStorage) database.getStorage().getUnderlying();
Directory dir = null;
if (storageLocalAbstract instanceof OLocalPaginatedStorage) {
String pathname = getIndexPath((OLocalPaginatedStorage) storageLocalAbstract);
OLogManager.instance().info(this, "Opening NIOFS Lucene db=%s, path=%s", database.getName(), pathname);
dir = NIOFSDirectory.open(new File(pathname).toPath());
} else {
OLogManager.instance().info(this, "Opening RAM Lucene index db=%s", database.getName());
dir = new RAMDirectory();
}
final IndexWriter indexWriter = createIndexWriter(dir);
mgrWriter = new TrackingIndexWriter(indexWriter);
searcherManager = new SearcherManager(indexWriter, true, null);
if (nrt != null) {
nrt.close();
}
nrt = new ControlledRealTimeReopenThread(mgrWriter, searcherManager, 60.00, 0.1);
nrt.setDaemon(true);
nrt.start();
flush();
OLogManager.instance().info(this, "REOPEN DONE");
}
use of com.orientechnologies.orient.core.db.ODatabaseDocumentInternal in project orientdb by orientechnologies.
the class ORemoteImportTest method testImport.
@Test
public void testImport() throws UnsupportedEncodingException {
ODatabaseDocumentInternal db = new ODatabaseDocumentTx("remote:localhost/" + ORemoteImportTest.class.getSimpleName());
db.open("admin", "admin");
try {
String content = "{\"records\": [{\"@type\": \"d\", \"@rid\": \"#9:0\",\"@version\": 1,\"@class\": \"V\"}]}";
OStorageRemote storage = (OStorageRemote) db.getStorage();
final StringBuffer buff = new StringBuffer();
storage.importDatabase("-merge=true", new ByteArrayInputStream(content.getBytes("UTF8")), "data.json", new OCommandOutputListener() {
@Override
public void onMessage(String iText) {
buff.append(iText);
}
});
assertTrue(buff.toString().contains("Database import completed"));
} finally {
db.close();
}
}
use of com.orientechnologies.orient.core.db.ODatabaseDocumentInternal in project orientdb by orientechnologies.
the class OIndexManagerAbstract method getServerLocale.
protected Locale getServerLocale() {
ODatabaseDocumentInternal db = getDatabase();
OStorage storage = db.getStorage();
OStorageConfiguration configuration = storage.getConfiguration();
return configuration.getLocaleInstance();
}
use of com.orientechnologies.orient.core.db.ODatabaseDocumentInternal in project orientdb by orientechnologies.
the class OIndexManagerShared method autoRecreateIndexesAfterCrash.
public boolean autoRecreateIndexesAfterCrash() {
if (rebuildCompleted)
return false;
final ODatabaseDocumentInternal database = ODatabaseRecordThreadLocal.INSTANCE.get();
final OStorage storage = database.getStorage().getUnderlying();
if (storage instanceof OAbstractPaginatedStorage) {
OAbstractPaginatedStorage paginatedStorage = (OAbstractPaginatedStorage) storage;
return paginatedStorage.wereDataRestoredAfterOpen() && paginatedStorage.wereNonTxOperationsPerformedInPreviousOpen();
}
return false;
}
Aggregations