rant: R hash library
Jul. 13th, 2010 03:28 pmR's hash library doesn't support keys with more than 256 bytes!
This is very silly... there should be no limit on key size: hash tables should accept any serializable object as a key! Why do they try to convert it into a variable name??
Maybe this is fixed if I upgrade to Hash 2.0, but that isn't backwards-compatible, and I'd have to convert/rewrite all my hashing code. Anyway, here's what their website says:
This shows a classical ambiguity: does "an error results" apply to the old hash, the new one, or both? Certainly it's happening in the old, as I showed above.
---
UPDATE: see the link above for discussion. Hash 2.0 does not solve the problem.
> h <- hash()
> big <- concat(rep("B",279))
> big
[1] "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
>
> h
containing 0 key-value pairs.
> h[big] <- 1
Error in assign(keys[[i]], values[[i]], envir = hash@.Data) :
variable names are limited to 256 bytes
This is very silly... there should be no limit on key size: hash tables should accept any serializable object as a key! Why do they try to convert it into a variable name??
Maybe this is fixed if I upgrade to Hash 2.0, but that isn't backwards-compatible, and I'd have to convert/rewrite all my hashing code. Anyway, here's what their website says:
<< Coercion of keys to valid R names ( i.e. non-blank character values) is not the responsibility of the user. The four accessor functions: [, [[, $, values, no longer do this automatically. An error results if a proper R name is not provided. >>
This shows a classical ambiguity: does "an error results" apply to the old hash, the new one, or both? Certainly it's happening in the old, as I showed above.
---
UPDATE: see the link above for discussion. Hash 2.0 does not solve the problem.