Class Context

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class Context
    extends java.lang.Object
    implements java.lang.AutoCloseable
    A TileDB context wraps a TileDB storage manager instance. Most objects and functions will require a Context.
    Internal error handling is also defined by the Context; the default error handler throws a TileDBError with a specific message.
    Example:
       Context ctx = new Context();
       // Use ctx when creating other objects:
       ArraySchema schema = new ArraySchema(ctx, tiledb_array_type_t.TILEDB_SPARSE);
    
       // Set a custom error handler:
       ctx.setErrorHandler(new MyContextCallback());
    
       //Context custom callback class example
       private static class MyContextCallback extends ContextCallback {
         @Override
         public void call(String msg) throws TileDBError {
           System.out.println("Callback error message: " + msg);
         }
       }
     
    • Constructor Summary

      Constructors 
      Constructor Description
      Context()
      Constructor.
      Context​(Config config)
      Creates a TileDB context with the given TileDB config object.
      Context​(java.util.Map<java.lang.String,​java.lang.String> config)
      Creates a TileDB context with the given TileDB parameter, value settings.
    • Constructor Detail

      • Context

        public Context()
                throws TileDBError
        Constructor. Creates a TileDB Context with default configuration.
        Throws:
        TileDBError - if construction fails
      • Context

        public Context​(Config config)
                throws TileDBError
        Creates a TileDB context with the given TileDB config object.
        Parameters:
        config - A TileDB Config object
        Throws:
        TileDBError - if construction fails
      • Context

        public Context​(java.util.Map<java.lang.String,​java.lang.String> config)
                throws TileDBError
        Creates a TileDB context with the given TileDB parameter, value settings.
        Parameters:
        config - A Map of TileDB setting, value string pairs
        Throws:
        TileDBError - if construction fails
    • Method Detail

      • setErrorHandler

        public void setErrorHandler​(ContextCallback errorHandler)
        Sets the error handler using a subclass of ContextCallback. If none is set, ContextCallback is used. The callback accepts an error message.
        Parameters:
        errorHandler - A custom ContextCallback error handler
      • handleError

        public void handleError​(int rc)
                         throws TileDBError
        Error handler for the TileDB C API (JNI) calls. Throws an exception in case of error.
        Parameters:
        rc - If != TILEDB_OK, call error handler
        Throws:
        TileDBError - A TileDB exception
      • isSupportedFs

        public boolean isSupportedFs​(Filesystem fs)
                              throws TileDBError
        Checks if the filesystem backend is supported.
        Parameters:
        fs - TileDB filesystem enum
        Returns:
        true if the filesystem is supported, false otherwise
        Throws:
        TileDBError - A TileDB exception
      • getConfig

        public Config getConfig()
                         throws TileDBError
        Returns:
        A Config object containing all configuration values of the Context.
        Throws:
        TileDBError
      • setTag

        public void setTag​(java.lang.String key,
                           java.lang.String value)
                    throws TileDBError
        Set context tasks
        Parameters:
        key - to set
        value - value to set
        Throws:
        TileDBError
      • close

        public void close()
        Close the context and delete all native objects. Should be called always to cleanup the context
        Specified by:
        close in interface java.lang.AutoCloseable