-
Notifications
You must be signed in to change notification settings - Fork 39
Better way of saving Dicts with non-Symbol keys - fixes #3 #7
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
Conversation
|
cc: @MikeInnes |
|
Bump @MikeInnes |
|
I can confirm that this fixes the issue around writing Dicts. |
|
Unfortunately, even with this, Dicts do not read back correctly. The keys are visible, but the indexing fails. Which probably means the hashes are incorrect. |
|
Hmmmm can you post an example where the Dicts do not read back correctly?
They do in the tests.
On Thu, Jun 21, 2018 at 19:36 Avik Sengupta ***@***.***> wrote:
Unfortunately, even with this, Dicts do not read back correctly. The keys
are visible, but the indexing fails. Which probably means the hashes are
incorrect.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#7 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AFXArXPRcLCJV96pbYPn38SYbNECcBnYks5t_C4TgaJpZM4UV2PW>
.
--
*Dilum Aluthge*
*[email protected] <[email protected]>*
*https://www.aluthge.com <https://www.aluthge.com>*
|
|
If you download the file at https://github.com/JuliaText/TextAnalysis.jl/releases/download/v0.3.0/sentiment.tar.gz (15.4MB) and unzip it, you'll find a file called Hope this helps. This file was written and read using this branch of |
|
Thanks! I’ll work on this today. |
|
@aviks I believe I've fixed this. Basically I just rehash every dictionary at load-time. It's an easy fix, and now your example seems to work. Can you confirm that it works for you? |
|
Yes, this does work for me, thanks! I'll let Mike chime in on whether rehashing on load is a valid strategy. |
|
Good stuff, but we can make this a bit simpler. Rather than trying to preserve the internal structure of the dict, we really just need to save a |
|
Hmmm. So on read, we would create a new Dict{K,V}(), and then we would
iterate through the key/value vectors and add the key/value pairs to the
Dict one by one?
That seems reasonable to me, but I’m not sure how to implement it. I think
I’d have to create a new method of newstruct_raw for T<:Dict{K, V}.
I’ll work on it this weekend!
On Mon, Jun 25, 2018 at 06:26 Mike J Innes ***@***.***> wrote:
Good stuff, but we can make this a bit simpler. Rather than trying to
preserve the internal structure of the dict, we really just need to save a
Vector{K} and Vector{V} for the keys and values respectively, and we can
reconstruct the dict from scratch on read (avoiding the need for rehash,
too). How does that sound?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#7 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AFXArV-q2C3YTzvdcjaHO_YL5U8hrPPSks5uALrqgaJpZM4UV2PW>
.
--
*Dilum Aluthge*
*[email protected] <[email protected]>*
*https://www.aluthge.com <https://www.aluthge.com>*
|
|
I think you just need |
|
Sounds good. I’ll work on it this weekend. Should I GitHub ping you when
I’m done, or no?
On Mon, Jun 25, 2018 at 09:01 Mike J Innes ***@***.***> wrote:
I think you just need structdata, initstruct and newstruct!.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#7 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AFXArY4sJpIS2z9TWuVaJ7U3Bs6GOwoeks5uAN8qgaJpZM4UV2PW>
.
--
*Dilum Aluthge*
*[email protected] <[email protected]>*
*https://www.aluthge.com <https://www.aluthge.com>*
|
|
Sure, feel free to bump this thread. |
|
I worked on this for a bit, but I reached the conclusion that it will actually be better to get #8 to work and use that. That way we are covered for any structs with undefined values. |
|
Closing in favor of #8 |
|
I disagree actually – we will end up having to do tricks like The undefined values patch will also be bigger / involve some design decisions, so it'll also be easier to get this in quickly. |
This is a better way of fixing #3 that isn't hacky.