Skip to content

Commit

Permalink
Formating #2
Browse files Browse the repository at this point in the history
  • Loading branch information
sanel committed Jan 20, 2012
1 parent fd33551 commit 6450fec
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions EXTENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

0 comments on commit 6450fec

Please sign in to comment.