Stop Indexing Task

9 views
Skip to first unread message

Michael Ruepp

unread,
Jul 18, 2015, 11:18:28 AM7/18/15
to semanti...@googlegroups.com
Hi,

I know this is not exactly a SV issue, but I am quite stuck:

I call the SV Methods from a Swingworker task by submitting a progressbar class with a cancel button method as arguments and call the indexing stuff like:

      try {
            BuildIndex.main(args);
        } catch (IOException e) {
            e.printStackTrace();
        }

from doinbackground, while composing the args together by myself as String[] because I do not want to reimplement the whole thing by myself a second time.


Usually I run some kind of loop out of my swingworker method where I am able to break if progressbar.isCanceled is true.

But due the nature of the heavy stuff is encapsulated in the SV classes, how would I be able to stop the thread without implementing the whole foo-bar by myself and hook up if - break statements in the loops?

I am completely stuck,

thanks for input,

Michael

Michael Ruepp

unread,
Jul 21, 2015, 4:03:15 AM7/21/15
to semanti...@googlegroups.com
Hi Dominic,

i am a litte stuck. Is there any way to easily implement some kind of cancel to indexing? I search the code for break or return points in the loops and it seems as the heavy work is buried deep in the Classes like TermVectorsFromLucene, or VectorStoreWriter etc.

Any input?

Thanks!

Dominic Widdows

unread,
Jul 21, 2015, 10:44:00 AM7/21/15
to semanti...@googlegroups.com
Hi Michael,

This isn't something I'm knowledgeable about - I've coded up a couple of things in Swing but with very little multithreading, so I don't know to design a class to work in a way that supports pausing, cancelling, etc. If you can explain the requirements in simple terms I might be able to help, but I can't promise anything.

Best wishes,
Dominic

--
You received this message because you are subscribed to the Google Groups "Semantic Vectors" group.
To unsubscribe from this group and stop receiving emails from it, send an email to semanticvecto...@googlegroups.com.
To post to this group, send email to semanti...@googlegroups.com.
Visit this group at http://groups.google.com/group/semanticvectors.
For more options, visit https://groups.google.com/d/optout.

Michael Ruepp

unread,
Jul 22, 2015, 7:54:30 AM7/22/15
to Semantic Vectors
Hi,

I have a Dialog Field Object with a Progressbar and a Cancel Button with a method iscanceled, and when this method is true (e.g. when the cancel button is pressed, it returns true) I would like to break a loop.

So I have three options:

1. I create all three classes (create buildIndex, LSA and buildPositionalIndex) by myself as methods in my parser class (including the depending methods like Vectorwriters and stuff and break the loops conditionally somewhere when the Index Process does its heavy duty work, but I know not exactly where this is, or I @Overwrite your classes but am not exactly sure how to do this.

2. There is some way to kill a swingworker thread without this whole stuff beeing implemented a second time...by interrupting which is task.cancel(), but so far this did not work for me.

3. Somewhere in your class I can call a method to kill the process (like maybe Vectorwriter.stop(), (buildIndex.stop() or LSA.stop()) which calls an internal variable in SV classes which is regularly queried in the docindexing loops of the SV classes and triggers a sane closing of the operation without corrupting vectorfiles or something which would be very handy!

if 1 is true, then it is a lot of work. But there must be examples to kill such a heavyweight process without killing the whole Application, did you never had this problem programatically?

I mean, If i use the jar file directly, I can always use ctrl-c but this means killing the process completely.

I would prefer option 3 to stay cleanly at the provided API´s instead of creating the stuff again (which is the buildIndex, LSA and buildPositionalIndex classes, but only with an option to stop the indexing).

Thanks a lot for your effort,

Michael

Dominic Widdows

unread,
Jul 22, 2015, 12:31:15 PM7/22/15
to semanti...@googlegroups.com
Hi Michael,

Option 3 sounds like the most disruptive to the codebase, so while you're welcome to try this in a forked copy, I don't want to complicate the main package to support these operations, since stopping and resuming a batch-mode indexing process is a pretty rare use-case.

Related to option 2 - have you tried creating just a regular java thread object (https://docs.oracle.com/javase/8/docs/api/java/lang/Thread.html) and running the indexing in that? Is there any reason why it has to be a swingworker, and is the threading model any different?

Using the operating system sounds a bit clumsy and it doesn't seem to work for me - CTRL-z stops the indexing process, it doesn't pause it in a way that I can resume.

Best wishes,
Dominic
Reply all
Reply to author
Forward
0 new messages