Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* tree. If we need a node that doesn't exist, we create it here.
*
* In each iteration, "o" denotes where we are currently in the tree,
* and "prev" refers to its parent. At the end of this loop, "o" refers
* to the leaf value that we'd like to update. (We wouldn't need "prev"
* at all if we could update numbers by reference, but we need it to
* update the leaf by updating the corresponding property of its
* parent.)
*/
prev = null;
o = this.sa_value;
for (i = 0; i < this.sa_decomps.length; i++) {
mod_assert.equal(typeof (o), 'object');
mod_assert.ok(o !== null);
field = this.sa_decomps[i];
fieldvalue = mod_jsprim.pluck(datapt['fields'], field);
prev = o;
if (this.sa_bucketizers.hasOwnProperty(field)) {
if (typeof (fieldvalue) == 'string') {
this.sa_nparsed++;
fieldvalue = parseFloat(fieldvalue);
}
if (typeof (fieldvalue) != 'number' ||
isNaN(fieldvalue)) {
this.sa_nnonnumeric++;
this.emit('invalid_object', datapt, new VError(
'value for field "%s" is not a number',
field), this.sa_nrecords);
return;
}
throw new errors.UnknownTypeError('unknown type "%s"', lhs.type);
}
if (typeof (self.types[lhs.type][op]) !== 'function') {
throw new errors.UnsupportedOperationError('unsupported '+
'operation "%s" on type "%s"', op, lhs.type);
}
if (typeof (context[lhs.name]) === 'undefined' ||
context[lhs.name] === null) {
throw new errors.MissingConditionError(
'missing condition in context: "%s"', lhs.name);
}
return (self.types[lhs.type][op](pluck(context, lhs.name), rhs));
};
outputs.forEach(function (o, i) {
var val;
if (json) {
if (o == 'this')
val = row[0];
else {
val = mod_jsprim.pluck(row[1], o);
if (val === undefined)
val = 'undefined';
else
val = JSON.stringify(val);
}
} else {
val = mod_jsprim.pluck(row, o);
}
outstream.write((i === 0 ? '' : ' ') + val.toString());
});
outstream.write('\n');
DataAggregator.prototype.extractField = function (row, field)
{
/*
* This works for both JSON mode, where "row" is an object and "field"
* may include nested references, as well as text mode, where "row" is
* an array and "field" is a number.
*/
return (mod_jsprim.pluck(row, field));
};
outputs.forEach(function (o, i) {
var val;
if (json) {
if (o == 'this')
val = row[0];
else {
val = mod_jsprim.pluck(row[1], o);
if (val === undefined)
val = 'undefined';
else
val = JSON.stringify(val);
}
} else {
val = mod_jsprim.pluck(row, o);
}
outstream.write((i === 0 ? '' : ' ') + val.toString());
});
outstream.write('\n');
krillPrimWalk(function (subpred, key) {
var field = subpred[key][0];
var value = mod_jsprim.pluck(xlate, field);
if (value === undefined)
throw (new VError('subpredicate "%j": ' +
'no translation for field "%s"',
subpred, field));
subpred[key][0] = value;
}, newpred);
return (new Predicate(newpred, this.p_types));
client: function _serializeClient(c) {
return ({
id: c._moray_id,
currentQuery: jsprim.pluck(c, 'client.activeQuery.text'),
timeout: c._queryTimeout,
txn: c._moray_txn
});
},
err: bunyan.stdSerializers.err
this.st_query.qc_synthetic.forEach(function (fieldconf) {
var val, parsed;
mod_assertplus.ok(fieldconf.hasOwnProperty('date'));
val = mod_jsprim.pluck(chunk.fields, fieldconf.field);
if (val === undefined) {
if (nerrors === 0) {
self.vsWarn(new VError(
'field "%s" is undefined', fieldconf.field),
'undef');
}
nerrors++;
return;
}
if (typeof (val) == 'number') {
/*
* For convenience, we allow people to specify "date"
* fields that are already parsed dates. We just pass
* these through.
*/
function validatePromoteRequest(clusterState)
{
var promote, error, expireTime;
promote = mod_jsprim.pluck(clusterState, 'promote');
if (!promote)
return (undefined);
error = validateAndCopy(schemas.promote, promote);
if (error instanceof Error)
return (error);
expireTime = mod_jsprim.parseDateTime(promote.expireTime);
if (isNaN(expireTime.getTime())) {
return (new VError('expireTime is not parseable (found "%s")',
promote.expireTime));
}
if (promote.generation !== clusterState.generation) {
return (new VError('generation does not match (expected %d, ' +