Search in sources :

Example 26 with HyracksDataException

use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.

the class PersistentLocalResourceRepository method getIndexFileRef.

public IndexFileProperties getIndexFileRef(String absoluteFilePath) throws HyracksDataException {
    //TODO pass relative path
    final String[] tokens = absoluteFilePath.split(File.separator);
    if (tokens.length < 5) {
        throw new HyracksDataException("Invalid file format");
    }
    String fileName = tokens[tokens.length - 1];
    String index = tokens[tokens.length - 2];
    String dataverse = tokens[tokens.length - 3];
    String partition = tokens[tokens.length - 4];
    int partitionId = StoragePathUtil.getPartitionNumFromName(partition);
    String relativePath = getLocalResourceRelativePath(absoluteFilePath);
    final LocalResource lr = get(relativePath);
    int datasetId = lr == null ? -1 : ((DatasetLocalResource) lr.getResource()).getDatasetId();
    return new IndexFileProperties(partitionId, dataverse, index, fileName, datasetId);
}
Also used : IndexFileProperties(org.apache.asterix.common.storage.IndexFileProperties) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) DatasetLocalResource(org.apache.asterix.common.dataflow.DatasetLocalResource) LocalResource(org.apache.hyracks.storage.common.LocalResource)

Example 27 with HyracksDataException

use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.

the class PersistentLocalResourceRepository method createReplicationJob.

private void createReplicationJob(ReplicationOperation operation, FileReference fileRef) throws HyracksDataException {
    /**
         * Durable resources path format:
         * /partition/dataverse/idx/fileName
         * Temporary resources path format:
         * /partition/TEMP_DATASETS_STORAGE_FOLDER/dataverse/idx/fileName
         */
    String[] fileNameTokens = fileRef.getAbsolutePath().split(File.separator);
    String partitionDir = fileNameTokens[fileNameTokens.length - 4];
    //exclude temporary datasets resources
    if (!partitionDir.equals(StoragePathUtil.TEMP_DATASETS_STORAGE_FOLDER)) {
        filesToBeReplicated.clear();
        filesToBeReplicated.add(fileRef.getAbsolutePath());
        ReplicationJob job = new ReplicationJob(ReplicationJobType.METADATA, operation, ReplicationExecutionType.SYNC, filesToBeReplicated);
        try {
            replicationManager.submitJob(job);
        } catch (IOException e) {
            throw new HyracksDataException(e);
        }
    }
}
Also used : ReplicationJob(org.apache.asterix.common.replication.ReplicationJob) IOException(java.io.IOException) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Example 28 with HyracksDataException

use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.

the class NonDeterministicPartitionBatchManager method getNextBatch.

@Override
public synchronized void getNextBatch(List<IFrameReader> batch, int size) throws HyracksDataException {
    if (partitions.size() <= size) {
        batch.addAll(partitions);
        partitions.clear();
    } else if (partitions.size() > size) {
        List<IFrameReader> sublist = partitions.subList(0, size);
        batch.addAll(sublist);
        sublist.clear();
    }
    if (batch.size() == size) {
        return;
    }
    this.batch = batch;
    this.requiredSize = size;
    while (batch.size() < size) {
        try {
            wait();
        } catch (InterruptedException e) {
            throw new HyracksDataException(e);
        }
    }
    this.batch = null;
}
Also used : List(java.util.List) ArrayList(java.util.ArrayList) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Example 29 with HyracksDataException

use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.

the class InputChannelFrameReader method nextFrame.

/**
     * This implementation works under the truth that one Channel is neverNonDeterministicChannelReader shared by two readers.
     * More precisely, one channel only has exact one reader and one writer side.
     *
     * @param frame
     *            outputFrame
     * @return {@code true} if succeed to read the data from the channel to the {@code frame}.
     *         Otherwise return {@code false} if the end of stream is reached.
     * @throws HyracksDataException
     */
@Override
public boolean nextFrame(IFrame frame) throws HyracksDataException {
    if (!canGetNextBuffer()) {
        return false;
    }
    frame.reset();
    ByteBuffer srcFrame = channel.getNextBuffer();
    int nBlocks = FrameHelper.deserializeNumOfMinFrame(srcFrame);
    frame.ensureFrameSize(frame.getMinSize() * nBlocks);
    FrameUtils.copyWholeFrame(srcFrame, frame.getBuffer());
    channel.recycleBuffer(srcFrame);
    for (int i = 1; i < nBlocks; ++i) {
        if (!canGetNextBuffer()) {
            throw new HyracksDataException("InputChannelReader is waiting for the new frames, but the input stream is finished");
        }
        srcFrame = channel.getNextBuffer();
        frame.getBuffer().put(srcFrame);
        channel.recycleBuffer(srcFrame);
    }
    if (frame.getBuffer().hasRemaining()) {
        // bigger frame
        FrameHelper.clearRemainingFrame(frame.getBuffer(), frame.getBuffer().position());
    }
    frame.getBuffer().flip();
    return true;
}
Also used : ByteBuffer(java.nio.ByteBuffer) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Example 30 with HyracksDataException

use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.

the class IntArraySerializerDeserializer method deserialize.

@Override
public int[] deserialize(DataInput in) throws HyracksDataException {
    try {
        int len = in.readInt();
        int[] array = new int[len];
        for (int i = 0; i < array.length; ++i) {
            array[i] = in.readInt();
        }
        return array;
    } catch (IOException e) {
        throw new HyracksDataException(e);
    }
}
Also used : IOException(java.io.IOException) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Aggregations

HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)566 IOException (java.io.IOException)209 DataOutput (java.io.DataOutput)96 ArrayBackedValueStorage (org.apache.hyracks.data.std.util.ArrayBackedValueStorage)78 ITupleReference (org.apache.hyracks.dataflow.common.data.accessors.ITupleReference)75 IPointable (org.apache.hyracks.data.std.api.IPointable)73 IFrameTupleReference (org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference)70 TypeMismatchException (org.apache.asterix.runtime.exceptions.TypeMismatchException)67 IScalarEvaluator (org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator)67 VoidPointable (org.apache.hyracks.data.std.primitive.VoidPointable)64 IScalarEvaluatorFactory (org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory)61 IHyracksTaskContext (org.apache.hyracks.api.context.IHyracksTaskContext)60 ArrayList (java.util.ArrayList)57 ACIDException (org.apache.asterix.common.exceptions.ACIDException)56 ISerializerDeserializer (org.apache.hyracks.api.dataflow.value.ISerializerDeserializer)56 ATypeTag (org.apache.asterix.om.types.ATypeTag)39 AsterixException (org.apache.asterix.common.exceptions.AsterixException)36 ArrayTupleBuilder (org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder)32 ByteBuffer (java.nio.ByteBuffer)30 MetadataEntityValueExtractor (org.apache.asterix.metadata.valueextractors.MetadataEntityValueExtractor)27