Do you have any example of how to manipulate the $stack object with 
OTraverse? I did not found any docs about that.

On Saturday, April 28, 2012 8:57:59 PM UTC-3, Lvc@ wrote:
>
> Hi,
> $stack contains Java stuff non displayable as projection but only with 
> OTraverse native API.
>
> Lvc@
>
> On 29 April 2012 00:47, Daniel Kersten <[email protected] <javascript:>>wrote:
>
>> Hi Luca,
>>
>> Thanks! This is exactly what I was looking for.
>>
>> PS: $stack doesn't seem to work for me, I don't get any results at all if 
>> I include it in a query. $depth, $path and $history work perfectly however.
>>
>> Regards,
>> Dan.
>>
>>
>> On 28 April 2012 20:23, Luca Garulli <[email protected] <javascript:>>wrote:
>>
>>> Hi,
>>> wow. That's is what I call to explain well a problem! :-)
>>>
>>> Some hints: use the $path and $stack in your query with the traverse.
>>>
>>> To see what exits try:
>>>
>>> select $path, $stack from ( traverse * from V where $depth <= 3 )
>>>
>>> Lvc@
>>>
>>>
>>> On 27 April 2012 04:10, Daniel Kersten <[email protected] 
>>> <javascript:>>wrote:
>>>
>>>> Hi Luca,
>>>>
>>>> I've attached some illustrations of the specific problem I'm trying to 
>>>> solve. Note, I don't need you to write the queries for me (unless its 
>>>> really quick and easy for you to do so), I'm more interested to understand 
>>>> if what I want to do is possible and how to approach it so that I can 
>>>> solve 
>>>> similar problems myself in the future, so am happy enough to try and write 
>>>> them myself with some guidance and help.
>>>>
>>>> Here is the data in tabular form:
>>>>
>>>> Class Vertex:
>>>> rid  | tag | in              | out
>>>> -----+-----+-----------------+-----
>>>> #1:0 |  1  |#2:3             |#2:0,#2:1,#2:2
>>>> #1:1 |  2  |#2:0             |#2:4
>>>> #1:2 |  3  |#2:1             |#2:7
>>>> #1:3 |  4  |#2:2,#2:5        |#2:3,#2:8,#2:9
>>>> #1:4 |  5  |#2:4,#2:6        |#2:5,#2:10,#2:11
>>>> #1:5 |  6  |#2:11            |#2:6
>>>> #1:6 |  7  |#2:7,#2:8,#2:12  |
>>>> #1:7 |  8  |#2:9,#2:15       |#2:12,#2:13
>>>> #1:8 |  9  |#2:10,#2:13,#2:14|#2:14,#2:16
>>>> #1:9 | 10  |#2:16            | #2:15
>>>>
>>>> Class Edge:
>>>> rid   | action | in | out
>>>> ------+--------+----+-----
>>>> #2:0  |   a    |#1:0|#1:1
>>>> #2:1  |   c    |#1:0|#1:2
>>>> #2:2  |   a    |#1:0|#1:3
>>>> #2:3  |   b    |#1:3|#1:0
>>>> #2:4  |   c    |#1:1|#1:4
>>>> #2:5  |   a    |#1:4|#1:3
>>>> #2:6  |   b    |#1:5|#1:4
>>>> #2:7  |   b    |#1:2|#1:6
>>>> #2:8  |   a    |#1:3|#1:6
>>>> #2:9  |   c    |#1:3|#1:7
>>>> #2:10 |   d    |#1:4|#1:8
>>>> #2:11 |   c    |#1:4|#1:5
>>>> #2:12 |   b    |#1:7|#1:6
>>>> #2:13 |   a    |#1:7|#1:8
>>>> #2:14 |   d    |#1:8|#1:8
>>>> #2:15 |   d    |#1:9|#1:7
>>>> #2:16 |   b    |#1:8|#1:9
>>>>
>>>>
>>>> So for the first query, I want to find the "path" followed to complete 
>>>> this query:
>>>>
>>>> select from (traverse out from #1:0 where $depth < 10) where action = 
>>>> 'd'
>>>>
>>>> Running that query returns:
>>>>
>>>> rid   | action | in | out
>>>> ------+--------+----+-----
>>>> #2:10 |   d    |#1:4|#1:8
>>>>
>>>>
>>>> But I want to retrieve the intermediary steps, as shown in red in 
>>>> graph1.png. Something like this:
>>>>
>>>> rid  | tag | Vertex.out | action | Edge.out
>>>> -----+-----+------------+--------+---------
>>>> #1:0 |  1  | #2:0       |   a    | #1:1
>>>> #1:1 |  2  | #2:4       |   c    | #1:4
>>>> #1:4 |  5  | #2:10      |   d    | #1:8
>>>>
>>>> The second query I would like to do is highlighted in graph2.png and 
>>>> isn't as important to me for what I am currently trying to achieve. Its 
>>>> essentially the same thing (except that the target is a vertex instead of 
>>>> an edge) only this time there is more than one possible path - there's the 
>>>> highlighted one and there's also #1:0 -> #1:3 -> #1:7 -> #1:8 which is the 
>>>> exact same number of traversals. I imagine in the future, I may want to 
>>>> query for the optimal path (using some domain specific definition of 
>>>> "optimal" that would need to be encoded in the query somehow), but for 
>>>> now, 
>>>> any path will do - or all paths listed one after the other as below (the 
>>>> path highlighted in the image is also highlighted below):
>>>>
>>>> rid  | tag | Vertex.out | action    | Edge.out
>>>> -----+-----+------------+-----------+---------
>>>> #1:0 |  1  | #2:2       |   a       | #1:3
>>>> #1:3 |  4  | #2:9       |   c       | #1:7
>>>> #1:7 |  8  | #2:13      |   a       | #1:8
>>>> #1:8 |  9  | undefined  | undefined | undefined
>>>> #1:0 |  1  | #2:0       |   a       | #1:1
>>>> #1:1 |  2  | #2:4       |   c       | #1:4
>>>> #1:4 |  5  | #2:10      |   d       | #1:8
>>>> #1:8 |  9  | undefined  | undefined | undefined
>>>>
>>>>
>>>> Thanks very much for all the help! I really appreciate it!
>>>>
>>>> Regards,
>>>> Dan.
>>>>
>>>>
>>>> On 26 April 2012 14:37, Daniel Kersten <[email protected] <javascript:>
>>>> > wrote:
>>>>
>>>>> Hi Luca,
>>>>>
>>>>> select from (traverse out from ? where $depth <= 5) where count = 50
>>>>>
>>>>> and ? is set to the @rid of the Webpage vertex where url = "google.com". 
>>>>> This should basically return the full graph of the sample data I posted. 
>>>>> (Of course real data would have many branching Redirect edges)
>>>>>
>>>>> On that note, I have a related question that I'm trying to understand. 
>>>>> I've experimented with a number of queries, but haven't been able to 
>>>>> nesting some of them. The following seems to work:
>>>>>
>>>>> select from (traverse out from (select from Webpage where url = '
>>>>> google.com') where $depth <= 5) where count = 50
>>>>>
>>>>> But I haven't been able to figure out how to do something similar to 
>>>>> this?
>>>>>
>>>>> select url from Webpage where out.count = (select max(count) from 
>>>>> Redirect)
>>>>>
>>>>> or 
>>>>>
>>>>> select url from Webpage where out.count = (select max(count) from 
>>>>> Redirect).max
>>>>>
>>>>> or
>>>>>
>>>>> select url from Webpage where out.count = (select max(count) from 
>>>>> Redirect)[max]
>>>>>
>>>>> Is this possible?
>>>>>
>>>>> -----
>>>>>
>>>>> Unrelated to the above, are there any instructions to what I have to 
>>>>> do to get Gremlin working? I'm using the 1.0-SNAPSHOT and copied the jars 
>>>>> from graphed lib/ to the lib/ in release1.0-SNAPSHOT but that doesn't 
>>>>> work. 
>>>>> Do I have to set a flag during compilation or set something in the config?
>>>>> Thanks!
>>>>>
>>>>> One final question is about implementing group by.
>>>>> I browsed through the code a bit to try and get a feel for how one 
>>>>> would go about implementing this, but honestly I'm a bit lost even 
>>>>> finding 
>>>>> out where such a thing would be added. Functions and operators seem easy 
>>>>> enough to add, but I'm having difficulty figuring out where new clauses 
>>>>> would fit in. I'm guessing perhaps 
>>>>>
>>>>> com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect
>>>>>
>>>>> I see around line 200 it seems to collect the data for the order by 
>>>>> clause, so maybe something similar must be run before running the 
>>>>> aggregate 
>>>>> functions.
>>>>>
>>>>> I guess maybe in execute() you would need to add an applyGroupBy(). 
>>>>> Maybe something like: it converts the list of results into a list of 
>>>>> lists 
>>>>> of results and applies the projections to this list. Something like this 
>>>>> pseudocode:
>>>>>
>>>>> executeSearch();
>>>>> applyFlatten();
>>>>>
>>>>> if (anyFunctionAggregates) {
>>>>>     // Group the results
>>>>>     for ( List result : applyGroupBy() ) {
>>>>>         // Apply to one list of results at a time
>>>>>         applyProjections(); 
>>>>>     }
>>>>> } else {
>>>>>     applyProjections();
>>>>> }
>>>>> applyOrderBy();
>>>>> applyLimit();
>>>>>
>>>>>
>>>>> Though I'm not really sure how to actually do this yet and definitely 
>>>>> have no idea where or how to parse for the group by clause. Can you also 
>>>>> point out where the "where" clause is parsed and applied? I would like to 
>>>>> study it, but am not sure where its implemented.
>>>>>
>>>>> Thanks,
>>>>> Dan.
>>>>>
>>>>>
>>>>> On 26 April 2012 10:48, Luca Garulli <[email protected] 
>>>>> <javascript:>>wrote:
>>>>>
>>>>>> select from (traverse out from ? where $depth <= 5) where action = 
>>>>>> 'target'
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to