Search in sources :

Example 1 with FrameManager

use of org.apache.hyracks.control.nc.resources.memory.FrameManager in project asterixdb by apache.

the class FrameFixedFieldTupleAppenderTest method testResetShouldWork.

@Test
public void testResetShouldWork() throws HyracksDataException {
    testAppendFieldShouldSucceed();
    appender.reset(new VSizeFrame(new FrameManager(TEST_FRAME_SIZE)), true);
    testAppendFieldShouldSucceed();
}
Also used : FrameManager(org.apache.hyracks.control.nc.resources.memory.FrameManager) VSizeFrame(org.apache.hyracks.api.comm.VSizeFrame) Test(org.junit.Test)

Example 2 with FrameManager

use of org.apache.hyracks.control.nc.resources.memory.FrameManager in project asterixdb by apache.

the class AbstractIntegrationTest method readResults.

protected List<String> readResults(JobSpecification spec, JobId jobId, ResultSetId resultSetId) throws Exception {
    int nReaders = 1;
    IFrameTupleAccessor frameTupleAccessor = new ResultFrameTupleAccessor();
    IHyracksDataset hyracksDataset = new HyracksDataset(hcc, spec.getFrameSize(), nReaders);
    IHyracksDatasetReader reader = hyracksDataset.createReader(jobId, resultSetId);
    List<String> resultRecords = new ArrayList<>();
    ByteBufferInputStream bbis = new ByteBufferInputStream();
    FrameManager resultDisplayFrameMgr = new FrameManager(spec.getFrameSize());
    VSizeFrame frame = new VSizeFrame(resultDisplayFrameMgr);
    int readSize = reader.read(frame);
    while (readSize > 0) {
        try {
            frameTupleAccessor.reset(frame.getBuffer());
            for (int tIndex = 0; tIndex < frameTupleAccessor.getTupleCount(); tIndex++) {
                int start = frameTupleAccessor.getTupleStartOffset(tIndex);
                int length = frameTupleAccessor.getTupleEndOffset(tIndex) - start;
                bbis.setByteBuffer(frame.getBuffer(), start);
                byte[] recordBytes = new byte[length];
                bbis.read(recordBytes, 0, length);
                resultRecords.add(new String(recordBytes, 0, length));
            }
        } finally {
            bbis.close();
        }
        readSize = reader.read(frame);
    }
    return resultRecords;
}
Also used : ArrayList(java.util.ArrayList) ByteBufferInputStream(org.apache.hyracks.dataflow.common.comm.util.ByteBufferInputStream) VSizeFrame(org.apache.hyracks.api.comm.VSizeFrame) HyracksDataset(org.apache.hyracks.client.dataset.HyracksDataset) IHyracksDataset(org.apache.hyracks.api.dataset.IHyracksDataset) IFrameTupleAccessor(org.apache.hyracks.api.comm.IFrameTupleAccessor) FrameManager(org.apache.hyracks.control.nc.resources.memory.FrameManager) ResultFrameTupleAccessor(org.apache.hyracks.dataflow.common.comm.io.ResultFrameTupleAccessor) IHyracksDatasetReader(org.apache.hyracks.api.dataset.IHyracksDatasetReader) IHyracksDataset(org.apache.hyracks.api.dataset.IHyracksDataset)

Example 3 with FrameManager

use of org.apache.hyracks.control.nc.resources.memory.FrameManager in project asterixdb by apache.

the class SimpleSerializableHashTableTest method setup.

@Before
public void setup() throws HyracksDataException {
    ctx = new FrameManager(256);
    nsTable = new SimpleSerializableHashTable(NUM_PART, ctx);
}
Also used : FrameManager(org.apache.hyracks.control.nc.resources.memory.FrameManager) Before(org.junit.Before)

Example 4 with FrameManager

use of org.apache.hyracks.control.nc.resources.memory.FrameManager in project asterixdb by apache.

the class SerializableHashTableTest method setup.

@Before
public void setup() throws HyracksDataException {
    ctx = new FrameManager(256);
    framePool = new DeallocatableFramePool(ctx, ctx.getInitialFrameSize() * 2048);
    bufferManager = new FramePoolBackedFrameBufferManager(framePool);
    nsTable = new SerializableHashTable(NUM_PART, ctx, bufferManager);
}
Also used : DeallocatableFramePool(org.apache.hyracks.dataflow.std.buffermanager.DeallocatableFramePool) IDeallocatableFramePool(org.apache.hyracks.dataflow.std.buffermanager.IDeallocatableFramePool) FramePoolBackedFrameBufferManager(org.apache.hyracks.dataflow.std.buffermanager.FramePoolBackedFrameBufferManager) FrameManager(org.apache.hyracks.control.nc.resources.memory.FrameManager) Before(org.junit.Before)

