cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [1/2] git commit: Avoid some map lookups
Date Mon, 22 Jul 2013 09:12:06 GMT
Updated Branches:
  refs/heads/trunk 41ef86b61 -> 79fe644aa


Avoid some map lookups


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/86a077a1
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/86a077a1
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/86a077a1

Branch: refs/heads/trunk
Commit: 86a077a190a1cec89112b9f1fd991f0fe06d2423
Parents: 089f92b
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Mon Jul 22 11:03:50 2013 +0200
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Mon Jul 22 11:04:28 2013 +0200

----------------------------------------------------------------------
 src/java/org/apache/cassandra/config/CFMetaData.java        | 4 ++--
 src/java/org/apache/cassandra/config/ColumnDefinition.java  | 4 ++--
 src/java/org/apache/cassandra/config/KSMetaData.java        | 2 +-
 .../apache/cassandra/cql3/statements/DeleteStatement.java   | 2 +-
 .../apache/cassandra/cql3/statements/UpdateStatement.java   | 2 +-
 src/java/org/apache/cassandra/db/RowMutation.java           | 9 +++++++--
 6 files changed, 14 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/86a077a1/src/java/org/apache/cassandra/config/CFMetaData.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/CFMetaData.java b/src/java/org/apache/cassandra/config/CFMetaData.java
index 81afd23..f3b235d 100644
--- a/src/java/org/apache/cassandra/config/CFMetaData.java
+++ b/src/java/org/apache/cassandra/config/CFMetaData.java
@@ -1292,7 +1292,7 @@ public final class CFMetaData
     public RowMutation dropFromSchema(long timestamp)
     {
         RowMutation rm = new RowMutation(Table.SYSTEM_KS, SystemTable.getSchemaKSKey(ksName));
-        ColumnFamily cf = rm.addOrGet(SystemTable.SCHEMA_COLUMNFAMILIES_CF);
+        ColumnFamily cf = rm.addOrGet(SchemaColumnFamiliesCf);
         int ldt = (int) (System.currentTimeMillis() / 1000);
 
         cf.addColumn(DeletedColumn.create(ldt, timestamp, cfName, ""));
@@ -1338,7 +1338,7 @@ public final class CFMetaData
     {
         // For property that can be null (and can be changed), we insert tombstones, to make
sure
         // we don't keep a property the user has removed
-        ColumnFamily cf = rm.addOrGet(SystemTable.SCHEMA_COLUMNFAMILIES_CF);
+        ColumnFamily cf = rm.addOrGet(SchemaColumnFamiliesCf);
         int ldt = (int) (System.currentTimeMillis() / 1000);
 
         Integer oldId = Schema.instance.convertNewCfId(cfId);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/86a077a1/src/java/org/apache/cassandra/config/ColumnDefinition.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/ColumnDefinition.java b/src/java/org/apache/cassandra/config/ColumnDefinition.java
index 97f57e1..db5f7ed 100644
--- a/src/java/org/apache/cassandra/config/ColumnDefinition.java
+++ b/src/java/org/apache/cassandra/config/ColumnDefinition.java
@@ -147,7 +147,7 @@ public class ColumnDefinition
      */
     public void deleteFromSchema(RowMutation rm, String cfName, AbstractType<?> comparator,
long timestamp)
     {
-        ColumnFamily cf = rm.addOrGet(SystemTable.SCHEMA_COLUMNS_CF);
+        ColumnFamily cf = rm.addOrGet(CFMetaData.SchemaColumnsCf);
         int ldt = (int) (System.currentTimeMillis() / 1000);
 
         cf.addColumn(DeletedColumn.create(ldt, timestamp, cfName, comparator.getString(name),
""));
@@ -160,7 +160,7 @@ public class ColumnDefinition
 
     public void toSchema(RowMutation rm, String cfName, AbstractType<?> comparator,
long timestamp)
     {
-        ColumnFamily cf = rm.addOrGet(SystemTable.SCHEMA_COLUMNS_CF);
+        ColumnFamily cf = rm.addOrGet(CFMetaData.SchemaColumnsCf);
         int ldt = (int) (System.currentTimeMillis() / 1000);
 
         cf.addColumn(Column.create("", timestamp, cfName, comparator.getString(name), ""));

http://git-wip-us.apache.org/repos/asf/cassandra/blob/86a077a1/src/java/org/apache/cassandra/config/KSMetaData.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/KSMetaData.java b/src/java/org/apache/cassandra/config/KSMetaData.java
index a5bc4a0..b92f9a5 100644
--- a/src/java/org/apache/cassandra/config/KSMetaData.java
+++ b/src/java/org/apache/cassandra/config/KSMetaData.java
@@ -238,7 +238,7 @@ public final class KSMetaData
     public RowMutation toSchema(long timestamp)
     {
         RowMutation rm = new RowMutation(Table.SYSTEM_KS, SystemTable.getSchemaKSKey(name));
-        ColumnFamily cf = rm.addOrGet(SystemTable.SCHEMA_KEYSPACES_CF);
+        ColumnFamily cf = rm.addOrGet(CFMetaData.SchemaKeyspacesCf);
 
         cf.addColumn(Column.create(durableWrites, timestamp, "durable_writes"));
         cf.addColumn(Column.create(strategyClass.getName(), timestamp, "strategy_class"));

http://git-wip-us.apache.org/repos/asf/cassandra/blob/86a077a1/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java b/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java
index eafe7c0..68ae6b8 100644
--- a/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java
@@ -102,7 +102,7 @@ public class DeleteStatement extends ModificationStatement
     {
         QueryProcessor.validateKey(key);
         RowMutation rm = new RowMutation(cfDef.cfm.ksName, key);
-        ColumnFamily cf = rm.addOrGet(columnFamily());
+        ColumnFamily cf = rm.addOrGet(cfDef.cfm);
 
         if (toRemove.isEmpty() && builder.componentCount() == 0)
         {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/86a077a1/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java b/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java
index 5f37e15..f31196a 100644
--- a/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java
@@ -213,7 +213,7 @@ public class UpdateStatement extends ModificationStatement
 
         QueryProcessor.validateKey(key);
         RowMutation rm = new RowMutation(cfDef.cfm.ksName, key);
-        ColumnFamily cf = rm.addOrGet(cfDef.cfm.cfName);
+        ColumnFamily cf = rm.addOrGet(cfDef.cfm);
 
         // Inserting the CQL row marker (see #4361)
         // We always need to insert a marker, because of the following situation:

http://git-wip-us.apache.org/repos/asf/cassandra/blob/86a077a1/src/java/org/apache/cassandra/db/RowMutation.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/RowMutation.java b/src/java/org/apache/cassandra/db/RowMutation.java
index b85cfcd..69f4a5f 100644
--- a/src/java/org/apache/cassandra/db/RowMutation.java
+++ b/src/java/org/apache/cassandra/db/RowMutation.java
@@ -149,7 +149,11 @@ public class RowMutation implements IMutation
      */
     public ColumnFamily addOrGet(String cfName)
     {
-        CFMetaData cfm = Schema.instance.getCFMetaData(table, cfName);
+        return addOrGet(Schema.instance.getCFMetaData(table, cfName));
+    }
+
+    public ColumnFamily addOrGet(CFMetaData cfm)
+    {
         ColumnFamily cf = modifications.get(cfm.cfId);
         if (cf == null)
         {
@@ -266,7 +270,8 @@ public class RowMutation implements IMutation
      */
     public void apply()
     {
-        KSMetaData ksm = Schema.instance.getTableDefinition(getTable());
+        KSMetaData ksm = Schema.instance.getTableDefinition(table);
+        assert ksm != null : "Attempting to mutate non-existant keyspace " + table;
         Table.open(table).apply(this, ksm.durableWrites);
     }
 


Mime
View raw message