本文整理汇总了Java中com.netflix.astyanax.model.Column类的典型用法代码示例。如果您正苦于以下问题:Java Column类的具体用法?Java Column怎么用?Java Column使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Column类属于com.netflix.astyanax.model包,在下文中一共展示了Column类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFolderChildren
import com.netflix.astyanax.model.Column; //导入依赖的package包/类
private List<RaptureFolderInfo> getFolderChildren(String cf, NormalizedKey prefix) {
List<RaptureFolderInfo> ret = new ArrayList<RaptureFolderInfo>();
ColumnList<String> result;
try {
ColumnFamily<String, String> cFam = ColumnFamily.newColumnFamily(cf, StringSerializer.get(), StringSerializer.get());
result = keyspace.prepareQuery(cFam).getKey(prefix.get()).withColumnRange(new RangeBuilder().setLimit(1000).build()).execute().getResult();
} catch (ConnectionException ce) {
throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, messageCatalog.getMessage("DbCommsError"), ce);
}
for (Column<String> column : result) {
RaptureFolderInfo info = new RaptureFolderInfo();
info.setName(column.getName());
info.setFolder(column.getIntegerValue() != -1);
ret.add(info);
}
return ret;
}
示例2: getPointsAfter
import com.netflix.astyanax.model.Column; //导入依赖的package包/类
public List<SeriesValue> getPointsAfter(String key, String startColumn, String endColumn, int maxNumber, boolean reverse) throws IOException {
List<SeriesValue> ret = new ArrayList<SeriesValue>();
int limit = (maxNumber > overflowLimit) ? overflowLimit : maxNumber;
ColumnList<String> result;
try {
result = keyspace.prepareQuery(columnFamily).getKey(key)
.withColumnRange(new RangeBuilder().setStart(startColumn).setEnd(endColumn).setLimit(limit).setReversed(reverse).build()).execute()
.getResult();
} catch (ConnectionException ce) {
throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, messageCatalog.getMessage("DbCommsError"), ce);
}
if (result.size() > overflowLimit) {
throw RaptureExceptionFactory.create(messageCatalog.getMessage("SmallerPages", "" + overflowLimit));
}
for (Column<String> column : result) {
ret.add(makeSeriesValue(column));
}
return ret;
}
示例3: toStorageSummary
import com.netflix.astyanax.model.Column; //导入依赖的package包/类
private StorageSummary toStorageSummary(ColumnList<Composite> columns) {
if (columns.size() == 0) {
return null;
}
// Read the summary column with the attributes, length etc.
Column<Composite> summaryColumn = columns.getColumnByIndex(0);
if (summaryColumn == null || !matches(summaryColumn.getName(), ColumnGroup.A, 0)) {
return null;
}
StorageSummary summary = JsonHelper.fromJson(summaryColumn.getStringValue(), StorageSummary.class);
// Check that all the chunks are available. Some may still be in the process of being written or replicated.
if (columns.size() < 1 + summary.getChunkCount()) {
return null;
}
for (int chunkId = 0; chunkId < summary.getChunkCount(); chunkId++) {
Column<Composite> presence = columns.getColumnByIndex(chunkId + 1);
if (presence == null ||
!matches(presence.getName(), ColumnGroup.B, chunkId) ||
presence.getTimestamp() != summary.getTimestamp()) {
return null;
}
}
return summary;
}
示例4: deleteOldColumns
import com.netflix.astyanax.model.Column; //导入依赖的package包/类
private void deleteOldColumns(AstyanaxTable table, String blobId, ColumnList<Composite> columns, long timestamp) {
for (AstyanaxStorage storage : table.getWriteStorage()) {
BlobPlacement placement = (BlobPlacement) storage.getPlacement();
// Any columns with a timestamp older than the one we expect must be from an old version
// of the blob. This should be rare, but if it happens clean up and delete the old data.
MutationBatch mutation = placement.getKeyspace().prepareMutationBatch(ConsistencyLevel.CL_ANY);
ColumnListMutation<Composite> row = mutation.withRow(
placement.getBlobColumnFamily(), storage.getRowKey(blobId));
boolean found = false;
for (Column<Composite> column : columns) {
if (column.getTimestamp() < timestamp) {
if (ColumnGroup.B.name().equals(column.getName().get(0, AsciiSerializer.get()))) {
int chunkId = column.getName().get(1, IntegerSerializer.get());
row.deleteColumn(getColumn(ColumnGroup.B, chunkId))
.deleteColumn(getColumn(ColumnGroup.Z, chunkId));
found = true;
}
}
}
if (found) {
execute(mutation);
}
}
}
示例5: findMaxRecords
import com.netflix.astyanax.model.Column; //导入依赖的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;
}
示例6: scanRecords
import com.netflix.astyanax.model.Column; //导入依赖的package包/类
@Override
public Iterator<ByteBuffer> scanRecords(UUID dataId, @Nullable ByteBuffer from, @Nullable final ByteBuffer to,
int batchSize, int limit) {
final Iterator<Column<ByteBuffer>> iter = executePaginated(
_keyspace.prepareQuery(CF_DEDUP_DATA, ConsistencyLevel.CL_LOCAL_QUORUM)
.getKey(dataId)
.withColumnRange(new RangeBuilder()
.setStart(Objects.firstNonNull(from, EMPTY_BUFFER))
.setEnd(Objects.firstNonNull(to, EMPTY_BUFFER))
.setLimit(batchSize)
.build())
.autoPaginate(true));
return Iterators.limit(new AbstractIterator<ByteBuffer>() {
@Override
protected ByteBuffer computeNext() {
while (iter.hasNext()) {
ByteBuffer record = iter.next().getName();
if (!record.equals(to)) { // To is exclusive
return record;
}
}
return endOfData();
}
}, limit);
}
示例7: readAll
import com.netflix.astyanax.model.Column; //导入依赖的package包/类
void readAll(String channel, SlabFilter filter, EventSink sink, ConsistencyLevel consistency) {
// PeekingIterator is needed so that we can look ahead and see the next slab Id
PeekingIterator<Column<ByteBuffer>> manifestColumns = Iterators.peekingIterator(executePaginated(
_keyspace.prepareQuery(ColumnFamilies.MANIFEST, consistency)
.getKey(channel)
.withColumnRange(new RangeBuilder().setLimit(50).build())
.autoPaginate(true)).iterator());
while (manifestColumns.hasNext()) {
Column<ByteBuffer> manifestColumn = manifestColumns.next();
ByteBuffer slabId = manifestColumn.getName();
ByteBuffer nextSlabId = manifestColumns.hasNext() ? manifestColumns.peek().getName() : null;
boolean open = manifestColumn.getBooleanValue();
if (filter != null && !filter.accept(slabId, open, nextSlabId)) {
continue;
}
if (!readSlab(channel, slabId, new SlabCursor(), open, sink)) {
break;
}
}
}
示例8: nextImpl
import com.netflix.astyanax.model.Column; //导入依赖的package包/类
@Override
public Holder<T> nextImpl() {
if(!forward)
throw new IllegalStateException("You must call beforeFirst to traverse the cursor forward, you cannot call next after calling previous due to limitations of talking to noSql apis");
try {
fetchMoreResultsImpl();
pointer++;
if(pointer >= subList.size())
return null; //no more results
Column<byte[]> column = subList.get(pointer);
return buildHolder(column);
} catch (ConnectionException e) {
throw new RuntimeException(e);
}
}
示例9: previousImpl
import com.netflix.astyanax.model.Column; //导入依赖的package包/类
@Override
public Holder<T> previousImpl() {
if(forward)
throw new IllegalStateException("You must call afterLast to traverse reverse. You cannot call previous after calling next due to limitations of calling into noSQL apis");
try {
fetchMoreResultsImpl();
pointer++;
if(pointer >= subList.size())
return null; //no more results
Column<byte[]> column = subList.get(pointer);
return buildHolder(column);
} catch (ConnectionException e) {
throw new RuntimeException(e);
}
}
示例10: queryWithRowkey
import com.netflix.astyanax.model.Column; //导入依赖的package包/类
public void queryWithRowkey(String rowKey, boolean isDynamicSearch) throws ConnectionException, InterruptedException, ExecutionException {
ColumnFamily<String, String> CF_AST;
if (isDynamicSearch) {
CF_AST = CF_AST_DYNA;
} else {
CF_AST = CF_AST_BACK;
}
// no asynchronous feature
ColumnList<String> columns = GlobalVariables.KS_AST.prepareQuery(CF_AST)
.getKey(rowKey)
.execute()
.getResult();
String logger = "";
for (Column<String> column : columns) {
logger += "<"+column.getName()+":"+column.getValue(StringSerializer.get()) +">";
}
LOG.info(logger);
}
示例11: queryWithUserID
import com.netflix.astyanax.model.Column; //导入依赖的package包/类
public String[] queryWithUserID(String user_id) throws ConnectionException {
String[] oauthInfo = new String[4];
ColumnList<String> columns = GlobalVariables.KS_AST.prepareQuery(CF_AST_UL)
.getKey(user_id)
.execute()
.getResult();
oauthInfo[0] = user_id;
for (Column<String> column : columns) {
if (column.getName().equals("new_oauth_token")) {
oauthInfo[1] = column.getValue(StringSerializer.get());
} else if (column.getName().equals("new_oauth_token_secret")) {
oauthInfo[2] = column.getValue(StringSerializer.get());
} else if (column.getName().equals("screen_name")) {
oauthInfo[3] = column.getValue(StringSerializer.get());
}
}
return oauthInfo;
}
示例12: get
import com.netflix.astyanax.model.Column; //导入依赖的package包/类
/**
* Get events for a specific time period.
*
* @param key Time series key.
* @param begin From time (inclusive).
* @param end To time (exclusive).
* @param reversed If true, the order of the results will be reversed.
* @param count Max number of events to return.
* @return Time series events.
* @throws ConnectionException Failed to retrieve time series events from Cassandra.
*/
public List<String> get(K key, Date begin, Date end, boolean reversed, int count) throws ConnectionException {
List<String> events = new ArrayList<>();
OperationResult<ColumnList<UUID>> operationResult = keyspace
.prepareQuery(columnFamily)
.getKey(key)
.withColumnRange(
DeterministicTimeUUIDFactory.createFirst(begin),
DeterministicTimeUUIDFactory.createLast(end),
reversed,
count
)
.execute();
ColumnList<UUID> result = operationResult.getResult();
for (Column<UUID> column : result) {
if (column.hasValue()) {
events.add(column.getStringValue());
}
}
return events;
}
示例13: deserializeAttribute
import com.netflix.astyanax.model.Column; //导入依赖的package包/类
/**
*
*
* @param column
* @param field
* @param entity
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public static <T> void deserializeAttribute(Column<String> column, AttributeAccessor accessor, T entity) {
Preconditions.checkNotNull(column);
Preconditions.checkNotNull(accessor);
Preconditions.checkNotNull(entity);
Object value = null;
if (column.hasValue()) {
Serializer serializer = SerializerFactory.inferSerializer(accessor);
value = column.getValue(serializer);
} else {
/*
* We can't distinguish between an empty collection type column and
* a collection type column set to null. We up-convert those to
* their corresponding empty collection type.
*/
if (List.class.isAssignableFrom(accessor.getClazz())) {
value = Lists.newArrayList();
} else if (Map.class.isAssignableFrom(accessor.getClazz())) {
value = Maps.newHashMap();
} else if (Set.class.isAssignableFrom(accessor.getClazz())) {
value = Sets.newHashSet();
}
}
accessor.set(entity, value);
}
示例14: getShardState
import com.netflix.astyanax.model.Column; //导入依赖的package包/类
@Override
public Collection<SlotState> getShardState(int shard) throws IOException {
AstyanaxIO astyanaxIO = AstyanaxIO.singleton();
Timer.Context ctx = Instrumentation.getReadTimerContext(CassandraModel.CF_METRICS_STATE_NAME);
final Collection<SlotState> slotStates = new LinkedList<SlotState>();
try {
ColumnList<SlotState> columns = astyanaxIO.getKeyspace().prepareQuery(CassandraModel.CF_METRICS_STATE)
.getKey((long)shard)
.execute()
.getResult();
for (Column<SlotState> column : columns) {
slotStates.add(column.getName()
.withTimestamp(column.getLongValue())
.withLastUpdatedTimestamp(column.getTimestamp() / 1000)); //write time is in micro seconds
}
} catch (ConnectionException e) {
Instrumentation.markReadError(e);
LOG.error("Error getting shard state for shard " + shard, e);
throw new IOException(e);
} finally {
ctx.stop();
}
return slotStates;
}
示例15: parseColumn
import com.netflix.astyanax.model.Column; //导入依赖的package包/类
@Override
public MvccEntity parseColumn( Column<UUID> column ) {
final EntityWrapper deSerialized;
final UUID version = column.getName();
try {
deSerialized = column.getValue( entityJsonSerializer );
}
catch ( DataCorruptionException e ) {
logger.error(
"DATA CORRUPTION DETECTED when de-serializing entity with Id {} and version {}. This means the write was truncated.",
id, version, e );
//return an empty entity, we can never load this one, and we don't want it to bring the system
//to a grinding halt
return new MvccEntityImpl( id, version, MvccEntity.Status.DELETED, Optional.<Entity>absent(),0 );
}
//Inject the id into it.
if ( deSerialized.entity.isPresent() ) {
EntityUtils.setId( deSerialized.entity.get(), id );
}
return new MvccEntityImpl( id, version, deSerialized.status, deSerialized.entity, 0 );
}