We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexSuggestions & BugsWebsite,  Documentation,  Book Bugs › visualizing data :: streamer queue
Page Index Toggle Pages: 1
visualizing data :: streamer queue (Read 1922 times)
visualizing data :: streamer queue
Apr 14th, 2008, 8:46pm
 
I have to parse a BIG file (about 60000 lines)

I'd like to use the Streamer Queue tips (p274 275 of Fry's last book Visualizing Data):

Code:
public void run( ) {
try {
while (Thread.currentThread( ) == thread) {
// Continue reading until reached the max list size

// (prevents from reading too much and getting out of control).
while (list.size( ) < MAX_LIST_SIZE) {
String line = reader.readLine( );
// Exit the while( ) loop and terminates the thread
if (line == null) break;
// Add to the list in a thread-safe manner.
synchronized (list) {
list.add(line);
}
}
try {
Thread.sleep(5);
} catch (InterruptedException e) { }
}
} catch (IOException e) {
e.printStackTrace( );
}
}
Loading Text Data | 275
// Get the next line from the list.
public String nextLine( ) {
synchronized (list) {
if (list.size( ) == 0) {
return null;
}
}
String line = (String) list.remove(0);
return line;
}
}


BUT I have an error.
I may forget something?! But I exactly copy the algorithm from the book
The error is:

Code:
E:/TMP/build43451.tmp/Temporary_3672_8371.java:133:38:138:14: Syntax Error: misplaced construct(s)


E:/TMP/build43451.tmp/Temporary_3672_8371.java:149:1:149:20: Syntax Error: ") Block" inserted to complete BlockStatements


E:/TMP/build43451.tmp/Temporary_3672_8371.java:153:17:153:20: Syntax Error: @ expected instead of this token


E:/TMP/build43451.tmp/Temporary_3672_8371.java:153:27:153:32: Syntax Error: instanceof expected after this token


E:/TMP/build43451.tmp/Temporary_3672_8371.java:153:42:153:42: Syntax Error: @ expected instead of this token


E:/TMP/build43451.tmp/Temporary_3672_8371.java:153:42:153:98: Syntax Error: ")" inserted to complete SingleMemberAnnotation


E:/TMP/build43451.tmp/Temporary_3672_8371.java:153:3:153:98: Syntax Error: "@ interface Identifier AnnotationTypeBody" inserted to complete TypeDeclaration


E:/TMP/build43451.tmp/Temporary_3672_8371.java:2:1:2:5: Semantic Error: Type "Table" was not found.


E:/TMP/build43451.tmp/Temporary_3672_8371.java:5:1:5:5: Semantic Error: Type "Table" was not found.


E:/TMP/build43451.tmp/Temporary_3672_8371.java:6:1:6:5: Semantic Error: Type "Table" was not found.



Someone can help me??

Ciao!
Re: visualizing data :: streamer queue
Reply #1 - Apr 14th, 2008, 10:29pm
 
if the line " Loading Text Data | 275 " is in your code the way you have it pasted here, then that's gonna give you strange compile errors like you're seeing.

there's also a problem with using "synchronized" in some cases:
http://dev.processing.org/bugs/show_bug.cgi?id=136

easiest fix is to give the tab a .java ending (which will keep the preprocessor from having trouble with the synchronized command).

(you can also use eclipse, the way it's used in that chapter/example, which won't have the preprocessor problem either)
Re: visualizing data :: streamer queue
Reply #2 - Apr 14th, 2008, 10:32pm
 
Unfortunately I don't think Processing plays nicely with the synchronised command. If you remove your synchronized lines, it should build properly.
Re: visualizing data :: streamer queue
Reply #3 - Apr 15th, 2008, 10:09am
 
fry wrote on Apr 14th, 2008, 10:29pm:
if the line " Loading Text Data | 275 " is in your code the way you have it pasted here, then that's gonna give you strange compile errors like you're seeing.

there's also a problem with using "synchronized" in some cases:
http://dev.processing.org/bugs/show_bug.cgi?id=136

easiest fix is to give the tab a .java ending (which will keep the preprocessor from having trouble with the synchronized command).

(you can also use eclipse, the way it's used in that chapter/example, which won't have the preprocessor problem either)


I'm ashamed.. I just copy/paste the code... Of course, in my code there wasn't this line Wink

ok for "synchronized" bugs..
I'll check it tonight!
thanks Ben and the others..

I'd have another question: my file contains more than 65536 lines. Of course it cannot be opened with excel, but with notepad etc.
Can it be a problem with processing I guess, it cannot..
Re: visualizing data :: streamer queue
Reply #4 - Apr 15th, 2008, 2:58pm
 
yeah, processing doesn't have any sort of limitation like the 64k lines the way that excel does.. that's left over from the fact that the file format uses two bytes to store the number of rows, and that having made that assumption early on, moving past that limit would require a major rewrite of excel. (the general idea is also that if you have more than 64k lines that you should be using a database.. though i don't personally agree with that)
Re: visualizing data :: streamer queue
Reply #5 - Apr 15th, 2008, 3:23pm
 
I won't use a database for this project.
Full text.
Indeed, I think about the close future where my project could be more dynamic: I have to avoid pre-processing of the "raw" data.

thanks again!
i could post that when it will be finished!
Page Index Toggle Pages: 1