Search in sources :

Example 26 with MetadataEntityValueExtractor

use of org.apache.asterix.metadata.valueextractors.MetadataEntityValueExtractor in project asterixdb by apache.

the class MetadataNode method getLibrary.

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

Example 27 with MetadataEntityValueExtractor

use of org.apache.asterix.metadata.valueextractors.MetadataEntityValueExtractor in project asterixdb by apache.

the class MetadataNode method getAdapter.

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

Aggregations

MetadataEntityValueExtractor (org.apache.asterix.metadata.valueextractors.MetadataEntityValueExtractor)27 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)27 ArrayList (java.util.ArrayList)26 ITupleReference (org.apache.hyracks.dataflow.common.data.accessors.ITupleReference)26 ExtensionMetadataDataset (org.apache.asterix.metadata.api.ExtensionMetadataDataset)4 Dataset (org.apache.asterix.metadata.entities.Dataset)4 DatasetTupleTranslator (org.apache.asterix.metadata.entitytupletranslators.DatasetTupleTranslator)4 Datatype (org.apache.asterix.metadata.entities.Datatype)3 DatatypeTupleTranslator (org.apache.asterix.metadata.entitytupletranslators.DatatypeTupleTranslator)3 IIndex (org.apache.hyracks.storage.common.IIndex)3 ExternalFile (org.apache.asterix.external.indexing.ExternalFile)2 IMetadataIndex (org.apache.asterix.metadata.api.IMetadataIndex)2 DatasourceAdapter (org.apache.asterix.metadata.entities.DatasourceAdapter)2 Dataverse (org.apache.asterix.metadata.entities.Dataverse)2 Feed (org.apache.asterix.metadata.entities.Feed)2 FeedConnection (org.apache.asterix.metadata.entities.FeedConnection)2 FeedPolicyEntity (org.apache.asterix.metadata.entities.FeedPolicyEntity)2 Function (org.apache.asterix.metadata.entities.Function)2 Index (org.apache.asterix.metadata.entities.Index)2 Library (org.apache.asterix.metadata.entities.Library)2