Package com.facebook.stats.cardinality.Model

Examples of com.facebook.stats.cardinality.Model.SymbolInfo


    this.out = out;
  }

  public void encode(int symbol) throws IOException {
    // lookup symbol data
    SymbolInfo symbolInfo = model.getSymbolInfo(symbol);

    // adjust low and high counts
    long range = (high - low + 1) >> model.log2MaxCount();
    high = low + (range * symbolInfo.highCount()) - 1;
    low = low + range * symbolInfo.lowCount();

    // write high byte if they are equal
    while ((high & 0xFF0000000000L) == (low & 0xFF0000000000L)) {
      int value = (int) (high >>> 40);
      out.write(value);
View Full Code Here


    // determine next symbol
    // calculate the % of the value within the range
    long range = (high - low + 1) >>> model.log2MaxCount();

    int currentSymbolCount = (int) ((value - low) / range);
    SymbolInfo symbolInfo = model.countToSymbol(currentSymbolCount);

    high = low + (range * symbolInfo.highCount()) - 1;
    low = low + range * symbolInfo.lowCount();

    // if high bytes are equal, remove high byte and add a new byte of input
    while ((high & 0xFF0000000000L) == (low & 0xFF0000000000L)) {
      bufferByte();
    }

    // handle possible underflow
    // if top two bytes differ by only one digit
    if ((high >> 32) - (low >> 32) == 1) {
      // if second highest bytes are 0x00 on the high and 0xFF
      // on the low, we need to deal with underflow
      while ((high & 0x00FF00000000L) == 0 && (low & 0x00FF00000000L) == 0x00FF00000000L) {
        // remove second chunk of low and high (shifting over lower bits)
        low = removeUnderflowByte(low);
        high = removeUnderflowByte(high);
        value = removeUnderflowByte(value);

        // add a new byte
        bufferByte();
      }
    }

    low &= 0xFFFFFFFFFFFFL;
    high &= 0xFFFFFFFFFFFFL;
    value &= 0xFFFFFFFFFFFFL;

    return symbolInfo.symbol();
  }
View Full Code Here

    // determine next symbol
    // calculate the % of the value within the range
    long range = (high - low + 1) >>> model.log2MaxCount();

    int currentSymbolCount = (int) ((value - low) / range);
    SymbolInfo symbolInfo = model.countToSymbol(currentSymbolCount);

    high = low + (range * symbolInfo.highCount()) - 1;
    low = low + range * symbolInfo.lowCount();

    // if high bytes are equal, remove high byte and add a new byte of input
    while ((high & 0xFF0000000000L) == (low & 0xFF0000000000L)) {
      bufferByte();
    }

    // handle possible underflow
    // if top two bytes differ by only one digit
    if ((high >> 32) - (low >> 32) == 1) {
      // if second highest bytes are 0x00 on the high and 0xFF
      // on the low, we need to deal with underflow
      while ((high & 0x00FF00000000L) == 0 && (low & 0x00FF00000000L) == 0x00FF00000000L) {
        // remove second chunk of low and high (shifting over lower bits)
        low = removeUnderflowByte(low);
        high = removeUnderflowByte(high);
        value = removeUnderflowByte(value);

        // add a new byte
        bufferByte();
      }
    }

    low &= 0xFFFFFFFFFFFFL;
    high &= 0xFFFFFFFFFFFFL;
    value &= 0xFFFFFFFFFFFFL;

    return symbolInfo.symbol();
  }
View Full Code Here

TOP

Related Classes of com.facebook.stats.cardinality.Model.SymbolInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.