Help coderanch get a
new server
by contributing to the fundraiser

Chandra shekar M

Ranch Hand
+ Follow
since Dec 20, 2006
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Chandra shekar M

the collection employees  is large and computeAndUpdate() performs costly DB operation so wanted to parallelize this part of the code, as each record is independent and doesn't depend on each others result.

The question is what is the right syntax to invoke computeAndUpdate() in parallelStream

I need something like a forloop, which can loop over the games and find the players not playing that game. Can I do this in SQL or should I write a procedure

 Please find the SQLfiddle link!9/89c76/2

How can I do this in a single query for all the games, there can be many types of games. I cant specify the games explicitly, instead, I want to write the query to fetch all the playerids who are not playing a game for each of the game some thing like this

the above query is giving only one record. I need like this

game1 | 4,5,6  
game2 | 4,6
game3 | 1,2,3,5,6
Hi Paul,
Thanks much for the help, however, I missed few more conditions. Please find the complete query

Hi Paul,
Thanks much for the help, however, I missed few more conditions. Please find the complete query

Yes, the second query I have doubt, the a.population > b.population. as I am using a.population, its not working.

Was looking on how we can rewrite the query

Was not knowing how to edit original post update with correct query


I am trying to write below query in vertica

Select *
From a
Where"India" AND
A.language ="Hindi"
AND(case when (spoken = true AND exist(
select 1 from b
where and
AND case when a.population >= b.populatiom)) then

it is not working, because we can't reference "a.population" outer query field in case expression of innerquery. I tried rewriting it wil OR caluse Vertica is not allowing it.

How can I re-write this
If two threads are locking on same object then they will block each other like on different objects they won't.

 When we shift the synchronization to method level.
 in case of 1. it will block as synchronized(this)  where this=a which is only one instance
 in 2. it will not block as this=a and this=b for two different Threads


Let consider the following use case,

it blocks on only the caller threads, if two different threads are called then they won’t get blocked, it is as good as no synchronization right ?

same thing is with built in Thread safe classes of java, hence we should not rely on them, we should handle synchronization ourselves right ?
Thanks Guys, really appreciate the help.

8 years ago

Piet Souris wrote:ah well, a little bit shuffling never hurt anybody!

A more serious problem with the method is that it is wrong.
With the corrected code:

the output is

So you should take a long enough BitSet for your 'checker'.

Corrected code is

Should fix the issue
8 years ago