Пример #1
0
		public DataFile GetFile(string name, FileMode mode = FileMode.OpenOrCreate)
		{
			bool flag = false;
			DataFile result;
			try
			{
				Monitor.Enter(this, ref flag);
				DataFile dataFile;
				this.files.TryGetValue(name, out dataFile);
				if (dataFile == null)
				{
					Console.WriteLine(DateTime.Now + " Opening file : " + name);
					dataFile = new DataFile(this.path + "\\" + name, this.streamerManager);
					dataFile.Open(mode);
					this.files.Add(name, dataFile);
				}
				result = dataFile;
			}
			finally
			{
				if (flag)
				{
					Monitor.Exit(this);
				}
			}
			return result;
		}
Пример #2
0
		public DataKey(DataFile file, object obj = null, long prev = -1L, long next = -1L) : base(file, "", obj)
		{
			this.label = "DKey";
			this.keyLength = 77;
			this.prev = prev;
			this.next = next;
		}
Пример #3
0
		public FileInstrumentServer(Framework framework, string fileName, string host = null) : base(framework)
		{
			if (host == null)
			{
				this.file = new DataFile(fileName, framework.streamerManager);
				return;
			}
			this.file = new NetDataFile(fileName, host, framework.streamerManager);
		}
Пример #4
0
        public DataSeries GetSeries(string fileName, string seriesName)
        {
            DataFile   file       = this.GetFile(fileName, FileMode.OpenOrCreate);
            DataSeries dataSeries = (DataSeries)file.Get(seriesName);

            if (dataSeries == null)
            {
                dataSeries = new DataSeries(seriesName);
                file.Write(seriesName, dataSeries);
            }
            return(dataSeries);
        }
Пример #5
0
 private void ReadCache()
 {
     this.cacheKey = this.file.ReadKey(this.cachePosition, 38);
     this.cache    = ((DataKeyIdArray)this.cacheKey.GetObject()).keys;
     for (int i = 0; i < this.cache.Size; i++)
     {
         if (this.cache[i] != null)
         {
             this.cache[i].file   = this.file;
             this.cache[i].number = i;
         }
     }
 }
Пример #6
0
 internal void Init(DataFile file)
 {
     this.file = file;
     if (this.obj != null)
     {
         ObjectStreamer objectStreamer;
         file.streamerManager.streamerByType.TryGetValue(this.obj.GetType(), out objectStreamer);
         if (objectStreamer != null)
         {
             this.typeId = objectStreamer.typeId;
             return;
         }
         Console.WriteLine("ObjectKey::Init Can not find streamer for object of type " + this.obj.GetType());
     }
 }
Пример #7
0
 internal void Init(DataFile file, ObjectKey key)
 {
     this.file             = file;
     this.key              = key;
     key.compressionLevel  = 0;
     key.compressionMethod = 0;
     if (this.cachePosition == -1L)
     {
         if (this.buffer_count < 4096)
         {
             this.cache = new IdArray <DataKey>(4096);
         }
         else
         {
             this.cache = new IdArray <DataKey>(this.buffer_count);
         }
         this.cacheKey = new ObjectKey(file, "", new DataKeyIdArray(this.cache));
     }
 }
Пример #8
0
 static void DumpDataFile()
 {
     var f = Framework.Current;
     var df = new DataFile("d:\\data.quant", f.StreamerManager);
     df.Open();
     df.Dump();
     ObjectKey key;
     var kname = "AAPL.0.Bid";
     df.Keys.TryGetValue(kname, out key);
     if (key != null)
     {
         Console.WriteLine(key.DateTime);
         Console.WriteLine(key.CompressionLevel);
         Console.WriteLine(key.CompressionMethod);
         var obj = (DataSeries)key.GetObject();
         obj.Dump();
         for (long i = 0; i < obj.Count; i++)
             Console.WriteLine(obj.Get(i));
     }
     df.Close();
 }
Пример #9
0
		internal void Init(DataFile file, ObjectKey key)
		{
			this.file = file;
			this.key = key;
			key.compressionLevel = 0;
			key.compressionMethod = 0;
			if (this.cachePosition == -1L)
			{
				if (this.buffer_count < 4096)
				{
					this.cache = new IdArray<DataKey>(4096);
				}
				else
				{
					this.cache = new IdArray<DataKey>(this.buffer_count);
				}
				this.cacheKey = new ObjectKey(file, "", new DataKeyIdArray(this.cache));
			}
		}
Пример #10
0
		private void ReadCache()
		{
			this.cacheKey = this.file.ReadKey(this.cachePosition, 38);
			this.cache = ((DataKeyIdArray)this.cacheKey.GetObject()).keys;
			for (int i = 0; i < this.cache.Size; i++)
			{
				if (this.cache[i] != null)
				{
					this.cache[i].file = this.file;
					this.cache[i].number = i;
				}
			}
		}
Пример #11
0
 public FreeKey(ObjectKey key)
 {
     this.file     = key.file;
     this.position = key.position;
     this.length   = key.recLength;
 }
Пример #12
0
 public FreeKey(DataFile file, long position = -1L, int length = -1)
 {
     this.file     = file;
     this.position = position;
     this.length   = length;
 }
Пример #13
0
        public void Delete(string fileName, string objectName)
        {
            DataFile file = this.GetFile(fileName, FileMode.OpenOrCreate);

            file.Delete(objectName);
        }