public static long loadOrAddRefPlanFragment ( byte [ ] planHash , byte [ ] plan , String stmtText ) { Sha1Wrapper key = new Sha1Wrapper ( planHash ) ; synchronized ( FragInfo . class ) { FragInfo frag = m_plansByHash . get ( key ) ; if ( frag == null ) { frag = new FragInfo ( key , plan , m_nextFragId ++ , stmtText ) ; m_plansByHash . put ( frag . hash , frag ) ; m_plansById . put ( frag . fragId , frag ) ; if ( m_plansById . size ( ) > ExecutionEngine . EE_PLAN_CACHE_SIZE ) { evictLRUfragment ( ) ; } } // Bit of a hack to work around an issue where a statement-less adhoc // fragment could be identical to a statement-needing regular procedure. // This doesn't really address the broader issue that fragment hashes // are not 1-1 with SQL statements. if ( frag . stmtText == null ) { frag . stmtText = stmtText ; } // The fragment MAY be in the LRU map. // An incremented refCount is a lazy way to keep it safe from eviction // without having to update the map. // This optimizes for popular fragments in a small or stable cache that may be reused // many times before the eviction process needs to take any notice. frag . refCount ++ ; return frag . fragId ; } }
Get the site - local fragment id for a given plan identified by 20 - byte sha - 1 hash If the plan isn t known to this SPC load it up . Otherwise addref it .