Inside the Engine: A Code-Level Look at ExSan CODE’s Processing Clusters

ExSan

c++ |ExSan| ++ ↄ

Simply Raw Pointers

iX     ilinkedIn         exsan.plusplus@gmail.com   Sat Apr 19 10:17:38 2025         x: R.J.Y      JOB: xsnPtfli_1738xsnPtfli

OUTPUT        Clusterig      The Code itself

      1    //-------------at the end of the data capture --here clustering-------//

      2    frameClk[1] = pt::microsec_clock::local_time();

      3    ++frameCounterDatum;  //every time a datum into new db? it could be where data is captured¡¡¡¡???? 

      4    for (i = 1; i <= net->get_rows_in_page(ppDataIn, 'f'); i++) { aryStockAux[i]  = 0; }  //those complete records

      5    if (loadNtimeLapse &&  frameClk[1] - frameClk[0] > xClkFrame && frameCounterDatum) { //cluster

      6       isTimeLapseOver = false;      // reset to start a new time lapse            

      7       

      9       counter = 0;   // counts  the clusters that have valid input

     10       unsigned short kth(0);

     11       double spreadCenter(0);                        

     12       /* Dummy Block

     13       net->boundaries(net, ppDataIn, 'f', 1, arySAPrevious, pfR, plR); 

     14       cout << "\n\t\t:2083: BEGINS aryStockPREVIOUS firstRow: " <<   pfR << "  lastRow: " <<  plR << "\t";

     15       if (!pfR) { fout.flush() << "\t\tNo Previous";  pfR = ++plR;  }    //*to avoid nex for*  to print only once          

     16       else { fout.flush() << "\tThere is a Previous AryStock "; }

     17       for (i = pfR; i <= plR; ++i) {               

     18          cout << "  "  << i  << ":->"  << arySAPrevious[i];   

     19       }               

     20       //*/            

     21       //make a copy of the current and active stocks

     22       for (i = 1; i <= net->get_rows_in_page(ppDataIn, 'f'); ++i) {

     23          aryStActPrev[i] = 0;

     24          if(aryStockActive[i])aryStActPrev[i] = 1;

     25          if (arySAPrevious[i])aryStActPrev[i] = 1;               

     26       }

     27       

     28       net->boundaries(net, ppDataIn, 'f', 1, aryStockActive, firstRow, lastRow);    

     29       

     30       if(firstRow) stockPtr = net->goto_row(net, ppDataIn, firstRow, 'f');  // point at the beggining                        

     31       

     32       unsigned short counToPortfolio(0);

     33       counter = countElementInAry(aryStockActive, true, firstRow, lastRow); //initial counter all are assumed as valid inputs

     35           << "\t\tAryCurrent->\t";    for (i = 1; i <= lastRow; ++i) { fout.flush() << aryStockActive[i]; if (!(i % 5)) cout << " "

     36       if (!counter) {   fout.flush() << "\n\t\t:2101:*> counter = zero Force to clear db ";

     37          ++counter; //fake value

     38          firstRow = 1;

     39          lastRow = net->get_rows_in_page(ppDataIn, 'f');

     40          stockPtr = net->goto_row(net, ppDataIn, firstRow, 'f');  // point at the beggining      

     41          cout  << "  fake counter:  " << counter << "\tfirstRow: " << firstRow << "\tlastRow: " << lastRow;

     42       }

     43       //--------------------------------------------------------------------------------------------------------     //stPtr

     45          if (counter < minDB) {//fout.flush() << "\n\t\t:2110: counter < minDB";

     46             for (i = firstRow; i <= lastRow; ++i) {//first/last from aryStockActive

     47                if (!aryStockActive[i]) { stockPtr = stockPtr->get_down_ptr(); continue; }

     48                

     49                stockPtr->get_ptrLasTick()->reset_ntCounter();//only resest data in cluster remains, previus was last input               

     50                

     51                if (loadNtimeLapse == 1) {

     52                   stockPtr->get_ptrLasTick()->set_bool(pp_bool, false); // next cluster is set not active

     53                   stockPtr->get_ptrLasTick()->Discard_nt_Tree(stockPtr->get_ptrLasTick(), stockPtr->get_ptrLasTick()->get_ntHead

     54                }

     55                else {                        

     56                   stockPtr->get_ptrLasTick()->set_ushort(pp_key_index, 0); 

     57                   stockPtr->get_ptrLasTick()->set_bool(pp_bool, true);  //before populating make it available                        

     58                

     59                }

     60                aryStockActive[i] = 0;  

     61                stockPtr = stockPtr->get_down_ptr();

     62             }

     63          }

     64          else {//fout.flush() << "\n\t\t:2127:*> *0.1* Error Halt Initial Stage Enough Active Stocks " ;

     65             for (i = firstRow; i <= lastRow; ++i) {// //first/last from aryStockActive

     66                if (!aryStockActive[i]) { stockPtr = stockPtr->get_down_ptr(); continue; }

     67                //check if cluster representative value is valid

     68                if (loadNtimeLapse == 1) {

     69                   ptrAry[0] = stockPtr->get_backward_ptr();  //auxiliar tree

     70                   ptr = stockPtr->get_ptrLasTick();  //ptr to the current cluster                              

     71                   ndptrAry[0] = ndptrAry[1] = ptrAry[0]->get_ntHead();

     72                   while (ndptrAry[0]->get_nt_left_ptr())  ndptrAry[0] = ndptrAry[0]->get_nt_left_ptr(); //find min

     73                   while (ndptrAry[1]->get_nt_right_ptr()) ndptrAry[1] = ndptrAry[1]->get_nt_right_ptr(); //find mx                  

     74                   kth = 0;

     75                   spreadCenter = 0;                  

     76                   spreadCenter = (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_data(ppnt_data)) / 2.;                  

     77                   if (ptr->get_ntCounter() % 2) { //cout << "\n\t\t\t:2151:*> ODD ntCounter:-> " << ptr->get_ntCounter(); //impa

     78                      kth = 1 + ptr->get_ntCounter() / 2;  //cout << "\tkth: " << kth;

     79                      ndptrAry[0] = net->InOrderFindKth_nt(net, stockPtr->get_backward_ptr()->get_ntHead(), kth);  //OK  auxilia

     80                      //ndptrAry[0] = net->InOrderFindKey_nt(net, ptr->get_ntHead(), kth);  ///NO                      

     81                      ptr->set_data(ppDataIn, ndptrAry[0]->get_nt_data(ppnt_data));                     

     82                   }

     83                   else { 

     84                      unsigned short kth = ptr->get_ntCounter() / 2;  //left

     85                      ndptrAry[0] = net->InOrderFindKth_nt(net, stockPtr->get_backward_ptr()->get_ntHead(), kth);   //OK      

     86                      kth = 1 + ptr->get_ntCounter() / 2; // right

     87                      ndptrAry[1] = net->InOrderFindKth_nt(net, stockPtr->get_backward_ptr()->get_ntHead(), kth);

     88                      

     89                      ptr->set_data(ppDataIn, (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_data(ppnt_data)) / 2.);

     91                      

     92                   }

     93                   //auxiliar ntTree

     94                   stockPtr->get_backward_ptr()->Discard_nt_Tree(stockPtr->get_backward_ptr(), stockPtr->get_backward_ptr()->get_

     95                   if (stockPtr->get_backward_ptr()->get_ntHead())  cout << "\n\t\t:2173: Errror head of auxiliar Cluster not nil

     96                   if (checkThisRow == ptr->get_row())   

     98                }

     99                else {cout << "\n\t\t:2180: New Version - ntNodes Not Deleted" ;                                             

     100                   // much more simpler instruction from is omited                     

    101                   ndptrAry[0] = ndptrAry[1] = nullptr;  // ! both initialized in null                     

    103                   

    104                   spreadCenter = (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_data(ppnt_data)) / 2.;

    105 

    106                   if ((unsigned short)ptr->get_ushort(pp_key_index) % 2) {

    108                      ptr->set_data(ppDataIn, ndptrAry[0]->get_nt_data(ppnt_data));

    109                      ptr->set_data(ppTime, ndptrAry[0]->get_nt_data(ppnt_time));   ///very important

    110                   }

    111                   else {cout << "\n\t:2191: EVEN key_index:-> " << setprecision(0) << ptr->get_ushort(pp_key_index); // impar                     

    112                      ptr->get_ntHead()->rangeKeyFindPair_nt(ptr->get_ntHead(), ndptrAry[0], ndptrAry[1], 

    113                      static_cast(aryUS_nt::key), 

    114                      ptr->get_ushort(pp_key_index) / 2, 1 + ptr->get_ushort(pp_key_index) / 2);

    115                      ptr->set_data(ppDataIn, (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_data(ppnt_data)) / 2.);

    117                   }

    118                }

    119 

    122                   /* Dummy block  ok

    126                   ptr1 = net->go_to(net, ptr->get_row(), 1);

    127                   for (unsigned short i = 1; i <= net->get_cols_in_page(ppDataIn, 'f'); i++) {

    128                      cout << ptr1->get_bool(pp_bool);

    129                      ptr1 = ptr1->get_next_ptr();

    130                   }

    131                   //*/

    132                   --counter;   // because of the discarded value

    135                      //for (i = pfR; i <= plR; ++i) {//error  check for 1 and 2 they are different, take out of this loop

    136                      firstRowPtr = net->goto_row(net, ppDataIn, 1, 'f');  // point at the beggining                     

    137                      for (i = 1; i <= net->get_rows_in_page(ppDataIn, 'f'); ++i) {

    138                         if (!aryStockActive[i] && !arySAPrevious[i]) { firstRowPtr = firstRowPtr->get_down_ptr(); continue; }

    142                         ptr = firstRowPtr->get_forward_ptr();  //traverse the whole record

    143                         for (j = 1; j <= net->get_cols_in_page(ppDataIn, 'f'); ++j) {//traverse record                  

    144                            if (ptr->get_ntHead()) {

    145                               fout.flush() << " " << ptr->get_col();

    146                               ptr->reset_ntCounter();//only resest data in cluster remains, previus was last input                           

    147                               if (loadNtimeLapse == 1) {

    148                                  //firstRowPtr->get_ptrLasTick()->set_bool(pp_bool, false); // next cluster is set not acti

    149                                  ptr->set_bool(pp_bool, false); // next cluster is set not active                                 

    150                                  ptr->Discard_nt_Tree(firstRowPtr->get_ptrLasTick(), firstRowPtr->get_ptrLasTick()->get_ntH

    151                               }

    152                               else {

    153                                  //rowPtr->set_status(1, true); //   index 0 used index 1 to flag this stock activity

    154                                  //firstRowPtr->get_ptrLasTick()->set_ushort(pp_key_index, 0); 

    155                                  // key_index keeps track of the total of ntNOdes every node has a sequential key, waste, u

    157                                  //firstRowPtr->get_ptrLasTick()->set_bool(pp_bool, true);  //before populating make it ava

    158                                  ptr->set_bool(pp_bool, true);  //before populating make it available                                                         

    159                               }

    160                            }

    161                            ptr = ptr->get_next_ptr();

    162 

    163                         }                              

    164                         arySAPrevious[i] = aryStockActive[i] = 0; // ok both ary are reset  previous + current            

    165                         firstRowPtr->tickInPoinTo(firstRowPtr->get_forward_ptr()); //  ok re-start from the beginning of the r

    166                         firstRowPtr = firstRowPtr->get_down_ptr();

    167                      }

    168                      i = lastRow + 1; // no need to browse the whole set of active Stocks, reset all here

    169                      stockPtr = firstRowPtr;  // points to the last one, for loop exits                            

    170                   }

    172                      //aryStockActive[i] = 0; //set to zero 

    173                      arySAPrevious[i] = aryStockActive[i] = 0; // ok both ary are reset  previous + current               

    174                      stockPtr->get_ptrLasTick()->reset_ntCounter();//only resest data in cluster remains, previus was last inpu

    176                      if (loadNtimeLapse == 1) {

    177                         stockPtr->get_ptrLasTick()->set_bool(pp_bool, false); // next cluster is set not active

    179                      }

    180                      else {

    181                         //rowPtr->set_status(1, true); //   index 0 used index 1 to flag this stock activity

    183                         stockPtr->get_ptrLasTick()->set_bool(pp_bool, true);  //before populating make it available                        

    185                      }

    186                   }                           

    187                }

    189                   stockPtr->get_ptrLasTick()->set_bool(pp_bool, true);

    190                   //ptr = stockPtr->get_ptrLasTick();

    191                   if (0 && ptr->get_col() == net->get_cols_in_page(ppDataIn, 'f')) { //end of the record   not in this block                                             

    192                      stockPtr->tickInPoinTo(stockPtr->get_forward_ptr()); //next cluster in col 1

    193                      cout << "\n\t\t:2280: Last Cluster is completed, Now it points to *stockPtr->get_ptrLasTick()->get_col()* 

    195                   }

    196                   else {//cout << "\n\t\t:1890: Update Cluster ---> " << stockPtr->get_ptrLasTick()->get_col();         

    198                      stockPtr->tickInToNextCluster();  //points the next cluster                     

    199                      ////  reset  cluster    counter

    200                      //ptr->set_ushort(pp_key_index, 0); // Node is completed 

    201                      //cout << "\n\t\tNext Cluster is in col *stockPtr->get_ptrLasTick()->get_col()* ---> " 

    202                      // << stockPtr->get_ptrLasTick()->get_col() << "  _ntCounter: " << stockPtr->get_ptrLasTick()->get_ntCount

    203                      //cout << "\n\t\t\t:1866: snapshot timing : : " << "(" << ptr->get_col() << ")" 

    205                      /*                           

    206                      //

    211                      */

    212                   }

    213                

    214                   //stockPtr->get_ptrLasTick()->set_bool(pp_bool, false); // next cluster is set not active  nooooo 

    215                   //cout << "\n\t\t\t:2280: Entry " << stockPtr->get_ptrLasTick()->get_col() 

    216                   //<< " Next Entry Status has been SET : " << stockPtr->get_ptrLasTick()->get_bool(pp_bool)  

    218                   // << stockPtr->get_ptrLasTick()->get_bool(pp_bool);

    219                   /*Dummy block

    220                   ptr = net->go_to(net, stockPtr->get_n_row(), 1); //TRAVERSE THE WHOLE RECORD from the begining

    221                   fout.flush() << "\n\t\t\tRow: " << stockPtr->get_n_row() <<  "\t";

    222                   for (unsigned short ii = 1; ii <= net->get_cols_in_page(ppDataIn, 'f'); ii++) {

    223                      cout << "   " << ptr->get_col() << ":"  << ptr->get_bool(pp_bool);

    224                      ptr = ptr->get_next_ptr();

    225                   }

    226                   //*/

    227                   //} //closes this if (stockPtr->get_ptrLasTick()->get_ntHead()) {                                             

    228                   /*

    229                   else{

    231                      if (stockPtr->get_ptrLasTick()->get_col() == 1) {

    232                         ptr1 = net->go_to(net, stockPtr->get_ptrLasTick()->get_row(), net->get_cols_in_page(ppDataIn, 'f'));

    233                      }

    234                      else ptr1 = stockPtr->get_ptrLasTick()->get_previous_ptr();

    235                      if (ptr1->get_bool(pp_bool)) {//cout << "\tIt was true";

    236                         ptr1->set_bool(pp_bool, false);

    237                      }

    238                   }

    239                   */                        

    240                   arySAPrevious[i] = aryStockActive[i];  //make a copy

    242                }                     

    243                stockPtr = stockPtr->get_down_ptr();

    244             }   

    245             if(counter >= minDB)  prevAry = 1; // there is a previous valid set of clusters

    246          }

    248       }

    249       else {fout.flush() << "\n\t\t:2329:*> *1*  -TRUE- prevAry  ";

    251             prevAry = 0;  // ok previous round is reset, 

    254             //firstRow = min(firstRow, pfR); // A full traversal is not necessary, leading to an excess of machine cycles.

    255             //lastRow  = max(lastRow, plR);   // A full traversal is not necessary, leading to an excess of machine cycles. 

    257             //stockPtr = net->goto_row(net, ppDataIn, firstRow, 'f'); // firstRow may have changed

    258             stockPtr = net->goto_row(net, ppDataIn, 1, 'f'); // firstRow may have changed                  

    261                if (!aryStockActive[i] && !arySAPrevious[i]) { stockPtr = stockPtr->get_down_ptr(); continue; }

    262                ptr = stockPtr->get_forward_ptr();  //traverse the whole record

    263                for (j = 1; j <= net->get_cols_in_page(ppDataIn, 'f');++j) {//traverse record                        

    264                   if (ptr->get_ntHead()) {                           

    265                      //fout.flush() << " " << ptr->get_col();

    266                      ptr->reset_ntCounter();//only resest data in cluster remains, previus was last input                           

    267                      if (loadNtimeLapse == 1) {

    268                         ptr->set_bool(pp_bool, false); // next cluster is set not active

    271                      }

    272                      else {                              

    274                         ptr->set_bool(pp_bool, true);  //before populating make it available                        

    276                      }

    277                   }                        

    278                   ptr = ptr->get_next_ptr();

    279                }                     

    280                arySAPrevious[i] = aryStockActive[i] = 0; // ok both ary are reset  previous + current                     

    281                stockPtr->tickInPoinTo(stockPtr->get_forward_ptr()); //re-start from the beginning of the record                     

    282                stockPtr = stockPtr->get_down_ptr();

    283             }               

    284          }

    285          else{

    286             bool lastCol(0); //

    288             firstRow = min(firstRow, pfR); //lets do a single traversal

    289             lastRow  = max(lastRow, plR);

    291             stockPtr =    net->goto_row(net, ppDataIn, firstRow, 'f');  // traverse the whole new set

    292             for (i = firstRow; i <= lastRow; ++i) {// //first/last from aryStockActive                     

    293                if (arySAPrevious[i] && !aryStockActive[i]) { 

    294                   arySAPrevious[i] = 0;  //                        

    296                   ptr = stockPtr->get_forward_ptr();  //traverse the whole record

    298                   for (j = 1; j <= net->get_cols_in_page(ppDataIn, 'f'); ++j) {//traverse record   only one entry, previous is 

    299                      if (ptr->get_ntHead()) {                                                            

    300                         ptr->reset_ntCounter();//only resest data in cluster remains, previus was last input

    301                         //fout.flush() << " " << ptr->get_col();

    302                         if (loadNtimeLapse == 1) {

    303                            ptr->set_bool(pp_bool, false); // next cluster is set not active

    305                         }

    306                         else {

    307                            //rowPtr->set_status(1, true); //   index 

    308                            // |0 used index 1 to flag this stock activity

    310                            ptr->set_bool(pp_bool, true);  //before populating make it available                        

    312                         }                              

    313                      }                           

    314                      ptr = ptr->get_next_ptr();

    315                   }                        

    316                   stockPtr->tickInPoinTo(stockPtr->get_forward_ptr()); //  ok re-start from the beginning of the record                     

    317                   stockPtr = stockPtr->get_down_ptr(); continue;

    318                }                     

    319                if (!aryStockActive[i]) { 

    320                   stockPtr = stockPtr->get_down_ptr(); continue; 

    321                }

    322                //check if cluster representative value is valid

    323                if (loadNtimeLapse == 1) {

    324                   ptrAry[0] = stockPtr->get_backward_ptr();  //auxiliar tree

    325                   ptr = stockPtr->get_ptrLasTick();  //ptr to the current cluster               

    326                   

    327                   //*//use the auxiliar tree                  

    328 

    329                   ndptrAry[0] = ndptrAry[1] = ptrAry[0]->get_ntHead();

    330                   while (ndptrAry[0]->get_nt_left_ptr())  ndptrAry[0] = ndptrAry[0]->get_nt_left_ptr(); //find min

    331                   while (ndptrAry[1]->get_nt_right_ptr()) ndptrAry[1] = ndptrAry[1]->get_nt_right_ptr(); //find mx

    333                   // << "  mean Val of Spread: " << (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_data(ppnt_data)) 

    334                   kth = 0;

    335                   spreadCenter = 0;

    337                   spreadCenter = (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_data(ppnt_data)) / 2.;

    339                   if (ptr->get_ntCounter() % 2) { //cout << "\n\t\t\t:2481:*> ODD ntCounter:-> " << ptr->get_ntCounter(); //impa

    340                      kth = 1 + ptr->get_ntCounter() / 2;  //cout << "\tkth: " << kth;

    341                      ndptrAry[0] = net->InOrderFindKth_nt(net, stockPtr->get_backward_ptr()->get_ntHead(), kth);  //OK  auxilia

    342                      //ndptrAry[0] = net->InOrderFindKey_nt(net, ptr->get_ntHead(), kth);  ///NO 

    344                      ptr->set_data(ppDataIn, ndptrAry[0]->get_nt_data(ppnt_data));

    345                      //ptr->set_data(ppTime, ndptrAry[0]->get_nt_data(ppnt_time)); //already done during streming

    346                   }

    347                   else { //cout << "\n\t\t:2431:*> EVEN ntCounter:-> " << ptr->get_ntCounter(); // par                     

    348                      unsigned short kth = ptr->get_ntCounter() / 2;  //left

    349                      ndptrAry[0] = net->InOrderFindKth_nt(net, stockPtr->get_backward_ptr()->get_ntHead(), kth);   //OK

    350                      //ndptrAry[0] = net->InOrderFindKey_nt(net, ptr->get_ntHead(), kth); //NO 

    352                      kth = 1 + ptr->get_ntCounter() / 2; // right

    353                      ndptrAry[1] = net->InOrderFindKth_nt(net, stockPtr->get_backward_ptr()->get_ntHead(), kth);

    354                      if (0) {

    356                         cout << "\n\t\t:2421: CENTRAL DATUM:-> " << (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt

    357                      }

    358                      ptr->set_data(ppDataIn, (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_data(ppnt_data)) / 2.);

    360                      //cout << "\n\t\t:1893: To Cluster Spread - Center:-> " << ptr->get_data(ppDataIn);

    361                   }

    362                   //auxiliar ntTree

    364                   if (stockPtr->get_backward_ptr()->get_ntHead())  cout << "\n\t\t:2430: Errror head of auxiliar Cluster not nil

    365                   if (checkThisRow == ptr->get_row())

    367                }

    368                else {cout << "\n\t\t:2453: New Version - ntNodes Not Deleted" ;                                             

    369                // much more simpler instruction from is omited                     

    370                ndptrAry[0] = ndptrAry[1] = nullptr;  // ! both initialized in null                     

    373                     << (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_data(ppnt_data)) / 2.;

    374                spreadCenter = (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_data(ppnt_data)) / 2.;

    375 

    379                   ptr->set_data(ppDataIn, ndptrAry[0]->get_nt_data(ppnt_data));

    380                   ptr->set_data(ppTime, ndptrAry[0]->get_nt_data(ppnt_time));   ///very important

    381                }

    382                else {cout << "\n\t:2446: EVEN key_index:-> " << setprecision(0) << ptr->get_ushort(pp_key_index); // impar                     

    384                   if (0) {

    387                      cout << "\n\t\t:2452: CENTRAL DATUM:-> " << (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_dat

    388                   }

    389                   ptr->set_data(ppDataIn, (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_data(ppnt_data)) / 2.);

    391                }

    392             }

    393 

    396                   /* Dummy block  ok

    400                   ptr1 = net->go_to(net, ptr->get_row(), 1);

    401                   for (unsigned short i = 1; i <= net->get_cols_in_page(ppDataIn, 'f'); i++) {

    402                      cout << ptr1->get_bool(pp_bool);

    403                      ptr1 = ptr1->get_next_ptr();

    404                   }

    405                   //*/

    406                   --counter;   // because of the discarded value

    407                   

    408                   if (counter < minDB) {   fout.flush() << "\n\t\t\t *1.1.0.0* Discard the whole entry";

    409                      //prevAry = 0;  // previous round is reset ???? next loop resests all

    410                      //counter = 0; // DOES IT NEED TO BE RESET?

    412                      pfR = min(firstRow, pfR);

    413                      plR = max(lastRow, plR);

    414                      firstRowPtr = net->goto_row(net, ppDataIn, pfR, 'f');  // point at the beggining                        

    415                      for (i = pfR; i <= plR; ++i) {//error  check for 1 and 2 they are different, take out of this loop      

    416                         if (aryStockActive[i]) {

    418 

    419                            firstRowPtr->get_ptrLasTick()->reset_ntCounter();//only resest data in cluster remains, previus wa

    421 

    422                            if (loadNtimeLapse == 1) {

    423                               firstRowPtr->get_ptrLasTick()->set_bool(pp_bool, false); // next cluster is set not active

    425                            }

    426                            else {

    427                               //rowPtr->set_status(1, true); //   index 

    428                               // |0 used index 1 to flag this stock activity

    430                               firstRowPtr->get_ptrLasTick()->set_bool(pp_bool, true);  //before populating make it available

    432                            }

    433                         }

    434 

    435                         if (arySAPrevious[i]) {

    436                            ptr = firstRowPtr->get_ptrLasTick(); //ok, previous round point to the last entry ?????

    437                            if (arySAPrevious[i] == aryStockActive[i]) {//stock has previous entry                     

    438                               if (ptr->get_col() == 1) ptr1 = net->go_to(net, firstRowPtr->get_n_row(), net->get_cols_in_pag

    439                               else ptr = ptr->get_previous_ptr();

    440                            }

    441                            //else {/*stock DOES NOT has previous entry  -default- firstRow points to the last in aryPrevious 

    442 

    444 

    445                            ptr->reset_ntCounter();//only resest data in cluster remains, previus was last input

    446                            fout.flush() << " bool/false counter/0 (" << ptr->get_row() << "," << ptr->get_col() << ")";

    447 

    448                            if (loadNtimeLapse == 1) {

    449                               ptr->set_bool(pp_bool, false); // next cluster is set not active

    451                            }

    452                            else {

    453                               //rowPtr->set_status(1, true); //   index 

    454                               // |0 used index 1 to flag this stock activity

    456                               ptr->set_bool(pp_bool, true);  //before populating make it available                        

    458                            }

    459                         }

    460                         arySAPrevious[i] = aryStockActive[i] = 0; // both ary are reset  previous + current   

    461                         firstRowPtr = firstRowPtr->get_down_ptr();

    462                      }

    463                      i = lastRow + 1; // no need to browse the whole set of active Stocks, reset all here

    464                      stockPtr = firstRowPtr;  // points to the last one, for loop exits                               

    465                   }

    466                   else {  //  *0.1.0.1* discard this stock only    //ok                                                   

    467                      stockPtr->get_ptrLasTick()->reset_ntCounter();//only resest data in cluster remains, previus was last inpu

    469                      if (loadNtimeLapse == 1) {

    470                         stockPtr->get_ptrLasTick()->set_bool(pp_bool, false); // next cluster is set not active

    472                      }

    473                      else {

    474                         //rowPtr->set_status(1, true); //   index 0 used index 1 to flag this stock activity

    476                         stockPtr->get_ptrLasTick()->set_bool(pp_bool, true);  //before populating make it available                        

    478                      }

    479 

    480                      if (0 && arySAPrevious[i]) {   ///error  i DON'T THINK THIS IS NECCESARY

    481                         ptr = stockPtr->get_ptrLasTick(); //ok, previous round point to the last entry ?????

    482                         if (arySAPrevious[i] == aryStockActive[i]) {//stock has previous entry                        

    483                            if (ptr->get_col() == 1) ptr1 = net->go_to(net, stockPtr->get_n_row(), net->get_cols_in_page(ppDat

    484                            else ptr = ptr->get_previous_ptr();

    485                         }

    486                         //else {/*stock DOES NOT has previous entry  -default- */ }

    487 

    489 

    490                         ptr->reset_ntCounter();//only resest data in cluster remains, previus was last input

    491                         fout.flush() << " bool/false counter/0 (" << ptr->get_row() << "," << ptr->get_col() << ")";

    492 

    493                         if (loadNtimeLapse == 1) {

    494                            ptr->set_bool(pp_bool, false); // next cluster is set not active

    496                         }

    497                         else {

    498                            //rowPtr->set_status(1, true); //   index 

    499                            // |0 used index 1 to flag this stock activity

    501                            ptr->set_bool(pp_bool, true);  //before populating make it available                        

    503                         }

    504                      }

    505                      arySAPrevious[i] = aryStockActive[i] = 0; // both ary are reset  previous + current   

    506                   }                        

    507                }

    508                else {//fout.flush() << "\n\t\t\t:2650:*> *1.1.1* VALID CLUSTER - Move to new Col:";

    509                   stockPtr->get_ptrLasTick()->set_bool(pp_bool, true);  

    510                   

    511                   if (ptr->get_col() < net->get_cols_in_page(ppDataIn, 'f')) {

    512                      stockPtr->tickInToNextCluster();  //points the next cluster                     

    514                      //      << stockPtr->get_ptrLasTick()->get_ntCounter() << " bool: " << stockPtr->get_ptrLasTick()->get_boo

    515                      arySAPrevious[i] = aryStockActive[i];  //make a copy

    517                   }                           

    518                   else{///* this block checks if there are enough complete clusters for minDB

    519                      /* nice code, useful tips, do not erase

    520                      stockPtr->set_status(0, true);  // SET TRUE ALWAYS AT THE BEGGINING its assume completed

    522                      //ptr1 = net->go_to(net, stockPtr->get_n_row(), 1); //TRAVERSE THE WHOLE RECORD from the begining

    523                      ptr1 = stockPtr->get_forward_ptr();

    524                      fout.flush() << "\tTraverse Row " << stockPtr->get_n_row() << ": ";

    525                      for (unsigned short ii = 1; ii <= net->get_cols_in_page(ppDataIn, 'f'); ii++) {

    526                         //cout << ptr1->get_bool(pp_bool);

    527                         if (stockPtr->get_status(0) && !ptr1->get_bool(pp_bool)) {

    528                            //cout << ptr1->get_bool(pp_bool) << "    this record is incomplete-> disable ";

    529                            cout << "       this record is incomplete-> disable ";

    530                            stockPtr->set_status(0, false);

    531                            break;

    532                         }

    533                         //cout << ptr1->get_bool(pp_bool);

    534                         ptr1 = ptr1->get_next_ptr();

    535                      }                  

    536                      if (stockPtr->get_status(0)) {  //true

    537                         aryStockAux[stockPtr->get_n_row()] = 1;  //selected for possible portfolio

    538                         ++counToPortfolio;

    539                         fout.flush() << "\n\t\t\t:2697: Record Complete Cluster - Time  counToPortfolio: " << counToPortfolio 

    540                      }

    542                      */

    543                      if (!lastCol) {   fout.flush() << "\n\t\t\t:2607:*> Last Cluster Reached  ";

    544                         lastCol = !lastCol;                              

    545                      }

    546                      aryStockAux[stockPtr->get_n_row()] = 1;  //selected for possible portfolio

    547                      ++counToPortfolio;

    548                      //fout.flush() << "\n\t\t\t:2688: Record Complete Cluster - Time  counToPortfolio: " << counToPortfolio <<

    549                   }                        

    550                }                     

    551                if(0 && counToPortfolio > minDB/2)

    554                      

    555                stockPtr = stockPtr->get_down_ptr();

    556             }

    557             //fout.flush() << "\n\t\t:2642:*> end of *1.1*";

    558             if (0) {    //useless block?

    559                //----this block after checking integrity of current set of clusters   

    560                //not sure, previously done !!!

    561                bool goodCluster(true); //check if previous round has the same set of stocks // 

    562                for (i = firstRow; i <= lastRow; ++i) {//error  check for 1 and 2 they are different, take out of this loop

    563                   if (!aryStockActive[i]) { //stockPtr = stockPtr->get_down_ptr(); 

    564                      continue; 

    565                   }

    566                   if (goodCluster  && !(arySAPrevious[i] == aryStockActive[i])) {  //if ary are different

    567                      goodCluster = !goodCluster;   // not a good cluster not previous activity                        

    568                      break;  //exit the for loop

    569                   }

    570                   //stockPtr = stockPtr->get_down_ptr();

    571                }

    572                ///-----

    573                if (!goodCluster) {   fout.flush() << "\n\t\t:2664: *1.1.0* discard previous round of clusters " ;                     

    574                net->boundaries(net, ppDataIn, 'f', 1, arySAPrevious, pfR, plR);

    575                stPtr = net->goto_row(net, ppDataIn, pfR, 'f');  // point at the beggining   

    576                for (i = pfR; i <= plR; ++i) {//error  check for 1 and 2 they are different, take out of this loop

    577                   if (!arySAPrevious[i]) { stockPtr = stockPtr->get_down_ptr(); continue; }

    578                   arySAPrevious[i] =  0;

    579                   ptr = stockPtr->get_ptrLasTick();  //ptr to the current cluster               

    580                   if (ptr->get_col() == 1) 

    581                      ptr = net->go_to(net, ptr->get_row(), net->get_cols_in_page(ppDataIn, 'f'));                                                    

    582                   else 

    583                      ptr = ptr->get_previous_ptr();

    584                    cout << "\n\t\t:1890: ptr to previous  Cluster ---> " << ptr->get_col();         

    585 

    586                   ptr->reset_ntCounter();//only resest data in cluster remains, previus was last input

    587                   fout.flush() << " bool/false counter/0 (" << ptr->get_row() << "," << ptr->get_col() << ")";

    588 

    589                   if (loadNtimeLapse == 1) {

    590                      ptr->set_bool(pp_bool, false); // next cluster is set not active

    592                   }

    593                   else {

    594                      //rowPtr->set_status(1, true); //   index 

    595                      // |0 used index 1 to flag this stock activity

    597                      ptr->set_bool(pp_bool, true);  //before populating make it available                        

    599                   }                        

    600                   stPtr = stPtr->get_down_ptr();

    601                }

    602                fout.flush() << "\n\t\t:2348:  New Previous";

    603                countElementInAry(aryStockActive, true, pfR, plR);

    604                stPtr = net->goto_row(net, ppDataIn, pfR, 'f');  // point at the beggining   

    605                for (i = pfR; i <= plR; ++i) // previous is set for next round                     

    606                   arySAPrevious[i] = aryStockActive[i];         

    607             }                  

    608             }

    609          }//system("pause");               

    610          if (counToPortfolio ) { 

    612                prevAry = 0;  //no previous

    613                stockPtr = net->goto_row(net, ppDataIn, firstRow, 'f');  // traverse the whole new set

    614                for (i = firstRow; i <= lastRow; ++i) {// //first/last from aryStockActive   

    615                   arySAPrevious[i] = aryStockActive[i] =  0;  //                        

    616                   //fout.flush() << "\n\t\t\t:2684: RESET bool/false/counter/0  stockPtr-> " << setw(3) << stockPtr->get_n_row()

    617                   //             << setw(8) << stockPtr->get_stock_name() << " clusters: ";  // point at the beggining

    618                   ptr = stockPtr->get_forward_ptr();  //traverse the whole record                        

    619                   for (j = 1; j <= net->get_cols_in_page(ppDataIn, 'f'); ++j) {//traverse record   only one entry, previous is 

    620                      if (ptr->get_ntHead()) {

    621                         ptr->reset_ntCounter();//only resest data in cluster remains, previus was last input

    622                         //fout.flush() << " " << ptr->get_col();

    623                         if (loadNtimeLapse == 1) {

    624                            ptr->set_bool(pp_bool, false); // next cluster is set not active

    627                         }

    628                         else {

    629                            //rowPtr->set_status(1, true); //   index 

    630                            // |0 used index 1 to flag this stock activity

    632                            ptr->set_bool(pp_bool, true);  //before populating make it available                        

    634                         }

    635                      }

    636                      ptr = ptr->get_next_ptr();

    637                   }                        

    638                   stockPtr->tickInPoinTo(stockPtr->get_forward_ptr()); //  ok re-start from the beginning of the record                     

    639                   stockPtr = stockPtr->get_down_ptr(); 

    640                }

    641                //LABEL reload exsan 

    642                //net->kill_exsan(net);     return; 

    643             }                  

    644             else{ 

    647                //net->kill_exsan(net);   return; 

    648                check = 1;

    649 

    650             }

    651          }

    652       }                        

    653       if(prevAry && dbfileID >= 4 ) {                  

    654          net->boundaries(net, ppDataIn, 'f', 1, arySAPrevious, pfR, plR); 

    655          fout.flush() << "\n\t\t:2752: END aryStockPREVIOUS firstRow: " << pfR << "  lastRow: " << plR << "\t";

    656          for (i = 1; i <= plR; ++i) { fout.flush() << arySAPrevious[i];  if (!(i % 5)) cout << " "; }               

    658       }

    659       

    660       if(0){                                       

    661          //--------------------------------------------------------------------------

    663          }

    666             net->boundaries(net, ppDataIn, 'f', 1, arySAPrevious, pfR, plR);  

    668             /*

    669             ndptrAry[0] = ndptrAry[1] = nullptr;

    670             //ptrAry[0]->inOrderSearch_nt_ptr_minmax(ptrAry[0], ptrAry[0]->get_ntHead(), ndptrAry[0], ndptrAry[1], 'f', ppnt_time)

    673             */

    674             //----------------------------------HERE-----------------------------------------------

    675             if(0) { 

    678             }

    681             //if(counter > minDB*4){ cout << "\n\t:2182: counter: " << counter;   //

    682             //if (counter >= 2) { cout << "\n\t:2302: Ready - Complete Recordscounter  counter  >= 4  -- RESET is skipped";   //sh

    683             if(counter > minDB + 10){ cout << "\n\t:2773: counter: " << counter;   //

    684                net->set_work_sheet(net, ppRTime, rows, cols);

    689                //all clusters start at j = 1

    690                stockPtr = net->goto_row(net, ppTime, firstRow, 'f');  // point at the beggining

    691                for (i = firstRow; i <= lastRow; ++i) {//error  check for 1 and 2 they are different, take out of this loop

    692                   if (!aryStockAux[i]) { stockPtr = stockPtr->get_down_ptr();  continue; }

    693                   //ptrAry[0] = stockPtr->get_ptrLasTick();  //ptr to the current cluster               

    694                   //ptr = net->net_point_to(net, net->get_net_rows(), 1);

    695                   ptr = stockPtr->get_forward_ptr()->get_next_ptr(); //on j = 2

    696                   for (j = 1; j < net->get_cols_in_page(ppTime, 'f'); j++) { // j - 1 clusters

    697                      if (ptr->get_data(ppTime)  < ptr->get_previous_ptr()->get_data(ppTime) ||

    698                         ptr->get_data(ppRTime) < ptr->get_previous_ptr()->get_data(ppRTime)  ) {

    699                         --counter;

    700                         cout << "\n\t\t\t:2320: Reset - Discard  this record of clusters Time not consistent  j:  " << j << " 

    701 

    702                         ptrAry[0] = stockPtr->get_forward_ptr()->get_next_ptr(); //

    703                         for (j = 1; j <= net->get_cols_in_page(ppTime, 'f'); j++) { 

    704 

    705                            ptrAry[0]->set_bool(pp_bool, false); // next cluster is set not active

    706                            ptrAry[0]->reset_ntCounter();//only resest data in cluster remains, previus was last input      

    708                            ptrAry[0] = ptrAry[0]->get_next_ptr();

    709                         }

    710                         //set auxary this index zero

    711                      }

    712 

    713                      /*

    714                      for (i = firstRow; i <= lastRow; ++i) {//error  check for 1 and 2 they are different, take out of this loo

    715                         if(ptrAry[0]->get_data(ppTime) <  (ptrAry[0]->get_data(ppRtime   ){

    716                         }

    717                      }

    718                      */

    719                      ptr = ptr->get_next_ptr();

    720                   }

    721                   //cout << endl;

    722                   stockPtr = stockPtr->get_down_ptr();

    723                }

    725                //------------- new block                              

    726             }

    728             

    729             //*

    730             if(1){

    731                stockPtr = net->goto_row(net, ppDataIn, firstRow, 'f');  // point at the beggining                        

    733                   if (!aryStockActive[i]) { stockPtr = stockPtr->get_down_ptr();  continue; }  //it was aryStock.... unneccesary

    735                   //if (stockPtr->get_ptrLasTick()->get_ntHead()) { //only if there is a nt tree

    736                      stockPtr->get_ptrLasTick()->set_bool(pp_bool, false); // next cluster is set not active

    737                      stockPtr->get_ptrLasTick()->reset_ntCounter();//only resest data in cluster remains, previus was last inpu

    739 

    740                      if (loadNtimeLapse == 1) {

    742                      }

    743                      else {

    744                         //rowPtr->set_status(1, true); //   index 0 used index 1 to flag this stock activity

    746                         stockPtr->get_ptrLasTick()->set_bool(pp_bool, true);  //before populating make it available                        

    748                             << ") reseted pp_key_index:-> " << stockPtr->get_ptrLasTick()->get_ushort(pp_key_index);

    749                      }

    750                   //}

    751 

    752                   stockPtr = stockPtr->get_down_ptr();  //OK browse all DB

    753                }

    754             }

    755             //*/

    756             //system("pause");

    757             //} while (stockPtr);

    758          }            

    759 

    760          }

    761       }         

    762    }//closes if (loadNtimeLapse &&  frameClk[1] ....

    763 }

    764 //else cout << "\n\t\t\t\t:2470: Invalid datum -not a number- Stock: "  << setw(7) << stockID[s] << " " << val.get_token();         

    765 //*

    766 if(1 && inData){         

    768    cout << "\n\t:2881: (inData)TIME STAMP ppTime";   net->displayMKT(net,   ppTime, aryStock, nullptr, 0, 5, widthCol, presCol - 2);

    769    inData = 0;  // to show only once¡????

    770 }

    771 //system("pause");

    772 //*/


R e j e c t         t h e       D e f a u l t
C h a l l e n g e   t h e   S t a n d a r d s
S h a p e           t h e         F u t u r e
+ + C         E x S a n                 C + +
EXIT FROM EXSAN
Flag Counter

Comments

Popular posts from this blog

Roberto Santander - Resume

🔥 ExSan Pushing the Limits of High-Frequency Trading with C++ 🔥