Search in sources :

Example 36 with FileReference

use of org.apache.hyracks.api.io.FileReference in project asterixdb by apache.

the class ExternalBTreeLocalResource method createInstance.

@Override
public ILSMIndex createInstance(INCServiceContext serviceCtx) throws HyracksDataException {
    IIOManager ioManager = serviceCtx.getIoManager();
    FileReference file = ioManager.resolve(path);
    return LSMBTreeUtil.createExternalBTree(ioManager, file, storageManager.getBufferCache(serviceCtx), storageManager.getFileMapProvider(serviceCtx), typeTraits, cmpFactories, bloomFilterKeyFields, bloomFilterFalsePositiveRate, mergePolicyFactory.createMergePolicy(mergePolicyProperties, serviceCtx), opTrackerProvider.getOperationTracker(serviceCtx), ioSchedulerProvider.getIoScheduler(serviceCtx), ioOpCallbackFactory.createIoOpCallback(), durable, metadataPageManagerFactory);
}
Also used : FileReference(org.apache.hyracks.api.io.FileReference) IIOManager(org.apache.hyracks.api.io.IIOManager)

Example 37 with FileReference

use of org.apache.hyracks.api.io.FileReference in project asterixdb by apache.

the class BTreeResource method createInstance.

@Override
public IIndex createInstance(INCServiceContext ctx) throws HyracksDataException {
    IBufferCache bufferCache = storageManager.getBufferCache(ctx);
    IIOManager ioManager = ctx.getIoManager();
    FileReference resourceRef = ioManager.resolve(path);
    return BTreeUtils.createBTree(bufferCache, storageManager.getFileMapProvider(ctx), typeTraits, comparatorFactories, BTreeLeafFrameType.REGULAR_NSM, resourceRef, pageManagerFactory.createPageManager(bufferCache));
}
Also used : FileReference(org.apache.hyracks.api.io.FileReference) IIOManager(org.apache.hyracks.api.io.IIOManager) IBufferCache(org.apache.hyracks.storage.common.buffercache.IBufferCache)

Example 38 with FileReference

use of org.apache.hyracks.api.io.FileReference in project asterixdb by apache.

the class IndexDataflowHelperFactory method create.

@Override
public IIndexDataflowHelper create(IHyracksTaskContext ctx, int partition) throws HyracksDataException {
    FileSplit fileSplit = fileSplitProvider.getFileSplits()[partition];
    FileReference resourceRef = fileSplit.getFileReference(ctx.getIoManager());
    return new IndexDataflowHelper(ctx.getJobletContext().getServiceContext(), storageMgr, resourceRef);
}
Also used : FileSplit(org.apache.hyracks.api.io.FileSplit) FileReference(org.apache.hyracks.api.io.FileReference) IIndexDataflowHelper(org.apache.hyracks.storage.am.common.api.IIndexDataflowHelper)

Example 39 with FileReference

use of org.apache.hyracks.api.io.FileReference in project asterixdb by apache.

the class PersistentLocalResourceRepository method insert.

@Override
public synchronized void insert(LocalResource resource) throws HyracksDataException {
    String relativePath = getFileName(resource.getPath());
    FileReference resourceFile = ioManager.resolve(relativePath);
    if (resourceFile.getFile().exists()) {
        throw new HyracksDataException("Duplicate resource: " + resourceFile.getAbsolutePath());
    } else {
        resourceFile.getFile().getParentFile().mkdirs();
    }
    resourceCache.put(resource.getPath(), resource);
    try (FileOutputStream fos = new FileOutputStream(resourceFile.getFile());
        ObjectOutputStream oosToFos = new ObjectOutputStream(fos)) {
        oosToFos.writeObject(resource);
        oosToFos.flush();
    } catch (IOException e) {
        throw new HyracksDataException(e);
    }
    //if replication enabled, send resource metadata info to remote nodes
    if (isReplicationEnabled) {
        createReplicationJob(ReplicationOperation.REPLICATE, resourceFile);
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) FileReference(org.apache.hyracks.api.io.FileReference) ObjectOutputStream(java.io.ObjectOutputStream) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Example 40 with FileReference

use of org.apache.hyracks.api.io.FileReference in project asterixdb by apache.

the class TransientFileMapManager method unregisterFile.

@Override
public void unregisterFile(int fileId) throws HyracksDataException {
    FileReference fileRef = id2nameMap.remove(fileId);
    name2IdMap.remove(fileRef);
}
Also used : FileReference(org.apache.hyracks.api.io.FileReference)

Aggregations

FileReference (org.apache.hyracks.api.io.FileReference)52 IIOManager (org.apache.hyracks.api.io.IIOManager)16 File (java.io.File)10 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)9 IBufferCache (org.apache.hyracks.storage.common.buffercache.IBufferCache)7 IOException (java.io.IOException)6 LSMComponentFileReferences (org.apache.hyracks.storage.am.lsm.common.impls.LSMComponentFileReferences)6 IFileMapProvider (org.apache.hyracks.storage.common.file.IFileMapProvider)6 IInvertedListBuilder (org.apache.hyracks.storage.am.lsm.invertedindex.api.IInvertedListBuilder)5 Test (org.junit.Test)5 FilenameFilter (java.io.FilenameFilter)4 IVirtualBufferCache (org.apache.hyracks.storage.am.lsm.common.api.IVirtualBufferCache)4 ArrayList (java.util.ArrayList)3 IODeviceHandle (org.apache.hyracks.api.io.IODeviceHandle)3 BTree (org.apache.hyracks.storage.am.btree.impls.BTree)3 LocalResource (org.apache.hyracks.storage.common.LocalResource)3 FileOutputStream (java.io.FileOutputStream)2 HashMap (java.util.HashMap)2 IBinaryComparatorFactory (org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory)2 ITypeTraits (org.apache.hyracks.api.dataflow.value.ITypeTraits)2