I'm uploading data to a web-service by iterating through a precompiled local database of about 150000 images with metadata. To prevent node from throwing Error: EMFILE, too many open files
, I'm batching the upload into small tasks of about 5000 images at a time.
To achieve this, I've written a script that accepts an upper and lower bounds:
node upload.js bot_bound top_bound;
In the code, there is a comparator that looks like this:
for(i in parsed_data){
if(i >= bot_bound && i < top_bound){
//...process the data
}
}
it's the (i >= bot_bound && i < top_bound)
that's really giving me trouble. It's behaving ...weird. For the first few batches, with bounds below like 40000, it was skipping over certain values. As I tried higher and higher batches, it skipped over more values until it skipped over all of them. by the time my bounding range was [95000, 100000)
it was returning false for all values.
So, to troubleshoot, I've been throwing this log line in there:
(${i} > ${bot_range}) && (${i} < ${top_range}) :: ${(i >= bot_range && i< top_range)}
It outputs this at runtime:
...
(94999 >= 95000) && (94999 < 100000) :: false
(95000 >= 95000) && (95000 < 100000) :: false
(95001 >= 95000) && (95001 < 100000) :: false
(95002 >= 95000) && (95002 < 100000) :: false
(95003 >= 95000) && (95003 < 100000) :: false
...
However, when I enter a repl, it works as expected:
> var bot_range = 95000
undefined
> var top_range = 100000
undefined
> var i = 95001
undefined
> `(${i} > ${bot_range}) && (${i} < ${top_range}) :: ${(i >= bot_range && i< top_range)}`
'(95001 > 95000) && (95001 < 100000) :: true'
So, what's going on here? I'm stumped.