cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r823349 - in /incubator/cassandra/trunk: conf/ src/java/org/apache/cassandra/config/ src/java/org/apache/cassandra/service/ test/system/
Date Thu, 08 Oct 2009 22:30:55 GMT
Author: jbellis
Date: Thu Oct  8 22:30:55 2009
New Revision: 823349

URL: http://svn.apache.org/viewvc?rev=823349&view=rev
Log:
r/m undocumented term aliases in favor of a single 'comment' field.
patch by jbellis and Brandon Williams; reviewed by Michael Greene for CASSANDRA-481

Modified:
    incubator/cassandra/trunk/conf/storage-conf.xml
    incubator/cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/service/CassandraServer.java
    incubator/cassandra/trunk/test/system/test_server.py

Modified: incubator/cassandra/trunk/conf/storage-conf.xml
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/conf/storage-conf.xml?rev=823349&r1=823348&r2=823349&view=diff
==============================================================================
--- incubator/cassandra/trunk/conf/storage-conf.xml (original)
+++ incubator/cassandra/trunk/conf/storage-conf.xml Thu Oct  8 22:30:55 2009
@@ -58,6 +58,9 @@
        ~
        ~ (To get the closest approximation to 0.3-style supercolumns, you
        ~ would use CompareWith=UTF8Type CompareSubcolumnsWith=LongType.)
+       ~
+       ~ An optional `Comment` attribute may be used to attach additional
+       ~ human-readable information about the column family to its definition.
       -->
       <ColumnFamily CompareWith="BytesType" Name="Standard1"/>
       <ColumnFamily CompareWith="UTF8Type" Name="Standard2"/>
@@ -65,7 +68,8 @@
       <ColumnFamily ColumnType="Super"
                     CompareWith="UTF8Type"
                     CompareSubcolumnsWith="UTF8Type"
-                    Name="Super1"/>
+                    Name="Super1"
+                    Comment="A column family with supercolumns, whose column and subcolumn
names are UTF8 strings"/>
     </Keyspace>
   </Keyspaces>
 

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java?rev=823349&r1=823348&r2=823349&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java Thu Oct
 8 22:30:55 2009
@@ -27,29 +27,13 @@
     public String columnType;           // type: super, standard, etc.
     public AbstractType comparator;       // name sorted, time stamp sorted etc.
     public AbstractType subcolumnComparator; // like comparator, for supercolumns
-
-    // The user chosen names (n_) for various parts of data in a column family.
-    public String n_rowKey;               
-    public String n_superColumnMap;     // only used if this is a super column family
-    public String n_superColumnKey;     // only used if this is a super column family
-    public String n_columnMap;
-    public String n_columnKey;
-    public String n_columnValue;
-    public String n_columnTimestamp;
+    public String comment; // for humans only
 
     // a quick and dirty pretty printer for describing the column family...
     public String pretty()
     {
-        String desc;
-        desc = n_columnMap + "(" + n_columnKey + ", " + n_columnValue + ", " + n_columnTimestamp
+ ")";
-        if ("Super".equals(columnType))
-        {
-            desc = n_superColumnMap + "(" + n_superColumnKey + ", " + desc + ")"; 
-        }
-        desc = tableName + "." + cfName + "(" + n_rowKey + ", " + desc + ")\n";
-        
-        desc += "Column Family Type: " + columnType + "\n" +
-                "Columns Sorted By: " + comparator + "\n";
-        return desc;
+        return tableName + "." + cfName + "\n"
+               + "Column Family Type: " + columnType + "\n"
+               + "Columns Sorted By: " + comparator + "\n";
     }
 }

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java?rev=823349&r1=823348&r2=823349&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
Thu Oct  8 22:30:55 2009
@@ -75,17 +75,6 @@
     private static Set<String> applicationColumnFamilies_ = new HashSet<String>();
     private static int bmtThreshold_ = 256;
 
-    // Default descriptive names for introspection. The user can override
-    // these choices in the config file. These are not case sensitive.
-    // Hence, these are stored in UPPER case for easy comparison.
-    private static String d_rowKey_           = "ROW_KEY";
-    private static String d_superColumnMap_   = "SUPER_COLUMN_MAP";
-    private static String d_superColumnKey_   = "SUPER_COLUMN_KEY";
-    private static String d_columnMap_        = "COLUMN_MAP";
-    private static String d_columnKey_        = "COLUMN_KEY";
-    private static String d_columnValue_      = "COLUMN_VALUE";
-    private static String d_columnTimestamp_  = "COLUMN_TIMESTAMP";
-
     /*
      * A map from table names to the set of column families for the table and the
      * corresponding meta data for that column family.
@@ -439,11 +428,6 @@
                 String xqlTable = "/Storage/Keyspaces/Keyspace[@Name='" + tName + "']/";
                 NodeList columnFamilies = xmlUtils.getRequestedNodeList(xqlTable + "ColumnFamily");
 
-                // get name of the rowKey for this table
-                String n_rowKey = xmlUtils.getNodeValue(xqlTable + "RowKey");
-                if (n_rowKey == null)
-                    n_rowKey = d_rowKey_;
-
                 //NodeList columnFamilies = xmlUtils.getRequestedNodeList(table, "ColumnFamily");
                 int size2 = columnFamilies.getLength();
 
@@ -487,29 +471,7 @@
 
                     // Parse out user-specified logical names for the various dimensions
                     // of a the column family from the config.
-                    String n_superColumnMap = xmlUtils.getNodeValue(xqlCF + "SuperColumnMap");
-                    if (n_superColumnMap == null)
-                        n_superColumnMap = d_superColumnMap_;
-
-                    String n_superColumnKey = xmlUtils.getNodeValue(xqlCF + "SuperColumnKey");
-                    if (n_superColumnKey == null)
-                        n_superColumnKey = d_superColumnKey_;
-
-                    String n_columnMap = xmlUtils.getNodeValue(xqlCF + "ColumnMap");
-                    if (n_columnMap == null)
-                        n_columnMap = d_columnMap_;
-
-                    String n_columnKey = xmlUtils.getNodeValue(xqlCF + "ColumnKey");
-                    if (n_columnKey == null)
-                        n_columnKey = d_columnKey_;
-
-                    String n_columnValue = xmlUtils.getNodeValue(xqlCF + "ColumnValue");
-                    if (n_columnValue == null)
-                        n_columnValue = d_columnValue_;
-
-                    String n_columnTimestamp = xmlUtils.getNodeValue(xqlCF + "ColumnTimestamp");
-                    if (n_columnTimestamp == null)
-                        n_columnTimestamp = d_columnTimestamp_;
+                    String cfComment = xmlUtils.getNodeValue(xqlCF + "Comment");
 
                     // now populate the column family meta data and
                     // insert it into the table dictionary.
@@ -517,22 +479,12 @@
 
                     cfMetaData.tableName = tName;
                     cfMetaData.cfName = cfName;
+                    cfMetaData.comment = cfComment;
 
                     cfMetaData.columnType = columnType;
                     cfMetaData.comparator = columnComparator;
                     cfMetaData.subcolumnComparator = subcolumnComparator;
 
-                    cfMetaData.n_rowKey = n_rowKey;
-                    cfMetaData.n_columnMap = n_columnMap;
-                    cfMetaData.n_columnKey = n_columnKey;
-                    cfMetaData.n_columnValue = n_columnValue;
-                    cfMetaData.n_columnTimestamp = n_columnTimestamp;
-                    if ("Super".equals(columnType))
-                    {
-                        cfMetaData.n_superColumnKey = n_superColumnKey;
-                        cfMetaData.n_superColumnMap = n_superColumnMap;
-                    }
-
                     tableToCFMetaDataMap_.get(tName).put(cfName, cfMetaData);
                 }
             }
@@ -542,15 +494,20 @@
             Map<String, CFMetaData> systemMetadata = new HashMap<String, CFMetaData>();
 
             CFMetaData data = new CFMetaData();
+            data.cfName = SystemTable.STATUS_CF;
             data.columnType = "Standard";
             data.comparator = new UTF8Type();
-            systemMetadata.put(SystemTable.STATUS_CF, data);
+            data.comment = "persistent metadata for the local node";
+            systemMetadata.put(data.cfName, data);
 
             data = new CFMetaData();
+            data.cfName = HintedHandOffManager.HINTS_CF;
             data.columnType = "Super";
             data.comparator = new UTF8Type();
             data.subcolumnComparator = new BytesType();
-            systemMetadata.put(HintedHandOffManager.HINTS_CF, data);
+            data.comment = "hinted handoff data";
+            systemMetadata.put(data.cfName, data);
+
             tableToCFMetaDataMap_.put(Table.SYSTEM_TABLE, systemMetadata);
 
             /* make sure we have a directory for each table */

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/service/CassandraServer.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/service/CassandraServer.java?rev=823349&r1=823348&r2=823349&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/service/CassandraServer.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/service/CassandraServer.java Thu
Oct  8 22:30:55 2009
@@ -539,31 +539,13 @@
             throw new NotFoundException();
         }
 
-        Iterator iter = tableMetaData.entrySet().iterator();
-        while (iter.hasNext())
+        for (Map.Entry<String, CFMetaData> stringCFMetaDataEntry : tableMetaData.entrySet())
         {
-            Map.Entry<String, CFMetaData> pairs = (Map.Entry<String, CFMetaData>)
iter.next();
-            CFMetaData columnFamilyMetaData = pairs.getValue();
-
-            String desc = "";
-
+            CFMetaData columnFamilyMetaData = stringCFMetaDataEntry.getValue();
 
             Map<String, String> columnMap = new HashMap<String, String>();
-            desc = columnFamilyMetaData.n_columnMap + "(" + columnFamilyMetaData.n_columnKey
+ ", " + columnFamilyMetaData.n_columnValue + ", " + columnFamilyMetaData.n_columnTimestamp
+ ")";
-            if (columnFamilyMetaData.columnType.equals("Super"))
-            {
-                columnMap.put("Type", "Super");
-                desc = columnFamilyMetaData.n_superColumnMap + "(" + columnFamilyMetaData.n_superColumnKey
+ ", " + desc + ")";
-            }
-            else
-            {
-                columnMap.put("Type", "Standard");
-            }
-
-            desc = columnFamilyMetaData.tableName + "." + columnFamilyMetaData.cfName + "("
+
-                   columnFamilyMetaData.n_rowKey + ", " + desc + ")";
-
-            columnMap.put("Desc", desc);
+            columnMap.put("Type", columnFamilyMetaData.columnType);
+            columnMap.put("Desc", columnFamilyMetaData.comment == null ? columnFamilyMetaData.pretty()
: columnFamilyMetaData.comment);
             columnMap.put("CompareWith", columnFamilyMetaData.comparator.getClass().getName());
             if (columnFamilyMetaData.columnType.equals("Super"))
             {

Modified: incubator/cassandra/trunk/test/system/test_server.py
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/system/test_server.py?rev=823349&r1=823348&r2=823349&view=diff
==============================================================================
--- incubator/cassandra/trunk/test/system/test_server.py (original)
+++ incubator/cassandra/trunk/test/system/test_server.py Thu Oct  8 22:30:55 2009
@@ -554,3 +554,13 @@
         for key in keys:
             assert rows.has_key(key) == True
             assert columns == rows[key]
+
+    def test_describe_keyspace(self):
+        """ Test keyspace description """
+        kspaces = client.get_string_list_property("keyspaces")
+        assert len(kspaces) == 3, kspaces
+        ks1 = client.describe_keyspace("Keyspace1")
+        assert ks1.keys() == ['Super1', 'Standard1', 'Standard2', 'Super2', 'StandardLong2',
'StandardLong1']
+        sysks = client.describe_keyspace("system")
+
+



Mime
View raw message