@Override public PMetaDataCache clone() { return new PMetaDataCache(this); }
@Override public PMetaDataImpl clone() { return new PMetaDataImpl(new PMetaDataCache(this.metaData), this.timeKeeper, this.tableRefFactory); }
public PMetaDataImpl(int initialCapacity, TimeKeeper timeKeeper, ReadOnlyProps props) { this(new PMetaDataCache(initialCapacity, props.getLong( QueryServices.MAX_CLIENT_METADATA_CACHE_SIZE_ATTRIB, QueryServicesOptions.DEFAULT_MAX_CLIENT_METADATA_CACHE_SIZE), timeKeeper, PTableRefFactory.getFactory(props)), timeKeeper, PTableRefFactory.getFactory(props)); }
@Override public PMetaDataCache clone() { return new PMetaDataCache(this); }
@Override public PMetaDataCache clone() { return new PMetaDataCache(this); }
/** * Used when the cache is growing past its max size to clone in a single pass. * Removes least recently used tables to get size of cache below its max size by * the overage amount. */ public PMetaDataCache cloneMinusOverage(long overage) { assert(overage > 0); int nToRemove = Math.max(MIN_REMOVAL_SIZE, (int)Math.ceil((currentByteSize-maxByteSize) / ((double)currentByteSize / size())) + 1); MinMaxPriorityQueue<PTableRef> toRemove = BUILDER.expectedSize(nToRemove).create(); PMetaDataCache newCache = new PMetaDataCache(this.size(), this.maxByteSize, this.timeKeeper, this.tableRefFactory); long toRemoveBytes = 0; // Add to new cache, but track references to remove when done // to bring cache at least overage amount below it's max size. for (PTableRef tableRef : this.tables.values()) { newCache.put(tableRef.getTable().getKey(), tableRefFactory.makePTableRef(tableRef)); toRemove.add(tableRef); toRemoveBytes += tableRef.getEstimatedSize(); while (toRemoveBytes - toRemove.peekLast().getEstimatedSize() >= overage) { PTableRef removedRef = toRemove.removeLast(); toRemoveBytes -= removedRef.getEstimatedSize(); } } for (PTableRef toRemoveRef : toRemove) { newCache.remove(toRemoveRef.getTable().getKey()); } return newCache; }
@Override public PMetaDataImpl clone() { return new PMetaDataImpl(new PMetaDataCache(this.metaData), this.timeKeeper, this.tableRefFactory); }
@Override public PMetaDataImpl clone() { return new PMetaDataImpl(new PMetaDataCache(this.metaData), this.timeKeeper, this.tableRefFactory); }
public PMetaDataImpl(int initialCapacity, TimeKeeper timeKeeper, ReadOnlyProps props) { this(new PMetaDataCache(initialCapacity, props.getLong( QueryServices.MAX_CLIENT_METADATA_CACHE_SIZE_ATTRIB, QueryServicesOptions.DEFAULT_MAX_CLIENT_METADATA_CACHE_SIZE), timeKeeper, PTableRefFactory.getFactory(props)), timeKeeper, PTableRefFactory.getFactory(props)); }
public PMetaDataImpl(int initialCapacity, TimeKeeper timeKeeper, ReadOnlyProps props) { this(new PMetaDataCache(initialCapacity, props.getLong( QueryServices.MAX_CLIENT_METADATA_CACHE_SIZE_ATTRIB, QueryServicesOptions.DEFAULT_MAX_CLIENT_METADATA_CACHE_SIZE), timeKeeper, PTableRefFactory.getFactory(props)), timeKeeper, PTableRefFactory.getFactory(props)); }
/** * Used when the cache is growing past its max size to clone in a single pass. * Removes least recently used tables to get size of cache below its max size by * the overage amount. */ public PMetaDataCache cloneMinusOverage(long overage) { assert(overage > 0); int nToRemove = Math.max(MIN_REMOVAL_SIZE, (int)Math.ceil((currentByteSize-maxByteSize) / ((double)currentByteSize / size())) + 1); MinMaxPriorityQueue<PTableRef> toRemove = BUILDER.expectedSize(nToRemove).create(); PMetaDataCache newCache = new PMetaDataCache(this.size(), this.maxByteSize, this.timeKeeper, this.tableRefFactory); long toRemoveBytes = 0; // Add to new cache, but track references to remove when done // to bring cache at least overage amount below it's max size. for (PTableRef tableRef : this.tables.values()) { newCache.put(tableRef.getTable().getKey(), tableRefFactory.makePTableRef(tableRef)); toRemove.add(tableRef); toRemoveBytes += tableRef.getEstimatedSize(); while (toRemoveBytes - toRemove.peekLast().getEstimatedSize() >= overage) { PTableRef removedRef = toRemove.removeLast(); toRemoveBytes -= removedRef.getEstimatedSize(); } } for (PTableRef toRemoveRef : toRemove) { newCache.remove(toRemoveRef.getTable().getKey()); } return newCache; }
/** * Used when the cache is growing past its max size to clone in a single pass. * Removes least recently used tables to get size of cache below its max size by * the overage amount. */ public PMetaDataCache cloneMinusOverage(long overage) { assert(overage > 0); int nToRemove = Math.max(MIN_REMOVAL_SIZE, (int)Math.ceil((currentByteSize-maxByteSize) / ((double)currentByteSize / size())) + 1); MinMaxPriorityQueue<PTableRef> toRemove = BUILDER.expectedSize(nToRemove).create(); PMetaDataCache newCache = new PMetaDataCache(this.size(), this.maxByteSize, this.timeKeeper, this.tableRefFactory); long toRemoveBytes = 0; // Add to new cache, but track references to remove when done // to bring cache at least overage amount below it's max size. for (PTableRef tableRef : this.tables.values()) { newCache.put(tableRef.getTable().getKey(), tableRefFactory.makePTableRef(tableRef)); toRemove.add(tableRef); toRemoveBytes += tableRef.getEstimatedSize(); while (toRemoveBytes - toRemove.peekLast().getEstimatedSize() >= overage) { PTableRef removedRef = toRemove.removeLast(); toRemoveBytes -= removedRef.getEstimatedSize(); } } for (PTableRef toRemoveRef : toRemove) { newCache.remove(toRemoveRef.getTable().getKey()); } return newCache; }