Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6796cf8

Browse files
committed
- Extensive documentation of serialization.
- Removed podify and integer.hpp - Removed outdated serialization tests
1 parent 2d513c4 commit 6796cf8

21 files changed

Lines changed: 267 additions & 514 deletions

src/graphlab/docs/main.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@
2525
/**
2626
\defgroup group_schedulers Schedulers
2727
\defgroup engine Engines
28-
\defgroup util_internal Internal Utility Classes
2928
\defgroup util GraphLab Utility Classes and Functions
3029
\defgroup rpc GraphLab RPC
31-
\defgroup rpc_internal GraphLab RPC Internal
3230
\defgroup random Random Number Generators
31+
\defgroup group_serialization Serialization
3332
\mainpage
3433
3534
\section intro_sec Introduction
@@ -63,7 +62,7 @@
6362
6463
GraphLab is additionally supported by a serialization library, a fast parallel/thread-safe
6564
random number generator, as well as a flexible command line parsing system.
66-
\li \ref Serialization
65+
\li \ref serialization
6766
\li \ref random
6867
\li \ref graphlab::command_line_options \n
6968
The \ref detailed_example "detailed example" provides a good example of how this is used

src/graphlab/engine/async_consistent_engine.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ namespace graphlab {
193193
* interface and is the value returned by the
194194
* \ref graphlab::ivertex_program::gather function. The
195195
* gather type must have an <code>operator+=(const gather_type&
196-
* other)</code> function and must be \ref serializable.
196+
* other)</code> function and must be \ref sec_serializable.
197197
*/
198198
typedef typename VertexProgram::gather_type gather_type;
199199

@@ -205,21 +205,21 @@ namespace graphlab {
205205
* interface and used in the call to \ref graphlab::icontext::signal.
206206
* The message type must have an
207207
* <code>operator+=(const gather_type& other)</code> function and
208-
* must be \ref serializable.
208+
* must be \ref sec_serializable.
209209
*/
210210
typedef typename VertexProgram::message_type message_type;
211211

212212
/**
213213
* \brief The type of data associated with each vertex in the graph
214214
*
215-
* The vertex data type must be \ref serializable.
215+
* The vertex data type must be \ref sec_serializable.
216216
*/
217217
typedef typename VertexProgram::vertex_data_type vertex_data_type;
218218

219219
/**
220220
* \brief The type of data associated with each edge in the graph
221221
*
222-
* The edge data type must be \ref serializable.
222+
* The edge data type must be \ref sec_serializable.
223223
*/
224224
typedef typename VertexProgram::edge_data_type edge_data_type;
225225

src/graphlab/engine/iengine.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ namespace graphlab {
393393
* which will make it accessible to all other running update functions.
394394
*
395395
* \tparam ReductionType The output of the map function. Must have
396-
* operator+= defined, and must be \ref Serializable.
396+
* operator+= defined, and must be \ref sec_serializable.
397397
* \tparam VertexMapperType The type of the map function.
398398
* Not generally needed.
399399
* Can be inferred by the compiler.
@@ -407,7 +407,7 @@ namespace graphlab {
407407
* a \ref vertex_type, or a reference to a
408408
* \ref vertex_type as its second argument.
409409
* Returns a ReductionType which must be summable
410-
* and \ref Serializable .
410+
* and \ref sec_serializable .
411411
* \param [in] finalize_function The Finalize function to use. Must take
412412
* an \ref icontext_type& as its first
413413
* argument and a ReductionType, or a
@@ -460,7 +460,7 @@ namespace graphlab {
460460
* a \ref vertex_type, or a reference to a
461461
* \ref vertex_type as its second argument.
462462
* Returns a ReductionType which must be summable
463-
* and \ref Serializable .
463+
* and \ref sec_serializable .
464464
* \param [in] finalize_function The Finalize function to use. Must take
465465
* an \ref icontext_type& as its first
466466
* argument and a ReductionType, or a
@@ -597,7 +597,7 @@ namespace graphlab {
597597
* which will make it accessible to all other running update functions.
598598
*
599599
* \tparam ReductionType The output of the map function. Must have
600-
* operator+= defined, and must be \ref Serializable.
600+
* operator+= defined, and must be \ref sec_serializable.
601601
* \tparam EdgeMapperType The type of the map function.
602602
* Not generally needed.
603603
* Can be inferred by the compiler.
@@ -611,7 +611,7 @@ namespace graphlab {
611611
* a \ref edge_type, or a reference to a
612612
* \ref edge_type as its second argument.
613613
* Returns a ReductionType which must be summable
614-
* and \ref Serializable .
614+
* and \ref sec_serializable .
615615
* \param [in] finalize_function The Finalize function to use. Must take
616616
* an \ref icontext_type& as its first
617617
* argument and a ReductionType, or a
@@ -667,7 +667,7 @@ namespace graphlab {
667667
* a \ref vertex_type, or a reference to a
668668
* \ref vertex_type as its second argument.
669669
* Returns a ReductionType which must be summable
670-
* and \ref Serializable .
670+
* and \ref sec_serializable .
671671
* \param [in] finalize_function The Finalize function to use. Must take
672672
* an \ref icontext_type& as its first
673673
* argument and a ReductionType, or a
@@ -792,7 +792,7 @@ namespace graphlab {
792792
* but may also make modifications to graph data.
793793
*
794794
* \tparam ResultType The output of the map function. Must have
795-
* operator+= defined, and must be \ref Serializable.
795+
* operator+= defined, and must be \ref sec_serializable.
796796
* \tparam VertexMapperType The type of the map function.
797797
* Not generally needed.
798798
* Can be inferred by the compiler.
@@ -801,7 +801,7 @@ namespace graphlab {
801801
* a \ref vertex_type, or a reference to a
802802
* \ref vertex_type as its second argument.
803803
* Returns a ResultType which must be summable
804-
* and \ref Serializable .
804+
* and \ref sec_serializable .
805805
*/
806806
template <typename ResultType, typename VertexMapperType>
807807
ResultType map_reduce_vertices(VertexMapperType mapfunction) {
@@ -887,7 +887,7 @@ namespace graphlab {
887887
* but may also make modifications to graph data.
888888
*
889889
* \tparam ResultType The output of the map function. Must have
890-
* operator+= defined, and must be \ref Serializable.
890+
* operator+= defined, and must be \ref sec_serializable.
891891
* \tparam EdgeMapperType The type of the map function.
892892
* Not generally needed.
893893
* Can be inferred by the compiler.
@@ -896,7 +896,7 @@ namespace graphlab {
896896
* a \ref edge_type, or a reference to a
897897
* \ref edge_type as its second argument.
898898
* Returns a ResultType which must be summable
899-
* and \ref Serializable .
899+
* and \ref sec_serializable .
900900
*/
901901
template <typename ResultType, typename EdgeMapperType>
902902
ResultType map_reduce_edges(EdgeMapperType mapfunction) {

src/graphlab/engine/synchronous_engine.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ namespace graphlab {
190190
* interface and is the value returned by the
191191
* \ref graphlab::ivertex_program::gather function. The
192192
* gather type must have an <code>operator+=(const gather_type&
193-
* other)</code> function and must be \ref serializable.
193+
* other)</code> function and must be \ref sec_serializable.
194194
*/
195195
typedef typename VertexProgram::gather_type gather_type;
196196

@@ -203,21 +203,21 @@ namespace graphlab {
203203
* interface and used in the call to \ref graphlab::icontext::signal.
204204
* The message type must have an
205205
* <code>operator+=(const gather_type& other)</code> function and
206-
* must be \ref serializable.
206+
* must be \ref sec_serializable.
207207
*/
208208
typedef typename VertexProgram::message_type message_type;
209209

210210
/**
211211
* \brief The type of data associated with each vertex in the graph
212212
*
213-
* The vertex data type must be \ref serializable.
213+
* The vertex data type must be \ref sec_serializable.
214214
*/
215215
typedef typename VertexProgram::vertex_data_type vertex_data_type;
216216

217217
/**
218218
* \brief The type of data associated with each edge in the graph
219219
*
220-
* The edge data type must be \ref serializable.
220+
* The edge data type must be \ref sec_serializable.
221221
*/
222222
typedef typename VertexProgram::edge_data_type edge_data_type;
223223

src/graphlab/graph/distributed_graph.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,10 @@ namespace graphlab {
275275
*
276276
* \tparam VertexData Type of data stored on vertices. Must be
277277
* Copyable, Default Constructable, Copy
278-
* Constructable and \ref Serializable.
278+
* Constructable and \ref sec_serializable.
279279
* \tparam EdgeData Type of data stored on edges. Must be
280280
* Copyable, Default Constructable, Copy
281-
* Constructable and \ref Serializable.
281+
* Constructable and \ref sec_serializable.
282282
*/
283283
template<typename VertexData, typename EdgeData>
284284
class distributed_graph {
@@ -798,15 +798,15 @@ namespace graphlab {
798798
* but may also make modifications to graph data.
799799
*
800800
* \tparam ResultType The output of the map function. Must have
801-
* operator+= defined, and must be \ref Serializable.
801+
* operator+= defined, and must be \ref sec_serializable.
802802
* \tparam VertexMapperType The type of the map function.
803803
* Not generally needed.
804804
* Can be inferred by the compiler.
805805
* \param mapfunction The map function to use. Must take
806806
* a \ref vertex_type, or a reference to a
807807
* \ref vertex_type as its only argument.
808808
* Returns a ResultType which must be summable
809-
* and \ref Serializable .
809+
* and \ref sec_serializable .
810810
*/
811811
template <typename ResultType, typename MapFunctionType>
812812
ResultType map_reduce_vertices(MapFunctionType mapfunction) {
@@ -902,15 +902,15 @@ namespace graphlab {
902902
* but may also make modifications to graph data.
903903
*
904904
* \tparam ResultType The output of the map function. Must have
905-
* operator+= defined, and must be \ref Serializable.
905+
* operator+= defined, and must be \ref sec_serializable.
906906
* \tparam EdgeMapperType The type of the map function.
907907
* Not generally needed.
908908
* Can be inferred by the compiler.
909909
* \param mapfunction The map function to use. Must take
910910
* a \ref edge_type, or a reference to a
911911
* \ref edge_type as its only argument.
912912
* Returns a ResultType which must be summable
913-
* and \ref Serializable .
913+
* and \ref sec_serializable .
914914
*/
915915
template <typename ResultType, typename MapFunctionType>
916916
ResultType map_reduce_edges(MapFunctionType mapfunction) {

src/graphlab/serialization/basic_types.hpp

Lines changed: 10 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright (c) 2009 Carnegie Mellon University.
33
* All rights reserved.
44
*
@@ -29,32 +29,9 @@
2929
#define ARCHIVE_BASIC_TYPES_HPP
3030

3131
#include <string>
32-
#include <graphlab/serialization/integer.hpp>
3332
#include <graphlab/serialization/serializable_pod.hpp>
3433
#include <graphlab/logger/assertions.hpp>
3534

36-
/***************************************************************************
37-
* Basic Serializers *
38-
***************************************************************************/
39-
// generate the operator<< call for a whole bunch of integer types
40-
41-
42-
#define INT_SERIALIZE(tname) \
43-
template <typename OutArcType> \
44-
struct serialize_impl<OutArcType, tname, false>{ \
45-
static void exec(OutArcType& oarc, const tname& t) { \
46-
oarc.write(reinterpret_cast<const char*>(&t), sizeof(tname)); \
47-
} \
48-
}; \
49-
template <typename InArcType> \
50-
struct deserialize_impl<InArcType, tname, false>{ \
51-
static void exec(InArcType& iarc, tname& t) { \
52-
decompress_int<InArcType, tname>(iarc, t); \
53-
} \
54-
};
55-
56-
57-
5835

5936
namespace graphlab {
6037
class oarchive;
@@ -64,21 +41,6 @@ namespace graphlab {
6441

6542
namespace graphlab {
6643
namespace archive_detail {
67-
/*
68-
* Generate serializers and deserializers for all integer types
69-
*/
70-
INT_SERIALIZE(bool);
71-
INT_SERIALIZE(char);
72-
INT_SERIALIZE(unsigned char);
73-
INT_SERIALIZE(short);
74-
INT_SERIALIZE(unsigned short);
75-
INT_SERIALIZE(int);
76-
INT_SERIALIZE(long);
77-
INT_SERIALIZE(long long);
78-
INT_SERIALIZE(unsigned long);
79-
INT_SERIALIZE(unsigned int);
80-
INT_SERIALIZE(unsigned long long);
81-
8244

8345
/** Serialization of null terminated const char* strings.
8446
* This is necessary to serialize constant strings like
@@ -92,7 +54,7 @@ namespace graphlab {
9254
// save the length
9355
// ++ for the \0
9456
size_t length = strlen(s); length++;
95-
serialize_impl<OutArcType, size_t, false>::exec(oarc, length);
57+
oarc << length;
9658
oarc.write(reinterpret_cast<const char*>(s), length);
9759
DASSERT_FALSE(oarc.fail());
9860
}
@@ -104,7 +66,7 @@ namespace graphlab {
10466
struct serialize_impl<OutArcType, char [len], false> {
10567
static void exec(OutArcType& oarc, const char s[len] ) {
10668
size_t length = len;
107-
serialize_impl<OutArcType, size_t, false>::exec(oarc, length);
69+
oarc << length;
10870
oarc.write(reinterpret_cast<const char*>(s), length);
10971
DASSERT_FALSE(oarc.fail());
11072
}
@@ -118,7 +80,7 @@ namespace graphlab {
11880
// save the length
11981
// ++ for the \0
12082
size_t length = strlen(s); length++;
121-
serialize_impl<OutArcType, size_t, false>::exec(oarc, length);
83+
oarc << length;
12284
oarc.write(reinterpret_cast<const char*>(s), length);
12385
DASSERT_FALSE(oarc.fail());
12486
}
@@ -130,7 +92,7 @@ namespace graphlab {
13092
static void exec(InArcType& iarc, char*& s) {
13193
// Save the length and check if lengths match
13294
size_t length;
133-
deserialize_impl<InArcType, size_t, false>::exec(iarc, length);
95+
iarc >> length;
13496
s = new char[length];
13597
//operator>> the rest
13698
iarc.read(reinterpret_cast<char*>(s), length);
@@ -143,7 +105,7 @@ namespace graphlab {
143105
struct deserialize_impl<InArcType, char [len], false> {
144106
static void exec(InArcType& iarc, char s[len]) {
145107
size_t length;
146-
deserialize_impl<InArcType, size_t, false>::exec(iarc, length);
108+
iarc >> length;
147109
ASSERT_LE(length, len);
148110
iarc.read(reinterpret_cast<char*>(s), length);
149111
DASSERT_FALSE(iarc.fail());
@@ -157,7 +119,7 @@ namespace graphlab {
157119
struct serialize_impl<OutArcType, std::string, false> {
158120
static void exec(OutArcType& oarc, const std::string& s) {
159121
size_t length = s.length();
160-
serialize_impl<OutArcType, size_t, false>::exec(oarc, length);
122+
oarc << length;
161123
oarc.write(reinterpret_cast<const char*>(s.c_str()),
162124
(std::streamsize)length);
163125
DASSERT_FALSE(oarc.fail());
@@ -171,7 +133,7 @@ namespace graphlab {
171133
static void exec(InArcType& iarc, std::string& s) {
172134
//read the length
173135
size_t length;
174-
deserialize_impl<InArcType, size_t, false>::exec(iarc, length);
136+
iarc >> length;
175137
//resize the string and read the characters
176138
s.resize(length);
177139
iarc.read(const_cast<char*>(s.c_str()), (std::streamsize)length);
@@ -183,10 +145,7 @@ namespace graphlab {
183145
template <typename OutArcType, typename T, typename U>
184146
struct serialize_impl<OutArcType, std::pair<T, U>, false > {
185147
static void exec(OutArcType& oarc, const std::pair<T, U>& s) {
186-
serialize_impl<OutArcType,
187-
T, gl_is_pod<T>::value >::exec(oarc, s.first);
188-
serialize_impl<OutArcType,
189-
U, gl_is_pod<U>::value >::exec(oarc, s.second);
148+
oarc << s.first << s.second;
190149
}
191150
};
192151

@@ -195,10 +154,7 @@ namespace graphlab {
195154
template <typename InArcType, typename T, typename U>
196155
struct deserialize_impl<InArcType, std::pair<T, U>, false > {
197156
static void exec(InArcType& iarc, std::pair<T, U>& s) {
198-
deserialize_impl<InArcType,
199-
T, gl_is_pod<T>::value >::exec(iarc, s.first);
200-
deserialize_impl<InArcType,
201-
U, gl_is_pod<U>::value >::exec(iarc, s.second);
157+
iarc >> s.first >> s.second;
202158
}
203159
};
204160

src/graphlab/serialization/has_load.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright (c) 2009 Carnegie Mellon University.
33
* All rights reserved.
44
*
@@ -26,9 +26,7 @@
2626

2727
#include <typeinfo>
2828

29-
/**
30-
Detects if a class has a load function implemented
31-
*/
29+
3230
namespace graphlab {
3331
namespace archive_detail {
3432

0 commit comments

Comments
 (0)