WindowParametersHelper { public static String getCacheKey( String query, IDataServiceClientService.StreamingMode windowMode, long windowSize, long windowEvery, int windowMaxRowLimit, long windowMaxTimeLimit, long windowLimit, int serviceExecutorCacheKeyHash ) { boolean timeBased = IDataServiceClientService.StreamingMode.TIME_BASED.equals( windowMode ); boolean rowBased = IDataServiceClientService.StreamingMode.ROW_BASED.equals( windowMode ); int maxRows = getMaxRows( windowMaxRowLimit, windowLimit, timeBased ); long maxTime = getMaxTime( windowMaxTimeLimit, windowLimit, rowBased ); windowSize = getWindowSize( windowSize, timeBased, maxRows, maxTime ); if ( windowSize == 0 ) { return null; } windowEvery = getWindowEvery( windowEvery, timeBased, maxRows, maxTime ); return String.valueOf( serviceExecutorCacheKeyHash ) .concat( "-" ).concat( query.concat( windowMode.toString() ) ) .concat( "-" ).concat( String.valueOf( windowSize ) ) .concat( "-" ).concat( String.valueOf( windowEvery ) ) .concat( "-" ).concat( String.valueOf( maxRows ) ) .concat( "-" ).concat( String.valueOf( maxTime ) ); }  static String getCacheKey( String query, IDataServiceClientService.StreamingMode windowMode, long windowSize, long windowEvery,
                                    int windowMaxRowLimit, long windowMaxTimeLimit, long windowLimit, int serviceExecutorCacheKeyHash ); static long getWindowEvery( long windowEvery, boolean timeBased, int maxRows, long maxTime ); static long getWindowSize( long windowSize, boolean timeBased, int maxRows, long maxTime ); static long getMaxTime( long windowMaxTimeLimit, long windowLimit, boolean rowBased ); static int getMaxRows( int windowMaxRowLimit, long windowLimit, boolean timeBased );  }
@Test public void testGetCacheKey() { assertNull( WindowParametersHelper.getCacheKey( "query", IDataServiceClientService.StreamingMode.ROW_BASED, 0, 1, 10000, 10000, 1000, 99999 ) ); assertEquals( "99999-queryROW_BASED-10-1-10000-1000", WindowParametersHelper.getCacheKey( "query", IDataServiceClientService.StreamingMode.ROW_BASED, 10, 1, 10000, 10000, 1000, 99999 ) ); assertEquals( "99999-queryROW_BASED-1-1-1-2", WindowParametersHelper.getCacheKey( "query", IDataServiceClientService.StreamingMode.ROW_BASED, 10, 5, 1, 2, 1000, 99999 ) ); assertEquals( "88888-queryROW_BASED-1-1-1-2", WindowParametersHelper.getCacheKey( "query", IDataServiceClientService.StreamingMode.ROW_BASED, 10, 5, 1, 2, 1000, 88888 ) ); assertEquals( "99999-queryTIME_BASED-10-1-1000-10000", WindowParametersHelper.getCacheKey( "query", IDataServiceClientService.StreamingMode.TIME_BASED, 10, 1, 10000, 10000, 1000, 99999 ) ); assertEquals( "99999-queryTIME_BASED-2-2-1-2", WindowParametersHelper.getCacheKey( "query", IDataServiceClientService.StreamingMode.TIME_BASED, 10, 5, 1, 2, 1000, 99999 ) ); assertEquals( "77777-queryTIME_BASED-2-2-1-2", WindowParametersHelper.getCacheKey( "query", IDataServiceClientService.StreamingMode.TIME_BASED, 10, 5, 1, 2, 1000, 77777 ) ); assertEquals( "99999-queryROW_BASED-10-0-10000-1000", WindowParametersHelper.getCacheKey( "query", IDataServiceClientService.StreamingMode.ROW_BASED, 10, -1, 10000, 10000, 1000, 99999 ) ); assertEquals( "55555-queryROW_BASED-10-0-10000-1000", WindowParametersHelper.getCacheKey( "query", IDataServiceClientService.StreamingMode.ROW_BASED, 10, -1, 10000, 10000, 1000, 55555 ) ); assertNull( WindowParametersHelper.getCacheKey( "query", IDataServiceClientService.StreamingMode.ROW_BASED, -10, 1, 10000, 10000, 1000, 99999 ) ); assertNull( WindowParametersHelper.getCacheKey( "query", IDataServiceClientService.StreamingMode.ROW_BASED, -10, -1, 10000, 10000, 1000, 99999 ) ); }