Skip to content
Browse files

log index scan subject in CompositesSearcher

patch by slebresne; reviewed by jbellis for CASSANDRA-4904
  • Loading branch information...
1 parent fdf2959 commit f04bebfa7e5fb0efd003685b10c0e31250de441d @pcmanus pcmanus committed Nov 5, 2012
View
1 CHANGES.txt
@@ -52,6 +52,7 @@
* Don't allow prepared marker inside collections (CASSANDRA-4890)
* Re-allow order by on non-selected columns (CASSANDRA-4645)
* Bug when composite index is created in a table having collections (CASSANDRA-4909)
+ * log index scan subject in CompositesSearcher (CASSANDRA-4904)
Merged from 1.1:
* add get[Row|Key]CacheEntries to CacheServiceMBean (CASSANDRA-4859)
* fix get_paged_slice to wrap to next row correctly (CASSANDRA-4816)
View
13 src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java
@@ -25,6 +25,7 @@
import org.apache.cassandra.db.*;
import org.apache.cassandra.db.marshal.*;
import org.apache.cassandra.dht.*;
+import org.apache.cassandra.thrift.IndexExpression;
import org.apache.cassandra.utils.ByteBufferUtil;
/**
@@ -73,6 +74,18 @@ public void init()
protected abstract ByteBuffer makeIndexColumnName(ByteBuffer rowKey, IColumn column);
+ protected abstract AbstractType getExpressionComparator();
+
+ public String expressionString(IndexExpression expr)
+ {
+ return String.format("'%s.%s %s %s'",
+ baseCfs.columnFamily,
+ getExpressionComparator().getString(expr.column_name),
+ expr.op,
+ baseCfs.metadata.getColumn_metadata().get(expr.column_name).getValidator().getString(expr.value));
+ }
+
+
public void delete(ByteBuffer rowKey, IColumn column)
{
if (column.isMarkedForDelete())
View
6 src/java/org/apache/cassandra/db/index/composites/CompositesIndex.java
@@ -67,6 +67,12 @@ protected ByteBuffer makeIndexColumnName(ByteBuffer rowKey, IColumn column)
return builder.build();
}
+ protected AbstractType getExpressionComparator()
+ {
+ CompositeType baseComparator = (CompositeType)baseCfs.getComparator();
+ return baseComparator.types.get(prefixSize);
+ }
+
@Override
public boolean indexes(ByteBuffer name)
{
View
8 src/java/org/apache/cassandra/db/index/composites/CompositesSearcher.java
@@ -23,6 +23,7 @@
import org.apache.cassandra.db.*;
import org.apache.cassandra.db.filter.*;
+import org.apache.cassandra.db.index.AbstractSimplePerColumnSecondaryIndex;
import org.apache.cassandra.db.index.PerColumnSecondaryIndex;
import org.apache.cassandra.db.index.SecondaryIndex;
import org.apache.cassandra.db.index.SecondaryIndexManager;
@@ -208,10 +209,9 @@ protected Row computeNext()
return makeReturn(currentKey, data);
}
- // TODO: broken because we need to extract the component comparator rather than the whole name comparator
- // if (logger.isDebugEnabled())
- // logger.debug("Scanning index {} starting with {}",
- // expressionString(primary), indexComparator.getString(startPrefix));
+ if (logger.isTraceEnabled() && (index instanceof AbstractSimplePerColumnSecondaryIndex))
+ logger.trace("Scanning index {} starting with {}",
+ ((AbstractSimplePerColumnSecondaryIndex)index).expressionString(primary), indexComparator.getString(startPrefix));
QueryFilter indexFilter = QueryFilter.getSliceFilter(indexKey,
new QueryPath(index.getIndexCfs().getColumnFamilyName()),
View
6 src/java/org/apache/cassandra/db/index/keys/KeysIndex.java
@@ -24,6 +24,7 @@
import org.apache.cassandra.db.IColumn;
import org.apache.cassandra.db.index.AbstractSimplePerColumnSecondaryIndex;
import org.apache.cassandra.db.index.SecondaryIndexSearcher;
+import org.apache.cassandra.db.marshal.AbstractType;
import org.apache.cassandra.exceptions.ConfigurationException;
/**
@@ -51,4 +52,9 @@ public void validateOptions() throws ConfigurationException
{
// no options used
}
+
+ protected AbstractType getExpressionComparator()
+ {
+ return baseCfs.getComparator();
+ }
}
View
14 src/java/org/apache/cassandra/db/index/keys/KeysSearcher.java
@@ -23,6 +23,7 @@
import org.apache.cassandra.db.*;
import org.apache.cassandra.db.filter.*;
+import org.apache.cassandra.db.index.AbstractSimplePerColumnSecondaryIndex;
import org.apache.cassandra.db.index.PerColumnSecondaryIndex;
import org.apache.cassandra.db.index.SecondaryIndex;
import org.apache.cassandra.db.index.SecondaryIndexManager;
@@ -68,15 +69,6 @@ private IndexExpression highestSelectivityPredicate(List<IndexExpression> clause
return best;
}
- private String expressionString(IndexExpression expr)
- {
- return String.format("'%s.%s %s %s'",
- baseCfs.columnFamily,
- baseCfs.getComparator().getString(expr.column_name),
- expr.op,
- baseCfs.metadata.getColumn_metadata().get(expr.column_name).getValidator().getString(expr.value));
- }
-
public boolean isIndexing(List<IndexExpression> clause)
{
return highestSelectivityPredicate(clause) != null;
@@ -133,9 +125,9 @@ protected Row computeNext()
return endOfData();
}
- if (logger.isTraceEnabled())
+ if (logger.isTraceEnabled() && (index instanceof AbstractSimplePerColumnSecondaryIndex))
logger.trace("Scanning index {} starting with {}",
- expressionString(primary), index.getBaseCfs().metadata.getKeyValidator().getString(startKey));
+ ((AbstractSimplePerColumnSecondaryIndex)index).expressionString(primary), index.getBaseCfs().metadata.getKeyValidator().getString(startKey));
QueryFilter indexFilter = QueryFilter.getSliceFilter(indexKey,
new QueryPath(index.getIndexCfs().getColumnFamilyName()),

0 comments on commit f04bebf

Please sign in to comment.
Something went wrong with that request. Please try again.