Yes, this is exactly what I need. To start from the day and walk
horizontally. I just don't understand how can I walk that way :)
Using my query, could you modify it to demo me how to walk horizontally?
I'm really confused here.
select from (
traverse out()
from #217:6 // Year node
maxdepth 2
strategy BREADTH_FIRST
)
where $depth >= 2
limit 10
On Wednesday, February 8, 2017 at 11:31:11 PM UTC-8, hartmut bischoff wrote:
>
> Hi,
>
> the time-graph in the ruby-gem follows the standard approach. Its
> documented on github.
>
> You are walking horizontally through the grid. Therefor you have to start
> at the day-class in order walk to a different day. On the year-level, the
> adjacent node is another year.
>
>
> Am Donnerstag, 9. Februar 2017 07:39:50 UTC+1 schrieb Borov:
>>
>> Does your time-grid has the same node structure as in my diagram? I like
>> the idea of counting number of days in the range and do a traversal,
>> however, if I start the traversal from the top (Year) node it will get me
>> all months and days for the specified limit.
>>
>> How do I start from the specific day and go let say to the right
>> (ascending order) to get next days until the counted limit of days reached?
>> If I start from a specific day, I would have to traverse to its parent
>> (Month) and then to that parent (Year) in order to traverse days
>> horizontally, but it's the same as starting from the Year.
>>
>> For example, this traversal query get's me the 10 days, but how do I
>> start from a specific day and go to the right to get the next day, etc.?
>>
>> select from (
>> traverse out()
>> from #217:6 // Year node
>> maxdepth 2
>> strategy BREADTH_FIRST
>> )
>> where $depth >= 2
>> limit 10
>>
>>
>> Or am I missing something here? Or my graph (per diagrams) is not correct?
>>
>>
>>
>> On Wednesday, February 8, 2017 at 1:40:31 AM UTC-8, hartmut bischoff
>> wrote:
>>>
>>>
>>>
>>> Am Mittwoch, 8. Februar 2017 09:55:43 UTC+1 schrieb hartmut bischoff:
>>>>
>>>> In the ruby-gem I realized it in a different way.
>>>> If you populated a time-grid correctly, you got exact one object per
>>>> time-frame (ie. one per day). The days are connected via nodes.
>>>> Thus - if you count the time-frames (days) between start and end of
>>>> your time-range, you know the count of nodes to traverse.
>>>>
>>>> This is the ruby-method to get these elements:
>>>>
>>>> 85 def environment previous_items = 10, next_items = nil
>>>> 86 next_items = previous_items if next_items.nil? # default :
>>>> symmetric fetching
>>>> 87
>>>> 88 my_query = -> (count) { dir = count <0 ? 'in' : 'out';
>>>> db.execute
>>>> { "select from ( traverse #{dir}(\"grid_of\") from #{rrid} while
>>>> $depth <= #{count.abs}) where $depth >=1 " } } # don't fetch self
>>>> 89
>>>> 90 prev_result = previous_items.zero? ? [] : my_query[
>>>> -previous_items
>>>> ]
>>>> 91 next_result = next_items.zero? ? [] : my_query[ next_items ]
>>>> 92
>>>> 93 prev_result.reverse << self | next_result
>>>> 94 end
>>>>
>>>>
>>>> From the documentation:
>>>>
>>>>> Get the nearest horizontal neighbors
>>>>>
>>>>> Takes one or two parameters.
>>>>>
>>>>> (TG::TimeBase.instance).environment: count_of_previous_nodes,
>>>>> count_of_future_nodes
>>>>>
>>>>> Default: return the previous and next 10 items
>>>>>
>>>>> "22.4.1967".to_tg.environment.datum
>>>>> => ["12.4.1967", "13.4.1967", "14.4.1967", "15.4.1967",
>>>>> "16.4.1967", "17.4.1967", "18.4.1967", "19.4.1967", …"20.4.1967",
>>>>> "21.4.1967", "22.4.1967", "23.4.1967", "24.4.1967", "25.4.1967",
>>>>> "26.4.1967", "27.4.1967", "28.4. …1967", "29.4.1967", "30.4.1967",
>>>>> "1.5.1967", "2.5.1967"]
>>>>>
>>>>
>>>>
>>>> I am sure you can easily adapt to java
>>>>
>>>
>>>
>>> I just checked
>>>
>>> 2.4.0 :017 > t1 = Date.new 2015, 10, 15 # 10/15/2015 - 02/05/2017
>>> => Thu, 15 Oct 2015
>>> 2.4.0 :018 > t2 = Date.new 2017, 5, 2
>>> => Tue, 02 May 2017
>>> 2.4.0 :019 > date_range = t1.to_tg.environment(t2-t1)
>>> (...)
>>>
>>>
>>> 2.4.0 :020 > date_range.first ## inspect ruby-object
>>> => #<TG::Tag:0x00000001d90188 @metadata={"type"=>"d", "class"=>"tag",
>>> "version"=>4, "fieldTypes"=>"in_grid_of=g,out_grid_of=g,in_day_of=g",
>>> "cluster"=>26, "record"=>10431, "edges"=>{"in"=>["grid_of", "day_of"],
>>> "out"=>["grid_of"]}}, @d=nil, @attributes={"value"=>29,
>>> "in_grid_of"=>["#49:10802"], "out_grid_of"=>["#50:10802"],
>>> "in_day_of"=>["#42:10431"], "created_at"=>Wed, 08 Feb 2017 10:30:39 +0100}>
>>> 2.4.0 :021 > date_range.last
>>> => #<TG::Tag:0x000000044c4f88 @metadata={"type"=>"d", "class"=>"tag",
>>> "version"=>4, "fieldTypes"=>"in_grid_of=g,out_grid_of=g,in_day_of=g",
>>> "cluster"=>28, "record"=>10713, "edges"=>{"in"=>["grid_of", "day_of"],
>>> "out"=>["grid_of"]}}, @d=nil, @attributes={"value"=>2,
>>> "in_grid_of"=>["#52:11094"], "out_grid_of"=>["#49:11095"],
>>> "in_day_of"=>["#44:10713"], "created_at"=>Wed, 08 Feb 2017 10:30:40 +0100}>
>>> 2.4.0 :022 > date_range.last.datum ## datum is a method of TG::Tag
>>> => "2.5.2017"
>>>
>>>
>>> 2.4.0 :024 > date_range.size
>>> => 1131
>>>
>>>
>>>
>>> seems it works as proposed
>>>
>>>
>>
--
---
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.