Skip to main content

BloomIndex

This class provides a PostgreSQL-specific Bloom index implementation for database fields. It supports indexing up to 32 fields and allows for customization of the index length and individual column bit settings. The class ensures data integrity by validating that configuration parameters fall within the specific constraints required by the underlying database engine.

Attributes

AttributeTypeDescription
suffixstring = "bloom"The storage engine suffix used for the index name generation, set to "bloom".
lengthintegerThe total length of the bloom filter in kilobytes, which must be an integer between 1 and 4096.
columnslist or tuple = ()A list or tuple of integers between 1 and 4095 specifying the number of bits generated for each indexed field.

Constructor

Signature

def BloomIndex(
*expressions: any,
length: int = None,
columns: list|tuple = (),
**kwargs: any
)

Parameters

NameTypeDescription
*expressionsanyPositional arguments representing the fields or expressions to be indexed.
lengthint = NoneThe length of the bloom filter, must be between 1 and 4096.
columns`listtuple` = ()
**kwargsanyAdditional keyword arguments passed to the parent PostgresIndex class.

Signature

def BloomIndex(
*expressions: any,
length: int,
columns: list|tuple,
**kwargs: any
) - > null

Parameters

NameTypeDescription
*expressionsanyPositional arguments representing the fields or expressions to be indexed.
lengthintThe total length of the bloom filter in kilobytes, ranging from 1 to 4096.
columns`listtuple`
**kwargsanyAdditional keyword arguments passed to the base PostgresIndex class.

Methods


deconstruct()

@classmethod
def deconstruct() - > tuple

Returns a 3-tuple containing the full import path, positional arguments, and keyword arguments required to recreate the index instance.

Returns

TypeDescription
tupleA tuple of (path, args, kwargs) used by Django's migration framework to serialize the index.

get_with_params()

@classmethod
def get_with_params() - > list

Generates a list of storage parameter strings specifically for the 'WITH' clause of a PostgreSQL CREATE INDEX statement.

Returns

TypeDescription
listA list of formatted strings such as 'length = 128' or 'col1 = 5' representing bloom filter configuration.