You can get the schema of an existing array as follows:
# load the schema directly# optionally pass `key=...` for encrypted arraysschema = tiledb.ArraySchema.load(array_name)# or access the schema from an open array objectA = tiledb.Array(array_name)schema = A.schema
You can also inspect the different array schema members:
# ... get array schema# Check if array is sparseschema.sparse# Get tile capacityschema.capacity# Cell and tile order return 'row-major', 'col-major', or 'global'# Get tile orderschema.tile_order# Get cell orderschema.cell_order# Get coordinates filter listcoords_filters = schema.coords_filters# Get offsets filter listoffsets_filters = schema.offsets_filters# Get the array domaindomain = schema.domain# Get number of attributesattr_num = schema.nattr# Get attribute by index (0 <= idx < attr_num)attr = schema.attr(0)# Check if the named attribute existsschema.has_attr("features")# Get attribute by nameattr = schema.attr("features")
# ... get array schema# ... get domain from schema# Get the domain data type (i.e., the datatype of all dimensions)# note: types are automatically converted to NumPy dtypesdomain_dtype = domain.dtype# Get number of dimensionsdim_num = domain.ndim# Get dimension by index (0 <= idx < dim_num)dim = domain.dim(0)# Get dimension by namedim = domain.dim("dim_1")# Check if domain has named dimensiondomain.has_dim("dim_1")# Print the domain in ASCII formatdomain.dump()
Inspect array dimensions
# ... get array schema# ... get domain# ... get dimension by index# Get dimension namedim_name = dims[0].name# Get dimension datatypedim_dtype = dims[0].dtype# Get dimension domaindim_domain = dims[0].domain# Get tile extenttile_extent = dims[0].tile# Get dimension filter listfilter_list = dims[0].filters
Inspect attributes
# ... create context# ... get array schema# ... get attribute by index or name# Get attribute nameattr_name = attr.name# Get attribute datatypeattr_dtype = attr.dtype# Get filter listfilter_list = attr.filters# Check if attribute is variable-lengthvar_length = attr.isvar# Get number of values per cell# note: for variable-length attributes, ncells == typemax(np.uint32)num = attr.ncells# Get datatype size (bytes) for this attributecell_size = attr.dtype.itemsize
Inspect filters
# ... get filter list# Get number of filtersnum_filters =len(filter_list)print(len(filter_list))# Get the maximum tile chunk sizemax_chunk_size = filter_list.chunksize# Get a filter by index (0 <= idx < num_filters)filter= filter_list[0]# Get filter typefilter.__class__# Get filter option (depends on the filter: `filter.{option_name}`)level =filter.level