Convert a long to a byte[] using the format Cassandra wants for a column or
supercolumn name. The antimethod for this one is {@link #toLong(byte[])}.

@param value Long value to be converted.
@return      Same value encoded into an byte[8] array.
194843
public static byte[] toBytes(long value) {
        byte[] bytes = new byte[8];
        ByteBuffer buffer = ByteBuffer.wrap(bytes);
        buffer.putLong(value);
        return bytes;
    }
49917
public static byte[] toByteArray(long value) {
        return new byte[]{(byte) (value >>> 56), (byte) (value >>> 48), (byte) (value >>> 40), (byte) (value >>> 32), (byte) (value >>> 24),
                (byte) (value >>> 16), (byte) (value >>> 8), (byte) value};
    }
1225230
public long toLong () {
    long result = 0;
    
    byte[] uuidBytes = super.toByteArray();
    
    for (int i = 0; i < 8; i++)
    {
      result = result << 8;
      result += (int) uuidBytes[i];
    }

    return result;
  }
300444
public static long asLong(Object value) {
        if (value instanceof Number) {
            return ((Number) value).longValue();
        } else if (value instanceof Numeric) {
            return ((Numeric) value).asInteger();
        } else if (value instanceof Boolean) {
            return ((Boolean) value) ? 1L : 0L;
        } else if (value instanceof CharSequence) {
            try {
                return Long.parseLong(value.toString());
            } catch (NumberFormatException nfe) {
                throw new IncompatibleValueException("Unable to parse string \"" + Strings.escape(value.toString()) +
                                                     "\" to a long", nfe);
            }
        } else if (value instanceof Date) {
            // Return date timestamp.
            return ((Date) value).getTime();
        }
        throw new IncompatibleValueException("Unable to convert " + value.getClass().getSimpleName() + " to a long");

    }
277320
public static byte[] getBytes(long value) {
        return new byte[]{(byte) (value >> 56), (byte) (value >> 48), (byte) (value >> 40), (byte) (value >> 32),
                (byte) (value >> 24), (byte) (value >> 16), (byte) (value >> 8), (byte) value};
    }
1012878
public static long byteArrayToLongBE( byte[] data ) {
        if (data == null)
            return 0x0;
        long accum = 0;
        int shiftBy = 8 * data.length - 8;
        for( byte b : data ) {
            accum |= (long) (0xff & b) << shiftBy;
            shiftBy -= 8;
        }
        return accum;
    }
1320762
static long asLong(Object value) throws ProvidenceConfigException {
        if (value instanceof Float || value instanceof Double) {
            long l = ((Number) value).longValue();
            if ((double) l != ((Number) value).doubleValue()) {
                throw new ProvidenceConfigException("Truncating long decimals from " + value.toString());
            }
            return l;
        } else if (value instanceof Number) {
            return ((Number) value).longValue();
        } else if (value instanceof Numeric) {
            return ((Numeric) value).asInteger();
        } else if (value instanceof Boolean) {
            return ((Boolean) value) ? 1L : 0L;
       }
        throw new ProvidenceConfigException("Unable to convert " + value.getClass().getSimpleName() + " to a long");
    }
899263
public long toLong(Object val) {
    if (val == null) {
      return 0L;
    }
    else if (val instanceof Double) {
      if (!Double.isNaN(((Double) val).doubleValue())) {
        return 0;
      }
      else {
        return ((Double) val).longValue();
      }
    }
    else if (val instanceof Number) {
      return ((Number) val).longValue();
    }
    else if (val instanceof String) {
      if ("".equals(val)) {
        return 0;
      }
      else {
        return Long.parseLong((String) val);
      }
    }
    else if (val instanceof Boolean) {
      return ((Boolean) val).booleanValue() ? 1L : 0L;
    }
    else if (val instanceof Character) {
      return ((Character) val).charValue();
    }

    throw new ArithmeticException("Long coercion: " + val.getClass().getName() + ":(" + val + ")");
  }
898662
@Override
	public long[] toArrayLong() {
		long[] result = new long[size];
		System.arraycopy(elementData, 0, result, 0, size);
		return result;
	}
1083934
public static final void writeLong(long value, byte[] array, int offset)
    {
        if (array.length < offset + 8)
        {
            throw new IllegalArgumentException("no room in array");
        }
        array[offset] = (byte) (value >> 56);
        array[offset + 1] = (byte) ((value >> 48) & 0xff);
        array[offset + 2] = (byte) ((value >> 40) & 0xff);
        array[offset + 3] = (byte) ((value >> 32) & 0xff);
        array[offset + 4] = (byte) ((value >> 24) & 0xff);
        array[offset + 5] = (byte) ((value >> 16) & 0xff);
        array[offset + 6] = (byte) ((value >> 8) & 0xff);
        array[offset + 7] = (byte) (value & 0xff);
    }
800239
public static byte[] longToByteArrayBE( long data ) {
        return new byte[]{(byte) ((data >> 56) & 0xff), (byte) ((data >> 48) & 0xff), (byte) ((data >> 40) & 0xff),
                (byte) ((data >> 32) & 0xff), (byte) ((data >> 24) & 0xff), (byte) ((data >> 16) & 0xff),
                (byte) ((data >> 8) & 0xff), (byte) ((data >> 0) & 0xff),};
    }
334823
private Item newLong(final long value) {
        Item result = get(key.set(LONG, value));
        if (result == null) {
            pool.putByte(LONG).putLong(value);
            result = new Item(poolIndex, key);
            put(result);
            poolIndex += 2;
        }
        return result;
    }
39532
public static long byteArrayToLongLE( byte[] data ) {
        if (data == null)
            return 0x0;
        long accum = 0;
        int shiftBy = 0;
        for( byte b : data ) {
            accum |= (long) (b & 0xff) << shiftBy;
            shiftBy += 8;
        }
        return accum;
    }
1105565
private static int appendLong(byte[] data, int offset, long value) {
        offset = appendByte(data, offset, value >>> 56);
        offset = appendByte(data, offset, value >>> 48);
        offset = appendByte(data, offset, value >>> 40);
        offset = appendByte(data, offset, value >>> 32);
        offset = appendInt(data, offset, value);
        return offset;
    }
353545
public void writeLong(long value) {
		try {
			buffer.writeInt(8);
			buffer.writeLong(value);
		} catch (Exception e) {
			throw new BinaryWriteFailedException(e);
		}
	}
885103
static void longToBase16String(long value, char[] dest, int destOffset) {
    byteToBase16((byte) (value >> 56 & 0xFFL), dest, destOffset);
    byteToBase16((byte) (value >> 48 & 0xFFL), dest, destOffset + BYTE_BASE16);
    byteToBase16((byte) (value >> 40 & 0xFFL), dest, destOffset + 2 * BYTE_BASE16);
    byteToBase16((byte) (value >> 32 & 0xFFL), dest, destOffset + 3 * BYTE_BASE16);
    byteToBase16((byte) (value >> 24 & 0xFFL), dest, destOffset + 4 * BYTE_BASE16);
    byteToBase16((byte) (value >> 16 & 0xFFL), dest, destOffset + 5 * BYTE_BASE16);
    byteToBase16((byte) (value >> 8 & 0xFFL), dest, destOffset + 6 * BYTE_BASE16);
    byteToBase16((byte) (value & 0xFFL), dest, destOffset + 7 * BYTE_BASE16);
  }
663759
public static byte[] toBytes(long value, int length) {
        if (length <= 0) return new byte[0];
        if (length > 8) length = 8;
        byte[] out = new byte[length];
        for (int i = length - 1; i >= 0; i--){
            out[i] = (byte)(value & 0xFFL);
            value = value >> 8;
        }
        return out;
    }