Search in sources :

Example 86 with ITupleReference

use of org.apache.hyracks.dataflow.common.data.accessors.ITupleReference in project asterixdb by apache.

the class IndexSearchOperatorNodePushable method writeSearchResults.

protected void writeSearchResults(int tupleIndex) throws Exception {
    boolean matched = false;
    while (cursor.hasNext()) {
        matched = true;
        tb.reset();
        cursor.next();
        if (retainInput) {
            frameTuple.reset(accessor, tupleIndex);
            for (int i = 0; i < frameTuple.getFieldCount(); i++) {
                dos.write(frameTuple.getFieldData(i), frameTuple.getFieldStart(i), frameTuple.getFieldLength(i));
                tb.addFieldEndOffset();
            }
        }
        ITupleReference tuple = cursor.getTuple();
        writeTupleToOutput(tuple);
        if (appendIndexFilter) {
            writeFilterTupleToOutput(cursor.getFilterMinTuple());
            writeFilterTupleToOutput(cursor.getFilterMaxTuple());
        }
        FrameUtils.appendToWriter(writer, appender, tb.getFieldEndOffsets(), tb.getByteArray(), 0, tb.getSize());
    }
    if (!matched && retainInput && retainMissing) {
        FrameUtils.appendConcatToWriter(writer, appender, accessor, tupleIndex, nonMatchTupleBuild.getFieldEndOffsets(), nonMatchTupleBuild.getByteArray(), 0, nonMatchTupleBuild.getSize());
    }
}
Also used : ITupleReference(org.apache.hyracks.dataflow.common.data.accessors.ITupleReference)

Example 87 with ITupleReference

use of org.apache.hyracks.dataflow.common.data.accessors.ITupleReference in project asterixdb by apache.

the class MetadataNode method getFeedPolicy.

@Override
public FeedPolicyEntity getFeedPolicy(JobId jobId, String dataverse, String policyName) throws MetadataException, RemoteException {
    try {
        ITupleReference searchKey = createTuple(dataverse, policyName);
        FeedPolicyTupleTranslator tupleReaderWriter = tupleTranslatorProvider.getFeedPolicyTupleTranslator(false);
        List<FeedPolicyEntity> results = new ArrayList<>();
        IValueExtractor<FeedPolicyEntity> valueExtractor = new MetadataEntityValueExtractor<>(tupleReaderWriter);
        searchIndex(jobId, MetadataPrimaryIndexes.FEED_POLICY_DATASET, searchKey, valueExtractor, results);
        if (!results.isEmpty()) {
            return results.get(0);
        }
        return null;
    } catch (HyracksDataException e) {
        throw new MetadataException(e);
    }
}
Also used : MetadataEntityValueExtractor(org.apache.asterix.metadata.valueextractors.MetadataEntityValueExtractor) FeedPolicyEntity(org.apache.asterix.metadata.entities.FeedPolicyEntity) ITupleReference(org.apache.hyracks.dataflow.common.data.accessors.ITupleReference) ArrayList(java.util.ArrayList) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) FeedPolicyTupleTranslator(org.apache.asterix.metadata.entitytupletranslators.FeedPolicyTupleTranslator)

Example 88 with ITupleReference

use of org.apache.hyracks.dataflow.common.data.accessors.ITupleReference in project asterixdb by apache.

the class MetadataNode method addFeed.

@Override
public void addFeed(JobId jobId, Feed feed) throws MetadataException, RemoteException {
    try {
        // Insert into the 'Feed' dataset.
        FeedTupleTranslator tupleReaderWriter = tupleTranslatorProvider.getFeedTupleTranslator(true);
        ITupleReference feedTuple = tupleReaderWriter.getTupleFromMetadataEntity(feed);
        insertTupleIntoIndex(jobId, MetadataPrimaryIndexes.FEED_DATASET, feedTuple);
    } catch (HyracksDataException e) {
        if (e.getComponent().equals(ErrorCode.HYRACKS) && e.getErrorCode() == ErrorCode.DUPLICATE_KEY) {
            throw new MetadataException("A feed with this name " + feed.getFeedName() + " already exists in dataverse '" + feed.getDataverseName() + "'.", e);
        } else {
            throw new MetadataException(e);
        }
    } catch (ACIDException e) {
        throw new MetadataException(e);
    }
}
Also used : ITupleReference(org.apache.hyracks.dataflow.common.data.accessors.ITupleReference) FeedTupleTranslator(org.apache.asterix.metadata.entitytupletranslators.FeedTupleTranslator) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) ACIDException(org.apache.asterix.common.exceptions.ACIDException)

Example 89 with ITupleReference

use of org.apache.hyracks.dataflow.common.data.accessors.ITupleReference in project asterixdb by apache.

the class MetadataNode method getExternalFile.

