ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anthony <amc2...@columbia.edu>
Subject Re: Question regarding possible use case of Sliding Windows
Date Fri, 19 Jun 2015 13:11:42 GMT
Val, I appreciate your time. It has been helpful for my understanding of
Ignite. Code is here:

public class StreamWords {
    
    private static final String[] INSTRUMENTS = {"ABC"};
    
    public static void main(String[] args) throws Exception {
        Ignition.setClientMode(true);
        try (Ignite ignite =
Ignition.start("examples/config/example-ignite.xml")) {
            if (!ExamplesUtils.hasServerNodes(ignite))
                return;
            try (
                    IgniteCache<AffinityUuid, String> stmCache =
ignite.getOrCreateCache(CacheConfig.wordCache());
                ) {
                    try (
                    	 IgniteDataStreamer<AffinityUuid, String> stmr =
ignite.dataStreamer(stmCache.getName())
                   ) {
                            int idx = 0;
                            stmr.addData(new AffinityUuid(INSTRUMENTS[idx]),
INSTRUMENTS[idx]);
                            System.out.println("at "+new
java.text.SimpleDateFormat("MM/dd/yyyy h:mm:ss a").format(new Date())+",
streamed "+INSTRUMENTS[idx]);
                            Thread.sleep(1000);
                            
                            stmr.addData(new AffinityUuid(INSTRUMENTS[idx]),
INSTRUMENTS[idx]);
                            System.out.println("at "+new
java.text.SimpleDateFormat("MM/dd/yyyy h:mm:ss a").format(new Date())+",
streamed "+INSTRUMENTS[idx]); 
                            Thread.sleep(1000);
                            
                            stmr.addData(new AffinityUuid(INSTRUMENTS[idx]),
INSTRUMENTS[idx]);
                            System.out.println("at "+new
java.text.SimpleDateFormat("MM/dd/yyyy h:mm:ss a").format(new Date())+",
streamed "+INSTRUMENTS[idx]); 
                            Thread.sleep(1000);
                            
                            stmr.addData(new AffinityUuid(INSTRUMENTS[idx]),
INSTRUMENTS[idx]);
                            System.out.println("at "+new
java.text.SimpleDateFormat("MM/dd/yyyy h:mm:ss a").format(new Date())+",
streamed "+INSTRUMENTS[idx]); 
                            Thread.sleep(1000);
                            
                            stmr.addData(new AffinityUuid(INSTRUMENTS[idx]),
INSTRUMENTS[idx]);
                            System.out.println("at "+new
java.text.SimpleDateFormat("MM/dd/yyyy h:mm:ss a").format(new Date())+",
streamed "+INSTRUMENTS[idx]);
                            Thread.sleep(1000);
                    }
                    System.out.println("Querying at "+new
java.text.SimpleDateFormat("MM/dd/yyyy h:mm:ss a").format(new Date())); 
                    SqlFieldsQuery tickerQry = new SqlFieldsQuery(
                    		"select _val,count(_val) as cnt from String group by
_val");  
                    List<List&lt;?>> tickers =
stmCache.query(tickerQry).getAll();
                    ExamplesUtils.printQueryResults(tickers);
        }
    }
}
}

The query returns all 5 of the elements I inserted, instead of just the past
two seconds. The CacheConfig is the same as the example used in the alice in
wonderland text steaming, but changed to two seconds. 



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Question-regarding-possible-use-case-of-Sliding-Windows-tp530p543.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Mime
View raw message