response = self.rest.request(method='post', path=path, data=data)
return response
+ def index_create(self, keyspace, table, index):
+
+ """Create indexes for a particular table"""
+
+ path = '/keyspaces/%(keyspace)s/tables/%(table)s/index/%(field)s' % {
+ 'keyspace': keyspace,
+ 'table': table,
+ 'field': index
+ }
+ response = self.rest.request(method='post', path=path)
+ return response
def row_complex_field_update(self, keyspace, table, pk_name, pk_value, plan_id, updated_fields, values):
def _set_table(self, keyspace, table):
self._keyspaces[keyspace][table] = {}
+ def _set_index(self, keyspace, table):
+ self._keyspaces[keyspace][table] = {}
+
def _unset_table(self, keyspace, table):
self._keyspaces[keyspace].pop(table)
self._set_table(keyspace, table)
return True
+ def index_create(self, keyspace, table, index=None):
+ """Creates a index."""
+ if CONF.music_api.debug:
+ LOG.debug("Creating index {}, keyspace {}".format(table, keyspace))
+ self._set_index(keyspace, table)
+ return True
+
def table_delete(self, keyspace, table):
"""Creates a table."""
if CONF.music_api.debug:
kwargs['schema'] = cls.schema()
api.MUSIC_API.table_create(**kwargs)
+ # Create indexes for the table
+ del kwargs['schema']
+ if cls.indexes():
+ for index in cls.indexes():
+ kwargs['index'] = index
+ api.MUSIC_API.index_create(**kwargs)
+
@abstractclassmethod
def atomic(cls):
"""Use atomic operations"""
"""Return schema"""
return cls()
+ @classmethod
+ def indexes(cls):
+ """Return Indexes"""
+ pass
+ # return cls()
+
@abstractclassmethod
def pk_name(cls):
"""Primary key name"""