-
Notifications
You must be signed in to change notification settings - Fork 234
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
Generalize and complete Value #2013
Comments
Nil, how do you see the |
We could make a storage API more extendible if allow adding specific storage procedure for each |
@vsbogd , I wonder about (3), which would be a mixture of option (1) and option (2)? |
Regarding the RAM footprint of my proposal:
So whether it is better or worth depends on the usage. It seems to me the majority of atoms in an atomspace have no value so it would be a pro in that case. But of course it ultimately depends on the usage. |
@ngeiswei, excuse me, I didn't get your answer here #2013 (comment) May be my question #2013 (comment) was confusing, let me rephrase it. If |
@vsbogd , my tentative suggestion was to overload |
Ah, ok, I've got it. The only disadvantage of having both What is the main motivation of this issue? Is it adding |
My primary motivation is to add Of course we don't need to replace |
@vsbogd, I'm realizing a problem with (2) is that there is no way to know whether the single value is being updated or if a new value is being inserted, unless the key is somehow stored somewhere, which requires an extra member. So, unless I misunderstood (2) I would now bend towards (1). |
Yes, I suppose instead |
OK, so .. regarding 1+3 Yes, during the original value design effort, I very explicitly thought a very long time about having a
For all of the above reasons, which I really did think about long and hard during many walks morning and evening in many different cities, I decided MapValue was a bad idea, and to instead hard-code one single map into the atom itself. |
The users who really want a hierarchical systems can use LinkValue to implement it. By "hierarchical" I mean the industry-standard named-path concept: Also, to be clear: take a look at how Plan 9 treats files and directories. If you haven't looked at Plan 9, its work a look. Roughly speaking, it allows any part of the file system to behave like the linux So - again -- everything you want to do with MapValue can be done with LinkValue, and some elbow grease. That is why LinkValue was invented. (And why LinkValue is a sequential list, and not an unordered set or other structure. I thought this stuff out. It's not random code.) |
To be super-clear about this: instead of a MapValue, and all the headache that causes, instead, just write some C++ code that parses slash-separated path-names. So, for example:
Right? This uses plain-old ordinary LinkValues to implement what looks like a Unix file directory path. You could even make it parse things like |
Re: 4) IntValue, BoolValue -- I thought long and hard about that too, way back when I was designing the whole thing. I realized that sooner or later, users would want these. I also realized that
Yes, I really thought about these things a lot. So my plan was to resist code-bloat for as long as possible. I'm very very serious about code-bloat. When you create code that no one actually needs:
So I really want to resist adding new features until they are really really needed. |
The good thing about |
We can store all the data in some atomspace owned Map[Atom] -> Map[Value] -> value. Then atom without values will require 0 bytes instead of 8 or 16 |
I thought I gave some clear and cogent arguments about why this should not be done, and how existing alternatives are adequate. I'd like to close this issue for further discussion. If there is an actual technical problem that needs an actual technical solution, a new, different issue should be opened. Regarding @noskill comment about where values are stored: yes, the implementation of issue #1967 would alter where, and how values are stored. As to sizes of atoms: there is always a space-time tradeoff. I would like to have access to values be "as fast as possible", and if this means fatter atoms, so what. Currently, atoms average out to 1.5KBytes in size, almost all of that being the incoming set.16 extra bytes is a "drop in the bucket". Can I close this issue? |
I'm neutral on whether this issue can be closed. The best way to tell what's best would be to try but that takes a lot of work, and it's certainly not an urgent matter. |
I suggest a few changes to generalize and complete
Value
(also known before asProto Atom
).MapValue
, to represent any mappingValue -> Value
, withMapValue::get_value
, etc, to return the associate value of a given value.Atom::compute_hash()
andAtom::get_hash()
toValue
, but notAtom::_content_hash
in order to haveValue
as light weight as possible. Of courseValue::get_hash
would directly callcompute_hash
whileAtom::get_hash
would first check ifAtom::_content_hash
is defined. Since values tends to be ephemeral, not caching their hash seems sensible.Atom::_values
byAtom::_value
. Where the C++ type of_value
would bemutable ValuePtr
instead ofmutable std::map<const Handle, ValuePtr>
.Atom::getValue
can still be kept for backward compatibility but would only work when_value
is aMapValue
by callingMapValue::get_value
, and raise an exception otherwise.Value
types,IntValue
,BoolValue
, etc. (letting aside the sequence or not debate).I know that adding more
Value
types requires to update the persistent storage code, but that sort of elementary types and constructs are few and once it is done, it is done. And this offers a massive freedom to the user. Even the freedom to only attach a boolean and nothing else to an atom (just use aBoolValue
forAtom::_value
), or a probability (just use aFloatValue
forAtom::_value
). This is as lightweight and flexible as it gets.The text was updated successfully, but these errors were encountered: