Refine search
if (row.cf != null && !row.cf.isMarkedForDelete()) assert row.cf.getSortedColumns() != null; for (IColumn c : row.cf.getSortedColumns()) String shardStr = ByteBufferUtil.string(c.name()); Integer shardNum = null; String token = ByteBufferUtil.string(subCol.name()); AtomicInteger offset = new AtomicInteger(Integer.valueOf(ByteBufferUtil.string(subCol .value()))); int startSeqOffset = getRandomSequenceOffset(offset.get());
ByteBuffer id = ByteBufferUtil.bytes(String.valueOf(nextOffset)); ByteBuffer off = id; if (row.cf == null || row.cf.isMarkedForDelete()) supercol = rows.get(0).cf.getColumn(id); logger.debug(offset + " was taken by " + ByteBufferUtil.string(c.name())); try winningTokenStr = winningToken == null ? "" : ByteBufferUtil.string(winningToken); } catch (CharacterCodingException e)
@Override public boolean apply(@Nullable Row row) { // The hasOnlyTombstones(x) call below ultimately calls Column.isMarkedForDelete(x) return !(row == null || row.cf == null || row.cf.isMarkedForDelete() || row.cf.hasOnlyTombstones(nowMillis)); } });
DocumentMetadata allTerms = IndexWriter.fromBytesUsingThrift(rows.get(0).cf.getColumn( CassandraUtils.documentMetaFieldBytes).value()); String rowKey = ByteBufferUtil.string(row.key.key, CassandraUtils.UTF_8); ByteBuffer val = row.cf.getSortedColumns().iterator().next().value();
ByteBuffer countBytes = ByteBufferUtil.bytes("count"); result.schema = new CqlMetadata(Collections.<ByteBuffer, String>emptyMap(), Collections.<ByteBuffer, String>emptyMap(), "AsciiType", "LongType"); List<Column> columns = Collections.singletonList(new Column(countBytes).setValue(ByteBufferUtil.bytes((long) rows.size()))); result.rows = Collections.singletonList(new CqlRow(countBytes, columns)); return result; new HashMap<ByteBuffer, String>(), TypeParser.getShortName(metadata.comparator.asAbstractType()), TypeParser.getShortName(metadata.getDefaultValidator())); List<CqlRow> cqlRows = new ArrayList<CqlRow>(rows.size()); for (org.apache.cassandra.db.Row row : rows) ByteBuffer keyName = ByteBufferUtil.bytes(metadata.getCQL2KeyName()); thriftColumns.add(new Column(keyName).setValue(row.key.getKey()).setTimestamp(-1)); result.schema.name_types.put(keyName, TypeParser.getShortName(AsciiType.instance)); result.schema.value_types.put(keyName, TypeParser.getShortName(metadata.getKeyValidator())); for (org.apache.cassandra.db.Cell c : row.cf.getSortedColumns()) if (cd != null) result.schema.value_types.put(nameBytes, TypeParser.getShortName(cd.type)); org.apache.cassandra.db.Cell c = row.cf.getColumn(name); if (c == null || !c.isLive()) thriftColumns.add(new Column().setName(nameBytes));
for(IColumn sc : row.cf.getSortedColumns()){ continue; Integer id = Integer.valueOf(ByteBufferUtil.string(sc.name())); logger.debug("Read "+fillSize+ " "+ ByteBufferUtil.string(startCol));
+ ByteBufferUtil.string(key.getValue(), CassandraUtils.UTF_8) + " " + rowMap); for (IColumn col : row.cf.getSortedColumns()) String fieldName = ByteBufferUtil.string(col.name()); if (ByteBufferUtil.compare(col.name(), CassandraUtils.documentMetaFieldBytes.array()) == 0)
public Long checkForUpdate(String indexName, String key) throws IOException { ByteBuffer keyCol = ByteBuffer.wrap(key.getBytes("UTF-8")); ByteBuffer keyKey = CassandraUtils.hashKeyBytes((indexName + "~" + key).getBytes("UTF-8"), CassandraUtils.delimeterBytes, "keys".getBytes("UTF-8")); List<Row> rows = CassandraUtils.robustRead(keyKey, new QueryPath(CassandraUtils.schemaInfoColumnFamily), Arrays.asList(keyCol), ConsistencyLevel.QUORUM); if (rows.size() == 1) { Row row = rows.get(0); if (row.cf != null) { IColumn col = row.cf.getColumn(keyCol); if (col != null) { Collection<IColumn> subCols = col.getSubColumns(); if (subCols != null && !subCols.isEmpty()) { ByteBuffer idVal = col.getSubColumns().iterator().next().name(); Long id = Long.valueOf(ByteBufferUtil.string(idVal)); return id; } } } } return null; }
private ByteBuffer extractDataValue(ColumnDefinition def, ByteBuffer rowKey, ColumnFamily data, Composite prefix) { switch (def.kind) { case PARTITION_KEY: return def.isOnAllComponents() ? rowKey : ((CompositeType)data.metadata().getKeyValidator()).split(rowKey)[def.position()]; case CLUSTERING_COLUMN: return prefix.get(def.position()); case REGULAR: CellName cname = prefix == null ? data.getComparator().cellFromByteBuffer(def.name.bytes) : data.getComparator().create(prefix, def); Cell cell = data.getColumn(cname); return cell == null ? null : cell.value(); case COMPACT_VALUE: assert data.getColumnCount() == 1; return data.getSortedColumns().iterator().next().value(); } throw new AssertionError(); }
public List<LogEntry> writePending(ConsistencyLevel consistencyLevel, RowMutation rowMutation) throws Throwable { List<String> columnNames = new ArrayList<String>(); for (ColumnFamily cf : rowMutation.getColumnFamilies()) { for (ByteBuffer b : cf.getColumnNames()) { columnNames.add(ByteBufferUtil.string(b)); } } String keyspace = rowMutation.getTable(); ByteBuffer rowKey = rowMutation.key(); List<LogEntry> entries = new ArrayList<LogEntry>(); for (Integer cfId : rowMutation.getColumnFamilyIds()) { ColumnFamily columnFamily = rowMutation.getColumnFamily(cfId); String path = keyspace + ":" + columnFamily.metadata().cfName; List<Trigger> triggers = TriggerStore.getStore().getTriggers().get(path); if (triggers != null && triggers.size() > 0) { String hostName = LogEntryStore.getHostName(); LogEntry entry = new LogEntry(keyspace, columnFamily, rowKey, consistencyLevel, hostName, System.currentTimeMillis(), columnNames); entries.add(entry); write(entry, PENDING_PRIORITY); } } return entries; }
builder.put("key", ByteBufferUtil.bytesToHex(key)); builder.put("column_family", column_family); builder.put("old", expected.toString()); ColumnFamily cfUpdates = ArrayBackedSortedColumns.factory.create(cfm); for (Column column : updates) cfUpdates.addColumn(cfm.comparator.cellFromByteBuffer(column.name), column.value, column.timestamp); cfExpected.addColumn(cfm.comparator.cellFromByteBuffer(column.name), column.value, column.timestamp); return result == null ? new CASResult(true) : new CASResult(false).setCurrent_values(thriftifyColumnsAsColumns(result.getSortedColumns(), System.currentTimeMillis()));
public ColumnFamily trim(ColumnFamily cf, int trimTo, long now) { // each cell can increment the count by at most one, so if we have fewer cells than trimTo, we can skip trimming if (cf.getColumnCount() < trimTo) return cf; ColumnCounter counter = columnCounter(cf.getComparator(), now); ColumnFamily trimmedCf = cf.getFactory().create(cf.metadata(), reversed, trimTo); trimmedCf.delete(cf); Collection<Cell> cells = reversed ? cf.getReverseSortedColumns() : cf.getSortedColumns(); DeletionInfo.InOrderTester tester = cf.deletionInfo().inOrderTester(reversed); for (Iterator<Cell> iter = cells.iterator(); iter.hasNext(); ) { Cell cell = iter.next(); counter.count(cell, tester); if (counter.live() > trimTo) { break; } else { trimmedCf.addColumn(cell); } } return trimmedCf; }
if (cf.isMarkedForDelete()) return EntryList.EMPTY_LIST; Iterables.filter(cf.getSortedColumns(), new FilterDeletedColumns(nowMillis)), entryGetter, query.getSliceEnd(),
private List<ColumnOrSuperColumn> thriftifyColumnFamily(ColumnFamily cf, boolean subcolumnsOnly, boolean reverseOrder, long now) { if (cf == null || !cf.hasColumns()) return EMPTY_COLUMNS; if (cf.metadata().isSuper()) { boolean isCounterCF = cf.metadata().isCounter(); return thriftifySuperColumns(cf.getSortedColumns(), reverseOrder, now, subcolumnsOnly, isCounterCF); } else { return thriftifyColumns(cf.getSortedColumns(), reverseOrder, now); } }
protected void addColumn(Cell cell) throws IOException { if (columnFamily.metadata().isSuper()) { if (currentSuperColumn == null) throw new IllegalStateException("Trying to add a cell to a super column family, but no super cell has been started."); cell = cell.withUpdatedName(columnFamily.getComparator().makeCellName(currentSuperColumn, cell.name().toByteBuffer())); } columnFamily.addColumn(cell); }
public LogEntry(String keyspace, ColumnFamily columnFamily, ByteBuffer rowKey, ConsistencyLevel consistencyLevel, String host, long timestamp, Collection<String> columnNames) throws Throwable { this(keyspace, rowKey, consistencyLevel, host, timestamp, columnNames); this.columnFamily = columnFamily.metadata().cfName; for (IColumn column : columnFamily.getSortedColumns()) { ColumnOperation operation = new ColumnOperation(); operation.setName(column.name()); operation.setDelete(columnFamily.isMarkedForDelete()); operations.add(operation); } }
private static Collection<IColumn> getFieldCacheEntries(IndexReader indexReader, String field) throws IOException { String indexName = SolandraCoreContainer.coreInfo.get().indexName + "~" + SolandraCoreContainer.coreInfo.get().shard; byte[] indexNameBytes = indexName.getBytes("UTF-8"); if(logger.isDebugEnabled()) logger.debug("Loading field cache from " + indexName + " " + field); ColumnParent fieldCacheParent = new ColumnParent(CassandraUtils.fieldCacheColumnFamily); ByteBuffer fieldCacheKey = CassandraUtils.hashKeyBytes(indexNameBytes, CassandraUtils.delimeterBytes, field .getBytes()); List<Row> rows = CassandraUtils.robustRead(CassandraUtils.consistency, new SliceFromReadCommand( CassandraUtils.keySpace, fieldCacheKey, fieldCacheParent, ByteBufferUtil.EMPTY_BYTE_BUFFER, ByteBufferUtil.EMPTY_BYTE_BUFFER, false, Integer.MAX_VALUE)); if (rows.isEmpty()) return Collections.emptyList(); Row row = rows.get(0); if (row.cf == null) return Collections.emptyList(); return row.cf.getSortedColumns(); }
public Collection<Mutation> augment(ByteBuffer key, ColumnFamily update) { CFMetaData cfm = update.metadata(); String localKey = cfm.getKeyValidator().getString(key); logger.info("key={}.", localKey); for (Cell cell : update) { try { String name = cfm.comparator.getString(cell.name()); logger.info("name={}.", name); String value = cfm.getValueValidator(cell.name()).getString(cell.value()); logger.info("value={}.", value); } catch (Exception e) { logger.info("Exception={}.", e.getMessage()); } } return Collections.emptyList();
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || !(o instanceof ColumnFamily)) return false; ColumnFamily comparison = (ColumnFamily) o; return metadata.equals(comparison.metadata) && deletionInfo().equals(comparison.deletionInfo()) && ByteBufferUtil.compareUnsigned(digest(this), digest(comparison)) == 0; }