File: msdatadescription.cpp

package info (click to toggle)
wsclean 3.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,968 kB
  • sloc: cpp: 85,742; python: 3,526; sh: 245; makefile: 21
file content (67 lines) | stat: -rw-r--r-- 2,256 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "msdatadescription.h"

#include "contiguousms.h"

#include "../main/settings.h"
#include "reorderedmsprovider.h"

#include <aocommon/io/serialostream.h>
#include <aocommon/io/serialistream.h>

#include <cassert>
#include <memory>

using schaapcommon::reordering::StorageManagerType;

namespace wsclean {

std::unique_ptr<MSProvider> MSDataDescription::GetProvider() const {
  if (_isReordered)
    return std::make_unique<ReorderedMsProvider>(_reorderedHandle, _partIndex,
                                                 _polarization);
  else
    return std::make_unique<ContiguousMS>(
        _filename, _dataColumnName, _modelColumnName, _modelStorageManager,
        _selection, _channel_selection, _polarization, _useMPI);
}

void MSDataDescription::Serialize(aocommon::SerialOStream& stream) const {
  // Serialization is only used with MPI.
  assert(_useMPI);
  stream.Bool(_isReordered)
      .UInt16(_polarization)
      .String(_filename)
      .String(_dataColumnName)
      .String(_modelColumnName)
      .UInt32(static_cast<unsigned>(_modelStorageManager))
      .Object(_selection)
      .UInt64(_channel_selection.Size());
  for (const schaapcommon::reordering::ChannelRange& range :
       _channel_selection) {
    stream.UInt64(range.data_desc_id).UInt64(range.start).UInt64(range.end);
  }
  stream.Object(_reorderedHandle).UInt64(_partIndex);
}

std::unique_ptr<MSDataDescription> MSDataDescription::Unserialize(
    aocommon::SerialIStream& stream) {
  std::unique_ptr<MSDataDescription> mdd(new MSDataDescription());
  stream.Bool(mdd->_isReordered)
      .UInt16(mdd->_polarization)
      .String(mdd->_filename)
      .String(mdd->_dataColumnName)
      .String(mdd->_modelColumnName);
  mdd->_modelStorageManager = static_cast<StorageManagerType>(stream.UInt32());
  stream.Object(mdd->_selection);
  const size_t n = stream.UInt64();
  for (size_t i = 0; i != n; ++i) {
    schaapcommon::reordering::ChannelRange& range =
        mdd->_channel_selection.EmplaceBack();
    stream.UInt64(range.data_desc_id).UInt64(range.start).UInt64(range.end);
  }
  stream.Object(mdd->_reorderedHandle).UInt64(mdd->_partIndex);
  mdd->_useMPI = true;  // Serialization only happens with MPI.
  return mdd;
}

}  // namespace wsclean