Search in sources :

Example 16 with Dataverse

use of org.apache.asterix.metadata.entities.Dataverse in project asterixdb by apache.

the class TestNodeController method createPrimaryIndex.

public void createPrimaryIndex(Dataset dataset, IAType[] primaryKeyTypes, ARecordType recordType, ARecordType metaType, ILSMMergePolicyFactory mergePolicyFactory, Map<String, String> mergePolicyProperties, int[] filterFields, IStorageComponentProvider storageComponentProvider, int[] primaryKeyIndexes, List<Integer> primaryKeyIndicators) throws AlgebricksException, HyracksDataException {
    PrimaryIndexInfo primaryIndexInfo = new PrimaryIndexInfo(dataset, primaryKeyTypes, recordType, metaType, mergePolicyFactory, mergePolicyProperties, filterFields, primaryKeyIndexes, primaryKeyIndicators, storageComponentProvider);
    Dataverse dataverse = new Dataverse(dataset.getDataverseName(), NonTaggedDataFormat.class.getName(), MetadataUtil.PENDING_NO_OP);
    MetadataProvider mdProvider = new MetadataProvider((ICcApplicationContext) ExecutionTestUtil.integrationUtil.cc.getApplicationContext(), dataverse, storageComponentProvider);
    try {
        IResourceFactory resourceFactory = dataset.getResourceFactory(mdProvider, primaryIndexInfo.index, recordType, metaType, mergePolicyFactory, mergePolicyProperties);
        IndexBuilderFactory indexBuilderFactory = new IndexBuilderFactory(storageComponentProvider.getStorageManager(), primaryIndexInfo.fileSplitProvider, resourceFactory, !dataset.isTemp());
        IHyracksTaskContext ctx = createTestContext(false);
        IIndexBuilder indexBuilder = indexBuilderFactory.create(ctx, 0);
        indexBuilder.build();
    } finally {
        mdProvider.getLocks().unlock();
    }
}
Also used : IIndexBuilder(org.apache.hyracks.storage.am.common.api.IIndexBuilder) MetadataProvider(org.apache.asterix.metadata.declared.MetadataProvider) IHyracksTaskContext(org.apache.hyracks.api.context.IHyracksTaskContext) IndexBuilderFactory(org.apache.hyracks.storage.am.common.build.IndexBuilderFactory) NonTaggedDataFormat(org.apache.asterix.runtime.formats.NonTaggedDataFormat) Dataverse(org.apache.asterix.metadata.entities.Dataverse) IResourceFactory(org.apache.hyracks.storage.common.IResourceFactory)

Example 17 with Dataverse

use of org.apache.asterix.metadata.entities.Dataverse in project asterixdb by apache.

the class TestNodeController method getPrimaryResourceFactory.

public IResourceFactory getPrimaryResourceFactory(IHyracksTaskContext ctx, PrimaryIndexInfo primaryIndexInfo, IStorageComponentProvider storageComponentProvider, Dataset dataset) throws AlgebricksException {
    Dataverse dataverse = new Dataverse(dataset.getDataverseName(), NonTaggedDataFormat.class.getName(), MetadataUtil.PENDING_NO_OP);
    Index index = primaryIndexInfo.getIndex();
    CcApplicationContext appCtx = (CcApplicationContext) ExecutionTestUtil.integrationUtil.cc.getApplicationContext();
    MetadataProvider mdProvider = new MetadataProvider(appCtx, dataverse, storageComponentProvider);
    try {
        return dataset.getResourceFactory(mdProvider, index, primaryIndexInfo.recordType, primaryIndexInfo.metaType, primaryIndexInfo.mergePolicyFactory, primaryIndexInfo.mergePolicyProperties);
    } finally {
        mdProvider.getLocks().unlock();
    }
}
Also used : CcApplicationContext(org.apache.asterix.runtime.utils.CcApplicationContext) ICcApplicationContext(org.apache.asterix.common.dataflow.ICcApplicationContext) MetadataProvider(org.apache.asterix.metadata.declared.MetadataProvider) Index(org.apache.asterix.metadata.entities.Index) NonTaggedDataFormat(org.apache.asterix.runtime.formats.NonTaggedDataFormat) Dataverse(org.apache.asterix.metadata.entities.Dataverse)

Example 18 with Dataverse

use of org.apache.asterix.metadata.entities.Dataverse in project asterixdb by apache.

the class MetadataManager method getDataverse.

@Override
public Dataverse getDataverse(MetadataTransactionContext ctx, String dataverseName) throws MetadataException {
    // First look in the context to see if this transaction created the
    // requested dataverse itself (but the dataverse is still uncommitted).
    Dataverse dataverse = ctx.getDataverse(dataverseName);
    if (dataverse != null) {
        // uncommitted.
        return dataverse;
    }
    if (ctx.dataverseIsDropped(dataverseName)) {
        // in the cache.
        return null;
    }
    dataverse = cache.getDataverse(dataverseName);
    if (dataverse != null) {
        // Dataverse is already in the cache, don't add it again.
        return dataverse;
    }
    try {
        dataverse = metadataNode.getDataverse(ctx.getJobId(), dataverseName);
    } catch (RemoteException e) {
        throw new MetadataException(e);
    }
    // when this transaction commits.
    if (dataverse != null) {
        ctx.addDataverse(dataverse);
    }
    return dataverse;
}
Also used : RemoteException(java.rmi.RemoteException) Dataverse(org.apache.asterix.metadata.entities.Dataverse)

Example 19 with Dataverse

use of org.apache.asterix.metadata.entities.Dataverse 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 20 with Dataverse

use of org.apache.asterix.metadata.entities.Dataverse in project asterixdb by apache.

the class MetadataBootstrap method insertInitialDataverses.

private static void insertInitialDataverses(MetadataTransactionContext mdTxnCtx) throws MetadataException {
    String dataFormat = NonTaggedDataFormat.NON_TAGGED_DATA_FORMAT;
    MetadataManager.INSTANCE.addDataverse(mdTxnCtx, new Dataverse(MetadataConstants.METADATA_DATAVERSE_NAME, dataFormat, MetadataUtil.PENDING_NO_OP));
    MetadataManager.INSTANCE.addDataverse(mdTxnCtx, MetadataBuiltinEntities.DEFAULT_DATAVERSE);
}
Also used : Dataverse(org.apache.asterix.metadata.entities.Dataverse)

Aggregations

Dataverse (org.apache.asterix.metadata.entities.Dataverse)20 MetadataTransactionContext (org.apache.asterix.metadata.MetadataTransactionContext)11 RemoteException (java.rmi.RemoteException)10 ACIDException (org.apache.asterix.common.exceptions.ACIDException)9 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)9 IOException (java.io.IOException)8 AsterixException (org.apache.asterix.common.exceptions.AsterixException)8 MetadataException (org.apache.asterix.metadata.MetadataException)7 AlgebricksException (org.apache.hyracks.algebricks.common.exceptions.AlgebricksException)7 ArrayList (java.util.ArrayList)6 CompilationException (org.apache.asterix.common.exceptions.CompilationException)6 MetadataProvider (org.apache.asterix.metadata.declared.MetadataProvider)3 Dataset (org.apache.asterix.metadata.entities.Dataset)3 Function (org.apache.asterix.metadata.entities.Function)3 Index (org.apache.asterix.metadata.entities.Index)3 IDataset (org.apache.asterix.common.metadata.IDataset)2 ExternalLibrary (org.apache.asterix.external.library.ExternalLibrary)2 LibraryFunction (org.apache.asterix.external.library.LibraryFunction)2 DatasourceAdapter (org.apache.asterix.metadata.entities.DatasourceAdapter)2 Library (org.apache.asterix.metadata.entities.Library)2