use of org.apache.cassandra.db.composites.CellName in project titan by thinkaurelius.
the class CassandraEmbeddedStoreManager method retryDummyRead.
private void retryDummyRead(String ks, String cf) throws PermanentBackendException {
final long limit = System.currentTimeMillis() + (60L * 1000L);
while (System.currentTimeMillis() < limit) {
try {
SortedSet<CellName> names = new TreeSet<>(new Comparator<CellName>() {
// This is a singleton set. We need to define a comparator because SimpleDenseCellName is not
// comparable, but it doesn't have to be a useful comparator
@Override
public int compare(CellName o1, CellName o2) {
return 0;
}
});
names.add(CellNames.simpleDense(ByteBufferUtil.zeroByteBuffer(1)));
NamesQueryFilter nqf = new NamesQueryFilter(names);
SliceByNamesReadCommand cmd = new SliceByNamesReadCommand(ks, ByteBufferUtil.zeroByteBuffer(1), cf, 1L, nqf);
StorageProxy.read(ImmutableList.<ReadCommand>of(cmd), ConsistencyLevel.QUORUM);
log.info("Read on CF {} in KS {} succeeded", cf, ks);
return;
} catch (Throwable t) {
log.warn("Failed to read CF {} in KS {} following creation", cf, ks, t);
}
try {
Thread.sleep(1000L);
} catch (InterruptedException e) {
throw new PermanentBackendException(e);
}
}
throw new PermanentBackendException("Timed out while attempting to read CF " + cf + " in KS " + ks + " following creation");
}
use of org.apache.cassandra.db.composites.CellName in project stargate-core by tuplejump.
the class ResultMapper method getPagedColumnSlices.
private ColumnSlice[] getPagedColumnSlices(DecoratedKey dk, Collection<IndexEntry> entries, int pageSize) {
ArrayList<ColumnSlice> columnSlices = new ArrayList<>(Math.min(entries.size(), pageSize));
for (IndexEntry entry : entries) {
CellName cellName = entry.clusteringKey;
if (!filter.columnFilter(dk.getKey()).maySelectPrefix(tableMapper.table.getComparator(), cellName.start())) {
continue;
}
Composite start = tableMapper.start(cellName);
Composite end = tableMapper.end(start);
ColumnSlice columnSlice = new ColumnSlice(start, end);
columnSlices.add(columnSlice);
if (columnSlices.size() == pageSize) {
break;
}
}
return columnSlices.toArray(new ColumnSlice[columnSlices.size()]);
}
use of org.apache.cassandra.db.composites.CellName in project stargate-core by tuplejump.
the class RowFetcher method fetchSorted.
public List<Row> fetchSorted() throws IOException {
List<Row> rows = new ArrayList<>();
List<IndexEntryCollector.IndexEntry> docsSorted = resultMapper.docs();
List<IndexEntryCollector.IndexEntry> sliceList;
for (IndexEntryCollector.IndexEntry input : docsSorted) {
CellName cellName = input.clusteringKey;
DecoratedKey dk = input.decoratedKey;
sliceList = new ArrayList<>();
sliceList.add(input);
Map<CellName, ColumnFamily> fullSlice = resultMapper.fetchRangeSlice(sliceList, dk);
if (!resultMapper.filter.columnFilter(dk.getKey()).maySelectPrefix(table.getComparator(), cellName.start())) {
continue;
}
ColumnFamily data = fullSlice.get(cellName);
if (data == null || resultMapper.searchSupport.deleteIfNotLatest(dk, data.maxTimestamp(), input.pkName, data))
continue;
float score = input.score;
ColumnFamily cleanColumnFamily = resultMapper.showScore ? scored(score, data) : data;
rows.add(new Row(dk, cleanColumnFamily));
columnsCount++;
if (columnsCount > limit)
break;
}
return rows;
}
use of org.apache.cassandra.db.composites.CellName in project stargate-core by tuplejump.
the class MatchPartition method getAllMatches.
private List<Tuple> getAllMatches(ResultMapper resultMapper, Map<String, Integer> positions) {
List<Tuple> allMatches = new ArrayList<>();
TreeMultimap<DecoratedKey, IndexEntryCollector.IndexEntry> docs = resultMapper.docsByRowKey();
for (final DecoratedKey dk : docs.keySet()) {
List<IndexEntryCollector.IndexEntry> entries = new ArrayList<>(docs.get(dk));
final Map<CellName, ColumnFamily> fullSlice = resultMapper.fetchRangeSlice(entries, dk);
List<Tuple> tuples = new ArrayList<>(fullSlice.size());
for (IndexEntryCollector.IndexEntry entry : entries) {
CellName cellName = entry.clusteringKey;
ColumnFamily cf = fullSlice.get(cellName);
if (cf != null) {
Tuple tuple = aggregateFunction.createTuple(options);
resultMapper.tableMapper.load(positions, tuple, new Row(dk, cf));
tuples.add(tuple);
}
}
int splice = Math.min(tuples.size(), maxMatches);
allMatches.addAll(matchPartition(tuples.subList(0, splice)));
}
return allMatches;
}
use of org.apache.cassandra.db.composites.CellName in project stargate-core by tuplejump.
the class RowIndexSupport method addCell.
private void addCell(ByteBuffer rowKey, IndexEntryBuilder builder, Cell cell) {
CellName cellName = cell.name();
ColumnIdentifier cql3ColName = cellName.cql3ColumnName(tableMapper.cfMetaData);
String actualColName = cql3ColName.toString();
if (logger.isTraceEnabled())
logger.trace("Got column name {} from CF", actualColName);
CellName clusteringKey = tableMapper.extractClusteringKey(cell.name());
ByteBuffer primaryKeyBuff = tableMapper.primaryKey(rowKey, clusteringKey);
String primaryKey = tableMapper.primaryKeyType.getString(primaryKeyBuff);
if (builder.isNew(primaryKey)) {
builder.newPrimaryKey(primaryKey, primaryKeyBuff);
// new pk found
if (logger.isTraceEnabled()) {
logger.trace("New PK found {}", primaryKey);
}
//fields for partition key columns need to be added.
addPartitionKeyFields(rowKey, cell.timestamp(), builder);
//fields for clustering key columns need to be added.
addClusteringKeyFields(clusteringKey, cell.timestamp(), builder);
}
addCell(cell, cql3ColName, actualColName, builder);
}
Aggregations