Example #1
0
 it('returns all elements <= 6', function () {
     base.close();
     base = new qm.Base({ mode: 'open'});
     var result = base.search({ $from: 'BTreeSearchTest', Value: { $lt: 6}});
     assert.equal(result.length, 70);
     result.each(function (rec) { assert.equal(rec.Value <= 6, true); });
 })
Example #2
0
it("should make test number 8", function () {

 // import the qm module
 var qm = require('qminer');
 // create a base with a simple store
 var base = new qm.Base({
    mode: "createClean",
    schema: [
    {
        name: "Students",
        fields: [
            { name: "Id", type: "float" },
            { name: "TimeOfGraduation", type: "datetime" }
        ]
    }]
 });

 // create a new time series tick stream aggregator for the 'Students' store, that takes the values from the 'Id' field
 // and the timestamp from the 'TimeOfGraduation' field.
 var tick = {
    name: 'TimeSeriesTickAggr',
    type: 'timeSeriesTick',
    store: 'Students',
    timestamp: 'TimeOfGraduation',
    value: 'Id',
 };
 var timeSeriesTick = base.store("Students").addStreamAggr(tick);
 base.close();

});
Example #3
0
it("should make test number 3", function () {
 
 // import the qm module
 var qm = require('qminer');
 // create a base with a simple store
 var base = new qm.Base({
    mode: "createClean",
    schema: [
    {
        name: "Heat",
        fields: [
            { name: "Celcius", type: "float" },
            { name: "Time", type: "datetime" }
        ]
    }]
 });

 // create a new time series stream aggregator for the 'Heat' store, that takes the values from the 'Celcius' field
 // and the timestamp from the 'Time' field. The size of the window is 2 seconds (2000ms).
 var aggr = {
    name: 'TimeSeriesAggr',
    type: 'timeSeriesWinBuf',
    store: 'Heat',
    timestamp: 'Time',
    value: 'Celcius',
    winsize: 2000
 };
 base.store("Heat").addStreamAggr(aggr); 
 base.close();

});
Example #4
0
it("should make test number 4", function () {

 // import the qm module
 var qm = require('qminer');
 // create a base with a simple store
 var base = new qm.Base({
    mode: "createClean",
    schema: [
    {
        name: "Heat",
        fields: [
            { name: "Celcius", type: "float" },
            { name: "Time", type: "datetime" }
        ]
    }]
 });

 // create a new time series stream aggregator for the 'Heat' store. The size of the window is 3 records.
 var aggr = {
    name: 'Delay',
    type: 'recordBuffer',
    size: 3
 };
 base.store("Heat").addStreamAggr(aggr);
 base.close();

});
it("should make test number 35", function () {

	 // import qm module
	 var qm = require('qminer');
	 // create a simple base containing one store
	 var base = new qm.Base({
          mode: 'createClean',
          schema: [{
            name: 'Docs',
            fields: [
              { name: 'Time', type: 'datetime' },
              { name: 'Text', type: 'string' }
            ]
          }]
     });
     store = base.store('Docs');
	 // the following aggregate maintains a window buffer (1000 milliseconds) with no delay
	 // and contains a categorical feature extractor. The extractor maps records in the buffer
	 // to sparse vectors (indicator vectors for growing set of categories). Each record that
	 // enters the buffer updates the feature extractor (potentially introduces a new category,
	 // which increases the dimensionality).
	 var aggr = {
          type: 'timeSeriesWinBufFeatureSpace',
          store: 'Docs',
          timestamp: 'Time',
          featureSpace: {
            type: "categorical",
            source: "Docs",
            field: "Text"
          },
          winsize: 1000
     };
	 var streamAggregate = store.addStreamAggr(aggr);
	 store.push({ Time: '2015-06-10T14:13:32.0', Text: 'a' });
	 store.push({ Time: '2015-06-10T14:13:33.0', Text: 'b' });
	 store.push({ Time: '2015-06-10T14:13:34.0', Text: 'c' });
	 // we have three dimensions, where "a" -> [1,0,0], "b" -> [0,1,0], "c" -> [0,0,1]
	 // the first record just fell out of the buffer, the third record just entered the buffer
	 // and buffer currently contains the second and the third record.
	 // In case of the feature space based window buffer, the vectors of just-in, just-out and in-the-buffer
	 // values correspond to vectors of sparse vectors = sparse matrices.
	 streamAggregate.getInValueVector().print(); // one column, one nonzero element at index 2
	 // = [
     // 2 0 1.000000
     // ]
	 streamAggregate.getOutValueVector().print(); // one column, one nonzero element at index 0
	 // = [
	 // 0 0 1.000000
	 // ]
	 streamAggregate.getValueVector().print(); // two column vectors, each with one nonzero element
	 // = [
	 // 1 0 1.000000
	 // 2 1 1.000000
	 // ]
	 
	 base.close();
	
});
Example #6
0
var dataResampler = function () {
    var date = new Date().toISOString();
    var lastRandom = saBase.store('Random').last;
    if (Math.random() > 0.5) {
        if (lastRandom != null) { saBase.store('Random').push({ Value: lastRandom.Value + qm.la.randn(), Time: date }); }
        else { saBase.store('Random').push({ Value: qm.la.randn(), Time: date }); }
    }
    setTimeout(dataResampler, 1000);
};
Example #7
0
var dataStats = function () {
    var date = new Date().toISOString();
    var lastStat = saBase.store('Stats').last;
    if (lastStat != null) { saBase.store('Stats').push({ Value: lastStat.Value + qm.la.randn(), Time: date }); }
    else { saBase.store('Stats').push({ Value: qm.la.randn(), Time: date }); }

    saBase.store('Average').push({ Value: maAverage.getFloat(), Time: date });
    setTimeout(dataStats, 1000);
};
Example #8
0
var dataGauss = function () {
    var date = new Date().toISOString();
    var numBefore = saBase.store('Merger').length;
    // first store: Gauss
    if (Math.random() > 0.5) { saBase.store('Gauss').push({ Value: qm.la.randn(), Time: date }); };
    // second store: otherGauss
    if (Math.random() > 0.5) { saBase.store('OtherGauss').push({ Value: qm.la.randn(), Time: date }); };

    setTimeout(dataGauss, 1000);
};
Example #9
0
it("should make test number 12", function () {

 // import the qm module
 var qm = require('qminer');
 // create a base with a simple store
 var base = new qm.Base({
    mode: "createClean",
    schema: [
    {
        name: "Heat",
        fields: [
            { name: "Celcius", type: "float" },
            { name: "WaterConsumption", type: "float" },
            { name: "Time", type: "datetime" }
        ]
    }]
 });

 // create a new time series stream aggregator for the 'Heat' store, that takes the values from the 'Celcius' field
 // and the timestamp from the 'Time' field. The size of the window is 1 day.
 var celcius = {
    name: 'CelciusAggr',
    type: 'timeSeriesWinBuf',
    store: 'Heat',
    timestamp: 'Time',
    value: 'Celcius',
    winsize: 86400000
 }; base.store("Heat").addStreamAggr(celcius);

 // create a new time series stream aggregator for the 'Heat' store, that takes the values from the 'WaterConsumption' field
 // and the timestamp from the 'Time' field. The size of the window is 1 day.
 var water = {
    name: 'WaterAggr',
    type: 'timeSeriesWinBuf',
    store: 'Heat',
    timestamp: 'Time',
    value: 'WaterConsumption',
    winsize: 86400000
 }; base.store("Heat").addStreamAggr(water);

 // add a covariance aggregator, that is connected with the 'CelciusAggr' and 'WaterAggr' stream aggregators
 var covariance = {
    name: 'covAggr',
    type: 'covariance',
    store: 'Heat',
    inAggrX: 'CelciusAggr',
    inAggrY: 'WaterAggr'
 };
 var covarianceAggr = base.store("Heat").addStreamAggr(covariance);
 base.close();

});
Example #10
0
 beforeEach(function () {
     base = new qm.Base({
         mode: 'createClean',
         schema: [{
             name: 'Docs',
             fields: [
                 { name: 'Time', type: 'datetime' },
                 { name: 'Text', type: 'string' }
             ]
         }]
     });
     store = base.store('Docs');
 });
