Search in sources :

Example 1 with ByteBufferInputStream

use of org.apache.hyracks.dataflow.common.comm.util.ByteBufferInputStream in project asterixdb by apache.

the class RecordIdReader method set.

public void set(FrameTupleAccessor accessor, RecordDescriptor inRecDesc) {
    this.tupleAccessor = accessor;
    this.fieldSlotsLength = accessor.getFieldSlotsLength();
    this.inRecDesc = inRecDesc;
    this.bbis = new ByteBufferInputStream();
    this.dis = new DataInputStream(bbis);
}
Also used : ByteBufferInputStream(org.apache.hyracks.dataflow.common.comm.util.ByteBufferInputStream) DataInputStream(java.io.DataInputStream)

Example 2 with ByteBufferInputStream

use of org.apache.hyracks.dataflow.common.comm.util.ByteBufferInputStream in project asterixdb by apache.

the class FrameDebugUtils method prettyPrint.

/**
     * Debugging method
     * They are safe as they don't print records. Printing records
     * using IserializerDeserializer can print incorrect results or throw exceptions.
     * A better way yet would be to use record pointable.
     * @param fta
     * @param recordDescriptor
     * @param prefix
     * @param recordFields
     * @throws IOException
     */
public void prettyPrint(IFrameTupleAccessor fta, RecordDescriptor recordDescriptor, String prefix, int[] recordFields) throws IOException {
    try (ByteBufferInputStream bbis = new ByteBufferInputStream();
        DataInputStream dis = new DataInputStream(bbis)) {
        int tc = fta.getTupleCount();
        StringBuilder sb = new StringBuilder();
        sb.append(prefix).append("TC: " + tc).append("\n");
        for (int i = 0; i < tc; ++i) {
            prettyPrint(fta, recordDescriptor, i, bbis, dis, sb, recordFields);
        }
        System.err.println(sb.toString());
    }
}
Also used : ByteBufferInputStream(org.apache.hyracks.dataflow.common.comm.util.ByteBufferInputStream) DataInputStream(java.io.DataInputStream)

Example 3 with ByteBufferInputStream

use of org.apache.hyracks.dataflow.common.comm.util.ByteBufferInputStream in project asterixdb by apache.

the class FrameTupleAppenderAccessor method prettyPrint.

public void prettyPrint() {
    ByteBufferInputStream bbis = new ByteBufferInputStream();
    DataInputStream dis = new DataInputStream(bbis);
    int tc = getTupleCount();
    System.err.println("TC: " + tc);
    for (int i = 0; i < tc; ++i) {
        prettyPrint(i, bbis, dis);
    }
}
Also used : ByteBufferInputStream(org.apache.hyracks.dataflow.common.comm.util.ByteBufferInputStream) DataInputStream(java.io.DataInputStream)

Example 4 with ByteBufferInputStream

use of org.apache.hyracks.dataflow.common.comm.util.ByteBufferInputStream in project asterixdb by apache.

the class FrameTupleAppenderAccessor method prettyPrint.

public void prettyPrint(int tid) {
    ByteBufferInputStream bbis = new ByteBufferInputStream();
    DataInputStream dis = new DataInputStream(bbis);
    prettyPrint(tid, bbis, dis);
}
Also used : ByteBufferInputStream(org.apache.hyracks.dataflow.common.comm.util.ByteBufferInputStream) DataInputStream(java.io.DataInputStream)

Example 5 with ByteBufferInputStream

use of org.apache.hyracks.dataflow.common.comm.util.ByteBufferInputStream 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)

Aggregations

ByteBufferInputStream (org.apache.hyracks.dataflow.common.comm.util.ByteBufferInputStream)16 DataInputStream (java.io.DataInputStream)14 IOException (java.io.IOException)7 ByteBuffer (java.nio.ByteBuffer)3 IFrameTupleAccessor (org.apache.hyracks.api.comm.IFrameTupleAccessor)3 VSizeFrame (org.apache.hyracks.api.comm.VSizeFrame)2 RecordDescriptor (org.apache.hyracks.api.dataflow.value.RecordDescriptor)2 IHyracksDataset (org.apache.hyracks.api.dataset.IHyracksDataset)2 IHyracksDatasetReader (org.apache.hyracks.api.dataset.IHyracksDatasetReader)2 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)2 HyracksDataset (org.apache.hyracks.client.dataset.HyracksDataset)2 FrameManager (org.apache.hyracks.control.nc.resources.memory.FrameManager)2 FrameTupleAccessor (org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor)2 ResultFrameTupleAccessor (org.apache.hyracks.dataflow.common.comm.io.ResultFrameTupleAccessor)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 BufferedWriter (java.io.BufferedWriter)1 FileWriter (java.io.FileWriter)1 PrintStream (java.io.PrintStream)1 ArrayList (java.util.ArrayList)1