本文整理汇总了Java中me.prettyprint.cassandra.service.template.ColumnFamilyTemplate.deleteColumn方法的典型用法代码示例。如果您正苦于以下问题:Java ColumnFamilyTemplate.deleteColumn方法的具体用法?Java ColumnFamilyTemplate.deleteColumn怎么用?Java ColumnFamilyTemplate.deleteColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类me.prettyprint.cassandra.service.template.ColumnFamilyTemplate
的用法示例。
在下文中一共展示了ColumnFamilyTemplate.deleteColumn方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteColumn
import me.prettyprint.cassandra.service.template.ColumnFamilyTemplate; //导入方法依赖的package包/类
/**
* Deletes a given column value of a row identified by the key.
*
* @param key - key of the row.
* @param columnName - name of the column to be deleted.
*/
public void deleteColumn(K key, String columnName) {
final ColumnFamilyTemplate<K, String> columnFamily1 = getColumnFamily();
final HColumn<String, String> oldValue = readColumn(key, columnName);
// is this insertion involves a change to secondary indexes
if (isSecondaryIndexByColumnNameAndValueEnabled && Collections.binarySearch(columnsToIndexOnColumnNameAndValue,
columnName) >= 0 &&
oldValue != null) {
secondaryIndexedColumnFamilyTemplate.deleteColumn(getSecondaryIndexKey(columnName, oldValue.getValue()),
key);
}
if (isSecondaryIndexesByColumnNamesEnabled && columnName.matches(secondaryIdxByColumnPattern)) {
secondaryIndexedColumnFamilyTemplate.deleteColumn(getSecondaryIndexKey(columnName, ""), key);
}
columnFamily1.deleteColumn(key, columnName);
}
示例2: doDeleteUser
import me.prettyprint.cassandra.service.template.ColumnFamilyTemplate; //导入方法依赖的package包/类
/**
* Deletes a user by userName.
*/
@Override
public void doDeleteUser(String userName) throws UserStoreException {
Mutator<Composite> mutator = HFactory.createMutator(keyspace, CompositeSerializer.get());
String[] roles = doGetExternalRoleListOfUser(userName, "");
for (String role : roles) {
Composite key = new Composite();
key.addComponent(role, stringSerializer);
key.addComponent(tenantIdString, stringSerializer);
ColumnFamilyTemplate<Composite, String> userCFTemplate = new ThriftColumnFamilyTemplate<Composite, String>(
keyspace, CFConstants.UM_ROLE_USER_INDEX, CompositeSerializer.get(), StringSerializer.get());
try {
userCFTemplate.deleteColumn(key, userName);
} catch (HectorException e) {
log.error("Error during deletion ", e);
}
}
Composite userKey = new Composite();
userKey.addComponent(userName, stringSerializer);
userKey.addComponent(tenantIdString, stringSerializer);
mutator.addDeletion(userKey, CFConstants.UM_USER_ROLE, null, CompositeSerializer.get());
mutator.addDeletion(userKey, CFConstants.UM_USER, null, CompositeSerializer.get());
mutator.execute();
if (log.isDebugEnabled()) {
log.debug("Deleted user " + userName + " successfully");
}
}
示例3: doUpdateUserListOfRole
import me.prettyprint.cassandra.service.template.ColumnFamilyTemplate; //导入方法依赖的package包/类
/**
* Update the user list mapped to a role.
*/
@Override
public void doUpdateUserListOfRole(String roleName, String[] deletedUsers, String[] newUsers)
throws UserStoreException {
Mutator<Composite> mutator = HFactory.createMutator(keyspace, CompositeSerializer.get());
RoleContext ctx = createRoleContext(roleName);
roleName = ctx.getRoleName();
boolean isShared = ctx.isShared();
if (!isShared) {
//TODO TO BE Implemented
}
if (deletedUsers != null && deletedUsers.length > 0) {
if (isShared) {
//TODO TO BE Implemented
} else {
if (deletedUsers.length > 0) {
Composite key = new Composite();
key.addComponent(roleName, stringSerializer);
key.addComponent(tenantIdString, stringSerializer);
for (String user : deletedUsers) {
Composite userKey = new Composite();
userKey.addComponent(user, stringSerializer);
userKey.addComponent(tenantIdString, stringSerializer);
ColumnFamilyTemplate<Composite, String> userCFTemplate = new ThriftColumnFamilyTemplate<Composite, String>(
keyspace, CFConstants.UM_USER_ROLE, CompositeSerializer.get(), StringSerializer.get());
ColumnFamilyTemplate<Composite, String> roleCFTemplate = new ThriftColumnFamilyTemplate<Composite, String>(
keyspace, CFConstants.UM_ROLE_USER_INDEX, CompositeSerializer.get(),
StringSerializer.get());
try {
roleCFTemplate.deleteColumn(mutator, key, user);
userCFTemplate.deleteColumn(mutator, userKey, roleName);
} catch (HectorException e) {
log.error(e.getMessage(), e);
throw new UserStoreException("Error during the updating of a user's role list");
}
}
}
}
}
// need to clear user roles cache upon roles update
clearUserRolesCacheByTenant(this.tenantId);
if (newUsers != null && newUsers.length > 0) {
if (isShared) {
//TODO TO BE Implemented
} else {
addRoleToUsersList(newUsers, roleName, mutator);
}
}
mutator.execute();
}
示例4: delete
import me.prettyprint.cassandra.service.template.ColumnFamilyTemplate; //导入方法依赖的package包/类
private void delete(ColumnFamilyTemplate<String, String> template) {
ColumnFamilyResult<String, String> res = template.queryColumns("a key");
String value = res.getString("domain");
template.deleteColumn("key", "column name");
}