예제 #1
0
        public override void LoadIndex()
        {
            ushort     maskval = (ushort)(Math.Log(Globals.SaxMaxCard, 2) - Math.Log(Globals.SaxBaseCard, 2));
            SaxOptions opts    = new SaxOptions(Util.UnsignedShortArray(Globals.SaxWordLength, maskval));

            this.sr = new StreamReader(this.dataFile);

            while (!(this.allRead && this.buffer.Count == 0))
            {
                if (this.buffer.Count == 0)
                {
                    Console.WriteLine(this.processed);
                    string line;
                    while ((line = this.sr.ReadLine()) != null)
                    {
                        double[] ts = Util.NormalizationHandler(Util.StringToArray(line));
                        if (!this.tsLength.HasValue)
                        {
                            this.tsLength = (uint)ts.Length;
                        }
                        else
                        if (this.tsLength.Value != ts.Length)
                        {
                            throw new ApplicationException("Inconsistent length when reading from file.");
                        }

                        this.buffer.Enqueue(ts);
                        if (this.buffer.Count == this.bufferSize)
                        {
                            break;
                        }
                    }
                    if (line == null)
                    {
                        this.allRead = true;
                    }
                }
                else
                {
                    double[]    tmp = this.buffer.Dequeue();
                    IDataFormat dl  = new RawDataFormat(tmp);
                    this.si.Insert(new SaxData(dl, Sax.ArrayToSaxVals(tmp, opts)));
                    this.processed++;
                }
            }

            this.sr.Close();
            //this.si.ForceFlushBuffers();
            this.si.FlushEntries();
            Console.WriteLine("Total: {0}", this.processed);
        }
예제 #2
0
        public override void LoadIndex()
        {
            Util.SeedGenerator(seed);
            ushort     maskval = (ushort)(Math.Log(Globals.SaxMaxCard, 2) - Math.Log(Globals.SaxBaseCard, 2));
            SaxOptions opts    = new SaxOptions(Util.UnsignedShortArray(Globals.SaxWordLength, maskval));

            double[]    ts;
            IDataFormat dl;

            while (this.processed < this.numTs)
            {
                ts = Util.RandomWalk(this.tsLength);
                dl = new RawDataFormat(ts);
                this.si.Insert(new SaxData(dl, Sax.ArrayToSaxVals(ts, opts)));  // Continuesly insertion on the first level of buffers ( with no threshold )
                this.processed++;
                Console.Write("\r{0}", this.processed);
                if (this.processed % Globals.FlushTsVal == 0)       // When reachs the value flush on disk
                {
                    this.si.FlushEntries();
                }
            }
            this.si.FlushEntries();
            Console.WriteLine();
        }