Example 5 with FrameManager

use of org.apache.hyracks.control.nc.resources.memory.FrameManager in project asterixdb by apache.

the class AbstractMultiNCIntegrationTest method runTest.

protected void runTest(JobSpecification spec) throws Exception {
    if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.info(spec.toJSON().asText());
    }
    JobId jobId = hcc.startJob(spec, EnumSet.of(JobFlag.PROFILE_RUNTIME));
    if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.info(jobId.toString());
    }
    int nReaders = 1;
    FrameManager resultDisplayFrameMgr = new FrameManager(spec.getFrameSize());
    VSizeFrame resultFrame = new VSizeFrame(resultDisplayFrameMgr);
    IFrameTupleAccessor frameTupleAccessor = new ResultFrameTupleAccessor();
    if (!spec.getResultSetIds().isEmpty()) {
        IHyracksDataset hyracksDataset = new HyracksDataset(hcc, spec.getFrameSize(), nReaders);
        IHyracksDatasetReader reader = hyracksDataset.createReader(jobId, spec.getResultSetIds().get(0));
        ObjectMapper om = new ObjectMapper();
        ArrayNode resultRecords = om.createArrayNode();
        ByteBufferInputStream bbis = new ByteBufferInputStream();
        int readSize = reader.read(resultFrame);
        while (readSize > 0) {
            try {
                frameTupleAccessor.reset(resultFrame.getBuffer());
                for (int tIndex = 0; tIndex < frameTupleAccessor.getTupleCount(); tIndex++) {
                    int start = frameTupleAccessor.getTupleStartOffset(tIndex);
                    int length = frameTupleAccessor.getTupleEndOffset(tIndex) - start;
                    bbis.setByteBuffer(resultFrame.getBuffer(), start);
                    byte[] recordBytes = new byte[length];
                    bbis.read(recordBytes, 0, length);
                    resultRecords.add(new String(recordBytes, 0, length));
                }
            } finally {
                try {
                    bbis.close();
                } catch (IOException e) {
                    throw new HyracksDataException(e);
                }
            }
            readSize = reader.read(resultFrame);
        }
    }
    hcc.waitForCompletion(jobId);
    dumpOutputFiles();
}
Also used : ByteBufferInputStream(org.apache.hyracks.dataflow.common.comm.util.ByteBufferInputStream) IOException(java.io.IOException) VSizeFrame(org.apache.hyracks.api.comm.VSizeFrame) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) HyracksDataset(org.apache.hyracks.client.dataset.HyracksDataset) IHyracksDataset(org.apache.hyracks.api.dataset.IHyracksDataset) IFrameTupleAccessor(org.apache.hyracks.api.comm.IFrameTupleAccessor) FrameManager(org.apache.hyracks.control.nc.resources.memory.FrameManager) ResultFrameTupleAccessor(org.apache.hyracks.dataflow.common.comm.io.ResultFrameTupleAccessor) IHyracksDatasetReader(org.apache.hyracks.api.dataset.IHyracksDatasetReader) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) IHyracksDataset(org.apache.hyracks.api.dataset.IHyracksDataset) JobId(org.apache.hyracks.api.job.JobId) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

FrameManager (org.apache.hyracks.control.nc.resources.memory.FrameManager)7 VSizeFrame (org.apache.hyracks.api.comm.VSizeFrame)5 IFrameTupleAccessor (org.apache.hyracks.api.comm.IFrameTupleAccessor)3 Before (org.junit.Before)3 IHyracksDataset (org.apache.hyracks.api.dataset.IHyracksDataset)2 IHyracksDatasetReader (org.apache.hyracks.api.dataset.IHyracksDatasetReader)2 HyracksDataset (org.apache.hyracks.client.dataset.HyracksDataset)2 ResultFrameTupleAccessor (org.apache.hyracks.dataflow.common.comm.io.ResultFrameTupleAccessor)2 ByteBufferInputStream (org.apache.hyracks.dataflow.common.comm.util.ByteBufferInputStream)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 IFrame (org.apache.hyracks.api.comm.IFrame)1 IFrameTupleAppender (org.apache.hyracks.api.comm.IFrameTupleAppender)1 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)1 JobId (org.apache.hyracks.api.job.JobId)1 FrameFixedFieldAppender (org.apache.hyracks.dataflow.common.comm.io.FrameFixedFieldAppender)1 FrameTupleAccessor (org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor)1 FrameTupleAppender (org.apache.hyracks.dataflow.common.comm.io.FrameTupleAppender)1