The following example shows how to create a filter list with a GZIP compressor and compression level 10.
#include <tiledb/tiledb.h>
// Create context
tiledb_ctx_t* ctx;
tiledb_ctx_alloc(nullptr, &ctx);
// Create compressor as a filter
tiledb_filter_t* filter;
tiledb_filter_alloc(ctx, TILEDB_FILTER_GZIP, &filter);
int level = 10;
tiledb_filter_set_option(ctx, filter, TILEDB_COMPRESSION_LEVEL, &level);
// Create filter list
tiledb_filter_list_t* filter_list;
tiledb_filter_list_alloc(ctx, &filter_list);
// Add compressor to filter list
tiledb_filter_list_add_filter(ctx, filter_list, filter);
// Clean up
tiledb_filter_free(&filter);
tiledb_filter_list_free(&filter_list);
tiledb_ctx_free(&ctx);
#include <tiledb/tiledb>
using namespace tiledb;
// Create context
Context ctx;
// Create compressor as a filter
Filter filter(ctx, TILEDB_FILTER_GZIP);
filter.set_option(ctx, TILEDB_COMPRESSION_LEVEL, 10);
// Create filter list
FilterList filter_list(ctx);
// Add compressor to filter list
filter_list.add_filter(filter)
import tiledb# tiledb.FilterList accepts an iterable of zero or more filters:filter_list = tiledb.FilterList([tiledb.GZipFilter(level=10)])
# create a "GZIP" compression filterflt <-tiledb_filter("GZIP")# set the option 'COMPRESSION_LEVEL' to 10tiledb_filter_set_option(flt, "COMPRESSION_LEVEL", 10)# create a filter list with this filterfltlst <-tiledb_filter_list(flt)
// Create contextContext ctx =newContext();// Create compressor as a filterFilter filter =newGzipFilter(ctx,10);// Create filter listFilterList filterList =newFilterList(ctx);// Add compressor to filter listfilterList.addFilter(filter);
// Create contextcontext, _ :=NewContext(nil)// Create compressor as a filterfilter, _ :=NewFilter(context, TILEDB_FILTER_GZIP)filter.SetOption(TILEDB_COMPRESSION_LEVEL, int32(10))// Create filter listfilterList, _ :=NewFilterList(context)// Add compressor to filter listfilterList.AddFilter(filter)
The default tile chunk size used by TileDB is 64KB, which is the size of many common processor L1 caches. You can control the chunk size by changing the option on a filter list:
// ... create context and filter list
tiledb_filter_list_set_max_chunk_size(ctx, filter_list, 10000);
// ... create filter list
filter_list.set_max_chunk_size(10000)
import tiledbimport numpy as npfilter_list = tiledb.FilterList([tiledb.GzipFilter()], chunksize=10000)
import tiledbimport numpy as np# ... create domain dom# ... create attributes attr1, attr2# ... create filter list fl# Create the schema setting the coordinates filter list schema = tiledb.ArraySchema(domain=dom, sparse=False, attrs=[attr1, attr2], coords_filters=fl)
# ... create (or retrieve) array schema sch# ... create filter list fl# assign filter list to schematiledb_array_schema_set_coords_filter_list(sch, fl)# Alternatively create the schema and set the coordinates filter listsch <-tiledb_array_schema(dom, c(attr1, attr2), coords_filter_list = fl)
// ... create array schema// ... create filter list fl// Set coordinates filter listschema.setCoordsFilterList(fl);
// ... create array schema// ... create filter list fl// Set coordinates filter listschema.SetCoordsFilterList(fl);
// ... create array schema and filter listschema.SetCoordsFilterList(filterList);
If you do not specify a filter for a dimension separately, the dimension will inherit the filters set to all dimensions collectively as shown above.
Setting a Filter List for Variable-sized Value Offsets
You can set filter lists for the offsets of variable-sized attributes or dimensions as follows:
#import <tiledb/tiledb.h>
// ... create context ctx
// ... create array schema
// ... create filter list fl
// Set offsets filter list
tiledb_array_schema_set_offsets_filter_list(ctx, schema, fl);
#import <tiledb/tiledb>
using namespace tiledb;
// ... create context ctx
// ... create array schema
// ... create filter list fl
// Set offsets filter list
schema.set_offsets_filter_list(fl);
import tiledbimport numpy as np# ... create domain dom# ... create attributes attr1, attr2# ... create filter list fl# Create the schema setting the offsets filter listschema = tiledb.ArraySchema(domain=dom, sparse=False, attrs=[attr1, attr2], offsets_filters=fl)
# ... create (or retrieve) array schema sch# ... create filter list fl# assign filter list to schematiledb_array_schema_set_offsets_filter_list(sch, fl)# Create the schema setting the offsets filter listsch <-tiledb_array_schema(dom, c(attr1, attr2), offsets_filter_list = fl)
// ... create array schema// ... create filter list fl// Set offsets filter listschema.setOffsetsFilterList(fl);
// ... create array schema// ... create filter list fl// Set offsets filter listschema.SetOffsetsFilterList(fl);
// ... create array schema and filter listschema.SetOffsetsFilterList(filterList);
The offset filters are applied to all variable-sized attributes and dimensions.