Data representation issue on AppEngine Datastore Object - google-app-engine

Structure of Data:
2-D string array of column length 3.
Eg. {["One","Two","Three"],["One","Two","Three"],["One","Two","Three"],...}
Datatypes tried & did not work:
String[][3]
ArrayList<String[3]>
How this data be represented , if not by above Datatypes ?

If you're using the com.google.appengine.api.datastore API, entity properties must be of one of the datastore native types, or a Collection of values of a datastore native type (or types). A single property value can't represent a two-dimensional list without serialization, nor can multiple values for a single property name (the Collection case).
If you can serialize, then that's a potential answer. If you have requirements for indexing values in your array for queries, then you'll need to describe those to figure out an answer. For example, entries in the array could be separate entities, each with a "first", "second", and "third" property; the main entity has a List of Keys.

Related

What types of data are supported in Memgraph?

What data types are supported in Memgraph? Is there a difference between node and relationship types? Do I need to define data type in similar way that you define variable types in programing languages?
Memgraph stores all of the data in nodes and relationships. There are some important differences when it comes to them:
Nodes can have labels that are used to label or group nodes. A label is of the type String, and each node can have none or multiple labels. Labels can be changed at any time.
Relationships have a type, also represented in the form of a String. Unlike nodes, relationships must have exactly one relationship type and once it is set upon creation, it can never be modified again.
Nodes and relationships can store various properties. Property names are represented as text, while values can be of different types.
Each property can store a single value, and it is not possible to have multiple properties with the same name on a single graph element. But, the same property names can be found across multiple graph elements.
There are no restrictions on the number of properties that can be stored in a single graph element. The only restriction is that the values must be of the supported types.
This are supported data types in Memgraph:
Null - Property has no value, which is the same as if the property doesn't exist.
String - Character string (text).
Boolean - Boolean value, either true or false.
Integer - Integer number.
Float - Floating-point number (real number).
List - List containing any number of property values of any supported type under a single property name.
Map - Mapping of string keys to values of any supported type.
Duration - Period of time.
Date - Date with year, month, and day.
LocalTime - Time without the time zone.
LocalDateTime - Date and time without the time zone.

Can't query semi-structured data using lateral flatten etc

I've got some data in a table, and one of the columns is a Variant which contains a ree of JSON data. I can successfully flatten arrays, and arrays within arrays to access data therein but I'm struggling with flattening key-value pairs to access the value for a given key.
I've seen the docs at https://docs.snowflake.net/manuals/user-guide/json-basics-tutorial.html mapping this onto my use case results in NULL values in the results.
My variant is show in part below - In particular it's values like MatchStatus and the key/values under Variables that I'm interested in extracting.
Thanks for any helpful suggestions.
The described JSON has a simple path-like structure with objects at various levels (and no arrays).
Per Snowflake's semi-structured data documentation, use the dot notation to extract a value following a (flatly nested) path:
Insert a colon : between the VARIANT column name
and any first-level element: <column>:<level1_element>.
Use dot notation to traverse a path in a JSON object:
<column>:<level1_element>.<level2_element>.<level3_element>.
An example would be (note the chained use of dots in the third and fourth lines):
SELECT
badminton_odds:Id as id,
badminton_odds:PricingRequest.MatchStatus as match_status,
badminton_odds:PricingRequest.Variables.Dispersion as var_dispersion
FROM odds_table
You do not require FLATTEN for simple, singular value extraction. Use FLATTEN when you have a need to explode some series data into multiple rows (such as in case of arrays).
For example, if the described JSON in the question is how a single array element looks in a long array of such objects, you may use FLATTEN to first break the whole array into rows, and then apply path style extraction to retrieve the value from each row.

React Native - Firebase Realtime Database and storing arrays

Say I have an array of strings: var myFavouriteSites = ["www.fb.com", "www.xe.com", "www.youtu.be"];
Is there a way I can push this array into the realtime database as one 'field'? All stored in one place? Because I have read that they must be matched with a unique id/key and I am not familiar of how to do it.
I'm not sure what you mean by "in one place". But I can tell you that everything in Realtime Database is essentially key/value pairs, where the values are either strings, numbers, or other objects. There is no native "array" value type. Arrays get translated into objects where the keys are array indices. So if you assign an array at /location:
["www.fb.com", "www.xe.com", "www.youtu.be"]
You'll get a database structure that looks like this:
/location
0: "www.fb.com"
1: "www.xe.com"
2: "www.youtu.be"

What is the difference between array and enum in C ?

I find enum to be similar to an array,with the elements in it being numbered from 0. So what is the difference between an array and enum?
An Enum is basically a group of named constants.
It is an alternative to numbered flag parameters.
(It also doesn't have to be numbered from zero, you can specify the numbering.)
An Enum could be days of the week for example.
A Enum could departments in a company: eg SALES, BILLING, HR ...
A array is a sequence of memory locations. It is a collection. Each element in that collection is indexed by a number. So using that number you can retrieve the value stored at that location. Much like the page number in a book lets you look up the content of that page, the index on an array lets you look up the value stored at that location.
For example, if your company had numbered physical mail boxes for each department (starting from zero):
and you were creating some very simple software to let users log in to check how many letters they had uncollected,
you might choose to store them in an Array of Ints. Where the index is the mail box number, and the value is the number of letters in the box.
Then for ease of programming, you might choose define the departments as Enums (as described before) such that you could index of department name. But that would be getting more advanced.
You may be confusing Enum, with Enumerable which is a term used in some languages to describe any collection type which can be iterated though in sequence (Eg IEnumerable in C#). This term is not often used in C. It is not in anyway the same at all as Enum.
Array is a variable that can contain multiple elements with index starting from 0 whereas enum is an user defined datatype that contains a list of members for which an integer constant is assigned starting from 0. in case of enum the numbers starting from 0 are not indexes whereas in case of an array they are indexes. Also in case of enum you can assign your own constant values to the members that may or may not start from 0 and may or may not be in a sequence.
The main difference is that an array is a value and an enum is a type. And One main difference we can say that an array is a collection of other values (that is it contains other values, you can iterate through them or access individual ones by index), whereas an enum value is simply one atomic value. It doesn't contain any other values.
Both of them are totally different. Array is a value and enum is a type. array is a collection of different values whereas enum value is simply one value.
Array is used to iterate among various values using index whereas enum is assigned some atomic value and iterated so that we can easily iterate the type.
Array's value are assigned by using = operator 'eg. int a[4]={1,2,3,4}' and enum is the user defined data type and it is assigned like
enum days{sun,mon,tue,wed,thr,fri,sat}

filter an array on the basis of some property of the objects of array

I have an array with some objects stored in it.
Say I have objects of type application.
Each application object has some information associated with it like applicationType, appId etc.
I need to create seperate arrays for each applicationType.
like everytime I need to fetch out the objects of same applicationType.
i.e at the end i need to have an array that will consist of objects ( that will be arrays of same applicationType)
eg : object at 0th index will be an array of application of applicationType1.
object at 1st index will be an array of application of applicationType 2.
etc....
What is the most efficient way to do this ?
You create the array-of-arrays, then iterate over your original array of objects, find out the type of each & add it to the appropriate array in your array-of-arrays, creating a new one each time you encounter a type for the first time. You'll need a mapping from types to indices in your array-of-arrays; a map (or dictionary) would be good for that. In fact, if you have the flexibility, I'd make the array-of-arrays a map/dictionary and cut out the middleman.

Resources