List of usage examples for java.util Set clear
void clear();
From source file:ca.uhn.fhir.rest.server.RestfulServerUtils.java
public static Set<String> parseAcceptHeaderAndReturnHighestRankedOptions(HttpServletRequest theRequest) { Set<String> retVal = new HashSet<String>(); Enumeration<String> acceptValues = theRequest.getHeaders(Constants.HEADER_ACCEPT); if (acceptValues != null) { float bestQ = -1f; while (acceptValues.hasMoreElements()) { String nextAcceptHeaderValue = acceptValues.nextElement(); Matcher m = ACCEPT_HEADER_PATTERN.matcher(nextAcceptHeaderValue); float q = 1.0f; while (m.find()) { String contentTypeGroup = m.group(1); if (isNotBlank(contentTypeGroup)) { String name = m.group(3); String value = m.group(4); if (name != null && value != null) { if ("q".equals(name)) { try { q = Float.parseFloat(value); q = Math.max(q, 0.0f); } catch (NumberFormatException e) { ourLog.debug("Invalid Accept header q value: {}", value); }// w w w . j a va2s .c om } } if (q > bestQ) { retVal.clear(); bestQ = q; } if (q == bestQ) { retVal.add(contentTypeGroup.trim()); } } if (!",".equals(m.group(5))) { break; } } } } return retVal; }
From source file:edu.emory.library.tast.images.admin.ImagesBean.java
public String saveImage() { Session sess = null;//w ww .j av a 2 s . c o m Transaction transaction = null; try { // open db sess = HibernateConn.getSession(); transaction = sess.beginTransaction(); // load image Image image = null; if (selectedImageId != null) { image = Image.loadById(Integer.parseInt(selectedImageId), sess); } else { image = new Image(); } // basic image metadata image.setTitle(imageTitle); image.setSource(imageSource); image.setCreator(imageCreator); image.setReferences(imageReferences); image.setEmoryLocation(imageEmoryLocation); image.setExternalId(imageExternalId); // we will use it often Configuration appConf = AppConfig.getConfiguration(); // image properties image.setWidth(imageWidth); image.setHeight(imageHeight); image.setSize(imageSize); image.setFileName(imageFileName); image.setMimeType(imageMimeType); // title String titleLocal = checkTextField(image.getTitle(), "title", appConf.getInt(AppConfig.IMAGES_TITLE_MAXLEN), false); image.setTitle(titleLocal); // description image.setDescription(imageDescription); // category ImageCategory cat = ImageCategory.loadById(sess, imageCategoryId); image.setCategory(cat); // check source String sourceLocal = checkTextField(image.getSource(), "source", appConf.getInt(AppConfig.IMAGES_SOURCE_MAXLEN), true); image.setSource(sourceLocal); // date image.setDate(imageDate); // check creator String creatorLocal = checkTextField(image.getCreator(), "creator", appConf.getInt(AppConfig.IMAGES_CREATOR_MAXLEN), true); image.setCreator(creatorLocal); // language image.setLanguage(imageLanguage); // comments image.setComments(imageComments); // check references String referencesLocal = checkTextField(image.getReferences(), "references", appConf.getInt(AppConfig.IMAGES_REFERENCES_MAXLEN), true); image.setReferences(referencesLocal); // is at Emory image.setEmory(imageEmory); // check emory location String emoryLocationLocal = checkTextField(image.getEmoryLocation(), "Emory location", appConf.getInt(AppConfig.IMAGES_EMORYLOCATION_MAXLEN), true); image.setEmoryLocation(emoryLocationLocal); // authorization status image.setAuthorizationStatus(imageAuthorizationStatus); // image status image.setImageStatus(imageImageStatus); // image ready to go image.setReadyToGo(imageReadyToGo); // links to regions (not shown now) Set imageRegions = new HashSet(); image.setRegions(imageRegions); for (int i = 0; i < selectedRegionsIds.length; i++) { int regionId = Integer.parseInt(selectedRegionsIds[i]); Region dbRegion = Region.loadById(sess, regionId); imageRegions.add(dbRegion); } // links to ports (not shown now) Set imagePorts = new HashSet(); image.setPorts(imagePorts); for (int i = 0; i < selectedPortsIds.length; i++) { int portId = Integer.parseInt(selectedPortsIds[i]); Port dbPort = Port.loadById(sess, portId); imagePorts.add(dbPort); } // links to voyages Integer[] newVoyageIds; try { newVoyageIds = StringUtils .parseIntegerArray(StringUtils.splitByLinesAndRemoveEmpty(imageVoyageIds)); } catch (NumberFormatException nfe) { throw new SaveImageException("All linked voyage IDs have to be integers."); } Set voyageIds = image.getVoyageIds(); voyageIds.clear(); Collections.addAll(voyageIds, newVoyageIds); // save sess.saveOrUpdate(image); // commit transaction.commit(); sess.close(); return "list"; } catch (SaveImageException se) { if (transaction != null) transaction.rollback(); if (sess != null) sess.close(); setErrorText(se.getMessage()); return null; } catch (DataException de) { if (transaction != null) transaction.rollback(); if (sess != null) sess.close(); setErrorText("Internal problem with database. Sorry for the inconvenience."); return null; } }
From source file:cn.future.ssh.service.impl.AccreditationServiceImpl.java
public void saveDocument(Accreditation accreditation, AccreditationBean accreditationBean, String methodName, List<String> allowType, File imagesSavedir) { //??/*w w w. j a v a2 s .c o m*/ String filesMethodStr = "get" + methodName; String fileNameMethodStr = "get" + methodName + "FileName"; String contentTypeMethodStr = "get" + methodName + "ContentType"; Class accreditationBeanClass = accreditationBean.getClass(); Method filesMethod = null; Method fileNameMethod = null; Method contentTypeMethod = null; List<File> files = null; List<String> fileNames = null; List<String> contentTypes = null; try { filesMethod = accreditationBeanClass.getDeclaredMethod(filesMethodStr); fileNameMethod = accreditationBeanClass.getDeclaredMethod(fileNameMethodStr); contentTypeMethod = accreditationBeanClass.getDeclaredMethod(contentTypeMethodStr); files = (List<File>) filesMethod.invoke(accreditationBean); fileNames = (List<String>) fileNameMethod.invoke(accreditationBean); contentTypes = (List<String>) contentTypeMethod.invoke(accreditationBean); } catch (Exception e) { e.printStackTrace(); } //HashMap<String,String> map = new HashMap<String,String>(); List<Document> documents = new ArrayList<Document>(); List<String> imageNames = new ArrayList<String>(); if (files != null) { for (int i = 0; i < files.size(); i++) { //map.put(fileNames.get(i), contentTypes.get(i)); imageNames.add(fileNames.get(i)); } int i = 0; for (String key : fileNames) { String ext = key.substring(key.lastIndexOf(".")); Document document = new Document(); String imageName = UUID.randomUUID().toString() + ext; document.setImageName(imageName); document.setAccreditation(accreditation); //?id documentService.saveDocument(document); File outputDir = new File(imagesSavedir, imageName); try { FileOutputStream os = new FileOutputStream(outputDir); FileInputStream is = new FileInputStream(files.get(i)); int length; byte[] buffer = new byte[1024 * 1024]; while ((length = is.read(buffer)) > 0) { os.write(buffer, 0, length); } os.close(); is.close(); } catch (Exception e) { e.printStackTrace(); } documents.add(document); i++;// } //??????? if (documents.size() > 0) { Class accreditationClass = accreditation.getClass(); try { Method m = accreditationClass.getDeclaredMethod(filesMethodStr); Set<Document> documents2 = (Set<Document>) m.invoke(accreditation); documents2.clear(); documents2.addAll(documents); /*String flagMethodStr = "set"+methodName+"Flag"; Method flagMethod = accreditationClass.getDeclaredMethod(flagMethodStr,Boolean.class); flagMethod.invoke(accreditation,true);*/ } catch (Exception e) { e.printStackTrace(); } documents.clear(); } } }
From source file:fr.mcc.ginco.services.ConceptHierarchicalRelationshipServiceUtil.java
private void getRoot(ThesaurusConcept concept, Integer iteration, ThesaurusConcept start, Map<String, Integer> path, Set<ThesaurusConcept> roots) { iteration++;/*from ww w . j a v a2 s . c om*/ Set<ThesaurusConcept> directParents = concept.getParentConcepts(); if (directParents.isEmpty()) { if (iteration != 1) { roots.add(concept); } return; } boolean flag = false; Set<ThesaurusConcept> stack = new HashSet<ThesaurusConcept>(); for (ThesaurusConcept directParent : directParents) { if (directParent == null || path.containsKey(directParent.getIdentifier())) { continue; } else { path.put(directParent.getIdentifier(), iteration); stack.add(directParent); flag = true; } } // HACK to deal with cyclic dependencies. Should be reThink in some // time... if (!flag && directParents.size() == 1 && directParents.contains(start)) { roots.add(concept); } if (!stack.isEmpty()) { for (ThesaurusConcept toVisit : stack) { getRoot(toVisit, iteration, start, path, roots); } stack.clear(); } }
From source file:org.drftpd.protocol.speedtest.net.slave.SpeedTestHandler.java
private float getDownloadSpeed(String url) { long totalTime = 0L; long totalBytes = 0L; long startTime = System.currentTimeMillis(); RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(60000).setConnectTimeout(5000) .setConnectionRequestTimeout(5000).build(); HttpGet httpGet = new HttpGet(); httpGet.setConfig(requestConfig);//from ww w . j a v a2s . c o m SpeedTestCallable[] speedTestCallables = new SpeedTestCallable[_downThreads]; for (int i = 0; i < _downThreads; i++) { speedTestCallables[i] = new SpeedTestCallable(); } ExecutorService executor = Executors.newFixedThreadPool(_downThreads); List<Future<Long>> threadList; Set<Callable<Long>> callables = new HashSet<Callable<Long>>(); url = url.substring(0, url.lastIndexOf('/') + 1) + "random"; StopWatch watch = new StopWatch(); for (int size : _sizes) { // Measure dl speed for each size in _sizes if ((System.currentTimeMillis() - startTime) > _downTime) { break; } String tmpURL = url + size + "x" + size + ".jpg"; try { httpGet.setURI(new URI(tmpURL)); } catch (URISyntaxException e) { logger.error("URI syntax error for " + tmpURL + " :: " + e.getMessage()); close(executor, callables); return 0; } callables.clear(); for (int k = 0; k < _downThreads; k++) { speedTestCallables[k].setHttpGet(httpGet); callables.add(speedTestCallables[k]); } for (int j = 0; j < _sizeLoop; j++) { try { watch.reset(); Thread.sleep(_sleep); watch.start(); threadList = executor.invokeAll(callables); for (Future<Long> fut : threadList) { Long bytes = fut.get(); totalBytes += bytes; } watch.stop(); totalTime += watch.getTime(); } catch (InterruptedException e) { logger.error(e.getMessage()); close(executor, callables); return 0; } catch (ExecutionException e) { logger.error(e.getMessage()); close(executor, callables); return 0; } if ((System.currentTimeMillis() - startTime) > _downTime) { break; } } } if (totalBytes == 0L || totalTime == 0L) { close(executor, callables); return 0; } close(executor, callables); return (float) (((totalBytes * 8) / totalTime) * 1000) / 1000000; }
From source file:ca.uhn.fhir.context.ModelScanner.java
private void init(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theExistingDefinitions, Set<Class<? extends IBase>> theTypesToScan) { if (theExistingDefinitions != null) { myClassToElementDefinitions.putAll(theExistingDefinitions); }/*from w w w . j av a 2 s. c o m*/ int startSize = myClassToElementDefinitions.size(); long start = System.currentTimeMillis(); Map<String, Class<? extends IBaseResource>> resourceTypes = myNameToResourceType; Set<Class<? extends IBase>> typesToScan = theTypesToScan; myVersionTypes = scanVersionPropertyFile(typesToScan, resourceTypes, myVersion, myClassToElementDefinitions); do { for (Class<? extends IBase> nextClass : typesToScan) { scan(nextClass); } for (Iterator<Class<? extends IBase>> iter = myScanAlso.iterator(); iter.hasNext();) { if (myClassToElementDefinitions.containsKey(iter.next())) { iter.remove(); } } typesToScan.clear(); typesToScan.addAll(myScanAlso); myScanAlso.clear(); } while (!typesToScan.isEmpty()); for (Entry<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> nextEntry : myClassToElementDefinitions .entrySet()) { if (theExistingDefinitions != null && theExistingDefinitions.containsKey(nextEntry.getKey())) { continue; } BaseRuntimeElementDefinition<?> next = nextEntry.getValue(); boolean deferredSeal = false; if (myContext.getPerformanceOptions().contains(PerformanceOptionsEnum.DEFERRED_MODEL_SCANNING)) { if (next instanceof BaseRuntimeElementCompositeDefinition) { deferredSeal = true; } } if (!deferredSeal) { next.sealAndInitialize(myContext, myClassToElementDefinitions); } } myRuntimeChildUndeclaredExtensionDefinition = new RuntimeChildUndeclaredExtensionDefinition(); myRuntimeChildUndeclaredExtensionDefinition.sealAndInitialize(myContext, myClassToElementDefinitions); long time = System.currentTimeMillis() - start; int size = myClassToElementDefinitions.size() - startSize; ourLog.debug("Done scanning FHIR library, found {} model entries in {}ms", size, time); }
From source file:functionaltests.RestSchedulerJobPaginationTest.java
private void checkJobIds(boolean indexAndRange, int index, int limit, String... expectedIds) throws Exception { JSONObject page;//ww w .j av a 2s .c o m JSONArray jobs; Set<String> expected = new HashSet<>(Arrays.asList(expectedIds)); Set<String> actual = new HashSet<>(); String url; // test 'jobs' request if (indexAndRange) { url = getResourceUrl("jobs?index=" + index + "&limit=" + limit); } else { url = getResourceUrl("jobs"); } page = getRequestJSONObject(url); jobs = (JSONArray) page.get("list"); for (int i = 0; i < jobs.size(); i++) { actual.add((String) jobs.get(i)); } Assert.assertEquals("Unexpected result of 'jobs' request (" + url + ")", expected, actual); // test 'jobsinfo' request if (indexAndRange) { url = getResourceUrl("jobsinfo?index=" + index + "&limit=" + limit); } else { url = getResourceUrl("jobsinfo"); } page = getRequestJSONObject(url); jobs = (JSONArray) page.get("list"); actual.clear(); for (int i = 0; i < jobs.size(); i++) { JSONObject job = (JSONObject) jobs.get(i); actual.add((String) job.get("jobid")); } Assert.assertEquals("Unexpected result of 'jobsinfo' request (" + url + ")", expected, actual); // test 'revisionjobsinfo' request if (indexAndRange) { url = getResourceUrl("revisionjobsinfo?index=" + index + "&limit=" + limit); } else { url = getResourceUrl("revisionjobsinfo"); } checkRevisionJobsInfo(url, expectedIds); }
From source file:org.apache.syncope.core.provisioning.java.propagation.PriorityPropagationTaskExecutor.java
@Override protected void doExecute(final Collection<PropagationTask> tasks, final PropagationReporter reporter, final boolean nullPriorityAsync) { List<PropagationTask> prioritizedTasks = CollectionUtils.select(tasks, new Predicate<PropagationTask>() { @Override//from w ww. ja v a2 s . com public boolean evaluate(final PropagationTask task) { return task.getResource().getPropagationPriority() != null; } }, new ArrayList<PropagationTask>()); Collections.sort(prioritizedTasks, new PriorityComparator()); LOG.debug("Propagation tasks sorted by priority, for serial execution: {}", prioritizedTasks); Collection<PropagationTask> concurrentTasks = CollectionUtils.subtract(tasks, prioritizedTasks); LOG.debug("Propagation tasks for concurrent execution: {}", concurrentTasks); // first process priority resources sequentially and fail as soon as any propagation failure is reported for (PropagationTask task : prioritizedTasks) { TaskExec execution = null; PropagationTaskExecStatus execStatus; try { execution = newPropagationTaskCallable(task, reporter).call(); execStatus = PropagationTaskExecStatus.valueOf(execution.getStatus()); } catch (Exception e) { LOG.error("Unexpected exception", e); execStatus = PropagationTaskExecStatus.FAILURE; } if (execStatus != PropagationTaskExecStatus.SUCCESS) { throw new PropagationException(task.getResource().getKey(), execution == null ? null : execution.getMessage()); } } // then process non-priority resources concurrently... final CompletionService<TaskExec> completionService = new ExecutorCompletionService<>(executor); Map<PropagationTask, Future<TaskExec>> nullPriority = new HashMap<>(concurrentTasks.size()); for (PropagationTask task : concurrentTasks) { try { nullPriority.put(task, completionService.submit(newPropagationTaskCallable(task, reporter))); } catch (Exception e) { LOG.error("Unexpected exception", e); } } // ...waiting for all callables to complete, if async processing was not required if (!nullPriority.isEmpty()) { if (nullPriorityAsync) { for (Map.Entry<PropagationTask, Future<TaskExec>> entry : nullPriority.entrySet()) { reporter.onSuccessOrNonPriorityResourceFailures(entry.getKey(), PropagationTaskExecStatus.CREATED, null, null, null); } } else { final Set<Future<TaskExec>> nullPriorityFutures = new HashSet<>(nullPriority.values()); try { executor.submit(new Runnable() { @Override public void run() { while (!nullPriorityFutures.isEmpty()) { try { nullPriorityFutures.remove(completionService.take()); } catch (Exception e) { LOG.error("Unexpected exception", e); } } } }).get(60, TimeUnit.SECONDS); } catch (Exception e) { LOG.error("Unexpected exception", e); } finally { for (Future<TaskExec> future : nullPriorityFutures) { future.cancel(true); } nullPriorityFutures.clear(); nullPriority.clear(); } } } }
From source file:com.jaeksoft.searchlib.crawler.web.database.UrlManager.java
public long updateSiteMap(TaskLog taskLog) throws SearchLibException { setCurrentTaskLog(taskLog);//from w w w . j a v a2 s .co m HttpDownloader httpDownloader = null; try { AbstractSearchRequest request = (AbstractSearchRequest) dbClient .getNewRequest(SearchTemplate.urlSearch.name()); long inserted = 0; long existing = 0; long setToFetchFirst = 0; int everyTen = 0; targetClient.getSiteMapList(); httpDownloader = targetClient.getWebCrawlMaster().getNewHttpDownloader(true); Set<SiteMapUrl> siteMapUrlSet = new HashSet<SiteMapUrl>(0); List<UrlItem> urlItemList = new ArrayList<UrlItem>(0); long now = System.currentTimeMillis(); for (SiteMapItem siteMapItem : targetClient.getSiteMapList().getArray()) { taskLog.setInfo("Loading " + siteMapItem.getUri()); siteMapUrlSet.clear(); urlItemList.clear(); siteMapItem.load(httpDownloader, siteMapUrlSet); for (SiteMapUrl siteMapUrl : siteMapUrlSet) { UrlItem urlItem = getUrl(request, siteMapUrl.getLoc().toString()); if (urlItem == null) { urlItemList.add(getNewUrlItem(siteMapUrl)); inserted++; } else { existing++; long timeDistanceMs = now - urlItem.getWhen().getTime(); FetchStatus fetchStatus = urlItem.getFetchStatus(); if (fetchStatus == FetchStatus.UN_FETCHED || (fetchStatus == FetchStatus.FETCHED && siteMapUrl.getChangeFreq().needUpdate(timeDistanceMs))) { if (fetchStatus != FetchStatus.FETCH_FIRST) { urlItem.setFetchStatus(FetchStatus.FETCH_FIRST); urlItemList.add(urlItem); setToFetchFirst++; } } } if (everyTen == 10) { if (taskLog.isAbortRequested()) throw new SearchLibException.AbortException(); everyTen = 0; taskLog.setInfo(inserted + "/" + existing + " URL(s) inserted/existing"); } else everyTen++; } if (urlItemList.size() > 0) updateUrlItems(urlItemList); } taskLog.setInfo( inserted + "/" + existing + "/" + setToFetchFirst + " URL(s) inserted/existing/fetchFirst"); Logging.info(taskLog.getInfo()); return inserted + existing; } finally { if (httpDownloader != null) httpDownloader.release(); resetCurrentTaskLog(); } }
From source file:no.sintef.ict.splcatool.CoveringArrayAlgICPL.java
private void generate3(int coverLimit, Integer sizelimit) throws TimeoutException, org.sat4j.specs.TimeoutException { // Get a list of vars List<BooleanVariableInterface> vars = new ArrayList<BooleanVariableInterface>(cnf.getFocusVariables()); // Get invalid 2-tuples generate2(100, sizelimit);//from w w w .j a v a2 s . c o m // 3-wise System.out.println("--- 3-wise ---"); // Set of invalid 3-tuples invalid3w = new HashSet<Pair3>(); // Solutions List<List<Integer>> solutions = new ArrayList<List<Integer>>(initial); int coveredInitially = 0; /* Calculate uncovered tuples */ long invalid = 0; long ignored = 0; List<Pair3> uncovered = new ArrayList<Pair3>(); { int f = vars.size(); long total = MathUtils.binomialCoefficient(f, 3); if (coverOnlyOnes) { } else if (!coverZerosOnly) { total *= (2 * 2 * 2 - 1); } else if (firstHalfOnly || secondHalfOnly) { total *= 4; } else if (firstFourthOnly || thirdFourthOnly) { total *= 2; } else if (coverEight != 0) { } else { total *= 2 * 2 * 2; } int threads = Runtime.getRuntime().availableProcessors(); List<CalcUncovered3Thread> cuts = new ArrayList<CalcUncovered3Thread>(); for (int i = 0; i < threads; i++) { int begin = i * vars.size() / threads; int end = ((i + 1) * vars.size() / threads); CalcUncovered3Thread cut = new CalcUncovered3Thread(begin, end, vars, coverOnlyOnes, coverZerosOnly, invalid2w, idnr, solutions, new HashSet<Pair3>(), firstHalfOnly, secondHalfOnly, firstFourthOnly, thirdFourthOnly, coverEight); cuts.add(cut); } List<Thread> cutts = new ArrayList<Thread>(); for (int i = 0; i < threads; i++) { cutts.add(new Thread(cuts.get(i))); } // Start threads for (int i = 0; i < threads; i++) { cutts.get(i).start(); } // Monitor progress List<ProgressReporter> xprs = new ArrayList<ProgressReporter>(); xprs.addAll(cuts); ProgressThread xpt = new ProgressThread("Calculate uncovered triples", xprs, total); Thread xptt = new Thread(xpt); xptt.start(); // Wait for (int i = 0; i < threads; i++) { try { cutts.get(i).join(); } catch (InterruptedException e1) { } } // Stop monitoring xpt.stop(); // Gather for (int i = 0; i < threads; i++) { invalid += cuts.get(i).getInvalidCount(); uncovered.addAll(cuts.get(i).getUncovered()); invalid3w.addAll(cuts.get(i).getInvalid()); } } // Done System.out.println( "Uncovered triples left: " + uncovered.size() + " invalid: " + invalid + " ignored: " + ignored); // Cover long grandTotal = uncovered.size() + invalid; boolean invalidRemoved = false; int oldcovered = uncovered.size(); while (!uncovered.isEmpty()) { List<List<Integer>> sols = new ArrayList<List<Integer>>(); int uncTotal = coveredInitially + uncovered.size(); // Start threads { List<Pair3> uncSplit = new ArrayList<Pair3>(); for (int i = 0; i < uncovered.size(); i++) { uncSplit.add(uncovered.get(i)); } uncovered.clear(); C3SplitThread fmt = new C3SplitThread(cnf, uncSplit, idnr); Thread t = new Thread(fmt); t.start(); // Start monitoring thread List<C3SplitThread> fmts = new ArrayList<C3SplitThread>(); fmts.add(fmt); List<ProgressReporter> prs = new ArrayList<ProgressReporter>(fmts); ProgressThread pt = new ProgressThread("Cover triples", prs, uncTotal); Thread ptt = new Thread(pt); ptt.start(); // Wait for thread to finish try { t.join(); } catch (InterruptedException e) { } // Stop monitoring pt.stop(); // Round complete System.out.println("Round complete"); uncovered.addAll(fmt.getUncovered()); sols.addAll(fmt.getSolutions()); if (saveAfterEachRound) { try { solutions.addAll(sols); result = solutions; writeToFile(tmp_save_filename, Type.horizontal, tmpSave_hideUnderscoreVariables); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } // Remove covered int newcovered; Set<Pair3> cov; { cov = getCovInv3(sols, uncovered); System.out.println("Additionally covered " + cov.size()); newcovered = uncovered.size(); Set<Pair3> uncovSet = new HashSet<Pair3>(uncovered); uncovered.clear(); uncovSet.removeAll(cov); uncovered.addAll(uncovSet); uncovSet.clear(); } newcovered = newcovered - uncovered.size(); // Remove invalid at some round if (!invalidRemoved) { if ((int) Math.log10(cov.size()) <= (int) Math.log10(cnf.getFocusVariables().size())) { System.out.println("Removing invalid"); int diff = uncovered.size(); uncovered = getInvalid3(coveredInitially, uncovered); diff -= uncovered.size(); uncTotal -= diff; System.out.println("Invalid: " + diff); invalidRemoved = true; } } // Store solutions.addAll(sols); // Report progress System.out.println("Uncovered: " + uncovered.size() + ", progress: " + (grandTotal - uncovered.size()) * 100 / grandTotal + "% with solutions: " + solutions.size()); // Stop at limit if (coverLimit <= (grandTotal - uncovered.size()) * 100 / grandTotal) break; // Stop at limit if (solutions.size() >= sizelimit) break; // Done if no more covered if (oldcovered == uncovered.size()) { System.out.println("Unable to cover valid tuples: " + uncovered.size()); System.exit(-1); } oldcovered = uncovered.size(); } result = solutions; }