Short helper to add a 64 bit counter value to the MIB subtree.
334268
def add_cnt_64bit(self,oid,value,label=None):
		""""""
		# Truncate integer to 64bits ma,x
		self.add_oid_entry(oid,'Counter64',int(value)%18446744073709551615,label=label)
261238
private long build64(int i1, int i2)
	{
		long	msi = (long)i1;
		long	lsi = (long)i2 & 0xFFFFFFFFL;
		return	(msi << 32) + lsi;
	}
703181
def _not32(ins):
    
    output = _32bit_oper(ins.quad[2])
    output.append('call __NOT32')
    output.append('push af')
    REQUIRES.add('not32.asm')
    return output
1017334
def iv(base, counter):
    
    if (counter >> 64) != 0:
        raise ECEException(u"Counter too big")
    (mask,) = struct.unpack("!Q", base[4:])
    return base[:4] + struct.pack("!Q", counter ^ mask)
923081
private void populatePut(Put p, byte[] family, String key, String groupName, String counterName,
      Long counterValue) {
    byte[] counterPrefix = null;

    try {
      switch (JobHistoryKeys.valueOf(JobHistoryKeys.class, key)) {
      case COUNTERS:
      case TOTAL_COUNTERS:
      case TASK_COUNTERS:
      case TASK_ATTEMPT_COUNTERS:
        counterPrefix = Bytes.add(Constants.COUNTER_COLUMN_PREFIX_BYTES, Constants.SEP_BYTES);
        break;
      case MAP_COUNTERS:
        counterPrefix = Bytes.add(Constants.MAP_COUNTER_COLUMN_PREFIX_BYTES, Constants.SEP_BYTES);
        break;
      case REDUCE_COUNTERS:
        counterPrefix =
            Bytes.add(Constants.REDUCE_COUNTER_COLUMN_PREFIX_BYTES, Constants.SEP_BYTES);
        break;
      default:
        throw new IllegalArgumentException("Unknown counter type " + key.toString());
      }
    } catch (IllegalArgumentException iae) {
      throw new ProcessingException("Unknown counter type " + key, iae);
    } catch (NullPointerException npe) {
      throw new ProcessingException("Null counter type " + key, npe);
    }

    byte[] groupPrefix = Bytes.add(counterPrefix, Bytes.toBytes(groupName), Constants.SEP_BYTES);
    byte[] qualifier = Bytes.add(groupPrefix, Bytes.toBytes(counterName));

    /*
     * store the map and reduce mb millis counter value
     */
    if (Constants.JOB_COUNTER_HADOOP2.equals(groupName)) {
      if (Constants.MB_MILLIS_MAPS.equals(counterName)) {
        this.mapMbMillis = counterValue;
      } else if (Constants.MB_MILLIS_REDUCES.equals(counterName)) {
          this.reduceMbMillis = counterValue;
      }
    }

    /*
     * correct and populate map and reduce slot millis
     */
    if ((Constants.SLOTS_MILLIS_MAPS.equals(counterName)) ||
        (Constants.SLOTS_MILLIS_REDUCES.equals(counterName))) {
      counterValue = getStandardizedCounterValue(counterName, counterValue);
    }

    p.addColumn(family, qualifier, Bytes.toBytes(counterValue));

  }
48138
def pad_hex(value, bit_size):
    
    value = remove_0x_prefix(value)
    return add_0x_prefix(value.zfill(int(bit_size / 4)))
858822
def add( self, start, end, val ):
        """"""
        insort( self.bins[ bin_for_range( start, end, offsets=self.offsets ) ], ( start, end, val ) )
        assert val >= 0
        self.max_val = max(self.max_val,val)
674363
def blob_counter(self):
        """"""
        import aa    # pylint: disablF0401        # noqa
        from ROOT import EventFile    # pylint: disable F0401

        try:
            event_file = EventFile(self.filename)
        except Exception:
            raise SystemExit("Could not open file")

        num_blobs = 0
        for event in event_file:
            num_blobs += 1

        return num_blobs
469096
def _inplace_logical_helper(self, bs, f):
        """"""
        # Give the two bitstrings the same offset (modulo 8)
        self_byteoffset, self_bitoffset = divmod(self._offset, 8)
        bs_byteoffset, bs_bitoffset = divmod(bs._offset, 8)
        if bs_bitoffset != self_bitoffset:
            if not self_bitoffset:
                bs._datastore = offsetcopy(bs._datastore, 0)
            else:
                self._datastore = offsetcopy(self._datastore, bs_bitoffset)
        a = self._datastore.rawbytes
        b = bs._datastore.rawbytes
        for i in xrange(len(a)):
            a[i] = f(a[i + self_byteoffset], b[i + bs_byteoffset])
        return self
