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 | Private Attributes | List of all members
lsst::ap::ZoneIndex< EntryT > Class Template Reference

Container for a sequence of adjacent zones. More...

#include <ZoneTypes.h>

Inheritance diagram for lsst::ap::ZoneIndex< EntryT >:
lsst.daf.base::Citizen

Public Types

typedef EntryT::Chunk Chunk
 
typedef EntryT::Data Data
 
typedef ZoneEntryArray< EntryT > Zone
 
- Public Types inherited from lsst.daf.base::Citizen
enum  { magicSentinel = 0xdeadbeef }
 
typedef unsigned long memId
 Type of the block's ID. More...
 
typedef memId(* memNewCallback )(const memId cid)
 A function used to register a callback. More...
 
typedef memId(* memCallback )(const Citizen *ptr)
 

Public Member Functions

 ZoneIndex (int const zonesPerDegree, int const zonesPerStripe, int const maxEntriesPerZoneEstimate)
 
void clear ()
 Removes all entries from every zone in the index. More...
 
int size () const
 Returns the number of entries in the index. More...
 
void setDecBounds (double const minDec, double const maxDec)
 Sets the range of declination values the index will accept data for. More...
 
void computeMatchParams (double const radius)
 Prepares for distance based matches of the given maximum radius. More...
 
void sort ()
 Sorts each zone in the index (on right ascension) More...
 
template<typename FilterT >
int pack (FilterT &filter)
 
template<typename FunctionT >
void apply (FunctionT &function)
 
void insert (double const ra, double const dec, Data *const data, Chunk *const chunk, int const index)
 
int getMinZone () const
 
int getMaxZone () const
 
ZonegetZone (int const zone)
 
ZonefirstZone (int const minZone, int const maxZone)
 
ZoneendZone (int const minZone, int const maxZone)
 
ZoneStripeChunkDecomposition
const & 
getDecomposition () const
 
- Public Member Functions inherited from lsst.daf.base::Citizen
 Citizen (const std::type_info &)
 
 Citizen (Citizen const &)
 
 ~Citizen ()
 
Citizenoperator= (Citizen const &)
 
std::string repr () const
 Return a string representation of a Citizen. More...
 
void markPersistent (void)
 Mark a Citizen as persistent and not destroyed until process end. More...
 
memId getId () const
 Return the Citizen's ID. More...
 

Private Attributes

ZoneStripeChunkDecomposition _zsc
 
boost::scoped_array< Zone_zones
 
int _capacity
 
int _minZone
 
int _maxZone
 

Additional Inherited Members

- Static Public Member Functions inherited from lsst.daf.base::Citizen
static bool hasBeenCorrupted ()
 Check all allocated blocks for corruption. More...
 
static memId getNextMemId ()
 Return the memId of the next object to be allocated. More...
 
static int init ()
 Called once when the memory system is being initialised. More...
 
static int census (int, memId startingMemId=0)
 How many active Citizens are there? More...
 
static void census (std::ostream &stream, memId startingMemId=0)
 Print a list of all active Citizens to stream, sorted by ID. More...
 
static const std::vector
< const Citizen * > * 
census ()
 Return a (newly allocated) std::vector of active Citizens sorted by ID. More...
 
static memId setNewCallbackId (memId id)
 Call the NewCallback when block is allocated. More...
 
static memId setDeleteCallbackId (memId id)
 Call the current DeleteCallback when block is deleted. More...
 
static memNewCallback setNewCallback (memNewCallback func)
 Set the NewCallback function. More...
 
static memCallback setDeleteCallback (memCallback func)
 Set the DeleteCallback function. More...
 
static memCallback setCorruptionCallback (memCallback func)
 Set the CorruptionCallback function. More...
 

Detailed Description

template<typename EntryT>
class lsst::ap::ZoneIndex< EntryT >

Container for a sequence of adjacent zones.

Definition at line 199 of file ZoneTypes.h.

Member Typedef Documentation

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

Definition at line 205 of file ZoneTypes.h.

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

Definition at line 206 of file ZoneTypes.h.

template<typename EntryT>
typedef ZoneEntryArray<EntryT> lsst::ap::ZoneIndex< EntryT >::Zone

Definition at line 207 of file ZoneTypes.h.

Constructor & Destructor Documentation

template<typename EntryT >
lsst::ap::ZoneIndex< EntryT >::ZoneIndex ( int const  zonesPerDegree,
int const  zonesPerStripe,
int const  maxEntriesPerZoneEstimate 
)

Definition at line 189 of file ZoneTypes.cc.

193  :
194  lsst::daf::base::Citizen(typeid(*this)),
195  _zsc(zonesPerDegree, zonesPerStripe, maxEntriesPerZoneEstimate),
196  _zones(),
197  _capacity(0),
198  _minZone(0),
199  _maxZone(-1)
200 {}
ZoneStripeChunkDecomposition _zsc
Definition: ZoneTypes.h:287
boost::scoped_array< Zone > _zones
Definition: ZoneTypes.h:288
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
Definition: Citizen.h:56

