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/06 17:10:08 UTC

svn commit: r762375 - in /incubator/cassandra/trunk: conf/storage-conf.xml test/conf/storage-conf.xml test/org/apache/cassandra/db/ColumnFamilyStoreTest.java

Author: jbellis
Date: Mon Apr  6 15:10:07 2009
New Revision: 762375

URL: http://svn.apache.org/viewvc?rev=762375&view=rev
Log:
write get_columns_since test to exercise sequenceFile.next(timeRange).  patch by jbellis; reviewed by Jun Rau.  see #52

Modified:
    incubator/cassandra/trunk/conf/storage-conf.xml
    incubator/cassandra/trunk/test/conf/storage-conf.xml
    incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnFamilyStoreTest.java

Modified: incubator/cassandra/trunk/conf/storage-conf.xml
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/conf/storage-conf.xml?rev=762375&r1=762374&r2=762375&view=diff
==============================================================================
--- incubator/cassandra/trunk/conf/storage-conf.xml (original)
+++ incubator/cassandra/trunk/conf/storage-conf.xml Mon Apr  6 15:10:07 2009
@@ -33,14 +33,14 @@
    <StagingFileDirectory>/var/cassandra/staging</StagingFileDirectory>
    <CommitLogFastSync>false</CommitLogFastSync>
    <Tables>
-      <Table Name = "Table1">
-   	    <ColumnFamily Index="Name" Name="Standard1"/>
-   	    <ColumnFamily Index="Name" Name="Standard2"/>
-   	    <ColumnFamily Index="Time" Name="StandardByTime1"/>
-   	    <ColumnFamily Index="Time" Name="StandardByTime2"/>
-   	    <ColumnFamily ColumnType="Super" Index="Name" Name="Super1"/>
-   	    <ColumnFamily ColumnType="Super" Index="Name" Name="Super2"/>
-      </Table>
+     <Table Name = "Table1">
+       <ColumnFamily ColumnSort="Name" Name="Standard1"/>
+       <ColumnFamily ColumnSort="Name" Name="Standard2"/>
+       <ColumnFamily ColumnSort="Time" Name="StandardByTime1"/>
+       <ColumnFamily ColumnSort="Time" Name="StandardByTime2"/>
+       <ColumnFamily ColumnType="Super" ColumnSort="Name" Name="Super1"/>
+       <ColumnFamily ColumnType="Super" ColumnSort="Name" Name="Super2"/>
+     </Table>
    </Tables>
    <Seeds>
      <!-- Add names of hosts that are deemed contact points -->

Modified: incubator/cassandra/trunk/test/conf/storage-conf.xml
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/conf/storage-conf.xml?rev=762375&r1=762374&r2=762375&view=diff
==============================================================================
--- incubator/cassandra/trunk/test/conf/storage-conf.xml (original)
+++ incubator/cassandra/trunk/test/conf/storage-conf.xml Mon Apr  6 15:10:07 2009
@@ -33,14 +33,14 @@
    <StagingFileDirectory>build/test/cassandra/staging</StagingFileDirectory>
    <CommitLogFastSync>false</CommitLogFastSync>
    <Tables>
-      <Table Name = "Table1">
-   	    <ColumnFamily Index="Name" Name="Standard1"/>
-   	    <ColumnFamily Index="Name" Name="Standard2"/>
-   	    <ColumnFamily Index="Time" Name="StandardByTime1"/>
-   	    <ColumnFamily Index="Time" Name="StandardByTime2"/>
-   	    <ColumnFamily ColumnType="Super" Index="Name" Name="Super1"/>
-   	    <ColumnFamily ColumnType="Super" Index="Name" Name="Super2"/>
-      </Table>
+     <Table Name = "Table1">
+       <ColumnFamily ColumnSort="Name" Name="Standard1"/>
+       <ColumnFamily ColumnSort="Name" Name="Standard2"/>
+       <ColumnFamily ColumnSort="Time" Name="StandardByTime1"/>
+       <ColumnFamily ColumnSort="Time" Name="StandardByTime2"/>
+       <ColumnFamily ColumnType="Super" ColumnSort="Name" Name="Super1"/>
+       <ColumnFamily ColumnType="Super" ColumnSort="Name" Name="Super2"/>
+     </Table>
    </Tables>
    <Seeds>
      <!-- Add names of hosts that are deemed contact points -->

Modified: incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnFamilyStoreTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnFamilyStoreTest.java?rev=762375&r1=762374&r2=762375&view=diff
==============================================================================
--- incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnFamilyStoreTest.java (original)
+++ incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnFamilyStoreTest.java Mon Apr  6 15:10:07 2009
@@ -12,7 +12,7 @@
 import java.util.Arrays;
 import java.util.ArrayList;
 import java.util.Set;
-import java.util.concurrent.FutureTask;
+import java.util.SortedSet;
 import java.util.concurrent.Future;
 import java.util.concurrent.ExecutionException;
 
@@ -30,7 +30,7 @@
     }
 
     @Test
-    public void testMain() throws IOException, ColumnFamilyNotDefinedException, ExecutionException, InterruptedException
+    public void testNameSort() throws IOException, ColumnFamilyNotDefinedException, ExecutionException, InterruptedException
     {
         Table table = Table.open("Table1");
 
@@ -55,11 +55,61 @@
             }
         }
 
-        validateBytes(table);
+        validateNameSort(table);
+
         table.getColumnFamilyStore("Standard1").forceFlush();
         table.getColumnFamilyStore("Super1").forceFlush();
+        waitForFlush();
+        validateNameSort(table);
+    }
+
+    @Test
+    public void testTimeSort() throws IOException, ColumnFamilyNotDefinedException, ExecutionException, InterruptedException
+    {
+        Table table = Table.open("Table1");
+
+        for (int i = 900; i < 1000; ++i)
+        {
+            String key = Integer.toString(i);
+            RowMutation rm;
+            for (int j = 0; j < 8; ++j)
+            {
+                byte[] bytes = j % 2 == 0 ? bytes1 : bytes2;
+                rm = new RowMutation("Table1", key);
+                rm.add("StandardByTime1:" + "Column-" + j, bytes, j);
+                rm.apply();
+            }
+        }
+
+        validateTimeSort(table);
 
-        // wait for flush to finish
+        table.getColumnFamilyStore("StandardByTime1").forceFlush();
+        waitForFlush();
+        validateTimeSort(table);
+    }
+
+    private void validateTimeSort(Table table) throws IOException, ColumnFamilyNotDefinedException
+    {
+        for (int i = 900; i < 1000; ++i)
+        {
+            String key = Integer.toString(i);
+            for (int j = 0; j < 8; j += 3)
+            {
+                ColumnFamily cf = table.getRow(key, "StandardByTime1", j).getColumnFamilies().iterator().next();
+                SortedSet<IColumn> columns = cf.getAllColumns();
+                assert columns.size() == 8 - j;
+                int k = 7;
+                for (IColumn c : columns)
+                {
+                    assert c.timestamp() == k--;
+                }
+            }
+        }
+    }
+
+    private void waitForFlush()
+            throws InterruptedException, ExecutionException
+    {
         Future f = MemtableManager.instance().flusher_.submit(new Runnable()
         {
             public void run()
@@ -67,11 +117,9 @@
             }
         });
         f.get();
-
-        validateBytes(table);
     }
 
-    private void validateBytes(Table table)
+    private void validateNameSort(Table table)
             throws ColumnFamilyNotDefinedException, IOException
     {
         for (int i = 900; i < 1000; ++i)