Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
allow SuperColumn.getSubColumn to return null. patch by Sandeep Tata;…
Browse files Browse the repository at this point in the history
… reviewed by jbellis for #91
  • Loading branch information
Jonathan Ellis committed Apr 21, 2009
1 parent 0155291 commit 0121734
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/org/apache/cassandra/db/SuperColumn.java
Expand Up @@ -80,7 +80,7 @@ public Collection<IColumn> getSubColumns()
public IColumn getSubColumn(String columnName)
{
IColumn column = columns_.get(columnName);
assert column instanceof Column;
assert column == null || column instanceof Column;
return column;
}

Expand Down Expand Up @@ -169,7 +169,6 @@ public byte[] value()
public byte[] value(String key)
{
IColumn column = columns_.get(key);
assert column instanceof Column;
if ( column != null )
return column.value();
throw new IllegalArgumentException("Value was requested for a column that does not exist.");
Expand Down
17 changes: 17 additions & 0 deletions test/org/apache/cassandra/db/SuperColumnTest.java
@@ -0,0 +1,17 @@
package org.apache.cassandra.db;

import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;

import org.testng.annotations.Test;
public class SuperColumnTest
{
@Test
public void testMissingSubcolumn() {
byte[] val = "sample value".getBytes();
SuperColumn sc = new SuperColumn("sc1");
sc.addColumn("col1", new Column("col1",val,1L));
assertNotNull(sc.getSubColumn("col1"));
assertNull(sc.getSubColumn("col2"));
}
}

0 comments on commit 0121734

Please sign in to comment.