Member Function Documentation

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

Calls a functor implementing

void operator()(EntryT const &)

on every entry in the index.

Definition at line 321 of file ZoneTypes.cc.

321  {
322  int const numZones = _maxZone - _minZone + 1;
323  for (int z = 0; z < numZones; ++z) {
324  _zones[z].apply<FunctionT>(function);
325  }
326 }
boost::scoped_array< Zone > _zones
Definition: ZoneTypes.h:288
template<typename EntryT >
void lsst::ap::ZoneIndex< EntryT >::clear ( )

Removes all entries from every zone in the index.

Definition at line 205 of file ZoneTypes.cc.

205  {
206  for (int i = 0; i < _capacity; ++i) {
207  _zones[i].clear();
208  }
209 }
boost::scoped_array< Zone > _zones
Definition: ZoneTypes.h:288
template<typename EntryT >
void lsst::ap::ZoneIndex< EntryT >::computeMatchParams ( double const  radius)

Prepares for distance based matches of the given maximum radius.

Definition at line 269 of file ZoneTypes.cc.

269  {
270  int const numZones = _maxZone - _minZone + 1;
271  for (int t = 0; t < numZones; ++t) {
272  _zones[t].computeMatchParams(_zsc, radius);
273  }
274 }
ZoneStripeChunkDecomposition _zsc
Definition: ZoneTypes.h:287
boost::scoped_array< Zone > _zones
Definition: ZoneTypes.h:288
template<typename EntryT>
Zone* lsst::ap::ZoneIndex< EntryT >::endZone ( int const  minZone,
int const  maxZone 
)
inline

Returns a pointer to the zone following the last zone in the index within the given id range, or 0 if there is no such zone.

Definition at line 271 of file ZoneTypes.h.

271  {
272  if (maxZone < _minZone || minZone > _maxZone) {
273  return 0;
274  }
275  if (maxZone >= _maxZone) {
276  return &_zones[_maxZone - _minZone + 1];
277  }
278  return &_zones[maxZone - _minZone + 1];
279  }
boost::scoped_array< Zone > _zones
Definition: ZoneTypes.h:288
template<typename EntryT>
Zone* lsst::ap::ZoneIndex< EntryT >::firstZone ( int const  minZone,
int const  maxZone 
)
inline

Returns a pointer to the first zone in the index within the given id range, or 0 if there is no such zone.

Definition at line 257 of file ZoneTypes.h.

257  {
258  if (maxZone < _minZone || minZone > _maxZone) {
259  return 0;
260  }
261  if (minZone <= _minZone) {
262  return _zones.get();
263  }
264  return &_zones[minZone - _minZone];
265  }
boost::scoped_array< Zone > _zones
Definition: ZoneTypes.h:288
template<typename EntryT>
ZoneStripeChunkDecomposition const& lsst::ap::ZoneIndex< EntryT >::getDecomposition ( ) const
inline

Definition at line 281 of file ZoneTypes.h.

281  {
282  return _zsc;
283  }
ZoneStripeChunkDecomposition _zsc
Definition: ZoneTypes.h:287
template<typename EntryT>
int lsst::ap::ZoneIndex< EntryT >::getMaxZone ( ) const
inline

Returns the largest zone id in the index.

Definition at line 240 of file ZoneTypes.h.

240 { return _maxZone; }
template<typename EntryT>
int lsst::ap::ZoneIndex< EntryT >::getMinZone ( ) const
inline

Returns the smallest zone id in the index.

Definition at line 237 of file ZoneTypes.h.

237 { return _minZone; }
template<typename EntryT>
Zone* lsst::ap::ZoneIndex< EntryT >::getZone ( int const  zone)
inline

Returns a pointer to the zone with the given id, or 0 if the requested zone isn't in the index.

Definition at line 246 of file ZoneTypes.h.

246  {
247  if (zone >= _minZone && zone <= _maxZone) {
248  return &_zones[zone - _minZone];
249  }
250  return 0;
251  }
boost::scoped_array< Zone > _zones
Definition: ZoneTypes.h:288
template<typename EntryT>
void lsst::ap::ZoneIndex< EntryT >::insert ( double const  ra,
double const  dec,
Data *const  data,
Chunk *const  chunk,
int const  index 
)
inline

Inserts the given data item from the given chunk into the index.

Definition at line 229 of file ZoneTypes.h.

229  {
230  int const zone = _zsc.decToZone(data->getDec());
231  if (zone >= _minZone && zone <= _maxZone) {
232  _zones[zone - _minZone].insert(ra, dec, data, chunk, index);
233  }
234  }
int decToZone(double const dec) const
Definition: SpatialUtil.h:132
ZoneStripeChunkDecomposition _zsc
Definition: ZoneTypes.h:287
boost::scoped_array< Zone > _zones
Definition: ZoneTypes.h:288
template<typename EntryT >
template<typename FilterT >
int lsst::ap::ZoneIndex< EntryT >::pack ( FilterT &  filter)

