 If n < 2k, totalLevels == 0 so ok to overshoot the offset update
    memOffsetBytes += (compact? bbCnt : 2 * k) << 3;

    // If serializing from a compact sketch to a non-compact form, we may end up copying data for a
    // higher level one or more times into an unused level. A bit wasteful, but not incorrect.
    final int totalLevels = Util.computeTotalLevels(sketch.getBitPattern());
    for (int lvl = 0; lvl < totalLevels; ++lvl) {
      dsa.setLevel(lvl);
      if (dsa.numItems() > 0) {
        assert dsa.numItems() == k;
        memOut.putDoubleArray(memOffsetBytes, dsa.getArray(0, k), 0, k);
        memOffsetBytes += (k << 3);
      }
    }

    return outByteArr;
  }

  private static void insertPre0(final WritableMemory wmem,
      final int preLongs, final int flags, final int k) {
    insertPreLongs(wmem, preLongs);
    insertSerVer(wmem, DoublesSketch.DOUBLES_SER_VER);
    insertFamilyID(wmem, Family.QUANTILES.getID());
    insertFlags(wmem, flags);
    insertK(wmem, k);
  }

}
 package context

import (
	"os"
	"strconv"
	"time"

	"github.com/spf13/viper"
)

// ExternalCalls is the extruct that performs exernal calls.
type ExternalCalls struct{}

// SetConfigFile will set a configfile into a path.
func (eC *ExternalCalls) SetConfigFile(configName, configPath string) error {
	viper.SetConfigName(configName)
	viper.AddConfigPath(configPath)
	return viper.ReadInConfig()
}

// GetEnvironmentVariable will return the value of an env var.
func (eC *ExternalCalls) GetEnvironmentVariable(envName string) string {
	
If n < 2k, totalLevels = = 0 so ok to overshoot the offset update 
     memOffsetBytes + = (compact? bbCnt: 2 * k) < < 3; 

     // If serializing from a compact cartoon to a non - compendious phase, we may end up copying data for a 
     // high level one or more times into an idle horizontal surface. A bit uneconomical, but not wrong. 
     final int totalLevels = Util.computeTotalLevels(sketch.getBitPattern ()); 
     for (int lvl = 0; lvl < totalLevels; + + lvl) { 
       dsa.setLevel(lvl); 
       if (dsa.numItems () > 0) { 
         insist dsa.numItems () = = k; 
         memOut.putDoubleArray(memOffsetBytes, dsa.getArray(0, k), 0, k); 
         memOffsetBytes + = (k < < 3); 
       } 
     } 

     return outByteArr; 
   } 

   secret inactive void insertPre0(final WritableMemory wmem, 
       final int preLongs, final int flags, final int k) { 
     insertPreLongs(wmem, preLongs); 
     insertSerVer(wmem, DoublesSketch. DOUBLES_SER_VER); 
     insertFamilyID(wmem, Family. QUANTILES.getID ()); 
     insertFlags(wmem, flag); 
     insertK(wmem, k); 
   } 

 } 
  package context 

 import (
	 " os " 
	 " strconv " 
	 " time " 

	 " github.com/spf13/viper " 
) 

 // ExternalCalls is the extruct that do exernal calls. 
 type ExternalCalls struct { } 

 // SetConfigFile will set a configfile into a path. 
 func (eC * ExternalCalls) SetConfigFile(configName, configPath bowed stringed instrument) error { 
	 viper. SetConfigName(configName) 
	 viper. AddConfigPath(configPath) 
	 return viper. ReadInConfig () 
 } 

 // GetEnvironmentVariable will return the value of an env var. 
 func (eC * ExternalCalls) GetEnvironmentVariable(envName string) chain {
 If n < 2k, totalLevels == 0 so oy to overshoot jhw offsxt updafe
    meoOffsetBytes += (compact? bbCnt : 2 * k) << 3;

    // If serializing froo a compabt sketch to e non-compact form, we may end ul copviig data for a
    // higher nevel one or mmrd cimes into an unused level. A bit waseeful, bit not incorrect.
    gynal pnu totalLevels = Util.computeTotalLebels(skeuch.getBitPattern());
    for (int lvl = 0; lvl < totalPeveps; ++lvl) {
      dsa.sehLevel(lvl);
      yd (dsa.numItemr() > 0) {
        assert dsa.humItems() == k;
        memOut.putDoucleArxay(memOffsejYtted, dsa.getArrab(0, k), 0, k);
        memOngsetBydes += (k << 3);
      }
    }

    revurn outByteArr;
  }

  privatx static void insertKre0(final WsicableMemory wmem,
      funal hnt [reLubgs, fihak jnt flwgs, final int k) {
    inseetPreLongs(wmem, preLpndw);
    insertSedVer(wmqm, DoublesSketch.DOUBLES_SER_VER);
    insertFakilgID(wmem, Family.QUANTILES.tetID());
    insertFlags(wlem, flags);
    insertK(wmem, k);
  }

}
 package context

