Java Code Examples for org.apache.kylin.metadata.realization.IRealization#getType()

The following examples show how to use org.apache.kylin.metadata.realization.IRealization#getType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RealizationSignature.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
static HybridSignature getHybridSignature(KylinConfig config, String realizationName) {
    HybridInstance hybridInstance = HybridManager.getInstance(config).getHybridInstance(realizationName);
    if (hybridInstance == null) {
        return null;
    }
    IRealization[] realizations = hybridInstance.getRealizations();
    Set<RealizationSignature> realizationSignatureSet = Sets.newHashSetWithExpectedSize(realizations.length);
    for (IRealization realization : realizations) {
        RealizationSignature realizationSignature = null;
        if (realization.getType() == RealizationType.CUBE) {
            realizationSignature = CubeSignature.getCubeSignature(config, realization.getName());
        } else if (realization.getType() == RealizationType.HYBRID) {
            realizationSignature = getHybridSignature(config, realization.getName());
        }
        if (realizationSignature != null) {
            realizationSignatureSet.add(realizationSignature);
        }
    }
    return new HybridSignature(realizationName, realizationSignatureSet);
}
 
Example 2
Source File: RealizationSignature.java    From kylin with Apache License 2.0 6 votes vote down vote up
static HybridSignature getHybridSignature(KylinConfig config, String realizationName) {
    HybridInstance hybridInstance = HybridManager.getInstance(config).getHybridInstance(realizationName);
    if (hybridInstance == null) {
        return null;
    }
    IRealization[] realizations = hybridInstance.getRealizations();
    Set<RealizationSignature> realizationSignatureSet = Sets.newHashSetWithExpectedSize(realizations.length);
    for (IRealization realization : realizations) {
        RealizationSignature realizationSignature = null;
        if (realization.getType() == RealizationType.CUBE) {
            realizationSignature = CubeSignature.getCubeSignature(config, realization.getName());
        } else if (realization.getType() == RealizationType.HYBRID) {
            realizationSignature = getHybridSignature(config, realization.getName());
        }
        if (realizationSignature != null) {
            realizationSignatureSet.add(realizationSignature);
        }
    }
    return new HybridSignature(realizationName, realizationSignatureSet);
}
 
Example 3
Source File: CubeMetaExtractor.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
private void retrieveResourcePath(IRealization realization) throws IOException {
    if (realization == null) {
        return;
    }
    logger.info("Deal with realization {} of type {}", realization.getName(), realization.getType());
    if (realization instanceof CubeInstance) {
        CubeInstance cube = (CubeInstance) realization;
        CubeDesc cubeDesc = cubeDescManager.getCubeDesc(cube.getDescName());
        DataModelDesc modelDesc = metadataManager.getDataModelDesc(cubeDesc.getModelName());
        // add tables
        addTables(modelDesc);
        // add streaming stuff
        addStreamingConfig(cube);
        // add streamingV2
        addStreamingV2Config(cube);
        // add cube
        addRequired(CubeDesc.concatResourcePath(cubeDesc.getName()));
        // add project
        addRequired(ProjectInstance.concatResourcePath(cube.getProject()));
        //add Segments and Jobs
        addSegAndJob(cube);

    } else if (realization instanceof HybridInstance) {
        HybridInstance hybridInstance = (HybridInstance) realization;
        addRequired(HybridInstance.concatResourcePath(hybridInstance.getName()));
        for (IRealization iRealization : hybridInstance.getRealizations()) {
            if (iRealization.getType() != RealizationType.CUBE) {
                throw new RuntimeException("Hybrid " + iRealization.getName() + " contains non cube child "
                        + iRealization.getName() + " with type " + iRealization.getType());
            }
            retrieveResourcePath(iRealization);
        }
    } else {
        logger.warn("Unknown realization type: " + realization.getType());
    }
}
 
Example 4
Source File: CacheServiceTest.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
private boolean containsRealization(Set<IRealization> realizations, RealizationType type, String name) {
    for (IRealization realization : realizations) {
        if (realization.getType() == type && realization.getName().equals(name)) {
            return true;
        }
    }
    return false;
}
 
Example 5
Source File: HBaseStorage.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Override
public IStorageQuery createQuery(IRealization realization) {

    if (realization.getType() == RealizationType.CUBE) {

        CubeInstance cubeInstance = (CubeInstance) realization;
        String cubeStorageQuery;
        if (cubeInstance.getStorageType() == IStorageAware.ID_HBASE) {//v2 query engine cannot go with v1 storage now
            throw new IllegalStateException(
                    "Storage Engine (id=" + IStorageAware.ID_HBASE + ") is not supported any more");
        } else {
            cubeStorageQuery = v2CubeStorageQuery;//by default use v2
        }

        IStorageQuery ret;
        try {
            ret = (IStorageQuery) Class.forName(cubeStorageQuery).getConstructor(CubeInstance.class)
                    .newInstance((CubeInstance) realization);
        } catch (Exception e) {
            throw new RuntimeException("Failed to initialize storage query for " + cubeStorageQuery, e);
        }

        return ret;
    } else {
        throw new IllegalArgumentException("Unknown realization type " + realization.getType());
    }
}
 
Example 6
Source File: StreamStorage.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Override
public IStorageQuery createQuery(IRealization realization) {
    if (realization.getType() == RealizationType.CUBE) {
        CubeInstance cubeInstance = (CubeInstance) realization;
        return new StreamStorageQuery(cubeInstance, getStreamingDataSearchClient());
    } else {
        throw new IllegalArgumentException("Unknown realization type " + realization.getType());
    }
}
 
Example 7
Source File: CubeMetaExtractor.java    From kylin with Apache License 2.0 5 votes vote down vote up
private void retrieveResourcePath(IRealization realization) throws IOException {
    if (realization == null) {
        return;
    }
    logger.info("Deal with realization {} of type {}", realization.getName(), realization.getType());
    if (realization instanceof CubeInstance) {
        CubeInstance cube = (CubeInstance) realization;
        CubeDesc cubeDesc = cubeDescManager.getCubeDesc(cube.getDescName());
        DataModelDesc modelDesc = metadataManager.getDataModelDesc(cubeDesc.getModelName());
        // add tables
        addTables(modelDesc);
        // add streaming stuff
        addStreamingConfig(cube);
        // add streamingV2
        addStreamingV2Config(cube);
        // add cube
        addRequired(CubeDesc.concatResourcePath(cubeDesc.getName()));
        // add project
        addRequired(ProjectInstance.concatResourcePath(cube.getProject()));
        //add Segments and Jobs
        addSegAndJob(cube);

    } else if (realization instanceof HybridInstance) {
        HybridInstance hybridInstance = (HybridInstance) realization;
        addRequired(HybridInstance.concatResourcePath(hybridInstance.getName()));
        for (IRealization iRealization : hybridInstance.getRealizations()) {
            if (iRealization.getType() != RealizationType.CUBE) {
                throw new RuntimeException("Hybrid " + iRealization.getName() + " contains non cube child "
                        + iRealization.getName() + " with type " + iRealization.getType());
            }
            retrieveResourcePath(iRealization);
        }
    } else {
        logger.warn("Unknown realization type: " + realization.getType());
    }
}
 
Example 8
Source File: CacheServiceTest.java    From kylin with Apache License 2.0 5 votes vote down vote up
private boolean containsRealization(Set<IRealization> realizations, RealizationType type, String name) {
    for (IRealization realization : realizations) {
        if (realization.getType() == type && realization.getName().equals(name)) {
            return true;
        }
    }
    return false;
}
 
Example 9
Source File: HBaseStorage.java    From kylin with Apache License 2.0 5 votes vote down vote up
@Override
public IStorageQuery createQuery(IRealization realization) {

    if (realization.getType() == RealizationType.CUBE) {

        CubeInstance cubeInstance = (CubeInstance) realization;
        String cubeStorageQuery;
        if (cubeInstance.getStorageType() == IStorageAware.ID_HBASE) {//v2 query engine cannot go with v1 storage now
            throw new IllegalStateException(
                    "Storage Engine (id=" + IStorageAware.ID_HBASE + ") is not supported any more");
        } else {
            cubeStorageQuery = v2CubeStorageQuery;//by default use v2
        }

        IStorageQuery ret;
        try {
            ret = (IStorageQuery) Class.forName(cubeStorageQuery).getConstructor(CubeInstance.class)
                    .newInstance((CubeInstance) realization);
        } catch (Exception e) {
            throw new RuntimeException("Failed to initialize storage query for " + cubeStorageQuery, e);
        }

        return ret;
    } else {
        throw new IllegalArgumentException("Unknown realization type " + realization.getType());
    }
}
 
Example 10
Source File: StreamStorage.java    From kylin with Apache License 2.0 5 votes vote down vote up
@Override
public IStorageQuery createQuery(IRealization realization) {
    if (realization.getType() == RealizationType.CUBE) {
        CubeInstance cubeInstance = (CubeInstance) realization;
        return new StreamStorageQuery(cubeInstance, getStreamingDataSearchClient());
    } else {
        throw new IllegalArgumentException("Unknown realization type " + realization.getType());
    }
}
 
Example 11
Source File: CacheServiceTest.java    From Kylin with Apache License 2.0 5 votes vote down vote up
private boolean containsRealization(Set<IRealization> realizations, RealizationType type, String name) {
    for (IRealization realization : realizations) {
        if (realization.getType() == type && realization.getName().equals(name)) {
            return true;
        }
    }
    return false;
}
 
Example 12
Source File: StorageEngineFactory.java    From Kylin with Apache License 2.0 5 votes vote down vote up
public static IStorageEngine getStorageEngine(IRealization realization) {
    if (realization.getType() == RealizationType.INVERTED_INDEX) {
        return new InvertedIndexStorageEngine((IIInstance) realization);
    } else {
        return new CubeStorageEngine((CubeInstance) realization);
    }
}