Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is URAlgorithm class thread safe ? #44

Open
Normal opened this issue Jan 11, 2018 · 4 comments
Open

Is URAlgorithm class thread safe ? #44

Normal opened this issue Jan 11, 2018 · 4 comments

Comments

@Normal
Copy link

Normal commented Jan 11, 2018

I always thought that algorithm object is shared between threads in processing predict queries. Does this predict method's code valid ?

queryEventNames = query.eventNames.getOrElse(modelEventNames) // eventNames in query take precedence
    val (queryStr, blacklist) = buildQuery(ap, query, rankingFieldNames)
    val searchHitsOpt = EsClient.search(queryStr, esIndex, queryEventNames)

Is queryEventNames published properly? Isn't it a data race ?

@pferrel
Copy link
Collaborator

pferrel commented Jan 11, 2018 via email

@Normal
Copy link
Author

Normal commented Jan 11, 2018

Let me clarify the question a little bit. I'm talking about the processing of predict queries, so I assume the engine already was built, trained and deployed. That means queryEventNames was already initialized (from engine.json). So there is no any problem yet.

But inside predict method as I see, queryEventNames reassigning happens with some query data (it is a var, not a val)

// this is inside predict method
queryEventNames = query.eventNames.getOrElse(modelEventNames)

So I guess it might be a problem because predict queries processed in parallel. Isn't it ?

BTW please leave questions in https://groups.google.com/forum/#!forum/actionml-user so others can have the benefit of the answer

I will, thank you!

@pferrel
Copy link
Collaborator

pferrel commented Jan 11, 2018 via email

@Normal
Copy link
Author

Normal commented Jan 12, 2018

Now I've got it, thank you!
I was just wondering why did that was implemented that way since queryEventNames can be converted to local variable (does not used out of predict method) , I'm not going to use that feature anyway, just learning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants