Petr Onderka has uploaded a new change for review.
https://gerrit.wikimedia.org/r/74389
Change subject: used cmake; fixed code for gcc
......................................................................
used cmake; fixed code for gcc
Change-Id: I12bdde53eab9ab4764d18b8e7c7d091ba3174eb9
---
M .gitignore
A CMakeLists.txt
M Dump.cpp
M Dump.h
M DumpObjects/DumpObject.cpp
M DumpObjects/DumpPage.cpp
M DumpObjects/DumpRevision.cpp
M DumpObjects/FileHeader.cpp
M Indexes/Index.h
M Indexes/IndexLeafNode.h
M Indexes/IndexLeafNode.tpp
M Indexes/IndexNode.h
M Indexes/IndexNode.tpp
M Indexes/Iterators/IndexIterator.h
M Indexes/Iterators/IndexLeafIterator.h
M Objects/Revision.cpp
M Objects/Revision.h
M XML/xmloutput.cpp
M XmlRevisionProcessor.cpp
M main.cpp
20 files changed, 172 insertions(+), 49 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/dumps/incremental
refs/changes/89/74389/1
diff --git a/.gitignore b/.gitignore
index aa34183..1dc8fa5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,7 @@
*.vcxproj.user
/Debug/
/Release/
+/CMakeCache.txt
+/CMakeFiles/
+/Makefile
+*.cmake
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..61b525c
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,105 @@
+cmake_minimum_required(VERSION 2.8)
+
+if(CMAKE_COMPILER_IS_GNUCXX)
+ add_definitions(-std=c++11)
+endif()
+
+# File list: C/C++ Compiler
+set(SOURCES_files_ClCompile
+ Dump.cpp
+ DumpException.cpp
+ DumpObjects/DumpIpV4User.cpp
+ DumpObjects/DumpNamedUser.cpp
+ DumpObjects/DumpObject.cpp
+ DumpObjects/DumpTraits.cpp
+ DumpObjects/FileHeader.cpp
+ DumpObjects/DumpPage.cpp
+ DumpObjects/DumpRevision.cpp
+ DumpObjects/DumpUser.cpp
+ Objects/IpV4User.cpp
+ main.cpp
+ DumpObjects/Offset.cpp
+ Objects/Page.cpp
+ Objects/Revision.cpp
+ SpaceManager.cpp
+ DumpWriters/TestDumpWriter.cpp
+ DumpWriters/StubCurrentWriter.cpp
+ Objects/User.cpp
+ StringHelpers.cpp
+ Objects/Timestamp.cpp
+ XmlContributorProcessor.cpp
+ XmlPageProcessor.cpp
+ XmlRevisionProcessor.cpp
+ XmlUtils.cpp
+ XML/xmlfile.cpp
+ XML/xmlfile_c.c
+ XML/xmlinput.cpp
+ XML/xmlinput_c.c
+ XML/xmloutput.cpp
+)
+# File list: C/C++ Header
+set(SOURCES_files_ClInclude
+ DumpException.h
+ DumpObjects/DumpIpV4User.h
+ DumpObjects/DumpNamedUser.h
+ DumpObjects/DumpObjectKind.h
+ DumpObjects/DumpPage.h
+ DumpObjects/DumpRevision.h
+ DumpObjects/DumpUser.h
+ Indexes/Index.h
+ Indexes/IndexLeafNode.tpp
+ Indexes/IndexNode.tpp
+ Indexes/Index.tpp
+ Dump.h
+ DumpObjects/DumpObject.h
+ DumpObjects/DumpTraits.h
+ DumpWriters/DumpWriter.h
+ DumpObjects/FileHeader.h
+ Indexes/IndexLeafNode.h
+ Indexes/IndexNode.h
+ DumpObjects/Offset.h
+ Objects/IpV4User.h
+ Objects/Page.h
+ Objects/Revision.h
+ Indexes/Iterators/IndexIterator.h
+ Indexes/Iterators/IndexIterator.tpp
+ Indexes/Iterators/IndexLeafIterator.h
+ Indexes/Iterators/IndexLeafIterator.tpp
+ Indexes/Iterators/IndexNodeIterator.h
+ Indexes/Iterators/IndexNodeIterator.tpp
+ SpaceManager.h
+ DumpWriters/TestDumpWriter.h
+ DumpWriters/StubCurrentWriter.h
+ Objects/User.h
+ StringHelpers.h
+ Objects/Timestamp.h
+ XmlContributorProcessor.h
+ XmlPageProcessor.h
+ XmlRevisionProcessor.h
+ XmlUtils.h
+ XML/xmlconfig.h
+ XML/xmlfile.h
+ XML/xmlinput.h
+ XML/xmlinputp.h
+ XML/xmloutput.h
+ XML/xmlstream.h
+)
+set_property(SOURCE ${SOURCES_files_ClInclude} PROPERTY HEADER_FILE_ONLY
+ ON
+)
+set(fl_want_add_to_target ON)
+
+set(SOURCES
+ ${SOURCES_files_ClCompile}
+ ${SOURCES_files_ClInclude}
+)
+
+if(NOT TARGET Incrementaldumps)
+ add_executable(Incrementaldumps ${SOURCES})
+endif(NOT TARGET Incrementaldumps)
+
+if(TARGET Incrementaldumps)
+ set(CMAKE_VS_PLATFORM_TOOLSET
+ v110
+ )
+endif(TARGET Incrementaldumps)
diff --git a/Dump.cpp b/Dump.cpp
index e610645..1de43f1 100644
--- a/Dump.cpp
+++ b/Dump.cpp
@@ -2,6 +2,7 @@
#include <string>
#include <fstream>
#include "Dump.h"
+#include "SpaceManager.h"
using std::move;
using std::unique_ptr;
@@ -78,4 +79,4 @@
pageIdIndex->Write();
revisionIdIndex->Write();
-}
\ No newline at end of file
+}
diff --git a/Dump.h b/Dump.h
index cc39835..2863f91 100644
--- a/Dump.h
+++ b/Dump.h
@@ -5,8 +5,6 @@
#include <string>
#include <iostream>
#include "DumpObjects/FileHeader.h"
-#include "Indexes/Index.h"
-#include "SpaceManager.h"
using std::int32_t;
using std::int64_t;
@@ -16,6 +14,11 @@
using std::iostream;
class WritableDump;
+
+template<typename TKey, typename TValue>
+class Index;
+
+class SpaceManager;
class ReadableDump
{
@@ -49,4 +52,4 @@
// it's necessary to call this after writing is finished
void WriteIndexes();
-};
\ No newline at end of file
+};
diff --git a/DumpObjects/DumpObject.cpp b/DumpObjects/DumpObject.cpp
index 550c493..491eb80 100644
--- a/DumpObjects/DumpObject.cpp
+++ b/DumpObjects/DumpObject.cpp
@@ -1,5 +1,6 @@
#include "DumpObject.h"
#include "../Dump.h"
+#include "../SpaceManager.h"
DumpObject::DumpObject(weak_ptr<WritableDump> dump)
: dump(dump), savedOffset(0), savedLength(0)
@@ -45,4 +46,4 @@
uint64_t DumpObject::SavedOffset() const
{
return savedOffset;
-}
\ No newline at end of file
+}
diff --git a/DumpObjects/DumpPage.cpp b/DumpObjects/DumpPage.cpp
index d151466..58c1000 100644
--- a/DumpObjects/DumpPage.cpp
+++ b/DumpObjects/DumpPage.cpp
@@ -1,5 +1,6 @@
#include "DumpPage.h"
#include "DumpObjectKind.h"
+#include "../Indexes/Index.h"
void DumpPage::Load(uint32_t pageId)
{
@@ -80,4 +81,4 @@
page = Read(dumpRef, offset);
savedOffset = offset.value;
savedLength = NewLength();
-}
\ No newline at end of file
+}
diff --git a/DumpObjects/DumpRevision.cpp b/DumpObjects/DumpRevision.cpp
index 973a2cf..54a458d 100644
--- a/DumpObjects/DumpRevision.cpp
+++ b/DumpObjects/DumpRevision.cpp
@@ -1,6 +1,7 @@
#include "DumpRevision.h"
#include "DumpObjectKind.h"
#include "DumpUser.h"
+#include "../Indexes/Index.h"
void DumpRevision::Load(uint32_t revisionId)
{
@@ -34,7 +35,7 @@
revision.RevisionId = DumpTraits<uint32_t>::Read(stream);
revision.Flags = (RevisionFlags)DumpTraits<uint8_t>::Read(stream);
revision.ParentId = DumpTraits<uint32_t>::Read(stream);
- revision.Timestamp = DumpTraits<uint32_t>::Read(stream);
+ revision.DateTime = DumpTraits<uint32_t>::Read(stream);
revision.Contributor = DumpUser::Read(revision.Flags, stream)->GetUser();
revision.Comment = DumpTraits<string>::Read(stream);
revision.Text = DumpTraits<string>::Read(stream);
@@ -50,7 +51,7 @@
WriteValue(revision.RevisionId);
WriteValue((uint8_t)revision.Flags);
WriteValue(revision.ParentId);
- WriteValue(revision.Timestamp.ToInteger());
+ WriteValue(revision.DateTime.ToInteger());
user->Write(stream);
WriteValue(revision.Comment);
if (withText)
@@ -77,7 +78,7 @@
+ ValueSize(revision.RevisionId)
+ ValueSize((uint8_t)revision.Flags)
+ ValueSize(revision.ParentId)
- + ValueSize(revision.Timestamp.ToInteger())
+ + ValueSize(revision.DateTime.ToInteger())
+ user->NewLength()
+ ValueSize(revision.Comment)
+ ValueSize(withText ? revision.Text : string());
@@ -91,4 +92,4 @@
DumpRevision::DumpRevision(weak_ptr<WritableDump> dump, bool withText)
: DumpObject(dump), revision(), withText(withText)
-{}
\ No newline at end of file
+{}
diff --git a/DumpObjects/FileHeader.cpp b/DumpObjects/FileHeader.cpp
index 0f683da..156b00b 100644
--- a/DumpObjects/FileHeader.cpp
+++ b/DumpObjects/FileHeader.cpp
@@ -1,3 +1,4 @@
+#include <cstring>
#include "FileHeader.h"
#include "../Dump.h"
#include "../DumpException.h"
@@ -59,4 +60,4 @@
FileHeader::FileHeader(weak_ptr<WritableDump> dump)
: DumpObject(dump), FileEnd(Length()), PageIdIndexRoot(0),
FreeSpaceIndexRoot(0)
-{}
\ No newline at end of file
+{}
diff --git a/Indexes/Index.h b/Indexes/Index.h
index 5c611ed..0ed08cf 100644
--- a/Indexes/Index.h
+++ b/Indexes/Index.h
@@ -1,7 +1,7 @@
#pragma once
#include <utility>
-#include "DumpObjects/Offset.h"
+#include "../DumpObjects/Offset.h"
#include "Iterators/IndexIterator.h"
#include "IndexNode.h"
@@ -30,4 +30,4 @@
void Write();
};
-#include "Index.tpp"
\ No newline at end of file
+#include "Index.tpp"
diff --git a/Indexes/IndexLeafNode.h b/Indexes/IndexLeafNode.h
index 85df841..37cc0e1 100644
--- a/Indexes/IndexLeafNode.h
+++ b/Indexes/IndexLeafNode.h
@@ -11,15 +11,17 @@
private:
static const int Size = 0xFFFF;
- map<TKey, TValue> map;
+ map<TKey, TValue> indexMap;
protected:
virtual void WriteInternal();
public:
- static unique_ptr<IndexNode> Read(weak_ptr<WritableDump> dump, istream
&stream);
+ static unique_ptr<IndexNode<TKey, TValue>> Read(weak_ptr<WritableDump>
dump, istream &stream);
IndexLeafNode(weak_ptr<WritableDump> dump);
using DumpObject::Write;
+ using DumpObjectBase::WriteValue;
+
virtual uint32_t NewLength() const;
virtual TValue Get(TKey key);
@@ -31,4 +33,4 @@
virtual shared_ptr<IndexNodeIterator<TKey, TValue>> end() const;
};
-#include "IndexLeafNode.tpp"
\ No newline at end of file
+#include "IndexLeafNode.tpp"
diff --git a/Indexes/IndexLeafNode.tpp b/Indexes/IndexLeafNode.tpp
index f09f1ee..de87ac0 100644
--- a/Indexes/IndexLeafNode.tpp
+++ b/Indexes/IndexLeafNode.tpp
@@ -1,6 +1,7 @@
#include <utility>
#include <vector>
#include "../DumpObjects/DumpTraits.h"
+#include "../DumpObjects/DumpObjectKind.h"
#include "Iterators/IndexLeafIterator.h"
using std::pair;
@@ -9,9 +10,9 @@
template<typename TKey, typename TValue>
TValue IndexLeafNode<TKey, TValue>::Get(TKey key)
{
- auto found = map.find(key);
+ auto found = indexMap.find(key);
- if (found == map.end())
+ if (found == indexMap.end())
return TValue();
return found->second;
@@ -20,20 +21,20 @@
template<typename TKey, typename TValue>
void IndexLeafNode<TKey, TValue>::Add(TKey key, TValue value)
{
- if (map.size() >= Size)
+ if (indexMap.size() >= Size)
{
// TODO
throw new DumpException();
}
- map.insert(pair<TKey, TValue>(key, value));
+ indexMap.insert(pair<TKey, TValue>(key, value));
}
template<typename TKey, typename TValue>
void IndexLeafNode<TKey, TValue>::AddOrUpdate(TKey key, TValue value)
{
- auto pos = map.find(key);
- if (pos == map.end())
+ auto pos = indexMap.find(key);
+ if (pos == indexMap.end())
{
Add(key, value);
}
@@ -46,12 +47,12 @@
template<typename TKey, typename TValue>
void IndexLeafNode<TKey, TValue>::Remove(const TKey key)
{
- map.erase(key);
+ indexMap.erase(key);
}
template<typename TKey, typename TValue>
IndexLeafNode<TKey, TValue>::IndexLeafNode(weak_ptr<WritableDump> dump)
- : IndexNode(dump)
+ : IndexNode<TKey, TValue>(dump)
{
}
@@ -73,7 +74,7 @@
for (int i = 0; i < count; i++)
{
- node->map.insert(pair<TKey, TValue>(keys[i],
DumpTraits<TValue>::Read(stream)));
+ node->indexMap.insert(pair<TKey, TValue>(keys[i],
DumpTraits<TValue>::Read(stream)));
}
return unique_ptr<IndexNode<TKey, TValue>>(node);
@@ -83,14 +84,14 @@
void IndexLeafNode<TKey, TValue>::WriteInternal()
{
WriteValue((uint8_t)DumpObjectKind::IndexLeafNode);
- WriteValue((uint16_t)map.size());
+ WriteValue((uint16_t)indexMap.size());
- for (auto pair : map)
+ for (auto pair : indexMap)
{
WriteValue(pair.first);
}
- for (auto pair : map)
+ for (auto pair : indexMap)
{
WriteValue(pair.second);
}
@@ -100,18 +101,18 @@
uint32_t IndexLeafNode<TKey, TValue>::NewLength() const
{
return
DumpTraits<uint8_t>::DumpSize((uint8_t)DumpObjectKind::IndexLeafNode)
- + DumpTraits<uint16_t>::DumpSize(map.size())
+ + DumpTraits<uint16_t>::DumpSize(indexMap.size())
+ Size * (DumpTraits<TKey>::DumpSize() +
DumpTraits<TValue>::DumpSize());
}
template<typename TKey, typename TValue>
shared_ptr<IndexNodeIterator<TKey, TValue>> IndexLeafNode<TKey,
TValue>::begin() const
{
- return shared_ptr<IndexNodeIterator<TKey, TValue>>(new
IndexLeafIterator<TKey, TValue>(map.begin()));
+ return shared_ptr<IndexNodeIterator<TKey, TValue>>(new
IndexLeafIterator<TKey, TValue>(indexMap.begin()));
}
template<typename TKey, typename TValue>
shared_ptr<IndexNodeIterator<TKey, TValue>> IndexLeafNode<TKey, TValue>::end()
const
{
- return shared_ptr<IndexNodeIterator<TKey, TValue>>(new
IndexLeafIterator<TKey, TValue>(map.end()));
-}
\ No newline at end of file
+ return shared_ptr<IndexNodeIterator<TKey, TValue>>(new
IndexLeafIterator<TKey, TValue>(indexMap.end()));
+}
diff --git a/Indexes/IndexNode.h b/Indexes/IndexNode.h
index 6265558..63d5c9d 100644
--- a/Indexes/IndexNode.h
+++ b/Indexes/IndexNode.h
@@ -30,4 +30,4 @@
virtual shared_ptr<IndexNodeIterator<TKey, TValue>> end() const = 0;
};
-#include "IndexNode.tpp"
\ No newline at end of file
+#include "IndexNode.tpp"
diff --git a/Indexes/IndexNode.tpp b/Indexes/IndexNode.tpp
index 0c13830..d827d56 100644
--- a/Indexes/IndexNode.tpp
+++ b/Indexes/IndexNode.tpp
@@ -1,6 +1,7 @@
#include "IndexNode.h"
#include "IndexLeafNode.h"
#include "../DumpException.h"
+#include "../Dump.h"
#include "../DumpObjects/DumpObjectKind.h"
template<typename TKey, typename TValue>
@@ -32,4 +33,4 @@
unique_ptr<IndexNode<TKey, TValue>> IndexNode<TKey,
TValue>::CreateNew(weak_ptr<WritableDump> dump)
{
return unique_ptr<IndexNode<TKey, TValue>>(new IndexLeafNode<TKey,
TValue>(dump));
-}
\ No newline at end of file
+}
diff --git a/Indexes/Iterators/IndexIterator.h
b/Indexes/Iterators/IndexIterator.h
index f73faab..432edcd 100644
--- a/Indexes/Iterators/IndexIterator.h
+++ b/Indexes/Iterators/IndexIterator.h
@@ -13,7 +13,7 @@
template<typename TKey, typename TValue>
class IndexIterator : public iterator<input_iterator_tag, const pair<TKey,
TValue>, int32_t>
{
- template<typename TKey, typename TValue>
+ template<typename TIndexKey, typename TIndexValue>
friend class Index;
private:
shared_ptr<IndexNodeIterator<TKey, TValue>> nodeIterator;
@@ -25,4 +25,4 @@
bool operator !=(const IndexIterator<TKey, TValue> other);
};
-#include "IndexIterator.tpp"
\ No newline at end of file
+#include "IndexIterator.tpp"
diff --git a/Indexes/Iterators/IndexLeafIterator.h
b/Indexes/Iterators/IndexLeafIterator.h
index 730571d..67ec353 100644
--- a/Indexes/Iterators/IndexLeafIterator.h
+++ b/Indexes/Iterators/IndexLeafIterator.h
@@ -11,16 +11,16 @@
{
typedef typename map<TKey, TValue>::const_iterator MapIterator;
- template<typename TKey, typename TValue>
+ template<typename TIndexKey, typename TIndexValue>
friend class IndexLeafNode;
private:
MapIterator mapIterator;
IndexLeafIterator(MapIterator mapIterator);
public:
- virtual const pair<TKey, TValue> operator *() const;
- virtual IndexLeafIterator& operator ++();
- virtual bool equals(const IndexNodeIterator *other) const;
+ virtual const pair<TKey, TValue> operator *() const override;
+ virtual IndexLeafIterator& operator ++() override;
+ virtual bool equals(const IndexNodeIterator<TKey, TValue> *other) const
override;
};
-#include "IndexLeafIterator.tpp"
\ No newline at end of file
+#include "IndexLeafIterator.tpp"
diff --git a/Objects/Revision.cpp b/Objects/Revision.cpp
index 1b2e5ab..7747624 100644
--- a/Objects/Revision.cpp
+++ b/Objects/Revision.cpp
@@ -17,5 +17,5 @@
}
Revision::Revision()
- : Flags(), RevisionId(), ParentId(), Timestamp(), Contributor(),
Comment(), Text()
-{}
\ No newline at end of file
+ : Flags(), RevisionId(), ParentId(), DateTime(), Contributor(), Comment(),
Text()
+{}
diff --git a/Objects/Revision.h b/Objects/Revision.h
index ab7954b..940a0ac 100644
--- a/Objects/Revision.h
+++ b/Objects/Revision.h
@@ -30,8 +30,8 @@
RevisionFlags Flags;
uint32_t RevisionId;
uint32_t ParentId;
- Timestamp Timestamp;
+ Timestamp DateTime;
shared_ptr<User> Contributor;
string Comment;
string Text;
-};
\ No newline at end of file
+};
diff --git a/XML/xmloutput.cpp b/XML/xmloutput.cpp
index 8ed937d..212a8a1 100644
--- a/XML/xmloutput.cpp
+++ b/XML/xmloutput.cpp
@@ -26,6 +26,7 @@
#include "xmloutput.h"
#include <stdio.h>
#include <assert.h>
+#include <string.h>
XML_BEGIN_NAMESPACE
diff --git a/XmlRevisionProcessor.cpp b/XmlRevisionProcessor.cpp
index 5d5db03..fffb638 100644
--- a/XmlRevisionProcessor.cpp
+++ b/XmlRevisionProcessor.cpp
@@ -10,7 +10,7 @@
XML::Handler("id", [](XML::Element &elem, void *userData) {
((Revision*)userData)->RevisionId = stoi(readElementData(elem)); }),
XML::Handler("parentid", [](XML::Element &elem, void *userData) {
((Revision*)userData)->ParentId = stoi(readElementData(elem)); }),
- XML::Handler("timestamp", [](XML::Element &elem, void *userData) {
((Revision*)userData)->Timestamp =
Timestamp(readElementData(elem)).ToInteger(); }),
+ XML::Handler("timestamp", [](XML::Element &elem, void *userData) {
((Revision*)userData)->DateTime = Timestamp(readElementData(elem)).ToInteger();
}),
XML::Handler("contributor", XmlContributorProcessor::Handler),
@@ -29,4 +29,4 @@
XmlPageProcessor* pageProcessor = (XmlPageProcessor*)userData;
pageProcessor->ProcessRevision(shared_ptr<Revision>(revision));
-}
\ No newline at end of file
+}
diff --git a/main.cpp b/main.cpp
index e0113f4..86b84a6 100644
--- a/main.cpp
+++ b/main.cpp
@@ -5,6 +5,7 @@
#include "XmlPageProcessor.h"
#include "Dump.h"
#include "DumpObjects/DumpRevision.h"
+#include "Indexes/Index.h"
using std::cin;
using std::cout;
@@ -79,7 +80,7 @@
{
auto revision = DumpRevision(dump, revisionId, false).revision;
- cout << " " << revision.RevisionId << " (<- " << revision.ParentId
<< ") " << revision.Timestamp.ToString() << " " <<
revision.Contributor->UserName << "\n";
+ cout << " " << revision.RevisionId << " (<- " << revision.ParentId
<< ") " << revision.DateTime.ToString() << " " <<
revision.Contributor->UserName << "\n";
cout << " " << revision.Comment << "\n";
if (++j >= 5)
@@ -130,4 +131,4 @@
cout << "Unknown action '" << action << "'\n";
printUsage();
}
-}
\ No newline at end of file
+}
--
To view, visit https://gerrit.wikimedia.org/r/74389
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I12bdde53eab9ab4764d18b8e7c7d091ba3174eb9
Gerrit-PatchSet: 1
Gerrit-Project: operations/dumps/incremental
Gerrit-Branch: gsoc
Gerrit-Owner: Petr Onderka <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits