To summarise:    **WORKING* TIME SERIES EXAMPLE*

1. Create linked Vertex with properties to linked hashmaps as per 
Alessandro's original post

2. Populate instances of days, weeks, etc 
        //add a few year vertex
        for(int yy = 2015; yy < 2020; yy++) //will allow minus 2015 to the 
orid to query 
        {
            //all months this year
            Map<String, OrientVertex> months = new HashMap<>();
            
            //add all the months
            for(int mm = 0; mm < 12; mm++) //developer gothcha - java 
months are 0 based!
            {
                //all days this month
                Map<String, OrientVertex> days = new HashMap<>();
                
                //add all the days in a month
                for(int dd = 1; dd < 32; dd++)
                {
                    //all hours this day
                    Map<String, OrientVertex> hours = new HashMap<>();
                    
                    //add all the hours in a day
                    for(int i = 0; i < 24; i++)
                    {
                        OrientVertex hour = graph.addVertex("class:hour");
                        hour.setProperty("log", new HashMap<>()); //new 
empty hashmap to hold the logs
                        hour.setProperty("label", i + ":00 to " + i + 
":59");
                        hours.put(Integer.toString(i), hour);
                    }
                    
                    //add days
                    OrientVertex day = graph.addVertex("class:day");
                    //link log with hour
                    day.setProperty("hour", hours);
                    day.setProperty("label", dd + "");
                    days.put(Integer.toString(dd), day);
                }
                
                //add months
                OrientVertex month = graph.addVertex("class:month");
                //link day with hour
                month.setProperty("day", days);
                month.setProperty("label", new 
DateFormatSymbols().getMonths()[mm]);
                months.put(Integer.toString(mm), month);
            }
            
            //add years
            OrientVertex year = graph.addVertex("class:year");
            year.setProperty("label", Integer.toString(yy));
            //link year with month ----
            year.setProperty("month", months);
        }

3. At runtime add logs with:

*insert into log(priority) values ('very high')*
*update hour add log =[#11:0] where @rid IN (select month[1].day[4].hour[6] 
from #12:0)    *                    (thanks Luigi)

4. Query logs with

*select month[10].day[12].hour[16].log from #12:0*                              
                                              


or select expand (logentry) from (select month[10].day[12].hour[16].log as 
logentry from #1756:0)

(#12:0 is the rid of the year, #11:0 is the rid of the log)


-- 

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