Antriksh
BAN USERI write dumb programs to solve complex problems
For loop will be blocked at each sumOfFile call, where it could have been processed in parallel. So that the next file can be processed without waiting for the sumOfFile call to complete for the current file.
Instead of holding the entire file in the memory, read the file in segments and simultaneously do the summation till you meet the end.
Once you're out of threads in thread pool, the processing of the remaining files will wait till someone gets free to pick up the next file.
One one of the simple approach I could think of is
def main(args: Array[String]): Unit = {
val length = intSeq.length
val n = length / 4
var counter = 0
val memory = scala.collection.mutable.HashSet[Int]()
while (counter < length - n + 1) {
val current = intSeq(counter)
if (current == intSeq(counter + n - 1)) {
if (!memory.contains(current)) {
println(current)
memory.add(current)
} else counter = counter + 1
counter = counter + n - 1
} else counter = counter + 1
}
}
Repjuliaaperez05, Cloud Support Associate at ABC TECH SUPPORT
I Performed extensive web research to collect pertinent data and gather images related to the assigned articleIts act of writing ...
Even better suggestion mechanism would be to,
1. tag each movie with multiple attributes such as Genre, Actor, Actress, Director, Release Year, Language and anything that you can think of.
2. Maintain a nested map data structure where we can push the number of movies watched by the user for the given key, here key will be these attributes. This map will have one more nested map.
3. Based on the top entries search for the movie database for similar movies.
So for ex. If a person has a Map Profile that looks something like
Then filter movies based on Actor IN ('Leo', 'Tom') Actresses IN ('Scarlett', 'Monica') AND Genere IN ('Action') and so on.
- Antriksh March 25, 2017And suggest movie based on the result.
Result can even be more optimized by applying another set of filters on top of this result where a record satisfying more than one entries will be at the top.
Going a step ahead, maintain a user graph with each edge having some weight value. two user with larger intersection between their profile graph can have higher edge weight.
Fetch the movie seen by such adjacent user, filter the movies seen by the neighbor user but not by the current one and add it to our suggestion list.