use of org.apache.hyracks.api.io.FileReference in project asterixdb by apache.
the class LSMBTreeFileManager 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 < 2) {
throw new HyracksDataException("LSM Btree transaction has less than 2 files :" + files.length);
}
try {
Files.delete(Paths.get(txnFileName));
} catch (IOException e) {
throw new HyracksDataException("Failed to delete transaction lock :" + txnFileName);
}
}
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(BLOOM_FILTER_STRING)) {
bloomFilterFile = new File(dir.getPath() + File.separator + fileName);
} else {
throw new HyracksDataException("unrecognized file found = " + fileName);
}
}
FileReference bTreeFileRef = ioManager.resolveAbsolutePath(bTreeFile.getAbsolutePath());
FileReference bloomFilterFileRef = ioManager.resolveAbsolutePath(bloomFilterFile.getAbsolutePath());
return new LSMComponentFileReferences(bTreeFileRef, null, bloomFilterFileRef);
}
use of org.apache.hyracks.api.io.FileReference in project asterixdb by apache.
the class ExternalBTree method scheduleMerge.
// The only reason to override the following method is that it uses a different context object
// in addition, determining whether or not to keep deleted tuples is different here
@Override
public void scheduleMerge(ILSMIndexOperationContext ctx, ILSMIOOperationCallback callback) throws HyracksDataException {
ExternalBTreeOpContext opCtx = createOpContext(NoOpOperationCallback.INSTANCE, -1);
opCtx.setOperation(IndexOperation.MERGE);
List<ILSMComponent> mergingComponents = ctx.getComponentHolder();
boolean returnDeletedTuples = false;
if (version == 0) {
if (ctx.getComponentHolder().get(ctx.getComponentHolder().size() - 1) != diskComponents.get(diskComponents.size() - 1)) {
returnDeletedTuples = true;
}
} else {
if (ctx.getComponentHolder().get(ctx.getComponentHolder().size() - 1) != secondDiskComponents.get(secondDiskComponents.size() - 1)) {
returnDeletedTuples = true;
}
}
ITreeIndexCursor cursor = new LSMBTreeRangeSearchCursor(opCtx, returnDeletedTuples);
BTree firstBTree = ((LSMBTreeDiskComponent) mergingComponents.get(0)).getBTree();
BTree lastBTree = ((LSMBTreeDiskComponent) mergingComponents.get(mergingComponents.size() - 1)).getBTree();
FileReference firstFile = firstBTree.getFileReference();
FileReference lastFile = lastBTree.getFileReference();
LSMComponentFileReferences relMergeFileRefs = fileManager.getRelMergeFileReference(firstFile.getFile().getName(), lastFile.getFile().getName());
ILSMIndexAccessor accessor = new LSMTreeIndexAccessor(getLsmHarness(), opCtx, cursorFactory);
ioScheduler.scheduleOperation(new LSMBTreeMergeOperation(accessor, mergingComponents, cursor, relMergeFileRefs.getInsertIndexFileReference(), relMergeFileRefs.getBloomFilterFileReference(), callback, fileManager.getBaseDir()));
}
use of org.apache.hyracks.api.io.FileReference in project asterixdb by apache.
the class ExternalBTreeWithBuddy method getMergeTargetFileName.
protected LSMComponentFileReferences getMergeTargetFileName(List<ILSMComponent> mergingDiskComponents) throws HyracksDataException {
BTree firstTree = ((LSMBTreeWithBuddyDiskComponent) mergingDiskComponents.get(0)).getBTree();
BTree lastTree = ((LSMBTreeWithBuddyDiskComponent) mergingDiskComponents.get(mergingDiskComponents.size() - 1)).getBTree();
FileReference firstFile = firstTree.getFileReference();
FileReference lastFile = lastTree.getFileReference();
LSMComponentFileReferences fileRefs = fileManager.getRelMergeFileReference(firstFile.getFile().getName(), lastFile.getFile().getName());
return fileRefs;
}
use of org.apache.hyracks.api.io.FileReference in project asterixdb by apache.
the class ExternalBTreeWithBuddyLocalResource method createInstance.
@Override
public ILSMIndex createInstance(INCServiceContext serviceCtx) throws HyracksDataException {
IIOManager ioManager = serviceCtx.getIoManager();
FileReference file = ioManager.resolve(path);
return LSMBTreeUtil.createExternalBTreeWithBuddy(ioManager, file, storageManager.getBufferCache(serviceCtx), storageManager.getFileMapProvider(serviceCtx), typeTraits, cmpFactories, bloomFilterFalsePositiveRate, mergePolicyFactory.createMergePolicy(mergePolicyProperties, serviceCtx), opTrackerProvider.getOperationTracker(serviceCtx), ioSchedulerProvider.getIoScheduler(serviceCtx), ioOpCallbackFactory.createIoOpCallback(), bloomFilterKeyFields, durable, metadataPageManagerFactory);
}
use of org.apache.hyracks.api.io.FileReference in project asterixdb by apache.
the class LSMBTreeLocalResource method createInstance.
@Override
public ILSMIndex createInstance(INCServiceContext serviceCtx) throws HyracksDataException {
IIOManager ioManager = serviceCtx.getIoManager();
FileReference file = ioManager.resolve(path);
List<IVirtualBufferCache> vbcs = vbcProvider.getVirtualBufferCaches(serviceCtx, file);
return LSMBTreeUtil.createLSMTree(ioManager, vbcs, file, storageManager.getBufferCache(serviceCtx), storageManager.getFileMapProvider(serviceCtx), typeTraits, cmpFactories, bloomFilterKeyFields, bloomFilterFalsePositiveRate, mergePolicyFactory.createMergePolicy(mergePolicyProperties, serviceCtx), opTrackerProvider.getOperationTracker(serviceCtx), ioSchedulerProvider.getIoScheduler(serviceCtx), ioOpCallbackFactory.createIoOpCallback(), isPrimary, filterTypeTraits, filterCmpFactories, btreeFields, filterFields, durable, metadataPageManagerFactory);
}
Aggregations