DistinctDataNet extends DistinctDataBag<E> { @Override protected List<File> getSpillFiles() { List<File> toReturn = new ArrayList<>(super.getSpillFiles()); if (null != firstSpillFile) { toReturn.add(firstSpillFile); } return toReturn; } DistinctDataNet(ThresholdPolicy<E> policy, SerializationFactory<E> serializerFactory, Comparator<E> comparator); boolean netAdd(E item); Iterator<E> netIterator();  }
@Test public void testTemporaryFilesAreCleanedUpAfterCompletion() { List<Binding> undistinct = new ArrayList<>(); random = new Random(); Var[] vars = new Var[]{ Var.alloc("1"), Var.alloc("2"), Var.alloc("3"), Var.alloc("4"), Var.alloc("5"), Var.alloc("6"), Var.alloc("7"), Var.alloc("8"), Var.alloc("9"), Var.alloc("0") }; for(int i = 0; i < 500; i++){ undistinct.add(randomBinding(vars)); } DistinctDataNet<Binding> db = new DistinctDataNet<>( new ThresholdPolicyCount<Binding>(10), SerializationFactoryFinder.bindingSerializationFactory(), new BindingComparator(new ArrayList<SortCondition>())); List<File> spillFiles = new ArrayList<>(); try { db.addAll(undistinct); spillFiles.addAll(db.getSpillFiles()); int count = 0; for (File file : spillFiles) { if (file.exists()) { count++; } } assertEquals(49, count); Iterator<Binding> iter = db.iterator(); while (iter.hasNext()) { iter.next(); } Iter.close(iter); } finally { db.close(); } int count = 0; for (File file : spillFiles) { if (file.exists()) { count++; } } assertEquals(0, count); }