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);
}
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);
}
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);
}
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");
}
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();
}
Aggregations