Closed pejrak closed 9 years ago
This is not only for 0 key. When I put console.log("item, id:", item, id) before the item.members.push(i), I get this:
node hashtable_test3.js item, id: { id: 0, members: [] } 0 item, id: { id: 0, members: [ 0 ] } 0 item, id: { id: 0, members: [ 0, 1 ] } 0 item, id: { domain: null, bytes: 41, oncomplete: [Function: afterWrite] } 0
/home/nol/webapps/tester/hashtable_test3.js:14 item.members.push(i) ^ TypeError: Cannot call method 'push' of undefined at Object.
(/home/nol/webapps/tester/hashtable_test3.js:14:16)
When I change the i starting from 1000:
node hashtable_test3.js item, id: { id: 68, members: [] } 68 item, id: { id: 14, members: [] } 14 item, id: { id: 23, members: [] } 23 item, id: { id: 14, members: [ 1001 ] } 14 item, id: { id: 13, members: [] } 13 item, id: { id: 121, members: [] } 121 item, id: { id: 19, members: [] } 19 item, id: { id: 39, members: [] } 39 item, id: { id: 11, members: [] } 11 item, id: { domain: null, bytes: 37, oncomplete: [Function: afterWrite] } 14
/home/nol/webapps/tester/hashtable_test3.js:14 item.members.push(i) ^ TypeError: Cannot call method 'push' of undefined at Object.
(/home/nol/webapps/tester/hashtable_test3.js:14:16)
Highest version this works with is 0.3.1 when I change keys to string before putting and getting.
Hi, @pejrak, I have a similar problem, and come up with a tmp fix as above.
Not a expert in v8, and at least that works for me.
my node version is v0.10.30, and use hashtable 0.4.3.
Hi @liyu1981, I have tried testing your solution, but I seem to be getting the same error:
item, id: { domain: null, bytes: 49, oncomplete: [Function: afterWrite] } 11
/home/nol/webapps/hashtable11/hashtable_test3.js:14 item.members.push(i) ^ TypeError: Cannot call method 'push' of undefined at Object.
(/home/nol/webapps/hashtable11/hashtable_test3.js:14:16) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:906:3
I hope I did install your code the right way:
sudo npm install git+https://github.com/liyu1981/node-hashtable.git
nol@mind07 ~/webapps/hashtable11 $ npm list /home/nol/webapps/hashtable11 └── hashtable@0.4.3 (git+https://github.com/liyu1981/node-hashtable.git#881d2fb3c4e545cc0b4816dcefee94e0ddfe3dfb)
I can see the hashtable.cpp with your code change in node_modules.
Yes, I have found similar problem. I will come back to it later. :)
发自我的 iPhone
在 2014年9月12日,下午6:44,pejrak notifications@github.com 写道:
Hi @liyu1981, I have tried testing your solution, but I seem to be getting the same error:
item, id: { domain: null, bytes: 49, oncomplete: [Function: afterWrite] } 11
/home/nol/webapps/hashtable11/hashtable_test3.js:14 item.members.push(i) ^ TypeError: Cannot call method 'push' of undefined at Object. (/home/nol/webapps/hashtable11/hashtable_test3.js:14:16) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:906:3
I hope I did install your code the right way:
sudo npm install git+https://github.com/liyu1981/node-hashtable.git
nol@mind07 ~/webapps/hashtable11 $ npm list /home/nol/webapps/hashtable11 └── hashtable@0.4.3 (git+https://github.com/liyu1981/node-hashtable.git#881d2fb3c4e545cc0b4816dcefee94e0ddfe3dfb)
I can see the hashtable.cpp with your code change in node_modules.
— Reply to this email directly or view it on GitHub.
Now this works in my place. (node_g
is the my debug build of node 0.10.30)
[liyu@localhost node-hashtable]$ cat test.js
// File contents (test_hashtable.js)
var ht = require('./build/Debug/native').HashTable;
var hash = new ht()
for (var i=0; i<10000; i++) {
// Create id under which several members will be added
var id = Math.round(i / (Math.random() * 100))
var item = hash.get(id) || {
id: id,
members: []
}
//console.log("item, id:", item, id)
item.members.push(i)
hash.put(id, item)
}
console.log("Hash size:", hash.size())
// Finishes and returns size with hashtable@0.1.4
// Breaks with hashtable@0.4+
[liyu@localhost node-hashtable]$ ../node-test/dist/bin/node_g test.js
Hash size: 1294
The changes are stashed and rebased to Commit 7e83c1a .
Hi @liyu1981, yes, this fixes the problem for me, I can run the test script without issues.
I'm sorry everyone, for some reason I never got emails about these new issues and pull requests, does this still happen in 0.5.2?
looks like this should still be a problem with 0.5.2, I'm so sorry. I've mostly focused on es6-native-set and es6-native-map (I used this node-hashtable code as the basis for them) since that's what we use at work, I'll merge this change and push a new version.
Hi, I ran into the below problem with versions 0.4+, and
node -v: v0.10.30
The error: