error when running the running query example

32 views
Skip to first unread message

AmaliaP

unread,
Jan 8, 2007, 2:37:29 AM1/8/07
to streamcruncher
hi
I just discovered your software and I try to intergrate it in some
application..now I learn how to use it so please understand I have
newbie questions.
I wrote the following code:


package streamCruncherTest;

import streamcruncher.api.QueryConfig;
import streamcruncher.api.QueryConfig.QuerySchedulePolicy;
import streamcruncher.api.StreamCruncher;

import streamcruncher.api.artifact.IndexSpec;
import streamcruncher.api.artifact.MiscSpec;
import streamcruncher.api.artifact.RowSpec;
import streamcruncher.api.artifact.TableSpec;
import streamcruncher.api.artifact.TableFQN;

import streamcruncher.api.ParsedQuery;
import streamcruncher.api.ParserParameters;

import java.sql.Connection;


public class StreamCruncherMain
{
/**
* @param args
*/
public static void main(String[] args)
{
StreamCruncher cruncher = new StreamCruncher();

try
{

cruncher.start("D:\\work\\streamCruncher\\work\\config\\sc_config_mysql.properties");

//events registration

//1.establish column names
String[] columnNames = { "country", "state",
"city", "item_sku",
"item_qty", "order_time", "order_id" };
//2. establish column types
String[] columnTypes = { "varchar(15)",
"varchar(15)",
"varchar(15)", "varchar(15)", "int", "timestamp", "bigint not null" };

//3. column set definition
//RowSpec = the column-set definition of the
Table of an
Input/Output Event Stream
//0 - position of index column
//1 - position of timestamp column
RowSpec rowSpec = new RowSpec(columnNames,
columnTypes, 0, 1);

//4. index definition
//IndexSpec = a definition of an Index on one or
more columns of an
Input or Output Event Stream
IndexSpec indexSpec = cruncher.createIndexSpec(null,
"test_idx", "test", true, "order_id",
true);

//5. table definition - TableSpec needs index
and
column names and types - in the definition
//createTableSpec - used to create Event Stream
definitions
TableSpec tableSpec = cruncher.createTableSpec(null,
"test",
rowSpec,
new IndexSpec[] { indexSpec }, new MiscSpec[]
{});

//register the table in stream
//cruncher.registerInStream(tableSpec, true);
if (cruncher.getInStreamTableSpec(null, "test") == null)
{
System.out.println("nu exista - deci se mai
inregistreaza o
data");
cruncher.registerInStream(tableSpec, true);
}
else
{
System.out.println("exista - deci nu se mai
inregistreaza");
}


//running query..
//query is established between start() and stop()
methods of
the cruncher
//and after the Event Input Stream registration
//operations for the Output Stream

//String[] columnNames = { "country", "state", "city",
"item_sku", "item_qty", "order_time", "order_id" };
String rql = "select country, state, city, item_sku,
item_qty,
order_time, order_id " +
" from test";/* (partition by item_sku
store last 5 seconds
max 5) as testStr " +
" where testStr.$row_status is not
dead";*/


//FQO = Fully-Qualified-Name

TableFQN tableFQN = new TableFQN("test_res");

String queryName = "test_res_rql";

ParserParameters parameters = new ParserParameters();
parameters.setQuery(rql);
parameters.setQueryName(queryName);
parameters.setResultColumnNames(columnNames);

parameters.setResultColumnTypes(columnTypes);
parameters.setResultTableFQN(tableFQN);

//the query has to be parsed by sc kernel first
ParsedQuery parsedQuery =
cruncher.parseQuery(parameters);

//register the parsed query
QueryConfig config = parsedQuery.getQueryConfig();
config.setQuerySchedulePolicy(new
QueryConfig.QuerySchedulePolicyValue(
QuerySchedulePolicy.ATLEAST_OR_SOONER,

5000));

//Registers the Query that was parsed using
parseQuery(ParserParameters).
//The Query execution will start after this registration
(based on the configurations provided using the QueryConfig).
cruncher.registerQuery(parsedQuery);

//results of the query will be found in table FQN ;
kernel
automatically generates an idColumns
//get the id
String idColumnName =
cruncher.getResultTableIdColumnName(queryName);
System.out.println("Name of the idColumn generated by
the
kernel on Output Stream: " + idColumnName);
}

catch(Exception ex)
{
System.out.println(ex.getMessage());
ex.printStackTrace(System.out);
}
finally
{
try
{
cruncher.stop();
System.out.println("crunch stops");
}
catch(Exception ex)
{
ex.printStackTrace(System.out);
}
}

System.out.println("ready!");
}
}


I get the exception :
Exception in thread "main" java.lang.NoClassDefFoundError:
antlr/RecognitionException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown
Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.getConstructor(Unknown Source)
at
streamcruncher.api.StreamCruncher.parseQuery(StreamCruncher.java:284)
at
streamCruncherTest.StreamCruncherMain.main(StreamCruncherMain.java:127)


That is the line where the kernel parse the query..(line: ParsedQuery
parsedQuery = cruncher.parseQuery(parameters);) What do I do wrong?


Thank you very much

PS: I use MySQL so the example (variables types) should work :(((

Ashwin

unread,
Jan 16, 2007, 7:43:12 AM1/16/07
to streamcruncher
Hi Amalia, I've already answered this question in a previous post :-).
You have to add all the JAR files in the "lib" provided in
StreamCruncher folder to your program's Classpath.

AmaliaP

unread,
Jan 18, 2007, 3:20:00 AM1/18/07
to streamcruncher
I added all libs provided - and finally (after I read some test units I
downloaded with SC) I saw I have to put ";" at the end of the query..so
the running query sent to the kernel to be parsed needs to have ";" in
the end...is it correct?

Ashwin

unread,
Jan 19, 2007, 7:33:50 AM1/19/07
to streamcruncher
Yes, that's right.

Reply all
Reply to author
Forward
0 new messages