All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.exasol.adapter.document.files.DocumentFilesAdapter Maven / Gradle / Ivy

There is a newer version: 8.1.3
Show newest version
package com.exasol.adapter.document.files;

import java.util.Collections;

import com.exasol.adapter.AdapterProperties;
import com.exasol.adapter.capabilities.*;
import com.exasol.adapter.document.DocumentAdapterDialect;
import com.exasol.adapter.document.QueryPlanner;
import com.exasol.adapter.document.connection.ConnectionPropertiesReader;
import com.exasol.adapter.document.documentfetcher.files.FileFinderFactory;
import com.exasol.adapter.document.mapping.TableKeyFetcher;
import com.exasol.adapter.document.mapping.auto.SchemaFetcher;

/**
 * This class is the entry point for the files Virtual Schema.
 */
public class DocumentFilesAdapter implements DocumentAdapterDialect {
    private final String adapterName;
    private final FileFinderFactory fileFinderFactory;

    /**
     * Create a new instance of {@link DocumentFilesAdapter}.
     *
     * @param adapterName       adapter name
     * @param fileFinderFactory file storage specific file loader factory
     */
    public DocumentFilesAdapter(final String adapterName, final FileFinderFactory fileFinderFactory) {
        this.adapterName = adapterName;
        this.fileFinderFactory = fileFinderFactory;
    }

    @Override
    public TableKeyFetcher getTableKeyFetcher(final ConnectionPropertiesReader connectionInformation) {
        return (tableName, mappedColumns) -> Collections.emptyList();
    }

    @Override
    public SchemaFetcher getSchemaFetcher(final ConnectionPropertiesReader connectionInformation) {
        return new FilesSchemaFetcher(this.fileFinderFactory, new FileTypeSpecificDocumentFetcherFactory(),
                connectionInformation);
    }

    @Override
    public final QueryPlanner getQueryPlanner(final ConnectionPropertiesReader connectionInformation,
            final AdapterProperties adapterProperties) {
        return new FilesQueryPlanner(this.fileFinderFactory, connectionInformation);
    }

    @Override
    public String getAdapterName() {
        return this.adapterName;
    }

    @Override
    public Capabilities getCapabilities() {
        return Capabilities.builder().addMain(MainCapability.SELECTLIST_PROJECTION, MainCapability.FILTER_EXPRESSIONS)
                .addPredicate(PredicateCapability.EQUAL, PredicateCapability.LIKE, PredicateCapability.AND,
                        PredicateCapability.OR, PredicateCapability.NOT)
                .addLiteral(LiteralCapability.STRING).build();
    }

    @Override
    public String getUserGuideUrl() {
        return this.fileFinderFactory.getUserGuideUrl();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy