Search in sources :

Example 1 with DataSourceDescriptor

use of org.polymap.core.data.pipeline.DataSourceDescriptor in project polymap4-core by Polymap4.

the class StoreCacheProcessor method init.

@Override
public void init(@SuppressWarnings("hiding") PipelineProcessorSite site) throws Exception {
    this.site = site;
    // XXX shouldn't the ressource name come from upstream schema?
    assert cachestore != null : "cachestore is not yet initialized.";
    cacheDs = cachestore.get();
    String resName = site.dsd.get().resourceName.get();
    lastUpdated.computeIfAbsent(site.layerId.get(), k -> new AtomicLong2());
    // init sync strategy
    String classname = getClass().getPackage().getName() + "." + SYNC_TYPE.get(site);
    sync = (SyncStrategy) getClass().getClassLoader().loadClass(classname).newInstance();
    sync.beforeInit(this, site);
    DataSourceDescriptor cacheDsd = new DataSourceDescriptor(cacheDs, resName);
    PipelineProcessorSite cacheSite = new PipelineProcessorSite(Params.EMPTY);
    cacheSite.layerId.set(site.layerId.get());
    cacheSite.usecase.set(site.usecase.get());
    cacheSite.builder.set(site.builder.get());
    cacheSite.dsd.set(cacheDsd);
    cache = new DataSourceProcessor();
    cache.init(cacheSite);
    sync.afterInit(this, site);
}
Also used : DataSourceProcessor(org.polymap.core.data.feature.DataSourceProcessor) PipelineProcessorSite(org.polymap.core.data.pipeline.PipelineProcessorSite) DataSourceDescriptor(org.polymap.core.data.pipeline.DataSourceDescriptor)

Example 2 with DataSourceDescriptor

use of org.polymap.core.data.pipeline.DataSourceDescriptor in project polymap4-core by Polymap4.

the class FeatureRenderProcessor2 method init.

@Override
public void init(@SuppressWarnings("hiding") PipelineProcessorSite site) throws Exception {
    this.site = site;
    // styleSupplier
    style = STYLE_SUPPLIER.rawopt(site).orElseGet(() -> {
        log.warn("No style for resource: " + site.dsd.get().resourceName.get());
        return () -> DefaultStyles.findStyle(fs.get());
    });
    // pipeline
    this.pipeline = new CachedLazyInit(() -> {
        try {
            PipelineBuilder builder = site.builder.get();
            DataSourceDescriptor dsd = new DataSourceDescriptor(site.dsd.get());
            return builder.createPipeline(site.layerId.get(), FeaturesProducer.class, dsd).get();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    });
    // fs
    this.fs = new CachedLazyInit(() -> {
        try {
            return new PipelineDataStore(pipeline.get()).getFeatureSource();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    });
}
Also used : CachedLazyInit(org.polymap.core.runtime.CachedLazyInit) IOException(java.io.IOException) PipelineBuilder(org.polymap.core.data.pipeline.PipelineBuilder) IOException(java.io.IOException) DataSourceDescriptor(org.polymap.core.data.pipeline.DataSourceDescriptor) PipelineDataStore(org.polymap.core.data.PipelineDataStore)

Aggregations

DataSourceDescriptor (org.polymap.core.data.pipeline.DataSourceDescriptor)2 IOException (java.io.IOException)1 PipelineDataStore (org.polymap.core.data.PipelineDataStore)1 DataSourceProcessor (org.polymap.core.data.feature.DataSourceProcessor)1 PipelineBuilder (org.polymap.core.data.pipeline.PipelineBuilder)1 PipelineProcessorSite (org.polymap.core.data.pipeline.PipelineProcessorSite)1 CachedLazyInit (org.polymap.core.runtime.CachedLazyInit)1