logo

Command Line Tool

Command Line Tool

This project source code is available on github at https://github.com/deanhiller/playorm.

Run Command line Tool

In memory *:

For Windows:

<PLAYORM_HOME\tools>playorm-cli.bat -k nosqlkeyspace -s seed -t inmemory

For Unix:

<PLAYORM_HOME/tools>playorm-cli -k nosqlkeyspace -s seed -t inmemory

*_Its a bug which need to be fixed that -k and -s are required for inmemory._

With Cassandra:

With cassandra, you can define the consistency level too which is an optional parameter. Default is CL_QUORUM

For Windows:

<PLAYORM_HOME\tools>playorm-cli.bat -k nosqlkeyspace -s localhost:9160 -t cassandra -c CL_ONE

For Unix:

<PLAYORM_HOME/tools>playorm-cli -k nosqlkeyspace -s localhost:9160 -t cassandra -c CL_ONE

With MongoDB:

For Windows:

<PLAYORM_HOME\tools>playorm-cli.bat -k nosqlkeyspace -s localhost -t mongodb

For Unix:

<PLAYORM_HOME/tools>playorm-cli -k nosqlkeyspace -s localhost -t mongodb

With Hbase:

for Windows

<PLAYORM_HOME\tools>playorm-cli.bat -k nosqlkeyspace -s localhost -t hbase
for unix
<PLAYORM_HOME/tools>playorm-cli -k nosqlkeyspace -s localhost -t hbase

This will display a message and a prompt like this:

Welcome to PlayOrm Command Line
Type 'help;' for help
Type 'exit;' to exit
playorm >>

Note: Always remember to end the command with a semi-colon.i.e,, ‘;’

View help by entering help command:

playorm >> help;
Getting around
help; Display this help
help Display command-specific help.
exit; Exit this utility

Commands:
SELECT Selects dataset matching expression. type 'help SELECT' for more info
UPDATE Updates dataset matching expression. type 'help UPDATE' for more info
DELETE Delete dataset matching expression. type 'help DELETE' for more info
DELETECOLUMN Delete a column from the rows which matching expression. type 'help DELETECOLUMN' for more info
PARTITIONS Selects dataset matching expression in a partition. type 'help PARTITIONS' for more info
VIEWINDEX Views an index. type 'help VIEWINDEX' for more info
REINDEX Rebuild a particular index. type 'help REINDEX' for more info
CREATE TABLE Not in yet
INSERT Not in yet
LIST TABLES To list all non-virtual column families. To list virual column families use LIST TABLES -all
LISTPARTITIONS IF you partition on a field with @ManyToOne, you can list the partitions. type 'help LISTPARTITIONS' for more info
playorm >> help select;
Select dataset matching expression in a table that is NOT partitioned at all
Example: SELECT a FROM Activity as a LEFT JOIN a.trade as t WHERE a.numShares > 5
In general, JQL(Java Query Language) can be followed. We are adding standard SQL as well
playorm >>

VIEWINDEX:
The VIEWINDEX command lists the index nodes in the index the way they are stored(which is in order)
Format(non-partitioned table): VIEWINDEX /{Column Family}/{Indexed Column}
Format(partitioned table): VIEWINDEX /{Column Family}/{Indexed Column}//{Partition Id}
e.g..

playorm >> VIEWINDEX /Activity/uniqueColumn;
indexed value type=STRING
row key type=STRING
.
0 .act1
1 .act2
2 .act3
3 .act4
4 .act5
5 .act6
6 .act7
7 Columns Total
playorm >>

REINDEX:

REINDEX command re-builds an index. This will remove duplicate rowkeys in an index AND if a row no longer exists, it will remove those index points as well BUT if there is a need to add missing index points, one need to map/reduce the table and JUST read in every row and write it back out and it will index it.

NOTE: It is extremely tough to be missing index points. There are more chances for duplicate rowkeys than missing points(There have been ZERO instances so far in production of this)

Format(non-partitioned table):

REINDEX /{Column Family}/{Indexed Column}

Format(partitioned table):

REINDEX /{Column Family}/{Indexed Column}/{Partitioned by}/{Partition Id}

Example for a non-partitioned table:

playorm >> REINDEX /Activity/name;
indexed value type=STRING
row key type=STRING
It is safe to kill this process at any time since it only removes duplicates
Beginning re-index
#Rows processed=7 totalRows to process=7 totalChanges=0
playorm >>
INNER JOIN:

The below example shows an INNER JOIN query for a non-partitioned table. It is using noSQL just like a RDBMS (for better or worse depending on its context).

playorm >> select * FROM Activity as e INNER JOIN e.account as a WHERE e.numTimes numTimes = 10

=> isCool = null
=> name = null
=> myFloat = 0.0
=> account = acc1
=> date = null
=> uniqueColumn = null
=> somethingElse = null
RowKey:acc1 (id)
=> isActive = false
=> users = null
=> name = null
=> someField = 0
=> activities.act1 = null
=> activities.act2 = null
=> activities.act7 = null
----------- JoinedRow1
RowKey:act7 (id)
=> numTimes = 10
=> isCool = null
=> name = null
=> myFloat = 0.0
=> account = acc1
=> date = null
=> uniqueColumn = null
=> somethingElse = null
RowKey:acc1 (id)
=> isActive = false
=> users = null
=> name = null
=> someField = 0
=> activities.act1 = null
=> activities.act2 = null
=> activities.act7 = null
2 Rows returned
playorm >>

LEFT JOIN:

Similarly, below query is an example of LEFT JOIN

playorm >> select * FROM Activity as e LEFT JOIN e.account as a WHERE e.numTimes numTimes = 10
=> isCool = null
=> name = null
=> myFloat = 0.0
=> account = acc1
=> date = null
=> uniqueColumn = null
=> somethingElse = null
RowKey:acc1 (id)
=> isActive = false
=> users = null
=> name = null
=> someField = 0
=> activities.act1 = null
=> activities.act2 = null
=> activities.act7 = null
----------- JoinedRow1
RowKey:act7 (id)
=> numTimes = 10
=> isCool = null
=> name = null
=> myFloat = 0.0
=> account = acc1
=> date = null
=> uniqueColumn = null
=> somethingElse = null
RowKey:acc1 (id)
=> isActive = false
=> users = null
=> name = null
=> someField = 0
=> activities.act1 = null
=> activities.act2 = null
=> activities.act7 = null
2 Rows returned

UPDATE:
The Update command is used to update the records of a table.

Example 1:

Simple update command with single column update.

playorm >> update Activity set(name="harry") where id="acc1";
6 row updated
playorm >>

Example 2:

Update with table alias and multiple column and multiple conditions.

playorm >> update Activity as a set(a.name="harry",a.numTimes=5) where a.id="act1" and
a.account="acc1";
1 row updated
playorm >>

Example 3:

 Update with INNER JOIN with multiple column and multiple conditions.

playorm >> update Activity as a inner join a.account as b set(a.name="harry",a.lastname="potter") where
a.id="acc1" and a.numTimes>

Example 4: 

Update with LEFT JOIN with multiple column and multiple conditions.

playorm >> update Activity as a left join a.account as b set(a.name="harry",a.lastname="potter")
where a.id="acc1" and a.numTimes=10";
1 row updated
playorm >>

DELETE:
The Delete command is used to delete the records of a table.

Example:

playorm >> Delete from Activity where id="act1";
1 row deleted
playorm >>

DELETECOLUMN:


The Deletecolumn command is used to delete a specific column of row/records in a table.

Example:


Deleting a primitive column

playorm >> DELETECOLUMN (name) from Account where id = “acc1″;
Column deleted from 1 rows
Deleting a *ToOne or *ToMany column

playorm >> DELETECOLUMN (activities, “act3″) from Account where id = “acc2″;
Column deleted from 1 rows
playorm >>
Deleting with table’s alias

playorm >> DELETECOLUMN (a.activities, "act3") from Account as a where a.id = "acc2";
Column deleted from 1 rows
playorm >>

List all the tables


To list all the tables, enter LIST TABLES command

playorm >> list tables;

The above code will not display the virtual column families. To view all the virtual and non-virtual column families, use “-all” option.

playorm >> list tables -all;

 

<< Back to Documentation Index