Search in sources :

Example 26 with FileReference

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));
    }
}
Also used : FileReference(org.apache.hyracks.api.io.FileReference) File(java.io.File)

Example 27 with FileReference

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();
}
Also used : FileReference(org.apache.hyracks.api.io.FileReference) RunFileWriter(org.apache.hyracks.dataflow.common.io.RunFileWriter)

Example 28 with FileReference

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;
}
Also used : FileReference(org.apache.hyracks.api.io.FileReference) RunFileWriter(org.apache.hyracks.dataflow.common.io.RunFileWriter)

Example 29 with FileReference

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();
        }
    }
}
Also used : DataOutput(java.io.DataOutput) TreeIndexStatsGatherer(org.apache.hyracks.storage.am.common.util.TreeIndexStatsGatherer) TreeIndexStats(org.apache.hyracks.storage.am.common.util.TreeIndexStats) ArrayTupleBuilder(org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder) IIOManager(org.apache.hyracks.api.io.IIOManager) VSizeFrame(org.apache.hyracks.api.comm.VSizeFrame) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) LocalResource(org.apache.hyracks.storage.common.LocalResource) IFileMapProvider(org.apache.hyracks.storage.common.file.IFileMapProvider) FrameTupleAppender(org.apache.hyracks.dataflow.common.comm.io.FrameTupleAppender) ITreeIndex(org.apache.hyracks.storage.am.common.api.ITreeIndex) FileReference(org.apache.hyracks.api.io.FileReference) IBufferCache(org.apache.hyracks.storage.common.buffercache.IBufferCache)

Example 30 with FileReference

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());
}
Also used : BTree(org.apache.hyracks.storage.am.btree.impls.BTree) 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