[Debtags-commits] [svn] r1560 - in tagcoll/trunk: . tagcoll

Enrico Zini enrico at costa.debian.org
Sat Feb 11 12:24:52 UTC 2006


Author: enrico
Date: Sat Feb 11 12:24:51 2006
New Revision: 1560

Added:
   tagcoll/trunk/tagcoll/StringIndex.cc
   tagcoll/trunk/tagcoll/StringIndex.h
Modified:
   tagcoll/trunk/   (props changed)
   tagcoll/trunk/tagcoll/Exception.h
   tagcoll/trunk/tagcoll/IntIndex.cc
   tagcoll/trunk/tagcoll/IntIndex.h
   tagcoll/trunk/tagcoll/Makefile.am
Log:
 r7214 at viaza:  enrico | 2006-02-10 13:16:00 +0100
 Added StringIndex


Modified: tagcoll/trunk/tagcoll/Exception.h
==============================================================================
--- tagcoll/trunk/tagcoll/Exception.h	(original)
+++ tagcoll/trunk/tagcoll/Exception.h	Sat Feb 11 12:24:51 2006
@@ -146,6 +146,23 @@
 };
 
 /**
+ * Exception thrown when some a requested item has not been found
+ * 
+ * It is a direct child of ContextException, and has the very same semantics.
+ */
+class NotFoundException : public ContextException
+{
+public:
+	NotFoundException(const std::string& context) throw () :
+		ContextException(context) {}
+
+	virtual const char* type() const throw ()
+	{
+		return "NotFoundException";
+	}
+};
+
+/**
  * Exception thrown when some long event is interrupted by an external event
  * (like a system call being interrupted by a signal)
  * 

Modified: tagcoll/trunk/tagcoll/IntIndex.cc
==============================================================================
--- tagcoll/trunk/tagcoll/IntIndex.cc	(original)
+++ tagcoll/trunk/tagcoll/IntIndex.cc	Sat Feb 11 12:24:51 2006
@@ -105,7 +105,7 @@
 #else
 	// Enlarge the temporary file to fit the data
 	int size = encodedSize();
-	if (lseek(fd, size - 1, SEEK_SET) == -1)
+	if (lseek(fd, (size * sizeof(int)) - 1, SEEK_SET) == -1)
 	{
 		close(fd);
 		unlink(name);
@@ -121,7 +121,7 @@
 	}
 
 	// Map the file into memory
-	void* buf = mmap(0, size, PROT_WRITE, MAP_SHARED, fd, 0);
+	void* buf = mmap(0, size * sizeof(int), PROT_WRITE, MAP_SHARED, fd, 0);
 	if (buf == MAP_FAILED)
 	{
 		close(fd);
@@ -133,7 +133,7 @@
 	encode((int*)buf);
 
 	// Unmap the file
-	if (munmap(buf, size) == -1)
+	if (munmap(buf, size * sizeof(int)) == -1)
 	{
 		close(fd);
 		unlink(name);

Modified: tagcoll/trunk/tagcoll/IntIndex.h
==============================================================================
--- tagcoll/trunk/tagcoll/IntIndex.h	(original)
+++ tagcoll/trunk/tagcoll/IntIndex.h	Sat Feb 11 12:24:51 2006
@@ -40,6 +40,7 @@
  * [size of array][sorted array of ints pointed by index 1]
  * [size of array][sorted array of ints pointed by index 2]
  * [...]
+ * [number of items in the mapping]
  *
  * This allows fast lookups, as well as fast lookups of unions or intersections
  * of mapped arrays.

Modified: tagcoll/trunk/tagcoll/Makefile.am
==============================================================================
--- tagcoll/trunk/tagcoll/Makefile.am	(original)
+++ tagcoll/trunk/tagcoll/Makefile.am	Sat Feb 11 12:24:51 2006
@@ -40,6 +40,7 @@
 		TDBReadonlyDiskIndex.h \
 		\
 		IntIndex.h \
+		StringIndex.h \
 		IntDiskIndex.h \
 		\
 		Filters.h \
@@ -80,6 +81,7 @@
 		TDBReadonlyDiskIndex.cc \
 		\
 		IntIndex.cc \
+		StringIndex.cc \
 		IntDiskIndex.cc \
 		\
 		Filters.cc \



More information about the Debtags-commits mailing list