Configuration

Configuration objects can be used when creating a TileDB context, or when using consolidation and virtual filesystem (VFS) functionality. See Configuration Parameters for a summary of all TileDB configuration options.

Basic Usage

You can create and set configuration objects as follows:

C
C++
Python
R
Java
Go
// Create a configuration object
tiledb_config_t *config;
tiledb_config_alloc(&config, NULL);
// Set a configuration parameter
tiledb_config_set(config, "sm.tile_cache_size", "5000", &error);
// Get a configuration parameter
const char* value;
tiledb_config_get(config, "sm.tile_cache_size", &value, &error);
// Unset a configuration parameter
tiledb_config_unset(config, "sm.tile_cache_size", &error);
// Clean up
tiledb_config_free(&config);
// Create a configuration object
Config config;
// Set a configuration parameter
config["sm.tile_cache_size"] = "5000";
// Get a configuration parameter
std::string = config["sm.tile_cache_size"];
// Unset a configuration parameter
config.unset("sm.tile_cache_size");
# Create a configuration object
config = tiledb.Config()
# Set a configuration parameter
config["sm.tile_cache_size"] = 5000
# Config objects may also be initialized with a dictionary
config = tiledb.Config({"sm.tile_cache_size": 5000})
# Create a configuration object
config <- tiledb_config()
# Set a configuration parameter
config["sm.tile_cache_size"] <- "5000";
# Get a configuration parameter
tile_cache_size <- config["sm.tile_cache_size"];
try(Config config = new Config()) {
// Set a configuration parameter
config.set("sm.tile_cache_size", "5000");
// Get a configuration parameter
String tile_cache_size = config.get("sm.tile_cache_size");
// Unset a configuration parameter
config.unset("sm.tile_cache_size");
}
// Create a configuration object
config, _ := tiledb.NewConfig()
// Set a configuration parameter
config.Set("sm.tile_cache_size", "5000");
// Get a configuration parameter
smTileCacheSize, _ := config.Get("sm.tile_cache_size")
// Unset a configuration parameter
config.Unset("sm.tile_cache_size")
// Clean up
config.Free()

Saving To / Loading From File

You can save a configuration object into a text file, as well as load a configuration object from a text file, as follows:

C
C++
Python
R
Java
Go
// Create a TileDB config
tiledb_config_t* config;
tiledb_config_alloc(&config, NULL);
tiledb_config_set(config, "sm.tile_cache_size", "0", &error);
// Save to file
tiledb_config_save_to_file(config, "tiledb_config.txt", &error);
// Load from file
tiledb_config_t* config_load;
tiledb_config_alloc(&config_load, &error);
tiledb_config_load_from_file(config_load, "tiledb_config.txt", &error);
const char* value;
tiledb_config_get(config_load, "sm.tile_cache_size", &value, &error);
// Clean up
tiledb_config_free(&config);
tiledb_config_free(&config_load);
// Save to file
Config config;
config["sm.tile_cache_size"] = 0;
config.save_to_file("tiledb_config.txt");
// Load from file
Config config_load("tiledb_config.txt");
std::string tile_cache_size = config_load["sm.tile_cache_size"];
config = tiledb.Config()
config["sm.tile_cache_size"] = 0
config.save("tiledb_config.txt")
# Save to file
config <- tiledb_config()
config["sm.tile_cache_size"] <- 0;
tiledb_config_save(config, "tiledb_config.txt");
# Load from file
config_loaded <- tiledb_config_load("tiledb_config.txt");
tile_cache_size = config_loaded["sm.tile_cache_size"];
// Save to file
try(Config config = new Config()) {
config.set("sm.tile_cache_size", "0");
config.saveToFile("tiledb_config.txt");
// Load from file
Config config_load = new Config("tiledb_config.txt");
String tile_cache_size = config_load.get("sm.tile_cache_size");
}
// Create a TileDB config
config, _ := tiledb.NewConfig()
// Set a value
config.Set("sm.tile_cache_size", "8")
// Save to file
config.SaveToFile(configFileName)
// Load from file
newConfig, _ := tiledb.LoadConfig(configFileName)
// Retrieve value
smTileCacheSize, _ := newConfig.Get("sm.tile_cache_size")
// Clean up
config.Free()

Configuration Iterator

You can also use a configuration iterator as follows:

C
C++
Python
R
Java
Go
// Create a TileDB config
tiledb_config_t* config;
tiledb_config_alloc(&config, NULL);
// Create a TileDB config iterator
// You can use any prefix instead of "vfs.s3."
tiledb_config_iter_t* config_iter;
tiledb_config_iter_alloc(config, "vfs.s3.", &config_iter, &error);
// Print all configuration parameters that start with "vfs.s3"
// Note that the prefix is exluded from the results
printf("\nVFS S3 settings:\n");
int done = 0;
const char *param, *value;
tiledb_config_iter_done(config_iter, &done, &error);
while (!done) {
tiledb_config_iter_here(config_iter, &param, &value, &error);
printf("\"%s\" : \"%s\"\n", param, value);
tiledb_config_iter_next(config_iter, &error);
tiledb_config_iter_done(config_iter, &done, &error);
}
// You can reset the iterator as follows
tiledb_config_iter_reset(config, config_iter, NULL, NULL);
// Clean up
tiledb_config_free(&config);
tiledb_config_iter_free(&config_iter);
Config config;
// Print only the S3 settings
// You can use any prefix instead of "vfs.s3."
// Note that the prefix is exluded from the results
std::cout << "\nVFS S3 settings:\n";
for (auto i = config.begin("vfs.s3."); i != config.end(); ++i) {
auto& p = *i;
std::cout << "\"" << p.first << "\" : \"" << p.second << "\"\n";
}
# ... create/open a Config object
for (key,value) in config.items():
print(f"'{key}': '{value}'")
# keys may optionally be filtered by passing a prefix to `items()`
for (key,value) in config.items("vfs.s3."):
print(f"'{key}': '{value}'")
# TODO: Looping over the configuration is not currently support in R
try(Config config = new Config()) {
// Print only the S3 settings
// You can use any prefix instead of "vfs.s3."
// Note that the prefix is exluded from the results
System.out.printf("\nVFS S3 settings:\n");
for (Map.Entry me : config.parameters("vfs.s3").entrySet()) {
System.out.Printf("\"%s\" : \"%s\"\n", p.getKey(), p.getValue());
}
}
// TODO: Looping over the configuration is not currently support in Go