Example #11
0
 beforeEach(function (done) {
     base = new qm.Base({
         mode: 'createClean',
         schema: [{
             name: "Philosophers",
             fields: [
                 { name: "Name", type: "string" },
                 { name: "Era", type: "string" }
             ]
         }]
     });
     store = base.store("Philosophers");
     done();
 });
Example #12
0
 beforeEach(function () {
     base = new qm.Base({
         mode: 'createClean',
         schema: [{
             name: 'Function',
             fields: [
                 { name: 'Time', type: 'datetime' },
                 { name: 'X', type: 'float' },
                 { name: 'Y', type: 'float' }
             ]
         }]
     });
     store = base.store('Function');
 });
Example #13
0
it("should make test number 8", function () {

 var qm = require('qminer');
 var base = new qm.Base({
 	mode: 'createClean',
 	schema: [{
 		name: 'Docs',
 		fields: [
 			{ name: 'Time', type: 'datetime' },
 			{ name: 'Text', type: 'string' }
 		]
 	}]
 });
 var store = base.store('Docs');

 var aggr = {
 	name: 'featureSpaceWindow',
 	type: 'timeSeriesWinBufFeatureSpace',
 	store: 'Docs',
 	timestamp: 'Time',
 	featureSpace: {
 		type: "categorical",
 		source: "Docs",
 		field: "Text"
 	},
 	winsize: 1000
 };
 var sa = store.addStreamAggr(aggr);

 var aggr2 = {
 	name: 'sparseVectorSum',
 	type: 'winBufSpVecSum',
 	store: 'Docs',
 	inAggr: 'featureSpaceWindow'
 };
 var sa2 = store.addStreamAggr(aggr2);

 store.push({ Time: '2015-06-10T14:13:32.0', Text: 'a' }); // 0
 store.push({ Time: '2015-06-10T14:13:33.0', Text: 'b' }); // 1
 store.push({ Time: '2015-06-10T14:14:34.0', Text: 'c' }); // 2
 store.push({ Time: '2015-06-10T14:15:35.0', Text: 'd' }); // 3
 store.push({ Time: '2015-06-10T14:15:36.0', Text: 'e' }); // 4
 store.push({ Time: '2015-06-10T14:15:37.0', Text: 'f' }); // 5

 var valVec2 = sa2.getValueVector(); // [0, 0, 0, 0, 1, 1] - only vectors 4 and 5 remain in window

 base.close();

});
Example #14
0
it("should make test number 15", function () {

 // import the qm module
 var qm = require('qminer');
 // create a base with a simple store
 var base = new qm.Base({
    mode: "createClean",
    schema: [
    {
        name: "Cars",
        fields: [
            { name: "NumberOfCars", type: "float" },
            { name: "Time", type: "datetime" }
        ]
    },
    {
        name: "Temperature",
        fields: [
            { name: "Celcius", type: "float" },
            { name: "Time", type: "datetime" }
        ]
    },
    {
        name: "Merged",
        fields: [
            { name: "NumberOfCars", type: "float" },
            { name: "Celcius", type: "float" },
            { name: "Time", type: "datetime" }
        ]
    }]
 });
 // create a new merger stream aggregator that mergers the records of the 'Cars' and 'Temperature' stores.
 // The records are interpolated linearly and stored in the 'Merged' store.
 var mer = {
    name: 'MergerAggr',
    type: 'stmerger',
    outStore: 'Merged',
    createStore: false,
    timestamp: 'Time',
    fields: [
        { source: 'Cars', inField: 'NumberOfCars', outField: 'NumberOfCars', interpolation: 'linear', timestamp: 'Time' },
        { source: 'Temperature', inField: 'Celcius', outField: 'Celcius', interpolation: 'linear', timestamp: 'Time' }
    ]
 };
 var merger = new qm.StreamAggr(base, mer);
 base.close();

});
Example #15
0
it("should make test number 2", function () {

 // import qm module
 var qm = require('qminer');
 // create a simple base containing one store
 var base = new qm.Base({
    mode: "createClean",
    schema: [{
        name: "People",
        fields: [
            { name: "Name", type: "string" },
            { name: "Gendre", type: "string" },
        ]
    },
    {
        name: "Laser",
        fields: [
            { name: "Time", type: "datetime" },
            { name: "WaveLength", type: "float" }
        ]
    }]
 });

 // create a new stream aggregator for 'People' store, get the length of the record name (with the function object)
 var aggr = new qm.StreamAggr(base, new function () {
    var length = 0;
    this.name = 'nameLength',
    this.onAdd = function (rec) {
        length = rec.Name.length;
    };
    this.saveJson = function (limit) {
        return { val: length };
    }
 }, "People");

 // create a new time series window buffer stream aggregator for 'Laser' store (with the JSON object)
 var wavelength = {
     name: "WaveLengthLaser",
     type: "timeSeriesWinBuf",
     store: "Laser",
     timestamp: "Time",
     value: "WaveLength",
     winsize: 10000
 }
 var sa = base.store("Laser").addStreamAggr(wavelength);
 base.close();

});
Example #16
0
 /**
  * Adds a stream aggr to the base.
  * @param {String} storeName - Store name.
  * @param {Object} opts - The stream aggr options.
  */
 _addStreamAggr(singleStore, opts, storeName) {
     if (singleStore) {
         this.base.store(storeName).addStreamAggr(opts);
     } else {
         new qm.StreamAggr(this.base, opts);
     }
 }
Example #17
0
 it("should create a record when store has a field of type 'json'", function () {       
     var basePlanets = new qm.Base({
         mode: "createClean",
         schema: [{
             name: "Planets",
             fields: [
                 { name: "Name", type: "string" },
                 { name: "Diameter", type: "int" },
                 { name: "NearestStars", type: "string_v" },
                 { name: "Json", type: "json" }
             ]
         }]
       });
     planet = basePlanets.store("Planets").newRecord({ Name: "Tatooine", Diameter: 10465, NearestStars: ["Tatoo 1", "Tatoo 2"], Json: {fruit: "banana"} });
     assert.deepEqual(planet.Json, {fruit: "banana"});
 });
Example #18
0
    beforeEach(function () {
        base = new qm.Base({ mode: 'createClean' });
        base.createStore({
            "name": store_name,
            "fields": [
                { "name": "title", "type": "string", "store" : "cache" },
                { "name": "src", "type": "string", "store" : "cache" },
                { "name": "ts", "type": "datetime", "store": "cache" }
            ]
        });
        store = base.store(store_name);

        store.push({title: "title1", src: "src1", ts: now});
        store.push({title: "title2", src: "src1", ts: now + 2 * 60 * 1000 });
        store.push({title: "title3", src: "src2", ts: now + 7 * 60 * 1000 });
        store.push({title: "title4", src: "src3", ts: now + 14 * 60 * 1000 });
    });
