You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ty...@apache.org on 2014/12/12 17:55:28 UTC
[1/2] cassandra git commit: Fix NPE when writetime() or ttl() are
nested inside a fn call
Repository: cassandra
Updated Branches:
refs/heads/cassandra-2.1 597a1d5db -> 025a63599
Fix NPE when writetime() or ttl() are nested inside a fn call
Patch by Tyler Hobbs; reviewed by Benjamin Lerer for CASSANDRA-8451
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/3f3d0edb
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/3f3d0edb
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/3f3d0edb
Branch: refs/heads/cassandra-2.1
Commit: 3f3d0edbad6b42f5fc8715ecfa52e2e41bbdcea9
Parents: ac9cfbd
Author: Tyler Hobbs <ty...@datastax.com>
Authored: Fri Dec 12 10:49:32 2014 -0600
Committer: Tyler Hobbs <ty...@datastax.com>
Committed: Fri Dec 12 10:49:32 2014 -0600
----------------------------------------------------------------------
CHANGES.txt | 2 +
.../cassandra/cql3/statements/Selection.java | 50 ++++++++++++++++++--
2 files changed, 47 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/3f3d0edb/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index c25caf9..cc426bb 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
2.0.12:
+ * Fix NPE when writetime() or ttl() calls are wrapped by
+ another function call (CASSANDRA-8451)
* Fix NPE after dropping a keyspace (CASSANDRA-8332)
* Fix error message on read repair timeouts (CASSANDRA-7947)
* Default DTCS base_time_seconds changed to 60 (CASSANDRA-8417)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/3f3d0edb/src/java/org/apache/cassandra/cql3/statements/Selection.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/Selection.java b/src/java/org/apache/cassandra/cql3/statements/Selection.java
index 407f7d9..223f698 100644
--- a/src/java/org/apache/cassandra/cql3/statements/Selection.java
+++ b/src/java/org/apache/cassandra/cql3/statements/Selection.java
@@ -186,11 +186,8 @@ public abstract class Selection
{
Selector selector = makeSelector(cfDef, rawSelector, names, metadata);
selectors.add(selector);
- if (selector instanceof WritetimeOrTTLSelector)
- {
- collectTimestamps |= ((WritetimeOrTTLSelector)selector).isWritetime;
- collectTTLs |= !((WritetimeOrTTLSelector)selector).isWritetime;
- }
+ collectTimestamps |= selector.usesTimestamps();
+ collectTTLs |= selector.usesTTLs();
}
return new SelectionWithProcessing(names, metadata, selectors, collectTimestamps, collectTTLs);
}
@@ -374,6 +371,12 @@ public abstract class Selection
private interface Selector extends AssignementTestable
{
public ByteBuffer compute(ResultSetBuilder rs) throws InvalidRequestException;
+
+ /** Returns true if the selector acts on a column's timestamp, false otherwise. */
+ public boolean usesTimestamps();
+
+ /** Returns true if the selector acts on a column's TTL, false otherwise. */
+ public boolean usesTTLs();
}
private static class SimpleSelector implements Selector
@@ -399,6 +402,16 @@ public abstract class Selection
return receiver.type.isValueCompatibleWith(type);
}
+ public boolean usesTimestamps()
+ {
+ return false;
+ }
+
+ public boolean usesTTLs()
+ {
+ return false;
+ }
+
@Override
public String toString()
{
@@ -431,6 +444,22 @@ public abstract class Selection
return receiver.type.isValueCompatibleWith(fun.returnType());
}
+ public boolean usesTimestamps()
+ {
+ for (Selector s : argSelectors)
+ if (s.usesTimestamps())
+ return true;
+ return false;
+ }
+
+ public boolean usesTTLs()
+ {
+ for (Selector s : argSelectors)
+ if (s.usesTTLs())
+ return true;
+ return false;
+ }
+
@Override
public String toString()
{
@@ -476,6 +505,17 @@ public abstract class Selection
return receiver.type.isValueCompatibleWith(isWritetime ? LongType.instance : Int32Type.instance);
}
+
+ public boolean usesTimestamps()
+ {
+ return isWritetime;
+ }
+
+ public boolean usesTTLs()
+ {
+ return !isWritetime;
+ }
+
@Override
public String toString()
{
[2/2] cassandra git commit: Merge branch 'cassandra-2.0' into
cassandra-2.1
Posted by ty...@apache.org.
Merge branch 'cassandra-2.0' into cassandra-2.1
Conflicts:
CHANGES.txt
src/java/org/apache/cassandra/cql3/statements/Selection.java
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/025a6359
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/025a6359
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/025a6359
Branch: refs/heads/cassandra-2.1
Commit: 025a635999b038f58b7541ab877ce1db823fbd5f
Parents: 597a1d5 3f3d0ed
Author: Tyler Hobbs <ty...@datastax.com>
Authored: Fri Dec 12 10:55:18 2014 -0600
Committer: Tyler Hobbs <ty...@datastax.com>
Committed: Fri Dec 12 10:55:18 2014 -0600
----------------------------------------------------------------------
CHANGES.txt | 2 +
.../cassandra/cql3/statements/Selection.java | 46 +++++++++++++++++---
2 files changed, 43 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/025a6359/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 2571a09,cc426bb..579fd62
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,29 -1,6 +1,31 @@@
-2.0.12:
+2.1.3
+ * Scale memtable slab allocation logarithmically (CASSANDRA-7882)
+ * cassandra-stress simultaneous inserts over same seed (CASSANDRA-7964)
+ * Reduce cassandra-stress sampling memory requirements (CASSANDRA-7926)
+ * Ensure memtable flush cannot expire commit log entries from its future (CASSANDRA-8383)
+ * Make read "defrag" async to reclaim memtables (CASSANDRA-8459)
+ * Remove tmplink files for offline compactions (CASSANDRA-8321)
+ * Reduce maxHintsInProgress (CASSANDRA-8415)
+ * BTree updates may call provided update function twice (CASSANDRA-8018)
+ * Release sstable references after anticompaction (CASSANDRA-8386)
+ * Handle abort() in SSTableRewriter properly (CASSANDRA-8320)
+ * Fix high size calculations for prepared statements (CASSANDRA-8231)
+ * Centralize shared executors (CASSANDRA-8055)
+ * Fix filtering for CONTAINS (KEY) relations on frozen collection
+ clustering columns when the query is restricted to a single
+ partition (CASSANDRA-8203)
+ * Do more aggressive entire-sstable TTL expiry checks (CASSANDRA-8243)
+ * Add more log info if readMeter is null (CASSANDRA-8238)
+ * add check of the system wall clock time at startup (CASSANDRA-8305)
+ * Support for frozen collections (CASSANDRA-7859)
+ * Fix overflow on histogram computation (CASSANDRA-8028)
+ * Have paxos reuse the timestamp generation of normal queries (CASSANDRA-7801)
+ * Fix incremental repair not remove parent session on remote (CASSANDRA-8291)
+ * Improve JBOD disk utilization (CASSANDRA-7386)
+ * Log failed host when preparing incremental repair (CASSANDRA-8228)
+Merged from 2.0:
+ * Fix NPE when writetime() or ttl() calls are wrapped by
+ another function call (CASSANDRA-8451)
* Fix NPE after dropping a keyspace (CASSANDRA-8332)
* Fix error message on read repair timeouts (CASSANDRA-7947)
* Default DTCS base_time_seconds changed to 60 (CASSANDRA-8417)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/025a6359/src/java/org/apache/cassandra/cql3/statements/Selection.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/cql3/statements/Selection.java
index 5deda5f,223f698..ff808bb
--- a/src/java/org/apache/cassandra/cql3/statements/Selection.java
+++ b/src/java/org/apache/cassandra/cql3/statements/Selection.java
@@@ -224,15 -184,12 +224,12 @@@ public abstract class Selectio
boolean collectTTLs = false;
for (RawSelector rawSelector : rawSelectors)
{
- Selector selector = makeSelector(cfDef, rawSelector, names, metadata);
+ Selector selector = makeSelector(cfm, rawSelector, defs, metadata);
selectors.add(selector);
- if (selector instanceof WritetimeOrTTLSelector)
- {
- collectTimestamps |= ((WritetimeOrTTLSelector)selector).isWritetime;
- collectTTLs |= !((WritetimeOrTTLSelector)selector).isWritetime;
- }
+ collectTimestamps |= selector.usesTimestamps();
+ collectTTLs |= selector.usesTTLs();
}
- return new SelectionWithProcessing(names, metadata, selectors, collectTimestamps, collectTTLs);
+ return new SelectionWithProcessing(defs, metadata, selectors, collectTimestamps, collectTTLs);
}
else
{
@@@ -376,18 -347,39 +373,30 @@@
}
}
- private static class SelectionWithProcessing extends Selection
+ private static abstract class Selector implements AssignementTestable
{
- private final List<Selector> selectors;
+ public abstract ByteBuffer compute(ResultSetBuilder rs) throws InvalidRequestException;
+ public abstract AbstractType<?> getType();
- public SelectionWithProcessing(List<CFDefinition.Name> columns, List<ColumnSpecification> metadata, List<Selector> selectors, boolean collectTimestamps, boolean collectTTLs)
+ public boolean isAssignableTo(String keyspace, ColumnSpecification receiver)
{
- super(columns, metadata, collectTimestamps, collectTTLs);
- this.selectors = selectors;
+ return receiver.type.isValueCompatibleWith(getType());
}
+
- protected List<ByteBuffer> handleRow(ResultSetBuilder rs) throws InvalidRequestException
++ /** Returns true if the selector acts on a column's timestamp, false otherwise. */
++ public boolean usesTimestamps()
+ {
- List<ByteBuffer> result = new ArrayList<ByteBuffer>();
- for (Selector selector : selectors)
- {
- result.add(selector.compute(rs));
- }
- return result;
++ return false;
+ }
- }
-
- private interface Selector extends AssignementTestable
- {
- public ByteBuffer compute(ResultSetBuilder rs) throws InvalidRequestException;
-
- /** Returns true if the selector acts on a column's timestamp, false otherwise. */
- public boolean usesTimestamps();
+
+ /** Returns true if the selector acts on a column's TTL, false otherwise. */
- public boolean usesTTLs();
++ public boolean usesTTLs()
++ {
++ return false;
++ }
}
- private static class SimpleSelector implements Selector
+ private static class SimpleSelector extends Selector
{
private final String columnName;
private final int idx;
@@@ -464,11 -439,27 +473,27 @@@
return fun.execute(args);
}
- public boolean isAssignableTo(ColumnSpecification receiver)
+ public AbstractType<?> getType()
{
- return receiver.type.isValueCompatibleWith(fun.returnType());
+ return fun.returnType();
}
+ public boolean usesTimestamps()
+ {
+ for (Selector s : argSelectors)
+ if (s.usesTimestamps())
+ return true;
+ return false;
+ }
+
+ public boolean usesTTLs()
+ {
+ for (Selector s : argSelectors)
+ if (s.usesTTLs())
+ return true;
+ return false;
+ }
+
@Override
public String toString()
{
@@@ -543,11 -500,22 +568,22 @@@
return ttl > 0 ? ByteBufferUtil.bytes(ttl) : null;
}
- public boolean isAssignableTo(ColumnSpecification receiver)
+ public AbstractType<?> getType()
{
- return receiver.type.isValueCompatibleWith(isWritetime ? LongType.instance : Int32Type.instance);
+ return isWritetime ? LongType.instance : Int32Type.instance;
}
+
+ public boolean usesTimestamps()
+ {
+ return isWritetime;
+ }
+
+ public boolean usesTTLs()
+ {
+ return !isWritetime;
+ }
+
@Override
public String toString()
{