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
--
---
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.