Example #19
0
it("should make test number 17", function () {

 // import the qm module
 var qm = require('qminer');
 // create a base with a simple store
 var base = new qm.Base({
    mode: "createClean",
    schema: [
    {
        name: "Heat",
        fields: [
            { name: "Celcius", type: "float" },
            { name: "Time", type: "datetime" }
        ]
    }]
 });

 // create a new time series stream aggregator for the 'Heat' store, that takes the values from the 'Celcius' field
 // and the timestamp from the 'Time' field. The size of the window is 4 weeks.
 var timeser = {
    name: 'TimeSeriesBuffer',
    type: 'timeSeriesWinBuf',
    store: 'Heat',
    timestamp: 'Time',
    value: 'Celcius',
    winsize: 2419200000 // 4 weeks
 };
 var timeSeries = base.store("Heat").addStreamAggr(timeser);

 // add a slotted-histogram aggregator, that is connected with the 'TimeSeriesAggr' aggregator
 // it will present accumulated histogram for the last 2 hours (window) of the week (period) for the last 4 weeks (see aggregate above)
 var aggrJson = {
    name: 'Histogram',
    type: 'onlineSlottedHistogram',
    store: 'Heat',
    inAggr: 'TimeSeriesBuffer',
    period: 604800000, // 1 week
    window: 7200000, // 2h
    bins: 5, // 5 possible clusters
    granularity: 300000  // 5 min
 };
 var hist = base.store("Heat").addStreamAggr(aggrJson);
 base.close();

});
Example #20
0
it("should make test number 16", function () {

 // import the qm module
 var qm = require('qminer');
 // create a base with a simple store
 var base = new qm.Base({
    mode: "createClean",
    schema: [
    {
        name: "Heat",
        fields: [
            { name: "Celcius", type: "float" },
            { name: "Time", type: "datetime" }
        ]
    }]
 });

 // create a new time series stream aggregator for the 'Heat' store, that takes the values from the 'Celcius' field
 // and the timestamp from the 'Time' field. The size of the window is 1 day.
 var timeser = {
    name: 'TimeSeriesBuffer',
    type: 'timeSeriesWinBuf',
    store: 'Heat',
    timestamp: 'Time',
    value: 'Celcius',
    winsize: 86400000 // one day in miliseconds
 };
 var timeSeries = base.store("Heat").addStreamAggr(timeser);

 // add a histogram aggregator, that is connected with the 'TimeSeriesAggr' aggregator
 var aggrJson = {
    name: 'Histogram',
    type: 'onlineHistogram',
    store: 'Heat',
    inAggr: 'TimeSeriesBuffer',
    lowerBound: 0,
    upperBound: 10,
    bins: 5,
    addNegInf: false,
    addPosInf: false
 };
 var hist = base.store("Heat").addStreamAggr(aggrJson);
 base.close();

});
Example #21
0
it("should make test number 10", function () {

 // import the qm module
 var qm = require('qminer');
 // create a base with a simple store
 var base = new qm.Base({
    mode: "createClean",
    schema: [
    {
        name: "Heat",
        fields: [
            { name: "Celcius", type: "float" },
            { name: "Time", type: "datetime" }
        ]
    }]
 });

 // create a new time series tick stream aggregator for the 'Heat' store, that takes the values from the 'Celcius' field
 // and the timestamp from the 'Time' field. The size of the window should be 1 hour.
 var timeser = {
    name: 'TimeSeriesAggr',
    type: 'timeSeriesTick',
    store: 'Heat',
    timestamp: 'Time',
    value: 'Celcius',
    winsize: 3600000
 };
 var timeSeries = base.store("Heat").addStreamAggr(timeser);

 // add an exponentional moving average aggregator, that is connected with the 'TimeSeriesAggr' aggregator.
 // It should interpolate with the previous value, the decay should be 3 seconds and the initWindow should be 2 seconds.
 var ema = {
    name: 'emaAggr',
    type: 'ema',
    store: 'Heat',
    inAggr: 'TimeSeriesAggr',
    emaType: 'previous',
    interval: 3000,
    initWindow: 2000
 };
 var expoMovingAverage = base.store("Heat").addStreamAggr(ema);
 base.close();

});
Example #22
0
it("should make test number 14", function () {

 // import the qm module
 var qm = require('qminer');
 // create a base with a simple store
 var base = new qm.Base({
    mode: "createClean",
    schema: [
    {
        name: "Heat",
        fields: [
            { name: "Celcius", type: "float" },
            { name: "Time", type: "datetime" }
        ]
    },
    {
        name: "interpolatedValues",
        fields: [
            { name: "Value", type: "float" },
            { name: "Time", type: "datetime" }
        ]
    }]
 });
 // create a new resampler stream aggregator for the 'Heat' store, that takes the values from the 'Celcius' field
 // and the timestamp from the 'Time' field. The interpolated values are stored in the 'interpolatedValues' store.
 // The interpolation should be linear and the interval should be 2 seconds.
 var res = {
    name: 'resamplerAggr',
    type: 'resampler',
    store: 'Heat',
    outStore: 'interpolatedValues',
    timestamp: 'Time',
    fields: [{
        name: 'Celcius',
        interpolator: 'linear'
    }],
    createStore: false,
    interval: 2000
 };
 var resampler = base.store("Heat").addStreamAggr(res);
 base.close();

});
Example #23
0
	it('should survive', function () {
	

var base1 = new qm.Base({
    mode: 'createClean',
    schema: [
      {
          name: 'People',
          fields: [{ name: 'name', type: 'string', null: true }],
      }
    ],
    dbPath: './db1'
});

var store1 = base1.store("People");
store1.add({ name: "Jan" });
store1.add({ name: null });
assert(store1.length == 2);
base1.close();
})});
Example #24
0
    beforeEach(function () {
        qm.delLock();
        base = new qm.Base({mode: 'createClean'});
		// prepare test set
        base.createStore({
            'name': 'BTreeSearchTest',
            'fields': [
              { 'name': 'Value', 'type': 'float' },
              { 'name': 'ForSort', 'type': 'float' }
            ],
            'joins': [],
            'keys': [
                { field: 'Value', type: 'linear' }
            ]
        });
        store = base.store('BTreeSearchTest');
        for (var i = 0; i < 100; i++) {
            store.push({ Value: (i % 10) + 0.123, ForSort: Math.random() });
        }
    });
