id int64 0 1.29M | original_id stringlengths 32 32 | swhid stringlengths 100 170 | sha1 stringlengths 40 40 | repo_name stringlengths 2 45 | repo_group stringclasses 12
values | filepath stringlengths 5 153 | name stringlengths 1 14.9k | type stringclasses 3
values | code stringlengths 7 2.12M |
|---|---|---|---|---|---|---|---|---|---|
18,100 | 11f83815a7ed7ed08987f0147c2acb33 | swh:1:cnt:10e4392c14fd08b25c6de4b00a1a0a74c367e773;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=265-293/ | 0a315bd5e53af3bee7d5a6bae593e6e1c0c8db0c | change-propagation | deployed | sys/dep_updates.js | DependencyProcessor::_getSiteInfo | function | _getSiteInfo(hyper, message) {
const domain = message.meta.domain;
if (!this.siteInfoCache[domain]) {
this.siteInfoCache[domain] = hyper.post(this.siteInfoRequest.expand({
message
}))
.then((res) => {
if (!res || !res.body || !res.body.... |
18,101 | 7239eff1447ca9b8fbc7b1a342f6a63d | swh:1:cnt:10e4392c14fd08b25c6de4b00a1a0a74c367e773;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=241-263/ | 0a315bd5e53af3bee7d5a6bae593e6e1c0c8db0c | change-propagation | deployed | sys/dep_updates.js | DependencyProcessor::_fetchAndProcessBatch | function | _fetchAndProcessBatch(hyper, requestTemplate, context, siteInfo, originalEvent) {
return hyper.post(requestTemplate.template.expand(context))
.then((res) => {
const titles = (requestTemplate.extractResults(res) || []).map((item) => ({
title: Title.newFromText(item.title, ... |
18,102 | 3b58bc6dd64c1ec0f30e5c5367ac181d | swh:1:cnt:10e4392c14fd08b25c6de4b00a1a0a74c367e773;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=166-294/ | 0a315bd5e53af3bee7d5a6bae593e6e1c0c8db0c | change-propagation | deployed | sys/dep_updates.js | DependencyProcessor | type | class DependencyProcessor {
constructor(options) {
this.options = options;
this.siteInfoCache = {};
this.backLinksRequest = createBackLinksTemplate(options);
this.imageLinksRequest = createImageUsageTemplate(options);
this.transcludeInRequest = createTranscludeInTemplate(opti... |
18,103 | 36aab62a64dfd8192847183f32a419a5 | swh:1:cnt:19d82af04f9ba544bdd9c674c2de724e89396093;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=15-100/ | 2e619c97ca661dad869f4f06aaa2dc23322b4a4f | change-propagation | deployed | sys/kafka.js | Kafka | type | class Kafka {
constructor(options) {
this.options = options;
this.kafkaFactory = kafkaFactory.getFactory(options);
this.staticRules = options.templates || {};
this.subscriber = new RuleSubscriber(options, this.kafkaFactory);
}
async setup(hyper) {
this.producer = aw... |
18,104 | cd6e94fdeb7f35d4d03fb2b15eebbd56 | swh:1:cnt:19d82af04f9ba544bdd9c674c2de724e89396093;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=16-22/ | 2e619c97ca661dad869f4f06aaa2dc23322b4a4f | change-propagation | deployed | sys/kafka.js | Kafka::constructor | function | constructor(options) {
this.options = options;
this.kafkaFactory = kafkaFactory.getFactory(options);
this.staticRules = options.templates || {};
this.subscriber = new RuleSubscriber(options, this.kafkaFactory);
} |
18,105 | 6672775a426d78d8e290cb3b4b3115e6 | swh:1:cnt:19d82af04f9ba544bdd9c674c2de724e89396093;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=39-46/ | 2e619c97ca661dad869f4f06aaa2dc23322b4a4f | change-propagation | deployed | sys/kafka.js | Kafka::_subscribeRules | function | async _subscribeRules(hyper, rules) {
await Promise.all(
Object.keys(rules).map(
ruleName => this.subscriber.subscribe(hyper, ruleName, rules[ruleName])
)
);
return { status: 201 };
} |
18,106 | 92523c13a399bdbdc74b97463d56c5cf | swh:1:cnt:19d82af04f9ba544bdd9c674c2de724e89396093;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=52-99/ | 2e619c97ca661dad869f4f06aaa2dc23322b4a4f | change-propagation | deployed | sys/kafka.js | Kafka::produce | function | async produce(hyper, req) {
if (this.options.test_mode) {
hyper.logger.log('trace/produce', 'Running in TEST MODE; Production disabled');
return { status: 201 };
}
if (!this._connected) {
hyper.logger.log('debug/produce', 'Attempt to produce while disconnecte... |
18,107 | f9aa866f76bb2a9b41c81cad12636c26 | swh:1:cnt:19d82af04f9ba544bdd9c674c2de724e89396093;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=24-37/ | 2e619c97ca661dad869f4f06aaa2dc23322b4a4f | change-propagation | deployed | sys/kafka.js | Kafka::setup | function | async setup(hyper) {
this.producer = await this.kafkaFactory.createGuaranteedProducer(hyper.logger);
this._connected = true;
HyperSwitch.lifecycle.once('close', () => {
this._connected = false;
this.subscriber.unsubscribeAll();
this.producer.disconnect();
... |
18,108 | a50d0cde33c3703adfa2cc09703acc92 | swh:1:cnt:19d82af04f9ba544bdd9c674c2de724e89396093;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=48-50/ | 2e619c97ca661dad869f4f06aaa2dc23322b4a4f | change-propagation | deployed | sys/kafka.js | Kafka::subscribe | function | subscribe(hyper, req) {
return this._subscribeRules(hyper, req.body);
} |
18,109 | a7d17d3cadc3ab3b377b73fbe4b0b00c | swh:1:cnt:91a6ade036ea6b9812444f87d214992ce067158a;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=5-114/ | 7d5fb79b073129c7252ab018559d0a4236a6374d | change-propagation | deployed | sys/ores_updates.js | OresProcessor | type | class OresProcessor {
constructor(options) {
this._options = options;
if (!options.ores_precache_uris || !Array.isArray(options.ores_precache_uris)) {
throw new Error('OresProcessor is misconfigured. ores_precache_uris is required');
}
if (!options.event_service_uri) {
... |
18,110 | 35516fbf02ae75fc9b41377c3499b4aa | swh:1:cnt:91a6ade036ea6b9812444f87d214992ce067158a;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=6-14/ | 7d5fb79b073129c7252ab018559d0a4236a6374d | change-propagation | deployed | sys/ores_updates.js | OresProcessor::constructor | function | constructor(options) {
this._options = options;
if (!options.ores_precache_uris || !Array.isArray(options.ores_precache_uris)) {
throw new Error('OresProcessor is misconfigured. ores_precache_uris is required');
}
if (!options.event_service_uri) {
throw new Error(... |
18,111 | 3191781a514113e0e2f5ac5ee3f723bb | swh:1:cnt:91a6ade036ea6b9812444f87d214992ce067158a;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=16-113/ | 7d5fb79b073129c7252ab018559d0a4236a6374d | change-propagation | deployed | sys/ores_updates.js | OresProcessor::process | function | async process(hyper, req) {
const message = req.body;
const preCache = await Promise.all(this._options.ores_precache_uris.map(uri => hyper.post({
uri,
headers: {
'content-type': 'application/json'
},
body: message
})));
con... |
18,112 | 7b918c486bc89c651c9be2291254cae8 | swh:1:cnt:8d72c719e405a14fd48d09d47834d025befbfd15;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=6-69/ | fa373c0be1d8c57bba9ab8a38cdcf8666220d699 | change-propagation | deployed | sys/partitioner.js | Partitioner | type | class Partitioner {
constructor(options) {
this._options = options || {};
if (!options.templates || !options.templates.partition_stream) {
throw new Error('No partition_stream template was provided to the partitioner');
}
if (!options.partition_key) {
throw ... |
18,113 | 8d1a1956d078e40732ee1760cf584244 | swh:1:cnt:8d72c719e405a14fd48d09d47834d025befbfd15;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=7-27/ | fa373c0be1d8c57bba9ab8a38cdcf8666220d699 | change-propagation | deployed | sys/partitioner.js | Partitioner::constructor | function | constructor(options) {
this._options = options || {};
if (!options.templates || !options.templates.partition_stream) {
throw new Error('No partition_stream template was provided to the partitioner');
}
if (!options.partition_key) {
throw new Error('No partition_... |
18,114 | 4bf8d86512da9dcc1ed34356ca7430b0 | swh:1:cnt:8d72c719e405a14fd48d09d47834d025befbfd15;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=29-40/ | fa373c0be1d8c57bba9ab8a38cdcf8666220d699 | change-propagation | deployed | sys/partitioner.js | Partitioner::_getPartitionKeyValue | function | /**
* Returns a partition key value based on a configured partition key
*
* @param {Object} event
* @return {undefined|string}
* @private
*/
_getPartitionKeyValue(event) {
const result = this._options.partition_key.split('.')
.reduce((value, key) => value ? value[key] :... |
18,115 | 583f689bf47b6c6f957866fb3afab485 | swh:1:cnt:8d72c719e405a14fd48d09d47834d025befbfd15;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=42-68/ | fa373c0be1d8c57bba9ab8a38cdcf8666220d699 | change-propagation | deployed | sys/partitioner.js | Partitioner::repostToPartition | function | /**
* Selects a proper partition and reposts the message to the partitioned topic.
*
* @param {HyperSwitch} hyper
* @param {Object} req
* @return {Object}
*/
repostToPartition(hyper, req) {
const origEvent = req.body;
let partition = this._options.partition_map[this._ge... |
18,116 | 082c2d0a364d4e99abcc664d425a6f07 | swh:1:cnt:89d8ddb025d3ed468c0dfb2217782c5c11540279;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=9-56/ | 51be25d7e6da9c2ba482658f3062f0e5f739d593 | change-propagation | deployed | sys/purge.js | PurgeService | type | class PurgeService {
constructor(options) {
this.options = options || {};
if (!this.options.host || !this.options.port) {
throw new Error('Purging module must be configured with host and port');
}
this.purger = new Purger({
log: this.options.log,
r... |
18,117 | 48e5a8dac0d705794306395560f19087 | swh:1:cnt:89d8ddb025d3ed468c0dfb2217782c5c11540279;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=10-20/ | 51be25d7e6da9c2ba482658f3062f0e5f739d593 | change-propagation | deployed | sys/purge.js | PurgeService::constructor | function | constructor(options) {
this.options = options || {};
if (!this.options.host || !this.options.port) {
throw new Error('Purging module must be configured with host and port');
}
this.purger = new Purger({
log: this.options.log,
routes: [ this.options ]
... |
18,118 | 9e7477f10413488d339c03902884a144 | swh:1:cnt:89d8ddb025d3ed468c0dfb2217782c5c11540279;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=26-55/ | 51be25d7e6da9c2ba482658f3062f0e5f739d593 | change-propagation | deployed | sys/purge.js | PurgeService::purge | function | purge(hyper, req) {
if (!Array.isArray(req.body)) {
throw new HTTPError({
status: 400,
body: {
type: 'bad_request',
description: 'Invalid request for purge service.'
}
});
}
return th... |
18,119 | b22e970aa11ccfdeeac511c40813742c | swh:1:cnt:89d8ddb025d3ed468c0dfb2217782c5c11540279;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=22-24/ | 51be25d7e6da9c2ba482658f3062f0e5f739d593 | change-propagation | deployed | sys/purge.js | PurgeService::init | function | init() {
return this.purger.bind().thenReturn({ status: 201 });
} |
18,120 | acf6a4d6653fd758b2bad12c3a40efe5 | swh:1:cnt:f7afbf9efaa2fd08d8f75e02b6d6d39e269188f3;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=8-80/ | b800e8f19af9fa5319995cb92a730d826498e022 | change-propagation | deployed | sys/rate_limiter.js | RateLimiter | type | class RateLimiter extends mixins.mix(Object).with(mixins.Redis) {
constructor(options) {
super(options);
this._options = options;
this._LIMITERS = new Map();
Object.keys(this._options.limiters).forEach((type) => {
let limiterOpts = this._options.limiters[type];
... |
18,121 | 01fc9ba711a86eb65ec7af835e045820 | swh:1:cnt:f7afbf9efaa2fd08d8f75e02b6d6d39e269188f3;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=9-31/ | b800e8f19af9fa5319995cb92a730d826498e022 | change-propagation | deployed | sys/rate_limiter.js | RateLimiter::constructor | function | constructor(options) {
super(options);
this._options = options;
this._LIMITERS = new Map();
Object.keys(this._options.limiters).forEach((type) => {
let limiterOpts = this._options.limiters[type];
if (!Array.isArray(limiterOpts)) {
limiterOpts = ... |
18,122 | 383c7eb1b3d16c05a5eb0a79a0bac460 | swh:1:cnt:f7afbf9efaa2fd08d8f75e02b6d6d39e269188f3;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=33-71/ | b800e8f19af9fa5319995cb92a730d826498e022 | change-propagation | deployed | sys/rate_limiter.js | RateLimiter::_execLimiterFun | function | _execLimiterFun(fun, hyper, type, key) {
const limiter = this._LIMITERS.get(type);
if (!limiter) {
hyper.logger.log('warn/ratelimit', {
message: 'Unconfigured rate-limiter is used',
limiter_type: type
});
return { status: 204 };
... |
18,123 | 4d25ec5db422a787d5062299d1be1b16 | swh:1:cnt:f7afbf9efaa2fd08d8f75e02b6d6d39e269188f3;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=77-79/ | b800e8f19af9fa5319995cb92a730d826498e022 | change-propagation | deployed | sys/rate_limiter.js | RateLimiter::check | function | check(hyper, req) {
return this._execLimiterFun('check', hyper, req.params.type, req.params.key);
} |
18,124 | 01a4d57883130bef1b40c04fb17fc50c | swh:1:cnt:f7afbf9efaa2fd08d8f75e02b6d6d39e269188f3;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=73-75/ | b800e8f19af9fa5319995cb92a730d826498e022 | change-propagation | deployed | sys/rate_limiter.js | RateLimiter::increment | function | increment(hyper, req) {
return this._execLimiterFun('incr', hyper, req.params.type, req.params.key);
} |
18,125 | bc90dd1919636cad4bb8e88734799522 | swh:1:cnt:7c119738631e554ef394e60b4bf8f4ae61433fd9;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=8-14/ | 545410c9cec7805a24d6cb5f8a20c8671272f476 | change-propagation | deployed | test/feature/sampler.js | makeRandomString | function | function makeRandomString(length) {
let text = '';
for (let i = 0; i < length; i++) {
text += CHARS.charAt(Math.floor(Math.random() * CHARS.length));
}
return text;
} |
18,126 | b99e462129dc1913b9137236cc883638 | swh:1:cnt:d283dc08e60cdbeaac56c37b1bdae6a704eb1898;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=163-187/ | 5f2555ac8dd1a512f36bcbe4a95e26ee05d133f1 | change-propagation | deployed | test/feature/static_rules.js | check | function | function check() {
return retryConsumer.consumeAsync(1)
.catch(check)
.then((messages) => {
if (!messages.length) {
return P.delay(1000).then(check);
}
const m... |
18,127 | b471235e24c9057c5ca05f69925d5400 | swh:1:cnt:73899d8ed25aa5677a102c5b2c90313a9f507da5;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=54-71/ | 491972a04c363c9ea0f5e2ef38774dc2d521f68b | change-propagation | deployed | test/feature/update_rules.js | summaryEndpointTest | function | function summaryEndpointTest(topic) {
const mwAPI = nock('https://en.wikipedia.org', {
reqheaders: {
'cache-control': 'no-cache',
'x-triggered-by': `req:${ common.SAMPLE_REQUEST_ID },${ topic }:https://en.wikipedia.org/api/rest_v1/page/html/Main_Page`,
... |
18,128 | 0f431f71e81e90c6aba9b152b1d6f367 | swh:1:cnt:73899d8ed25aa5677a102c5b2c90313a9f507da5;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=73-106/ | 491972a04c363c9ea0f5e2ef38774dc2d521f68b | change-propagation | deployed | test/feature/update_rules.js | testPurgeCacheOnResourceChange | function | function testPurgeCacheOnResourceChange(uriBefore, uriAfter, domain, tags, testString, done) {
const udpServer = dgram.createSocket('udp4');
let closed = false;
udpServer.on('message', (msg) => {
try {
msg = msg.slice(22, 22 + msg.readInt16BE(20)).toString();
... |
18,129 | fa00c34e3f39c1ea92917f09e0648b7a | swh:1:cnt:73899d8ed25aa5677a102c5b2c90313a9f507da5;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=726-784/ | 491972a04c363c9ea0f5e2ef38774dc2d521f68b | change-propagation | deployed | test/feature/update_rules.js | backlinksTest | function | function backlinksTest(pageTitle, topic) {
const mwAPI = nockWithOptionalSiteInfo()
.get(`/api/rest_v1/page/title/${ pageTitle }`)
.query({ redirect: false })
.optionally()
.reply(200)
.post('/w/api.php', {
format: 'json',
... |
18,130 | 1bd9a96890fec3fa550d3d705660572d | swh:1:cnt:713b3fcb90d9d0dbb6e166f7c6318533836b07b6;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=10-28/ | 6e001d34afe0ca9340771b6d5007e22ec40626df | change-propagation | deployed | test/utils/changeProp.js | ChangePropServer | type | class ChangePropServer extends TestServer {
constructor(configPath = `${ __dirname }/../../config.test.yaml`) {
super(configPath);
}
start() {
return super.start()
.delay(process.env.MOCK_SERVICES ? 0 : CHANGE_PROP_START_DELAY);
}
stop() {
if (this._running) {
... |
18,131 | 3fc3d990710029a5eb591dd9261249bf | swh:1:cnt:713b3fcb90d9d0dbb6e166f7c6318533836b07b6;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=11-13/ | 6e001d34afe0ca9340771b6d5007e22ec40626df | change-propagation | deployed | test/utils/changeProp.js | ChangePropServer::constructor | function | constructor(configPath = `${ __dirname }/../../config.test.yaml`) {
super(configPath);
} |
18,132 | 1f13f1cabff64939541c852a85004151 | swh:1:cnt:713b3fcb90d9d0dbb6e166f7c6318533836b07b6;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=15-18/ | 6e001d34afe0ca9340771b6d5007e22ec40626df | change-propagation | deployed | test/utils/changeProp.js | ChangePropServer::start | function | start() {
return super.start()
.delay(process.env.MOCK_SERVICES ? 0 : CHANGE_PROP_START_DELAY);
} |
18,133 | fcfcbadb87ca08b122d7e552532ed318 | swh:1:cnt:713b3fcb90d9d0dbb6e166f7c6318533836b07b6;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=20-27/ | 6e001d34afe0ca9340771b6d5007e22ec40626df | change-propagation | deployed | test/utils/changeProp.js | ChangePropServer::stop | function | stop() {
if (this._running) {
return super.stop()
.tap(() => common.clearKafkaFactory())
.delay(process.env.MOCK_SERVICES ? 0 : CHANGE_PROP_STOP_DELAY);
}
return P.resolve();
} |
18,134 | 83b856add77e829528310dd166b4ac00 | swh:1:cnt:04217cbd60f0dd2311a80727561e78660d990b73;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=233-249/ | 0d875593fc6261d388db2bd1f80739961059c0b8 | change-propagation | deployed | test/utils/common.js | pageMove | function | pageMove(
uri = 'https://en.wikipedia.org/api/rest_v1/page/html/Main_Page',
oldTitle = 'New_Title',
dt = new Date().toISOString()
) {
return Object.assign(commonMWEvent(
'mediawiki/page/move/1.0.0',
'mediawiki.page-move',
uri,
dt
... |
18,135 | 72a65cf8e153b337e967d553401dfd43 | swh:1:cnt:04217cbd60f0dd2311a80727561e78660d990b73;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=250-264/ | 0d875593fc6261d388db2bd1f80739961059c0b8 | change-propagation | deployed | test/utils/common.js | pagePropertiesChange | function | pagePropertiesChange(
uri = 'https://en.wikipedia.org/api/rest_v1/page/html/Main_Page',
dt = new Date().toISOString()
) {
return Object.assign(commonMWEvent(
'mediawiki/page/properties-change/1.0.0',
'mediawiki.page-properties-change',
uri,
dt
... |
18,136 | 8ad71661b1bf722fecde0f4ed70fb92b | swh:1:cnt:04217cbd60f0dd2311a80727561e78660d990b73;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=222-232/ | 0d875593fc6261d388db2bd1f80739961059c0b8 | change-propagation | deployed | test/utils/common.js | pageDelete | function | pageDelete(
uri = 'https://en.wikipedia.org/api/rest_v1/page/html/Main_Page',
dt = new Date().toISOString()
) {
return commonMWEvent(
'mediawiki/page/delete/1.0.0',
'mediawiki.page-delete',
uri,
dt
);
} |
18,137 | d83e91dd35627ea6754cf334e24e5243 | swh:1:cnt:04217cbd60f0dd2311a80727561e78660d990b73;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=265-275/ | 0d875593fc6261d388db2bd1f80739961059c0b8 | change-propagation | deployed | test/utils/common.js | pageUndelete | function | pageUndelete(
uri = 'https://en.wikipedia.org/api/rest_v1/page/html/Main_Page',
dt = new Date().toISOString()
) {
return commonMWEvent(
'mediawiki/page/undelete/1.0.0',
'mediawiki.page-undelete',
uri,
dt
);
} |
18,138 | 327f0929c9480e51132e1f5a3f352784 | swh:1:cnt:04217cbd60f0dd2311a80727561e78660d990b73;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=276-292/ | 0d875593fc6261d388db2bd1f80739961059c0b8 | change-propagation | deployed | test/utils/common.js | revisionCreate | function | revisionCreate(
uri = 'https://en.wikipedia.org/api/rest_v1/page/html/Main_Page',
dt = new Date().toISOString()
) {
return Object.assign(commonMWEvent(
'mediawiki/revision/create/1.0.0',
'mediawiki.revision-create',
uri,
dt
), {
... |
18,139 | b9504268a48c293b378254e5f1d80777 | swh:1:cnt:04217cbd60f0dd2311a80727561e78660d990b73;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=293-305/ | 0d875593fc6261d388db2bd1f80739961059c0b8 | change-propagation | deployed | test/utils/common.js | revisionVisibilitySet | function | revisionVisibilitySet(
uri = 'https://en.wikipedia.org/api/rest_v1/page/html/Main_Page',
dt = new Date().toISOString()
) {
return Object.assign(commonMWEvent(
'mediawiki/revision/visibility-change/1.0.0',
'mediawiki.revision-visibility-change',
uri,
... |
18,140 | eaf1b5b0f53d849890fac247c0442b31 | swh:1:cnt:04217cbd60f0dd2311a80727561e78660d990b73;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=311-333/ | 0d875593fc6261d388db2bd1f80739961059c0b8 | change-propagation | deployed | test/utils/common.js | updateBetaFeaturesUserCounts | function | get updateBetaFeaturesUserCounts() {
return {
__proto__: eventMethods,
$schema: 'mediawiki/job/1.0.0',
database: 'enwiki',
meta: {
domain: 'en.wikipedia.org',
dt: new Date().toISOString(),
id: uuidv1(),
... |
18,141 | 3239c8c1e57fae54c7a6b95e53365bd1 | swh:1:cnt:04217cbd60f0dd2311a80727561e78660d990b73;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=368-397/ | 0d875593fc6261d388db2bd1f80739961059c0b8 | change-propagation | deployed | test/utils/common.js | refreshLinks | function | get refreshLinks() {
const rootSignature = common.randomString(10);
return {
__proto__: eventMethods,
$schema: 'mediawiki/job/1.0.0',
database: 'zhwiki',
mediawiki_signature: 'b2aad36ac3f784de69ad2809da3e82f6f1a08ab65f8542d626f556975fa6058c',
m... |
18,142 | 662f57874b58ea63103276b5a64bac44 | swh:1:cnt:04217cbd60f0dd2311a80727561e78660d990b73;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=334-367/ | 0d875593fc6261d388db2bd1f80739961059c0b8 | change-propagation | deployed | test/utils/common.js | htmlCacheUpdate | function | // TODO: After transition to eventgate, change to new-style events too.
get htmlCacheUpdate() {
const rootSignature = common.randomString(10);
return {
__proto__: eventMethods,
$schema: 'mediawiki/job/1.0.0',
database: 'commonswiki',
mediawiki_signatur... |
18,143 | 0377335f7f2c7f2954961d12dbd40929 | swh:1:cnt:04217cbd60f0dd2311a80727561e78660d990b73;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=398-423/ | 0d875593fc6261d388db2bd1f80739961059c0b8 | change-propagation | deployed | test/utils/common.js | cdnPurge | function | get cdnPurge() {
const releaseTimestamp = new Date(Date.now() + 3000).toISOString();
return {
__proto__: eventMethods,
$schema: 'mediawiki/job/1.0.0',
database: 'commonswiki',
delay_until: `${ releaseTimestamp }`,
mediawiki_signature: 'e6ff5af8... |
18,144 | caa2ef50194d3b2ea12bcc6b35ff2b35 | swh:1:cnt:04217cbd60f0dd2311a80727561e78660d990b73;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=201-221/ | 0d875593fc6261d388db2bd1f80739961059c0b8 | change-propagation | deployed | test/utils/common.js | resourceChange | function | resourceChange(
uri = 'https://en.wikipedia.org/api/rest_v1/page/html/Main_Page',
stream = 'resource_change',
dt = new Date().toISOString(),
tags = [ 'restbase' ]
) {
const domain = /https?:\/\/([^/]+).+/.exec(uri)[1];
return {
__proto__: eventMethods,
... |
18,145 | aa4aa284a8b167724fddd5805ae62b67 | swh:1:cnt:04217cbd60f0dd2311a80727561e78660d990b73;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=169-171/ | 0d875593fc6261d388db2bd1f80739961059c0b8 | change-propagation | deployed | test/utils/common.js | toBuffer | function | toBuffer() {
return Buffer.from(JSON.stringify(this));
} |
18,146 | f25fb9b6b070ecfda45320a7d0d22897 | swh:1:cnt:7335a38a028280eeec85087bc03b4bed02823615;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=12-18/ | 01611e12674d3bf958ecc94d0e5b585b6dede9f1 | change-propagation | deployed | test/utils/mock_kafka_factory.js | MockMetadataWatch | type | class MockMetadataWatch extends EventEmitter {
getTopics() {
return P.resolve(fixtureTopics);
}
disconnect() {}
} |
18,147 | d5d2896a1ba02380d5beb4709971b8e2 | swh:1:cnt:7335a38a028280eeec85087bc03b4bed02823615;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=20-38/ | 01611e12674d3bf958ecc94d0e5b585b6dede9f1 | change-propagation | deployed | test/utils/mock_kafka_factory.js | MockProducer | type | class MockProducer {
constructor(messages) {
this._messages = messages;
}
produce(topic, partition, message) {
if (!this._messages.has(topic)) {
this._messages.set(topic, []);
}
this._messages.get(topic).push({
topic,
partition,
... |
18,148 | aa20bc9c65a685636661912457ffe257 | swh:1:cnt:7335a38a028280eeec85087bc03b4bed02823615;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=40-81/ | 01611e12674d3bf958ecc94d0e5b585b6dede9f1 | change-propagation | deployed | test/utils/mock_kafka_factory.js | MockConsumer | type | class MockConsumer extends EventEmitter {
constructor(messages, topics = []) {
super();
this._topics = topics;
this._messages = messages;
this._currentTopicOffsets = new Map();
}
_getCurrentOffset(topic) {
if (this._currentTopicOffsets.has(topic)) {
retur... |
18,149 | 9eb7bfa802d086c143f4dfe0bb6de991 | swh:1:cnt:7335a38a028280eeec85087bc03b4bed02823615;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=83-130/ | 01611e12674d3bf958ecc94d0e5b585b6dede9f1 | change-propagation | deployed | test/utils/mock_kafka_factory.js | MockKafkaFactory | type | class MockKafkaFactory {
constructor() {
this._messages = new Map();
}
/**
* Returns a DC name to consume from
*
* @return {string}
*/
get consumeDC() {
// TODO
return 'test_dc';
}
/**
* Returns a DC name to produce to
*
* @return {str... |
18,150 | 77cb8855536dbe1dd84671c48a942493 | swh:1:cnt:7335a38a028280eeec85087bc03b4bed02823615;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=13-15/ | 01611e12674d3bf958ecc94d0e5b585b6dede9f1 | change-propagation | deployed | test/utils/mock_kafka_factory.js | MockMetadataWatch::getTopics | function | getTopics() {
return P.resolve(fixtureTopics);
} |
18,151 | a8e68fdf5424d8c8a2ac8de83c4749bc | swh:1:cnt:7335a38a028280eeec85087bc03b4bed02823615;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=21-23/ | 01611e12674d3bf958ecc94d0e5b585b6dede9f1 | change-propagation | deployed | test/utils/mock_kafka_factory.js | MockProducer::constructor | function | constructor(messages) {
this._messages = messages;
} |
18,152 | 66765b571bcb4b5f880ade6ca664c6e4 | swh:1:cnt:7335a38a028280eeec85087bc03b4bed02823615;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=25-35/ | 01611e12674d3bf958ecc94d0e5b585b6dede9f1 | change-propagation | deployed | test/utils/mock_kafka_factory.js | MockProducer::produce | function | produce(topic, partition, message) {
if (!this._messages.has(topic)) {
this._messages.set(topic, []);
}
this._messages.get(topic).push({
topic,
partition,
value: message
});
return P.resolve();
} |
18,153 | 093926fd41c65e975e0abbd165d233b6 | swh:1:cnt:7335a38a028280eeec85087bc03b4bed02823615;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=37-37/ | 01611e12674d3bf958ecc94d0e5b585b6dede9f1 | change-propagation | deployed | test/utils/mock_kafka_factory.js | MockProducer::disconnect | function | disconnect() {} |
18,154 | 093926fd41c65e975e0abbd165d233b6 | swh:1:cnt:7335a38a028280eeec85087bc03b4bed02823615;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=17-17/ | 01611e12674d3bf958ecc94d0e5b585b6dede9f1 | change-propagation | deployed | test/utils/mock_kafka_factory.js | MockMetadataWatch::disconnect | function | disconnect() {} |
18,155 | 9b0c734fc63305247a5cef45ddab31a8 | swh:1:cnt:7335a38a028280eeec85087bc03b4bed02823615;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=41-46/ | 01611e12674d3bf958ecc94d0e5b585b6dede9f1 | change-propagation | deployed | test/utils/mock_kafka_factory.js | MockConsumer::constructor | function | constructor(messages, topics = []) {
super();
this._topics = topics;
this._messages = messages;
this._currentTopicOffsets = new Map();
} |
18,156 | 11d52a68ed23659fcf69e9b3195b1467 | swh:1:cnt:7335a38a028280eeec85087bc03b4bed02823615;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=48-53/ | 01611e12674d3bf958ecc94d0e5b585b6dede9f1 | change-propagation | deployed | test/utils/mock_kafka_factory.js | MockConsumer::_getCurrentOffset | function | _getCurrentOffset(topic) {
if (this._currentTopicOffsets.has(topic)) {
return this._currentTopicOffsets.get(topic);
}
return 0;
} |
18,157 | 093926fd41c65e975e0abbd165d233b6 | swh:1:cnt:7335a38a028280eeec85087bc03b4bed02823615;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=55-55/ | 01611e12674d3bf958ecc94d0e5b585b6dede9f1 | change-propagation | deployed | test/utils/mock_kafka_factory.js | MockConsumer::disconnect | function | disconnect() {} |
18,158 | f82f84e32d7871f5560fd35c5417894d | swh:1:cnt:7335a38a028280eeec85087bc03b4bed02823615;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=57-57/ | 01611e12674d3bf958ecc94d0e5b585b6dede9f1 | change-propagation | deployed | test/utils/mock_kafka_factory.js | MockConsumer::disconnectAsync | function | disconnectAsync() {} |
18,159 | 824597f0c39668dcfb5950e2559c93a3 | swh:1:cnt:7335a38a028280eeec85087bc03b4bed02823615;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=59-76/ | 01611e12674d3bf958ecc94d0e5b585b6dede9f1 | change-propagation | deployed | test/utils/mock_kafka_factory.js | MockConsumer::consumeAsync | function | consumeAsync() {
for (const topic of this._topics) {
if (this._messages.has(topic)) {
const topicMessages = this._messages.get(topic);
const currentTopicOffset = this._getCurrentOffset(topic);
if (topicMessages.length > currentTopicOffset) {
... |
18,160 | cdd0d466223cb6a7aac4a73d0295cbab | swh:1:cnt:7335a38a028280eeec85087bc03b4bed02823615;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=84-86/ | 01611e12674d3bf958ecc94d0e5b585b6dede9f1 | change-propagation | deployed | test/utils/mock_kafka_factory.js | MockKafkaFactory::constructor | function | constructor() {
this._messages = new Map();
} |
18,161 | f50e9313f4cbea54f7099297cac5d0cc | swh:1:cnt:7335a38a028280eeec85087bc03b4bed02823615;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=98-106/ | 01611e12674d3bf958ecc94d0e5b585b6dede9f1 | change-propagation | deployed | test/utils/mock_kafka_factory.js | MockKafkaFactory::produceDC | function | /**
* Returns a DC name to produce to
*
* @return {string}
*/
get produceDC() {
// TODO
return 'test_dc';
} |
18,162 | 42ad288532bf36d87f270e1a58e25472 | swh:1:cnt:7335a38a028280eeec85087bc03b4bed02823615;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=108-117/ | 01611e12674d3bf958ecc94d0e5b585b6dede9f1 | change-propagation | deployed | test/utils/mock_kafka_factory.js | MockKafkaFactory::createConsumer | function | /**
* Create new KafkaConsumer and connect it.
*
* @param {string} groupId Consumer group ID to use
* @param {Array} topics Topics to subscribe to
* @return {Object} kafka consumer
*/
createConsumer(groupId, topics) {
return P.resolve(new MockConsumer(this._messages, topics));
... |
18,163 | ad57ce08d1edee6cc8524ca73d367e40 | swh:1:cnt:7335a38a028280eeec85087bc03b4bed02823615;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=127-129/ | 01611e12674d3bf958ecc94d0e5b585b6dede9f1 | change-propagation | deployed | test/utils/mock_kafka_factory.js | MockKafkaFactory::createGuaranteedProducer | function | createGuaranteedProducer() {
return this.createProducer();
} |
18,164 | ab072b97216d9fa24973abe45ddbb6a0 | swh:1:cnt:7335a38a028280eeec85087bc03b4bed02823615;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=123-125/ | 01611e12674d3bf958ecc94d0e5b585b6dede9f1 | change-propagation | deployed | test/utils/mock_kafka_factory.js | MockKafkaFactory::createProducer | function | createProducer() {
return P.resolve(new MockProducer(this._messages));
} |
18,165 | 666b44199600ee49dabf934e3b57673a | swh:1:cnt:7335a38a028280eeec85087bc03b4bed02823615;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=119-121/ | 01611e12674d3bf958ecc94d0e5b585b6dede9f1 | change-propagation | deployed | test/utils/mock_kafka_factory.js | MockKafkaFactory::createMetadataWatch | function | createMetadataWatch() {
return P.resolve(new MockMetadataWatch());
} |
18,166 | b497489a39064fd88efe427c7437e9e7 | swh:1:cnt:7335a38a028280eeec85087bc03b4bed02823615;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=88-96/ | 01611e12674d3bf958ecc94d0e5b585b6dede9f1 | change-propagation | deployed | test/utils/mock_kafka_factory.js | MockKafkaFactory::consumeDC | function | /**
* Returns a DC name to consume from
*
* @return {string}
*/
get consumeDC() {
// TODO
return 'test_dc';
} |
18,167 | 4fda9d0461d386a20665e1d749385a60 | swh:1:cnt:7335a38a028280eeec85087bc03b4bed02823615;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=78-80/ | 01611e12674d3bf958ecc94d0e5b585b6dede9f1 | change-propagation | deployed | test/utils/mock_kafka_factory.js | MockConsumer::commitMessageAsync | function | commitMessageAsync() {
return P.resolve();
} |
18,168 | 3b4a8b3fe42d0a879980f314ace917f7 | swh:1:cnt:0155dc31f19d9b38b3b8397cb11436178a2ca921;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=32-105/ | 9558ca98866dcf2b543e60b186afad40f87e0a56 | pageview-api | analytics | backend/aggregate.cpp | LinePeekableFile | type | /**
* A buffer in which lines can be peeked or consumed.
*/
class LinePeekableFile
{
static const int CHUNK_SIZE = 10;
public:
LinePeekableFile(std::string name,std::istream *in):
m_in(in),m_name(name),m_cachePresent(false),m_isGood(true)
{
}
L... |
18,169 | 1d845e2808f7e54f842231ba2cd5988a | swh:1:cnt:0155dc31f19d9b38b3b8397cb11436178a2ca921;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=40-43/ | 9558ca98866dcf2b543e60b186afad40f87e0a56 | pageview-api | analytics | backend/aggregate.cpp | LinePeekableFile(std::string name,std::istream *in) | function | LinePeekableFile(std::string name,std::istream *in):
m_in(in),m_name(name),m_cachePresent(false),m_isGood(true)
{
} |
18,170 | f627bca291277d7d3fcf98abd10e1ae9 | swh:1:cnt:0155dc31f19d9b38b3b8397cb11436178a2ca921;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=51-63/ | 9558ca98866dcf2b543e60b186afad40f87e0a56 | pageview-api | analytics | backend/aggregate.cpp | LinePeekableFile::LinePeekableFile(const LinePeekableFile &other) | function | LinePeekableFile &operator=(const LinePeekableFile &other)
{
if (this != &other)
{
m_isGood = other.m_isGood;
m_cachePresent = other.m_cachePresent;
m_cache = other.m_cache;
m_name = other.m_name;
m_in = othe... |
18,171 | 5dfc0870dad40dd4a2d44378e3ff47d6 | swh:1:cnt:0155dc31f19d9b38b3b8397cb11436178a2ca921;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=81-86/ | 9558ca98866dcf2b543e60b186afad40f87e0a56 | pageview-api | analytics | backend/aggregate.cpp | LinePeekableFile::get() | function | const std::string &get()
{
const std::string &ret = peek();
m_cachePresent = false;
return ret;
} |
18,172 | 22a002a4992ffb0113763cc1bbd6ece1 | swh:1:cnt:0155dc31f19d9b38b3b8397cb11436178a2ca921;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=93-96/ | 9558ca98866dcf2b543e60b186afad40f87e0a56 | pageview-api | analytics | backend/aggregate.cpp | LinePeekableFile::name() | function | const std::string &name()
{
return m_name;
} |
18,173 | 788640fe595d10e3b9f88eb10819ff4c | swh:1:cnt:0155dc31f19d9b38b3b8397cb11436178a2ca921;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=130-153/ | 9558ca98866dcf2b543e60b186afad40f87e0a56 | pageview-api | analytics | backend/aggregate.cpp | urldecode(const std::string &in) | function | std::string urldecode(const std::string &in)
{
std::string result;
//std::cout << "'" << in << "'" << std::endl;
for(int i=0;i<in.length();i++)
{
if (in[i] == '%')
{
char ch[3];
// Malformed, just ignore last.
if (i > in.length() - 2)
return result;
ch[0]=in[++i]; ... |
18,174 | bb7154a30b94353444719fd1b97c60ec | swh:1:cnt:0155dc31f19d9b38b3b8397cb11436178a2ca921;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=169-177/ | 9558ca98866dcf2b543e60b186afad40f87e0a56 | pageview-api | analytics | backend/aggregate.cpp | getIndexOffset(std::string in) | function | int getIndexOffset(std::string in)
{
char s[8];
memset(s,0,8);
strncpy(s,in.c_str(),7);
long res = ((long)s[0])*(1ULL<<18)+s[1]*(1<<15)+s[2]*(1<<12)+s[3]*(1<<9)+s[4]*(1<<6)+s[5]*(1<<3)+s[6];
return res;
} |
18,175 | 3221dbcd77eded54c6fe5f5eecc47121 | swh:1:cnt:0155dc31f19d9b38b3b8397cb11436178a2ca921;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=65-79/ | 9558ca98866dcf2b543e60b186afad40f87e0a56 | pageview-api | analytics | backend/aggregate.cpp | LinePeekableFile::peek() | function | const std::string &peek()
{
if(m_cachePresent)
{
return m_cache;
}
getline(*m_in,m_cache);
if (m_in->eof())
{
m_isGood = false;
}
m_cachePresent = true;
return ... |
18,176 | 3e3e2432d4c003861843ce74ae682318 | swh:1:cnt:0155dc31f19d9b38b3b8397cb11436178a2ca921;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=88-91/ | 9558ca98866dcf2b543e60b186afad40f87e0a56 | pageview-api | analytics | backend/aggregate.cpp | LinePeekableFile::good() | function | bool good()
{
return m_isGood;
} |
18,177 | 0f42a1e8c01de21509992b098099b429 | swh:1:cnt:0155dc31f19d9b38b3b8397cb11436178a2ca921;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=108-126/ | 9558ca98866dcf2b543e60b186afad40f87e0a56 | pageview-api | analytics | backend/aggregate.cpp | tokenize(const std::string& str,
std::vector<std::string>& tokens,
const std::string& delimiters = " ") | function | void tokenize(const std::string& str,
std::vector<std::string>& tokens,
const std::string& delimiters = " ")
{
// Skip delimiters at beginning.
std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
// Find first "non-delimiter".
std::string::size_type pos ... |
18,178 | 49704c10898a925c7825ae0869b93cb5 | swh:1:cnt:0155dc31f19d9b38b3b8397cb11436178a2ca921;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=155-167/ | 9558ca98866dcf2b543e60b186afad40f87e0a56 | pageview-api | analytics | backend/aggregate.cpp | trim(const std::string &in) | function | std::string trim(const std::string &in)
{
if (in.empty())
return "";
int sidx=in.find_first_not_of(" \t\n");
int eidx=in.find_last_not_of(" \t\n");
if (sidx==std::string::npos || eidx==std::string::npos)
return "";
return in.substr(sidx,eidx-sidx+1);
} |
18,179 | f9c5c6a874dd95078269d7f29ed66ecf | swh:1:cnt:0155dc31f19d9b38b3b8397cb11436178a2ca921;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=178-272/ | 9558ca98866dcf2b543e60b186afad40f87e0a56 | pageview-api | analytics | backend/aggregate.cpp | aggregate(std::vector<LinePeekableFile> &files,std::ostream &output) | function | void aggregate(std::vector<LinePeekableFile> &files,std::ostream &output)
{
long long offset = 0;
std::priority_queue<std::string,std::vector<std::string>,std::greater<std::string> > candidates;
for(std::vector<LinePeekableFile>::iterator it = ++files.begin();
it != files.end();
it++)
... |
18,180 | e1080cdeb0b4d4b776f6d62b27ab0bee | swh:1:cnt:0155dc31f19d9b38b3b8397cb11436178a2ca921;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=278-295/ | 9558ca98866dcf2b543e60b186afad40f87e0a56 | pageview-api | analytics | backend/aggregate.cpp | testLinePeek(std::string str) | function | void testLinePeek(std::string str)
{
std::stringstream ibuf(str);
LinePeekableFile lp("",&ibuf);
QUNIT_IS_EQUAL(lp.peek(),"foo");
QUNIT_IS_EQUAL(lp.get(),"foo");
QUNIT_IS_EQUAL(lp.peek(),"bar");
QUNIT_IS_EQUAL(lp.peek(),"bar");
QUNIT_IS_EQUAL(lp.get(),"bar");
QUNIT_IS_EQUAL(lp.get(... |
18,181 | 5e771cf75e462a225c458c64a2115bb9 | swh:1:cnt:0155dc31f19d9b38b3b8397cb11436178a2ca921;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=297-323/ | 9558ca98866dcf2b543e60b186afad40f87e0a56 | pageview-api | analytics | backend/aggregate.cpp | testAggregate() | function | void testAggregate()
{
std::stringstream a("aa foo 1 1\n");
std::stringstream b("aa foo 16 16\nbb foo 2 2\ncc nisse 3 3\n");
std::stringstream c("aa bar 4 4\n");
std::stringstream d("bb foo 8 8\n");
std::vector<LinePeekableFile> files;
files.push_back(LinePeekableFile("",&a));
files.pus... |
18,182 | 7807a64bdfd1fed8f2607f1a62835483 | swh:1:cnt:0155dc31f19d9b38b3b8397cb11436178a2ca921;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=326-333/ | 9558ca98866dcf2b543e60b186afad40f87e0a56 | pageview-api | analytics | backend/aggregate.cpp | test() | function | void test()
{
#ifdef TESTING
testLinePeek("foo\nbar\nbla\nbaz\n");
testLinePeek("foo\nbar\nbla\nbaz");
testAggregate();
#endif
} |
18,183 | 50320156166c35f2ff52367c6eb31b90 | swh:1:cnt:0155dc31f19d9b38b3b8397cb11436178a2ca921;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=335-360/ | 9558ca98866dcf2b543e60b186afad40f87e0a56 | pageview-api | analytics | backend/aggregate.cpp | main(int argc,char *argv[]) | function | int main(int argc,char *argv[])
{
if (argc == 1)
{
test();
return 0;
}
std::vector<LinePeekableFile> files;
for(int i=1;i<argc;i++)
{
std::ifstream *inf = new std::ifstream(argv[i]);
if (!inf)
{
std::cerr << "Couldn't open " << argv[i] ... |
18,184 | 62e96c070fe8a34d1d6f38c078c0e514 | swh:1:cnt:1c711834ecbc340f7326cee0e95449ab36bdf260;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=32-110/ | 139a44f22507fcb0faaaf918c607bbc238a9e4ef | pageview-api | analytics | backend/aggregate_month.cpp | LinePeekableFile | type | /**
* A buffer in which lines can be peeked or consumed.
*/
class LinePeekableFile
{
static const int CHUNK_SIZE = 10;
public:
int line;
LinePeekableFile(std::string name,std::istream *in):
m_in(in),m_name(name),m_cachePresent(false),m_isGood(true)
{
... |
18,185 | a3a654455a397b7448b082daa8fe6d2a | swh:1:cnt:1c711834ecbc340f7326cee0e95449ab36bdf260;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=42-46/ | 139a44f22507fcb0faaaf918c607bbc238a9e4ef | pageview-api | analytics | backend/aggregate_month.cpp | LinePeekableFile(std::string name,std::istream *in) | function | LinePeekableFile(std::string name,std::istream *in):
m_in(in),m_name(name),m_cachePresent(false),m_isGood(true)
{
line=0;
} |
18,186 | e49bcb7f8b542316be3733cda48cbaa7 | swh:1:cnt:1c711834ecbc340f7326cee0e95449ab36bdf260;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=85-91/ | 139a44f22507fcb0faaaf918c607bbc238a9e4ef | pageview-api | analytics | backend/aggregate_month.cpp | LinePeekableFile::get() | function | const std::string &get()
{
const std::string &ret = peek();
m_cachePresent = false;
line++;
return ret;
} |
18,187 | f627bca291277d7d3fcf98abd10e1ae9 | swh:1:cnt:1c711834ecbc340f7326cee0e95449ab36bdf260;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=55-67/ | 139a44f22507fcb0faaaf918c607bbc238a9e4ef | pageview-api | analytics | backend/aggregate_month.cpp | LinePeekableFile::LinePeekableFile(const LinePeekableFile &other) | function | LinePeekableFile &operator=(const LinePeekableFile &other)
{
if (this != &other)
{
m_isGood = other.m_isGood;
m_cachePresent = other.m_cachePresent;
m_cache = other.m_cache;
m_name = other.m_name;
m_in = othe... |
18,188 | 22a002a4992ffb0113763cc1bbd6ece1 | swh:1:cnt:1c711834ecbc340f7326cee0e95449ab36bdf260;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=98-101/ | 139a44f22507fcb0faaaf918c607bbc238a9e4ef | pageview-api | analytics | backend/aggregate_month.cpp | LinePeekableFile::name() | function | const std::string &name()
{
return m_name;
} |
18,189 | d2af6dd63081b7c22fdc01d6dc939975 | swh:1:cnt:1c711834ecbc340f7326cee0e95449ab36bdf260;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=135-160/ | 139a44f22507fcb0faaaf918c607bbc238a9e4ef | pageview-api | analytics | backend/aggregate_month.cpp | urldecode(const std::string &in) | function | std::string urldecode(const std::string &in)
{
std::string result;
//std::cout << "'" << in << "'" << std::endl;
for(int i=0;i<in.length();i++)
{
if (in[i] == '%')
{
char ch[3];
// Malformed, just ignore last.
if (i > in.length() - 2)
return result;
ch[0]=in[++i]; ... |
18,190 | bb7154a30b94353444719fd1b97c60ec | swh:1:cnt:1c711834ecbc340f7326cee0e95449ab36bdf260;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=176-184/ | 139a44f22507fcb0faaaf918c607bbc238a9e4ef | pageview-api | analytics | backend/aggregate_month.cpp | getIndexOffset(std::string in) | function | int getIndexOffset(std::string in)
{
char s[8];
memset(s,0,8);
strncpy(s,in.c_str(),7);
long res = ((long)s[0])*(1ULL<<18)+s[1]*(1<<15)+s[2]*(1<<12)+s[3]*(1<<9)+s[4]*(1<<6)+s[5]*(1<<3)+s[6];
return res;
} |
18,191 | 3221dbcd77eded54c6fe5f5eecc47121 | swh:1:cnt:1c711834ecbc340f7326cee0e95449ab36bdf260;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=69-83/ | 139a44f22507fcb0faaaf918c607bbc238a9e4ef | pageview-api | analytics | backend/aggregate_month.cpp | LinePeekableFile::peek() | function | const std::string &peek()
{
if(m_cachePresent)
{
return m_cache;
}
getline(*m_in,m_cache);
if (m_in->eof())
{
m_isGood = false;
}
m_cachePresent = true;
return ... |
18,192 | 3e3e2432d4c003861843ce74ae682318 | swh:1:cnt:1c711834ecbc340f7326cee0e95449ab36bdf260;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=93-96/ | 139a44f22507fcb0faaaf918c607bbc238a9e4ef | pageview-api | analytics | backend/aggregate_month.cpp | LinePeekableFile::good() | function | bool good()
{
return m_isGood;
} |
18,193 | 7c657c70cd479e9f1a7d9b463ec23b7a | swh:1:cnt:1c711834ecbc340f7326cee0e95449ab36bdf260;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=113-131/ | 139a44f22507fcb0faaaf918c607bbc238a9e4ef | pageview-api | analytics | backend/aggregate_month.cpp | tokenize(const std::string& str,
std::vector<std::string>& tokens,
const std::string& delimiters = "\t") | function | void tokenize(const std::string& str,
std::vector<std::string>& tokens,
const std::string& delimiters = "\t")
{
// Skip delimiters at beginning.
std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
// Find first "non-delimiter".
std::string::size_type pos ... |
18,194 | 49704c10898a925c7825ae0869b93cb5 | swh:1:cnt:1c711834ecbc340f7326cee0e95449ab36bdf260;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=162-174/ | 139a44f22507fcb0faaaf918c607bbc238a9e4ef | pageview-api | analytics | backend/aggregate_month.cpp | trim(const std::string &in) | function | std::string trim(const std::string &in)
{
if (in.empty())
return "";
int sidx=in.find_first_not_of(" \t\n");
int eidx=in.find_last_not_of(" \t\n");
if (sidx==std::string::npos || eidx==std::string::npos)
return "";
return in.substr(sidx,eidx-sidx+1);
} |
18,195 | f75523ccfdaa4d7b8afea301713d66d9 | swh:1:cnt:1c711834ecbc340f7326cee0e95449ab36bdf260;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=185-339/ | 139a44f22507fcb0faaaf918c607bbc238a9e4ef | pageview-api | analytics | backend/aggregate_month.cpp | aggregate(std::vector<LinePeekableFile> &files,std::ostream &output) | function | void aggregate(std::vector<LinePeekableFile> &files,std::ostream &output)
{
long long offset = 0;
std::priority_queue<std::string,std::vector<std::string>,std::greater<std::string> > candidates;
for(std::vector<LinePeekableFile>::iterator it = ++files.begin();
it != files.end();
it++)
... |
18,196 | e1080cdeb0b4d4b776f6d62b27ab0bee | swh:1:cnt:1c711834ecbc340f7326cee0e95449ab36bdf260;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=345-362/ | 139a44f22507fcb0faaaf918c607bbc238a9e4ef | pageview-api | analytics | backend/aggregate_month.cpp | testLinePeek(std::string str) | function | void testLinePeek(std::string str)
{
std::stringstream ibuf(str);
LinePeekableFile lp("",&ibuf);
QUNIT_IS_EQUAL(lp.peek(),"foo");
QUNIT_IS_EQUAL(lp.get(),"foo");
QUNIT_IS_EQUAL(lp.peek(),"bar");
QUNIT_IS_EQUAL(lp.peek(),"bar");
QUNIT_IS_EQUAL(lp.get(),"bar");
QUNIT_IS_EQUAL(lp.get(... |
18,197 | 21ddef8da613a3dcb6bdfcf2849020af | swh:1:cnt:1c711834ecbc340f7326cee0e95449ab36bdf260;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=364-395/ | 139a44f22507fcb0faaaf918c607bbc238a9e4ef | pageview-api | analytics | backend/aggregate_month.cpp | testAggregate() | function | void testAggregate()
{
std::stringstream a("aa\tfoo\t1\t1\nasda\nsaf\naf\n");
std::stringstream b("aa\tfoo\t16\t16\n"
"bb\tfoo\t2\t2\n"
"cc\tnisse\t3\t3\n");
std::stringstream c("aa\tbar\t4\t4\n");
std::stringstream d("bb\tfoo\t8\t8\n"
... |
18,198 | caec9eac73bea4f21c1e99ef1b857adb | swh:1:cnt:1c711834ecbc340f7326cee0e95449ab36bdf260;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=398-404/ | 139a44f22507fcb0faaaf918c607bbc238a9e4ef | pageview-api | analytics | backend/aggregate_month.cpp | test() | function | void test()
{
#ifdef TESTING
testLinePeek("foo\nbar\nbla\nbaz\n");
testAggregate();
#endif
} |
18,199 | 50320156166c35f2ff52367c6eb31b90 | swh:1:cnt:1c711834ecbc340f7326cee0e95449ab36bdf260;origin=https://gerrit.wikimedia.org/r/analytics/pageview-api.git;lines=406-431/ | 139a44f22507fcb0faaaf918c607bbc238a9e4ef | pageview-api | analytics | backend/aggregate_month.cpp | main(int argc,char *argv[]) | function | int main(int argc,char *argv[])
{
if (argc == 1)
{
test();
return 0;
}
std::vector<LinePeekableFile> files;
for(int i=1;i<argc;i++)
{
std::ifstream *inf = new std::ifstream(argv[i]);
if (!inf)
{
std::cerr << "Couldn't open " << argv[i] ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.