本文整理汇总了Java中com.netflix.astyanax.model.Rows.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java Rows.isEmpty方法的具体用法?Java Rows.isEmpty怎么用?Java Rows.isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.netflix.astyanax.model.Rows
的用法示例。
在下文中一共展示了Rows.isEmpty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isRequireIsDone
import com.netflix.astyanax.model.Rows; //导入方法依赖的package包/类
boolean isRequireIsDone() throws ConnectionException {
if (required_keys == null) {
return true;
}
if (required_keys.isEmpty()) {
return true;
}
Rows<String, String> rows = keyspace.prepareQuery(CF_QUEUE).getKeySlice(required_keys).withColumnSlice("status").execute().getResult();
if (rows == null) {
return false;
}
if (rows.isEmpty()) {
return false;
}
for (Row<String, String> row : rows) {
if (row.getColumns().getStringValue("status", JobStatus.WAITING.name()).equals(JobStatus.DONE.name()) == false) {
return false;
}
}
return true;
}
示例2: getJobsStatusByKeys
import com.netflix.astyanax.model.Rows; //导入方法依赖的package包/类
/**
* @return never null if keys is not empty
*/
public static LinkedHashMap<String, JobStatus> getJobsStatusByKeys(Collection<String> keys) throws ConnectionException {
if (keys == null) {
return null;
}
if (keys.size() == 0) {
return null;
}
LinkedHashMap<String, JobStatus> status = new LinkedHashMap<String, JobStatus>(keys.size());
Rows<String, String> rows = keyspace.prepareQuery(CF_QUEUE).getKeySlice(keys).withColumnSlice("status").execute().getResult();
if (rows.isEmpty()) {
return status;
}
for (Row<String, String> row : rows) {
if (row.getColumns().isEmpty()) {
continue;
}
status.put(row.getKey(), JobStatus.valueOf(row.getColumns().getStringValue("status", JobStatus.POSTPONED.name())));
}
return status;
}
示例3: findOne
import com.netflix.astyanax.model.Rows; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public synchronized T findOne(ID id) {
try {
String cql = cqlGen.buildFindOneStatement();
PreparedCqlQuery<String, String> preparedStatement = doPreparedCqlRead(cql);
Map<String, ByteBuffer> serializedKeyValues = spec.getSerializedKeyValues(id);
for (String column : spec.getKeyColumns()) {
preparedStatement = preparedStatement.withValue(serializedKeyValues.get(column));
}
OperationResult<CqlResult<String, String>> opResult = preparedStatement.execute();
LOGGER.debug("attempts: {}, latency: {}ms", opResult.getAttemptsCount(),
opResult.getLatency(TimeUnit.MILLISECONDS));
CqlResult<String, String> resultSet = opResult.getResult();
Rows<String, String> resultSetRows = resultSet.getRows();
if (resultSetRows.isEmpty()) {
return null;
} else if (resultSetRows.size() > 1) {
throw new DataRetrievalFailureException("Got several rows for single key");
} else {
Row<String, String> row = resultSetRows.getRowByIndex(0);
ColumnList<String> columns = row.getColumns();
return spec.map(columns);
}
} catch (ConnectionException e) {
throw new DataRetrievalFailureException("Error while executing CQL3 query", e);
}
}
示例4: listRows
import com.netflix.astyanax.model.Rows; //导入方法依赖的package包/类
@Override
public QueryResult listRows(String cursor, Integer rowLimit, Integer columnLimit) throws PaasException {
try {
invariant();
// Execute the query
Partitioner partitioner = keyspace.getPartitioner();
Rows<ByteBuffer, ByteBuffer> result = keyspace
.prepareQuery(columnFamily)
.getKeyRange(null, null, cursor != null ? cursor : partitioner.getMinToken(), partitioner.getMaxToken(), rowLimit)
.execute()
.getResult();
// Convert raw data into a simple sparse tree
SchemalessRows.Builder builder = SchemalessRows.builder();
for (Row<ByteBuffer, ByteBuffer> row : result) {
Map<String, String> columns = Maps.newHashMap();
for (Column<ByteBuffer> column : row.getColumns()) {
columns.put(serializers.columnAsString(column.getRawName()), serializers.valueAsString(column.getRawName(), column.getByteBufferValue()));
}
builder.addRow(serializers.keyAsString(row.getKey()), columns);
}
QueryResult dr = new QueryResult();
dr.setSrows(builder.build());
if (!result.isEmpty()) {
dr.setCursor(partitioner.getTokenForKey(Iterables.getLast(result).getKey()));
}
return dr;
} catch (ConnectionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
示例5: isRequireHasProblemThisSwitchStatus
import com.netflix.astyanax.model.Rows; //导入方法依赖的package包/类
private boolean isRequireHasProblemThisSwitchStatus() throws ConnectionException {
if (required_keys == null) {
return false;
}
if (required_keys.isEmpty()) {
return false;
}
Rows<String, String> rows = keyspace.prepareQuery(CF_QUEUE).getKeySlice(required_keys).withColumnSlice("status").execute().getResult();
if (rows == null) {
return true;
}
if (rows.isEmpty()) {
return true;
}
for (Row<String, String> row : rows) {
String status = row.getColumns().getStringValue("status", JobStatus.WAITING.name());
if (status.equals(JobStatus.WAITING.name())) {
continue;
} else if (status.equals(JobStatus.DONE.name())) {
continue;
} else if (status.equals(JobStatus.PROCESSING.name())) {
continue;
} else if (status.equals(JobStatus.ERROR.name())) {
this.status = JobStatus.ERROR;
return true;
} else if (status.equals(JobStatus.CANCELED.name())) {
if (this.status != JobStatus.ERROR) {
this.status = JobStatus.CANCELED;
}
return true;
} else if (status.equals(JobStatus.STOPPED.name())) {
if (this.status != JobStatus.ERROR) {
this.status = JobStatus.CANCELED;
}
return true;
} else if (status.equals(JobStatus.TOO_LONG_DURATION.name())) {
if (this.status != JobStatus.ERROR) {
this.status = JobStatus.CANCELED;
}
return true;
} else if (status.equals(JobStatus.TOO_OLD.name())) {
if (this.status != JobStatus.ERROR) {
this.status = JobStatus.CANCELED;
}
return true;
}
}
return false;
}