Search in sources :

Example 71 with ODatabaseDocumentInternal

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);
            }
        }
    }
}
Also used : DirectoryTaxonomyWriter(org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter) ODatabaseDocumentInternal(com.orientechnologies.orient.core.db.ODatabaseDocumentInternal) RAMDirectory(org.apache.lucene.store.RAMDirectory) Directory(org.apache.lucene.store.Directory) NIOFSDirectory(org.apache.lucene.store.NIOFSDirectory)

Example 72 with ODatabaseDocumentInternal

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");
}
Also used : ControlledRealTimeReopenThread(org.apache.lucene.search.ControlledRealTimeReopenThread) TrackingIndexWriter(org.apache.lucene.index.TrackingIndexWriter) IndexWriter(org.apache.lucene.index.IndexWriter) TrackingIndexWriter(org.apache.lucene.index.TrackingIndexWriter) OLocalPaginatedStorage(com.orientechnologies.orient.core.storage.impl.local.paginated.OLocalPaginatedStorage) SearcherManager(org.apache.lucene.search.SearcherManager) OAbstractPaginatedStorage(com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage) File(java.io.File) ODatabaseDocumentInternal(com.orientechnologies.orient.core.db.ODatabaseDocumentInternal) RAMDirectory(org.apache.lucene.store.RAMDirectory) RAMDirectory(org.apache.lucene.store.RAMDirectory) Directory(org.apache.lucene.store.Directory) NIOFSDirectory(org.apache.lucene.store.NIOFSDirectory)

Example 73 with ODatabaseDocumentInternal

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();
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) OStorageRemote(com.orientechnologies.orient.client.remote.OStorageRemote) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) OCommandOutputListener(com.orientechnologies.orient.core.command.OCommandOutputListener) ODatabaseDocumentInternal(com.orientechnologies.orient.core.db.ODatabaseDocumentInternal) Test(org.junit.Test)

Example 74 with ODatabaseDocumentInternal

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();
}
Also used : OStorage(com.orientechnologies.orient.core.storage.OStorage) OStorageConfiguration(com.orientechnologies.orient.core.config.OStorageConfiguration) ODatabaseDocumentInternal(com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)

Example 75 with ODatabaseDocumentInternal

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;
}
Also used : OStorage(com.orientechnologies.orient.core.storage.OStorage) OAbstractPaginatedStorage(com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage) ODatabaseDocumentInternal(com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)

Aggregations

ODatabaseDocumentInternal (com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)139 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)42 OStorage (com.orientechnologies.orient.core.storage.OStorage)31 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)26 OStorageProxy (com.orientechnologies.orient.core.storage.OStorageProxy)20 OAutoshardedStorage (com.orientechnologies.orient.core.storage.OAutoshardedStorage)18 OCommandExecutionException (com.orientechnologies.orient.core.exception.OCommandExecutionException)17 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)16 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)14 ORID (com.orientechnologies.orient.core.id.ORID)13 IOException (java.io.IOException)13 OException (com.orientechnologies.common.exception.OException)12 ORecordId (com.orientechnologies.orient.core.id.ORecordId)11 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)10 OSchemaException (com.orientechnologies.orient.core.exception.OSchemaException)10 ORecord (com.orientechnologies.orient.core.record.ORecord)7 OMetadataInternal (com.orientechnologies.orient.core.metadata.OMetadataInternal)6 OCommandRequestText (com.orientechnologies.orient.core.command.OCommandRequestText)5 ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)5 ODatabaseException (com.orientechnologies.orient.core.exception.ODatabaseException)5