Search in sources :

Example 1 with DatatypeTupleTranslator

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

the class MetadataNode method getDataverseDatatypes.

private List<Datatype> getDataverseDatatypes(JobId jobId, String dataverseName) throws MetadataException, RemoteException {
    try {
        ITupleReference searchKey = createTuple(dataverseName);
        DatatypeTupleTranslator tupleReaderWriter = tupleTranslatorProvider.getDataTypeTupleTranslator(jobId, this, false);
        IValueExtractor<Datatype> valueExtractor = new MetadataEntityValueExtractor<>(tupleReaderWriter);
        List<Datatype> results = new ArrayList<>();
        searchIndex(jobId, MetadataPrimaryIndexes.DATATYPE_DATASET, searchKey, valueExtractor, results);
        return results;
    } catch (HyracksDataException e) {
        throw new MetadataException(e);
    }
}
Also used : MetadataEntityValueExtractor(org.apache.asterix.metadata.valueextractors.MetadataEntityValueExtractor) DatatypeTupleTranslator(org.apache.asterix.metadata.entitytupletranslators.DatatypeTupleTranslator) ITupleReference(org.apache.hyracks.dataflow.common.data.accessors.ITupleReference) ArrayList(java.util.ArrayList) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) Datatype(org.apache.asterix.metadata.entities.Datatype)

Example 2 with DatatypeTupleTranslator

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

the class MetadataNode method getAllDatatypes.

public List<Datatype> getAllDatatypes(JobId jobId) throws MetadataException, RemoteException {
    try {
        ITupleReference searchKey = null;
        DatatypeTupleTranslator tupleReaderWriter = tupleTranslatorProvider.getDataTypeTupleTranslator(jobId, this, false);
        IValueExtractor<Datatype> valueExtractor = new MetadataEntityValueExtractor<>(tupleReaderWriter);
        List<Datatype> results = new ArrayList<>();
        searchIndex(jobId, MetadataPrimaryIndexes.DATATYPE_DATASET, searchKey, valueExtractor, results);
        return results;
    } catch (HyracksDataException e) {
        throw new MetadataException(e);
    }
}
Also used : MetadataEntityValueExtractor(org.apache.asterix.metadata.valueextractors.MetadataEntityValueExtractor) DatatypeTupleTranslator(org.apache.asterix.metadata.entitytupletranslators.DatatypeTupleTranslator) ITupleReference(org.apache.hyracks.dataflow.common.data.accessors.ITupleReference) ArrayList(java.util.ArrayList) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) Datatype(org.apache.asterix.metadata.entities.Datatype)

Example 3 with DatatypeTupleTranslator

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

the class MetadataNode method addDatatype.

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

Example 4 with DatatypeTupleTranslator

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

the class MetadataNode method getDatatype.

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

Aggregations

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