HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_PageArray.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GA_PageArray.h (GA Library, C++)
7  *
8  * COMMENTS: An array class with special handling of constant pages and
9  * shared page data, specialized for GA_Offset.
10  */
11 
12 #pragma once
13 
14 #ifndef __GA_PageArray__
15 #define __GA_PageArray__
16 
17 #include "GA_Defaults.h"
18 #include "GA_Iterator.h"
19 #include "GA_Range.h"
20 #include "GA_Types.h"
21 #include <UT/UT_Assert.h>
22 #include <UT/UT_BitArray.h>
23 #include <UT/UT_FixedVector.h>
24 #include <UT/UT_JSONDefines.h>
25 #include <UT/UT_PageArray.h>
26 #include <UT/UT_Storage.h>
27 #include <UT/UT_UniquePtr.h>
28 #include <UT/UT_VectorTypes.h>
29 #include <SYS/SYS_Inline.h>
30 #include <SYS/SYS_Math.h>
31 #include <SYS/SYS_Types.h>
32 #include <SYS/SYS_TypeTraits.h>
33 
34 class GA_Defragment;
35 class GA_LoadMap;
36 class GA_MergeMap;
37 class GA_SaveOptions;
38 class UT_JSONParser;
39 class UT_JSONWriter;
40 template <typename T> class UT_Array;
41 
44 {
45  switch (storage)
46  {
48  return GA_STORE_INVALID;
49  case UT_Storage::INT8:
50  return GA_STORE_INT8;
51  case UT_Storage::UINT8:
52  return GA_STORE_UINT8;
53  case UT_Storage::INT16:
54  return GA_STORE_INT16;
55  case UT_Storage::INT32:
56  return GA_STORE_INT32;
57  case UT_Storage::INT64:
58  return GA_STORE_INT64;
59  case UT_Storage::REAL16:
60  return GA_STORE_REAL16;
61  case UT_Storage::REAL32:
62  return GA_STORE_REAL32;
63  case UT_Storage::REAL64:
64  return GA_STORE_REAL64;
65  }
66  UT_ASSERT_MSG_P(0, "Unhandled UT_Storage value!");
67  return GA_STORE_INVALID;
68 }
69 
72 {
73  switch (storage)
74  {
75  case GA_STORE_BOOL:
76  case GA_STORE_INVALID:
77  case GA_STORE_STRING:
78  case GA_STORE_DICT:
79  return UT_Storage::INVALID;
80  case GA_STORE_INT8:
81  return UT_Storage::INT8;
82  case GA_STORE_UINT8:
83  return UT_Storage::UINT8;
84  case GA_STORE_INT16:
85  return UT_Storage::INT16;
86  case GA_STORE_INT32:
87  return UT_Storage::INT32;
88  case GA_STORE_INT64:
89  return UT_Storage::INT64;
90  case GA_STORE_REAL16:
91  return UT_Storage::REAL16;
92  case GA_STORE_REAL32:
93  return UT_Storage::REAL32;
94  case GA_STORE_REAL64:
95  return UT_Storage::REAL64;
96  }
97  UT_ASSERT_MSG_P(0, "Unhandled GA_Storage value!");
98  return UT_Storage::INVALID;
99 }
100 
101 template<typename DATA_T=void,exint TSIZE=-1,bool TABLEHARDENED=true,bool PAGESHARDENED=false>
102 class GA_PageArray : public UT_PageArray<DATA_T, TSIZE, TABLEHARDENED, PAGESHARDENED, GA_PAGE_BITS, GA_Offset>
103 {
104 public:
107  using Base::get;
108  using Base::getPageData;
109  using Base::getRange;
110  using Base::getTupleSize;
111  using Base::getVector;
112  using Base::hardenPage;
114  using Base::isPageConstant;
115  using Base::moveRange;
116  using Base::numPages;
117  using Base::set;
118  using Base::setConstant;
119  using Base::setPageConstant;
120  using Base::setRange;
121  using Base::setSize;
122  using Base::setVector;
123  using Base::size;
124  using Base::swapRange;
125  using Base::thePageSize;
126  using Base::thePageMask;
127  using Base::tryCompressPage;
128  using Base::hardenTable;
129 private:
130  using typename Base::NotVoidType;
132  using Base::isEqual;
133  using Base::isZero;
134 public:
135 
136  /// The default constructor can only be used if the tuple size
137  /// and storage type are known at compile time.
138  /// Unfortunately, this can't be asserted at compile time, because
139  /// compilers aren't all that bright, but Base asserts it at runtime
140  /// if paranoid asserts are on.
142  {}
143 
144  /// This constructor can only be used if the storage type is
145  /// known at compile time, but the tuple size is not.
146  GA_PageArray(exint tuplesize) : Base(tuplesize)
147  {}
148 
149  /// This constructor can only be used if the storage type is
150  /// known at compile time, but the tuple size is not.
152  {}
153 
154  /// This constructor can only be used if the tuple size and
155  /// storage type are unknown at compile time.
156  GA_PageArray(exint tuplesize, UT_Storage storage) : Base(tuplesize, storage)
157  {}
158 
159  /// This constructor can only be used if the tuple size and
160  /// storage type are unknown at compile time.
161  GA_PageArray(exint tuplesize, GA_Storage storage) : Base(tuplesize, GAStorageToUTStorage(storage))
162  {}
163 
164  /// Get the storage type for each component of this GA_PageArray
167  {
169  return UTStorageToGAStorage(storage);
170  }
171  /// Set the storage type for each component of this GA_PageArray
173  {
174  UT_Storage utstorage = GAStorageToUTStorage(storage);
175  Base::setStorage(utstorage);
176  }
177 
178  template<typename SRC_T>
179  void setConstant(const GA_Range &range, SRC_T val)
180  {
181  if (!SYSisSame<DATA_T,void>())
182  {
183  // Easy case, where the storage type is known at compile time.
184  NotVoidType dval(val);
185 
187  GA_Offset end;
188  for (GA_Iterator it(range); it.fullBlockAdvance(start, end); )
189  {
190  Base::setConstant(start, end, dval);
191  }
192  return;
193  }
194 
195  // Hard case, where the storage type is not known at compile time.
197  switch (storage)
198  {
199  case UT_Storage::INT8:
200  castType<int8>().setConstant(range, int8(val)); return;
201  case UT_Storage::UINT8:
202  castType<uint8>().setConstant(range, uint8(val)); return;
203  case UT_Storage::INT16:
204  castType<int16>().setConstant(range, int16(val)); return;
205  case UT_Storage::INT32:
206  castType<int32>().setConstant(range, int32(val)); return;
207  case UT_Storage::INT64:
208  castType<int64>().setConstant(range, int64(val)); return;
209  case UT_Storage::REAL16:
210  castType<fpreal16>().setConstant(range, fpreal16(val)); return;
211  case UT_Storage::REAL32:
212  castType<fpreal32>().setConstant(range, fpreal32(val)); return;
213  case UT_Storage::REAL64:
214  castType<fpreal64>().setConstant(range, fpreal64(val)); return;
215  case UT_Storage::INVALID:
216  UT_ASSERT_MSG(0, "Can't have a GA_PageArray with invalid storage!");
217  return;
218  }
219  }
220 
221  void setConstant(const GA_Range &range, const GA_Defaults &defaults)
222  {
223  if (!SYSisSame<DATA_T,void>())
224  {
226  GA_Offset end;
227  for (GA_Iterator it(range); it.fullBlockAdvance(start, end); )
228  {
229  Base::setConstant(start, end, defaults);
230  }
231  return;
232  }
233 
234  // Hard case, where the storage type is not known at compile time.
236  switch (storage)
237  {
238  case UT_Storage::INT8:
239  castType<int8>().setConstant(range, defaults); return;
240  case UT_Storage::UINT8:
241  castType<uint8>().setConstant(range, defaults); return;
242  case UT_Storage::INT16:
243  castType<int16>().setConstant(range, defaults); return;
244  case UT_Storage::INT32:
245  castType<int32>().setConstant(range, defaults); return;
246  case UT_Storage::INT64:
247  castType<int64>().setConstant(range, defaults); return;
248  case UT_Storage::REAL16:
249  castType<fpreal16>().setConstant(range, defaults); return;
250  case UT_Storage::REAL32:
251  castType<fpreal32>().setConstant(range, defaults); return;
252  case UT_Storage::REAL64:
253  castType<fpreal64>().setConstant(range, defaults); return;
254  case UT_Storage::INVALID:
255  UT_ASSERT_MSG(0, "Can't have a GA_PageArray with invalid storage!");
256  return;
257  }
258  }
259 
262  {
263  Base::setConstant(start, end, v);
264  }
265 
266  template<typename SRC_T>
268  {
269  if (!SYSisSame<DATA_T,void>())
270  {
271  // Easy case, where the storage type is known at compile time.
272  NotVoidType dval(val);
273 
274  Base::setConstant(start, end, dval);
275  return;
276  }
277 
278  // Hard case, where the storage type is not known at compile time.
280  switch (storage)
281  {
282  case UT_Storage::INT8:
283  castType<int8>().setConstant(start, end, int8(val)); return;
284  case UT_Storage::UINT8:
285  castType<uint8>().setConstant(start, end, uint8(val)); return;
286  case UT_Storage::INT16:
287  castType<int16>().setConstant(start, end, int16(val)); return;
288  case UT_Storage::INT32:
289  castType<int32>().setConstant(start, end, int32(val)); return;
290  case UT_Storage::INT64:
291  castType<int64>().setConstant(start, end, int64(val)); return;
292  case UT_Storage::REAL16:
293  castType<fpreal16>().setConstant(start, end, fpreal16(val)); return;
294  case UT_Storage::REAL32:
295  castType<fpreal32>().setConstant(start, end, fpreal32(val)); return;
296  case UT_Storage::REAL64:
297  castType<fpreal64>().setConstant(start, end, fpreal64(val)); return;
298  case UT_Storage::INVALID:
299  UT_ASSERT_MSG(0, "Can't have a GA_PageArray with invalid storage!");
300  return;
301  }
302  }
303 
304  template<typename SRC_T>
306  {
307  if (!SYSisSame<DATA_T,void>())
308  {
309  // Easy case, where the storage type is known at compile time.
311 
313  GA_Offset end;
314  for (GA_Iterator it(range); it.fullBlockAdvance(start, end); )
315  {
316  Base::setConstant(start, end, dval);
317  }
318  return;
319  }
320 
321  // Hard case, where the storage type is not known at compile time.
323  switch (storage)
324  {
325  case UT_Storage::INT8:
326  castType<int8>().setConstantVector(range, UT_FixedVector<int8,theSafeTupleSize>(val)); return;
327  case UT_Storage::UINT8:
328  castType<uint8>().setConstantVector(range, UT_FixedVector<uint8,theSafeTupleSize>(val)); return;
329  case UT_Storage::INT16:
330  castType<int16>().setConstantVector(range, UT_FixedVector<int16,theSafeTupleSize>(val)); return;
331  case UT_Storage::INT32:
332  castType<int32>().setConstantVector(range, UT_FixedVector<int32,theSafeTupleSize>(val)); return;
333  case UT_Storage::INT64:
334  castType<int64>().setConstantVector(range, UT_FixedVector<int64,theSafeTupleSize>(val)); return;
335  case UT_Storage::REAL16:
336  castType<fpreal16>().setConstantVector(range, UT_FixedVector<fpreal16,theSafeTupleSize>(val)); return;
337  case UT_Storage::REAL32:
338  castType<fpreal32>().setConstantVector(range, UT_FixedVector<fpreal32,theSafeTupleSize>(val)); return;
339  case UT_Storage::REAL64:
340  castType<fpreal64>().setConstantVector(range, UT_FixedVector<fpreal64,theSafeTupleSize>(val)); return;
341  case UT_Storage::INVALID:
342  UT_ASSERT_MSG(0, "Can't have a GA_PageArray with invalid storage!");
343  return;
344  }
345  }
346 
347  template<typename SRC_T>
349  {
350  if (!SYSisSame<DATA_T,void>())
351  {
352  // Easy case, where the storage type is known at compile time.
354 
355  Base::setConstant(start, end, dval);
356  return;
357  }
358 
359  // Hard case, where the storage type is not known at compile time.
361  switch (storage)
362  {
363  case UT_Storage::INT8:
364  castType<int8>().setConstantVector(start, end, UT_FixedVector<int8,theSafeTupleSize>(val)); return;
365  case UT_Storage::UINT8:
366  castType<uint8>().setConstantVector(start, end, UT_FixedVector<uint8,theSafeTupleSize>(val)); return;
367  case UT_Storage::INT16:
368  castType<int16>().setConstantVector(start, end, UT_FixedVector<int16,theSafeTupleSize>(val)); return;
369  case UT_Storage::INT32:
370  castType<int32>().setConstantVector(start, end, UT_FixedVector<int32,theSafeTupleSize>(val)); return;
371  case UT_Storage::INT64:
372  castType<int64>().setConstantVector(start, end, UT_FixedVector<int64,theSafeTupleSize>(val)); return;
373  case UT_Storage::REAL16:
374  castType<fpreal16>().setConstantVector(start, end, UT_FixedVector<fpreal16,theSafeTupleSize>(val)); return;
375  case UT_Storage::REAL32:
376  castType<fpreal32>().setConstantVector(start, end, UT_FixedVector<fpreal32,theSafeTupleSize>(val)); return;
377  case UT_Storage::REAL64:
378  castType<fpreal64>().setConstantVector(start, end, UT_FixedVector<fpreal64,theSafeTupleSize>(val)); return;
379  case UT_Storage::INVALID:
380  UT_ASSERT_MSG(0, "Can't have a GA_PageArray with invalid storage!");
381  return;
382  }
383  }
384 
385  /// NOTE: values must have a number of values equal to the tuple size.
386  template<typename SRC_T>
387  void setConstant(const GA_Range &range, const SRC_T *values)
388  {
389  if (!SYSisSame<DATA_T,void>())
390  {
392  GA_Offset end;
393  for (GA_Iterator it(range); it.fullBlockAdvance(start, end); )
394  {
395  Base::setConstant(start, end, values);
396  }
397 
398  return;
399  }
400 
401  // Hard case, where the storage type is not known at compile time.
403  switch (storage)
404  {
405  case UT_Storage::INT8:
406  castType<int8>().setConstant(range, values); return;
407  case UT_Storage::UINT8:
408  castType<uint8>().setConstant(range, values); return;
409  case UT_Storage::INT16:
410  castType<int16>().setConstant(range, values); return;
411  case UT_Storage::INT32:
412  castType<int32>().setConstant(range, values); return;
413  case UT_Storage::INT64:
414  castType<int64>().setConstant(range, values); return;
415  case UT_Storage::REAL16:
416  castType<fpreal16>().setConstant(range, values); return;
417  case UT_Storage::REAL32:
418  castType<fpreal32>().setConstant(range, values); return;
419  case UT_Storage::REAL64:
420  castType<fpreal64>().setConstant(range, values); return;
421  case UT_Storage::INVALID:
422  UT_ASSERT_MSG(0, "Can't have a GA_PageArray with invalid storage!");
423  return;
424  }
425  }
426 
427  /// NOTE: values must have a number of values equal to the tuple size.
428  template<typename SRC_T>
431  {
432  Base::setConstant(start, end, values);
433  }
434 
435  /// Include GA_PageArrayImpl.h to call this.
436  void defragment(const GA_Defragment &defrag);
437 
438  /// Include GA_PageArrayImpl.h to call this.
439  template<typename SRC_DATA_T,exint SRC_TSIZE,bool SRC_TABLEHARDENED,bool SRC_PAGESHARDENED>
441 
442  template<typename SRC_DATA_T,exint SRC_TSIZE,bool SRC_TABLEHARDENED,bool SRC_PAGESHARDENED>
444  {
445  GA_Iterator destit(destrange);
446  GA_Iterator srcit(srcrange);
447 
448  GA_Offset deststart = GA_INVALID_OFFSET;
449  GA_Offset destend = GA_INVALID_OFFSET;
450  GA_Offset srcstart = GA_INVALID_OFFSET;
451  GA_Offset srcend = GA_INVALID_OFFSET;
452 
453  while (true)
454  {
455  // If either range runs out, stop.
456  if (deststart == destend)
457  {
458  if (!destit.fullBlockAdvance(deststart, destend))
459  break;
460  }
461  if (srcstart == srcend)
462  {
463  if (!srcit.fullBlockAdvance(srcstart, srcend))
464  break;
465  }
466 
467  GA_Offset nelements = SYSmin(destend-deststart, srcend-srcstart);
468 
469  moveRange(src, srcstart, deststart, nelements);
470 
471  deststart += nelements;
472  srcstart += nelements;
473  }
474  }
475 
476  template<typename T>
477  void getRange(const GA_Range &srcrange, T *dest) const
478  {
479  if (SYSisSame<DATA_T,void>())
480  {
481  // Hard case, where the storage type is not known at compile time.
483  switch (storage)
484  {
485  case UT_Storage::INT8:
486  castType<int8>().getRange(srcrange, dest); return;
487  case UT_Storage::UINT8:
488  castType<uint8>().getRange(srcrange, dest); return;
489  case UT_Storage::INT16:
490  castType<int16>().getRange(srcrange, dest); return;
491  case UT_Storage::INT32:
492  castType<int32>().getRange(srcrange, dest); return;
493  case UT_Storage::INT64:
494  castType<int64>().getRange(srcrange, dest); return;
495  case UT_Storage::REAL16:
496  castType<fpreal16>().getRange(srcrange, dest); return;
497  case UT_Storage::REAL32:
498  castType<fpreal32>().getRange(srcrange, dest); return;
499  case UT_Storage::REAL64:
500  castType<fpreal64>().getRange(srcrange, dest); return;
501  case UT_Storage::INVALID:
502  UT_ASSERT_MSG(0, "Can't have a GA_PageArray with invalid storage!");
503  return;
504  }
505  return;
506  }
507 
508  int tuplesize = getTupleSize();
509 
510  // Cast to optimize for small tuple sizes
511  if (TSIZE == -1 && tuplesize <= 3)
512  {
513  if (tuplesize == 1)
514  castTupleSize<1>().getRange(srcrange, dest);
515  else if (tuplesize == 2)
516  castTupleSize<2>().getRange(srcrange, dest);
517  else if (tuplesize == 3)
518  castTupleSize<3>().getRange(srcrange, dest);
519  return;
520  }
521 
523  GA_Offset end;
524  for (GA_Iterator it(srcrange); it.fullBlockAdvance(start, end); )
525  {
526  GA_Offset nelements = end-start;
527  getRange(start, nelements, dest);
528  dest += GA_Size(nelements);
529  }
530  }
531 
532  template<typename T>
533  void setRange(const GA_Range &destrange, const T *src)
534  {
535  if (SYSisSame<DATA_T,void>())
536  {
537  // Hard case, where the storage type is not known at compile time.
539  switch (storage)
540  {
541  case UT_Storage::INT8:
542  castType<int8>().setRange(destrange, src); return;
543  case UT_Storage::UINT8:
544  castType<uint8>().setRange(destrange, src); return;
545  case UT_Storage::INT16:
546  castType<int16>().setRange(destrange, src); return;
547  case UT_Storage::INT32:
548  castType<int32>().setRange(destrange, src); return;
549  case UT_Storage::INT64:
550  castType<int64>().setRange(destrange, src); return;
551  case UT_Storage::REAL16:
552  castType<fpreal16>().setRange(destrange, src); return;
553  case UT_Storage::REAL32:
554  castType<fpreal32>().setRange(destrange, src); return;
555  case UT_Storage::REAL64:
556  castType<fpreal64>().setRange(destrange, src); return;
557  case UT_Storage::INVALID:
558  UT_ASSERT_MSG(0, "Can't have a GA_PageArray with invalid storage!");
559  return;
560  }
561  return;
562  }
563 
564  int tuplesize = getTupleSize();
565 
566  // Cast to optimize for small tuple sizes
567  if (TSIZE == -1 && tuplesize <= 3)
568  {
569  if (tuplesize == 1)
570  castTupleSize<1>().setRange(destrange, src);
571  else if (tuplesize == 2)
572  castTupleSize<2>().setRange(destrange, src);
573  else if (tuplesize == 3)
574  castTupleSize<3>().setRange(destrange, src);
575  return;
576  }
577 
579  GA_Offset end;
580  for (GA_Iterator it(destrange); it.fullBlockAdvance(start, end); )
581  {
582  GA_Offset nelements = end-start;
583  setRange(start, nelements, src);
584  src += GA_Size(nelements);
585  }
586  }
587 
588  /// For each page, this sets a bit in bits iff there's a chance that
589  /// the data in a page of this may be different from the data in the
590  /// corresponding page of that. It will not clear bits.
591  /// bits must be pre-sized to at least the number of pages in
592  /// this, (which must be equal to the size of that). that must
593  /// have the same tuple size and storage type as this.
594  /// It will only check pointers and constant values. It will not
595  /// compare full pages of data.
596  void comparePages(UT_BitArray &bits, const ThisType &that) const
597  {
598  // Calling getPageData requires that DATA_T be defined, so switch.
599  if (SYSisSame<DATA_T,void>())
600  {
601  // Hard case, where the storage type is not known at compile time.
603  switch (storage)
604  {
605  case UT_Storage::INT8:
606  castType<int8>().comparePages(bits, that.castType<int8>()); return;
607  case UT_Storage::UINT8:
608  castType<uint8>().comparePages(bits, that.castType<uint8>()); return;
609  case UT_Storage::INT16:
610  castType<int16>().comparePages(bits, that.castType<int16>()); return;
611  case UT_Storage::INT32:
612  castType<int32>().comparePages(bits, that.castType<int32>()); return;
613  case UT_Storage::INT64:
614  castType<int64>().comparePages(bits, that.castType<int64>()); return;
615  case UT_Storage::REAL16:
616  castType<fpreal16>().comparePages(bits, that.castType<fpreal16>()); return;
617  case UT_Storage::REAL32:
618  castType<fpreal32>().comparePages(bits, that.castType<fpreal32>()); return;
619  case UT_Storage::REAL64:
620  castType<fpreal64>().comparePages(bits, that.castType<fpreal64>()); return;
621  case UT_Storage::INVALID:
622  UT_ASSERT_MSG(0, "Can't have a GA_PageArray with invalid storage!");
623  return;
624  }
625  return;
626  }
627 
628  UT_ASSERT(getTupleSize() == that.getTupleSize());
629  UT_ASSERT(getStorage() == that.getStorage());
630 
631  UT_PageNum npages = numPages(size());
632  UT_ASSERT(npages == numPages(that.size()));
633  for (UT_PageNum pagei = 0; pagei < npages; ++pagei)
634  {
635  const NotVoidType *thisdata = getPageData(pagei);
636  const NotVoidType *thatdata = that.getPageData(pagei);
637  if (thisdata == thatdata)
638  continue;
639 
640  if (!thisdata || !thatdata ||
641  !isPageConstant(pagei) || !that.isPageConstant(pagei) ||
642  !isEqual(thisdata, thatdata, getTupleSize()))
643  {
644  bits.setBitFast(pagei, true);
645  }
646  }
647  }
648 
649  /// Save data to a JSON stream
650  /// Include GA_PageArrayImpl.h to call this.
651  bool jsonSave(UT_JSONWriter &w, const GA_Range &range,
652  const GA_SaveOptions *options = nullptr,
653  const UT_IntArray *map = nullptr, int defvalue=-1) const;
654 
655  /// Load data from a JSON stream
656  /// Include GA_PageArrayImpl.h to call this.
657  bool jsonLoad(UT_JSONParser &p,
658  const GA_LoadMap &map, GA_AttributeOwner owner);
659 
660 private:
661  /// These are just used internally by jsonSave
662  /// @{
663  template<typename MAP_ARRAY_CLASS>
664  bool jsonSaveConstantOutputPageFlags(
665  UT_JSONWriter &w, const GA_Range &range,
666  UT_UniquePtr<UT_BitArray> &const_page_flags) const;
667  static bool
668  jsonWriteDataSpan(
669  UT_JSONWriter &w,
670  const NotVoidType *page_data,
671  exint length, exint tuplesize,
672  bool const_output, bool const_input,
673  const UT_IntArray *map, int defvalue,
675  bool jsonSaveRawPageData(
676  UT_JSONWriter &w, const GA_Range &range,
677  const UT_BitArray *const_page_flags,
678  UT_JID jid_storage,
679  const UT_IntArray *map, int defvalue) const;
680 
681  class ga_SubPageBlock;
682 
683  static void buildOutputToInternalPageMap(
684  const GA_Range &range,
685  UT_Array<GA_PageNum> &map);
686  static void buildOutputToInternalPageMap(
687  const GA_Range &range,
689  GA_Size marshallConstantFlagsForOutputPages(
690  const UT_Array<GA_PageNum> &map,
691  UT_BitArray &flags) const;
692  GA_Size marshallConstantFlagsForOutputPages(
693  const UT_Array<ga_SubPageBlock> &map,
694  UT_BitArray &flags) const;
696  static bool isSubPageConstant(
697  const NotVoidType *page,
699  const exint tuplesize,
700  const NotVoidType *value);
701 
702  template<bool ARRAY_OF_ARRAYS>
703  bool jsonSaveAsArray(UT_JSONWriter &w, const GA_Range &range, UT_JID jid_storage,
704  const UT_IntArray *map, int defvalue) const;
705  /// @}
706 
707 
708  /// These are just used internally by jsonLoad
709  /// @{
710  class LoadComponentArrayFunctor;
711 
712  bool jsonLoadRawPageData(
713  UT_JSONParser &p,
714  const GA_LoadMap &map,
715  GA_AttributeOwner owner,
716  GA_Size page_size,
717  const int *packing,
718  int n_packing_entries,
719  const UT_UniquePtr<UT_BitArray> *const constant_page_flags);
720  /// @}
721 
723  static UT_JID GAStorageToJID(GA_Storage storage);
724 
725 public:
726 
727  /// This is for setting the DATA_T template after checking getStorage(),
728  /// if DATA_T wasn't already known.
729  /// @{
730  template<typename DEST_DATA_T>
732  castType() const
733  {
737  }
738  template<typename DEST_DATA_T>
741  {
745  }
746  /// @}
747 
748  /// This is for setting the TSIZE template after checking getTupleSize(),
749  /// if TSIZE wasn't already known.
750  /// @{
751  template<exint DEST_TSIZE>
754  {
755  UT_ASSERT_P(TSIZE == -1 || TSIZE == DEST_TSIZE);
756  UT_ASSERT_P(getTupleSize() == DEST_TSIZE);
758  }
759  template<exint DEST_TSIZE>
762  {
763  UT_ASSERT_P(TSIZE == -1 || TSIZE == DEST_TSIZE);
764  UT_ASSERT_P(getTupleSize() == DEST_TSIZE);
766  }
767  /// @}
768 };
769 
770 #endif
SYS_FORCE_INLINE bool isPageConstant(UT_PageNum pagenum) const
Returns true iff the specified page is constant-compressed.
GLbitfield flags
Definition: glcorearb.h:1596
int int32
Definition: SYS_Types.h:39
GLenum GLint * range
Definition: glcorearb.h:1925
SYS_FORCE_INLINE GA_PageArray< DATA_T, DEST_TSIZE, TABLEHARDENED, PAGESHARDENED > & castTupleSize()
Definition: GA_PageArray.h:761
UT_Storage
Definition: UT_Storage.h:28
GA_Size GA_PageOff
Definition: GA_Types.h:650
Iteration over a range of elements.
Definition: GA_Iterator.h:29
UT_PageArray< DATA_T, TSIZE, TABLEHARDENED, PAGESHARDENED, GA_PAGE_BITS, GA_Offset > Base
Definition: GA_PageArray.h:105
UT_JID
The UT_JID enums are used in byte-stream encoding of binary JSON.
Class which stores the default values for a GA_Attribute.
Definition: GA_Defaults.h:35
void
Definition: png.h:1083
getFileOption("OpenEXR:storage") storage
Definition: HDK_Image.dox:276
bool jsonSave(UT_JSONWriter &w, const GA_Range &range, const GA_SaveOptions *options=nullptr, const UT_IntArray *map=nullptr, int defvalue=-1) const
const GLdouble * v
Definition: glcorearb.h:837
void setConstant(const GA_Range &range, const SRC_T *values)
NOTE: values must have a number of values equal to the tuple size.
Definition: GA_PageArray.h:387
GLuint start
Definition: glcorearb.h:475
void comparePages(UT_BitArray &bits, const ThisType &that) const
Definition: GA_PageArray.h:596
The merge map keeps track of information when merging details.
Definition: GA_MergeMap.h:53
int64 exint
Definition: SYS_Types.h:125
SYS_FORCE_INLINE DEST_DATA_T get(GA_Offseti, exint component=0) const
Definition: UT_PageArray.h:488
GLuint GLsizei GLsizei * length
Definition: glcorearb.h:795
exint UT_PageNum
Definition: UT_PageArray.h:35
SYS_FORCE_INLINE GA_PageArray< DEST_DATA_T, TSIZE, TABLEHARDENED, PAGESHARDENED > & castType()
Definition: GA_PageArray.h:740
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:87
void setConstantVector(const GA_Range &range, const UT_FixedVector< SRC_T, theSafeTupleSize > &val)
Definition: GA_PageArray.h:305
void defragment(const GA_Defragment &defrag)
Include GA_PageArrayImpl.h to call this.
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:37
#define UT_ASSERT_MSG_P(ZZ,...)
Definition: UT_Assert.h:158
bool jsonLoad(UT_JSONParser &p, const GA_LoadMap &map, GA_AttributeOwner owner)
SYS_FORCE_INLINE UT_FixedVector< DEST_DATA_T, DEST_TSIZE > getVector(GA_Offseti) const
Definition: UT_PageArray.h:498
GA_PageArray(exint tuplesize)
Definition: GA_PageArray.h:146
SYS_FORCE_INLINE void set(GA_Offseti, SRC_DATA_T v)
component == 0 in this version
Definition: UT_PageArray.h:624
float fpreal32
Definition: SYS_Types.h:200
void setConstant(const GA_Range &range, SRC_T val)
Definition: GA_PageArray.h:179
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:236
void copy(const GA_Range &destrange, const GA_PageArray< SRC_DATA_T, SRC_TSIZE, SRC_TABLEHARDENED, SRC_PAGESHARDENED > &src, const GA_Range &srcrange)
Definition: GA_PageArray.h:443
#define GA_INVALID_OFFSET
Definition: GA_Types.h:687
A range of elements in an index-map.
Definition: GA_Range.h:42
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
double fpreal64
Definition: SYS_Types.h:201
#define UT_ASSERT_MSG(ZZ,...)
Definition: UT_Assert.h:159
unsigned char uint8
Definition: SYS_Types.h:36
GA_Size GA_Offset
Definition: GA_Types.h:646
void setConstantVector(GA_Offset start, GA_Offset end, const UT_FixedVector< SRC_T, theSafeTupleSize > &val)
Definition: GA_PageArray.h:348
SYS_FORCE_INLINE void setConstant(GA_Offset start, GA_Offset end, const GA_Defaults &v)
Definition: GA_PageArray.h:261
Definition: core.h:760
GA_PageArray(GA_Storage storage)
Definition: GA_PageArray.h:151
static SYS_FORCE_INLINE bool isEqual(const T0 *a, const T1 *b, exint tuplesize)
SYS_FORCE_INLINE void getRange(GA_Offsetsrcstart, GA_Offsetnelements, T *dest) const
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:155
SYS_FORCE_INLINE void setPageConstant(UT_PageNum pagenum, const NotVoidType &val)
GLuint GLuint end
Definition: glcorearb.h:475
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
void setConstant(GA_Offset start, GA_Offset end, SRC_T val)
Definition: GA_PageArray.h:267
void setBitFast(exint index, bool value)
Definition: UT_BitArray.h:342
long long int64
Definition: SYS_Types.h:116
Options during loading.
Definition: GA_LoadMap.h:42
GA_PageArray(exint tuplesize, GA_Storage storage)
Definition: GA_PageArray.h:161
SYS_FORCE_INLINE GA_Storage UTStorageToGAStorage(UT_Storage storage)
Definition: GA_PageArray.h:43
Defragmentation of IndexMaps.
Definition: GA_Defragment.h:45
signed char int8
Definition: SYS_Types.h:35
void getRange(const GA_Range &srcrange, T *dest) const
Definition: GA_PageArray.h:477
void mergeGrowArrayAndCopy(const GA_MergeMap &map, GA_AttributeOwner owner, const GA_PageArray< SRC_DATA_T, SRC_TSIZE, SRC_TABLEHARDENED, SRC_PAGESHARDENED > &src, const GA_Defaults &defaults)
Include GA_PageArrayImpl.h to call this.
void setConstant(const GA_Range &range, const GA_Defaults &defaults)
Definition: GA_PageArray.h:221
GA_PageArray(exint tuplesize, UT_Storage storage)
Definition: GA_PageArray.h:156
void moveRange(GA_Offsetsrcstart, GA_Offsetdeststart, GA_Offsetnelements)
SYS_FORCE_INLINE void setConstant(GA_Offset start, GA_Offset end, const SRC_T *values)
NOTE: values must have a number of values equal to the tuple size.
Definition: GA_PageArray.h:430
void setRange(const GA_Range &destrange, const T *src)
Definition: GA_PageArray.h:533
SYS_FORCE_INLINE UT_Storage GAStorageToUTStorage(GA_Storage storage)
Definition: GA_PageArray.h:71
GA_AttributeOwner
Definition: GA_Types.h:35
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1602
void swapRange(GA_Offsetastart, GA_Offsetbstart, GA_Offsetnelements)
short int16
Definition: SYS_Types.h:37
SYS_FORCE_INLINE GA_Storage getStorage() const
Get the storage type for each component of this GA_PageArray.
Definition: GA_PageArray.h:166
GA_PageArray< DATA_T, TSIZE, TABLEHARDENED, PAGESHARDENED > ThisType
Definition: GA_PageArray.h:106
SYS_FORCE_INLINE void setRange(GA_Offsetdeststart, GA_Offsetnelements, const T *src)
GLuint GLfloat * val
Definition: glcorearb.h:1608
SYS_FORCE_INLINE UT_PageArray< DATA_T, TSIZE, true, PAGESHARDENED, THEPAGEBITS, GA_Offset > & hardenTable()
SYS_FORCE_INLINE const GA_PageArray< DATA_T, DEST_TSIZE, TABLEHARDENED, PAGESHARDENED > & castTupleSize() const
Definition: GA_PageArray.h:753
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
Definition: core.h:1131
SYS_FORCE_INLINE const GA_PageArray< DEST_DATA_T, TSIZE, TABLEHARDENED, PAGESHARDENED > & castType() const
Definition: GA_PageArray.h:732
#define SYSmin(a, b)
Definition: SYS_Math.h:1571
GA_Storage
Definition: GA_Types.h:51
bool fullBlockAdvance(GA_Offset &start, GA_Offset &end)
void setStorage(GA_Storage storage)
Set the storage type for each component of this GA_PageArray.
Definition: GA_PageArray.h:172
GLenum src
Definition: glcorearb.h:1793