@Override
    public StreamEvent find(CompiledCondition compiledCondition, StateEvent matchingEvent)
            throws ConnectionUnavailableException {
        try {
            updateStoreTableSize();
        } catch (ConnectionUnavailableException e) {
            log.error(e);
        }

        // handle compile condition type conv
        RecordStoreCompiledCondition recordStoreCompiledCondition;
        CompiledConditionWithCache compiledConditionWithCache = null;
        findMatchingEvent = matchingEvent;
        if (cacheEnabled) {
            RecordStoreCompiledCondition compiledConditionTemp = (RecordStoreCompiledCondition) compiledCondition;
            compiledConditionWithCache = (CompiledConditionWithCache)
                    compiledConditionTemp.getCompiledCondition();
            recordStoreCompiledCondition = new RecordStoreCompiledCondition(compiledConditionTemp.
                    variableExpressionExecutorMap, compiledConditionWithCache.getStoreCompileCondition(),
                    compiledConditionTemp.getSiddhiQueryContext());
        } else {
            recordStoreCompiledCondition =
                    ((RecordStoreCompiledCondition) compiledCondition);
        }

        StreamEvent cacheResults;
        if (cacheEnabled) {
            readWriteLock.writeLock().lock();
            try {
                // when table is smaller than max cache send results from cache
                if (storeTableSize <= maxCacheSize) {
                    if (log.isDebugEnabled()) {
                        log.debug(siddhiAppContext.getName() + "-" +
                                recordStoreCompiledCondition.getSiddhiQueryContext().getName() +
                                ": store table size is smaller than max cache. Sending results from cache");
                    }
                    cacheResults = cacheTable.find(compiledConditionWithCache.getCacheCompileCondition(),
                            matchingEvent);
                    return cacheResults;
                } else {
                    if (log.isDebugEnabled()) {
                        log.debug(siddhiAppContext.getName() + "-" +
                                recordStoreCompiledCondition.getSiddhiQueryContext().getName() +
                                ": store table size is bigger than cache.");
                    }
                    if (compiledConditionWithCache.isRouteToCache()) {
                        if (log.isDebugEnabled()) {
                            log.debug(siddhiAppContext.getName() + "-" +
                                    recordStoreCompiledCondition.getSiddhiQueryContext().
                                            getName() + ": cache constraints satisfied. Checking cache");
                        }
                        cacheResults = cacheTable.find(compiledConditionWithCache.getCacheCompileCondition(),
                                matchingEvent);
                        if (cacheResults != null) {
                            if (log.isDebugEnabled()) {
                                log.debug(siddhiAppContext.getName() + "-" + recordStoreCompiledCondition.
                                        getSiddhiQueryContext().getName() + ": cache hit. Sending results from cache");
                            }
                            return cacheResults;
                        }
                        // cache miss
                        if (log.isDebugEnabled()) {
                            log.debug(siddhiAppContext.getName() + "-" +
                                    recordStoreCompiledCondition.getSiddhiQueryContext().
                                            getName() + ": cache miss. Loading from store");
                        }
                        StreamEvent streamEvent = super.find(recordStoreCompiledCondition, matchingEvent);
                        if (streamEvent == null) {
                            if (log.isDebugEnabled()) {
                                log.debug(siddhiAppContext.getName() + "-" + recordStoreCompiledCondition.
                                        getSiddhiQueryContext().getName() + ": store also miss. sending null");
                            }
                            return null;
                        }

                        if (cacheTable.size() == maxCacheSize) {
                            ((CacheTable) cacheTable).deleteOneEntryUsingCachePolicy();
                        }
                        ((CacheTable) cacheTable).addStreamEventUptoMaxSize(streamEvent);
                        cacheResults = cacheTable.find(compiledConditionWithCache.getCacheCompileCondition(),
                                matchingEvent);
                        if (log.isDebugEnabled()) {
                            log.debug(siddhiAppContext.getName() + "-" + recordStoreCompiledCondition.
                                    getSiddhiQueryContext().getName() +
                                    ": sending results from cache after loading from store");
                        }
                        return cacheResults;
                    }
                }
            } finally {
                readWriteLock.writeLock().unlock();
            }
        }
        // when cache is not enabled or cache query conditions are not satisfied
        if (log.isDebugEnabled()) {
            log.debug(siddhiAppContext.getName() + "-" + recordStoreCompiledCondition.getSiddhiQueryContext().getName()
                    + ": sending results from store");
        }
        return super.find(recordStoreCompiledCondition, matchingEvent);
    }
An abstract implementation of table. Abstract implementation will handle {@link ComplexEventChunk} so that
developer can directly work with event data.
modules/siddhi-core/src/main/java/io/siddhi/core/table/record/AbstractQueryableRecordTable.java