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

com.marklogic.flux.api.Executor Maven / Gradle / Ivy

There is a newer version: 1.1.3
Show newest version
/*
 * Copyright © 2024 MarkLogic Corporation. All Rights Reserved.
 */
package com.marklogic.flux.api;

import java.util.function.Consumer;

/**
 * Top-level interface for objects that can execute some type of batch process involving a connection to MarkLogic.
 */
public interface Executor {

    /**
     * Execute this executor instance with a default Spark session.
     */
    void execute();

    /**
     * Execute this executor with a user-defined Spark session.
     *
     * @param sparkSession must be an instance of {@code org.apache.spark.sql.SparkSession}. The Spark type is not used
     *                     here to avoid adding the Spark API and all of its dependencies to the compile-time
     *                     classpath of clients.
     * @return instance of this executor
     */
    T withSparkSession(Object sparkSession);

    /**
     * Configure a connection to MarkLogic.
     *
     * @param consumer Provided by the caller to configure the given options object.
     * @return instance of this executor
     */
    T connection(Consumer consumer);

    /**
     * Convenience for the common use case of configuring a MarkLogic connection via a connection string. Requires
     * that the associated MarkLogic REST API app server use basic or digest authentication.
     *
     * @param connectionString Defines a connection to MarkLogic via "user:password@host:port/optionalDatabaseName".
     * @return instance of this executor
     */
    T connectionString(String connectionString);

    /**
     * Limit the number of records read from the executor's data source.
     *
     * @param limit Maximum number of records to read from the executor's data source.
     * @return instance of this executor
     */
    T limit(int limit);

    /**
     * @return the count of rows to be read by this executor from its data source.
     */
    long count();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy