From 6450feca0e358494b0ec34a76bf6e01ab824d34a Mon Sep 17 00:00:00 2001 From: Sanel Zukan Date: Fri, 20 Jan 2012 13:54:46 +0100 Subject: [PATCH] Formating #2 --- EXTENDING.md | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/EXTENDING.md b/EXTENDING.md index 04f6f78..b75111e 100644 --- a/EXTENDING.md +++ b/EXTENDING.md @@ -143,34 +143,33 @@ Instead, I created simple command (named it _do-magic_) with the following conte "Add million rows to 'demo2' table" [] (hbase.core/with-connection + ;; create table object using current connection and operate on 'demo2' table + (def table (HTable. (hbase.core/hbase-conf) "demo2")) - ;; create table object using current connection and operate on 'demo2' table - (def table (HTable. (hbase.core/hbase-conf) "demo2")) + ;; this is the way how we loop in clojure; we start with 'i = 0' and ends when it + ;; gets to 'e' which is million; during the iteration, we append new row with + ;; the name 'row_X' with value X, where X is current iteration number - ;; this is the way how we loop in clojure; we start with 'i = 0' and ends when it - ;; gets to 'e' which is million; during the iteration, we append new row with - ;; the name 'row_X' with value X, where X is current iteration number + ;; rest of the code is pretty much ordinary HBase API usage; create family, qualifier, + ;; convert names/value to bytes and fill table with appropriate Put object + (loop [i 0 + e 1000000 + familly (Bytes/toBytes "f1") + qualifier (Bytes/toBytes "q")] ;; some qualifier - ;; rest of the code is pretty much ordinary HBase API usage; create family, qualifier, - ;; convert names/value to bytes and fill table with appropriate Put object - (loop [i 0 - e 1000000 - familly (Bytes/toBytes "f1") - qualifier (Bytes/toBytes "q")] ;; some qualifier + (let [row (Bytes/toBytes (format "row_%d" i)) + value (Bytes/toBytes (str i)) + p (Put. row)] - (let [row (Bytes/toBytes (format "row_%d" i)) - value (Bytes/toBytes (str i)) - p (Put. row)] + ;; simple status so I know how long to wait + (printf "Adding %d\n" (inc i)) - ;; simple status so I know how long to wait - (printf "Adding %d\n" (inc i)) + (.add p familly qualifier value) + (.put table p) - (.add p familly qualifier value) - (.put table p) - - ;; recurse to 'loop' - (if (< i e) - (recur (inc i) e familly qualifier) ))))) + ;; recurse to 'loop' + (if (< i e) + (recur (inc i) e familly qualifier) ))))) ``` Job done! It took me a couple of minutes to finish this on computer where only java was installed (using hubris with all dependencies).