write get_columns_since test to exercise sequenceFile.next(timeRange). patch by jbellis; reviewed by Jun Rau. see #52

git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/trunk@762375 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonathan Ellis 2009-04-06 15:10:07 +00:00
parent b61cbd37e8
commit 9cdc839ee8
3 changed files with 71 additions and 23 deletions

View File

@ -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 -->

View File

@ -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 -->

View File

@ -12,7 +12,7 @@ import java.util.Random;
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 @@ public class ColumnFamilyStoreTest extends ServerTest
}
@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 @@ public class ColumnFamilyStoreTest extends ServerTest
}
}
validateBytes(table);
validateNameSort(table);
table.getColumnFamilyStore("Standard1").forceFlush();
table.getColumnFamilyStore("Super1").forceFlush();
waitForFlush();
validateNameSort(table);
}
// wait for flush to finish
@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);
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 @@ public class ColumnFamilyStoreTest extends ServerTest
}
});
f.get();
validateBytes(table);
}
private void validateBytes(Table table)
private void validateNameSort(Table table)
throws ColumnFamilyNotDefinedException, IOException
{
for (int i = 900; i < 1000; ++i)