本文整理汇总了Java中com.netflix.astyanax.model.Row.getKey方法的典型用法代码示例。如果您正苦于以下问题:Java Row.getKey方法的具体用法?Java Row.getKey怎么用?Java Row.getKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.netflix.astyanax.model.Row
的用法示例。
在下文中一共展示了Row.getKey方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getArchiveUpdateTimes
import com.netflix.astyanax.model.Row; //导入方法依赖的package包/类
/**
* Get the last update times of all of the script archives managed by this Repository.
* @return map of moduleId to last update time
*/
@Override
public Map<ModuleId, Long> getArchiveUpdateTimes() throws IOException {
Iterable<Row<String, String>> rows;
try {
rows = getRows((EnumSet<?>)EnumSet.of(Columns.module_id, Columns.last_update));
} catch (Exception e) {
throw new IOException(e);
}
Map<ModuleId, Long> updateTimes = new LinkedHashMap<ModuleId, Long>();
for (Row<String, String> row : rows) {
String moduleId = row.getKey();
Column<String> lastUpdateColumn = row.getColumns().getColumnByName(Columns.last_update.name());
Long updateTime = lastUpdateColumn != null ? lastUpdateColumn.getLongValue() : null;
if (StringUtils.isNotBlank(moduleId) && updateTime != null) {
updateTimes.put(ModuleId.fromString(moduleId), updateTime);
}
}
return updateTimes;
}
示例6: getArchiveSummaries
import com.netflix.astyanax.model.Row; //导入方法依赖的package包/类
/**
* Get a summary of all archives in this Repository
* @return List of summaries
*/
@Override
public List<ArchiveSummary> getArchiveSummaries() throws IOException {
List<ArchiveSummary> summaries = new LinkedList<ArchiveSummary>();
Iterable<Row<String, String>> rows;
try {
rows = getRows((EnumSet<?>)EnumSet.of(Columns.module_id, Columns.last_update, Columns.module_spec));
} catch (Exception e) {
throw new IOException(e);
}
for (Row<String, String> row : rows) {
String moduleId = row.getKey();
ColumnList<String> columns = row.getColumns();
Column<String> lastUpdateColumn = columns.getColumnByName(Columns.last_update.name());
long updateTime = lastUpdateColumn != null ? lastUpdateColumn.getLongValue() : 0;
ScriptModuleSpec moduleSpec = getModuleSpec(columns);
ArchiveSummary summary = new ArchiveSummary(ModuleId.fromString(moduleId), moduleSpec, updateTime, null);
summaries.add(summary);
}
return summaries;
}
示例7: fetchNext
import com.netflix.astyanax.model.Row; //导入方法依赖的package包/类
private Holder<com.alvazan.orm.api.z8spi.Row> fetchNext() {
if(!iterator.hasNext())
return null;
Row<byte[], byte[]> row = iterator.next();
byte[] key = row.getKey();
com.alvazan.orm.api.z8spi.Row r = rowProvider.get();
r.setKey(key);
CassandraSession.processColumns(row, r);
return new Holder<com.alvazan.orm.api.z8spi.Row>(r);
}
示例8: fetchNext
import com.netflix.astyanax.model.Row; //导入方法依赖的package包/类
private com.alvazan.orm.api.z8spi.iter.AbstractCursor.Holder<IndexColumn> fetchNext() {
if(!iterator.hasNext())
return null;
Row<byte[], byte[]> row = iterator.next();
byte[] key = row.getKey();
IndexColumn col = new IndexColumn();
col.setPrimaryKey(key);
return new Holder<IndexColumn>(col);
}
示例9: AstyanaxResultSet
import com.netflix.astyanax.model.Row; //导入方法依赖的package包/类
public AstyanaxResultSet(OperationResult<Rows<K, String>> result) {
this.result = result;
rows = result.getResult();
this.rowIterator = rows.iterator();
if (rowIterator.hasNext()) {
Row<K, String> row = rowIterator.next();
this.columns = row.getColumns();
this.key = row.getKey();
} else {
this.columns = new EmptyColumnList<String>();
}
}
示例10: run
import com.netflix.astyanax.model.Row; //导入方法依赖的package包/类
@Override
public void run() {
if (families == null || families.length < 1) {
deferred.callback(new UnsupportedOperationException(
"Can't scan cassandra without a column family: " + this));
return;
}
if (iterator == null) {
try {
final OperationResult<Rows<byte[], byte[]>> results =
keyspace.prepareQuery(client.getColumnFamilySchemas().get(families[0]))
.withCaching(populate_blockcache)
.getRowRange(start_key, stop_key, null, null, Integer.MAX_VALUE).execute();
iterator = results.getResult().iterator();
} catch (ConnectionException e) {
deferred.callback(e);
return;
}
}
if (!iterator.hasNext()) {
deferred.callback(null);
//return Deferred.fromResult(null);
return;
}
// dunno how to size this since we don't have the low level deets
final ArrayList<ArrayList<KeyValue>> rows =
new ArrayList<ArrayList<KeyValue>>();
int kv_count = 0;
while (rows.size() < max_num_rows && iterator.hasNext()) {
final Row<byte[], byte[]> result = iterator.next();
if (filter != null) {
// TODO - post filtering SUCKS!!!!!
final KeyRegexpFilter regex = (KeyRegexpFilter)filter;
if (!regex.matches(result.getKey())) {
continue;
}
}
final ArrayList<KeyValue> row = new ArrayList<KeyValue>(result.getColumns().size());
// TODO - iterator on the columns too so we can satisfy max kvs
for (final Column<byte[]> column : result.getColumns()) {
final KeyValue kv = new KeyValue(result.getKey(), families[0],
column.getName(), column.getTimestamp() / 1000, // micro to ms
column.getByteArrayValue());
row.add(kv);
}
rows.add(row);
kv_count += row.size();
}
deferred.callback(rows);
}
示例11: nextResult
import com.netflix.astyanax.model.Row; //导入方法依赖的package包/类
@Override
public void nextResult() {
Row<K, String> row = rowIterator.next();
this.columns = row.getColumns();
this.key = row.getKey();
}
示例12: getScriptArchives
import com.netflix.astyanax.model.Row; //导入方法依赖的package包/类
/**
* Get all of the {@link ScriptArchive}s for the given set of moduleIds. Will perform the operation in batches
* as specified by {@link CassandraArchiveRepositoryConfig#getArchiveFetchBatchSize()} and outputs the jar files in
* the path specified by {@link CassandraArchiveRepositoryConfig#getArchiveOutputDirectory()}.
*
* @param moduleIds keys to search for
* @return set of ScriptArchives retrieved from the database
*/
@Override
public Set<ScriptArchive> getScriptArchives(Set<ModuleId> moduleIds) throws IOException {
Set<ScriptArchive> archives = new LinkedHashSet<ScriptArchive>(moduleIds.size()*2);
Path archiveOuputDir = getConfig().getArchiveOutputDirectory();
List<ModuleId> moduleIdList = new LinkedList<ModuleId>(moduleIds);
int batchSize = getConfig().getArchiveFetchBatchSize();
int start = 0;
try {
while (start < moduleIdList.size()) {
int end = Math.min(moduleIdList.size(), start + batchSize);
List<ModuleId> batchModuleIds = moduleIdList.subList(start, end);
List<String> rowKeys = new ArrayList<String>(batchModuleIds.size());
for (ModuleId batchModuleId:batchModuleIds) {
rowKeys.add(batchModuleId.toString());
}
Rows<String, String> rows = cassandra.getRows(rowKeys.toArray(new String[0]));
for (Row<String, String> row : rows) {
String moduleId = row.getKey();
ColumnList<String> columns = row.getColumns();
Column<String> lastUpdateColumn = columns.getColumnByName(Columns.last_update.name());
Column<String> hashColumn = columns.getColumnByName(Columns.archive_content_hash.name());
Column<String> contentColumn = columns.getColumnByName(Columns.archive_content.name());
if (lastUpdateColumn == null || hashColumn == null || contentColumn == null) {
continue;
}
ScriptModuleSpec moduleSpec = getModuleSpec(columns);
long lastUpdateTime = lastUpdateColumn.getLongValue();
byte[] hash = hashColumn.getByteArrayValue();
byte[] content = contentColumn.getByteArrayValue();
// verify the hash
if (hash != null && hash.length > 0 && !verifyHash(hash, content)) {
logger.warn("Content hash validation failed for moduleId {}. size: {}", moduleId, content.length);
continue;
}
String fileName = new StringBuilder().append(moduleId).append("-").append(lastUpdateTime).append(".jar").toString();
Path jarFile = archiveOuputDir.resolve(fileName);
Files.write(jarFile, content);
JarScriptArchive scriptArchive = new JarScriptArchive.Builder(jarFile)
.setModuleSpec(moduleSpec)
.setCreateTime(lastUpdateTime)
.build();
archives.add(scriptArchive);
}
start = end;
}
} catch (Exception e) {
throw new IOException(e);
}
return archives;
}