-
-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
shift and rehash methods in Array and Hash #3142
Comments
Java Maps do not support rehash, so that's why we raise NotImplementedError. I suppose we could just do nothing, since rehash is largely an invisible operation. For Java arrays, shift has no meaning; they are fixed-size. I think in this case we need to preserve the NotImpl error. |
I mean we should leave it unimplemented. Java arrays are not like Ruby arrays. If you want a Ruby array, call to_a. |
May I ask why you are calling these methods against Java maps? Perhaps we can help you find an alternative, because at least in the case of |
I should point out that rehash does work when the particular Java Map supports it, but it doesn't exist for all Map impls:
|
Thx for the reply. I'm writing a custom plugin for logstash. If I use to_a, I'm afraid I will get a copy of the event, and won't be able to modify referenced map itself. |
Re maps: I can make rehash work, but there's no equivalent to shift for Java maps. Re arrays: Java arrays have fixed size, so size-altering methods will never have an equivalent. Not really anything we can do about that :-\ |
* Make the default rehash impl no-op. If the map supports rehash, the correct Java method will be bound instead. * Make the default shift have a better error explaining that Java Map does not generally preserve insertion order.
I've pushed the rehash change, and improved the shift error message. That's about all we can do, so I'm marking this fixed. |
* Make the default rehash impl no-op. If the map supports rehash, the correct Java method will be bound instead. * Make the default shift have a better error explaining that Java Map does not generally preserve insertion order.
Ok, thx anyway! |
Oh, one last change I will do...if I mark the default rehash and shift as unimplemented, they should not show up in respond_to? checks. |
Allows using respond_to? to check if they do anything. #3142
Allows using respond_to? to check if they do anything. #3142
Currently it throws a "NotImplementedError" in MapJavaProxy.java, and it is not defined in ArrayJavaProxy.java
However, the methods seem to be implemented in RubyHash.java and RubyArray.java
Is it a matter of connecting pipes, or am I missing something? Maybe the current implementation in RubyArray and RubyHash does not work?
The text was updated successfully, but these errors were encountered: