0

I have a list of objects with list size of 500K. Each object in the list have a unique identifier. I want to validate the list for any duplicate objects(having the same identifier) and mark them with a flag. Since there are lot of elements in the list, the processing takes quite long time and i am not able to achieve within allotted time frame.

Is there any way to process the list in parallel(Using java Future/Callable)?

Thanks in advance. Mayuran

10
  • 1
    If identifier is the only criteria for 2 objects being equal, then why don't you override equals() and hashCode() and use a Set ? Commented Oct 14, 2014 at 5:58
  • 1
    Take a look at Java8 parallel streams. Commented Oct 14, 2014 at 5:59
  • Divide the chunk into smaller pieces and process it Commented Oct 14, 2014 at 6:00
  • How do you process the list right now? Post relevant code! Commented Oct 14, 2014 at 6:01
  • 1
    @subhrajyoti Majumder, If i divide the list, how can i check for duplicate? The duplicate object may be in the another divided list Commented Oct 14, 2014 at 6:03

1 Answer 1

3

I don't know what your definition of a long time is, but 500K object is not a lot. Most likely your algorithm is quite inefficient. Rather than relying on parallelisation (how would you parallelise this anyway?), consider using a better data structure/algorithm for this.

HashMap or HashSet should work quite well for this.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, but each object has to go through lot of validation scenarios. So validation for each object takes some time. So that i want to process in parallel
@Mayuran: That's not what your questions says. You might want to work on improving the clarity of the question then.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.