object db compiles
diff --git a/include/object-db-file.h b/include/object-db-file.h
index dea8582..1eb1ef8 100644
--- a/include/object-db-file.h
+++ b/include/object-db-file.h
@@ -4,8 +4,6 @@
#include "object-db.h"
#include <stdio.h>
#include <fstream>
-#include <ifstream>
-#include <ofstream>
#include <sstream>
#include <deque>
#include <boost/thread/locks.hpp>
@@ -50,7 +48,7 @@
typedef boost::unique_lock<Mutex> ULock;
ObjectDBFile(const string &filename);
- virtual ~ObjectDBFile(){}
+ virtual ~ObjectDBFile();
// reserve the "address" table for n COs; must reserve before
// write anything (unless reserved quota has not be consumed yet)
@@ -149,4 +147,7 @@
void
readBytes(istream &in, Bytes &bytes);
+char *
+head(const Bytes &bytes);
+
#endif
diff --git a/include/object-db.h b/include/object-db.h
index 7daa37c..207e0b3 100644
--- a/include/object-db.h
+++ b/include/object-db.h
@@ -35,7 +35,7 @@
// size in terms of number of COs
virtual int
- size() = 0 const;
+ size() = 0;
};
diff --git a/src/object-db-file.cpp b/src/object-db-file.cpp
index 526ea4e..26f8fb3 100644
--- a/src/object-db-file.cpp
+++ b/src/object-db-file.cpp
@@ -1,6 +1,12 @@
#include "object-db-file.h"
#include <assert.h>
+char *
+head(const Bytes &bytes)
+{
+ return (char *)&bytes[0];
+}
+
void
writeBytes(ostream &out, const Bytes &bytes)
{
@@ -26,9 +32,9 @@
, m_filename(filename)
// This ensures file with filename exists (assuming having write permission)
// This is needed as file_lock only works with existing file
- , m_ostream(m_filename, ios_base::binary | ios_base::app)
- , m_istream(m_filename, ios_base::binary | ios_base::in)
- , m_filelock(m_filename)
+ , m_ostream(m_filename.c_str(), ios_base::binary | ios_base::app)
+ , m_istream(m_filename.c_str(), ios_base::binary | ios_base::binary)
+ , m_filelock(m_filename.c_str())
{
int magic;
ReadLock(m_filelock);
@@ -51,7 +57,7 @@
void
ObjectDBFile::init(int capacity)
{
- WriteLock(m_filelock);
+ WriteLock(*m_filelock);
if (m_initialized)
{
throwException("Trying to init already initialized ObjectDBFile object" + m_filename);
@@ -66,7 +72,7 @@
writeInt(m_ostream, m_size);
m_initialized = true;
- int count = size;
+ int count = m_cap;
int offset = 0;
while (count-- > 0)
{
@@ -126,7 +132,7 @@
{
SLock(m_cacheLock);
// no need to read file if found in cache
- if (m_dummyCache.find(m_index) != map::end)
+ if (m_dummyCache.find(m_index) != m_dummyCache.end())
{
int index = m_index;
m_index++;
@@ -177,7 +183,7 @@
}
void
-ObjectDBFile::updateSzie()
+ObjectDBFile::updateSize()
{
int pos = m_istream.tellg();
m_istream.seekg(2 * sizeof(int), ios::beg);
@@ -219,7 +225,7 @@
}
void
-rewind()
+ObjectDBFile::rewind()
{
ReadLock(m_filelock);
m_index = 0;