Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Apache Cassandra and BIRT
Apache Cassandra and BIRT [message #806127] Fri, 24 February 2012 15:19 Go to next message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 817
Registered: July 2009
Senior Member
Cassandra is a NoSQL database used by Twitter and many other high data applications. Even though Cassandra is NoSQL, there is a SQL alike language (CQL) and even a JDBC wrapper for CQL (http://code.google.com/a/apache-extras.org/p/cassandra-jdbc/). Using these two techniques I'm able to access Cassandra from Java as if it were a RDBMS:

public class CassandraJdbcTrial
{
static public void main (String[] args) throws ClassNotFoundException, SQLException
{
Class.forName("org.apache.cassandra.cql.jdbc.CassandraDriver");
Connection con = DriverManager.getConnection("jdbc:cassandra://localhost:9160/M2A");

String query = "SELECT * from InstanceLicense";

Statement stmt = con.createStatement();
ResultSet result = stmt.executeQuery(query);

while (result.next())
{
for (int i = 1; i <= result.getMetaData().getColumnCount(); i++)
{
System.out.println( result.getMetaData().getColumnName(i) + "=" + result.getString(i) );
}
System.out.println("-----");
}
}
}

This results in the output below:

KEY=L0000001_n1234_20120221_32
javaxdiff=java.nio.HeapByteBuffer[pos=114832 lim=115193 cap=116325]
-----
KEY=L0000001_n1234_20120217_1599670502
javaxdiff=java.nio.HeapByteBuffer[pos=115341 lim=115703 cap=116325]
-----
....


If I set this JDBC driver up in BIRT, the "test connection" on the Data Source works fine. I can also create a Data Set, but there are no output columns. Also if I just do a "select KEY from InstanceLicense". What is the JDBC driver not doing right?

Tom
Re: Apache Cassandra and BIRT [message #806380 is a reply to message #806127] Fri, 24 February 2012 22:40 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 817
Registered: July 2009
Senior Member
> If I set this JDBC driver up in BIRT, the "test connection" on the Data Source works fine. I can also create a Data Set, but there are no output columns. Also if I just do a "select KEY from InstanceLicense". What is the JDBC driver not doing right?

After doing some research; is BIRT accessing the resultset's metadata before fetching the first row? Cassandra has no database schedule, so it must derive the meta data from the actual values.
Re: Apache Cassandra and BIRT [message #808482 is a reply to message #806380] Mon, 27 February 2012 20:45 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

That is most likely the issue. The JDBC driver needs to support meta
data. Another option would be to just use a scripted data source and
call it like you were calling any external Java class.

Jason

On 2/24/2012 5:40 PM, tbee wrote:
>> If I set this JDBC driver up in BIRT, the "test connection" on the
>> Data Source works fine. I can also create a Data Set, but there are no
>> output columns. Also if I just do a "select KEY from InstanceLicense".
>> What is the JDBC driver not doing right?
>
> After doing some research; is BIRT accessing the resultset's metadata
> before fetching the first row? Cassandra has no database schedule, so it
> must derive the meta data from the actual values.
>
Re: Apache Cassandra and BIRT [message #808921 is a reply to message #808482] Tue, 28 February 2012 09:39 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 817
Registered: July 2009
Senior Member
I've patched Cassandra's JDBC driver to do a read ahead when getMetadata is done before the first row of data is read. The problem with Cassandra is that it does not have a database schema, only collections of key-value pairs, and therefore each row may have different contents.

In real life use this turns out not to be such a big issue, since one usually writes the same values in each row, but it does require a row to be fetched in order to determine what columns are available.

Patched. Thanks!

Tom
Re: Apache Cassandra and BIRT [message #809420 is a reply to message #808921] Tue, 28 February 2012 21:24 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Did you get this to work? If so I would love to see a blog post on it.

Jason

On 2/28/2012 4:39 AM, tbee wrote:
> I've patched Cassandra's JDBC driver to do a read ahead when getMetadata
> is done before the first row of data is read. The problem with Cassandra
> is that it does not have a database schema, only collections of
> key-value pairs, and therefore each row may have different contents.
>
> In real life use this turns out not to be such a big issue, since one
> usually writes the same values in each row, but it does require a row to
> be fetched in order to determine what columns are available.
>
> Patched. Thanks!
>
> Tom
Previous Topic:Parameter Display Value
Next Topic:Error message "Path must include project and resource name"
Goto Forum:
  


Current Time: Mon Dec 06 21:46:44 GMT 2021

Powered by FUDForum. Page generated in 0.02639 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top