Ejemplo n.º 1
0
Archivo: Piled.cs Proyecto: zhabis/nfx
 /// <summary>
 /// Creates distributed pointer
 /// </summary>
 public Piled(int pileId, PilePointer ptr)
 {
     PileID        = pileId;
     Pointer       = ptr;
     m_ValueLoaded = false;
     m_Value       = default(T);
 }
Ejemplo n.º 2
0
        public unsafe override void WritePilePointer(int addr, PilePointer ptr)
        {
            byte *bptr = null;

            m_View.SafeMemoryMappedViewHandle.AcquirePointer(ref bptr);
            try
            {
                bptr += addr;
                *bptr++ = (byte)(ptr.NodeID >> 24);
                *bptr++ = (byte)(ptr.NodeID >> 16);
                *bptr++ = (byte)(ptr.NodeID >> 8);
                *bptr++ = (byte)(ptr.NodeID);

                *bptr++ = (byte)(ptr.Segment >> 24);
                *bptr++ = (byte)(ptr.Segment >> 16);
                *bptr++ = (byte)(ptr.Segment >> 8);
                *bptr++ = (byte)(ptr.Segment);

                *bptr++ = (byte)(ptr.Address >> 24);
                *bptr++ = (byte)(ptr.Address >> 16);
                *bptr++ = (byte)(ptr.Address >> 8);
                *bptr   = (byte)(ptr.Address);
            }
            finally
            {
                m_View.SafeMemoryMappedViewHandle.ReleasePointer();
            }
        }
Ejemplo n.º 3
0
                                              private bool crawlSegment(_segment seg)//must be called under segment read lock
                                              {
                                                  const int BUFFER_SIZE = 1024;

                                                  var addr = 0;//start crawling from very first byte to avoid segment corruption as previous address may have been deleted

                                                  while (addr < seg.Data.Length - CHUNK_HDER_SZ)
                                                  {
                                                      var add = addr >= m_Address;

                                                      var chunkStartAdr = addr;
                                                      var flag          = seg.Data.ReadChunkFlag(addr);
                                                      if (flag == ChunkFlag.Wrong) //todo In future corruption recovery attempt may take place if we scan form 8-aligned block
                                                      {
                                                          throw new PileException(StringConsts.PILE_CRAWL_INTERNAL_SEGMENT_CORRUPTION_ERROR.Args(addr));
                                                      }
                                                      addr += 3;

                                                      var payloadSize = seg.Data.ReadInt32(addr); addr += 4;

                                                      var sver = seg.Data.ReadByte(addr); addr++; //read serializer version

                                                      addr += payloadSize;                        //skip the body of payload

                                                      if (!add)
                                                      {
                                                          continue;
                                                      }

                                                      m_Address = addr;//next chunk

                                                      if (flag == ChunkFlag.Used)
                                                      {
                                                          var ptr = new PilePointer(m_SegmentIdx, chunkStartAdr);
                                                          var dt  = sver == SVER_UTF8 ? PileEntry.DataType.String :
                                                                    sver == SVER_BUFF ? PileEntry.DataType.Buffer :
                                                                    sver == SVER_LINK ? PileEntry.DataType.Link   : PileEntry.DataType.Object;
                                                          var entry = new PileEntry(ptr, dt, payloadSize);
                                                          m_Buffer.Add(entry);
                                                          if (m_Buffer.Count == BUFFER_SIZE)
                                                          {
                                                              return(m_Address >= seg.Data.Length - CHUNK_HDER_SZ);
                                                          }
                                                      }
                                                  }//while

                                                  return(true);
                                              }
Ejemplo n.º 4
0
 public override void WritePilePointer(int addr, PilePointer ptr)
 {
     m_Data.WriteBEInt32(addr, ptr.NodeID); addr  += 4;
     m_Data.WriteBEInt32(addr, ptr.Segment); addr += 4;
     m_Data.WriteBEInt32(addr, ptr.Address);
 }
Ejemplo n.º 5
0
Archivo: Memory.cs Proyecto: zhabis/nfx
 public abstract void WritePilePointer(int addr, PilePointer ptr);
Ejemplo n.º 6
0
 public PileEntry(PilePointer ptr, DataType tp, int size)
 {
     Pointer = ptr;
     Type    = tp;
     Size    = size;
 }