default Function<CacheType, T> pullFromSegmentLevelCache() { return pullFromCache(false); } }
private Sequence<T> deserializeResults(final byte[] cachedResult, CacheStrategy strategy, String resultSetId) { if (cachedResult == null) { log.error("Cached result set is null"); } final Function<Object, T> pullFromCacheFunction = strategy.pullFromCache(true); final TypeReference<Object> cacheObjectClazz = strategy.getCacheObjectClazz(); //Skip the resultsetID and its length bytes Sequence<T> cachedSequence = Sequences.simple(() -> { try { int resultOffset = Integer.BYTES + resultSetId.length(); return objectMapper.readValues( objectMapper.getFactory().createParser( cachedResult, resultOffset, cachedResult.length - resultOffset ), cacheObjectClazz ); } catch (IOException e) { throw new RE(e, "Failed to retrieve results from cache for query ID [%s]", query.getId()); } }); return Sequences.map(cachedSequence, pullFromCacheFunction); }
); Result<TopNResultValue> fromResultCacheResult = strategy.pullFromCache(true).apply(fromResultCacheValue); Assert.assertEquals(result2, fromResultCacheResult);
); Result<TimeseriesResultValue> fromResultLevelCacheRes = strategy.pullFromCache(true).apply(fromResultLevelCacheValue); Assert.assertEquals(result2, fromResultLevelCacheRes);
default Function<CacheType, T> pullFromSegmentLevelCache() { return pullFromCache(false); } }
private Sequence<T> deserializeResults( final byte[] cachedResult, CacheStrategy strategy, String resultSetId ) { if (cachedResult == null) { log.error("Cached result set is null"); } final Function<Object, T> pullFromCacheFunction = strategy.pullFromCache(true); final TypeReference<Object> cacheObjectClazz = strategy.getCacheObjectClazz(); //Skip the resultsetID and its length bytes Sequence<T> cachedSequence = Sequences.simple(() -> { try { int resultOffset = Integer.BYTES + resultSetId.length(); return objectMapper.readValues( objectMapper.getFactory().createParser( cachedResult, resultOffset, cachedResult.length - resultOffset ), cacheObjectClazz ); } catch (IOException e) { throw new RE(e, "Failed to retrieve results from cache for query ID [%s]", query.getId()); } }); return Sequences.map(cachedSequence, pullFromCacheFunction); }