Search in sources :

Example 11 with FileReference

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

the class LSMRTreeFileManager method getTransactionFileReferenceForCommit.

@Override
public LSMComponentFileReferences getTransactionFileReferenceForCommit() throws HyracksDataException {
    FilenameFilter transactionFilter;
    File dir = new File(baseDir);
    String[] files = dir.list(transactionFileNameFilter);
    if (files.length == 0) {
        return null;
    }
    if (files.length != 1) {
        throw new HyracksDataException("More than one transaction lock found:" + files.length);
    } else {
        transactionFilter = getTransactionFileFilter(true);
        String txnFileName = dir.getPath() + File.separator + files[0];
        // get the actual transaction files
        files = dir.list(transactionFilter);
        if (files.length < 3) {
            throw new HyracksDataException("LSM Rtree transaction has less than 3 files :" + files.length);
        }
        try {
            Files.delete(Paths.get(txnFileName));
        } catch (IOException e) {
            throw new HyracksDataException("Failed to delete transaction lock :" + txnFileName);
        }
    }
    File rTreeFile = null;
    File bTreeFile = null;
    File bloomFilterFile = null;
    for (String fileName : files) {
        if (fileName.endsWith(BTREE_STRING)) {
            bTreeFile = new File(dir.getPath() + File.separator + fileName);
        } else if (fileName.endsWith(RTREE_STRING)) {
            rTreeFile = new File(dir.getPath() + File.separator + fileName);
        } else if (fileName.endsWith(BLOOM_FILTER_STRING)) {
            bloomFilterFile = new File(dir.getPath() + File.separator + fileName);
        } else {
            throw new HyracksDataException("unrecognized file found = " + fileName);
        }
    }
    FileReference rTreeFileRef = ioManager.resolveAbsolutePath(rTreeFile.getAbsolutePath());
    FileReference bTreeFileRef = ioManager.resolveAbsolutePath(bTreeFile.getAbsolutePath());
    FileReference bloomFilterFileRef = ioManager.resolveAbsolutePath(bloomFilterFile.getAbsolutePath());
    return new LSMComponentFileReferences(rTreeFileRef, bTreeFileRef, bloomFilterFileRef);
}
Also used : FilenameFilter(java.io.FilenameFilter) IOException(java.io.IOException) FileReference(org.apache.hyracks.api.io.FileReference) File(java.io.File) LSMComponentFileReferences(org.apache.hyracks.storage.am.lsm.common.impls.LSMComponentFileReferences) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Example 12 with FileReference

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

the class RTreeResource method createInstance.

@Override
public IIndex createInstance(INCServiceContext ctx) throws HyracksDataException {
    IIOManager ioManager = ctx.getIoManager();
    FileReference resourceRef = ioManager.resolve(path);
    return RTreeUtils.createRTree(storageManager.getBufferCache(ctx), storageManager.getFileMapProvider(ctx), typeTraits, valueProviderFactories, comparatorFactories, rtreePolicyType, resourceRef, false, pageManagerFactory);
}
Also used : FileReference(org.apache.hyracks.api.io.FileReference) IIOManager(org.apache.hyracks.api.io.IIOManager)

Example 13 with FileReference

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

the class IOManager method resolveAbsolutePath.

@Override
public FileReference resolveAbsolutePath(String path) throws HyracksDataException {
    IODeviceHandle devHandle = getDevice(path);
    if (devHandle == null) {
        throw HyracksDataException.create(ErrorCode.FILE_WITH_ABSOULTE_PATH_NOT_WITHIN_ANY_IO_DEVICE, path);
    }
    String relativePath = devHandle.getRelativePath(path);
    return new FileReference(devHandle, relativePath);
}
Also used : IODeviceHandle(org.apache.hyracks.api.io.IODeviceHandle) FileReference(org.apache.hyracks.api.io.FileReference)

Example 14 with FileReference

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

the class ExternalDatasetIndexesCommitOperatorDescriptor method performOpOnIndex.

@Override
protected void performOpOnIndex(IIndexDataflowHelper indexHelper, IHyracksTaskContext ctx) throws HyracksDataException {
    String path = indexHelper.getResource().getPath();
    IIOManager ioManager = ctx.getIoManager();
    FileReference file = ioManager.resolve(path);
    LOGGER.warn("performing the operation on " + file.getFile().getAbsolutePath());
    // Get index
    IIndex index = indexHelper.getIndexInstance();
    // commit transaction
    ((ITwoPCIndex) index).commitTransaction();
    LOGGER.warn("operation on " + file.getFile().getAbsolutePath() + " Succeded");
}
Also used : IIndex(org.apache.hyracks.storage.common.IIndex) FileReference(org.apache.hyracks.api.io.FileReference) IIOManager(org.apache.hyracks.api.io.IIOManager) ITwoPCIndex(org.apache.hyracks.storage.am.lsm.common.api.ITwoPCIndex)

Example 15 with FileReference

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

the class ExternalDatasetIndexesRecoverOperatorDescriptor method performOpOnIndex.

@Override
protected void performOpOnIndex(IIndexDataflowHelper indexDataflowHelper, IHyracksTaskContext ctx) throws HyracksDataException {
    String path = indexDataflowHelper.getResource().getPath();
    IIOManager ioManager = ctx.getIoManager();
    FileReference file = ioManager.resolve(path);
    AbortRecoverLSMIndexFileManager fileManager = new AbortRecoverLSMIndexFileManager(ctx.getIoManager(), file);
    fileManager.recoverTransaction();
}
Also used : AbortRecoverLSMIndexFileManager(org.apache.hyracks.storage.am.lsm.common.impls.AbortRecoverLSMIndexFileManager) FileReference(org.apache.hyracks.api.io.FileReference) IIOManager(org.apache.hyracks.api.io.IIOManager)

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