Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
defaults: {
appId: '',
logicalName: '',
className: '',
containers: [],
cpuPercentageMA: 0,
currentWindowId: 0, // new WindowId("0")
recoveryWindowId: 0, // new WindowId("75")
failureCount: 1,
hosts: [],
ids: [],
ports: [],
lastHeartbeat: 0,
latencyMA: 0,
status: {},
totalTuplesEmitted: BigInteger.ZERO,
totalTuplesProcessed: BigInteger.ZERO,
tuplesEmittedPSMA: BigInteger.ZERO,
tuplesProcessedPSMA: BigInteger.ZERO,
partitionCount: 0,
containerCount: 0
},
initialize: function(attrs, options) {
OperatorModel.prototype.initialize.call(this, attrs, options);
if (options.keepPhysicalCollection) {
this.physicalOperators = new OperatorCollection([], {
dataSource: this.dataSource
});
this.physicalOperators.appId = this.get('appId');
}
return result;
}()),
*/
// min
"lastHeartbeat": null,
// max
"latencyMA": group[0]["latencyMA"],
// same
"logicalName": group[0]["logicalName"],
// map of status => array of ids
"status": {},
// sum
"totalTuplesEmitted": BigInteger.ZERO,
"totalTuplesProcessed": BigInteger.ZERO,
"tuplesEmittedPSMA": BigInteger.ZERO,
"tuplesProcessedPSMA": BigInteger.ZERO,
partitionCount: 0,
containerCount: 0
});
reduction.containerCount = reduction.containers.length;
// Reduce ports
/*
if (reduction.ports.length) {
reduction.ports = _.map(reduction.ports, function(portArray, name, list) {
return _.reduce(portArray, function(memo, port, i, list) {
_.each(['bufferServerBytesPSMA', 'totalTuples', 'tuplesPSMA'], function(key) {
memo[key] = memo[key].add(new BigInteger(port[key]));
});
className: '',
containers: [],
cpuPercentageMA: 0,
currentWindowId: 0, // new WindowId("0")
recoveryWindowId: 0, // new WindowId("75")
failureCount: 1,
hosts: [],
ids: [],
ports: [],
lastHeartbeat: 0,
latencyMA: 0,
status: {},
totalTuplesEmitted: BigInteger.ZERO,
totalTuplesProcessed: BigInteger.ZERO,
tuplesEmittedPSMA: BigInteger.ZERO,
tuplesProcessedPSMA: BigInteger.ZERO,
partitionCount: 0,
containerCount: 0
},
initialize: function(attrs, options) {
OperatorModel.prototype.initialize.call(this, attrs, options);
if (options.keepPhysicalCollection) {
this.physicalOperators = new OperatorCollection([], {
dataSource: this.dataSource
});
this.physicalOperators.appId = this.get('appId');
}
},
url: function() {
_.each(['tuplesProcessedPSMA','totalTuplesProcessed','tuplesEmittedPSMA','totalTuplesEmitted'], function(key) {
memo[key] = memo[key].add(new BigInteger(op[key]+''));
});
// lastHeartbeat
memo.lastHeartbeat = op.lastHeartbeat;
return memo;
},
{
'currentWindowId': false,
'recoveryWindowId': false,
'tuplesProcessedPSMA': BigInteger.ZERO,
'totalTuplesProcessed': BigInteger.ZERO,
'tuplesEmittedPSMA': BigInteger.ZERO,
'totalTuplesEmitted': BigInteger.ZERO
}
);
_.each(['recoveryWindowId', 'currentWindowId'], function(wKey) {
if (aggregates[wKey] === false) {
aggregates[wKey] = '0';
}
});
this.set(aggregates);
},
adjustOffsetForTail: function(newLimit, newTotal) {
if (this.get('tail')) {
// calculate new offset
var limit = new BigInteger(newLimit ? newLimit+'' : this.get('limit')+'');
var total = new BigInteger(newTotal ? newTotal+'' : this.get('totalTuples')+'');
var newOffset = total.subtract(limit);
if (newOffset.compareTo(BigInteger.ZERO) < 0) {
newOffset = BigInteger.ZERO;
}
this.set('offset', newOffset.toString());
}
},
validate: function(attrs) {
var offset = new BigInteger(attrs.offset+'');
var total = typeof this.getCurrentTotal === 'function' ? this.getCurrentTotal() : new BigInteger(this.get('totalTuples')+'') ;
var upper = total.subtract(new BigInteger(attrs.limit+''));
if (offset.compareTo(BigInteger.ZERO) < 0) return 'The offset cannot be less than zero.';
if (offset.compareTo(upper) > 0) return 'The offset cannot exceed total.';
},
validate: function(attrs) {
var offset = new BigInteger(attrs.offset+'');
var total = typeof this.getCurrentTotal === 'function' ? this.getCurrentTotal() : new BigInteger(this.get('totalTuples')+'') ;
var upper = total.subtract(new BigInteger(attrs.limit+''));
if (offset.compareTo(BigInteger.ZERO) < 0) return 'The offset cannot be less than zero.';
if (attrs.limit*1 > 300) return 'Limit cannot exceed 300.';
},
function getprimeover(bitLength){
function getNBitRand(n){
return new bn(n, 1, rng);
}
var p = bn.ZERO;
while(!p.isProbablePrime(20)){
p = getNBitRand(bitLength);
}
return p;
}