@@ -178,6 +178,10 @@ struct Block {
178178 inline W* getCreateData () { return payload ? (payload + nDict) : getCreatePayload (); }
179179 inline W* getCreateLiterals () { return payload ? payload + (nDict + nData) : getCreatePayload (); }
180180
181+ inline auto getOffsDict () { return reinterpret_cast <std::uintptr_t >(getCreateDict ()) - reinterpret_cast <std::uintptr_t >(registry->head ); }
182+ inline auto getOffsData () { return reinterpret_cast <std::uintptr_t >(getCreateData ()) - reinterpret_cast <std::uintptr_t >(registry->head ); }
183+ inline auto getOffsLiterals () { return reinterpret_cast <std::uintptr_t >(getCreateLiterals ()) - reinterpret_cast <std::uintptr_t >(registry->head ); }
184+
181185 inline void setNDict (int _ndict)
182186 {
183187 nDict = _ndict;
@@ -437,6 +441,7 @@ class EncodedBlocks
437441
438442 // / print itself
439443 void print (const std::string& prefix = " " ) const ;
444+ void dump (const std::string& prefix = " " , int ncol = 20 ) const ;
440445
441446 protected:
442447 static_assert (N > 0 , " number of encoded blocks < 1" );
@@ -860,6 +865,7 @@ void EncodedBlocks<H, N, W>::encode(const input_IT srcBegin, // iterator be
860865 // store dictionary first
861866 if (frequencyTable.size ()) {
862867 thisBlock->storeDict (frequencyTable.size (), frequencyTable.data ());
868+ LOGP (DEBUG, " StoreDict {} bytes, offs: {}:{}" , frequencyTable.size () * sizeof (W), thisBlock->getOffsDict (), thisBlock->getOffsDict () + frequencyTable.size () * sizeof (W));
863869 }
864870 // vector of incompressible literal symbols
865871 std::vector<input_t > literals;
@@ -871,6 +877,7 @@ void EncodedBlocks<H, N, W>::encode(const input_IT srcBegin, // iterator be
871877 dataSize = encodedMessageEnd - thisBlock->getDataPointer ();
872878 thisBlock->setNData (dataSize);
873879 thisBlock->realignBlock ();
880+ LOGP (DEBUG, " StoreData {} bytes, offs: {}:{}" , dataSize * sizeof (W), thisBlock->getOffsData (), thisBlock->getOffsData () + dataSize * sizeof (W));
874881 // update the size claimed by encode message directly inside the block
875882
876883 // store incompressible symbols if any
@@ -885,6 +892,7 @@ void EncodedBlocks<H, N, W>::encode(const input_IT srcBegin, // iterator be
885892 const size_t nLiteralStorageElems = calculateNDestTElements<input_t , storageBuffer_t>(nSymbols);
886893 expandStorage (nLiteralStorageElems);
887894 thisBlock->storeLiterals (nLiteralStorageElems, reinterpret_cast <const storageBuffer_t*>(literals.data ()));
895+ LOGP (DEBUG, " StoreLiterals {} bytes, offs: {}:{}" , nLiteralStorageElems * sizeof (W), thisBlock->getOffsLiterals (), thisBlock->getOffsLiterals () + nLiteralStorageElems * sizeof (W));
888896 return nLiteralStorageElems;
889897 }
890898 return size_t (0 );
@@ -947,6 +955,57 @@ std::vector<char> EncodedBlocks<H, N, W>::createDictionaryBlocks(const std::vect
947955 return std::move (vdict);
948956}
949957
958+ template <typename H, int N, typename W>
959+ void EncodedBlocks<H, N, W>::dump(const std::string& prefix, int ncol) const
960+ {
961+ for (int ibl = 0 ; ibl < getNBlocks (); ibl++) {
962+ const auto & blc = getBlock (ibl);
963+ std::string ss;
964+ LOGP (INFO, " {} Bloc:{} Dict: {} words" , prefix, ibl, blc.getNDict ());
965+ const auto * ptr = blc.getDict ();
966+ for (int i = 0 ; i < blc.getNDict (); i++) {
967+ if (i && (i % ncol) == 0 ) {
968+ LOG (INFO) << ss;
969+ ss.clear ();
970+ }
971+ ss += fmt::format (" {:#010x}" , ptr[i]);
972+ }
973+ if (!ss.empty ()) {
974+ LOG (INFO) << ss;
975+ ss.clear ();
976+ }
977+ LOG (INFO) << " \n " ;
978+ LOGP (INFO, " {} Bloc:{} Data: {} words" , prefix, ibl, blc.getNData ());
979+ ptr = blc.getData ();
980+ for (int i = 0 ; i < blc.getNData (); i++) {
981+ if (i && (i % ncol) == 0 ) {
982+ LOG (INFO) << ss;
983+ ss.clear ();
984+ }
985+ ss += fmt::format (" {:#010x}" , ptr[i]);
986+ }
987+ if (!ss.empty ()) {
988+ LOG (INFO) << ss;
989+ ss.clear ();
990+ }
991+ LOG (INFO) << " \n " ;
992+ LOGP (INFO, " {} Bloc:{} Literals: {} words" , prefix, ibl, blc.getNLiterals ());
993+ ptr = blc.getData ();
994+ for (int i = 0 ; i < blc.getNLiterals (); i++) {
995+ if (i && (i % 20 ) == 0 ) {
996+ LOG (INFO) << ss;
997+ ss.clear ();
998+ }
999+ ss += fmt::format (" {:#010x}" , ptr[i]);
1000+ }
1001+ if (!ss.empty ()) {
1002+ LOG (INFO) << ss;
1003+ ss.clear ();
1004+ }
1005+ LOG (INFO) << " \n " ;
1006+ }
1007+ }
1008+
9501009} // namespace ctf
9511010} // namespace o2
9521011
0 commit comments