Example #1
0
        internal View SetView(Table tmp, string nm, mpIndexKey rky)
        {
            SyncView.WaitOne();
            View vw;

            if (ViewList.TryGetValue(rky, out vw))
            {
                vw.Grow();
                SyncView.ReleaseMutex();
                return(vw);
            }
            vw = new View();
            if (nm == null || nm.Length == 0)
            {
                nm        = Alias + ViewList.Count.ToString();
                vw.delete = true;
            }
            DataFile.Blank(tmp, Struct.RowLength);
            if (vw.MustBuild(nm, Struct.LastUpdate, rky, tmp))
            {
                long r, x;
                x = Struct.RowCount;
                for (r = 1; r <= x; r++)
                {
                    Read(tmp, r);
                    vw.AddKey(tmp, r);
                }
            }
            ViewList.Add(rky, vw);
            SyncView.ReleaseMutex();
            return(vw);
        }
Example #2
0
        public Index(string nm, ushort kl, DateTime udTime)
        {
            int sz = DataFile.GetSize(Root);

            if (DataFile.Exists(nm, "Index"))
            {
                File = DataFile.Open(nm, "Index", FileMode.Open);
                File.Read(Root, DataFile.coSignatureSz, sz);
                if (DateTime.Compare(Root.LastUpdate, udTime) >= 0 && Root.Closed)
                {
                    Root.Closed = false;
                    File.Lock(Root);
                    File.Write(Root);
                    return;
                }
                File.Close();
                DataFile.Delete(nm, "Index");
            }
            File = DataFile.Open(nm, "Index", FileMode.CreateNew);
            DataFile.Blank(Root, sz);
            Root.KeyLength = kl;
            Root.Closed    = false;
            Root.PageSize  = (ushort)DataFile.GetSize(new IdxPage(0, 0, 0, kl));
            File.Append(Root, sz);
            File.Lock(Root);
        }
Example #3
0
 internal void Blank(Table obj)
 {
     DataFile.Blank(obj, Struct.RowLength);
 }