Skip to content

Commit

Permalink
Refactor Nodem for future maintainability
Browse files Browse the repository at this point in the history
- Add support to APIs for local variables with the new 'local' property
and the new localDirectory method
- Change character set encoding to default to UTF-8 and decouple it from
the encoding set for the underyling YottaDB/GT.M database
- Add support for the previousNode API in YottaDB versions r1.10 and
newer
- Remove support for Node.js versions earlier than 0.12.0
- Add new help method, with a list of APIs, and more detailed call
information for each API
  • Loading branch information
dlwicksell committed Apr 5, 2018
1 parent d383d8d commit 2bd94ee
Show file tree
Hide file tree
Showing 16 changed files with 5,921 additions and 1,775 deletions.
414 changes: 251 additions & 163 deletions README.md

Large diffs are not rendered by default.

44 changes: 9 additions & 35 deletions binding.gyp
Expand Up @@ -2,7 +2,7 @@
# binding.gyp - Nodem build script
#
# Written by David Wicksell <dlw@linux.com>
# Copyright © 2012-2016 Fourth Watch Software LC
# Copyright © 2012-2016,2018 Fourth Watch Software LC
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License (AGPL)
Expand All @@ -18,7 +18,6 @@
# along with this program. If not, see http://www.gnu.org/licenses/.
#


{
'targets': [
{
Expand All @@ -30,50 +29,25 @@
'cflags': [
'-ansi',
'-pedantic',
'-Wno-deprecated-declarations'
'-std=c++11',
'-Wno-deprecated-declarations',
'-Wno-expansion-to-defined'
],
'conditions': [
['target_arch == "x64"', {
'variables': {
'gtm_build%': '/usr/lib/x86_64-linux-gnu/fis-gtm/V6.2-002A-2build1_x86_64',
'gtm_opt%': '/opt/lsb-fis/gtm/V6.3-000A_x86_64'
}
}, {
'variables': {
'gtm_build%': '/usr/lib/fis-gtm/V6.0-003_i686',
'gtm_opt%': '/opt/lsb-fis/gtm/V6.0-003_i686'
}
}]
'defines': [
'GTM_VERSION=63'
],
'variables': {
'gtm_dist%': '$(gtm_dist)',
'gtm_link%': '$(HOME)/lib/gtm',
'gtm_path%': '/usr/lib/fis-gtm/current'
'gtm_dist%': '$(gtm_dist)'
},
'include_dirs': [
'<(gtm_dist)',
'<(gtm_link)',
'<(gtm_path)',
'<(gtm_build)',
'<(gtm_opt)'
'<(gtm_dist)'
],
'libraries': [
'-L<(gtm_dist)',
'-L<(gtm_link)',
'-L<(gtm_path)',
'-L<(gtm_build)',
'-L<(gtm_opt)',
'-lgtmshr'
],
'defines': [
'GTM_VERSION=63'
],
'ldflags': [
'-Wl,-rpath,<(gtm_dist),--enable-new-dtags',
'-Wl,-rpath,<(gtm_link),--enable-new-dtags',
'-Wl,-rpath,<(gtm_path),--enable-new-dtags',
'-Wl,-rpath,<(gtm_build),--enable-new-dtags',
'-Wl,-rpath,<(gtm_opt),--enable-new-dtags'
'-Wl,-rpath,<(gtm_dist),--enable-new-dtags'
]
}
]
Expand Down
32 changes: 0 additions & 32 deletions examples/function.js

This file was deleted.

96 changes: 0 additions & 96 deletions examples/retrieve.js

This file was deleted.

89 changes: 72 additions & 17 deletions examples/set.js
Expand Up @@ -2,7 +2,7 @@
* set.js - Test the set API
*
* Written by David Wicksell <dlw@linux.com>
* Copyright © 2012-2015 Fourth Watch Software LC
* Copyright © 2012-2015,2018 Fourth Watch Software LC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License (AGPL)
Expand All @@ -16,33 +16,88 @@
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*
* 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.
*/

process.on('uncaughtException', function(err) {
gtm.close();
console.trace('Uncaught Exception:\n', err);
process.exit(1);
});

var gtm = require('../lib/nodem');
var db = new gtm.Gtm();
db.open();
var type = 'global';
var name = 'v4wTest';

if (process.argv[2] === 'global' || process.argv[2] === 'local') {
type = process.argv[2];
} else if (process.argv[3] === 'global' || process.argv[3] === 'local') {
type = process.argv[3];
}

var node;
var ret;
var i;
if (type === 'local') {
name = 'test';
}

var nodes = 100000;

if (!isNaN(parseInt(process.argv[2]))) {
nodes = process.argv[2];
} else if (!isNaN(parseInt(process.argv[3]))) {
nodes = process.argv[3];
}

var gtm = require('../lib/nodem').Gtm();
gtm.open();

if (type === 'global') {
if (gtm.data({global: name, subscripts: ['testing']}).defined !== 0) {
console.error('^' + name + '("testing") already contains data, aborting...');
gtm.close();
process.exit(1);
}
}

console.log('Testing the set command, starting at: ' + Date());
var start = process.hrtime(), ret;

for (i = 0; i < 1000000; i++) {
node = {global: 'dlw', subscripts: ['testing', i], data: 'record ' + i};
if (type === 'global') {
for (var i = 0; i < nodes; i++) {
ret = gtm.set({global: name, subscripts: ['testing', i], data: 'record ' + i});

ret = db.set(node);
if (!ret.ok) break;
}
} else {
for (var i = 0; i < nodes; i++) {
ret = gtm.set({local: name, subscripts: ['testing', i], data: 'record ' + i});

if (ret.ok === 0) {
break;
}
if (!ret.ok) break;
}
}

db.close();
var end = process.hrtime(start);

if (ret.ok === 1) {
console.log('Set a million nodes in ^dlw("testing"), ending at: ' + Date());
if (ret.ok) {
if (type === 'global') {
console.log('Set ' + nodes + ' nodes in ^' + name + '("testing"), ending at: ' + Date());
} else {
console.log('Set ' + nodes + ' nodes in ' + name + '("testing"), ending at: ' + Date());
}

console.log('You set approximately', Math.round(nodes / (end[0] + end[1] / 1e+9)), 'nodes per second');
} else {
console.log('There was an error: ' + ret.errorCode + ' ' + ret.errorMessage);
console.log('There was an error: ' + ret.errorCode + ' ' + ret.errorMessage);
}

if (type === 'global') {
console.log('Killing ^' + name + '("testing") now...');
gtm.kill({global: name, subscripts: ['testing']});
}

gtm.close();

0 comments on commit 2bd94ee

Please sign in to comment.