LSSTApplications  1.1.2+25,10.0+13,10.0+132,10.0+133,10.0+224,10.0+41,10.0+8,10.0-1-g0f53050+14,10.0-1-g4b7b172+19,10.0-1-g61a5bae+98,10.0-1-g7408a83+3,10.0-1-gc1e0f5a+19,10.0-1-gdb4482e+14,10.0-11-g3947115+2,10.0-12-g8719d8b+2,10.0-15-ga3f480f+1,10.0-2-g4f67435,10.0-2-gcb4bc6c+26,10.0-28-gf7f57a9+1,10.0-3-g1bbe32c+14,10.0-3-g5b46d21,10.0-4-g027f45f+5,10.0-4-g86f66b5+2,10.0-4-gc4fccf3+24,10.0-40-g4349866+2,10.0-5-g766159b,10.0-5-gca2295e+25,10.0-6-g462a451+1
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Public Attributes | List of all members
lsst::ap::ZoneEntryArray< EntryT > Struct Template Reference

Stores entries inside a single zone (a narrow declination stripe) in a sorted array. More...

#include <ZoneTypes.h>

Public Types

typedef EntryT::Chunk Chunk
 
typedef EntryT::Data Data
 

Public Member Functions

 ZoneEntryArray ()
 
 ~ZoneEntryArray ()
 
void init (int const capacity)
 
void insert (double const ra, double const dec, Data *const data, Chunk *const chunk, int const index)
 
void sort ()
 
void grow ()
 
int size () const
 
void clear ()
 
int findLte (boost::uint32_t const ra)
 
int findGte (boost::uint32_t const ra) const
 
void computeMatchParams (ZoneStripeChunkDecomposition const &zsc, double const radius)
 
template<typename FilterT >
int pack (FilterT &filter)
 
template<typename FunctionT >
void apply (FunctionT &function)
 

Public Attributes

EntryT * _entries
 
int _size
 
int _capacity
 
int _zone
 
boost::uint32_t _deltaRa
 

Detailed Description

template<typename EntryT>
struct lsst::ap::ZoneEntryArray< EntryT >

Stores entries inside a single zone (a narrow declination stripe) in a sorted array.

Definition at line 113 of file ZoneTypes.h.

Member Typedef Documentation

template<typename EntryT >
typedef EntryT::Chunk lsst::ap::ZoneEntryArray< EntryT >::Chunk

Definition at line 114 of file ZoneTypes.h.

template<typename EntryT >
typedef EntryT::Data lsst::ap::ZoneEntryArray< EntryT >::Data

Definition at line 115 of file ZoneTypes.h.

Constructor & Destructor Documentation

template<typename EntryT >
lsst::ap::ZoneEntryArray< EntryT >::ZoneEntryArray ( )

Definition at line 84 of file ZoneTypes.cc.

template<typename EntryT >
lsst::ap::ZoneEntryArray< EntryT >::~ZoneEntryArray ( )

Definition at line 89 of file ZoneTypes.cc.

89  {
90  if (_entries != 0) {
91  std::free(_entries);
92  _entries = 0;
93  }
94 }
EntryT * _entries
Definition: ZoneTypes.h:117

Member Function Documentation

template<typename EntryT >
template<typename FunctionT >
void lsst::ap::ZoneEntryArray< EntryT >::apply ( FunctionT &  function)

Given a functor that implements

void operator()(EntryT const &)

, applies it to every entry in the zone.

Definition at line 179 of file ZoneTypes.cc.

179  {
180  for (int i = 0; i < _size; ++i) {
181  function(_entries[i]);
182  }
183 }
int _size
Definition: ZoneTypes.h:118
EntryT * _entries
Definition: ZoneTypes.h:117
template<typename EntryT >
void lsst::ap::ZoneEntryArray< EntryT >::clear ( )
inline

Empties the zone (without deallocating/shrinking memory).

Definition at line 146 of file ZoneTypes.h.

146 { _size = 0; }
int _size
Definition: ZoneTypes.h:118
template<typename EntryT >
void lsst::ap::ZoneEntryArray< EntryT >::computeMatchParams ( ZoneStripeChunkDecomposition const &  zsc,
double const  radius 
)

Prepares for a distance based match with the given radius

Definition at line 137 of file ZoneTypes.cc.

140  {
141  double d1 = std::fabs(zsc.getZoneDecMin(_zone));
142  double d2 = std::fabs(zsc.getZoneDecMax(_zone));
143  _deltaRa = deltaRaToScaledInteger(maxAlpha(radius, d1 < d2 ? d2 : d1));
144 }
boost::uint32_t deltaRaToScaledInteger(double const delta)
Definition: SpatialUtil.h:258
int _zone
Definition: ZoneTypes.h:120
boost::uint32_t _deltaRa
Definition: ZoneTypes.h:121
double maxAlpha(double const theta, double const centerDec)
Definition: SpatialUtil.cc:279
template<typename EntryT >
int lsst::ap::ZoneEntryArray< EntryT >::findGte ( boost::uint32_t const  ra) const
inline

Finds the first entry with ra greater than or equal to the specified value.

Definition at line 170 of file ZoneTypes.h.

170  {
171  EntryT const * const entries = _entries;
172  int const end = _size;
173 
174  int sz = end;
175  int i = 0;
176 
177  while (sz > 0) {
178  int mid = sz >> 1;
179  if (entries[i + mid] < ra) {
180  i += mid + 1;
181  sz -= mid + 1;
182  } else {
183  sz = mid;
184  }
185  }
186  // if no entry was found, wrap to the smallest entry
187  return (i == end) ? 0 : i;
188  }
int _size
Definition: ZoneTypes.h:118
EntryT * _entries
Definition: ZoneTypes.h:117
template<typename EntryT >
int lsst::ap::ZoneEntryArray< EntryT >::findLte ( boost::uint32_t const  ra)
inline

