Search in sources :

Example 1 with DataverseTupleTranslator

use of org.apache.asterix.metadata.entitytupletranslators.DataverseTupleTranslator in project asterixdb by apache.

the class MetadataNode method getDataverses.

@Override
public List<Dataverse> getDataverses(JobId jobId) throws MetadataException, RemoteException {
    try {
        DataverseTupleTranslator tupleReaderWriter = tupleTranslatorProvider.getDataverseTupleTranslator(false);
        IValueExtractor<Dataverse> valueExtractor = new MetadataEntityValueExtractor<>(tupleReaderWriter);
        List<Dataverse> results = new ArrayList<>();
        searchIndex(jobId, MetadataPrimaryIndexes.DATAVERSE_DATASET, null, valueExtractor, results);
        return results;
    } catch (HyracksDataException e) {
        throw new MetadataException(e);
    }
}
Also used : MetadataEntityValueExtractor(org.apache.asterix.metadata.valueextractors.MetadataEntityValueExtractor) DataverseTupleTranslator(org.apache.asterix.metadata.entitytupletranslators.DataverseTupleTranslator) ArrayList(java.util.ArrayList) Dataverse(org.apache.asterix.metadata.entities.Dataverse) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Example 2 with DataverseTupleTranslator

use of org.apache.asterix.metadata.entitytupletranslators.DataverseTupleTranslator in project asterixdb by apache.

the class MetadataNode method getDataverse.

@Override
public Dataverse getDataverse(JobId jobId, String dataverseName) throws MetadataException, RemoteException {
    try {
        ITupleReference searchKey = createTuple(dataverseName);
        DataverseTupleTranslator tupleReaderWriter = tupleTranslatorProvider.getDataverseTupleTranslator(false);
        IValueExtractor<Dataverse> valueExtractor = new MetadataEntityValueExtractor<>(tupleReaderWriter);
        List<Dataverse> results = new ArrayList<>();
        searchIndex(jobId, MetadataPrimaryIndexes.DATAVERSE_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) DataverseTupleTranslator(org.apache.asterix.metadata.entitytupletranslators.DataverseTupleTranslator) ITupleReference(org.apache.hyracks.dataflow.common.data.accessors.ITupleReference) ArrayList(java.util.ArrayList) Dataverse(org.apache.asterix.metadata.entities.Dataverse) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Example 3 with DataverseTupleTranslator

use of org.apache.asterix.metadata.entitytupletranslators.DataverseTupleTranslator in project asterixdb by apache.

the class MetadataNode method addDataverse.

@Override
public void addDataverse(JobId jobId, Dataverse dataverse) throws MetadataException, RemoteException {
    try {
        DataverseTupleTranslator tupleReaderWriter = tupleTranslatorProvider.getDataverseTupleTranslator(true);
        ITupleReference tuple = tupleReaderWriter.getTupleFromMetadataEntity(dataverse);
        insertTupleIntoIndex(jobId, MetadataPrimaryIndexes.DATAVERSE_DATASET, tuple);
    } catch (HyracksDataException e) {
        if (e.getComponent().equals(ErrorCode.HYRACKS) && e.getErrorCode() == ErrorCode.DUPLICATE_KEY) {
            throw new MetadataException("A dataverse with this name " + dataverse.getDataverseName() + " already exists.", e);
        } else {
            throw new MetadataException(e);
        }
    } catch (ACIDException e) {
        throw new MetadataException(e);
    }
}
Also used : DataverseTupleTranslator(org.apache.asterix.metadata.entitytupletranslators.DataverseTupleTranslator) ITupleReference(org.apache.hyracks.dataflow.common.data.accessors.ITupleReference) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) ACIDException(org.apache.asterix.common.exceptions.ACIDException)

Aggregations

DataverseTupleTranslator (org.apache.asterix.metadata.entitytupletranslators.DataverseTupleTranslator)3 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)3 ArrayList (java.util.ArrayList)2 Dataverse (org.apache.asterix.metadata.entities.Dataverse)2 MetadataEntityValueExtractor (org.apache.asterix.metadata.valueextractors.MetadataEntityValueExtractor)2 ITupleReference (org.apache.hyracks.dataflow.common.data.accessors.ITupleReference)2 ACIDException (org.apache.asterix.common.exceptions.ACIDException)1