Search in sources :

Example 16 with MetadataEntityValueExtractor

use of org.apache.asterix.metadata.valueextractors.MetadataEntityValueExtractor 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)

Example 17 with MetadataEntityValueExtractor

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

the class MetadataNode method getDataverseAdapters.

@Override
public List<DatasourceAdapter> getDataverseAdapters(JobId jobId, String dataverseName) throws MetadataException, RemoteException {
    try {
        ITupleReference searchKey = createTuple(dataverseName);
        DatasourceAdapterTupleTranslator tupleReaderWriter = tupleTranslatorProvider.getAdapterTupleTranslator(false);
        IValueExtractor<DatasourceAdapter> valueExtractor = new MetadataEntityValueExtractor<>(tupleReaderWriter);
        List<DatasourceAdapter> results = new ArrayList<>();
        searchIndex(jobId, MetadataPrimaryIndexes.DATASOURCE_ADAPTER_DATASET, searchKey, valueExtractor, results);
        return results;
    } 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)

Example 18 with MetadataEntityValueExtractor

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

the class MetadataNode method getCompactionPolicy.

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

Example 19 with MetadataEntityValueExtractor

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

the class MetadataNode method initializeDatasetIdFactory.

@Override
public void initializeDatasetIdFactory(JobId jobId) throws MetadataException, RemoteException {
    int mostRecentDatasetId = MetadataIndexImmutableProperties.FIRST_AVAILABLE_USER_DATASET_ID;
    try {
        String resourceName = MetadataPrimaryIndexes.DATASET_DATASET.getFile().getRelativePath();
        IIndex indexInstance = datasetLifecycleManager.get(resourceName);
        datasetLifecycleManager.open(resourceName);
        try {
            IIndexAccessor indexAccessor = indexInstance.createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
            IIndexCursor rangeCursor = indexAccessor.createSearchCursor(false);
            DatasetTupleTranslator tupleReaderWriter = tupleTranslatorProvider.getDatasetTupleTranslator(false);
            IValueExtractor<Dataset> valueExtractor = new MetadataEntityValueExtractor<>(tupleReaderWriter);
            RangePredicate rangePred = new RangePredicate(null, null, true, true, null, null);
            indexAccessor.search(rangeCursor, rangePred);
            int datasetId;
            try {
                while (rangeCursor.hasNext()) {
                    rangeCursor.next();
                    final ITupleReference ref = rangeCursor.getTuple();
                    final Dataset ds = valueExtractor.getValue(jobId, ref);
                    datasetId = ds.getDatasetId();
                    if (mostRecentDatasetId < datasetId) {
                        mostRecentDatasetId = datasetId;
                    }
                }
            } finally {
                rangeCursor.close();
            }
        } finally {
            datasetLifecycleManager.close(resourceName);
        }
    } catch (HyracksDataException e) {
        throw new MetadataException(e);
    }
    DatasetIdFactory.initialize(mostRecentDatasetId);
}
Also used : IIndex(org.apache.hyracks.storage.common.IIndex) RangePredicate(org.apache.hyracks.storage.am.btree.impls.RangePredicate) DatasetTupleTranslator(org.apache.asterix.metadata.entitytupletranslators.DatasetTupleTranslator) ExtensionMetadataDataset(org.apache.asterix.metadata.api.ExtensionMetadataDataset) Dataset(org.apache.asterix.metadata.entities.Dataset) AString(org.apache.asterix.om.base.AString) AMutableString(org.apache.asterix.om.base.AMutableString) IIndexAccessor(org.apache.hyracks.storage.common.IIndexAccessor) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) MetadataEntityValueExtractor(org.apache.asterix.metadata.valueextractors.MetadataEntityValueExtractor) ITupleReference(org.apache.hyracks.dataflow.common.data.accessors.ITupleReference) IIndexCursor(org.apache.hyracks.storage.common.IIndexCursor)

Example 20 with MetadataEntityValueExtractor

use of org.apache.asterix.metadata.valueextractors.MetadataEntityValueExtractor 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

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