Finds the last entry with ra less than or equal to the specified value.

Definition at line 149 of file ZoneTypes.h.

149  {
150  EntryT const * const entries = _entries;
151  int const last = _size - 1;
152 
153  int sz = last + 1;
154  int i = last;
155 
156  while (sz > 0) {
157  int mid = sz >> 1;
158  if (ra < entries[i - mid]) {
159  i -= mid + 1;
160  sz -= mid + 1;
161  } else {
162  sz = mid;
163  }
164  }
165  // if no entry was found, wrap to the largest entry
166  return (i < 0) ? last : i;
167  }
int _size
Definition: ZoneTypes.h:118
EntryT * _entries
Definition: ZoneTypes.h:117
template<typename EntryT >
void lsst::ap::ZoneEntryArray< EntryT >::grow ( )

Increases the size of the underlying array of entries by roughly 25% (and by at least 1).

Definition at line 122 of file ZoneTypes.cc.

122  {
123  int cap = _capacity >> 2;
124  cap = _capacity + (64 > cap ? 64 : cap);
125  EntryT * entries = static_cast<EntryT *>(std::realloc(_entries, sizeof(EntryT)*cap));
126  if (entries == 0) {
127  throw LSST_EXCEPT(lsst::pex::exceptions::MemoryError,
128  "failed to increase zone capacity");
129  }
130  _entries = entries;
131  _capacity = cap;
132 }
EntryT * _entries
Definition: ZoneTypes.h:117
int _capacity
Definition: ZoneTypes.h:119
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
template<typename EntryT >
void lsst::ap::ZoneEntryArray< EntryT >::init ( int const  capacity)

Initializes the zone, allocating space for the given number of entries.

Definition at line 99 of file ZoneTypes.cc.

99  {
100  if (capacity > 0) {
101  std::size_t const nb = sizeof(EntryT) * capacity;
102  EntryT * entries = static_cast<EntryT *>(std::malloc(nb));
103  if (entries == 0) {
104  throw LSST_EXCEPT(lsst::pex::exceptions::MemoryError,
105  "failed to allocate zone");
106  }
107  _entries = entries;
108  _capacity = capacity;
109  }
110 }
EntryT * _entries
Definition: ZoneTypes.h:117
int _capacity
Definition: ZoneTypes.h:119
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
template<typename EntryT >
void lsst::ap::ZoneEntryArray< EntryT >::insert ( double const  ra,
double const  dec,
Data *const  data,
Chunk *const  chunk,
int const  index 
)
inline

Inserts the given data item into the zone.

Definition at line 129 of file ZoneTypes.h.

129  {
130  int const sz = _size;
131  if (sz == _capacity) {
132  grow();
133  }
134  new(&_entries[sz]) EntryT(ra, dec, data, chunk, index);
135  _size = sz + 1;
136  }
void grow()
Definition: ZoneTypes.cc:122
int _size
Definition: ZoneTypes.h:118
EntryT * _entries
Definition: ZoneTypes.h:117
int _capacity
Definition: ZoneTypes.h:119
template<typename EntryT >
template<typename FilterT >
int lsst::ap::ZoneEntryArray< EntryT >::pack ( FilterT &  filter)

Given a functor that implements

bool operator()(EntryT const &)

, removes any entry e where filter(e) returns false from the zone.

Returns
the number of entries that were removed.

Definition at line 155 of file ZoneTypes.cc.

155  {
156  int src = 0;
157  int dst = 0;
158 
159  for ( ; src < _size; ++src) {
160  if (!filter(_entries[src])) {
161  continue;
162  }
163  if (dst != src) {
164  _entries[dst] = _entries[src];
165  }
166  ++dst;
167  }
168  _size = dst;
169  return src - dst;
170 }
int _size
Definition: ZoneTypes.h:118
EntryT * _entries
Definition: ZoneTypes.h:117
template<typename EntryT >
int lsst::ap::ZoneEntryArray< EntryT >::size ( ) const
inline

Returns the number of entries in the zone.

Definition at line 143 of file ZoneTypes.h.

143 { return _size; }
int _size
Definition: ZoneTypes.h:118
template<typename EntryT >
void lsst::ap::ZoneEntryArray< EntryT >::sort ( )

Sorts the zone entries on ra.

Definition at line 115 of file ZoneTypes.cc.

115  {
116  std::sort(_entries, _entries + _size);
117 }
int _size
Definition: ZoneTypes.h:118
EntryT * _entries
Definition: ZoneTypes.h:117

Member Data Documentation

template<typename EntryT >
int lsst::ap::ZoneEntryArray< EntryT >::_capacity

Definition at line 119 of file ZoneTypes.h.

template<typename EntryT >
boost::uint32_t lsst::ap::ZoneEntryArray< EntryT >::_deltaRa

Definition at line 121 of file ZoneTypes.h.

template<typename EntryT >
EntryT* lsst::ap::ZoneEntryArray< EntryT >::_entries

Definition at line 117 of file ZoneTypes.h.

template<typename EntryT >
int lsst::ap::ZoneEntryArray< EntryT >::_size

Definition at line 118 of file ZoneTypes.h.

template<typename EntryT >
int lsst::ap::ZoneEntryArray< EntryT >::_zone

Definition at line 120 of file ZoneTypes.h.


The documentation for this struct was generated from the following files: