qminer
Version:
A C++ based data analytics platform for processing large-scale real-time streams containing structured and unstructured data
1,140 lines (1,137 loc) • 75.2 kB
HTML
<!doctype html>
<html>
<head>
<meta name="generator" content="JSDoc 3">
<meta charset="utf-8">
<title>Class: Store</title>
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Noto+Serif:400,400i,700,700i" type="text/css">
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
<link href="css/baseline.css" rel="stylesheet">
</head>
<body onload="prettyPrint()">
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
<div id="jsdoc-navbar-container">
<div id="jsdoc-navbar-content">
<a href="index.html" class="jsdoc-navbar-package-name">QMiner JavaScript API v9.4.0</a>
</div>
</div>
</nav>
<div id="jsdoc-body-container">
<div id="jsdoc-content">
<div id="jsdoc-content-container">
<div id="jsdoc-main" role="main">
<header class="page-header">
<div class="symbol-detail-labels"><span class="label label-kind">class</span> <span class="label label-static">static</span></div>
<h1><small><a href="module-qm.html">qm</a>.<wbr></small><span class="symbol-name">Store</span></h1>
<p class="source-link">Source: <a href="qminerdoc.js.html#source-line-817">qminerdoc.<wbr>js:817</a></p>
<dl class="dl-compact">
</dl>
</header>
<section id="summary">
<div class="summary-callout">
<h2 class="summary-callout-heading">Properties</h2>
<div class="summary-content">
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="module-qm.Store.html#allRecords">allRecords</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#backwardIter">backwardIter</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#base">base</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#empty">empty</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="module-qm.Store.html#fields">fields</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#first">first</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#forwardIter">forwardIter</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#joins">joins</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="module-qm.Store.html#keys">keys</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#last">last</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#length">length</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#name">name</a></dt>
<dd>
</dd>
</dl>
</div>
</div>
</div>
<div class="summary-callout">
<h2 class="summary-callout-heading">Methods</h2>
<div class="summary-content">
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="module-qm.Store.html#addStreamAggr">addStreamAggr(arg)</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#addTrigger">addTrigger(trigger)</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#cell">cell(recId, fieldName)</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#clear">clear([num])</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#each">each(callback)</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#field">field(fieldName)</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#getMatrix">getMatrix(fieldName)</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#getStreamAggrNames">getStreamAggrNames()</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="module-qm.Store.html#getVector">getVector(fieldName)</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#inspect">inspect(depth)</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#isDate">isDate(fieldName)</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#isNumeric">isNumeric(fieldName)</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#isString">isString(fieldName)</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#key">key(keyName)</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#loadJson">loadJson(file[, limit])</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#map">map(callback)</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="module-qm.Store.html#newRecord">newRecord(obj)</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#newRecordSet">newRecordSet(idVec)</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#push">push(rec[, triggerEvents])</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#recordByName">recordByName(recName)</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#resetStreamAggregates">resetStreamAggregates()</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#sample">sample(sampleSize)</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#toJSON">toJSON()</a></dt>
<dd>
</dd>
<dt><a href="module-qm.Store.html#triggerOnAddCallbacks">triggerOnAddCallbacks([arg])</a></dt>
<dd>
</dd>
</dl>
</div>
</div>
</div>
</section>
<section>
<h2 id="Store"><span class="symbol-name">Store</span><span class="signature"><span class="signature-params">()</span></span></h2>
<p>Stores are containers of records. <br>
<b>Factory pattern:</b> this class cannot be construced using the new keyword. This class is constructed when
calling a specific method or attribute, e.g. constructing the <a href="module-qm.Base.html">module:qm.Base</a> using schema or with the
<a href="module-qm.Base.html#createStore">module:qm.Base#createStore</a>.
</p>
<section>
<h3>
Examples
</h3>
<div>
<p>Creating a store with createStore function</p>
<pre class="prettyprint"><code>// import qm module
var qm = require('qminer');
// factory based construction using base.createStore
var base = new qm.Base({ mode: 'createClean' });
base.createStore([{
name: "People",
fields: [
{ name: "Name", type: "string", primary: true },
{ name: "Gender", type: "string", shortstring: true },
{ name: "Age", type: "int" }
],
joins: [
{ name: "ActedIn", type: "index", store: "Movies", inverse: "Actor" },
{ name: "Directed", type: "index", store: "Movies", inverse: "Director" }
],
keys: [
{ field: "Name", type: "text" },
{ field: "Gender", type: "value" }
]
},
{
name: "Movies",
fields: [
{ name: "Title", type: "string", primary: true },
{ name: "Plot", type: "string", store: "cache" },
{ name: "Year", type: "int" },
{ name: "Rating", type: "float" },
{ name: "Genres", type: "string_v", codebook: true }
],
joins: [
{ name: "Actor", type: "index", store: "People", inverse: "ActedIn" },
{ name: "Director", type: "index", store: "People", inverse: "Directed" }
],
keys: [
{ field: "Title", type: "value" },
{ field: "Plot", type: "text", vocabulary: "voc_01" },
{ field: "Genres", type: "value" }
]
}]);
base.close();</code></pre>
</div>
<div>
<p>Creating store with schema in base constructor</p>
<pre class="prettyprint"><code>// import qm module
var qm = require('qminer');
// using the base constructor
var base = new qm.Base({
mode: "createClean",
schema: [{
name: "Class",
fields: [
{ name: "Name", type: "string" },
{ name: "StudyGroup", type: "string" }
]
}]
});
base.close();</code></pre>
</div>
</section>
<dl class="dl-compact">
</dl>
</section>
<section>
<h2>Properties</h2>
<section>
<h3 id="allRecords"><span class="symbol-name">allRecords</span></h3>
<p>Creates a record set containing all the records from the store. Type <a href="module-qm.RecordSet.html">module:qm.RecordSet</a>.</p>
<dl class="dl-compact">
</dl>
<h3 id="backwardIter"><span class="symbol-name">backwardIter</span></h3>
<p>Returns an iterator for iterating over the store form end to start. Type <a href="module-qm.Iterator.html">module:qm.Iterator</a>.</p>
<dl class="dl-compact">
</dl>
<h3 id="base"><span class="symbol-name">base</span></h3>
<p>Returns the base, in which the store is contained. Type <a href="module-qm.Base.html">module:qm.Base</a>.</p>
<dl class="dl-compact">
</dl>
<h3 id="empty"><span class="symbol-name">empty</span></h3>
<p>Checks if the store is empty. Type <code>boolean</code>.</p>
<dl class="dl-compact">
</dl>
<h3 id="fields"><span class="symbol-name">fields</span></h3>
<p>Gives an array of all field descriptor objects. Type <code>Array of objects</code>, where the objects contain the properties:
<br>1. <code>id</code> - The ID of the field. Type B4numberB4.
<br>2. <code>name</code> - The name of the field. Type <code>string</code>.
<br>3. <code>type</code> - The type of the field. Type <code>string</code>.
<br>4. <code>nullable</code> - If the field value can be null. Type <code>boolean</code>.
<br>5. <code>internal</code> - If the field is internal. Type <code>boolean</code>.
<br>6. <code>primary</code> - If the field is primary. Type <code>boolean</code>.
</p>
<dl class="dl-compact">
</dl>
<h3 id="first"><span class="symbol-name">first</span></h3>
<p>Returns the first record of the store. Type <a href="module-qm.Record.html">module:qm.Record</a>.</p>
<dl class="dl-compact">
</dl>
<h3 id="forwardIter"><span class="symbol-name">forwardIter</span></h3>
<p>Returns an iterator for iterating over the store from start to end. Type <a href="module-qm.Iterator.html">module:qm.Iterator</a>.</p>
<dl class="dl-compact">
</dl>
<h3 id="joins"><span class="symbol-name">joins</span></h3>
<p>Gives an array of all join descriptor objects. Type <code>Array of objects</code>, where the objects contain the properties:
<br>1. <code>id</code> - The ID of the join. Type B4numberB4.
<br>2. <code>name</code> - The name of the join. Type <code>string</code>.
<br>2. <code>store</code> - The store the join was created in. Type <code>string</code>.
<br>2. <code>inverse</code> - The inverse join. Type <code>string</code>.
<br>3. <code>type</code> - The type of the field. Type <code>string</code>.
<br>4. <code>key</code> - The index key. Type <a href="module-qm.html#~DetailKeyObject">module:qm~DetailKeyObject</a>.
</p>
<dl class="dl-compact">
</dl>
<h3 id="keys"><span class="symbol-name">keys</span></h3>
<p>Gives an array of all key descriptor objects. Type <code>Array of <a href="module-qm.html#~DetailKeyObject">module:qm~DetailKeyObject</a></code>.</p>
<dl class="dl-compact">
</dl>
<h3 id="last"><span class="symbol-name">last</span></h3>
<p>Returns the last record of the store. Type <a href="module-qm.Record.html">module:qm.Record</a>.</p>
<dl class="dl-compact">
</dl>
<h3 id="length"><span class="symbol-name">length</span></h3>
<p>Gives the number of records. Type <code>number</code>.</p>
<dl class="dl-compact">
</dl>
<h3 id="name"><span class="symbol-name">name</span></h3>
<p>Gives the name of the store. Type <code>string</code>.</p>
<dl class="dl-compact">
</dl>
</section>
<h2>Methods</h2>
<section>
<h3 id="addStreamAggr"><span class="symbol-name">addStreamAggr</span><span class="signature"><span class="signature-params">(arg)</span></span></h3>
<p>Adds a stream aggregate to the store. For use example see <a href="module-qm.StreamAggr.html">module:qm.StreamAggr</a> constructor example.</p>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>arg</p>
</td>
<td>
<p>(<a href="module-qm.html#~StreamAggregator">module:qm~StreamAggregator</a> or function())</p>
</td>
<td>
<p> </p>
</td>
<td>
<p>Constructor arguments. There are two argument types:
<br>1. Using the <a href="module-qm.html#~StreamAggregator">module:qm~StreamAggregator</a> object,
<br>2. using a function/JavaScript class. The function has defined The object containing the schema of the stream aggregate or the function object defining the operations of the stream aggregate.
</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
</dl>
<h3 id="addTrigger"><span class="symbol-name">addTrigger</span><span class="signature"><span class="signature-params">(trigger)</span></span></h3>
<p>Adds a stream aggregate to a store.</p>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>trigger</p>
</td>
<td>
<p>function()</p>
</td>
<td>
<p> </p>
</td>
<td>
<p>The trigger containing the method <a href="module-qm.StreamAggr.html#onAdd">module:qm.StreamAggr#onAdd</a> and optional
<a href="module-qm.StreamAggr.html#onUpdate">module:qm.StreamAggr#onUpdate</a> and <a href="module-qm.StreamAggr.html#onDelete">module:qm.StreamAggr#onDelete</a>.
</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
</dl>
<h3 id="cell"><span class="symbol-name">cell</span><span class="signature"><span class="signature-params">(recId, fieldName)</span> → <span class="signature-returns"> (number, string, Array of number, or Array of string)</span></span></h3>
<p>Gives the field value of a specific record.</p>
<section>
<h4>
Example
</h4>
<div>
<pre class="prettyprint"><code>//import qm module
var qm = require('qminer');
// create a new base containing one store
var base = new qm.Base({
mode: "createClean",
schema: [{
name: "Festivals",
fields: [
{ name: "Name", type: "string" },
{ name: "Type", type: "string" },
{ name: "Location", type: "string" }
]
}]
});
// add some records in the store
base.store("Festivals").push({ Name: "Metaldays", Type: "music", Location: "Tolmin, Slovenia" });
base.store("Festivals").push({ Name: "Festival de Cannes", Type: "movie", Location: "Cannes, France" });
base.store("Festivals").push({ Name: "The Festival of Chocolate", Type: "food", Location: "Hillsborough, USA" });
// get the field value of the second record for field "Type"
var fieldValue = base.store("Festivals").cell(1, "Type"); // returns "movie"
base.close();</code></pre>
</div>
</section>
<section>
<h4>Parameters</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>recId</p>
</td>
<td>
<p>number</p>
</td>
<td>
<p> </p>
</td>
<td>
<p>The record id.</p>
</td>
</tr>
<tr>
<td>
<p>fieldName</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p> </p>
</td>
<td>
<p>The field name.</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>(number, string, Array of number, or Array of string)</code>B The <code>fieldName</code> value of the record with ID <code>recId</code>.</p>
</dd>
</dl>
<h3 id="clear"><span class="symbol-name">clear</span><span class="signature"><span class="signature-params">([num])</span> → <span class="signature-returns"> number</span></span></h3>
<p>Deletes the first records in the store.</p>
<section>
<h4>
Example
</h4>
<div>
<pre class="prettyprint"><code>// import qm module
var qm = require('qminer');
// create a base containing one store
var base = new qm.Base({
mode: "createClean",
schema: [{
name: "TVSeries",
fields: [
{ name: "Title", type: "string", primary: true },
{ name: "NumberOfEpisodes", type: "int" }
]
}]
});
// add some records in the store
base.store("TVSeries").push({ Title: "Archer", NumberOfEpisodes: 75 });
base.store("TVSeries").push({ Title: "The Simpsons", NumberOfEpisodes: 574 });
base.store("TVSeries").push({ Title: "New Girl", NumberOfEpisodes: 94 });
base.store("TVSeries").push({ Title: "Rick and Morty", NumberOfEpisodes: 11 });
base.store("TVSeries").push({ Title: "Game of Thrones", NumberOfEpisodes: 47 });
// deletes the first 2 records (Archer and The Simpsons) in TVSeries
base.store("TVSeries").clear(2); // returns 3
// delete all remaining records in TVStore
base.store("TVSeries").clear(); // returns 0
base.close();</code></pre>
</div>
</section>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>num</p>
</td>
<td>
<p>number</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
<p>The number of deleted records. If the number is given, the first <code>num</code> records will be deleted.</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>number</code>B The number of remaining records in the store.</p>
</dd>
</dl>
<h3 id="each"><span class="symbol-name">each</span><span class="signature"><span class="signature-params">(callback)</span> → <span class="signature-returns"> <a href="module-qm.Store.html">module:qm.Store</a></span></span></h3>
<p>Executes a function on each record in store.</p>
<section>
<h4>
Example
</h4>
<div>
<pre class="prettyprint"><code>// import qm module
var qm = require('qminer');
// create a base containing the store Class
var base = new qm.Base({
mode: "createClean",
schema: [{
name: "Class",
fields: [
{ name: "Name", type: "string" },
{ name: "StudyGroup", type: "string" }
]
}]
});
// add some records to the store
base.store("Class").push({ Name: "Abed", StudyGroup: "A" });
base.store("Class").push({ Name: "Annie", StudyGroup: "B" });
base.store("Class").push({ Name: "Britta", StudyGroup: "C" });
base.store("Class").push({ Name: "Jeff", StudyGroup: "A" });
// change the StudyGroup of all records of store Class to A
base.store("Class").each(function (rec) { rec.StudyGroup = "A"; }); // all records in Class are now in study group A
base.close();</code></pre>
</div>
</section>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>callback</p>
</td>
<td>
<p>function()</p>
</td>
<td>
<p> </p>
</td>
<td>
<p>Function to be executed. It takes two parameters:
<br>1. <code>rec</code> - The current record. Type <a href="module-qm.Record.html">module:qm.Record</a>.
<br>2. <code>idx</code> - The index of the current record (<i>optional</i>). Type <code>number</code>.
</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code><a href="module-qm.Store.html">module:qm.Store</a></code>B Self.</p>
</dd>
</dl>
<h3 id="field"><span class="symbol-name">field</span><span class="signature"><span class="signature-params">(fieldName)</span> → <span class="signature-returns"> object</span></span></h3>
<p>Gets the details of the selected field.</p>
<section>
<h4>
Example
</h4>
<div>
<pre class="prettyprint"><code>// import qm module
var qm = require("qminer");
// create a new base containing one store
var base = new qm.Base({
mode: "createClean",
schema: [{
name: "People",
fields: [
{ name: "Name", type: "string", primary: true },
{ name: "Gender", type: "string" },
{ name: "Age", type: "int" }
]
}]
});
// get the details of the field "Name" of store "People"
// it returns a JSON object:
// { id: 0, name: "Name", type: "string", primary: true, nullable: false, internal: false }
var details = base.store("People").field("Name");
base.close();</code></pre>
</div>
</section>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>fieldName</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p> </p>
</td>
<td>
<p>The field name.</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>object</code>B The object containing the details of the field. The properties are:
<br>1. <code>id</code> - The ID of the field. Type B4numberB4.
<br>2. <code>name</code> - The name of the field. Type <code>string</code>.
<br>3. <code>type</code> - The type of the field. Type <code>string</code>.
<br>4. <code>nullable</code> - If the field value can be null. Type <code>boolean</code>.
<br>5. <code>internal</code> - If the field is internal. Type <code>boolean</code>.
<br>6. <code>primary</code> - If the field is primary. Type <code>boolean</code>.
</p>
</dd>
</dl>
<h3 id="getMatrix"><span class="symbol-name">getMatrix</span><span class="signature"><span class="signature-params">(fieldName)</span> → <span class="signature-returns"> (<a href="module-la.Matrix.html">module:la.Matrix</a> or <a href="module-la.SparseMatrix.html">module:la.SparseMatrix</a>)</span></span></h3>
<p>Gives a matrix containing the field values of each record.</p>
<section>
<h4>
Example
</h4>
<div>
<pre class="prettyprint"><code>// import qm module
var qm = require('qminer');
// create a new base containing one store
var base = new qm.Base({
mode: "createClean",
schema: [{
name: "ArcheryChampionship",
fields: [
{ name: "Name", type: "string" },
{ name: "ScorePerRound", type: "float_v" }
]
}]
});
// set new records in the store
base.store("ArcheryChampionship").push({ Name: "Robin Hood", ScorePerRound: [50, 48, 48] });
base.store("ArcheryChampionship").push({ Name: "Oliver Queen", ScorePerRound: [44, 46, 44] });
base.store("ArcheryChampionship").push({ Name: "Legolas", ScorePerRound: [50, 50, 48] });
// get the matrix containing the "score per round" values
// The values of the i-th column are the values of the i-th record.
// The function will give the matrix:
// 50 44 50
// 48 46 50
// 48 44 48
var matrix = base.store("ArcheryChampionship").getMatrix("ScorePerRound");
base.close();</code></pre>
</div>
</section>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>fieldName</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p> </p>
</td>
<td>
<p>The field name. Field mustn't be of type <code>string</code>.</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>(<a href="module-la.Matrix.html">module:la.Matrix</a> or <a href="module-la.SparseMatrix.html">module:la.SparseMatrix</a>)</code>B The matrix containing the field values.</p>
</dd>
</dl>
<h3 id="getStreamAggrNames"><span class="symbol-name">getStreamAggrNames</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Array of string</span></span></h3>
<p>Returns an array of the stream aggregates names connected to the store.</p>
<section>
<h4>
Example
</h4>
<div>
<pre class="prettyprint"><code>// import qm module
var qm = require('qminer');
// create a simple base containing one store
var base = new qm.Base({
mode: "createClean",
schema: [{
name: "Laser",
fields: [
{ name: "Time", type: "datetime" },
{ name: "WaveLength", type: "float" }
]
}]
});
// 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);
// get the stream aggregates on store "Laser"
base.store("Laser").getStreamAggrNames();
base.close();</code></pre>
</div>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Array of string</code>B An array of stream aggregates names.</p>
</dd>
</dl>
<h3 id="getVector"><span class="symbol-name">getVector</span><span class="signature"><span class="signature-params">(fieldName)</span> → <span class="signature-returns"> <a href="module-la.Vector.html">module:la.Vector</a></span></span></h3>
<p>Gives a vector containing the field value of each record.</p>
<section>
<h4>
Example
</h4>
<div>
<pre class="prettyprint"><code>// import qm module
var qm = require('qminer');
// create a base containing one store
var base = new qm.Base({
mode: "createClean",
schema: [{
name: "Companies",
fields: [
{ name: "Name", type: "string", primary: true },
{ name: "Location", type: "string" }
]
}]
});
// add some records to the store
base.store("Companies").push({ Name: "DC Comics", Location: "Burbank, California" });
base.store("Companies").push({ Name: "DC Shoes", Location: "Huntington Beach, California" });
base.store("Companies").push({ Name: "21st Century Fox", Location: "New York City, New York" });
// get the vector of company names
var companyNames = base.store("Companies").getVector("Name"); // returns a vector ["DC Comics", "DC Shoes", "21st Century Fox"]
base.close();</code></pre>
</div>
</section>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>fieldName</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p> </p>
</td>
<td>
<p>The field name. Field must be of one-dimensional type, e.g. <code>int</code>, <code>float</code>, <code>string</code>...</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code><a href="module-la.Vector.html">module:la.Vector</a></code>B The vector containing the field values of each record.</p>
</dd>
</dl>
<h3 id="inspect"><span class="symbol-name">inspect</span><span class="signature"><span class="signature-params">(depth)</span> → <span class="signature-returns"> string</span></span></h3>
<p>Inspects the stores.</p>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>depth</p>
</td>
<td>
<p>number</p>
</td>
<td>
<p> </p>
</td>
<td>
<p>The depth of inspection. How many times to recurse while formatting the store object.</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>string</code>B String representation of the store.</p>
</dd>
</dl>
<h3 id="isDate"><span class="symbol-name">isDate</span><span class="signature"><span class="signature-params">(fieldName)</span> → <span class="signature-returns"> boolean</span></span></h3>
<p>Checks if the field is of type Date.</p>
<section>
<h4>
Example
</h4>
<div>
<pre class="prettyprint"><code>// import qm module
var qm = require('qminer');
// create a new base containing one store
var base = new qm.Base({
mode: "createClean",
schema: [{
name: "BasketballPlayers",
fields: [
{ name: "Name", type: "string" },
{ name: "SeasonScore", type: "int_v" },
{ name: "DateOfBirth", type: "datetime" }
]
}]
});
// check if the SeasonScore field is of type Date
var isSeasonScoreDate = base.store("BasketballPlayers").isDate("SeasonScore"); // returns false
// check if the FirstPlayed field is of type Date
var isFirstPlayedDate = base.store("BasketballPlayers").isDate("DateOfBirth"); // returns true
base.close();</code></pre>
</div>
</section>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>fieldName</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p> </p>
</td>
<td>
<p>The field name.</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>boolean</code>B True, if the field is of type Date. Otherwise, false.</p>
</dd>
</dl>
<h3 id="isNumeric"><span class="symbol-name">isNumeric</span><span class="signature"><span class="signature-params">(fieldName)</span> → <span class="signature-returns"> boolean</span></span></h3>
<p>Checks if the field is of numeric type.</p>
<section>
<h4>
Example
</h4>
<div>
<pre class="prettyprint"><code>// import qm module
var qm = require('qminer');
// create a base containing one store
var base = new qm.Base({
mode: "createClean",
schema: [{
name: "TVSeries",
fields: [
{ name: "Title", type: "string", primary: true },
{ name: "NumberOfEpisodes", type: "int" }
]
}]
});
// check if the field "Title" is of numeric type
var isTitleNumeric = base.store("TVSeries").isNumeric("Title"); // returns false
// check if the field "NumberOfEpisodes" is of numeric type
var isNumberOfEpisodesNumeric = base.store("TVSeries").isNumeric("NumberOfEpisodes"); // returns true
base.close();</code></pre>
</div>
</section>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>fieldName</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p> </p>
</td>
<td>
<p>The field name.</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>boolean</code>B True, if the field is of numeric type. Otherwise, false.</p>
</dd>
</dl>
<h3 id="isString"><span class="symbol-name">isString</span><span class="signature"><span class="signature-params">(fieldName)</span> → <span class="signature-returns"> boolean</span></span></h3>
<p>Checks if the field is of string type.</p>
<section>
<h4>
Example
</h4>
<div>
<pre class="prettyprint"><code>// import qm module
var qm = require("qminer");
// create a new base containing one store
var base = new qm.Base({
mode: "createClean",
schema: [{
name: "People",
fields: [
{ name: "Name", type: "string", primary: true },
{ name: "Gender", type: "string" },
{ name: "Age", type: "int" }
]
}]
});
// check if the field "Name" is of string type
var isNameString = base.store("People").isString("Name"); // returns true
// check if the field "Age" is of string type
var isAgeString = base.store("People").isString("Age"); // returns false
base.close();</code></pre>
</div>
</section>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>fieldName</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p> </p>
</td>
<td>
<p>The field name.</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>boolean</code>B True, if the field is of string type. Otherwise, false.</p>
</dd>
</dl>
<h3 id="key"><span class="symbol-name">key</span><span class="signature"><span class="signature-params">(keyName)</span> → <span class="signature-returns"> <a href="module-qm.html#~DetailKeyObject">module:qm~DetailKeyObject</a></span></span></h3>
<p>Returns the details of the selected key as a object.</p>
<section>
<h4>
Example
</h4>
<div>
<pre class="prettyprint"><code>// import qm module
var qm = require('qminer');
// create a new base containing one store
var base = new qm.Base({
mode: "createClean",
schema: [{
name: "Countries",
fields: [
{ name: "Name", type: "string", primary: true },
{ name: "Population", type: "int" },
{ name: "Continent", type: "string" }
],
keys: [
{ field: "Name", type: "text" },
{ field: "Continent", type: "value" }
]
}]
});
// get the details of the key of the field "Continent"
// returns a JSON object containing the details of the key:
// { fq: { length: 0 }, vocabulary: { length: 0 }, name: 'Continent', store: { name: 'Countries', ... }}
var details = base.store("Countries").key("Continent");
base.close();</code></pre>
</div>
</section>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>keyName</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p> </p>
</td>
<td>
<p>The key name.</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code><a href="module-qm.html#~DetailKeyObject">module:qm~D