Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
+ nodeEnvData['appmetrics.version'] + ", expected 99.99.99.123456789012 (or 99.99.99-dev.99.12345678901)");
}
if (nodeEnvData['agentcore.version'])
{
assert(/^\d+\.\d+\.\d+\.\d{12}$/.test(nodeEnvData['agentcore.version']),
"Agent core version format not recognised"
+ nodeEnvData['agentcore.version'] + ", expected 99.99.99.123456789012");
}
// NOTE(mjt): heap.size.limit, max.semi.space.size and max.old.space.size were added in
// appmetrics 1.0.4 (required field in this version onwards)
// NOTE(ignasbol): max.heap.size included as well as part of 1.0.4
var prefix = 'Node environment message ';
if (nodeEnvData['heap.size.limit']) {
assert(isInteger(nodeEnvData['heap.size.limit']),
prefix + 'does not have an integer heap size limit (' + nodeEnvData['heap.size.limit'] + ')');
assert(parseInt(nodeEnvData['heap.size.limit']) > 0,
prefix + 'does not have a positive heap size limit (' + nodeEnvData['heap.size.limit'] + ')');
assert(isInteger(nodeEnvData['max.semi.space.size']),
prefix + 'does not have an integer max semi space size (' + nodeEnvData['max.semi.space.size'] + ')');
assert(parseInt(nodeEnvData['max.semi.space.size']) > 0,
prefix + 'does not have a positive max semi space size (' + nodeEnvData['max.semi.space.size'] + ')');
assert(isInteger(nodeEnvData['max.old.space.size']),
prefix + 'does not have an integer max old space size (' + nodeEnvData['max.old.space.size'] + ')');
assert(parseInt(nodeEnvData['max.old.space.size']) > 0,
prefix + 'does not have a positive max old space size (' + nodeEnvData['max.old.space.size'] + ')');
assert(4*parseInt(nodeEnvData['max.semi.space.size']) + parseInt(nodeEnvData['max.old.space.size']) === parseInt(nodeEnvData['heap.size.limit']),
prefix + 'values for max old space size and max semi space size do not match heap size limit');
"Appmetrics version format not recognised"
+ nodeEnvData['appmetrics.version'] + ", expected 99.99.99.123456789012 (or 99.99.99-dev.99.12345678901)");
}
if (nodeEnvData['agentcore.version'])
{
assert(/^\d+\.\d+\.\d+\.\d{12}$/.test(nodeEnvData['agentcore.version']),
"Agent core version format not recognised"
+ nodeEnvData['agentcore.version'] + ", expected 99.99.99.123456789012");
}
// NOTE(mjt): heap.size.limit, max.semi.space.size and max.old.space.size were added in
// appmetrics 1.0.4 (required field in this version onwards)
// NOTE(ignasbol): max.heap.size included as well as part of 1.0.4
var prefix = 'Node environment message ';
if (nodeEnvData['heap.size.limit']) {
assert(isInteger(nodeEnvData['heap.size.limit']),
prefix + 'does not have an integer heap size limit (' + nodeEnvData['heap.size.limit'] + ')');
assert(parseInt(nodeEnvData['heap.size.limit']) > 0,
prefix + 'does not have a positive heap size limit (' + nodeEnvData['heap.size.limit'] + ')');
assert(isInteger(nodeEnvData['max.semi.space.size']),
prefix + 'does not have an integer max semi space size (' + nodeEnvData['max.semi.space.size'] + ')');
assert(parseInt(nodeEnvData['max.semi.space.size']) > 0,
prefix + 'does not have a positive max semi space size (' + nodeEnvData['max.semi.space.size'] + ')');
assert(isInteger(nodeEnvData['max.old.space.size']),
prefix + 'does not have an integer max old space size (' + nodeEnvData['max.old.space.size'] + ')');
assert(parseInt(nodeEnvData['max.old.space.size']) > 0,
prefix + 'does not have a positive max old space size (' + nodeEnvData['max.old.space.size'] + ')');
assert(4*parseInt(nodeEnvData['max.semi.space.size']) + parseInt(nodeEnvData['max.old.space.size']) === parseInt(nodeEnvData['heap.size.limit']),
nodeEnvData['agentcore.version'],
/^\d+\.\d+\.\d+\.\d{12}$/,
"Agent core version matches '99.99.99.123456789012' format"
);
}
// NOTE(mjt): heap.size.limit, max.semi.space.size and max.old.space.size were added in
// appmetrics 1.0.4 (required field in this version onwards)
// NOTE(ignasbol): max.heap.size included as well as part of 1.0.4
if (nodeEnvData['heap.size.limit']) {
t.ok(
isInteger(nodeEnvData['heap.size.limit']),
'heap.size.limit is an integer (value was: ' + nodeEnvData['heap.size.limit'] + ')'
);
t.ok(parseInt(nodeEnvData['heap.size.limit']) > 0, 'heap.size.limit is positive');
t.ok(
isInteger(nodeEnvData['max.semi.space.size']),
'max.semi.space.size is an integer (value was: ' + nodeEnvData['max.semi.space.size'] + ')'
);
t.ok(parseInt(nodeEnvData['max.semi.space.size']) > 0, 'max.semi.size is positive');
t.ok(
isInteger(nodeEnvData['max.old.space.size']),
'max.old.space.size is an integer (value was: ' + nodeEnvData['max.old.space.size'] + ')'
);
t.ok(parseInt(nodeEnvData['max.old.space.size']) > 0, 'max.old.space.size is positive');
if (semver.gt(process.version, '12.0.0')) {
t.skip();
} else if (semver.gt(process.version, '10.0.0')) {
// heap size limit is now scaled by a factor - see
"Appmetrics version matches '99.99.99(-dev).123456789012' format"
);
}
if (nodeEnvData['agentcore.version']) {
t.match(
nodeEnvData['agentcore.version'],
/^\d+\.\d+\.\d+\.\d{12}$/,
"Agent core version matches '99.99.99.123456789012' format"
);
}
// NOTE(mjt): heap.size.limit, max.semi.space.size and max.old.space.size were added in
// appmetrics 1.0.4 (required field in this version onwards)
// NOTE(ignasbol): max.heap.size included as well as part of 1.0.4
if (nodeEnvData['heap.size.limit']) {
t.ok(
isInteger(nodeEnvData['heap.size.limit']),
'heap.size.limit is an integer (value was: ' + nodeEnvData['heap.size.limit'] + ')'
);
t.ok(parseInt(nodeEnvData['heap.size.limit']) > 0, 'heap.size.limit is positive');
t.ok(
isInteger(nodeEnvData['max.semi.space.size']),
'max.semi.space.size is an integer (value was: ' + nodeEnvData['max.semi.space.size'] + ')'
);
t.ok(parseInt(nodeEnvData['max.semi.space.size']) > 0, 'max.semi.size is positive');
t.ok(
isInteger(nodeEnvData['max.old.space.size']),
'max.old.space.size is an integer (value was: ' + nodeEnvData['max.old.space.size'] + ')'
);
if (nodeEnvData['agentcore.version']) {
t.match(
nodeEnvData['agentcore.version'],
/^\d+\.\d+\.\d+\.\d{12}$/,
"Agent core version matches '99.99.99.123456789012' format"
);
}
// NOTE(mjt): heap.size.limit, max.semi.space.size and max.old.space.size were added in
// appmetrics 1.0.4 (required field in this version onwards)
// NOTE(ignasbol): max.heap.size included as well as part of 1.0.4
if (nodeEnvData['heap.size.limit']) {
t.ok(
isInteger(nodeEnvData['heap.size.limit']),
'heap.size.limit is an integer (value was: ' + nodeEnvData['heap.size.limit'] + ')'
);
t.ok(parseInt(nodeEnvData['heap.size.limit']) > 0, 'heap.size.limit is positive');
t.ok(
isInteger(nodeEnvData['max.semi.space.size']),
'max.semi.space.size is an integer (value was: ' + nodeEnvData['max.semi.space.size'] + ')'
);
t.ok(parseInt(nodeEnvData['max.semi.space.size']) > 0, 'max.semi.size is positive');
t.ok(
isInteger(nodeEnvData['max.old.space.size']),
'max.old.space.size is an integer (value was: ' + nodeEnvData['max.old.space.size'] + ')'
);
t.ok(parseInt(nodeEnvData['max.old.space.size']) > 0, 'max.old.space.size is positive');
if (semver.gt(process.version, '12.0.0')) {
}
if (nodeEnvData['agentcore.version']) {
t.match(
nodeEnvData['agentcore.version'],
/^\d+\.\d+\.\d+\.\d{12}$/,
"Agent core version matches '99.99.99.123456789012' format"
);
}
// NOTE(mjt): heap.size.limit, max.semi.space.size and max.old.space.size were added in
// appmetrics 1.0.4 (required field in this version onwards)
// NOTE(ignasbol): max.heap.size included as well as part of 1.0.4
if (nodeEnvData['heap.size.limit']) {
t.ok(
isInteger(nodeEnvData['heap.size.limit']),
'heap.size.limit is an integer (value was: ' + nodeEnvData['heap.size.limit'] + ')'
);
t.ok(parseInt(nodeEnvData['heap.size.limit']) > 0, 'heap.size.limit is positive');
t.ok(
isInteger(nodeEnvData['max.semi.space.size']),
'max.semi.space.size is an integer (value was: ' + nodeEnvData['max.semi.space.size'] + ')'
);
t.ok(parseInt(nodeEnvData['max.semi.space.size']) > 0, 'max.semi.size is positive');
t.ok(
isInteger(nodeEnvData['max.old.space.size']),
'max.old.space.size is an integer (value was: ' + nodeEnvData['max.old.space.size'] + ')'
);
t.ok(parseInt(nodeEnvData['max.old.space.size']) > 0, 'max.old.space.size is positive');
var tweetsPerSect = 5
for (var sect in tweetsBySect){
//Select the tweets within the sect
var sectTweets = tweetsBySect[sect];
// Setup a hastable and list for heap
var hashtable = new HashTable();
var scoresList = []
for (var i = 0; i < sectTweets.length; i++) {
var tweet = sectTweets[i];
var score = evaluate(tweet);
scoresList.push(score);
hashtable.put(score, tweet);
}
//Get the largest few scores in the scoresList
var largeScores = Heap.nlargest(unique(scoresList), tweetsPerSect);
//Push those tweets into the final list
for (var i=0; i < tweetsPerSect; i++){
if (largeScores[i]) {
finalList.push(hashtable.get(largeScores[i]))
}
}
}
return finalList;
}
module.exports = function(arr, n=10) {
// Subset the reverse index so that both the largest elements
// and the indices where they occur are returned.
return _.pick(_.invertBy(arr),
Heap.nlargest(arr, n)
);
};
function expandSeqTree(rootSeq, graphs, expandCnt, minSupport, maxSupport, terms, itemset) {
if (rootSeq.words && rootSeq.words.length > 0) {
rootSeq.graph.nodes = rootSeq.graph.nodes.concat(rootSeq.words);
expandCnt -= rootSeq.words.length;
}
/* Create a max heap */
const seqs = new Heap((a, b) => b.size - a.size);
seqs.push(rootSeq);
const leafSeqs = [];
while (!seqs.empty() && expandCnt > 0) {
/* find the candidate sequence with largest support DB */
const s = seqs.pop();
let graph = s.graph;
let s0 = s.r;
let s1 = s.l;
if (!s0 && !s1) {
/* find the next frequent sequence */
const result = growSeq(s, terms, minSupport, maxSupport, itemset);
s0 = result.s0;
s1 = result.s1;
const { word, pos, count } = result;
bundle() {
const heap = new Heap((a, b) => a.data.id - b.data.id);
// Add candidate parents to heap
this.nodes
.filter(n => this.hasPotential(n))
.forEach(n => { heap.push(n); });
while (heap.size() > 0) {
const parent = heap.pop();
if (parent.merged) {
continue;
}
let groups = [];
if (parent.leftLinks.length > 1) {
const lNodes = parent.leftLinks.map(l => l.source);
groups = groups.concat(this.groupMergeableNodes(lNodes));