mirror of https://github.com/apache/cassandra
Remove unused method CF.merge and add more tests to ColumnFamilyTest. patch by Sandeep Tata; review by jbellis for #69
git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/trunk@763859 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
768d2d1493
commit
a7d5c6506b
|
|
@ -306,21 +306,6 @@ public final class ColumnFamily
|
|||
return markedForDeleteAt > Long.MIN_VALUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
|
|
@ -337,7 +322,6 @@ public final class ColumnFamily
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This function will calculate the differnce between 2 column families
|
||||
* the external input is considered the superset of internal
|
||||
|
|
|
|||
|
|
@ -64,4 +64,53 @@ public class ColumnFamilyTest
|
|||
}
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue