本文整理汇总了Java中me.prettyprint.hector.api.beans.Composite.addComponent方法的典型用法代码示例。如果您正苦于以下问题:Java Composite.addComponent方法的具体用法?Java Composite.addComponent怎么用?Java Composite.addComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类me.prettyprint.hector.api.beans.Composite
的用法示例。
在下文中一共展示了Composite.addComponent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteInSPOC
import me.prettyprint.hector.api.beans.Composite; //导入方法依赖的package包/类
/**
* Deletes in SPOC index.
*
* @param rowKey the row key.
* @param ids the triple identifiers
* @throws DataAccessLayerException in case of data access failure.
*/
void deleteInSPOC(final byte[] rowKey, final byte[][]ids) throws DataAccessLayerException {
final Composite poc_col = new Composite();
// predicate
poc_col.addComponent(ids[1], BYTE_SERIALIZER);
// object
poc_col.addComponent(ids[2], BYTE_SERIALIZER);
if (ids.length == 4) {
// context
poc_col.addComponent(ids[3], BYTE_SERIALIZER);
}
_mutators.get().addDeletion(rowKey, S_POC, poc_col, COMPOSITE_SERIALIZER);
}
示例2: doCheckExistingRole
import me.prettyprint.hector.api.beans.Composite; //导入方法依赖的package包/类
/**
* Checks if the role is existing the role store.
*/
@Override
protected boolean doCheckExistingRole(String roleNameWithTenantDomain) throws UserStoreException {
RoleContext roleContext = createRoleContext(roleNameWithTenantDomain);
boolean isExisting = false;
String roleName = roleContext.getRoleName();
Composite key = new Composite();
key.addComponent(roleName, stringSerializer);
key.addComponent(tenantIdString, stringSerializer);
ColumnQuery<Composite, String, String> getCredentialQuery = HFactory.createColumnQuery(keyspace,
CompositeSerializer.get(), stringSerializer, stringSerializer);
getCredentialQuery.setColumnFamily(CFConstants.UM_ROLES).setKey(key).setName(CFConstants.UM_ROLE_NAME);
HColumn<String, String> result = getCredentialQuery.execute().get();
if (result != null && result.getValue() != null) {
isExisting = true;
}
return isExisting;
}
示例3: doCheckExistingUser
import me.prettyprint.hector.api.beans.Composite; //导入方法依赖的package包/类
/**
* Checks if the user is existing in the user store.
*/
@Override
protected boolean doCheckExistingUser(String userName) throws UserStoreException {
Boolean isExist = false;
Composite key = new Composite();
key.addComponent(userName, stringSerializer);
key.addComponent(tenantIdString, stringSerializer);
ColumnQuery<Composite, String, String> getCredentialQuery = HFactory.createColumnQuery(keyspace,
CompositeSerializer.get(), stringSerializer, stringSerializer);
getCredentialQuery.setColumnFamily(CFConstants.UM_USER).setKey(key).setName(CFConstants.UM_USER_NAME);
HColumn<String, String> result = getCredentialQuery.execute().get();
if (result != null && result.getValue() != null) {
isExist = true;
}
return isExist;
}
示例4: doAddRole
import me.prettyprint.hector.api.beans.Composite; //导入方法依赖的package包/类
/**
* Adds a role to the role store.
*/
@Override
public void doAddRole(String roleName, String[] userList, boolean shared) throws UserStoreException {
Mutator<Composite> mutator = HFactory.createMutator(keyspace, CompositeSerializer.get());
Composite composite = new Composite();
composite.addComponent(roleName, stringSerializer);
composite.addComponent(tenantIdString, stringSerializer);
mutator.addInsertion(composite, CFConstants.UM_ROLES,
HFactory.createColumn(CFConstants.UM_ROLE_NAME, roleName, stringSerializer, stringSerializer));
mutator.addInsertion(composite, CFConstants.UM_ROLES,
HFactory.createColumn(CFConstants.UM_TENANT_ID, tenantIdString, stringSerializer, stringSerializer));
if (userList != null && userList.length > 0) {
addRoleToUsersList(userList, roleName, mutator);
}
mutator.execute();
}
示例5: addUserToRoleList
import me.prettyprint.hector.api.beans.Composite; //导入方法依赖的package包/类
/**
* Maps the users to a role list. Adds the (username, tenantId) -> roleList
* and (role, tenantId) -> userName
*
* @param userName The username of the user the roles need to be added to.
* @param roleList The list of roles that needs to be mapped against the user.
*/
private void addUserToRoleList(String userName, String[] roleList) {
Mutator<Composite> mutator = HFactory.createMutator(keyspace, CompositeSerializer.get());
if (roleList != null) {
for (String role : roleList) {
Composite key = new Composite();
key.addComponent(userName, stringSerializer);
key.addComponent(tenantIdString, stringSerializer);
mutator.addInsertion(key, CFConstants.UM_USER_ROLE, HFactory.createColumn(role, role));
Composite keyRole = new Composite();
keyRole.addComponent(role, stringSerializer);
keyRole.addComponent(tenantIdString, stringSerializer);
mutator.addInsertion(keyRole, CFConstants.UM_ROLE_USER_INDEX, HFactory.createColumn(userName, userName));
}
mutator.execute();
}
}
示例6: addRoleToUsersList
import me.prettyprint.hector.api.beans.Composite; //导入方法依赖的package包/类
/**
* Maps the role to a user list. Adds the (username, tenantId) -> roleList
* and (role, tenantId) -> userName
*
* @param userNames The username list of the user the role need to be added to.
* @param roleName The role that needs to be mapped against the user list.
* @param mutator Passes the mutator and returns it with the insert statements.
*/
private Mutator<Composite> addRoleToUsersList(String[] userNames, String roleName, Mutator<Composite> mutator) {
if (userNames != null) {
for (String userName : userNames) {
Composite key = new Composite();
key.addComponent(userName, stringSerializer);
key.addComponent(tenantIdString, stringSerializer);
mutator.addInsertion(key, CFConstants.UM_USER_ROLE, HFactory.createColumn(roleName, roleName));
Composite keyRole = new Composite();
keyRole.addComponent(roleName, stringSerializer);
keyRole.addComponent(tenantIdString, stringSerializer);
mutator.addInsertion(keyRole, CFConstants.UM_ROLE_USER_INDEX, HFactory.createColumn(userName, userName));
}
}
return mutator;
}
示例7: doGetUserListOfRole
import me.prettyprint.hector.api.beans.Composite; //导入方法依赖的package包/类
/**
* Get the list of users mapped to a role.
*/
@Override
public String[] doGetUserListOfRole(String roleName, String filter) throws UserStoreException {
List<String> usersList = new ArrayList<String>();
Composite key = new Composite();
key.addComponent(roleName, stringSerializer);
key.addComponent(tenantIdString, stringSerializer);
SliceQuery<Composite, String, String> query = HFactory
.createSliceQuery(keyspace, CompositeSerializer.get(), StringSerializer.get(), StringSerializer.get())
.setKey(key).setColumnFamily(CFConstants.UM_ROLE_USER_INDEX);
ColumnSliceIterator<Composite, String, String> iterator = new ColumnSliceIterator<Composite, String, String>(
query, null, "\uFFFF", false);
while (iterator.hasNext()) {
HColumn<String, String> column = iterator.next();
usersList.add(column.getValue());
}
return usersList.toArray(new String[usersList.size()]);
}
示例8: doGetExternalRoleListOfUser
import me.prettyprint.hector.api.beans.Composite; //导入方法依赖的package包/类
/**
* Gets the external role list of a user.
*/
@Override
public String[] doGetExternalRoleListOfUser(String userName, String filter) throws UserStoreException {
List<String> roles = new ArrayList<String>();
int arrayLength = 0;
Composite key = new Composite();
key.addComponent(userName, stringSerializer);
key.addComponent(tenantIdString, stringSerializer);
SliceQuery<Composite, String, String> query = HFactory
.createSliceQuery(keyspace, CompositeSerializer.get(), StringSerializer.get(), StringSerializer.get())
.setKey(key).setColumnFamily(CFConstants.UM_USER_ROLE);
ColumnSliceIterator<Composite, String, String> iterator = new ColumnSliceIterator<Composite, String, String>(
query, null, "\uFFFF", false);
while (iterator.hasNext()) {
HColumn<String, String> column = iterator.next();
roles.add(column.getValue());
}
return roles.toArray(new String[arrayLength]);
}
示例9: deleteInOSPC
import me.prettyprint.hector.api.beans.Composite; //导入方法依赖的package包/类
/**
* Deletes in OPSC index.
*
* @param rowKey the row key.
* @param ids the triple identifiers
* @throws DataAccessLayerException in case of data access failure.
*/
void deleteInOSPC(final byte[] rowKey, final byte[][]ids) throws DataAccessLayerException {
final Composite spc_col = new Composite();
spc_col.addComponent(ids[0], BYTE_SERIALIZER);
spc_col.addComponent(ids[1], BYTE_SERIALIZER);
if (ids.length == 4) {
spc_col.addComponent(ids[3], BYTE_SERIALIZER);
}
_mutators.get().addDeletion(rowKey, O_SPC, spc_col, COMPOSITE_SERIALIZER);
}
示例10: deleteInPOSC
import me.prettyprint.hector.api.beans.Composite; //导入方法依赖的package包/类
/**
* Deletes in POSC index.
*
* @param rowKey the row key.
* @param ids the triple identifiers
* @throws DataAccessLayerException in case of data access failure.
*/
void deleteInPOSC(final byte[] rowKey, final byte[][]ids) throws DataAccessLayerException {
final Composite sc_col = new Composite();
// subject
sc_col.addComponent(ids[0], BYTE_SERIALIZER);
if (ids.length == 4) {
// context
sc_col.addComponent(ids[3], BYTE_SERIALIZER);
}
_mutators.get().addDeletion(rowKey, ColumnFamily.PO_SC, sc_col, COMPOSITE_SERIALIZER);
}
示例11: insertInOPSC
import me.prettyprint.hector.api.beans.Composite; //导入方法依赖的package包/类
/**
* Insert a triple in OPSC index.
*
* @param rowKey the row key.
* @param ids the triple identifiers
* @throws DataAccessLayerException in case of data access failure.
*/
void insertInOPSC(final byte [] rowKey, final byte[][]ids) throws DataAccessLayerException {
final Composite spc_col = new Composite();
spc_col.addComponent(ids[0], BYTE_SERIALIZER);
spc_col.addComponent(ids[1], BYTE_SERIALIZER);
if (ids.length == 4) {
spc_col.addComponent(ids[3], BYTE_SERIALIZER);
}
_mutators.get().addInsertion(rowKey, O_SPC, HFactory.createColumn(spc_col, EMPTY_VAL, COMPOSITE_SERIALIZER, BYTE_SERIALIZER));
}
示例12: insertInPOSC
import me.prettyprint.hector.api.beans.Composite; //导入方法依赖的package包/类
/**
* Insert a triple in POSC index.
*
* @param rowKey the row key.
* @param ids the triple identifiers
* @throws DataAccessLayerException in case of data access failure.
*/
void insertInPOSC(final byte [] rowKey, final byte[][]ids) throws DataAccessLayerException {
final Composite sc_col = new Composite();
sc_col.addComponent(ids[0], BYTE_SERIALIZER);
if (ids.length == 4) {
sc_col.addComponent(ids[3], BYTE_SERIALIZER);
}
// subject col
_mutators.get()
.addInsertion(rowKey, PO_SC, HFactory.createColumn(sc_col, EMPTY_VAL, COMPOSITE_SERIALIZER, BYTE_SERIALIZER))
.addInsertion(rowKey, PO_SC, HFactory.createColumn(P_COL, ids[1], COMPOSITE_SERIALIZER, BYTE_SERIALIZER));
}
示例13: insertInSPOC
import me.prettyprint.hector.api.beans.Composite; //导入方法依赖的package包/类
/**
* Insert a triple in SPOC index.
*
* @param rowKey the row key.
* @param ids the triple identifiers
* @throws DataAccessLayerException in case of data access failure.
*/
void insertInSPOC(final byte [] rowKey, final byte[][]ids) throws DataAccessLayerException {
final Composite poc_col = new Composite();
poc_col.addComponent(ids[1], BYTE_SERIALIZER);
poc_col.addComponent(ids[2], BYTE_SERIALIZER);
if (ids.length == 4) {
poc_col.addComponent(ids[3], BYTE_SERIALIZER);
}
_mutators.get().addInsertion(rowKey, S_POC, HFactory.createColumn(poc_col, EMPTY_VAL, COMPOSITE_SERIALIZER, BYTE_SERIALIZER));
}
示例14: insertTriple
import me.prettyprint.hector.api.beans.Composite; //导入方法依赖的package包/类
@Override
public void insertTriple(final byte[][] ids) throws DataAccessLayerException {
super.insertTriple(ids);
// Insert in OC_PS
// Key: O + C
byte[] oc_row = _dictionary.compose(ids[2], ids[3]);
final Composite sp_col = new Composite();
sp_col.addComponent(ids[1], BYTE_SERIALIZER);
sp_col.addComponent(ids[0], BYTE_SERIALIZER);
// subject + predicate col
_mutators.get().addInsertion(oc_row, OC_PS, HFactory.createColumn(sp_col, EMPTY_VAL, COMPOSITE_SERIALIZER, BYTE_SERIALIZER));
// context col
_mutators.get().addInsertion(oc_row, OC_PS, HFactory.createColumn(C_COL, ids[3], COMPOSITE_SERIALIZER, BYTE_SERIALIZER));
// Insert in SC_OP
// Key: S + C
final byte[] sc_row = _dictionary.compose(ids[0], ids[3]);
final Composite op_col = new Composite();
op_col.addComponent(ids[2], BYTE_SERIALIZER);
op_col.addComponent(ids[1], BYTE_SERIALIZER);
_mutators.get().addInsertion(sc_row, SC_OP, HFactory.createColumn(op_col, EMPTY_VAL, COMPOSITE_SERIALIZER, BYTE_SERIALIZER));
// Insert in SPC_O
// Key: S + P + C
byte[] spc_row = _dictionary.compose(ids[0], ids[1], ids[3]);
byte[] pc_val = _dictionary.compose(ids[1], ids[3]);
final Composite o_col = new Composite();
o_col.addComponent(ids[2], BYTE_SERIALIZER);
// object col
_mutators.get().addInsertion(spc_row, SPC_O, HFactory.createColumn(o_col, EMPTY_VAL, COMPOSITE_SERIALIZER, BYTE_SERIALIZER));
// predicate + context col
_mutators.get().addInsertion(spc_row, SPC_O, HFactory.createColumn(PC_COL, pc_val, COMPOSITE_SERIALIZER, BYTE_SERIALIZER));
}
示例15: doDeleteUser
import me.prettyprint.hector.api.beans.Composite; //导入方法依赖的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");
}
}