Skip to content

Commit

Permalink
Nits
Browse files Browse the repository at this point in the history
  • Loading branch information
beobal committed Aug 21, 2015
1 parent 454bba7 commit 6a5766c
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -919,9 +919,6 @@ public UnfilteredRowIterator cleanup(UnfilteredRowIterator partition)

cfs.invalidateCachedPartition(partition.partitionKey());

// we need to acquire memtable lock because secondary index deletion may
// cause a race (see CASSANDRA-3712). This is done internally by the
// index manager (see newCleanupTransaction())
cfs.indexManager.deletePartition(partition, nowInSec);
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public class AtomicBTreePartition extends AbstractBTreePartition

public AtomicBTreePartition(CFMetaData metadata, DecoratedKey partitionKey, MemtableAllocator allocator)
{
// TODO: is this a potential bug? partition columns may be a subset if we alter columns while it's in memtable
// involved in potential bug? partition columns may be a subset if we alter columns while it's in memtable
super(metadata, partitionKey, metadata.partitionColumns());
this.allocator = allocator;
this.ref = EMPTY;
Expand Down Expand Up @@ -149,7 +149,6 @@ public long[] addAllWithSizeDelta(final PartitionUpdate update, OpOrder.Group wr
deletionInfo = current.deletionInfo;
}

// todo static rows? anything more to do for indexing
Row newStatic = update.staticRow();
Row staticRow = newStatic.isEmpty()
? current.staticRow
Expand Down
29 changes: 13 additions & 16 deletions src/java/org/apache/cassandra/index/Index.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
* The main interface defines methods for index management, index selection at both write and query time,
* as well as validation of values that will ultimately be indexed.
* Two sub-interfaces are also defined, which represent single use helpers for short lived tasks at read and write time.
* Indexer: an event listener which receives notifications at particular points duing an update of a single partition
* Indexer: an event listener which receives notifications at particular points during an update of a single partition
* in the base table.
* IndexSearcher: perform queries against the index based on a predicate defined in a RowFilter.Expression. An instance
* is expected to be single use, being used by the execution of a single ReadCommand.
* Searcher: performs queries against the index based on a predicate defined in a RowFilter. An instance
* is expected to be single use, being involved in the execution of a single ReadCommand.
*
* The main interface includes factory methods for obtaining instances of both of the sub-interfaces;
*
Expand Down Expand Up @@ -281,21 +281,21 @@ public interface Indexer
* Notification of the start of a partition update.
* This event always occurs before any other during the update.
*/
default void begin(){}
public void begin();

/**
* Notification of a top level partition delete.
* @param deletionTime
*/
default void partitionDelete(DeletionTime deletionTime){}
public void partitionDelete(DeletionTime deletionTime);

/**
* Notification of a RangeTombstone.
* An update of a single partition may contain multiple RangeTombstones,
* and a notification will be passed for each of them.
* @param tombstone
*/
default void rangeTombstone(RangeTombstone tombstone){}
public void rangeTombstone(RangeTombstone tombstone);

/**
* Notification that a new row was inserted into the Memtable holding the partition.
Expand All @@ -305,7 +305,7 @@ default void rangeTombstone(RangeTombstone tombstone){}
*
* @param row the Row being inserted into the base table's Memtable.
*/
default void insertRow(Row row){}
public void insertRow(Row row);

/**
* Notification of a modification to a row in the base table's Memtable.
Expand All @@ -326,7 +326,7 @@ default void insertRow(Row row){}
* @param newRowData data that was not present in the existing row and is being inserted
* into the base table's Memtable
*/
default void updateRow(Row oldRowData, Row newRowData){}
public void updateRow(Row oldRowData, Row newRowData);

/**
* Notification that a row was removed from the partition.
Expand All @@ -342,18 +342,15 @@ default void updateRow(Row oldRowData, Row newRowData){}
* have been deleted, so implementations which index primary key columns should not
* purge those entries from their indexes.
*
* Row deletions via the normal write path do not trigger calls to this method as
* they are processed as RangeTombstones.
*
* @param row data being removed from the base table
*/
default void removeRow(Row row){}
public void removeRow(Row row);

/**
* Notification of the end of the partition update.
* This event always occurs after all others for the particular update.
*/
default void finish(){}
public void finish();
}

/*
Expand All @@ -370,16 +367,16 @@ default void finish(){}
* transformed in this way but this may change over time as usage is generalized.
* See CASSANDRA-8717 for further discussion.
*
* The function should takes a PartitionIterator of the results from the replicas which has already been collated
* The function takes a PartitionIterator of the results from the replicas which has already been collated
* & reconciled, along with the command being executed. It returns another PartitionIterator containing the results
* of the transformation.
* of the transformation (which may be the same as the input if the transformation is a no-op).
*/
public BiFunction<PartitionIterator, ReadCommand, PartitionIterator> postProcessorFor(ReadCommand command);

/**
* Factory method for query time search helper.
* @param command the read command being executed
* @return an Optional<IndexSearcher> which should be empty if this index cannot satisfy the
* @return an Searcher with which to perform the supplied command
*/
public Searcher searcherFor(ReadCommand command);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,9 @@ public void indexPartition(UnfilteredRowIterator partition, OpOrder.Group opGrou
*/
public void deletePartition(UnfilteredRowIterator partition, int nowInSec)
{
// we need to acquire memtable lock because secondary index deletion may
// cause a race (see CASSANDRA-3712). This is done internally by the
// index transaction when it commits
CleanupTransaction indexTransaction = newCleanupTransaction(partition.partitionKey(),
partition.columns(),
nowInSec);
Expand Down
17 changes: 17 additions & 0 deletions src/java/org/apache/cassandra/index/internal/CassandraIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,18 @@ public Indexer indexerFor(final DecoratedKey key,
{
return new Indexer()
{
public void begin()
{
}

public void partitionDelete(DeletionTime deletionTime)
{
}

public void rangeTombstone(RangeTombstone tombstone)
{
}

public void insertRow(Row row)
{
if (isPrimaryKeyIndex())
Expand Down Expand Up @@ -224,6 +236,7 @@ public void removeRow(Row row)
removeCell(row.clustering(), row.getCell(metadata.indexedColumn));
}


public void updateRow(Row oldRow, Row newRow)
{
if (isPrimaryKeyIndex())
Expand All @@ -243,6 +256,10 @@ public void updateRow(Row oldRow, Row newRow)
}
}

public void finish()
{
}

private void indexCells(Clustering clustering, Iterable<Cell> cells)
{
if (cells == null)
Expand Down
16 changes: 16 additions & 0 deletions test/unit/org/apache/cassandra/index/StubIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ public Indexer indexerFor(DecoratedKey key,
{
return new Indexer()
{
public void begin()
{
}

public void partitionDelete(DeletionTime deletionTime)
{
}

public void rangeTombstone(RangeTombstone tombstone)
{
}

public void insertRow(Row row)
{
rowsInserted.add(row);
Expand All @@ -96,6 +108,10 @@ public void updateRow(Row oldRowData, Row newRowData)
{
rowsUpdated.add(Pair.create(oldRowData, newRowData));
}

public void finish()
{
}
};
}

Expand Down

0 comments on commit 6a5766c

Please sign in to comment.