public _segment(DefaultPileBase pile, Memory data, bool brandNew)
                              {
                                  Pile = pile;
                                  Data = data;//segment memory

                                  FreeChunks = new freeChunks[FREE_LST_COUNT];
                                  for (var i = 0; i < FreeChunks.Length; i++)
                                  {
                                      var chunk = new freeChunks();
                                      chunk.Addresses    = new int[pile.m_FreeListSize];
                                      chunk.CurrentIndex = -1;
                                      FreeChunks[i]      = chunk;
                                  }

                                  if (brandNew)
                                  {
                                      //init 1 chunk for the whole segment
                                      var adr = 0;
                                      data.WriteFreeChunkFlag(0); adr += 3;               //flag
                                      data.WriteInt32(adr, Data.Length - CHUNK_HDER_SZ);
                                      FreeChunks[FreeChunks.Length - 1].CurrentIndex = 0; //mark the largest chunk as free
                                      LOADED_AND_CRAWLED = true;
                                  }
                                  else
                                  {
                                      //Segment will be Crawled first
                                      LOADED_AND_CRAWLED = false;
                                  }
                              }
Exemple #2
0
               public _segment(DefaultPile pile)
               {
                 Pile = pile;
                 Data = new byte[pile.m_SegmentSize];//segment memory

                 //init 1 chunk for the whole segment
                 var adr = 0;
                 writeFreeFlag(Data, 0); adr+=3;//flag
                 Data.WriteBEInt32(adr, Data.Length - CHUNK_HDER_SZ); 

                 FreeChunks = new freeChunks[FREE_LST_COUNT];
                 for(var i=0; i<FreeChunks.Length; i++)
                 {
                   var chunk = new freeChunks();
                   chunk.Addresses = new int[pile.m_FreeListSize];
                   chunk.CurrentIndex = -1;
                   FreeChunks[i] = chunk;
                 }
                 FreeChunks[FreeChunks.Length-1].CurrentIndex = 0;//mark the largest chunk as free
               }