The following example shows how to create a filter list with a GZIP compressor and compression level 10.
#include<tiledb/tiledb.h>// Create contexttiledb_ctx_t* ctx;tiledb_ctx_alloc(nullptr,&ctx);// Create compressor as a filtertiledb_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 listtiledb_filter_list_t* filter_list;tiledb_filter_list_alloc(ctx,&filter_list);// Add compressor to filter listtiledb_filter_list_add_filter(ctx, filter_list, filter);// Clean uptiledb_filter_free(&filter);tiledb_filter_list_free(&filter_list);tiledb_ctx_free(&ctx);
#include<tiledb/tiledb>usingnamespace tiledb;// Create contextContext ctx;// Create compressor as a filterFilterfilter(ctx,TILEDB_FILTER_GZIP);filter.set_option(ctx, TILEDB_COMPRESSION_LEVEL,10);// Create filter listFilterListfilter_list(ctx);// Add compressor to filter listfilter_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 listtiledb_filter_list_set_max_chunk_size(ctx, filter_list,10000);
// ... create context ctx // ... create array schema// ... create filter list fl// Set coordinates filter listsschema.set_coords_filter_list(fl);
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: