Create a
ksbhaskar opened this issue · 1 comments
It would be nice if NodeM came with a small program that one can run to confirm successful installation as well as use as an example of working code to copy (at least for me, I find it easiest to code by finding working code and modifying it, generalizing it, or at least learning from it. There is a sample C program at https://raw.githubusercontent.com/YottaDB/YottaDBtest/master/simpleapi/inref/wordfreq.c and an M program wordfreq1.m (attached) with a reference input file at https://raw.githubusercontent.com/YottaDB/YottaDBt
wordfreq1.m.gz
est/master/simpleapi/outref/wordfreq_input.txt and a reference output file at https://raw.githubusercontent.com/YottaDB/YottaDBtest/master/simpleapi/outref/wordfreq_output.txt
For example, see https://docs.yottadb.com/MultiLangProgGuide/MultiLangProgGuide.html#quick-start
Bhaskar,
NodeM actually does have example programs, and they can be run quickly to determine if NodeM was successfully installed and set up. Using them for that purpose, they may not handle errors as well as they should, something I will improve over time, but they should provide a good spot check on whether NodeM is set up and working.
So there are two example JavaScript programs, both located in the examples/ directory. One, called set.js will test the set API, and providing some performance metrics. Here is some info on how it can be called, but it has defaults if you just invoke it as node examples/set.js.
Store nodes of data in the database (^v4wTest) or symbol table (test), while providing performance timing information. Pass, in any order, the string 'global' or 'local' to test storing in to the database, or local symbol table. Pass, in any order, the number of nodes you want to store data in to.
Also, this program cleans up after itself, by killing the global nodes it writes to (in my own name spaced global, ^v4wTest) after it has finished.
The other example program is called zwrite.js. It is a JavaScript implementation of the ZWRITE command, but is limited to dumping the data of a whole global only, at this time. It actually also provides a much faster wrapper around an actual ZWRITE dump, as it can be a useful way for me to confirm that NodeM is working correctly with data. Here is some info on how it can be called, and again, it has defaults if you just invoke it as node examples/zwrite.js, although in this case, it dumps a test global that you likely would not have any data in. So for this one to be more useful to you, you'd probably want to pass an argument to it.
Dumps the contents of a full global in a similar format to the zwrite command in YottaDB/Gt.M. Pass the name of the global you want to dump, or don't pass any argument and it will use a default of ^v4wTest. You can optionally supply the following arguments, in any order, before or after the global name.
-f [fast mode] - - Creates a temporary GT.M routine and calls into the
routine (which will also dump the entire contents of the global), and then
cleans up after itself. Calling it this way will execute much faster than
the default JavaScript implementation.
-m [data mode] - |strict - The operating mode, which controls the way
data is formatted, and a few other aspects of the API. Strict mode follows
the cache.node API as closely as possible, including treating all data as
a string.
-c [character set encoding] - |m - The character encoding of the data
-d [debug mode] - - Turns on debug mode, which provides debug tracing data
I hope that helps. Let me know if this is enough to close this issue for you. Thank you!