本文整理汇总了Java中com.datastax.driver.core.querybuilder.Select.Where方法的典型用法代码示例。如果您正苦于以下问题:Java Select.Where方法的具体用法?Java Select.Where怎么用?Java Select.Where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.datastax.driver.core.querybuilder.Select
的用法示例。
在下文中一共展示了Select.Where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findDeviceTypesByTenantIdCustomerIdAndIdsAsync
import com.datastax.driver.core.querybuilder.Select; //导入方法依赖的package包/类
@Override
public ListenableFuture<List<DeviceType>> findDeviceTypesByTenantIdCustomerIdAndIdsAsync(UUID tenantId, UUID customerId, List<UUID> deviceIds) {
log.debug("Try to find devices by tenantId [{}], customerId [{}] and device Ids [{}]", tenantId, customerId, deviceIds);
Select select = select().from(getColumnFamilyName());
Select.Where query = select.where();
query.and(eq(DEVICE_TYPE_TENANT_ID_PROPERTY, tenantId));
query.and(eq(DEVICE_TYPE_CUSTOMER_ID_PROPERTY, customerId));
query.and(in(ID_PROPERTY, deviceIds));
return findListByStatementAsync(query);
}
示例2: findRelations
import com.datastax.driver.core.querybuilder.Select; //导入方法依赖的package包/类
@Override
public ListenableFuture<List<EntityRelation>> findRelations(EntityId from, String relationType, RelationTypeGroup typeGroup, ThingType childType, TimePageLink pageLink) {
Select.Where query = CassandraAbstractSearchTimeDao.buildQuery(ModelConstants.RELATION_BY_TYPE_AND_CHILD_TYPE_VIEW_NAME,
Arrays.asList(eq(ModelConstants.RELATION_FROM_ID_PROPERTY, from.getId()),
eq(ModelConstants.RELATION_FROM_TYPE_PROPERTY, from.getEntityType().name()),
eq(ModelConstants.RELATION_TYPE_GROUP_PROPERTY, typeGroup.name()),
eq(ModelConstants.RELATION_TYPE_PROPERTY, relationType),
eq(ModelConstants.RELATION_TO_TYPE_PROPERTY, childType.name())),
Arrays.asList(
pageLink.isAscOrder() ? QueryBuilder.desc(ModelConstants.RELATION_TYPE_GROUP_PROPERTY) :
QueryBuilder.asc(ModelConstants.RELATION_TYPE_GROUP_PROPERTY),
pageLink.isAscOrder() ? QueryBuilder.desc(ModelConstants.RELATION_TYPE_PROPERTY) :
QueryBuilder.asc(ModelConstants.RELATION_TYPE_PROPERTY),
pageLink.isAscOrder() ? QueryBuilder.desc(ModelConstants.RELATION_TO_TYPE_PROPERTY) :
QueryBuilder.asc(ModelConstants.RELATION_TO_TYPE_PROPERTY)
),
pageLink, ModelConstants.RELATION_TO_ID_PROPERTY);
return getFuture(executeAsyncRead(query), this::getEntityRelations);
}
示例3: findEvent
import com.datastax.driver.core.querybuilder.Select; //导入方法依赖的package包/类
@Override
public Event findEvent(UUID tenantId, EntityId entityId, String eventType, String eventUid) {
log.debug("Search event entity by [{}][{}][{}][{}]", tenantId, entityId, eventType, eventUid);
Select.Where query = select().from(getColumnFamilyName()).where(
eq(ModelConstants.EVENT_TENANT_ID_PROPERTY, tenantId))
.and(eq(ModelConstants.EVENT_ENTITY_TYPE_PROPERTY, entityId.getEntityType()))
.and(eq(ModelConstants.EVENT_ENTITY_ID_PROPERTY, entityId.getId()))
.and(eq(ModelConstants.EVENT_TYPE_PROPERTY, eventType))
.and(eq(ModelConstants.EVENT_UID_PROPERTY, eventUid));
log.trace("Execute query [{}]", query);
EventEntity entity = findOneByStatement(query);
if (log.isTraceEnabled()) {
log.trace("Search result: [{}] for event entity [{}]", entity != null, entity);
} else {
log.debug("Search result: [{}]", entity != null);
}
return DaoUtil.getData(entity);
}
示例4: findTenantAssetTypesAsync
import com.datastax.driver.core.querybuilder.Select; //导入方法依赖的package包/类
@Override
public ListenableFuture<List<EntitySubtype>> findTenantAssetTypesAsync(UUID tenantId) {
Select select = select().from(ENTITY_SUBTYPE_COLUMN_FAMILY_NAME);
Select.Where query = select.where();
query.and(eq(ENTITY_SUBTYPE_TENANT_ID_PROPERTY, tenantId));
query.and(eq(ENTITY_SUBTYPE_ENTITY_TYPE_PROPERTY, EntityType.ASSET));
query.setConsistencyLevel(cluster.getDefaultReadConsistencyLevel());
ResultSetFuture resultSetFuture = getSession().executeAsync(query);
return Futures.transform(resultSetFuture, new Function<ResultSet, List<EntitySubtype>>() {
@Nullable
@Override
public List<EntitySubtype> apply(@Nullable ResultSet resultSet) {
Result<EntitySubtypeEntity> result = cluster.getMapper(EntitySubtypeEntity.class).map(resultSet);
if (result != null) {
List<EntitySubtype> entitySubtypes = new ArrayList<>();
result.all().forEach((entitySubtypeEntity) ->
entitySubtypes.add(entitySubtypeEntity.toEntitySubtype())
);
return entitySubtypes;
} else {
return Collections.emptyList();
}
}
});
}
示例5: findRelations
import com.datastax.driver.core.querybuilder.Select; //导入方法依赖的package包/类
@Override
public ListenableFuture<List<EntityRelation>> findRelations(EntityId from, String relationType, RelationTypeGroup typeGroup, EntityType childType, TimePageLink pageLink) {
Select.Where query = CassandraAbstractSearchTimeDao.buildQuery(ModelConstants.RELATION_BY_TYPE_AND_CHILD_TYPE_VIEW_NAME,
Arrays.asList(eq(ModelConstants.RELATION_FROM_ID_PROPERTY, from.getId()),
eq(ModelConstants.RELATION_FROM_TYPE_PROPERTY, from.getEntityType().name()),
eq(ModelConstants.RELATION_TYPE_GROUP_PROPERTY, typeGroup.name()),
eq(ModelConstants.RELATION_TYPE_PROPERTY, relationType),
eq(ModelConstants.RELATION_TO_TYPE_PROPERTY, childType.name())),
Arrays.asList(
pageLink.isAscOrder() ? QueryBuilder.desc(ModelConstants.RELATION_TYPE_GROUP_PROPERTY) :
QueryBuilder.asc(ModelConstants.RELATION_TYPE_GROUP_PROPERTY),
pageLink.isAscOrder() ? QueryBuilder.desc(ModelConstants.RELATION_TYPE_PROPERTY) :
QueryBuilder.asc(ModelConstants.RELATION_TYPE_PROPERTY),
pageLink.isAscOrder() ? QueryBuilder.desc(ModelConstants.RELATION_TO_TYPE_PROPERTY) :
QueryBuilder.asc(ModelConstants.RELATION_TO_TYPE_PROPERTY)
),
pageLink, ModelConstants.RELATION_TO_ID_PROPERTY);
return getFuture(executeAsyncRead(query), this::getEntityRelations);
}
示例6: findTenantDeviceTypesAsync
import com.datastax.driver.core.querybuilder.Select; //导入方法依赖的package包/类
@Override
public ListenableFuture<List<EntitySubtype>> findTenantDeviceTypesAsync(UUID tenantId) {
Select select = select().from(ENTITY_SUBTYPE_COLUMN_FAMILY_NAME);
Select.Where query = select.where();
query.and(eq(ENTITY_SUBTYPE_TENANT_ID_PROPERTY, tenantId));
query.and(eq(ENTITY_SUBTYPE_ENTITY_TYPE_PROPERTY, EntityType.DEVICE));
query.setConsistencyLevel(cluster.getDefaultReadConsistencyLevel());
ResultSetFuture resultSetFuture = getSession().executeAsync(query);
return Futures.transform(resultSetFuture, new Function<ResultSet, List<EntitySubtype>>() {
@Nullable
@Override
public List<EntitySubtype> apply(@Nullable ResultSet resultSet) {
Result<EntitySubtypeEntity> result = cluster.getMapper(EntitySubtypeEntity.class).map(resultSet);
if (result != null) {
List<EntitySubtype> entitySubtypes = new ArrayList<>();
result.all().forEach((entitySubtypeEntity) ->
entitySubtypes.add(entitySubtypeEntity.toEntitySubtype())
);
return entitySubtypes;
} else {
return Collections.emptyList();
}
}
});
}
示例7: get
import com.datastax.driver.core.querybuilder.Select; //导入方法依赖的package包/类
public List<Row> get() {
Select.Where where = QueryBuilder.select().from(parent.getKeyspace(), parent.getTable()).where();
for (Clause clause : clauses) {
where.and(clause);
}
if (searchBuilder != null) {
where.and(QueryBuilder.eq(parent.getIndexColumn(), searchBuilder.refresh(refresh).toJson()));
}
BuiltStatement statement = limit == null ? where : where.limit(limit);
String query = statement.toString();
query = query.substring(0, query.length() - 1);
StringBuilder sb = new StringBuilder(query);
for (String extra : extras) {
sb.append(" ");
sb.append(extra);
sb.append(" ");
}
return parent.execute(sb, fetchSize);
}
示例8: findByEvent
import com.datastax.driver.core.querybuilder.Select; //导入方法依赖的package包/类
@Override
public Collection<Badge> findByEvent(String event) {
Map<UUID, Badge> badges = new HashMap<>();
Select.Where select = QueryBuilder.select().distinct().column("badge_id")
.from("badge_events")
.where(QueryBuilder.eq("event", event));
ResultSet set = session.execute(select);
for(Row row:set.all()) {
UUID badgeId = row.getUUID("badge_id");
if(badges.get(badgeId) == null) {
badges.put(badgeId, get(badgeId).get());
}
}
return badges.values();
}
示例9: findGoalsByBadgeId
import com.datastax.driver.core.querybuilder.Select; //导入方法依赖的package包/类
@Override
public List<Goal> findGoalsByBadgeId(UUID badgeId) {
Select.Where goalQuery = QueryBuilder.select("event", "count")
.from("badge_events")
.where(QueryBuilder.eq("badge_id", badgeId));
ResultSet rows = session.execute(goalQuery);
List<Goal> goals = new ArrayList<>();
for (Row row : rows) {
goals.add(new Goal.Builder()
.event(row.getString("event"))
.value(row.getInt("count"))
.build());
}
return goals;
}
示例10: get
import com.datastax.driver.core.querybuilder.Select; //导入方法依赖的package包/类
@Override
public Optional<Badge> get(UUID id) {
Select.Where badgeQuery = QueryBuilder
.select()
.all()
.from("badges")
.where(QueryBuilder.eq("id", id));
ResultSet set = session.execute(badgeQuery);
Row row = set.one();
return Optional.of(new Badge.Builder().id(row.getUUID("id"))
.retired(row.getBool("retired"))
.description(row.getString("description"))
.name(row.getString("name"))
.goals(findGoalsByBadgeId(id))
.url(row.getString("url"))
.build());
}
示例11: evaluate
import com.datastax.driver.core.querybuilder.Select; //导入方法依赖的package包/类
@Override
public boolean evaluate(long playerId, Badge badge) {
if(hasEarned(playerId, badge.getId())) return false;
int goalsAchieved = 0;
for (Goal goal : badge.getGoals()) {
Select.Where eval = QueryBuilder.select().all()
.from("player_event_counts")
.where(QueryBuilder.eq("player_id", playerId))
.and(QueryBuilder.eq("event", goal.getEvent()));
ResultSet resultSet = session.execute(eval);
Row row = resultSet.one();
if(row != null) {
long count = row.getLong("counter_value");
if(count >= goal.getValue() ) {
goalsAchieved++;
}
}
}
return goalsAchieved == badge.getGoals().size();
}
示例12: findByUserIdAndAppTokenAndSchemaVersion
import com.datastax.driver.core.querybuilder.Select; //导入方法依赖的package包/类
@Override
public CassandraEndpointUserConfiguration findByUserIdAndAppTokenAndSchemaVersion(
String userId,
String appToken,
Integer schemaVersion
) {
LOG.debug("Searching for user specific configuration by user id {}, "
+ "application token {} and schema version {}",
userId, appToken, schemaVersion);
Select.Where select = select().from(getColumnFamilyName())
.where(eq(EP_USER_CONF_USER_ID_PROPERTY, userId))
.and(eq(EP_USER_CONF_APP_TOKEN_PROPERTY, appToken))
.and(eq(EP_USER_CONF_VERSION_PROPERTY, schemaVersion));
CassandraEndpointUserConfiguration userConfiguration = findOneByStatement(select);
if (LOG.isTraceEnabled()) {
LOG.debug("[{},{},{}] Search result: {}.",
userId, appToken, schemaVersion, userConfiguration);
} else {
LOG.debug("[{},{},{}] Search result: {}.",
userId, appToken, schemaVersion, userConfiguration != null);
}
return userConfiguration;
}
示例13: createPreparedStatements
import com.datastax.driver.core.querybuilder.Select; //导入方法依赖的package包/类
private void createPreparedStatements() {
Select.Where select = select()
.all()
.from( CassandraModel.CF_METRICS_METADATA_NAME )
.where( eq( KEY, bindMarker() ));
getValue = DatastaxIO.getSession().prepare( select );
Insert insert = insertInto( CassandraModel.CF_METRICS_METADATA_NAME )
.value( KEY, bindMarker() )
.value( COLUMN1, bindMarker() )
.value( VALUE, bindMarker() );
putValue = DatastaxIO.getSession().prepare( insert );
putValue.setConsistencyLevel( ConsistencyLevel.LOCAL_ONE );
}
示例14: createPreparedStatements
import com.datastax.driver.core.querybuilder.Select; //导入方法依赖的package包/类
/**
* Create all prepared statements use in this class for metrics_locator
*/
private void createPreparedStatements() {
// create a generic select statement for retrieving from metrics_locator
Select.Where select = QueryBuilder
.select()
.all()
.from( CassandraModel.CF_METRICS_LOCATOR_NAME )
.where( eq ( KEY, bindMarker() ));
getValue = DatastaxIO.getSession().prepare( select );
// create a generic insert statement for inserting into metrics_locator
Insert insert = QueryBuilder.insertInto( CassandraModel.CF_METRICS_LOCATOR_NAME)
.using(ttl(TenantTtlProvider.LOCATOR_TTL))
.value(KEY, bindMarker())
.value(COLUMN1, bindMarker())
.value(VALUE, bindMarker());
putValue = DatastaxIO.getSession()
.prepare(insert)
.setConsistencyLevel( ConsistencyLevel.LOCAL_ONE );
}
示例15: DDelayedLocatorIO
import com.datastax.driver.core.querybuilder.Select; //导入方法依赖的package包/类
public DDelayedLocatorIO() {
// create a generic select statement for retrieving from metrics_delayed_locator
Select.Where select = QueryBuilder
.select()
.all()
.from( CassandraModel.CF_METRICS_DELAYED_LOCATOR_NAME )
.where( eq ( KEY, bindMarker() ));
getValue = DatastaxIO.getSession().prepare( select );
// create a generic insert statement for inserting into metrics_delayed_locator
Insert insert = QueryBuilder.insertInto( CassandraModel.CF_METRICS_DELAYED_LOCATOR_NAME)
.using(ttl(TenantTtlProvider.DELAYED_LOCATOR_TTL))
.value(KEY, bindMarker())
.value(COLUMN1, bindMarker())
.value(VALUE, bindMarker());
putValue = DatastaxIO.getSession()
.prepare(insert)
.setConsistencyLevel( ConsistencyLevel.LOCAL_ONE );
}