[Debtags-commits] [svn] r1765 - in tagcoll/2.0: . bench tagcoll tagcoll/coll tagcoll/experimental tagcoll/tests tools

Enrico Zini enrico at costa.debian.org
Thu May 11 02:45:34 UTC 2006


Author: enrico
Date: Thu May 11 02:44:47 2006
New Revision: 1765

Added:
   tagcoll/2.0/tagcoll/coll/patched.tcc
   tagcoll/2.0/tagcoll/experimental/
   tagcoll/2.0/tagcoll/experimental/CardinalityStore.cc
   tagcoll/2.0/tagcoll/experimental/CardinalityStore.h
   tagcoll/2.0/tagcoll/experimental/experiments.cc
   tagcoll/2.0/tagcoll/experimental/experiments.h
   tagcoll/2.0/tagcoll/tests/test-utils.tcc
Removed:
   tagcoll/2.0/tagcoll/CardinalityStore.cc
   tagcoll/2.0/tagcoll/CardinalityStore.h
   tagcoll/2.0/tagcoll/experiments.cc
   tagcoll/2.0/tagcoll/experiments.h
   tagcoll/2.0/tagcoll/test-utils.tcc
   tagcoll/2.0/tagcoll/tests/Makefile.am
Modified:
   tagcoll/2.0/   (props changed)
   tagcoll/2.0/bench/collection.cc
   tagcoll/2.0/configure.ac
   tagcoll/2.0/tagcoll/DerivedTags.cc
   tagcoll/2.0/tagcoll/Makefile.am
   tagcoll/2.0/tagcoll/coll/fast.cc
   tagcoll/2.0/tagcoll/coll/intdiskindex.cc
   tagcoll/2.0/tagcoll/coll/patched.cc
   tagcoll/2.0/tagcoll/coll/simple.cc
   tagcoll/2.0/tools/tagcoll.cc
Log:
 r2700 at viaza:  enrico | 2006-05-10 18:57:48 -0500
 Reorganized tests so that test-only .cc files are not included in libtagcoll


Modified: tagcoll/2.0/bench/collection.cc
==============================================================================
--- tagcoll/2.0/bench/collection.cc	(original)
+++ tagcoll/2.0/bench/collection.cc	Thu May 11 02:44:47 2006
@@ -1,10 +1,11 @@
 #include <bench/Benchmark.h>
 #include <tagcoll/TextFormat.h>
-//#include <tagcoll/BasicStringDiskIndex.h>
 #include <tagcoll/stream/sink.h>
 #include <tagcoll/coll/simple.h>
 #include <tagcoll/coll/fast.h>
+#include <tagcoll/coll/patched.h>
 //#include <tagcoll/CardinalityStore.h>
+//#include <tagcoll/BasicStringDiskIndex.h>
 
 #include <vector>
 #include <iostream>
@@ -320,6 +321,52 @@
 	benchFast() : CollectionBench("Fast") {}
 };
 
+class benchPatchedOverhead : public CollectionBench
+{
+protected:
+	virtual void main()
+	{
+		Timer main = mktimer("total");
+		coll::Fast<string, string> subcoll;
+		coll::Patched< coll::Fast<string, string> > coll(subcoll);
+
+		Timer t1 = mktimer("indexing collection");
+		outputROCollection(inserter(subcoll));
+		t1.done();
+			
+		{
+			Timer t = mktimer("read only collection");
+			benchROCollection(coll);
+		}
+	}
+
+public:
+	benchPatchedOverhead() : CollectionBench("PatchedOverhead") {}
+};
+
+class benchPatched : public CollectionBench
+{
+protected:
+	virtual void main()
+	{
+		Timer main = mktimer("total");
+		coll::Fast<string, string> subcoll;
+		coll::Patched< coll::Fast<string, string> > coll(subcoll);
+
+		Timer t1 = mktimer("indexing collection");
+		outputROCollection(inserter(coll));
+		t1.done();
+			
+		{
+			Timer t = mktimer("read only collection");
+			benchROCollection(coll);
+		}
+	}
+
+public:
+	benchPatched() : CollectionBench("Patched") {}
+};
+
 #if 0
 class benchCardinalityStore : public CollectionBench
 {
@@ -353,6 +400,8 @@
 		//addChild(new benchBasicStringDiskIndex());
 		//addChild(new benchTDBReadonlyDiskIndex());
 		addChild(new benchFast());
+		addChild(new benchPatchedOverhead());
+		//addChild(new benchPatched());
 		//addChild(new benchCardinalityStore());
 	}
 };
@@ -362,5 +411,8 @@
 }
 
 #include <tagcoll/coll/simple.tcc>
+#include <tagcoll/coll/fast.tcc>
+#include <tagcoll/coll/patched.tcc>
+#include <tagcoll/Patches.tcc>
 
 /* vim:set ts=4 sw=4: */

Modified: tagcoll/2.0/configure.ac
==============================================================================
--- tagcoll/2.0/configure.ac	(original)
+++ tagcoll/2.0/configure.ac	Thu May 11 02:44:47 2006
@@ -27,6 +27,7 @@
 AM_PROG_CC_STDC
 AC_HEADER_STDC
 
+AM_PROG_CC_C_O
 AM_PROG_LEX
 AC_PROG_YACC
 
@@ -60,7 +61,6 @@
 Makefile
 tagcoll/Makefile
 tagcoll/tagexpr/Makefile
-tagcoll/tests/Makefile
 bench/Makefile
 doc/Makefile
 tools/Makefile

Modified: tagcoll/2.0/tagcoll/DerivedTags.cc
==============================================================================
--- tagcoll/2.0/tagcoll/DerivedTags.cc	(original)
+++ tagcoll/2.0/tagcoll/DerivedTags.cc	Thu May 11 02:44:47 2006
@@ -101,7 +101,7 @@
 }
 
 #include <tagcoll/TextFormat.tcc>
-#include <tagcoll/test-utils.tcc>
+#include <tagcoll/tests/test-utils.tcc>
 
 #endif
 

Modified: tagcoll/2.0/tagcoll/Makefile.am
==============================================================================
--- tagcoll/2.0/tagcoll/Makefile.am	(original)
+++ tagcoll/2.0/tagcoll/Makefile.am	Thu May 11 02:44:47 2006
@@ -1,10 +1,9 @@
 ## Process this file with automake to produce Makefile.in
 
-SUBDIRS = tagexpr . tests
+SUBDIRS = tagexpr .
 
 tagcollincludedir = $(includedir)/tagcoll-$(VERSION)/tagcoll
 
-# Include the .cc files that contain template definitions
 tagcollinclude_HEADERS = \
 		utils/set.h \
 		\
@@ -32,7 +31,7 @@
 		coll/fast.h \
 		coll/fast.tcc \
 		coll/patched.h \
-		coll/patched.cc \
+		coll/patched.tcc \
 		coll/intdiskindex.h \
 		\
 		Patches.h \
@@ -46,11 +45,10 @@
 		DerivedTags.h \
 		\
 		SmartHierarchy.h \
-		SmartHierarchy.cc \
-		\
-		experiments.h
-
+		SmartHierarchy.cc
 
+# This library gets the non-template code
+# (and currently some tests)
 lib_LTLIBRARIES = libtagcoll.la
 libtagcoll_la_SOURCES = \
 		input/base.cc \
@@ -64,6 +62,19 @@
 		\
 		expression.cc \
 		\
+		coll/intdiskindex.cc \
+		\
+		TextFormat.cc \
+		\
+		SmartHierarchy.cc
+
+libtagcoll_la_LIBADD = tagexpr/libtagexpr.la
+libtagcoll_la_LDFLAGS = $(LIBWIBBLE_LIBS) -version-info @LIBTAGCOLL_VERSION_INFO@
+
+# Tests
+TESTS = tests/libtagcoll-test
+check_PROGRAMS = tests/libtagcoll-test
+tests_libtagcoll_test_SOURCES = \
 		stream/sink.cc \
 		stream/filters.cc \
 		stream/expression.cc \
@@ -73,23 +84,30 @@
 		coll/simple.cc \
 		coll/fast.cc \
 		coll/patched.cc \
-		coll/intdiskindex.cc \
 		\
 		Patches.cc \
-		\
-		TextFormat.cc \
-		\
 		Implications.cc \
 		DerivedTags.cc \
-		\
-		SmartHierarchy.cc
-
-#		CardinalityStore.cc \
-#		\
-#		experiments.cc
+		tests/tut-main.cpp
+# Disabled: it failed, but it also looks meaningless as it is
+# test-textformat.cc
+tests_libtagcoll_test_LDADD = -dlpreopen libtagcoll.la tagexpr/libtagexpr.la
+
+#noinst_PROGRAMS = normalize mkgraph
+# test-tagset
+
+#normalize_SOURCES = \
+#	normalize.cc
+#normalize_LDADD = ../libtagcoll.la
+
+#mkgraph_SOURCES = \
+#	mkgraph.cc
+#mkgraph_LDADD = ../libtagcoll.la
+
+#test_tagset_SOURCES = \
+	#test-tagset.cc
+#test_tagset_LDADD = ../tagcoll/libtagcoll.la
 
-libtagcoll_la_LIBADD = tagexpr/libtagexpr.la
-
-libtagcoll_la_LDFLAGS = $(LIBWIBBLE_LIBS) -version-info @LIBTAGCOLL_VERSION_INFO@
+EXTRA_DIST = test-utils.h test-utils.tcc
 
 INCLUDES = -I$(top_srcdir) -DCOMPILE_TESTSUITE $(LIBWIBBLE_DEFS)

Modified: tagcoll/2.0/tagcoll/coll/fast.cc
==============================================================================
--- tagcoll/2.0/tagcoll/coll/fast.cc	(original)
+++ tagcoll/2.0/tagcoll/coll/fast.cc	Thu May 11 02:44:47 2006
@@ -151,7 +151,7 @@
 }
 }
 
-#include <tagcoll/test-utils.tcc>
+#include <tagcoll/tests/test-utils.tcc>
 #include <tagcoll/coll/fast.tcc>
 #include <tagcoll/Patches.tcc>
 

Modified: tagcoll/2.0/tagcoll/coll/intdiskindex.cc
==============================================================================
--- tagcoll/2.0/tagcoll/coll/intdiskindex.cc	(original)
+++ tagcoll/2.0/tagcoll/coll/intdiskindex.cc	Thu May 11 02:44:47 2006
@@ -728,7 +728,7 @@
 }
 }
 
-#include <tagcoll/test-utils.tcc>
+#include <tagcoll/tests/test-utils.tcc>
 
 #endif
 // vim:set ts=4 sw=4:

Modified: tagcoll/2.0/tagcoll/coll/patched.cc
==============================================================================
--- tagcoll/2.0/tagcoll/coll/patched.cc	(original)
+++ tagcoll/2.0/tagcoll/coll/patched.cc	Thu May 11 02:44:47 2006
@@ -1,7 +1,7 @@
 /*
  * Wrap a Collection, preserving modifications as patches
  *
- * Copyright (C) 2005  Enrico Zini <enrico at debian.org>
+ * Copyright (C) 2005,2006  Enrico Zini <enrico at debian.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -18,196 +18,16 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include <tagcoll/coll/patched.h>
-
-#include <wibble/operators.h>
-#include <wibble/mixin.h>
-
-using namespace std;
-using namespace wibble::operators;
-
-namespace tagcoll {
-namespace coll {
-
-template<typename ROCOLL>
-typename coll_traits<ROCOLL>::itemset_type Patched<ROCOLL>::getItemsHavingTag(const Tag& tag) const
-{
-	ItemSet items(coll.getItemsHavingTag(tag));
-	ItemSet res;
-
-	// Check items in coll first
-	for (typename ItemSet::const_iterator i = items.begin(); i != items.end(); ++i)
-		// If they are unmodified, then we can trust coll.getItems
-		if (m_changes.find(*i) == m_changes.end())
-			res |= *i;
-
-	// Then check items in the patch
-	for (typename Patches::const_iterator i = m_changes.begin();
-			i != m_changes.end(); i++)
-		if (utils::set_contains(m_changes.patch(i->first, coll.getTagsOfItem(i->first)), tag))
-			res |= i->first;
-
-	return res;
-}
-
-template<typename ROCOLL>
-void Patched<ROCOLL>::setChanges(const Patches& changes)
-{
-	this->m_changes.clear();
-	
-	// Simplify the patch against the contents of `coll' before adding it.
-	for (typename Patches::const_iterator i = changes.begin(); i != changes.end(); i++)
-		// Consider only valid items
-		if (i->first != Item())
-		{
-			Patch newChange(i->second);
-
-			TagSet tags(coll.getTags(i->first));
-			newChange.removeRedundant(tags);
-
-			// Empty patches are filtered out by PatchList so we don't need to do
-			// it here
-			this->changes.addPatch(newChange);
-		}
-}
-
-template<typename ROCOLL>
-void Patched<ROCOLL>::addChanges(const Patches& changes)
-{
-	Patches ch(m_changes);
-
-	ch.addPatch(changes);
-
-	setChanges(ch);
-}
-
-template<typename ROCOLL>
-bool Patched<ROCOLL>::hasTag(const Tag& tag) const
-{
-	ItemSet items(coll.getItemsHavingTag(tag));
-
-	// Check items in coll first
-	for (typename ItemSet::const_iterator i = items.begin();
-			i != items.end(); i++)
-		// If they are unmodified, then we can trust coll.getItems
-		if (m_changes.find(*i) == m_changes.end())
-			return true;
-
-	// Then check items in the patch
-	for (typename Patches::const_iterator i = m_changes.begin();
-			i != m_changes.end(); i++)
-		if (utils::set_contains(i->second.getAdded(), tag))
-			return true;
-
-	return false;
-}
-
-template<typename ROCOLL>
-typename coll_traits<ROCOLL>::itemset_type Patched<ROCOLL>::getTaggedItems() const
-{
-	ItemSet res(coll.getTaggedItems());
-	for (typename Patches::const_iterator i = m_changes.begin();
-			i != m_changes.end(); i++)
-		res |= i->first;
-	return res;
-}
-
-template<typename ROCOLL>
-typename coll_traits<ROCOLL>::tagset_type Patched<ROCOLL>::getAllTags() const
-{
-	TagSet res;
-	for (typename Patched<ROCOLL>::const_iterator i = begin();
-			i != end(); ++i)
-		res |= i->second;
-	return res;
-}
-
-#if 0
-template<typename ITEM, typename TAG, typename OUT>
-class UnpatchedOnly : public wibble::mixin::OutputIterator< UnpatchedOnly<ITEM, TAG, OUT> >
-{
-protected:
-	OUT out;
-	const PatchList<ITEM, TAG>& changes;
-
-public:	
-	UnpatchedOnly(const PatchList<ITEM, TAG>& changes, const OUT& out) : out(out), changes(changes) {}
-
-	UnpatchedOnly<ITEM, TAG, OUT>& operator++() { return *this; }
-	
-	template<typename Items, typename Tags>
-	UnpatchedOnly<ITEM, TAG, OUT>& operator=(const std::pair<Items, Tags>& data)
-	{
-		for (typename Items::const_iterator i = data.first.begin();
-				i != data.first.end(); ++i)
-			if (changes.find(*i) == changes.end())
-			{
-				*out = data;
-				++out;
-			}
-		return *this;
-	}
-};
-
-template<typename ITEM, typename TAG, typename OUT>
-UnpatchedOnly<ITEM, TAG, OUT> unpatchedOnly(const PatchList<ITEM, TAG>& changes, const OUT& out)
-{
-	return UnpatchedOnly<ITEM, TAG, OUT>(changes, out);
-}
-
-template<class ITEM, class TAG>
-void Patched<ITEM, TAG>::output(Consumer<ITEM, TAG>& cons) const
-{
-	// First, only pass the unpatched items
-	coll.outputToIterator(unpatchedOnly(changes, consumer(cons)));
-
-	// Then output the items in the patch
-	for (typename PatchList<ITEM, TAG>::const_iterator i = changes.begin();
-			i != changes.end(); i++)
-		cons.consume(i->first,
-				changes.patch(i->first, coll.getTags(i->first)));
-}
-#endif
-
-template<typename ROCOLL>
-void Patched<ROCOLL>::applyChange(const Patches& change)
-{
-	for (typename Patches::const_iterator i = change.begin();
-			i != change.end(); i++)
-	{
-		Patch newChange(i->second);
-		newChange.removeRedundant(getTagsOfItem(i->first));
-		m_changes.addPatch(newChange);
-	}
-}
-
-template<typename ROCOLL>
-int Patched<ROCOLL>::getCardinality(const Tag& tag) const
-{
-	int card = coll.getCardinality(tag);
-
-	for (typename Patches::const_iterator i = m_changes.begin();
-			i != m_changes.end(); i++)
-	{
-		if (utils::set_contains(i->second.getAdded(), tag))
-			card++;
-		else if (utils::set_contains(i->second.getRemoved(), tag))
-			card--;
-	}
-
-	return card;
-}
-
-}
-}
 
 #ifdef COMPILE_TESTSUITE
 
+#include <tagcoll/coll/patched.h>
 #include <tests/test-utils.h>
 #include <tagcoll/coll/simple.h>
 
 namespace wibble {
 namespace tut {
+using namespace std;
 using namespace tagcoll;
 using namespace tagcoll::tests;
 using namespace tagcoll::coll;
@@ -242,7 +62,9 @@
 }
 }
 
-#include <tagcoll/test-utils.tcc>
+#include <tagcoll/tests/test-utils.tcc>
+#include <tagcoll/coll/patched.tcc>
+#include <tagcoll/coll/simple.tcc>
 
 #endif
 // vim:set ts=4 sw=4:

Modified: tagcoll/2.0/tagcoll/coll/simple.cc
==============================================================================
--- tagcoll/2.0/tagcoll/coll/simple.cc	(original)
+++ tagcoll/2.0/tagcoll/coll/simple.cc	Thu May 11 02:44:47 2006
@@ -55,7 +55,7 @@
 
 #include <tagcoll/Patches.tcc>
 #include <tagcoll/coll/simple.tcc>
-#include <tagcoll/test-utils.tcc>
+#include <tagcoll/tests/test-utils.tcc>
 
 #endif
 

Modified: tagcoll/2.0/tools/tagcoll.cc
==============================================================================
--- tagcoll/2.0/tools/tagcoll.cc	(original)
+++ tagcoll/2.0/tools/tagcoll.cc	Thu May 11 02:44:47 2006
@@ -771,5 +771,6 @@
 #include <tagcoll/Patches.tcc>
 #include <tagcoll/Implications.tcc>
 #include <tagcoll/coll/simple.tcc>
+#include <tagcoll/coll/fast.tcc>
 
 // vim:set ts=4 sw=4:



More information about the Debtags-commits mailing list