Search in sources :

Example 1 with BufferManagerImpl

use of org.sirix.cache.BufferManagerImpl in project sirix by sirixdb.

the class DatabaseImpl method getResourceManager.

// //////////////////////////////////////////////////////////
// END resource name <=> ID handling ////////////////////////
// //////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////
// START DB-Operations //////////////////////////////////////
// //////////////////////////////////////////////////////////
@Override
public synchronized ResourceManager getResourceManager(final ResourceManagerConfiguration resourceManagerConfig) throws SirixException {
    final Path resourceFile = mDBConfig.getFile().resolve(DatabaseConfiguration.DatabasePaths.DATA.getFile()).resolve(resourceManagerConfig.getResource());
    if (!Files.exists(resourceFile)) {
        throw new SirixUsageException("Resource could not be opened (since it was not created?) at location", resourceFile.toString());
    }
    if (mResourceStore.hasOpenResourceManager(resourceFile))
        return mResourceStore.getOpenResourceManager(resourceFile);
    final ResourceConfiguration resourceConfig = ResourceConfiguration.deserialize(resourceFile);
    // Resource of must be associated to this database.
    assert resourceConfig.mPath.getParent().getParent().equals(mDBConfig.getFile());
    if (!mBufferManagers.containsKey(resourceFile))
        mBufferManagers.put(resourceFile, new BufferManagerImpl());
    final ResourceManager resourceManager = mResourceStore.openResource(this, resourceConfig, resourceManagerConfig, mBufferManagers.get(resourceFile), resourceFile);
    return resourceManager;
}
Also used : Path(java.nio.file.Path) BufferManagerImpl(org.sirix.cache.BufferManagerImpl) ResourceManager(org.sirix.api.ResourceManager) SirixUsageException(org.sirix.exception.SirixUsageException) ResourceConfiguration(org.sirix.access.conf.ResourceConfiguration)

Aggregations

Path (java.nio.file.Path)1 ResourceConfiguration (org.sirix.access.conf.ResourceConfiguration)1 ResourceManager (org.sirix.api.ResourceManager)1 BufferManagerImpl (org.sirix.cache.BufferManagerImpl)1 SirixUsageException (org.sirix.exception.SirixUsageException)1