815017
def _ensure_counter(self):
        """"""
        if self._counter_path not in self._client.kv:
            self._client.kv[self._counter_path] = ''.zfill(self._COUNTER_FILL)
1148230
def _neg16(ins):
    ''' 
    '''
    output = _16bit_oper(ins.quad[2])
    output.append('call __NEGHL')
    output.append('push hl')
    REQUIRES.add('neg16.asm')
    return output
51246
def _fix_lsm_bitspersample(self, parent):
        
        if self.code != 258 or self.count != 2:
            return
        # TODO: test this case; need example file
        log.warning('TiffTag %i: correcting LSM bitspersample tag', self.code)
        value = struct.pack('<HH', *self.value)
        self.valueoffset = struct.unpack('<I', value)[0]
        parent.filehandle.seek(self.valueoffset)
        self.value = struct.unpack('<HH', parent.filehandle.read(4))
1058308
private void setBitsImpl(int position, long value, int length) {
		int i = position >> ADDRESS_BITS;
		int s = position & ADDRESS_MASK;
		long m = length == ADDRESS_SIZE ? -1L : (1L << length) - 1L;
		long v = value & m;
		performAdjSet(length, i, s, m, v);
	}
126958
def _fast_count_smallints(arr):
    """"""
    counts = np.bincount(arr.astype(np.int_))
    nz = counts.nonzero()[0]
    return np.c_[nz, counts[nz]]
273362
private static long[][] getKeyPrefixArrayCounts(
      LongArray array, long startIndex, long numRecords, int startByteIndex, int endByteIndex) {
    long[][] counts = new long[8][];
    long bitwiseMax = 0;
    long bitwiseMin = -1L;
    long baseOffset = array.getBaseOffset() + startIndex * 8L;
    long limit = baseOffset + numRecords * 16L;
    Object baseObject = array.getBaseObject();
    for (long offset = baseOffset; offset < limit; offset += 16) {
      long value = Platform.getLong(baseObject, offset + 8);
      bitwiseMax |= value;
      bitwiseMin &= value;
    }
    long bitsChanged = bitwiseMin ^ bitwiseMax;
    for (int i = startByteIndex; i <= endByteIndex; i++) {
      if (((bitsChanged >>> (i * 8)) & 0xff) != 0) {
        counts[i] = new long[256];
        for (long offset = baseOffset; offset < limit; offset += 16) {
          counts[i][(int)((Platform.getLong(baseObject, offset + 8) >>> (i * 8)) & 0xff)]++;
        }
      }
    }
    return counts;
  }
476715
private static void set32x64Bits(int[] table, int start, int limit) {
        assert (64 == table.length);
        int lead = start >> 6;  // Named for UTF-8 2-byte lead byte with upper 5 bits.
        int trail = start & 0x3f;  // Named for UTF-8 2-byte trail byte with lower 6 bits.

        // Set one bit indicating an all-one block.
        int bits = 1 << lead;
        if ((start + 1) == limit) { // Single-character shortcut.
            table[trail] |= bits;
            return;
        }

        int limitLead = limit >> 6;
        int limitTrail = limit & 0x3f;

        if (lead == limitLead) {
            // Partial vertical bit column.
            while (trail < limitTrail) {
                table[trail++] |= bits;
            }
        } else {
            // Partial vertical bit column,
            // followed by a bit rectangle,
            // followed by another partial vertical bit column.
            if (trail > 0) {
                do {
                    table[trail++] |= bits;
                } while (trail < 64);
                ++lead;
            }
            if (lead < limitLead) {
                bits = ~((1 << lead) - 1);
                if (limitLead < 0x20) {
                    bits &= (1 << limitLead) - 1;
                }
                for (trail = 0; trail < 64; ++trail) {
                    table[trail] |= bits;
                }
            }
            // limit<=0x800. If limit==0x800 then limitLead=32 and limitTrail=0.
            // In that case, bits=1<<limitLead == 1<<0 == 1
            // (because Java << uses only the lower 5 bits of the shift operand)
            // but the bits value is not used because trail<limitTrail is already false.
            bits = 1 << limitLead;
            for (trail = 0; trail < limitTrail; ++trail) {
                table[trail] |= bits;
            }
        }
    }
528830
def insert(self, value):
        """"""
        i = 0
        n = len(self._tree)
        while i < n:
            cur = self._tree[i]
            self._counts[i] += 1
            if value < cur:
                i = 2 * i + 1
            elif value > cur:
                i = 2 * i + 2
            else:
                return
        raise ValueError("Value %s not contained in tree." "Also, the counts are now messed up." % value)