@Override public boolean indexes(CellName name) { String toCheck = name.cql3ColumnName(cfMetaData).toString().trim(); for (String columnName : this.options.fields.keySet()) { boolean areEqual = toCheck.equalsIgnoreCase(columnName.trim()); if (logger.isDebugEnabled()) logger.debug(String.format("Comparing name for index - This column name [%s] - Passed column name [%s] - Equal [%s]", columnName, toCheck, areEqual)); if (areEqual) return true; } return false; }
void add(Cell cell) { CellName cellName = cell.name(); ColumnIdentifier columnName = cellName.cql3ColumnName(cfMetaData); if (cellName.isCollectionCell()) { if (collections == null) collections = new HashMap<>(); List<Cell> values = collections.get(columnName); if (values == null) { values = new ArrayList<Cell>(); collections.put(columnName, values); } values.add(cell); } else { if (columns == null) columns = new HashMap<>(); columns.put(columnName, cell); } }
private static boolean isDroppedColumn(Cell c, CFMetaData meta) { Long droppedAt = meta.getDroppedColumns().get(c.name().cql3ColumnName(meta)); return droppedAt != null && c.timestamp() <= droppedAt; }
public boolean isDroppedColumn(Cell c, CFMetaData meta) { Long droppedAt = meta.getDroppedColumns().get(c.name().cql3ColumnName(meta)); return droppedAt != null && c.timestamp() <= droppedAt; }
/** * Returns a ColumnDefinition given a cell name. */ public ColumnDefinition getColumnDefinition(CellName cellName) { ColumnIdentifier id = cellName.cql3ColumnName(this); ColumnDefinition def = id == null ? getColumnDefinition(cellName.toByteBuffer()) // Means a dense layout, try the full column name : getColumnDefinition(id); // It's possible that the def is a PRIMARY KEY or COMPACT_VALUE one in case a concrete cell // name conflicts with a CQL column name, which can happen in 2 cases: // 1) because the user inserted a cell through Thrift that conflicts with a default "alias" used // by CQL for thrift tables (see #6892). // 2) for COMPACT STORAGE tables with a single utf8 clustering column, the cell name can be anything, // including a CQL column name (without this being a problem). // In any case, this is fine, this just mean that columnDefinition is not the ColumnDefinition we are // looking for. return def != null && def.isPartOfCellName() ? def : null; }
public boolean deleteIfNotLatest(DecoratedKey decoratedKey, long timestamp, String pkString, ColumnFamily cf) throws IOException { if (deleteRowIfNotLatest(decoratedKey, cf)) return true; Cell lastColumn = null; for (CellName colKey : cf.getColumnNames()) { String name = colKey.cql3ColumnName(tableMapper.cfMetaData).toString(); com.tuplejump.stargate.lucene.Properties option = options.fields.get(name); //if option was not found then the column is not indexed if (option != null) { lastColumn = cf.getColumn(colKey); } } if (lastColumn != null && lastColumn.timestamp() > timestamp) { currentIndex.delete(decoratedKey, pkString, timestamp); return true; } return false; }
private void loadOldRow(DecoratedKey dk, ByteBuffer pkBuf, List<Field> fields) { CellName clusteringKey = tableMapper.makeClusteringKey(pkBuf); Composite start = tableMapper.start(clusteringKey); Composite end = tableMapper.end(start); ColumnSlice columnSlice = new ColumnSlice(start, end); SliceQueryFilter sliceQueryFilter = new SliceQueryFilter(columnSlice, false, Integer.MAX_VALUE); QueryFilter queryFilter = new QueryFilter(dk, tableMapper.table.name, sliceQueryFilter, new Date().getTime()); ColumnFamily columnFamily = tableMapper.table.getColumnFamily(queryFilter); Map<CellName, ColumnFamily> fullSlice = tableMapper.getRows(columnFamily); ColumnFamily oldDocument = fullSlice.get(clusteringKey); for (Cell cell : oldDocument) { CellName cellName = cell.name(); ColumnIdentifier cql3ColName = cellName.cql3ColumnName(tableMapper.cfMetaData); String actualColName = cql3ColName.toString(); ColumnDefinition columnDefinition = tableMapper.cfMetaData.getColumnDefinition(cql3ColName); if (options.shouldIndex(actualColName)) { addFields(cell, actualColName, columnDefinition, fields); } } }
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); }
private ColumnFamily scored(Float score, ColumnFamily data) { ColumnFamily cleanColumnFamily = data.getFactory().create(table.metadata); String indexColumnName = resultMapper.tableMapper.primaryColumnName(); boolean metaColReplaced = false; Cell firstColumn = null; for (Cell column : data) { if (firstColumn == null) firstColumn = column; ColumnIdentifier cellName = column.name().cql3ColumnName(table.metadata); String thisColName = cellName.toString(); boolean isIndexColumn = indexColumnName.equals(thisColName); if (isIndexColumn) { Cell scoreColumn = new BufferCell(column.name(), UTF8Type.instance.decompose("{\"score\":" + score.toString() + "}")); cleanColumnFamily.addColumn(scoreColumn); metaColReplaced = true; } else { cleanColumnFamily.addColumn(column); } } if (!metaColReplaced && firstColumn != null) { Cell newColumn = getMetaColumn(firstColumn, score); cleanColumnFamily.addColumn(newColumn); } return cleanColumnFamily; }
keyColumnsAdded = true; String actualColumnName = column.name().cql3ColumnName(table.metadata).toString(); ByteBuffer colValue = column.value(); AbstractType<?> valueValidator = table.metadata.getValueValidator(column.name());