Given a functor that implements

bool operator()(EntryT const &)

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

Returns
the number of entries that were removed.

Definition at line 299 of file ZoneTypes.cc.

299  {
300  int const numZones = _maxZone - _minZone + 1;
301  int numPacked = 0;
302 #if LSST_AP_HAVE_OPEN_MP
303 # pragma omp parallel for default(shared) \
304  reduction(+:numPacked) \
305  schedule(static,8)
306 #endif
307  for (int z = 0; z < numZones; ++z) {
308  int np = _zones[z].pack<FilterT>(filter);
309  numPacked = numPacked + np;
310  } // end of parallel for
311  return numPacked;
312 }
boost::scoped_array< Zone > _zones
Definition: ZoneTypes.h:288
template<typename EntryT >
void lsst::ap::ZoneIndex< EntryT >::setDecBounds ( double const  minDec,
double const  maxDec 
)

Sets the range of declination values the index will accept data for.

Definition at line 225 of file ZoneTypes.cc.

225  {
226  int minZone = _zsc.decToZone(minDec);
227  int maxZone = _zsc.decToZone(maxDec);
228  if (maxZone < minZone) {
229  throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
230  "min/max zone ids inverted");
231  }
232  int const cap = maxZone - minZone + 1;
233  if (cap >= _capacity) {
234  int const worst = _zsc.getMaxEntriesPerZoneEstimate();
235  boost::scoped_array<Zone> zones(new Zone[cap]);
236  int i = 0;
237  for ( ; i < _capacity; ++i) {
238  zones[i] = _zones[i];
239  }
240  for ( ; i < cap; ++i) {
241  zones[i].init(worst);
242  }
243  // transfer zone ownership from old zone array to new array
244  for (i = 0; i < _capacity; ++i) {
245  _zones[i]._entries = 0;
246  _zones[i]._size = 0;
247  _zones[i]._capacity = 0;
248  }
249  using std::swap;
250  swap(_zones, zones);
251  _capacity = cap;
252  }
253 
254  int i = 0;
255  for ( ; i <= maxZone - minZone; ++i) {
256  _zones[i].clear();
257  _zones[i]._zone = i + minZone;
258  }
259  for ( ; i < _capacity; ++i) {
260  _zones[i].clear();
261  }
262  _minZone = minZone;
263  _maxZone = maxZone;
264 }
void swap(Ellipse< DataT > &a, Ellipse< DataT > &b)
Definition: EllipseTypes.h:90
int decToZone(double const dec) const
Definition: SpatialUtil.h:132
void swap(ImageBase< PixelT > &a, ImageBase< PixelT > &b)
Definition: Image.cc:291
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
ZoneEntryArray< EntryT > Zone
Definition: ZoneTypes.h:207
ZoneStripeChunkDecomposition _zsc
Definition: ZoneTypes.h:287
boost::scoped_array< Zone > _zones
Definition: ZoneTypes.h:288
template<typename EntryT >
int lsst::ap::ZoneIndex< EntryT >::size ( ) const

Returns the number of entries in the index.

Definition at line 214 of file ZoneTypes.cc.

214  {
215  int sz = 0;
216  for (int i = 0; i <= _maxZone - _minZone; ++i) {
217  sz += _zones[i].size();
218  }
219  return sz;
220 }
boost::scoped_array< Zone > _zones
Definition: ZoneTypes.h:288
template<typename EntryT >
void lsst::ap::ZoneIndex< EntryT >::sort ( )

Sorts each zone in the index (on right ascension)

Definition at line 279 of file ZoneTypes.cc.

279  {
280  int const numZones = _maxZone - _minZone + 1;
281 #if LSST_AP_HAVE_OPEN_MP
282 # pragma omp parallel for default(shared) \
283  schedule(static,8)
284 #endif
285  for (int t = 0; t < numZones; ++t) {
286  _zones[t].sort();
287  } // end of parallel for
288 }
boost::scoped_array< Zone > _zones
Definition: ZoneTypes.h:288

Member Data Documentation

template<typename EntryT>
int lsst::ap::ZoneIndex< EntryT >::_capacity
private

Definition at line 289 of file ZoneTypes.h.

template<typename EntryT>
int lsst::ap::ZoneIndex< EntryT >::_maxZone
private

Definition at line 291 of file ZoneTypes.h.

template<typename EntryT>
int lsst::ap::ZoneIndex< EntryT >::_minZone
private

Definition at line 290 of file ZoneTypes.h.

template<typename EntryT>
boost::scoped_array<Zone> lsst::ap::ZoneIndex< EntryT >::_zones
private

Definition at line 288 of file ZoneTypes.h.

template<typename EntryT>
ZoneStripeChunkDecomposition lsst::ap::ZoneIndex< EntryT >::_zsc
private

Definition at line 287 of file ZoneTypes.h.


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