Question regarding nested arrays

10 views
Skip to first unread message

jcav

unread,
Sep 21, 2021, 9:21:16 AM9/21/21
to Daikon discuss

I am trying to create a front-end for Daikon that allows to read invariants in exits in json format from a series of input parameters and, after analyzing the documentation and testing with the Chicory front-end, I have found a series of limitations when dealing with nested arrays of objects. For example, when trying to process a json like the following, which contains an array of objects of type location, with each location containing an array of objects of type id:

ARRAY EXAMPLE

{

locations: [ // List of locations objects

{ // location 1

url: "www.url1.com",

ids: [ // List of ids objects

{ // id 1

keyword: "keyword1",

provider: "provider1"

}

]

},

{ // location 2

url: "www.url2.com",

ids: [

{

keyword: "keyword2",

provider: "provider2"

}

]

}

]

}

Initially I thought that the format of a .dtrace file would be something similar to the one shown in the following screenshot, in which information about the elements of each of the arrays is stored separately:

IDEAL DTRACE


return 

hashcode1

1

return.locations

hashcode2

1

return.locations[..]

[hashcode3 hashcode4]

1

return.locations[0].url

"www.url1.com"

1

return.locations[0].ids

hashcode5

1

return.locations[0].ids[..]

[hashcode6 hashcode7]

1

return.locations[0].ids[0].keyword

"keyword1"

1

return.locations[0].ids[0].provider

"provider1"

1

...

However, the actual dtrace seems to "flatten" the properties of each of the objects into a single array (As is the case with the list of urls), as well as not being able to detect a deeper level of nesting (As is the case with objects of type id, of which only the hashcode is preserved).

REAL DTRACE


return

hashcode1

1

return.locations

hashcode2

1

return.locations[..]

[hashcode3 hashcode4]

1

return.locations[..].url

["www.url1.com" "www.url2.com"]

1

return.locations[..].ids

[hashcode5 hashcode6]

1

As a solution, I have thought of splitting the output program point into several outputs recursively each time an array appears, like the following one.

PROPOSED DTRACE

// locations

return

hashcode1

1

return.locations

hashcode2

1

return.locations[..]

[hashcode3 hashcode4]

1


// single location (Location 0)

return 

hashcode1

1

return.url

"www.url1.com"

1

return.ids

hashcode2

1

return.ids[..]

[hashcode3 hashcode4]


// Single id

return

hashcode1

1

return.keyword

"keyword1"

1

return.provider

"provider1"

1

...


By doing this, a single dtrace would be created for the locations property, two for the location type objects (One for each), and two for the id type objects (One for each). With this format, Daikon seems to detect the invariant types I am looking for, my question is if there is any way to represent this array nesting in Daikon that I may have missed, as I have not found anything similar running Chicory and reading the documentation. The documentation refers in some cases to multidimensional arrays, but I haven't found anything similar when running Daikon.



Reply all
Reply to author
Forward
0 new messages