You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2009/04/10 04:34:08 UTC
svn commit: r763859 - in /incubator/cassandra/trunk:
src/org/apache/cassandra/db/ColumnFamily.java
test/org/apache/cassandra/db/ColumnFamilyTest.java
Author: jbellis
Date: Fri Apr 10 02:34:07 2009
New Revision: 763859
URL: http://svn.apache.org/viewvc?rev=763859&view=rev
Log:
Remove unused method CF.merge and add more tests to ColumnFamilyTest. patch by Sandeep Tata; review by jbellis for #69
Modified:
incubator/cassandra/trunk/src/org/apache/cassandra/db/ColumnFamily.java
incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnFamilyTest.java
Modified: incubator/cassandra/trunk/src/org/apache/cassandra/db/ColumnFamily.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/db/ColumnFamily.java?rev=763859&r1=763858&r2=763859&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/db/ColumnFamily.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/db/ColumnFamily.java Fri Apr 10 02:34:07 2009
@@ -307,21 +307,6 @@
}
/*
- * This is used as oldCf.merge(newCf). Basically we take the newCf
- * and merge it into the oldCf.
- */
- void merge(ColumnFamily columnFamily)
- {
- Map<String, IColumn> columns = columnFamily.getColumns();
- Set<String> cNames = columns.keySet();
-
- for ( String cName : cNames )
- {
- columns_.put(cName, columns.get(cName));
- }
- }
-
- /*
* This function will repair a list of columns
* If there are any columns in the external list which are not present
* internally then they are added ( this might have to change depending on
@@ -337,7 +322,6 @@
}
}
-
/*
* This function will calculate the differnce between 2 column families
* the external input is considered the superset of internal
Modified: incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnFamilyTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnFamilyTest.java?rev=763859&r1=763858&r2=763859&view=diff
==============================================================================
--- incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnFamilyTest.java (original)
+++ incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnFamilyTest.java Fri Apr 10 02:34:07 2009
@@ -64,4 +64,53 @@
}
assert new HashSet<String>(cf.getColumns().keySet()).equals(map.keySet());
}
+
+ @Test
+ public void testGetColumnCount() {
+ ColumnFamily cf = new ColumnFamily("Standard1", "Standard");
+ byte val[] = "sample value".getBytes();
+
+ cf.addColumn("col1", val, 1);
+ cf.addColumn("col2", val, 2);
+ cf.addColumn("col1", val, 3);
+
+ assert 2 == cf.getColumnCount();
+ assert 2 == cf.getAllColumns().size();
+ }
+
+ @Test
+ public void testTimestamp() {
+ ColumnFamily cf = new ColumnFamily("Standard1", "Standard");
+ byte val1[] = "sample 1".getBytes();
+ byte val2[] = "sample 2".getBytes();
+ byte val3[] = "sample 3".getBytes();
+
+ cf.addColumn("col1", val1, 2);
+ cf.addColumn("col1", val2, 2); // same timestamp, new value
+ cf.addColumn("col1", val3, 1); // older timestamp -- should be ignored
+
+ assert Arrays.equals(val2, cf.getColumn("col1").value());
+ }
+
+ @Test
+ public void testMergeAndAdd(){
+ ColumnFamily cf_new = new ColumnFamily("Standard1", "Standard");
+ ColumnFamily cf_old = new ColumnFamily("Standard1", "Standard");
+ ColumnFamily cf_result = new ColumnFamily("Standard1", "Standard");
+ byte val[] = "sample value".getBytes();
+ byte val2[] = "x value ".getBytes();
+
+ cf_new.addColumn("col1", val, 3);
+ cf_new.addColumn("col2", val, 4);
+
+ cf_old.addColumn("col2", val2, 1);
+ cf_old.addColumn("col3", val2, 2);
+
+ cf_result.addColumns(cf_new);
+ cf_result.addColumns(cf_old);
+
+ assert 3 == cf_result.getColumnCount() : "Count is " + cf_new.getColumnCount();
+ //addcolumns will only add if timestamp >= old timestamp
+ assert Arrays.equals(val, cf_result.getColumn("col2").value());
+ }
}