1 | #include "skip_days.h" |
---|---|
2 | #include "date.h" |
3 | #include "constants.h" |
4 | #include "scaling.h" |
5 | #include "parallel.h" |
6 | |
7 | ds_key_t skipDays(int nTable, ds_key_t *pRemainder) { |
8 | static int bInit = 0; |
9 | static date_t BaseDate; |
10 | ds_key_t jDate; |
11 | ds_key_t kRowCount, kFirstRow, kDayCount, index = 1; |
12 | |
13 | if (!bInit) { |
14 | strtodt(&BaseDate, DATA_START_DATE); |
15 | bInit = 1; |
16 | *pRemainder = 0; |
17 | } |
18 | |
19 | // set initial conditions |
20 | jDate = BaseDate.julian; |
21 | *pRemainder = dateScaling(nTable, jDate) + index; |
22 | |
23 | // now check to see if we need to move to the |
24 | // the next piece of a parallel build |
25 | // move forward one day at a time |
26 | split_work(nTable, &kFirstRow, &kRowCount); |
27 | while (index < kFirstRow) { |
28 | kDayCount = dateScaling(nTable, jDate); |
29 | index += kDayCount; |
30 | jDate += 1; |
31 | *pRemainder = index; |
32 | } |
33 | if (index > kFirstRow) { |
34 | jDate -= 1; |
35 | } |
36 | return (jDate); |
37 | } |
38 |