Java SE

Optimized Character Escaper for Java

I wanted to write my own character escaper for requests going to Apache Lucent.
After writing my own, I also received feedback from programmers-stackexchange which resulted in the fastest implementation, also posted here. (Thanks to MrSmit42)

Below is my application that tests 6 different slightly different implementations over 30,000,000 executions each and outputs the time in MS.

The results in MS (on my computer) were the following:

Method 1 (Boolean Array)->    7574
Method 0 (Switch Stmt)->    9778
Method 4 (Switch Stmt Ugly – BreakPoints after evert case)->    12451
Method 6 (HashSet)->    17273
Method 5 (EnumMap)->    39516
Method 3 (Pattern/Regex)->    98229

This proves that for production systems that have many requests, jumping directly on the RegEx bandwagon for even trivial problems is not always the solution.
Even a 0,5 MS reduction per request leads to 50MS saved over 100 requests (per second) and 500MS over 1000 requests.

[polldaddy poll=7418939]

More

Data insertion to CouchDB using Lightcouch lib in Java (Sample)

Introduction

Hello, a small sample on how to insert JSON data to couchDB.

First off there are MANY java libraries for accessing couchdb. For information on which one to choose for you the 2 links below may help:
1) http://stackoverflow.com/questions/1105807/which-java-library-libraries-for-couchdb
2) http://wiki.apache.org/couchdb/Getting_started_with_Java

In this post we made use of LightCouch as we wanted something relatively simple without object mappings and other such features.

Aside: an also interesting tutorial utilizing couchdb4j with description of sessions is: http://www.drdobbs.com/jvm/223100116

More