@Override
public ExternalFile getExternalFile(JobId jobId, String dataverseName, String datasetName, Integer fileNumber) throws MetadataException, RemoteException {
    try {
        ITupleReference searchKey = createExternalFileSearchTuple(dataverseName, datasetName, fileNumber);
        ExternalFileTupleTranslator tupleReaderWriter = tupleTranslatorProvider.getExternalFileTupleTranslator(false);
        IValueExtractor<ExternalFile> valueExtractor = new MetadataEntityValueExtractor<>(tupleReaderWriter);
        List<ExternalFile> results = new ArrayList<>();
        searchIndex(jobId, MetadataPrimaryIndexes.EXTERNAL_FILE_DATASET, searchKey, valueExtractor, results);
        if (results.isEmpty()) {
            return null;
        }
        return results.get(0);
    } catch (HyracksDataException e) {
        throw new MetadataException(e);
    }
}
Also used : MetadataEntityValueExtractor(org.apache.asterix.metadata.valueextractors.MetadataEntityValueExtractor) ExternalFileTupleTranslator(org.apache.asterix.metadata.entitytupletranslators.ExternalFileTupleTranslator) ITupleReference(org.apache.hyracks.dataflow.common.data.accessors.ITupleReference) ArrayList(java.util.ArrayList) ExternalFile(org.apache.asterix.external.indexing.ExternalFile) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Example 90 with ITupleReference

use of org.apache.hyracks.dataflow.common.data.accessors.ITupleReference in project asterixdb by apache.

the class MetadataNode method getIndex.

@Override
public Index getIndex(JobId jobId, String dataverseName, String datasetName, String indexName) throws MetadataException, RemoteException {
    try {
        ITupleReference searchKey = createTuple(dataverseName, datasetName, indexName);
        IndexTupleTranslator tupleReaderWriter = tupleTranslatorProvider.getIndexTupleTranslator(jobId, this, false);
        IValueExtractor<Index> valueExtractor = new MetadataEntityValueExtractor<>(tupleReaderWriter);
        List<Index> results = new ArrayList<>();
        searchIndex(jobId, MetadataPrimaryIndexes.INDEX_DATASET, searchKey, valueExtractor, results);
        if (results.isEmpty()) {
            return null;
        }
        return results.get(0);
    } catch (HyracksDataException e) {
        throw new MetadataException(e);
    }
}
Also used : MetadataEntityValueExtractor(org.apache.asterix.metadata.valueextractors.MetadataEntityValueExtractor) IndexTupleTranslator(org.apache.asterix.metadata.entitytupletranslators.IndexTupleTranslator) ITupleReference(org.apache.hyracks.dataflow.common.data.accessors.ITupleReference) ArrayList(java.util.ArrayList) IMetadataIndex(org.apache.asterix.metadata.api.IMetadataIndex) Index(org.apache.asterix.metadata.entities.Index) AbstractLSMIndex(org.apache.hyracks.storage.am.lsm.common.impls.AbstractLSMIndex) ILSMIndex(org.apache.hyracks.storage.am.lsm.common.api.ILSMIndex) IIndex(org.apache.hyracks.storage.common.IIndex) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Aggregations

ITupleReference (org.apache.hyracks.dataflow.common.data.accessors.ITupleReference)149 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)80 ArrayList (java.util.ArrayList)40 ACIDException (org.apache.asterix.common.exceptions.ACIDException)31 MetadataEntityValueExtractor (org.apache.asterix.metadata.valueextractors.MetadataEntityValueExtractor)26 ISerializerDeserializer (org.apache.hyracks.api.dataflow.value.ISerializerDeserializer)20 Test (org.junit.Test)20 RangePredicate (org.apache.hyracks.storage.am.btree.impls.RangePredicate)18 IIndexCursor (org.apache.hyracks.storage.common.IIndexCursor)18 Dataset (org.apache.asterix.metadata.entities.Dataset)10 MultiComparator (org.apache.hyracks.storage.common.MultiComparator)10 CheckTuple (org.apache.hyracks.storage.am.common.CheckTuple)8 ITreeIndexAccessor (org.apache.hyracks.storage.am.common.api.ITreeIndexAccessor)8 ITreeIndexCursor (org.apache.hyracks.storage.am.common.api.ITreeIndexCursor)8 ArrayTupleBuilder (org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder)7 ILSMDiskComponentBulkLoader (org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponentBulkLoader)7 SearchPredicate (org.apache.hyracks.storage.am.rtree.impls.SearchPredicate)7 ExtensionMetadataDataset (org.apache.asterix.metadata.api.ExtensionMetadataDataset)6 Datatype (org.apache.asterix.metadata.entities.Datatype)6 ArrayTupleReference (org.apache.hyracks.dataflow.common.comm.io.ArrayTupleReference)6