Monday, December 13, 2010

Using SVNKit from within Groovy using SvnAnt

To load in SVN Ant you use (this assumes it's in the classpath):
ant.typedef(resource: "org/tigris/subversion/svnant/svnantlib.xml")

This then allows you to use the runSvn closures:
runSvn {
"export"(srcUrl: "", destPath: "")
"import"(url: "", path: "", message: "")
"copy"(srcUrl: "", destUrl: "", message: "")
"delete"(url: "", message: "")
"checkout"(url: "", destPath: "")
"propset"(path: "", name: "", value: "")
}

SvnAnt documentation has more details.

Adding Active Directory properties to ApacheDS

One of the things I have to do during my day is replicate Active Directory in ApacheDS. The most simple properties are member and memberOf. The following uses an LDIF file to add these properties. I've reused the OID for memberOf but I think the adUser OID is from a tutorial or something so it may clash.


dn: m-oid=1.2.840.113556.1.5.8, ou=objectClasses, cn=other, ou=schema
objectclass: metaObjectClass
objectclass: metaTop
objectclass: top
m-oid: 1.2.840.113556.1.5.8
m-name: group
m-must: cn
m-may: member

dn: m-oid=1.2.840.113556.1.2.102,ou=attributeTypes,cn=other,ou=schema
m-usage: USER_APPLICATIONS
m-equality: distinguishedNameMatch
objectClass: metaAttributeType
objectClass: metaTop
objectClass: top
m-name: memberOf
m-oid: 1.2.840.113556.1.2.102
m-obsolete: FALSE
m-noUserModification: FALSE
m-syntax: 1.3.6.1.4.1.1466.115.121.1.12

dn: m-oid=1.3.6.1.4.1.18060.0.4.3.3.1, ou=objectClasses, cn=other, ou=schema
objectclass: metaObjectClass
objectclass: metaTop
objectclass: top
m-oid: 1.3.6.1.4.1.18060.0.4.3.3.1
m-name: adUser
m-supObjectClass: inetOrgPerson
m-must: cn
m-may: memberOf

What's a Dual?

Erik Meijer has been giving a talk at YOW (in Melbourne) and San Francisco at QCON about Key Value Stores being the dual of SQL.

The obvious question is what is a dual? And like most really good questions you already know the answer. Set operations AND and OR are dual. Which means that if A OR F = A is true, by replacing AND with OR and T with F (or as Erik said switching the arrows), you get A AND T = A. Likewise, A OR T = T becomes A AND F = F.

This is the bit where Maths almost becomes magical. Why should these properties hold? Why doesn't this work for multiplication and addition?

In his talk, Erik quoted Benjamin Black, that the noSQL movement took away the relational model and gave nothing back. His talk also seems to be about the beginnings of a noSQL/coSQL algebra and a project to write a noSQL database within Microsoft (noSQL Server perhaps?). He's not the only one thinking about these kinds of things obviously.

He also mentioned, closure as an important property of numbers and other things. That is you plug 1 + 1 in, you get 2 and you can plug 2 into + 1 and get 3 and so on - the answer of one operation can be used for the next. You can't do that with SQL or SPARQL, which in my mind is a big fail. Erik agrees - and suggested that noSQL (or coSQL) should support this property. He's not the only one to think that noSQL should support the Unix philosophy (which is not just closure but is an important part of it). And he's certainly not going to be the last.

He described these properties in the same way as I discovered them in RDF, which was through graphs. The object model in LINQ has a graph of objects - objects which don't have a globally identifiable name - much like blank nodes. The cool thing about LINQ, well one of the many cool things, is that it supports closure - you query your object graph, you get back another object graph and can continue to plug away at it as you narrow your query. This certainly makes a lot of sense from a user querying data perspective (among others) - where you start with all students, you ask for all male students, then you ask for all male students with a grade point average about 5 or whatever. Narrower and narrower is one typical way people find the answer they're looking for.

The other thing he mentions is that SQL is a nightmare due to normalization, the complexity of queries, null semantics and computing over them and the difference between objects and tables. Erik showed that objects and relations are dual.

This is the bit where I introduce monads and say it's like pizza delivery or something. Screw that. It's just good in that if your operations follow laws then they can be mapped to other things and inherit any work done to make them good - like optimisation or scaling. In Erik's talk that meant finding out cool things like noSQL being dual to SQL and LINQ can be done as MapReduce (see this slide of Erik's). This works because LINQ operations are associative and MapReduce operations are also associative. It's not just a good idea it's a monadic law. If you can, read 10 pages on category theory (I'm only up to page 8 though).

Obviously, not everything is peaches. The noSQL/coSQL people say don't do joins - they don't scale - you can't self join on the web for example. In a MapReduce/noSQL system you either end up querying multiple times or you end up processing the data again. I'd suggest that someone will write a library that does multiple queries and joins over noSQL databases so that you don't have to do it yourself - maybe locally and in memory at first, and then with disk based structures for scalability later - I guess this is where LINQ would fit in.

There were lots of dualing properties in the relational vs noSQL/coSQL talk. I only remember a few SQL vs noSQL/coSQL: closed world vs open world, identity by value vs identity by reference (or properties), and (I might be wrong) transactional vs non-transactional.

So with our arrows in hand, ignoring how cool the world will be without JOINs and UNIONs and our mighty knowledge of set theory, what would JOIN and UNION look like if they were a dual and if such a thing existed as 0 and U for relations. U JOIN R = R becomes 0 UNION R = R and likewise U UNION R = U becomes 0 JOIN R = 0 (which matches my existing prejudices).

Just to put the cherry on this pig of a blog post (to mix metaphors), objects and functions look like duals too (given that people claim there's no meaning behind what an object is and what a dual is I feel safe anyway):

But from another perspective, the apply "method" of a closure can be used as a low-level method dispatch mechanism, so closures can be, and are, used to implement very effective objects with multiple methods...With closures seen as a building block with which to implement objects, it's clear that objects are a poor man's closures...If your language only has these restricted closures, and you're forced to build an object system on top of them, it's clear that closures are a poor man's objects.

Erik via Eugene Wigner said there's an unreasonable effectiveness of mathematics and I have to agree. Monads, duals, properties for LINQ, noSQL, relational databases, SPARQL, and so on. Very unreasonable and very cool.


Sunday, September 12, 2010

WebDAV No More

This is reasonably old news. And has been obvious pretty much since WebDAV began. But it's interesting to listen to Greg Stein talk about WebDAV, it's history and the reason why it was put into Subversion. At the moment if you want to go over HTTP for Subversion there's not any other option.

In the next version of Subversion, 1.7, there's going to be a new, not your father's, Subverison over HTTP. It basically means stop pretending to be WebDAV and fix it's problems. Perhaps the most interesting of which is that versions will have public URIs rather than going around and around using PROPFINDs. The WebDAV methods remain but it does look like the sprinkle it with some proprietary headers like X-SVN-Version-Name (which seems like a sensible way to send "the version I last knew about" information without the WebDAV tomfoolery).

As well, there's some other Git like features (svn patch to support Git's format). While I probably still favour DCVS for OS projects, Subversion still makes sense a lot of times.

Monday, June 28, 2010

Sunday, January 17, 2010

Functional Mainstream

From reading, "Functional Programming Doesn't Work (and what to do about it)" - I found this post along similar lines, "Functional Programming Went Mainstream Years Ago":
You can view a Perl (or Python or Ruby or Lua or Rebol) program as a series of small functional programs connected by a lightweight imperative program...0% of the impressive magic from early functional languages has been rolled into mainstream languages. That last 10%, well, it's not clear that anyone is really wanting it or that the benefits are actually there. Purity has some advantages, but it's so convenient and useful to directly modify a dictionary in Python. Fold and map are beautiful, but they work just as well in the guise of a foreach loop.