@Test public void shouldAlwaysKeepAtLeastOneEntryEvenIfTooLarge() throws Exception { TestTimeKeeper timeKeeper = new TestTimeKeeper(); Map<String, String> props = Maps.newHashMapWithExpectedSize(2); props.put(QueryServices.MAX_CLIENT_METADATA_CACHE_SIZE_ATTRIB, "5"); props.put(QueryServices.CLIENT_CACHE_ENCODING, "object"); PMetaData metaData = new PMetaDataImpl(5, timeKeeper, new ReadOnlyProps(props)); addToTable(metaData, "a", 1, timeKeeper); assertEquals(1, metaData.size()); addToTable(metaData, "b", 1, timeKeeper); assertEquals(2, metaData.size()); addToTable(metaData, "c", 5, timeKeeper); assertEquals(1, metaData.size()); addToTable(metaData, "d", 20, timeKeeper); assertEquals(1, metaData.size()); assertNames(metaData, "d"); addToTable(metaData, "e", 1, timeKeeper); assertEquals(1, metaData.size()); addToTable(metaData, "f", 2, timeKeeper); assertEquals(2, metaData.size()); assertNames(metaData, "e", "f"); }
@Override public int size() { return metaData.size(); }
PMetaDataImpl implements PMetaData { @Override public int size() { return metaData.size(); } }
PMetaDataImpl implements PMetaData { @Override public int size() { return metaData.size(); } PMetaDataImpl(int initialCapacity, ReadOnlyProps props);  PMetaDataImpl(int initialCapacity, TimeKeeper timeKeeper, ReadOnlyProps props); private  PMetaDataImpl(PMetaDataCache metaData, TimeKeeper timeKeeper, PTableRefFactory tableRefFactory); }
PMetaDataImpl implements PMetaData { @Override public int size() { return metaData.size(); } PMetaDataImpl(int initialCapacity, ReadOnlyProps props);  PMetaDataImpl(int initialCapacity, TimeKeeper timeKeeper, ReadOnlyProps props); private  PMetaDataImpl(PMetaDataCache metaData, TimeKeeper timeKeeper, PTableRefFactory tableRefFactory); @Override PMetaDataImpl clone(); @Override PTableRef getTableRef(PTableKey key); @Override PFunction getFunction(PTableKey key); @Override int size(); @Override void updateResolvedTimestamp(PTable table, long resolvedTimestamp); @Override void addTable(PTable table, long resolvedTime); @Override void removeTable(PName tenantId, String tableName, String parentTableName, long tableTimeStamp); @Override void removeColumn(PName tenantId, String tableName, List<PColumn> columnsToRemove, long tableTimeStamp, long tableSeqNum, long resolvedTime); @Override void pruneTables(Pruner pruner); @Override Iterator<PTable> iterator(); @Override void addFunction(PFunction function); @Override void removeFunction(PName tenantId, String function, long functionTimeStamp); @Override void pruneFunctions(Pruner pruner); @Override long getAge(PTableRef ref); @Override void addSchema(PSchema schema); @Override PSchema getSchema(PTableKey key); @Override void removeSchema(PSchema schema, long schemaTimeStamp); }
PMetaDataImpl implements PMetaData { @Override public int size() { return metaData.size(); } PMetaDataImpl(int initialCapacity, ReadOnlyProps props);  PMetaDataImpl(int initialCapacity, TimeKeeper timeKeeper, ReadOnlyProps props); private  PMetaDataImpl(PMetaDataCache metaData, TimeKeeper timeKeeper, PTableRefFactory tableRefFactory); @Override PMetaDataImpl clone(); @Override PTableRef getTableRef(PTableKey key); @Override PFunction getFunction(PTableKey key); @Override int size(); @Override void updateResolvedTimestamp(PTable table, long resolvedTimestamp); @Override void addTable(PTable table, long resolvedTime); @Override void removeTable(PName tenantId, String tableName, String parentTableName, long tableTimeStamp); @Override void removeColumn(PName tenantId, String tableName, List<PColumn> columnsToRemove, long tableTimeStamp, long tableSeqNum, long resolvedTime); @Override void pruneTables(Pruner pruner); @Override Iterator<PTable> iterator(); @Override void addFunction(PFunction function); @Override void removeFunction(PName tenantId, String function, long functionTimeStamp); @Override void pruneFunctions(Pruner pruner); @Override long getAge(PTableRef ref); @Override void addSchema(PSchema schema); @Override PSchema getSchema(PTableKey key); @Override void removeSchema(PSchema schema, long schemaTimeStamp);  }