Class AsyncOperator

java.lang.Object
org.apache.opendal.NativeObject
org.apache.opendal.AsyncOperator
All Implemented Interfaces:
AutoCloseable

public class AsyncOperator extends NativeObject
AsyncOperator represents an underneath OpenDAL operator that accesses data asynchronously.

Operators without an explicit executor share a default executor. Operators, derived streams, and outstanding operations keep it alive. Closing the last operator and stream releases it after outstanding operations complete; a later operator creates a new default executor.

The default executor uses the same worker context class loader behavior as AsyncExecutor.

  • Field Details

  • Method Details

    • of

      public static AsyncOperator of(ServiceConfig config)
      Construct an OpenDAL operator.
      Parameters:
      config - the config of the underneath service to access data from.
    • of

      public static AsyncOperator of(ServiceConfig config, AsyncExecutor executor)
      Construct an OpenDAL operator.
      Parameters:
      executor - the underneath executor to run async operations; null to use a default global executor.
    • of

      public static AsyncOperator of(String scheme, Map<String,String> map)
      Construct an OpenDAL operator:

      You can find all possible schemes here and see what config options each service supports.

      Parameters:
      scheme - the name of the underneath service to access data from.
      map - a map of properties to construct the underneath operator.
    • of

      public static AsyncOperator of(String scheme, Map<String,String> map, AsyncExecutor executor)
      Construct an OpenDAL operator:

      You can find all possible schemes here and see what config options each service supports.

      Parameters:
      scheme - the name of the underneath service to access data from.
      map - a map of properties to construct the underneath operator.
      executor - the underneath executor to run async operations; null to use a default global executor.
    • duplicate

      public AsyncOperator duplicate()
      Clone a new operator that is identical to this one. The new operator has its own lifecycle.

      Since an operator will release all its resource and "flush" on lifecycle end, this method is suitable to create a narrowed "scope" while avoiding creating a brand-new operator for each scope.

      Returns:
      the cloned operator.
    • layer

      public AsyncOperator layer(Layer layer)
      Create a new operator that is layered with the given layer.

      Note that the current operator is not modified. The returned operator is a new instance. You must close the current operator on demand to avoid resource leak.

      Parameters:
      layer - the layer to be applied.
      Returns:
      the layered new operator.
    • blocking

      public Operator blocking()
      Create a new operator that performs every operation blocking.

      Note that the current operator is not modified. The returned operator is a new instance. You must close the current operator on demand to avoid resource leak.

      Returns:
      the blocking new operator.
    • write

      public CompletableFuture<Void> write(String path, String content)
    • write

      public CompletableFuture<Void> write(String path, byte[] content)
    • write

      public CompletableFuture<Void> write(String path, String content, WriteOptions options)
    • write

      public CompletableFuture<Void> write(String path, byte[] content, WriteOptions options)
    • stat

      public CompletableFuture<Metadata> stat(String path)
    • stat

      public CompletableFuture<Metadata> stat(String path, StatOptions options)
    • read

      public CompletableFuture<byte[]> read(String path)
    • read

      public CompletableFuture<byte[]> read(String path, long offset, long length)
    • read

      public CompletableFuture<byte[]> read(String path, ReadOptions options)
    • presignRead

      public CompletableFuture<PresignedRequest> presignRead(String path, Duration duration)
    • presignRead

      public CompletableFuture<PresignedRequest> presignRead(String path, Duration duration, ReadOptions options)
      Creates a presigned read request with the given options.

      The service must support presigning this operation. Support for individual options depends on the service. Send the returned HTTP method and headers along with the URI.

      Parameters:
      path - the path of the object.
      duration - how long the presigned request remains valid.
      options - the read options to include in the presigned request.
      Returns:
      the presigned request.
    • presignWrite

      public CompletableFuture<PresignedRequest> presignWrite(String path, Duration duration)
    • presignWrite

      public CompletableFuture<PresignedRequest> presignWrite(String path, Duration duration, WriteOptions options)
      Creates a presigned write request with the given options.

      The service must support presigning this operation. Support for individual options depends on the service. Send the returned HTTP method and headers along with the URI.

      Parameters:
      path - the path of the object.
      duration - how long the presigned request remains valid.
      options - the write options to include in the presigned request.
      Returns:
      the presigned request.
    • presignStat

      public CompletableFuture<PresignedRequest> presignStat(String path, Duration duration)
    • presignStat

      public CompletableFuture<PresignedRequest> presignStat(String path, Duration duration, StatOptions options)
      Creates a presigned stat request with the given options.

      The service must support presigning this operation. Support for individual options depends on the service. Send the returned HTTP method and headers along with the URI.

      Parameters:
      path - the path of the object.
      duration - how long the presigned request remains valid.
      options - the stat options to include in the presigned request.
      Returns:
      the presigned request.
    • delete

      public CompletableFuture<Void> delete(String path)
    • createDir

      public CompletableFuture<Void> createDir(String path)
    • copy

      public CompletableFuture<Void> copy(String sourcePath, String targetPath)
    • rename

      public CompletableFuture<Void> rename(String sourcePath, String targetPath)
    • removeAll

      public CompletableFuture<Void> removeAll(String path)
    • list

      public CompletableFuture<List<Entry>> list(String path)
    • list

      public CompletableFuture<List<Entry>> list(String path, ListOptions options)
    • disposeInternal

      protected void disposeInternal(long handle)
      Description copied from class: NativeObject
      Deletes underlying native object pointer.
      Specified by:
      disposeInternal in class NativeObject
      Parameters:
      handle - to the native object pointer