Skip to content

Commit

Permalink
Adding EXERCISES.md to match hbase shell exercises from HBase book
Browse files Browse the repository at this point in the history
(Stack proposal). Also begin implementing 'create' command.

CTRL-D is now handled properly, hope so.
  • Loading branch information
sanel committed Jan 18, 2012
1 parent 5ca5593 commit 5b347e2
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
11 changes: 11 additions & 0 deletions EXERCISES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Shell Exercises

This article is inspired from [HBase Book Exercises](http://hbase.apache.org/book/quickstart.html#shell_exercises).

Connect to your running HBase via **hubris**.

$ ./bin/hubris
Hbase UBer Interactive Shell; enter 'help<RETURN>' to see available commands or 'exit<RETURN>' to quit.
hubris>

Type **help**
2 changes: 1 addition & 1 deletion bin/hubris
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

VERSION="0.1.0"
VERSION="0.2.0"

# content location
program=`basename $0`
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject hubris "0.1.0"
(defproject hubris "0.2.0"
:description "Hubris - HBase uber shell"
:license "EPL 1.0"
:url "http://github.com/sanel/hubris"
Expand Down
20 changes: 17 additions & 3 deletions src/hubris/builtin.clj
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ Examples:
hubris> connect ;; connect to localhost
hubris> connect \"foo\" ;; connect to 'foo' host and the same zookeeper address
hubris> connect \"foo\" \"baz\" ;; connect to 'foo' host with 'baz' as zookeeper address"
([] (connect "localhost"))
([host] (connect host host))
([host zk] (hbase.core/connect-to host zk))
([] (connect "localhost"))
([host] (connect host host))
([host zk] (hbase.core/connect-to host zk))
)

(defcommand host
Expand All @@ -70,6 +70,20 @@ Examples:
(println "Not connected to any HBase instance")
) ) )

(defcommand create
"Create table; pass table name, a dictionary of specifications per column family, and optionally
a dictionary of table configuration. Dictionaries are described below in the GENERAL NOTES section.
Examples:
hbase> create \"t1\" {:NAME \"f1\" :VERSIONS 5}
hbase> create \"t1\" [{:NAME \"f1\"} {:NAME \"f2\"} {:NAME \"f3\"}]
hbase> ;; The above in shorthand would be the following:
hbase> create \"t1\" \"f1\" \"f2\" \"f3\"
hbase> create \"t1\" {:NAME \"f1\" :VERSIONS 1 :TTL 2592000 :BLOCKCACHE true}"
[table opts]
(println "TODO"))

(defcommand list-tables
"List all tables in hbase"
[]
Expand Down
5 changes: 5 additions & 0 deletions src/hubris/repl.clj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
(defn evaluate-with-redirection
"Scan expression for possible redirection(s), and if found, bind output to it. If not, proceed as usual."
[expr]
;; Try to catch CTRL-D input; normaly, REPL would quit with CTRL-C, but CTRL-D combo would force nil input
;; causing further functions to throw null exception. I'm hoping this 'hack' would not cause other troubles...
(when-not expr
(System/exit 0))

(if (re-find #"\s+>\s+" expr)
(do
(let [tokens (.split expr "\\s+>\\s+")
Expand Down

0 comments on commit 5b347e2

Please sign in to comment.