本文整理汇总了Java中com.netflix.astyanax.model.Row类的典型用法代码示例。如果您正苦于以下问题:Java Row类的具体用法?Java Row怎么用?Java Row使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Row类属于com.netflix.astyanax.model包,在下文中一共展示了Row类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decodeMetadataRows
import com.netflix.astyanax.model.Row; //导入依赖的package包/类
private Iterator<Map.Entry<String, StorageSummary>> decodeMetadataRows(
final Iterator<Row<ByteBuffer, Composite>> rowIter, final AstyanaxTable table) {
return new AbstractIterator<Map.Entry<String, StorageSummary>>() {
@Override
protected Map.Entry<String, StorageSummary> computeNext() {
while (rowIter.hasNext()) {
Row<ByteBuffer, Composite> row = rowIter.next();
ByteBuffer key = row.getKey();
ColumnList<Composite> columns = row.getColumns();
String blobId = AstyanaxStorage.getContentKey(key);
StorageSummary summary = toStorageSummary(columns);
if (summary == null) {
continue; // Partial blob, parts may still be replicating.
}
// Cleanup older versions of the blob, if any (unlikely).
deleteOldColumns(table, blobId, columns, summary.getTimestamp());
return Maps.immutableEntry(blobId, summary);
}
return endOfData();
}
};
}
示例2: listQueues
import com.netflix.astyanax.model.Row; //导入依赖的package包/类
@Override
public Iterator<String> listQueues() {
final Iterator<Row<String, UUID>> rowIter = execute(
_keyspace.prepareQuery(CF_DEDUP_MD, ConsistencyLevel.CL_LOCAL_QUORUM)
.getAllRows()
.setRowLimit(100)
.withColumnRange(new RangeBuilder().setLimit(1).build()))
.iterator();
return new AbstractIterator<String>() {
@Override
protected String computeNext() {
while (rowIter.hasNext()) {
Row<String, UUID> row = rowIter.next();
if (!row.getColumns().isEmpty()) {
return row.getKey();
}
}
return endOfData();
}
};
}
示例3: findMaxRecords
import com.netflix.astyanax.model.Row; //导入依赖的package包/类
@Override
public Map<UUID, ByteBuffer> findMaxRecords(Collection<UUID> dataIds) {
// Finding the max using a reversed column range shouldn't have to worry about skipping tombstones since
// we always delete smaller column values before deleting larger column values--scanning will hit the max
// before needing to skip over tombstones.
Map<UUID, ByteBuffer> resultMap = Maps.newHashMap();
for (List<UUID> batch : Iterables.partition(dataIds, 10)) {
Rows<UUID, ByteBuffer> rows = execute(
_keyspace.prepareQuery(CF_DEDUP_DATA, ConsistencyLevel.CL_LOCAL_QUORUM)
.getKeySlice(batch)
.withColumnRange(new RangeBuilder()
.setReversed(true)
.setLimit(1)
.build()));
for (Row<UUID, ByteBuffer> row : rows) {
UUID dataId = row.getKey();
for (Column<ByteBuffer> column : row.getColumns()) {
resultMap.put(dataId, column.getName());
}
}
}
return resultMap;
}
示例4: listChannels
import com.netflix.astyanax.model.Row; //导入依赖的package包/类
@Override
public Iterator<String> listChannels() {
final Iterator<Row<String, ByteBuffer>> rowIter = execute(
_keyspace.prepareQuery(ColumnFamilies.MANIFEST, ConsistencyLevel.CL_LOCAL_QUORUM)
.getAllRows()
.setRowLimit(1000)
.withColumnRange(new RangeBuilder().setLimit(1).build()))
.iterator();
return new AbstractIterator<String>() {
@Override
protected String computeNext() {
while (rowIter.hasNext()) {
Row<String, ByteBuffer> row = rowIter.next();
if (!row.getColumns().isEmpty()) {
return row.getKey();
}
}
return endOfData();
}
};
}
示例5: decodeRows
import com.netflix.astyanax.model.Row; //导入依赖的package包/类
/**
* Decodes rows returned by querying for a specific set of rows.
*/
private Iterator<Record> decodeRows(List<Map.Entry<ByteBuffer, Key>> keys, final Rows<ByteBuffer, DeltaKey> rows,
final int largeRowThreshold, final ReadConsistency consistency) {
// Avoiding pinning multiple decoded rows into memory at once.
return Iterators.transform(keys.iterator(), new Function<Map.Entry<ByteBuffer, Key>, Record>() {
@Override
public Record apply(Map.Entry<ByteBuffer, Key> entry) {
Row<ByteBuffer, DeltaKey> row = rows.getRow(entry.getKey());
if (row == null) {
return emptyRecord(entry.getValue());
}
// Convert the results into a Record object, lazily fetching the rest of the columns as necessary.
return newRecord(entry.getValue(), row.getRawKey(), row.getColumns(), largeRowThreshold, consistency, null);
}
});
}
示例6: decodeRows
import com.netflix.astyanax.model.Row; //导入依赖的package包/类
/**
* Decodes rows returned by querying for a specific set of rows.
*/
private Iterator<Record> decodeRows(List<Map.Entry<ByteBuffer, Key>> keys, final Rows<ByteBuffer, UUID> rows,
final int largeRowThreshold, final ReadConsistency consistency) {
// Avoiding pinning multiple decoded rows into memory at once.
return Iterators.transform(keys.iterator(), new Function<Map.Entry<ByteBuffer, Key>, Record>() {
@Override
public Record apply(Map.Entry<ByteBuffer, Key> entry) {
Row<ByteBuffer, UUID> row = rows.getRow(entry.getKey());
if (row == null) {
return emptyRecord(entry.getValue());
}
// Convert the results into a Record object, lazily fetching the rest of the columns as necessary.
return newRecord(entry.getValue(), row.getRawKey(), row.getColumns(), largeRowThreshold, consistency, null);
}
});
}
示例7: getSiblings
import com.netflix.astyanax.model.Row; //导入依赖的package包/类
public List<String> getSiblings(final String path) {
final List<String> result = new LinkedList<String>();
try {
final UUID resourceUUID = getResourceUUID(ROOT_UUID, path);
final OperationResult<CqlResult<String, String>> execute = keyspace
.prepareQuery(CassandraUtils.CQL3_CF)
.withCql("SELECT child FROM directory WHERE pathId=?")
.asPreparedStatement()
.withUUIDValue(resourceUUID)
.execute();
for (Row<String, String> row : execute.getResult().getRows()) {
final String fileName = row.getColumns().getStringValue("child", null);
if (CURRENT_DIR.equals(fileName)) {
continue;
}
result.add(fileName);
}
return result;
} catch (ConnectionException e) {
throw new RuntimeException(e);
}
}
示例8: getFileSize
import com.netflix.astyanax.model.Row; //导入依赖的package包/类
public long getFileSize(final UUID file) throws ConnectionException {
final OperationResult<CqlResult<String, String>> execute = keyspace
.prepareQuery(CassandraUtils.CQL3_CF)
.withCql("SELECT size FROM file WHERE file=?")
.asPreparedStatement()
.withUUIDValue(file)
.execute();
for (Row<String, String> row : execute.getResult().getRows()) {
final Long fileSize = row.getColumns().getLongValue("size", null);
if (fileSize != null) {
return fileSize;
}
}
throw new RuntimeException("Unable to find given file");
}
示例9: listIds
import com.netflix.astyanax.model.Row; //导入依赖的package包/类
@Override
public Collection<String> listIds() throws PersistenceException {
final List<String> ids = Lists.newArrayList();
try {
new AllRowsReader.Builder<String, String>(keyspace, columnFamily)
.withIncludeEmptyRows(false)
.forEachRow(new Function<Row<String,String>, Boolean>() {
@Override
public Boolean apply(Row<String, String> row) {
ids.add(row.getKey());
return true;
}
})
.build()
.call();
} catch (Exception e) {
throw new PersistenceException("Error trying to fetch row ids", e);
}
return ids;
}
示例10: readAliases
import com.netflix.astyanax.model.Row; //导入依赖的package包/类
public Set<Long> readAliases(Publisher source, Iterable<Alias> aliases)
throws ConnectionException {
ImmutableSet<Alias> uniqueAliases = ImmutableSet.copyOf(aliases);
String columnName = checkNotNull(source).key();
RowSliceQuery<String, String> aliasQuery = keyspace.prepareQuery(columnFamily)
.getRowSlice(serialize(uniqueAliases.asList()))
.withColumnSlice(columnName);
Rows<String, String> rows = aliasQuery.execute().getResult();
List<Long> ids = Lists.newArrayListWithCapacity(rows.size());
for (Row<String, String> row : rows) {
Column<String> idCell = row.getColumns().getColumnByName(columnName);
if (idCell != null) {
ids.add(idCell.getLongValue());
}
}
return ImmutableSet.copyOf(ids);
}
示例11: listAuthorsByEvents
import com.netflix.astyanax.model.Row; //导入依赖的package包/类
public static HashMap<String, ArrayList<String>> listAuthorsByEvents() throws ConnectionException {
HashMap<String, ArrayList<String>> result = new HashMap<String, ArrayList<String>>();
Rows<String, String> rows = DARDB.get().getKeyspace().prepareQuery(DARDB.CF_DAR).getAllRows().withColumnSlice("account_user_key", "event_name").execute().getResult();
for (Row<String, String> row : rows) {
String account_user_key = row.getColumns().getStringValue("account_user_key", "");
String event_name = row.getColumns().getStringValue("event_name", "");
if (event_name.equals("") | account_user_key.equals("")) {
Loggers.DAReport.warn("Empty values for event_name or account_user_key in [" + row.getKey() + "]");
continue;
}
if (result.containsKey(event_name) == false) {
result.put(event_name, new ArrayList<>(5));
}
result.get(event_name).add(account_user_key);
}
return result;
}
示例12: isRequireIsDone
import com.netflix.astyanax.model.Row; //导入依赖的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;
}
示例13: removeMaxDateForPostponedJobs
import com.netflix.astyanax.model.Row; //导入依赖的package包/类
static void removeMaxDateForPostponedJobs(MutationBatch mutator, String creator_hostname) throws ConnectionException {
if (Loggers.Job.isDebugEnabled()) {
Loggers.Job.debug("Search for remove max date for postponed jobs");
}
IndexQuery<String, String> index_query = keyspace.prepareQuery(CF_QUEUE).searchWithIndex();
index_query.addExpression().whereColumn("status").equals().value(JobStatus.POSTPONED.name());
index_query.addExpression().whereColumn("creator_hostname").equals().value(creator_hostname);
index_query.addExpression().whereColumn("expiration_date").lessThan().value(System.currentTimeMillis() + default_max_execution_time);
index_query.withColumnSlice("source", "context_class");
OperationResult<Rows<String, String>> rows = index_query.execute();
for (Row<String, String> row : rows.getResult()) {
if (MyDMAM.factory.isClassExists(row.getColumns().getStringValue("context_class", "null")) == false) {
continue;
}
JobNG job = JobNG.Utility.importFromDatabase(row.getColumns());
job.expiration_date = System.currentTimeMillis() + (default_max_execution_time * 7l);
job.update_date = System.currentTimeMillis();
if (Loggers.Job.isDebugEnabled()) {
Loggers.Job.info("Remove max date for this postponed job:\t" + job);
}
job.exportToDatabase(mutator.withRow(CF_QUEUE, job.key));
}
}
示例14: getJobsStatusByKeys
import com.netflix.astyanax.model.Row; //导入依赖的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;
}
示例15: getJobsByStatus
import com.netflix.astyanax.model.Row; //导入依赖的package包/类
/**
* Storted by priority
*/
static List<JobNG> getJobsByStatus(JobStatus status) throws ConnectionException {
IndexQuery<String, String> index_query = keyspace.prepareQuery(CF_QUEUE).searchWithIndex();
index_query.addExpression().whereColumn("status").equals().value(status.name());
index_query.withColumnSlice("source", "context_class");
OperationResult<Rows<String, String>> rows = index_query.execute();
ArrayList<JobNG> result = new ArrayList<JobNG>();
for (Row<String, String> row : rows.getResult()) {
if (MyDMAM.factory.isClassExists(row.getColumns().getStringValue("context_class", "null")) == false) {
continue;
}
JobNG new_job = JobNG.Utility.importFromDatabase(row.getColumns());
result.add(new_job);
}
Collections.sort(result, job_priority_comparator);
return result;
}