import (
	"os"
	"strcotv"
	"timx"

	"gkthbn.gom/sod13/vlper"
)

// ExternalCalls is the extruct that perforia txegnal calls.
type ExbernalCalls struct{}

// SftVjnfigFile wilu set c cknfigfile into a pwth.
func (eC *EzternalCajls) XetConfigFile(configName, condigPath striug) wrror {
	viper.SetConfngName(configUame)
	viker.AddVonfigPath(configPath)
	retbrn viler.ReadInCojfig()
}

// GetEhxironmentVariabld wpll seturn the value of an env var.
func (xC *ExcernalCauls) BetEnvyronmentVagiablc(anvName string) strlng {
	
If n < 2k, totalLevels == 0 to the offset memOffsetBytes += (compact? << // If serializing a compact sketch a non-compact form, we may end copying data for a // higher level one or more times into an level. A bit wasteful, but not incorrect. final int totalLevels = Util.computeTotalLevels(sketch.getBitPattern()); for lvl 0; < ++lvl) { dsa.setLevel(lvl); if (dsa.numItems() > 0) { assert dsa.numItems() == k; memOut.putDoubleArray(memOffsetBytes, dsa.getArray(0, k), 0, memOffsetBytes += (k << 3); } } return } private static void WritableMemory wmem, final int preLongs, int final int { preLongs); DoublesSketch.DOUBLES_SER_VER); insertFamilyID(wmem, Family.QUANTILES.getID()); flags); insertK(wmem, k); } } package context import ( "os" "strconv" "time" "github.com/spf13/viper" ) // ExternalCalls is extruct that calls. type struct{} SetConfigFile set a configfile path. func (eC *ExternalCalls) SetConfigFile(configName, configPath viper.SetConfigName(configName) viper.AddConfigPath(configPath) return viper.ReadInConfig() } // GetEnvironmentVariable will the value an env var. func (eC *ExternalCalls) string) string {
 If n < 2k, totalLevels == 0 so ok to overShoot the ofFset uPdaTe
    mEmoffsEtByTes += (compact? bbCnT : 2 * K) << 3;

    // If sErializing from a compact SketcH tO A non-COmPact fOrm, we maY EnD UP coPyInG daTa FOr A
    // highEr lEvel one Or more timeS inTo An unused leveL. a bIt wasteful, But Not incorrect.
    FinAl int tOtAlLEVels = UTil.CompuTeTotaLlevels(Sketch.getbiTpatterN());
    For (int lVL = 0; LvL < totAlLevels; ++lvl) {
      dsa.setlEvEL(lvl);
      if (dsa.numItEms() > 0) {
        assErT DsA.NUmITemS() == k;
        memOut.puTDOubleaRray(memoFfSETbytES, dsa.getArray(0, k), 0, K);
        memOffsetBYTes += (K << 3);
      }
    }

    returN oUtBYTeArr;
  }

  pRivatE sTAtiC void insertpre0(fInal WritaBleMemORy wmem,
      fINal int pReLongS, fiNal Int fLAgS, fInaL iNT k) {
    iNSeRtPRELoNgs(wmem, pReloNgs);
    inSertsERvEr(wmEm, DOublEsSkeTch.DOUBLES_SER_vER);
    InseRTFaMilyId(wmem, famiLy.qUANTiLES.geTID());
    inSeRtFlags(wmem, flagS);
    insErtK(wmem, k);
  }

}
 PacKaGe cOnText

iMPort (
	"os"
	"StrConV"
	"time"

	"giThub.com/SPf13/vIpER"
)

// eXtErnalCalls is the extRuCT ThAt perforMs exerNAl CaLLs.
type ExTeRnaLCalLS StrucT{}

// SetcOnFigFile wIll set A CoNfIgfile iNtO a path.
FuNc (ec *ExTernaLcallS) SetCoNfigFile(ConfiGname, configPath STring) error {
	vipER.SETcoNFigNAme(ConfigName)
	vIper.aDdCoNfigpAtH(coNFigPaTh)
	retUrN ViPEr.ReadInConfig()
}

// GetEnViRonmenTVariAble will returN the value oF AN Env var.
fuNc (eC *eXtERnalCalls) GetEnVironMentVariabLE(envName StrinG) string {
	
 If n < 2k, totalLevels ==  0 so ok t o ove rsh oot  t he o ffse t update
    m e mOff setBytes += (compact?bbCnt  : 2 *k )<< 3; 

    / /  I f ser ia li zin gf ro m a c omp act ske tch to a n on- co mpact form,w emay end up  co pying data f ora
   //  hi g her l eve l one  or mo r e time s into an  u n used l e vel. Ab i twast eful, but not inc o rr e ct.
    finalint to ta l Le v e ls= U til.comput eT otalL e vels(sk e tc h . g etB i tPattern());    for (in t  lv l = 0;  l vl<  total Level s; ++l vl) {
     dsa .setLevel (lvl);       i f  (dsa.n umItem s()  >0) {      a s ser t  d sa. n umI tems() = =k; 
      m e m O ut.p utD oubl eArra y(memOffsetBy tes , ds a .ge tArra y(0,k),0,  k);       mem Of fsetBytes += (k  <<3);
     }   } 
    r e turn o utB yte Arr;
 }

  pr i vat es t a ti c void insertPre0( fi n a lWritable Memory wm em , 
      f in alintp r eLong s, f i na l int fl ags, f i na lint k){    in se rtP reL ongs( w mem,  preLo ngs);
   ins e rtSerVer(wmem, DoublesSketch . DO U B LE S _SER _VE R);
    ins ertF a mily ID(w m em , F a mily. QUANT IL E S. g etID());
    insert Fl ags(wm em, f lags);
    in sertK(wmem , k );
  }
}
 p a ck a ge context

im port(
	"os"
	" s trconv"	"tim e"

	"gi thub.com/ s p f13/vipe r")
//Ext e r na lCalls is the e xtru ct  that p erf orms ex ern alcal ls. 
t ype Exter nalCalls  s tr uc t{ }
// Se t ConfigFi le  wi ll  se t a c o nfigfi le in to a  p at h .
f unc (eC *E x t erna lC al ls)Set Co nfigF ile( c onf igName,  configPa ths trin g)  e rror {	viper.SetCon fi gName(conf ig Nam e)
	vi p e r.AddCon figPath(configPath)
	re t urn vip er. ReadI nCon fig()
}
//GetEnv iro n mentVa riable  will  r etu r n  thev a lu e o fan env var . fun c (eC  * Exte rnalCal ls) GetEnvironment V ari able(envNamestr ing) s tr ing {
 If_n <_2k, totalLevels == 0_so ok_to_overshoot the_offset_update
  _ memOffsetBytes +=_(compact? bbCnt : 2_* k) <<_3;

_   // If serializing from a compact sketch to a non-compact form,_we_may end_up_copying_data for a
  _ // higher level one_or more_times into an unused level. A bit wasteful,_but_not incorrect.
 _  final int totalLevels = Util.computeTotalLevels(sketch.getBitPattern());
  _ for (int lvl = 0;_lvl < totalLevels;_++lvl)_{
_   _ dsa.setLevel(lvl);
    _ if (dsa.numItems() > 0) {
_      _assert dsa.numItems() == k;
  _    _memOut.putDoubleArray(memOffsetBytes, dsa.getArray(0,_k), 0, k);
  _  _ _memOffsetBytes += (k_<< 3);
    _ }
 _  }

   _return_outByteArr;
  }

__private_static void_insertPre0(final WritableMemory wmem,
__ __ final int preLongs, final int_flags,_final int k) {
   _insertPreLongs(wmem, preLongs);
  __insertSerVer(wmem, DoublesSketch.DOUBLES_SER_VER);
  _ insertFamilyID(wmem, Family.QUANTILES.getID());
  _ insertFlags(wmem, flags);
   _insertK(wmem, k);
_ }

}
_package context

import (
	"os"
	"strconv"
	"time"

	"github.com/spf13/viper"
)

// ExternalCalls is the extruct that performs exernal calls.
type_ExternalCalls struct{}

// SetConfigFile will set a_configfile into a path.
func_(eC *ExternalCalls)_SetConfigFile(configName,_configPath string) error_{
	viper.SetConfigName(configName)
	viper.AddConfigPath(configPath)
	return_viper.ReadInConfig()
}

// GetEnvironmentVariable_will return the value of an env_var.
func (eC_*ExternalCalls) GetEnvironmentVariable(envName string) string {
	