use of org.apache.hyracks.api.io.FileReference in project asterixdb by apache.
the class TestLsmIndexFileManager method cleanupAndGetValidFilesInternal.
@Override
protected void cleanupAndGetValidFilesInternal(FilenameFilter filter, TreeIndexFactory<? extends ITreeIndex> treeFactory, ArrayList<ComparableFileName> allFiles) throws HyracksDataException {
File dir = new File(baseDir);
String[] files = dir.list(filter);
for (String fileName : files) {
File file = new File(dir.getPath() + File.separator + fileName);
FileReference fileRef = ioManager.resolveAbsolutePath(file.getAbsolutePath());
allFiles.add(new ComparableFileName(fileRef));
}
}
use of org.apache.hyracks.api.io.FileReference in project asterixdb by apache.
the class MaterializerTaskState method open.
public void open(IHyracksTaskContext ctx) throws HyracksDataException {
FileReference file = ctx.getJobletContext().createManagedWorkspaceFile(MaterializerTaskState.class.getSimpleName());
out = new RunFileWriter(file, ctx.getIoManager());
out.open();
}
use of org.apache.hyracks.api.io.FileReference in project asterixdb by apache.
the class OptimizedHybridHashJoin method getSpillWriterOrCreateNewOneIfNotExist.
private RunFileWriter getSpillWriterOrCreateNewOneIfNotExist(int pid, SIDE whichSide) throws HyracksDataException {
RunFileWriter[] runFileWriters = null;
String refName = null;
switch(whichSide) {
case BUILD:
runFileWriters = buildRFWriters;
refName = buildRelName;
break;
case PROBE:
refName = probeRelName;
runFileWriters = probeRFWriters;
break;
}
RunFileWriter writer = runFileWriters[pid];
if (writer == null) {
FileReference file = ctx.getJobletContext().createManagedWorkspaceFile(refName);
writer = new RunFileWriter(file, ctx.getIoManager());
writer.open();
runFileWriters[pid] = writer;
}
return writer;
}
use of org.apache.hyracks.api.io.FileReference in project asterixdb by apache.
the class TreeIndexStatsOperatorNodePushable method initialize.
@Override
public void initialize() throws HyracksDataException {
treeIndexHelper.open();
ITreeIndex treeIndex = (ITreeIndex) treeIndexHelper.getIndexInstance();
try {
writer.open();
IBufferCache bufferCache = storageManager.getBufferCache(ctx.getJobletContext().getServiceContext());
IFileMapProvider fileMapProvider = storageManager.getFileMapProvider(ctx.getJobletContext().getServiceContext());
LocalResource resource = treeIndexHelper.getResource();
IIOManager ioManager = ctx.getIoManager();
FileReference fileRef = ioManager.resolve(resource.getPath());
int indexFileId = fileMapProvider.lookupFileId(fileRef);
TreeIndexStatsGatherer statsGatherer = new TreeIndexStatsGatherer(bufferCache, treeIndex.getPageManager(), indexFileId, treeIndex.getRootPageId());
TreeIndexStats stats = statsGatherer.gatherStats(treeIndex.getLeafFrameFactory().createFrame(), treeIndex.getInteriorFrameFactory().createFrame(), treeIndex.getPageManager().createMetadataFrame());
// Write the stats output as a single string field.
FrameTupleAppender appender = new FrameTupleAppender(new VSizeFrame(ctx));
ArrayTupleBuilder tb = new ArrayTupleBuilder(1);
DataOutput dos = tb.getDataOutput();
tb.reset();
utf8SerDer.serialize(stats.toString(), dos);
tb.addFieldEndOffset();
if (!appender.append(tb.getFieldEndOffsets(), tb.getByteArray(), 0, tb.getSize())) {
throw new HyracksDataException("Record size (" + tb.getSize() + ") larger than frame size (" + appender.getBuffer().capacity() + ")");
}
appender.write(writer, false);
} catch (Exception e) {
writer.fail();
throw new HyracksDataException(e);
} finally {
try {
writer.close();
} finally {
treeIndexHelper.close();
}
}
}
use of org.apache.hyracks.api.io.FileReference in project asterixdb by apache.
the class LSMBTree method getMergeFileReferences.
@Override
protected LSMComponentFileReferences getMergeFileReferences(ILSMDiskComponent firstComponent, ILSMDiskComponent lastComponent) throws HyracksDataException {
BTree firstBTree = ((LSMBTreeDiskComponent) firstComponent).getBTree();
BTree lastBTree = ((LSMBTreeDiskComponent) lastComponent).getBTree();
FileReference firstFile = firstBTree.getFileReference();
FileReference lastFile = lastBTree.getFileReference();
return fileManager.getRelMergeFileReference(firstFile.getFile().getName(), lastFile.getFile().getName());
}
Aggregations