Ejemplo n.º 1
0
        public DateTime GetObject(byte[] buffer, int offset, int count)
        {
            long ticks = Helper.ToInt64(buffer, offset);

            return(new DateTime(ticks));
        }
Ejemplo n.º 2
0
 public long GetObject(byte[] buffer, int offset, int count)
 {
     return(Helper.ToInt64(buffer, offset));
 }
Ejemplo n.º 3
0
 public byte[] GetBytes(DateTime obj)
 {
     return(Helper.GetBytes(obj.Ticks, false));
 }
Ejemplo n.º 4
0
 public uint GetObject(byte[] buffer, int offset, int count)
 {
     return((uint)Helper.ToInt32(buffer, offset));
 }
Ejemplo n.º 5
0
 public byte[] GetBytes(long obj)
 {
     return(Helper.GetBytes(obj, false));
 }
Ejemplo n.º 6
0
 public string GetObject(byte[] buffer, int offset, int count)
 {
     return(Helper.GetString(buffer, offset, (short)count));
 }
Ejemplo n.º 7
0
 public byte[] GetBytes(string obj)
 {
     return(Helper.GetBytes(obj));
 }
Ejemplo n.º 8
0
 public short GetObject(byte[] buffer, int offset, int count)
 {
     return(Helper.ToInt16(buffer, offset));
 }
Ejemplo n.º 9
0
 public byte[] GetBytes(short obj)
 {
     return(Helper.GetBytes(obj, false));
 }
Ejemplo n.º 10
0
        internal void SavePage(Page <T> node)
        {
            lock (_fileLock)
            {
                int pnum = node.DiskPageNumber;
                if (pnum > _LastPageNumber)
                {
                    throw new Exception("should not be here: page out of bounds");
                }

                SeekPage(pnum);
                byte[] page        = new byte[_PageLength];
                byte[] blockheader = CreateBlockHeader(0, (ushort)node.tree.Count, node.RightPageNumber);
                Buffer.BlockCopy(blockheader, 0, page, 0, blockheader.Length);

                int    index = blockheader.Length;
                int    i     = 0;
                byte[] b     = null;
                T[]    keys  = node.tree.Keys();
                Array.Sort(keys); // sort keys on save for read performance
                int blocknum = 0;
                if (_externalStrings)
                {
                    // free old blocks
                    if (node.allocblocks != null)
                    {
                        _strings.FreeBlocks(node.allocblocks);
                    }
                    blocknum = _strings.SaveData(node.DiskPageNumber.ToString(), fastBinaryJSON.BJSON.ToBJSON(keys));
                }
                // node children
                foreach (var kp in keys)
                {
                    var val = node.tree[kp];
                    int idx = index + _rowSize * i;
                    // key bytes
                    byte[] kk;
                    byte   size;
                    if (_externalStrings == false)
                    {
                        kk   = _T.GetBytes(kp);
                        size = (byte)kk.Length;
                        if (size > _maxKeySize)
                        {
                            size = _maxKeySize;
                        }
                    }
                    else
                    {
                        kk = new byte[4];
                        Buffer.BlockCopy(Helper.GetBytes(blocknum, false), 0, kk, 0, 4);
                        size = 4;
                    }
                    // key size = 1 byte
                    page[idx] = size;
                    Buffer.BlockCopy(kk, 0, page, idx + 1, page[idx]);
                    // offset = 4 bytes
                    b = Helper.GetBytes(val.RecordNumber, false);
                    Buffer.BlockCopy(b, 0, page, idx + 1 + _maxKeySize, b.Length);
                    // duplicatepage = 4 bytes
                    b = Helper.GetBytes(val.DuplicateBitmapNumber, false);
                    Buffer.BlockCopy(b, 0, page, idx + 1 + _maxKeySize + 4, b.Length);
                    i++;
                }
                _file.Write(page, 0, page.Length);
            }
        }