In [ ]:
In [1]:
import asm_utils as util
In [3]:
data = util.get_collection(collection='samples')
all_data = util.get_collection()
In [4]:
data.count()
Out[4]:
In [124]:
In [153]:
## Gets average number of unique assembly instruction counts for all classes
map = '''function() {
emit(this.class, this.asm_info.num_uniq_instr);
};
'''
reduce = '''
function(key, value) {
return Array.sum(value)/value.length;
}
'''
In [154]:
data.map_reduce(map, reduce, {'inline':1})
Out[154]:
In [151]:
## Gets average number of unique assembly instruction counts for all classes
map = '''function() {
emit(this.class, {uniq: this.asm_info.num_uniq_instr, tot: this.asm_info.num_instr});
};
'''
reduce = '''
function(key, value) {
var res = { uniqs:0, tots: 0 }
var count = 0;
value.forEach(function(value) {
res.uniqs += value.uniq;
res.tots += value.tot;
count += 1;
})
res.uniqs = res.uniqs/count;
res.tots = res.tots/count;
return res;
}
'''
In [152]:
data.map_reduce(map, reduce, {'inline':1})
Out[152]:
In [182]:
# This one gets the counts of all classes.
map = '''function() {
emit(this.class, 1);
};
'''
reduce = '''
function(key, value) {
return Array.sum(value);
}
'''
In [183]:
result = data.map_reduce(map, reduce, {'inline':1})
result
Out[183]:
In [157]:
result = all_data.map_reduce(map, reduce, {'inline':1})
In [158]:
result
Out[158]:
In [5]:
# This one gets the counts of all classes.
map = '''function() {
emit(this.class, 1);
};
'''
reduce = '''
function(key, value) {
return Array.sum(value);
}
'''
In [8]:
result = all_data.map_reduce(map, reduce, {'inline':1}, query={'dlls': []})
In [9]:
result
Out[9]:
In [168]:
comments = [['word', 'comment'],['wdofas', 'dafsdf']]
comments
Out[168]:
In [161]:
data.find_one().keys()
Out[161]:
In [197]:
comments = all_data.find({"class": '5'})
In [201]:
coms = [com['ida_comments'] for com in all_data.find()]
In [200]:
len(coms)
Out[200]:
In [ ]: