[Debtags-commits] [svn] r1750 - in tagcoll/2.0: . tagcoll
tagcoll/coll tagcoll/stream tagcoll/tests
Enrico Zini
enrico at costa.debian.org
Wed May 10 00:51:05 UTC 2006
Author: enrico
Date: Wed May 10 00:38:26 2006
New Revision: 1750
Added:
tagcoll/2.0/tagcoll/coll/intdiskindex.cc
tagcoll/2.0/tagcoll/coll/intdiskindex.h
Removed:
tagcoll/2.0/tagcoll/IntDiskIndex.cc
tagcoll/2.0/tagcoll/IntDiskIndex.h
Modified:
tagcoll/2.0/ (props changed)
tagcoll/2.0/tagcoll/Makefile.am
tagcoll/2.0/tagcoll/TextFormat.cc
tagcoll/2.0/tagcoll/stream/filters.cc
tagcoll/2.0/tagcoll/stream/sink.cc
tagcoll/2.0/tagcoll/stream/sink.h
tagcoll/2.0/tagcoll/tests/test-utils.h
Log:
r2681 at viaza: enrico | 2006-05-09 19:25:35 -0500
Refactored IntDiskIndex to fit in the new collection framework
Modified: tagcoll/2.0/tagcoll/Makefile.am
==============================================================================
--- tagcoll/2.0/tagcoll/Makefile.am (original)
+++ tagcoll/2.0/tagcoll/Makefile.am Wed May 10 00:38:26 2006
@@ -13,6 +13,10 @@
input/string.h \
input/stdio.h \
\
+ diskindex/mmap.h \
+ diskindex/int.h \
+ diskindex/string.h \
+ \
expression.h \
\
stream/sink.h \
@@ -29,12 +33,8 @@
coll/fast.tcc \
coll/patched.h \
coll/patched.cc \
+ coll/intdiskindex.h \
\
- diskindex/mmap.h \
- diskindex/int.h \
- diskindex/string.h \
- \
- Consumer.h \
Patches.h \
Patches.tcc \
\
@@ -43,8 +43,6 @@
TextFormat.h \
TextFormat.tcc \
\
- IntDiskIndex.h \
- IntDiskIndex.cc \
BasicStringDiskIndex.h \
\
Implications.h \
@@ -52,12 +50,11 @@
\
DerivedTags.h \
\
- CardinalityStore.h \
- CardinalityStore.cc \
+ SmartHierarchy.h \
+ SmartHierarchy.cc \
+ \
experiments.h
-# SmartHierarchy.h \
-# SmartHierarchy.cc
lib_LTLIBRARIES = libtagcoll.la
libtagcoll_la_SOURCES = \
@@ -66,6 +63,10 @@
input/string.cc \
input/stdio.cc \
\
+ diskindex/mmap.cc \
+ diskindex/int.cc \
+ diskindex/string.cc \
+ \
expression.cc \
\
stream/sink.cc \
@@ -77,12 +78,8 @@
coll/simple.cc \
coll/fast.cc \
coll/patched.cc \
+ coll/intdiskindex.cc \
\
- diskindex/mmap.cc \
- diskindex/int.cc \
- diskindex/string.cc \
- \
- Consumer.cc \
Patches.cc \
\
Serializer.cc \
@@ -96,7 +93,6 @@
\
test-utils.cc
-# IntDiskIndex.cc \
# BasicStringDiskIndex.cc \
# \
# CardinalityStore.cc \
Modified: tagcoll/2.0/tagcoll/TextFormat.cc
==============================================================================
--- tagcoll/2.0/tagcoll/TextFormat.cc (original)
+++ tagcoll/2.0/tagcoll/TextFormat.cc Wed May 10 00:38:26 2006
@@ -159,6 +159,7 @@
#include <tests/test-utils.h>
#include <tagcoll/input/string.h>
+#include <tagcoll/stream/sink.h>
#include <tagcoll/Patches.h>
namespace wibble {
@@ -180,11 +181,11 @@
"d: c::D, e::F, f::g\n"
);
- TestConsumer<string, string> cons;
- textformat::parse(coll, consumer(cons));
+ int countItems = 0, countTags = 0;
+ textformat::parse(coll, stream::countingSink(countItems, countTags));
- ensure_equals(cons.items, 4);
- ensure_equals(cons.tags, 5);
+ ensure_equals(countItems, 4);
+ ensure_equals(countTags, 5);
}
template<> template<>
Modified: tagcoll/2.0/tagcoll/stream/filters.cc
==============================================================================
--- tagcoll/2.0/tagcoll/stream/filters.cc (original)
+++ tagcoll/2.0/tagcoll/stream/filters.cc Wed May 10 00:38:26 2006
@@ -176,13 +176,17 @@
"b: \n"
"c: 2, 3\n"
);
- int count1 = 0;
- int count2 = 0;
+ int count1Items = 0, count1Tags = 0;
+ int count2Items = 0, count2Tags = 0;
- parseCollection(input_coll, teeFilter(stream::countingSink(count1), stream::countingSink(count2)));
+ parseCollection(input_coll, teeFilter(
+ stream::countingSink(count1Items, count1Tags),
+ stream::countingSink(count2Items, count2Tags)));
- ensure_equals(count1, 3);
- ensure_equals(count2, 3);
+ ensure_equals(count1Items, 3);
+ ensure_equals(count1Tags, 4);
+ ensure_equals(count2Items, 3);
+ ensure_equals(count2Tags, 4);
}
}
Modified: tagcoll/2.0/tagcoll/stream/sink.cc
==============================================================================
--- tagcoll/2.0/tagcoll/stream/sink.cc (original)
+++ tagcoll/2.0/tagcoll/stream/sink.cc Wed May 10 00:38:26 2006
@@ -40,10 +40,11 @@
"b: \n"
"c: 2, 3\n"
);
- int count = 0;
- parseCollection(input_coll, tagcoll::stream::countingSink(count));
+ int countItems = 0, countTags = 0;
+ parseCollection(input_coll, tagcoll::stream::countingSink(countItems, countTags));
- ensure_equals(count, 3);
+ ensure_equals(countItems, 3);
+ ensure_equals(countTags, 4);
}
}
Modified: tagcoll/2.0/tagcoll/stream/sink.h
==============================================================================
--- tagcoll/2.0/tagcoll/stream/sink.h (original)
+++ tagcoll/2.0/tagcoll/stream/sink.h Wed May 10 00:38:26 2006
@@ -51,26 +51,28 @@
template<typename COUNTER>
class CountingSink : public wibble::mixin::OutputIterator< CountingSink<COUNTER> >
{
- COUNTER& count;
+ COUNTER& countItems;
+ COUNTER& countTags;
+
public:
- CountingSink(COUNTER& count) : count(count) {}
+ CountingSink(COUNTER& countItems, COUNTER& countTags) :
+ countItems(countItems), countTags(countTags) {}
// TODO: see if there's a way of implementing the count using size() when
// the method actually exists
template<typename ITEMS, typename TAGS>
CountingSink& operator=(const std::pair<ITEMS, TAGS>& data)
{
- for (typename ITEMS::const_iterator i = data.first.begin();
- i != data.first.end(); ++i)
- ++count;
+ countItems += data.first.size();
+ countTags += data.second.size();
return *this;
}
};
template<typename COUNTER>
-inline CountingSink<COUNTER> countingSink(COUNTER& count)
+inline CountingSink<COUNTER> countingSink(COUNTER& countItems, COUNTER& countTags)
{
- return CountingSink<COUNTER>(count);
+ return CountingSink<COUNTER>(countItems, countTags);
}
Modified: tagcoll/2.0/tagcoll/tests/test-utils.h
==============================================================================
--- tagcoll/2.0/tagcoll/tests/test-utils.h (original)
+++ tagcoll/2.0/tagcoll/tests/test-utils.h Wed May 10 00:38:26 2006
@@ -20,29 +20,6 @@
namespace tagcoll {
namespace tests {
-template<class ITEM, class TAG>
-class TestConsumer : public tagcoll::Consumer<ITEM, TAG>
-{
-protected:
- virtual void consumeItemUntagged(const ITEM& item) { items++; }
-
- virtual void consumeItem(const ITEM& item, const std::set<TAG>& tags)
- {
- items++;
- this->tags += tags.size();
- }
-
-public:
- int items;
- int tags;
-
- TestConsumer() : items(0), tags(0) {}
-};
-
-#if 0
-void outputCollection(const std::string& str, tagcoll::Consumer<string, string>& cons);
-#endif
-
template<typename OUT>
void parseCollection(const std::string& str, const OUT& out)
{
More information about the Debtags-commits
mailing list