MCPcopy Create free account
hub / github.com/apache/cassandra-python-driver / _build_index_metadata

Method _build_index_metadata

cassandra/metadata.py:2336–2363  ·  view source on GitHub ↗
(column_metadata, row)

Source from the content-addressed store, hash-verified

2334
2335 @staticmethod
2336 def _build_index_metadata(column_metadata, row):
2337 index_name = row.get("index_name")
2338 kind = row.get("index_type")
2339 if index_name or kind:
2340 options = row.get("index_options")
2341 options = json.loads(options) if options else {}
2342 options = options or {} # if the json parsed to None, init empty dict
2343
2344 # generate a CQL index identity string
2345 target = protect_name(column_metadata.name)
2346 if kind != "CUSTOM":
2347 if "index_keys" in options:
2348 target = 'keys(%s)' % (target,)
2349 elif "index_values" in options:
2350 # don't use any "function" for collection values
2351 pass
2352 else:
2353 # it might be a "full" index on a frozen collection, but
2354 # we need to check the data type to verify that, because
2355 # there is no special index option for full-collection
2356 # indexes.
2357 data_type = column_metadata._cass_type
2358 collection_types = ('map', 'set', 'list')
2359 if data_type.typename == "frozen" and data_type.subtypes[0].typename in collection_types:
2360 # no index option for full-collection index
2361 target = 'full(%s)' % (target,)
2362 options['target'] = target
2363 return IndexMetadata(column_metadata.table.keyspace_name, column_metadata.table.name, index_name, kind, options)
2364
2365 @staticmethod
2366 def _build_trigger_metadata(table_metadata, row):

Callers 1

_build_table_metadataMethod · 0.95

Calls 3

protect_nameFunction · 0.85
IndexMetadataClass · 0.85
getMethod · 0.45

Tested by

no test coverage detected