GraphLab: Distributed Graph-Parallel API  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Serialization

Classes

class  graphlab::iarchive
 The serialization input archive object which, provided with a reference to an istream, will read from the istream, providing deserialization capabilities. More...
class  graphlab::iarchive_soft_fail
 When this archive is used to deserialize an object, and the object does not support serialization, failure will only occur at runtime. Otherwise equivalent to graphlab::iarchive. More...
struct  graphlab::IS_POD_TYPE
 Inheriting from this type will force the serializer to treat the derived type as a POD type. More...
struct  graphlab::gl_is_pod< T >
 Tests if T is a POD type. More...
class  graphlab::oarchive
 The serialization output archive object which, provided with a reference to an ostream, will write to the ostream, providing serialization capabilities. More...
class  graphlab::oarchive_soft_fail
 When this archive is used to serialize an object, and the object does not support serialization, failure will only occur at runtime. Otherwise equivalent to graphlab::oarchive. More...
struct  graphlab::unsupported_serialize
 Inheritting from this class will prevent the serialization of the derived class. Used for debugging purposes. More...

Macros

#define BEGIN_OUT_OF_PLACE_LOAD(arc, tname, tval)
 Macro to make it easy to define out-of-place loads.
#define BEGIN_OUT_OF_PLACE_SAVE(arc, tname, tval)
 Macro to make it easy to define out-of-place saves.
#define GRAPHLAB_UNSERIALIZABLE(tname)
 A macro which disables the serialization of type so that it will fault at runtime.

Functions

template<typename OutArcType , typename RandomAccessIterator >
void graphlab::serialize_iterator (OutArcType &oarc, RandomAccessIterator begin, RandomAccessIterator end)
 Serializes the contents between the iterators begin and end.
template<typename OutArcType , typename InputIterator >
void graphlab::serialize_iterator (OutArcType &oarc, InputIterator begin, InputIterator end, size_t vsize)
 Serializes the contents between the iterators begin and end.
template<typename InArcType , typename T , typename OutputIterator >
void graphlab::deserialize_iterator (InArcType &iarc, OutputIterator result)
 The accompanying function to serialize_iterator() Reads elements from the stream and writes it to the output iterator.
template<typename T >
std::string graphlab::serialize_to_string (const T &t)
 Serializes a object to a string.
template<typename T >
void graphlab::deserialize_from_string (const std::string &s, T &t)
 Deserializes a object from a string.

Detailed Description


Macro Definition Documentation

#define BEGIN_OUT_OF_PLACE_LOAD (   arc,
  tname,
  tval 
)
Value:
namespace graphlab{ namespace archive_detail { \
template <typename InArcType> \
struct deserialize_impl<InArcType, tname, false>{ \
static void exec(InArcType& arc, tname & tval) {

Macro to make it easy to define out-of-place loads.

In the event that it is impractical to implement a save() and load() function in the class one wnats to serialize, it is necessary to define an "out of save" save and load.

See Out of Place Serialization for an example

Note:
important! this must be defined in the global namespace!

Definition at line 292 of file iarchive.hpp.

#define BEGIN_OUT_OF_PLACE_SAVE (   arc,
  tname,
  tval 
)
Value:
namespace graphlab{ namespace archive_detail { \
template <typename OutArcType> struct serialize_impl<OutArcType, tname, false> { \
static void exec(OutArcType& arc, const tname & tval) {

Macro to make it easy to define out-of-place saves.

In the event that it is impractical to implement a save() and load() function in the class one wnats to serialize, it is necessary to define an "out of save" save and load.

See Out of Place Serialization for an example

Note:
important! this must be defined in the global namespace!

Definition at line 328 of file oarchive.hpp.

#define GRAPHLAB_UNSERIALIZABLE (   tname)
Value:
BEGIN_OUT_OF_PLACE_LOAD(arc, tname, tval) \
ASSERT_MSG(false,"trying to deserialize an unserializable object"); \
END_OUT_OF_PLACE_LOAD() \
BEGIN_OUT_OF_PLACE_SAVE(arc, tname, tval) \
ASSERT_MSG(false,"trying to serialize an unserializable object"); \
END_OUT_OF_PLACE_SAVE() \

A macro which disables the serialization of type so that it will fault at runtime.

Writing GRAPHLAB_UNSERIALIZABLE(T) for some typename T in the global namespace will result in an assertion failure if any attempt is made to serialize or deserialize the type T. This is largely used for debugging purposes to enforce that certain types are never serialized.

Definition at line 64 of file unsupported_serialize.hpp.


Function Documentation

template<typename T >
void graphlab::deserialize_from_string ( const std::string &  s,
T &  t 
)
inline

Deserializes a object from a string.

Deserializes a serializable object t from a string using the deserializer.

Template Parameters:
Tthe type of object to deserialize. Typically will be inferred by the compiler.
Parameters:
sThe string to deserialize
tA reference to the object which will contain the deserialized object when the function returns
See also:
serialize_from_string()

Definition at line 72 of file serialize_to_from_string.hpp.

template<typename InArcType , typename T , typename OutputIterator >
void graphlab::deserialize_iterator ( InArcType &  iarc,
OutputIterator  result 
)

The accompanying function to serialize_iterator() Reads elements from the stream and writes it to the output iterator.

Note that this requires an additional template parameter T which is the "type of object to deserialize" This is necessary for instance for the map type. The map<T,U>::value_type is pair<const T,U>which is not useful since I cannot assign to it. In this case, T=pair<T,U>

Template Parameters:
OutArcTypeThe output archive type.
TThe type of values to deserialize
OutputIteratorThe type of the output iterator to be written to. This should not need to be specified. The compiler will typically infer this correctly.
Parameters:
iarcA reference to the input archive
resultThe output iterator to write to

Definition at line 118 of file iterator.hpp.

template<typename OutArcType , typename RandomAccessIterator >
void graphlab::serialize_iterator ( OutArcType &  oarc,
RandomAccessIterator  begin,
RandomAccessIterator  end 
)

Serializes the contents between the iterators begin and end.

This function prefers random access iterators since it needs a distance between the begin and end iterator. This function as implemented will work for other input iterators but is extremely inefficient.

Template Parameters:
OutArcTypeThe output archive type. This should not need to be specified. The compiler will typically infer this correctly.
RandomAccessIteratorThe iterator type. This should not need to be specified. The compiler will typically infer this correctly.
Parameters:
oarcA reference to the output archive to write to.
beginThe start of the iterator range to write.
endThe end of the iterator range to write.

Definition at line 54 of file iterator.hpp.

template<typename OutArcType , typename InputIterator >
void graphlab::serialize_iterator ( OutArcType &  oarc,
InputIterator  begin,
InputIterator  end,
size_t  vsize 
)

Serializes the contents between the iterators begin and end.

This functions takes all iterator types, but takes a "count" for efficiency. This count is checked and will return failure if the number of elements serialized does not match the count

Template Parameters:
OutArcTypeThe output archive type. This should not need to be specified. The compiler will typically infer this correctly.
InputIteratorThe iterator type. This should not need to be specified. The compiler will typically infer this correctly.
Parameters:
oarcA reference to the output archive to write to.
beginThe start of the iterator range to write.
endThe end of the iterator range to write.
vsizeThe distance between the iterators begin and end. Must match std::distance(begin, end);

Definition at line 85 of file iterator.hpp.

template<typename T >
std::string graphlab::serialize_to_string ( const T &  t)
inline

Serializes a object to a string.

Converts a serializable object t to a string using the serializer.

Template Parameters:
Tthe type of object to serialize. Typically will be inferred by the compiler.
Parameters:
tThe object to serializer
Returns:
A string containing a serialized form of t
See also:
deserialize_from_string()

Definition at line 46 of file serialize_to_from_string.hpp.