Wednesday, June 29, 2011

mongodb - understanding the mapReduce

From my experiences the reduce function is operatable only on the emitted results.
If the record is not emitted(grouped) then the reduce function make NOTHING
with this record.

in case of max/min calculation this state can not be catch.
Not emitted records are already have it is max/min value as the one is only one
value in interested field but not a result of the reduce function.

the mentioned state is clearly observed when you try to modify the existing field
that come from emit.

for example:

db.test.drop();
db.test.insert({username:"0000001453"});
db.test.insert({username:"0000000018"});
//db.test.insert({username:"0000000018"});//try with and w/o this.

m=function(){
emit({username:this.username}, {firstname:"firstname",lastname:"lastname"});
}
r=function(key,values){
var x=values[0];
x.firstname="smth";//no effect when not emitted
x.lastname ="smth";//no effect when not emitted
return x;
}
db.test.mapReduce(m,r,{out:"results"});
db.results.find();

Monday, May 9, 2011

x509 SubjectAlternativeNameExtension GeneralNames

SubjectAltName ::= GeneralNames
GeneralNames ::= SEQUENCE SIZE (1..MAX) OF GeneralName
GeneralName ::= CHOICE {
otherName [0] OtherName,
rfc822Name [1] IA5String,
dNSName [2] IA5String,
x400Address [3] ORAddress,
directoryName [4] Name,
ediPartyName [5] EDIPartyName,
uniformResourceIdentifier [6] IA5String,
iPAddress [7] OCTET STRING,
registeredID [8] OBJECT IDENTIFIER}


CertificateExtensions ext = new CertificateExtensions();

DNSName dNSName = new DNSName("shahbazov.com");
GeneralName generalName= new GeneralName(dNSName);
GeneralNames generalNames = new GeneralNames();
generalNames.add(generalName);
ext.set(SubjectAlternativeNameExtension.NAME,
new SubjectAlternativeNameExtension(generalNames));

X509CertInfo info = new X509CertInfo();
...
...
info.set(X509CertInfo.EXTENSIONS, ext);

X509CertImpl cert = new X509CertImpl(info);