@Override public int getCollectionCount(String dbCollectionName) { return delegate.getCollectionCount(dbCollectionName); }
@Test public void testCollectionCount() { IMetadataService metaService = repositoryService.getRepository(repoName).getMetadataService(); int count = metaService.getCollectionCount("Environment"); Assert.assertEquals(0, count); }
private int calculateFullTableScanCost(MetaClass metaClass, int cost) { if (!metaClass.isEmbed() && QueryCostEnum.isFullTableScan(cost)) { if (metaClass.isAllowFullTableScan()) { return QueryCostEnum.AllowFullTableScan.getValue(); } PersistenceContext pctxt = context.getPersistenceContext(metaClass); IMetadataService msvc = context.getMetadataService(metaClass.getRepository()); String collectionName = pctxt.getDBCollectionName(metaClass); int docCnt = msvc.getCollectionCount(collectionName); if (docCnt < context.getSmallTableThreshold()) { return QueryCostEnum.AllowFullTableScan.getValue(); } } return cost; }
@Test public void testCollectionCount() { PersistenceContext pContext = newPersistenceContext(raptorMetaService); MetaClass depClass = new MetaClass(); depClass.setName("Dep"); MetaClass roomClass = new MetaClass(); roomClass.setName("Room"); int depCount = raptorMetaService.getCollectionCount(pContext.getDBCollectionName(depClass)); int roomCount = raptorMetaService.getCollectionCount(pContext.getDBCollectionName(roomClass)); Assert.assertEquals(13, depCount); Assert.assertEquals(9, roomCount); EntityContext context = newEntityContext(); IEntity qEntity = buildQueryEntity(RAPTOR_REPO, RAPTOR_MAIN_BRANCH_ID, "Room", "room06"); entityService.delete(qEntity, context); try { TimeUnit.SECONDS.sleep(1); } catch (InterruptedException e) { ; } roomCount = raptorMetaService.getCollectionCount(pContext.getDBCollectionName(roomClass)); Assert.assertEquals(9, roomCount); // cache }