What's the meaning of the frozen keyword in Cassandra?
I'm trying to read this documentation page: Using a user-defined type, but their explanation for the frozen keyword (which they use in their examples) is not clear enough for me:
To support future capabilities, a column definition of a user-defined
or tuple type requires the frozen keyword. Cassandra serializes a
frozen value having multiple components into a single value. For
examples and usage information, see "Using a user-defined type",
"Tuple type", and Collection type.
I haven't found any other definition or a clear explanation for that in the net.
In Cassandra if you define UDT or Collection as frozen, you can't update UDT's or collection's individual item, you have to reinsert with full value.
A frozen value serializes multiple components into a single value. Non-frozen types allow updates to individual fields. Cassandra treats the value of a frozen type as a blob. The entire value must be overwritten.
Source : https://docs.datastax.com/en/cql/3.1/cql/cql_reference/collection_type_r.html
#Alon : "Long story short: frozen = immutable"
For a user-defined type, I have noticed that you can update frozen the set by adding or removing the set elements. For example, let's say we create a table as follows.
create type rule_option_udt(display text, code text);
create TABLE rules (key text, options set<frozen<rule_option_udt>>, primary key (key));
As per the definition we expect that we won't be able to use + or - operation with the options field. But you can use add or remove operation as a normal set.
insert into rules (key, options) values ('fruits', {{display: 'Apple', code: 'apple'}}) ;
update rules set options = options + {{display: 'Orange', code: 'orange'}};
The above update is valid but you can't do the same with simple types such as text. I am not sure if this is expected nature or not but this is how it works for me.
In addition to this <frozen<set<udt>> && set<frozen<udt>> are behaving in the same manner. While describing the table you can see both are being shown as set<frozen<udt>>
Related
My department uses a software tool that can use a custom component library sourced from Tables or Queries in an MS Access database.
Table: Components
ID: AutoNumber
Type: String
Mfg: String
P/N: String
...
Query: Resistors
SELECT Components.*
FROM Components
WHERE Components.Type = "Resistors"
Query: Capacitors
SELECT Components.*
FROM Components
WHERE Components.Type = "Capacitors"
These queries work fine for SELECT. But when users add a row to the query, how can I ensure the correct value is saved to the Type field?
Edit #2:
Nope, can't be done. Sorry.
Edit #1:
As was pointed out, I may have misunderstood the question. It's not a wonky question after all, but perhaps an easy one?
If you're asking how to add records to your table while making sure that, for example, "the record shows up in a Resistors query if it's a Resistor", then it's a regular append query, that specifies Resisitors as your Type.
For example:
INSERT INTO Components ( ID, Type, Mfg )
SELECT 123, 'Resistors', 'Company XYZ'
If you've already tried that and are having problems, it could be because you are using a Reserved Word as a field name which, although it may work sometimes, can cause problems in unexpected ways.
Type is a word that Access, SQL and VBA all use for a specific purpose. It's the same idea as if you used SELECT and FROM as field or table names. (SELECT SELECT FROM FROM).
Here is a list of reserved words that should generally be avoided. (I realize it's labelled Access 2007 but the list is very similar, and it's surprisingly difficult to find an recent 'official' list for Excel VBA.)
Original Answer:
That's kind a a wonky way to do things. The point of databases is to organize in such a way as to prevent duplication of not only data, but queries and codes as well
I made up the programming rule for my own use "If you're doing anything more than once, you're doing it wrong." (That's not true in all cases but a general rule of thumb nonetheless.)
Are the only options "Resistors" and "Capacitors"? (...I hope you're not tracking the inventory of an electronics supply store...) If there are may options, that's even more reason to find an alternative method.
To answer your question, in the Query Design window, it is not possible to return the name of the open query.
Some alternative options:
As #Erik suggested, constrain to a control on a form. Perhaps have a drop-down or option buttons which the user can select the relevant type. Then your query would look like:
SELECT * FROM Components WHERE Type = 'Forms![YourFormName]![NameOfYourControl]'
In VBA, have the query refer to the value of a variable, foe example:
Dim TypeToDel as String
TypeToDel = "Resistor"
DoCmd.RunSQL "SELECT * FROM Components WHERE Type = '" & typeToDel'"
Not recommended, but you could have the user manually enter the criteria. If your query is like this:
SELECT * FROM Components WHERE Type = '[Enter the component type]'
...then each time the query is run, it will prompt:
Similarly, you could have the query prompt for an option, perhaps a single-digit or a code, and have the query choose the the appropriate criteria:
...and have an IF statement in the query criteria.
SELECT *
FROM Components
WHERE Type = IIf([Enter 1 for Resistors, 2 for Capacitors, 3 for sharks with frickin' laser beams attached to their heads]=1,'Resistors',IIf([Enter 1 for Resistors, 2 for Capacitors, 3 for sharks with frickin' laser beams attached to their heads]=2,'Capacitors','LaserSharks'));
Note that if you're going to have more than 2 options, you'll need to have the parameter box more than once, and they must be spelled identically.
Lastly, if you're still going to take the route of a separate query for each component type, as long as you're making separate queries anyway, why not just put a static value in each one (just like your example):
SELECT * FROM Components WHERE Type = 'Resistor'
There's another wonky answer here but that's just creating even more duplicate information (and more future mistakes).
Side note: Type is a reserved word in Access & VBA; you might be best to choose another. (I usually prefix with a related letter like cType.)
More Information:
Use parameters in queries, forms, and reports
Use parameters to ask for input when running a query
Microsoft Access Tips & Tricks: Parameter Queries
• Frickin' Lasers
Here's what I have:
class A{
Ref<foo> b;
Ref<foo> c;
int code;
Date timestamp
}
The pseudo "where" clause of the SQL statement would like like this:
where b = object or (c = object and code = 1) order by timestamp
In plain English, give me all the records of A if b equals the specific object or if c equals the specified object when code equals 1. Order the result w/ timestamp.
Is the composite query part even possible w/ datastore (Objectify)? I really don't want to do two queries and merge the results, because I have to sort by timestamp.
Any help is appreciated.
P.S. I already tried
new FilterPredicate(b, EQUAL, object)
This didn't work, because the entity type is not a support type.
Thanks!
Pass a native datastore Key object to the FilterPredicate. The Google SDK Key, not the generic Objectify Key<?>.
Normally when filtering on properties, Objectify translates Ref<?> and Key<?> objects to native datastore keys for you. With the google-supplied FilterPredicate, that isn't an option. So you have to do the translation manually.
Objectify stores all Key<?> and Ref<?> fields and native datastore Keys, so you can freely interchange them (or even change the type of fields if you want).
Let's say I have a feed of data in the form of key-value pairs. This feed comes from multiple sources which provide additional fields and also reuse similar fields to mean different things.
An issue occurs when you try to extract meaning from a data set made from both sources using these similar fields.
What is this phenomenon called?
Example from source A:
{ name: 'building A', ... }
Example from source A-firewall-events
{ name: 'rejected', ip: '...', ... }
The key, name, has no semantic association outside of its context, which in your example is A and A-firewall-events. There is no loss of data or loss of meaning. Unless you append the source of the key value name will not have any inherent meaning. There exists no terminology to describe this, as it is solely the result of poor software engineering practices.
I need to understand the eval attribute in the following code in the product_demo.xml in product module in Odoo:
"record id="product_product_4_product_template" model="product.template">
field name="attribute_line_ids" eval="[(6,0,[ref('product.product_attribute_line_1'), ref('product.product_attribute_line_2'), ref('product.product_attribute_line_3')])]"/>
</record>"
I understand that the attribute_line_ids value is being set here. I also understand that the values inside the 'ref' refers to XML ids which would, in short, return the model-'product.attribute.line associate with the XML id.
I really don't understand what each of the values in the eval attribute mean and what changes would it do on view level and db level. I have referred to many odoo documentation but none could provide clarity.
This adds a bunch of values to a Many2many field called attribute_line_ids. Odoo has a special syntax for setting values on Many2many fields. This syntax is described here and is used in the code you asked about.
Basically, to modify a many2many relation you use a three-element tuple. The first element of the tuple is a numeric command, and two other elements are values - their exact function depend on the command.
There are six numeric commands:
0 - creates a new object and adds it to the Many2many relation
1 - updates an object that already exists on the relation
2 - deletes an object that already exists on the relation
3 - removes an existing object from the relation, without deleting it
4 - adds an existing object to the relation
5 - removes all objects from the relation, without deleting them
6 - replaces pervious objects existing on the relation with a new set of objects
The relevant part of your code look like this:
(6,0,[ref('product.product_attribute_line_1'), ref('product.product_attribute_line_2'), ref('product.product_attribute_line_3')])
It's a three-element tuple (which is expected, since the code sets values on a Many2many relation):
The first element is the command. "6" means elements previously existing in the relation (if any) will be replaced with elements which ids are passed as the third element of the tuple.
The second argument is irrelevant. It has a role with other commands, but when used with "6" it can be anything (personally I would use None to better reflect this).
The third element is a list of ids. Since the first element is "6", this signifies the objects that will be put into the relation, replacing whatever was previously there.
What I want to do is trigger an action when one of the fields on my field collection is changed to a certain value. For example, my 'campaign' node has a field collection with a field called 'status' This status is a list containing 3 options; 'onboard', 'live', or 'dead'. When the field on a campaign node field collection is set to 'live' I want to trigger an action.
So I start by saying:
Events: After node is updated
Conditions: This is the bit I am struggling to work out as I cannot do a data comparison with this particular field.
Action: send email
How can I achieve this?
You may get it to work by using an approach similar to what is mentioned in comment # 4 of issue # 1315566, i.e.:
Create an "entity has field" condition on your Rule.
For the "Data Selector," select the entity that contains the field (in my case, a node). For the "Field" value, select the machine name of the field collection in question.
Go to your action. Using the "Data Selector" mode, you should be able to drill down through the entity in question to all the values contained within the field collection. In my case, the end result is "node:field-enrollee:field-school-district:0:tid"
In your case you try to do what is mentioned in step 3 above as a Rules Condition (instead of a Rules Action). So add a Rules Condition "Entity has field" (prior to being able to use it anywhere later on in your rule), which refers to your field collection field.
For way more details about this, refer to "How to iterate over all field collection items in the Rules module?" (which also includes a rule in export format you may want to experiment with, if you only adapt some machine names of the used fields).