Example #25
0
it("should make test number 5", function () {

 // import the qm module
 var qm = require('qminer');
 // create a base with a simple store
 var base = new qm.Base({
    mode: "createClean",
    schema: [
    {
        name: "Income",
        fields: [
            { name: "Amount", type: "float" },
            { name: "Time", type: "datetime" }
        ]
    }]
 });

 // create a new time series stream aggregator for the 'Income' store, that takes the values from the 'Amount' field
 // and the timestamp from the 'Time' field. The size of the window should 1 week.
 var timeser = {
    name: 'TimeSeriesAggr',
    type: 'timeSeriesWinBuf',
    store: 'Income',
    timestamp: 'Time',
    value: 'Amount',
    winsize: 604800000 // 7 days in miliseconds
 };
 var timeSeries = base.store("Income").addStreamAggr(timeser);

 // add a sum aggregator, that is connected with the 'TimeSeriesAggr' aggregator
 var sum = {
    name: 'SumAggr',
    type: 'winBufSum',
    store: 'Heat',
    inAggr: 'TimeSeriesAggr'
 };
 var sumAggr = base.store("Income").addStreamAggr(sum);
 base.close();

});
Example #26
0
it("should make test number 26", function () {

	 // import qm module
	 var qm = require('qminer');
	 // create a simple base containing one store
	 var base = new qm.Base({
	    mode: 'createClean',
	    schema: [{
	        name: 'Signals',
	        fields: [
	            { name: 'BeepLoudness', type: 'float' },
	            { name: 'Time', type: 'datetime' }
	        ]
	    }]
	 });
	 // create a time series stream aggregator that gets the values from the 'BeepLoudness' field and
	 // the timestamp from the 'Time' field. The window size should be 10 seconds.
	 var ts = {
	    name: 'SignalBeep',
	    type: 'timeSeriesWinBuf',
	    store: 'Signals',
	    timestamp: 'Time',
	    value: 'BeepLoudness',
	    winsize: 10000
	 };
	 var signalBeep = base.store('Signals').addStreamAggr(ts);
	 // add some records to the store
	 base.store('Signals').push({ BeepLoudness: 10, Time: '2015-07-21T12:30:30.0' });
	 base.store('Signals').push({ BeepLoudness: 25, Time: '2015-07-21T12:30:31.0' });
	 base.store('Signals').push({ BeepLoudness: 20, Time: '2015-07-21T12:30:32.0' });
	 // get the timestamp vector of signalBeep
	 var vec = signalBeep.getTimestampVector(); // returns vector [13081955430000, 13081955431000, 13081955432000]
	 base.close();
	
});
Example #27
0
it("should make test number 9", function () {

 // import the qm module
 var qm = require('qminer');
 // create a base with a simple store
 var base = new qm.Base({
    mode: "createClean",
    schema: [
    {
        name: "Heat",
        fields: [
            { name: "Celcius", type: "float" },
            { name: "Time", type: "datetime" }
        ]
    }]
 });

 // create a new time series stream aggregator for the 'Heat' store, that takes the values from the 'Celcius' field
 // and the timestamp from the 'Time' field. The size of the window should be 1 day.
 var timeser = {
    name: 'TimeSeriesAggr',
    type: 'timeSeriesWinBuf',
    store: 'Heat',
    timestamp: 'Time',
    value: 'Celcius',
    winsize: 86400000
 };
 var timeSeries = base.store("Heat").addStreamAggr(timeser);

 // add a moving average aggregator, that is connected with the 'TimeSeriesAggr' aggregator
 var ma = {
    name: 'movingAverageAggr',
    type: 'ma',
    store: 'Heat',
    inAggr: 'TimeSeriesAggr'
 };
 var movingAverage = base.store("Heat").addStreamAggr(ma);
 base.close();

});
Example #28
0
    beforeEach(function () {
        qm.delLock();
        base = new qm.Base({mode: 'createClean'});
		// prepare test set
        base.createStore({
            'name': 'BTreeSearchTest',
            'fields': [
              { 'name': 'Value', 'type': 'datetime' },
              { 'name': 'ForSort', 'type': 'float' }
            ],
            'joins': [],
            'keys': [
                { field: 'Value', type: 'linear' }
            ]
        });
        store = base.store('BTreeSearchTest');
        var date = new Date('2015-09-27T00:00:00.000Z');
        for (var i = 0; i < 100; i++) {
            var _date = new Date(date.getTime() + (i % 10)*60*60*1000);
            store.push({ Value: _date.toISOString(), ForSort: Math.random() });
        }
    });
Example #29
0
it("should make test number 24", function () {

	 // import qm module
	 var qm = require('qminer');
	 // create a simple base containing one store
	 var base = new qm.Base({
	    mode: 'createClean',
	    schema: [{
	        name: 'Medicine',
	        fields: [
	            { name: 'NumberOfPills', type: 'float' },
	            { name: 'Time', type: 'datetime' }
            ]
	    }]
	 });
	 // create a time series stream aggregator that takes the values from the 'NumberOfPills' field
	 // and the timestamp from the 'Time' field. The window size should be 1 week.
	 var ts = {
	    name: 'WeekPills',
	    type: 'timeSeriesWinBuf',
	    store: 'Medicine',
	    timestamp: 'Time',
	    value: 'NumberOfPills',
	    winsize: 604800000
	 };
	 var weekly = base.store('Medicine').addStreamAggr(ts);
	 // add some records in the store
	 base.store('Medicine').push({ NumberOfPills: 4, Time: '2015-07-21T09:00:00.0' });
	 base.store('Medicine').push({ NumberOfPills: 5, Time: '2015-07-21T19:00:00.0' });
	 base.store('Medicine').push({ NumberOfPills: 4, Time: '2015-07-22T09:00:00.0' });
	 base.store('Medicine').push({ NumberOfPills: 5, Time: '2015-07-22T19:00:00.0' });
	 base.store('Medicine').push({ NumberOfPills: 4, Time: '2015-07-23T09:00:00.0' });
	 base.store('Medicine').push({ NumberOfPills: 6, Time: '2015-07-23T19:00:00.0' });
	 base.store('Medicine').push({ NumberOfPills: 4, Time: '2015-07-24T09:00:00.0' });
	 // get the length of the timestamp vector
	 var length = weekly.getTimestampLength(); // returns 7
	 base.close();
	
});
Example #30
0
it("should make test number 32", function () {

	 // import qm module
	 var qm = require('qminer');
	 // create a simple base containing one store
	 var base = new qm.Base({
	    mode: 'createClean',
	    schema: [{
	        name: 'Noise',
	        fields: [
	            { name: 'Decibels', type: 'float' },
	            { name: 'Time', type: 'datetime' }
	        ]
	    }]
	 });
	 // create a time series stream aggregator that takes the values from the 'Decibels' field
	 // and timestamps from the 'Time' fields. The window size should be 1 second.
	 var ts = {
	    name: 'Music',
	    type: 'timeSeriesWinBuf',
	    store: 'Noise',
	    timestamp: 'Time',
	    value: 'Decibels',
	    winsize: 1000
	 };
	 var music = base.store('Noise').addStreamAggr(ts);
	 // add some records in the store
	 base.store('Noise').push({ Decibels: 54, Time: '2015-07-21T14:43:00.0' });
	 base.store('Noise').push({ Decibels: 55, Time: '2015-07-21T14:43:00.200' });
	 base.store('Noise').push({ Decibels: 54, Time: '2015-07-21T14:43:00.400' });
	 base.store('Noise').push({ Decibels: 53, Time: '2015-07-21T14:43:00.600' });
	 base.store('Noise').push({ Decibels: 53, Time: '2015-07-21T14:43:00.800' });
	 base.store('Noise').push({ Decibels: 54, Time: '2015-07-21T14:43:01.0' });
	 base.store('Noise').push({ Decibels: 53, Time: '2015-07-21T14:43:01.2' });
	 // get the timestamps that just left the window buffer by adding the last record
	 var last = music.getOutTimestampVector(); // returns [13081963380000]
	 base.close();
	
});