How to workout Arrays, objects and Arrays within object in crate? - crate

I have done preliminary studies on Crate. Now i would like to work on Objects, Arrays and Arrays within Object using crate. It seems very basic document was given on
https://crate.io/docs/current/sql/ddl.html#object.
I need advanced examples using objects, arrays Arrays within objects. I need to accomplish this using my php-client which is on development.
i found a note saying
in the python client a python list can be used as an argument to the cursors execute method.
I want to know more on this. Especially I would like to do this on php.

You have to use the args field in the JSON payload to specify nested values. The value in args is just a plain JSON array, so it should be straight forward to send them with your php client.
Details on the HTTP endpoint of crate, which you probably already use via PHP, can be found here https://crate.io/docs/current/sql/rest.html . There is also an example for argument passing.
greetings, bernd

Related

CDK constructs: passing values to constructors vs using the context values

I wrote a small cdk construct that parses the logs in a cloudwatch log group via a lambda and sends a mail when a pattern is matched. This allows a developer to be notified via an sns topic, should an error appear in the logs.
The construct needs to know which log group to monitor, and which pattern to look for. These are currently passed in as parameters to its constructor. The user of my small construct library is supposed to use this construct as part of his stack. However, one could also define them as parameters, or better yet given what the docs say values in a context - basically using this construct in a standalone app.
Would this be an appropriate use of the context? What else it is useful for?
It's hard to say a definitive answer, but I would recommend always passing in properties to a construct explicitly on the constructor.
A) This creates consistency with the rest of the constructs.
B) Nothing is 'hidden' in your construct definition.
The only thing I've generally found context useful for is passing in parameters from the CLI, but even that is pretty rare and there are often better ways to do it.

What exactly is the data type "array" in TypoScript

In the TypoScript Reference, the data type for some properties is defined as "array" or "array of ... with stdWrap" or something similar.
In the list of data types in the TSRef however, "array" is nowhere to be found.
I know, essentially it really is an array when converted to PHP, but what does data type array mean exactly in this context?
There are further arrays (like array of cObjects for subparts and marks in templates)
They all define another level of elements in your typoscript. The kind of array may give you a hint what index and what kind of values are expected.
Sometimes the index is ordered for evaluation (e.g. COA, layoutRootPaths), sometimes it does not matter (e.g. marks, subparts) or are evaluated in the order of the typoscript (e.g. includeJS). As you could have multiple kinds of array in PHP each can be evaluated in multiple ways.
The kind of values (in the documentation) depend on the further evaluation. Simple integer, strings, cObjects, ...
Not everywhere you are able to add stdWrap functions (so values evaluated in the core should have it).
As you already mentioned: typoscript is scanned and stored as multidimensional array.
Each part of (core-)code evaluates this array with an individual logic. So the interpretation of an array is done individually.
And until now there is no full consens about which kind of arrays are representative or typical to be an own type. An unification would probably need code changes, in core and in multiple extensions.
For optimization of the manuals you should open a forge ticket requesting an explanation in the manuals with the kind of arrays you found.
The docs are kind of confusing in that regard, because there are no "arrays" in TypoScript at all, because TypoScript isn't even a programming language.
TypoScript is just a configuration, like YAML or JSON and will be converted into an array itself by PHP. I think it should rather be called "a list of things" instead of "an array of things", but since arrays are kinda lists themselfes and developers, who are the main audience of the docs, should know what the docs are talking about when talking about "an array of things", it is kinda valid to leave it as is.

variable number of arguements RPC

I would like to know how to pass a variable number of arguments and types to an RPC function in UNITY?
I saw some similar questions asked in here but no straight answers on how to do it.
Thanks
RPC function is deprecated since unity 5.X cause a new network system was released. If you have an already made game and can't migrate from old network API you should take a look on Legacy Network RPC's documentation, there is good covering information about how to pass params into RPCs.
Basicaly what you need is an array of objects like:
networkView.RPC("MyMethod",RPCMode.All, arg1[], arg2, arg...);
where args must match the end point method signature MyMethod(arg1[], arg2, arg...).
If you need declare methods with variable types and number of arguments you'll have a lot of ways to proceed (from using specific objects as arguments through convert or serialize an object as byte arrays or something that you would deserializes after receive ). You can improve your research results on this approaches by searching directly on "C#" instead of "Unity" or "RPC" targets...

Perl module that works like Data::Dumper but allow data manipulation

Is there a popular Perl module that works like Data::Dumper but allows user to write hook to manipulate the data inside complex structure or object.
There are a few modules showing up in google such as Data::Visitor or Data::Structure::Util that might do the job, but I'm not sure if they are the popular ones .
I've written Data::Dmap to do this, but as mentioned, Data::Rmap, Data::Transformer and Data::Visitor are also relevant.
The basic idea of Data::Dmap is that it allows you to transform anything in a nested data structure and still tries to behave like the built in map function.
I am not sure it is what you mean, but Data::Dump supports hooks to filter dumped data. Similar hooks are also possible in Data::Printer.
Edit: If you need editing, I would look at Data::Rmap or Data::Transformer. Also, if your structure is simple (say only scalars, hashes and arrays), you can make simple recursive traversal yourself.
YAML is a nice serialization format, easy to edit string values and such. It might not handle all your objects, but it's worth a try, and it both serializes and reloads things easily.

Access objects through Lua (iPhone SDK)

I'm trying to get to grips with how Lua works, and how it can be integrated into a project, like an Obj-C based iPhone game. I've got Lua's source integrated fine, and have managed to use a simple manager class to translate function calls written in a .lua file, to Obj-C methods in the project.
I'm now a little stuck; I'm not sure how to go about what I'd like to use Lua for, and having Googled a lot on it I haven't found an article which fills the little gaps in my understanding. What I'd like to do is use Lua to script simple game logic for levels in my game; for example, I might want to check that the player has moved to a certain part of the level, then once he does that I check if he picks up an object, then once he throws that object I check if it hits another object, etc, etc.
In the script, I'd like to have something like this:
if (objectsAreTouching(level.objects["objIndex1"], level.objects["objIndex2"]))
{
//Move to next win-condition.
}
So I know how to access a function, for example the one named above, objectsAreTouching, but I can't see how I would, from within the .lua file, access a Dictionary or Array from within one of the game's main classes. I assume this must be possible, am I right? If so, how do you do this? If you can, can you then have a method in your game engine which returns a BOOL pass that return value to the script, so that the if statement above would then execute the code within it?
I may well have asked this question badly, and so if I need to clarify anything let me know. Also, I'm aware of the issues surrounding Apple's ban of interpreted code, and it doesn't concern me for this little project.
Thanks for any help!
You have (at least) three options:
Create the Dictionary (using a Lua table) and Array (also using a Lua table) on the Lua side rather than on the C++ side; you can do this in C++ using Lua's C API, or in a Lua script that you load to construct the game environment.
Provide access functions to Lua to read the C++ based Dictionary and Array. These access functions are just like the objectsAreTouching function you described, but at the level of data accessors. Typically the results returned from the accessors would be lightuserdata.
Use Lua userdata objects to share the state of the Dictionary and Array between Lua and C++. In this case they would be C++ objects requiring accessors, just like (2), but would be managed by Lua and could have methods (a metatable) and an environment associated with them.