本文整理汇总了Java中me.prettyprint.hector.api.query.RangeSlicesQuery.addEqualsExpression方法的典型用法代码示例。如果您正苦于以下问题:Java RangeSlicesQuery.addEqualsExpression方法的具体用法?Java RangeSlicesQuery.addEqualsExpression怎么用?Java RangeSlicesQuery.addEqualsExpression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类me.prettyprint.hector.api.query.RangeSlicesQuery
的用法示例。
在下文中一共展示了RangeSlicesQuery.addEqualsExpression方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getArtifacts
import me.prettyprint.hector.api.query.RangeSlicesQuery; //导入方法依赖的package包/类
@Override
public List<ArtifactMetadata> getArtifacts( final String repositoryId )
throws MetadataRepositoryException
{
RangeSlicesQuery<String, String, String> query = HFactory //
.createRangeSlicesQuery( keyspace, ss, ss, ss ) //
.setColumnFamily( cassandraArchivaManager.getArtifactMetadataFamilyName() ) //
.setColumnNames( ArtifactMetadataModel.COLUMNS ); //
query = query.addEqualsExpression( REPOSITORY_NAME.toString(), repositoryId );
QueryResult<OrderedRows<String, String, String>> result = query.execute();
List<ArtifactMetadata> artifactMetadatas = new ArrayList<>( result.get().getCount() );
for ( Row<String, String, String> row : result.get() )
{
ColumnSlice<String, String> columnSlice = row.getColumnSlice();
artifactMetadatas.add( mapArtifactMetadataStringColumnSlice( columnSlice ) );
}
return artifactMetadatas;
}
示例2: getArtifactsByMetadata
import me.prettyprint.hector.api.query.RangeSlicesQuery; //导入方法依赖的package包/类
@Override
public List<ArtifactMetadata> getArtifactsByMetadata( String key, String value, String repositoryId )
throws MetadataRepositoryException
{
RangeSlicesQuery<String, String, String> query =
HFactory.createRangeSlicesQuery( keyspace, ss, ss, ss ) //
.setColumnFamily( cassandraArchivaManager.getMetadataFacetFamilyName() ) //
.setColumnNames( MetadataFacetModel.COLUMNS ) //
.addEqualsExpression( VALUE.toString(), value );
if ( key != null )
{
query.addEqualsExpression( KEY.toString(), key ); //
}
if ( repositoryId != null )
{
query.addEqualsExpression( "repositoryName", repositoryId );
}
QueryResult<OrderedRows<String, String, String>> metadataFacetResult = query.execute();
if ( metadataFacetResult.get() == null || metadataFacetResult.get().getCount() < 1 )
{
return Collections.emptyList();
}
List<ArtifactMetadata> artifactMetadatas = new LinkedList<ArtifactMetadata>();
// TODO doing multiple queries, there should be a way to get all the artifactMetadatas for any number of
// projects
for ( Row<String, String, String> row : metadataFacetResult.get() )
{
QueryResult<OrderedRows<String, String, String>> artifactMetadataResult =
HFactory.createRangeSlicesQuery( keyspace, ss, ss, ss ) //
.setColumnFamily( cassandraArchivaManager.getArtifactMetadataFamilyName() ) //
.setColumnNames( ArtifactMetadataModel.COLUMNS ) //
.setRowCount( Integer.MAX_VALUE ) //
.addEqualsExpression( REPOSITORY_NAME.toString(),
getStringValue( row.getColumnSlice(), REPOSITORY_NAME ) ) //
.addEqualsExpression( NAMESPACE_ID.toString(), getStringValue( row.getColumnSlice(), NAMESPACE_ID ) ) //
.addEqualsExpression( PROJECT.toString(), getStringValue( row.getColumnSlice(), PROJECT_ID ) ) //
.addEqualsExpression( PROJECT_VERSION.toString(),
getStringValue( row.getColumnSlice(), PROJECT_VERSION ) ) //
.execute();
if ( artifactMetadataResult.get() == null || artifactMetadataResult.get().getCount() < 1 )
{
return Collections.emptyList();
}
for ( Row<String, String, String> artifactMetadataRow : artifactMetadataResult.get() )
{
artifactMetadatas.add( mapArtifactMetadataStringColumnSlice( artifactMetadataRow.getColumnSlice() ) );
}
}
return mapArtifactMetadataToArtifact( metadataFacetResult, artifactMetadatas );
}
示例3: doListUsers
import me.prettyprint.hector.api.query.RangeSlicesQuery; //导入方法依赖的package包/类
/**
* Lists the users in the user store.
*/
@Override
protected String[] doListUsers(String filter, int maxItemLimit) throws UserStoreException {
List<String> users = new ArrayList<String>();
int arrayLength = 0;
if (maxItemLimit == 0) {
return new String[0];
}
int givenMax = UserCoreConstants.MAX_USER_ROLE_LIST;
try {
givenMax = Integer.parseInt(realmConfig
.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_MAX_USER_LIST));
} catch (Exception e) {
givenMax = UserCoreConstants.MAX_USER_ROLE_LIST;
if (log.isDebugEnabled()) {
log.debug("Realm configuration maximum not set : Using User Core Constant value instead!", e);
}
}
if (maxItemLimit < 0 || maxItemLimit > givenMax) {
maxItemLimit = givenMax;
}
RangeSlicesQuery<String, String, String> rangeSliceQuery = HFactory.createRangeSlicesQuery(keyspace,
stringSerializer, stringSerializer, stringSerializer);
rangeSliceQuery.setColumnFamily(CFConstants.UM_USER);
rangeSliceQuery.setRange(filter, null, false, Integer.MAX_VALUE);
rangeSliceQuery.addEqualsExpression(CFConstants.UM_TENANT_ID, tenantIdString);
// TODO - Need to check how to use the filter for range
rangeSliceQuery.setKeys("", "");
rangeSliceQuery.setRowCount(maxItemLimit);
QueryResult<OrderedRows<String, String, String>> result = rangeSliceQuery.execute();
if (result != null) {
OrderedRows<String, String, String> rows = result.get();
if (rows.getCount() <= 0) {
// reformatted to avoid nesting too many blocks
return users.toArray(new String[arrayLength]);
}
arrayLength = rows.getCount();
Iterator<Row<String, String, String>> rowsIterator = rows.iterator();
while (rowsIterator.hasNext()) {
Row<String, String, String> row = rowsIterator.next();
if (row.getColumnSlice().getColumnByName(CFConstants.UM_USER_ID).getValue() != null) {
String name = row.getColumnSlice().getColumnByName(CFConstants.UM_USER_NAME).getValue();
// append the domain if exist
name = UserCoreUtil.addDomainToName(name, domain);
users.add(name);
}
}
}
return users.toArray(new String[arrayLength]);
}
示例4: doGetRoleNames
import me.prettyprint.hector.api.query.RangeSlicesQuery; //导入方法依赖的package包/类
/**
* Get the role names in the roles store.
*/
@Override
public String[] doGetRoleNames(String filter, int maxItemLimit) throws UserStoreException {
List<String> roles = new ArrayList<String>();
if (maxItemLimit == 0) {
return new String[0];
}
int givenMax = UserCoreConstants.MAX_USER_ROLE_LIST;
try {
givenMax = Integer.parseInt(realmConfig
.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_MAX_ROLE_LIST));
} catch (Exception e) {
givenMax = UserCoreConstants.MAX_USER_ROLE_LIST;
if (log.isDebugEnabled()) {
log.debug("Realm configuration maximum not set : Using User Core Constant value instead!", e);
}
}
if (maxItemLimit < 0 || maxItemLimit > givenMax) {
maxItemLimit = givenMax;
}
int arrayLength = 0;
String domain = realmConfig.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_NAME);
RangeSlicesQuery<String, String, String> rangeSliceQuery = HFactory.createRangeSlicesQuery(keyspace,
stringSerializer, stringSerializer, stringSerializer);
rangeSliceQuery.setColumnFamily(CFConstants.UM_ROLES);
rangeSliceQuery.setRange(null, null, false, Integer.MAX_VALUE);
rangeSliceQuery.addEqualsExpression(CFConstants.UM_TENANT_ID, tenantIdString);
rangeSliceQuery.setKeys("", "");
rangeSliceQuery.setRowCount(maxItemLimit);
QueryResult<OrderedRows<String, String, String>> result = rangeSliceQuery.execute();
if (result != null) {
OrderedRows<String, String, String> rows = result.get();
if (rows.getCount() <= 0) {
return roles.toArray(new String[arrayLength]);
}
arrayLength = rows.getCount();
Iterator<Row<String, String, String>> rowsIterator = rows.iterator();
while (rowsIterator.hasNext()) {
Row<String, String, String> row = rowsIterator.next();
if (row.getColumnSlice().getColumnByName(CFConstants.UM_ROLE_NAME).getValue() != null) {
String name = row.getColumnSlice().getColumnByName(CFConstants.UM_ROLE_NAME).getValue();
// append the domain if exist
name = UserCoreUtil.addDomainToName(name, domain);
roles.add(name);
}
}
}
return roles.toArray(new String[arrayLength]);
}