#ifndef FOR_H_ #define FOR_H_ #include "common.h" #include "codecs.h" #include "bpacking.h" #include "forutil.h" namespace Codecset { class FOR : public IntegerCODEC { public: using IntegerCODEC::encodeArray; using IntegerCODEC::decodeArray; using IntegerCODEC::randomdecodeArray; using IntegerCODEC::encodeArray8; using IntegerCODEC::decodeArray8; using IntegerCODEC::randomdecodeArray8; using IntegerCODEC::init; using IntegerCODEC::summation; int block_num; int block_size; void init(int blocks, int blocksize,int extra){ block_num=blocks; block_size=blocksize; } uint32_t * encodeArray(uint32_t *in, const size_t length,uint32_t *res, size_t nvalue) { uint32_t * out = res; out[0] = length; ++out; if(length == 0) return out; uint32_t m = in[0]; uint32_t M = in[0]; for(uint32_t i = 1; i < length; ++i) { if(in[i]>M) M=in[i]; if(in[i](M-m)); if(b==31){ b=32; } out[0] = m; ++out; out[0] = M; ++out; uint32_t k = 0; //std::cout<(M-m)); if(b==31){ b=32; } //std::cout<<"bit "<(M-m)); if(b==0){ return m; } if(b==31){ b=32; } #ifdef _OPENMP #pragma omp parallel for #endif uint32_t recover=0; in = in + ((int)l/32)*b; int number_left = l - ((int)l/32)*32; //std::cout<<"nvalue "<=16 ){ // number_left -= 16; // in = in +(int)ceil((double)b*16./32.); // if(number_left>=8){ // number_left -= 8; // in = in +(int)ceil((double)b*8./32.); // } // else{ // unpack8[b](m,in,out); // return out[number_left]; // } // } // else if(number_left>=8){ // number_left -= 8; // in = in +(int)ceil((double)b*8./32.); // return in[number_left]; // } // if(number_left>0){ // return in[number_left]; // } // */ // uint32_t *res = new uint32_t[32]; // uint32_t *tmpres =res; // for(uint32_t k=nvalue/32*32; k+16<=nvalue; k+=16,res+=16) { // in = unpack16[b](m,in,res); // } // for(uint32_t k=nvalue/16*16; k+8<=nvalue; k+=8,res+=8) { // in = unpack8[b](m,in,res); // } // // we could pack the rest, but we don't bother // for(uint32_t k=nvalue/8*8; k=b){ recover = (in[0]>>bit_left) & ((1U<>bit_left); recover +=m; return recover; } // } /* uint32_t number_occupy = (number_left*b)/32; in+= number_occupy; if(b==32){ return in[0]+m; } long long bit_left = number_left*b - number_occupy*32; //std::cout<<"ind "<=b){ recover = (in[0]>>bit_left) & ((1U<>bit_left); recover +=m; return recover; } */ } uint8_t* encodeArray8( uint32_t *in, const size_t length, uint8_t *res, size_t nvalue) { uint32_t * out=reinterpret_cast(res); uint32_t * mark_out = out; out = encodeArray(in,length,out,nvalue); res = reinterpret_cast(mark_out); uint8_t *tmp_res = reinterpret_cast(out); return tmp_res; } uint32_t *decodeArray8( uint8_t *in, const size_t length, uint32_t *out, size_t nvalue) { uint32_t * tmpin = reinterpret_cast(in); return decodeArray(tmpin,length,out,nvalue); } uint32_t randomdecodeArray8(uint8_t *in, const size_t l,uint32_t *out, size_t nvalue){ uint32_t * tmpin = reinterpret_cast(in); uint32_t tmp = randomdecodeArray(tmpin,l,out,nvalue); //std::cout<