My favorites
▼
|
Sign in
pelops
A Java client library for the Cassandra database
Project Home
Downloads
Wiki
Issues
Source
Checkout
Browse
Changes
Source path:
svn
/
trunk
/
src
/
org
/
wyki
/
cassandra
/
pelops
/
NumberHelper.java
r7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package org.wyki.cassandra.pelops;
public class NumberHelper {
public static final long toLong(byte[] b) {
return toLong(b,0,b.length);
}
public static final long toLong(byte[] b,int offset,int size) {
long l = 0;
for (int i=0; i<size; ++i)
l |= ((long)b[offset+i]&0xff)<<((size-i-1)<<3);
return l;
}
public static final int toInt(byte[] b,int offset) {
return b[offset+0]<<24 | (b[offset+1]&0xff)<<16 | (b[offset+2]&0xff)<<8 | (b[offset+3]&0xff);
}
public static final int toInt(byte[] b) {
return b[0]<<24 | (b[1]&0xff)<<16 | (b[2]&0xff)<<8 | (b[3]&0xff);
}
public static final short toShort(byte[] b,int offset) {
return (short)((b[offset+0]&0xff)<<8 | (b[offset+1]&0xff));
}
public static final short toShort(byte[] b) {
return (short)((b[0]&0xff)<<8 | (b[1]&0xff));
}
public static final byte[] toBytes(long l) {
return toBytes(l, 8);
}
public static final byte[] toBytes(long l,int size) {
byte[] b = new byte[size];
toBytes(l,b,0,size);
return b;
}
public static final void toBytes(long l, byte[] b, int offset, int size) {
for (int i=0; i<size; ++i)
b[offset+i] = (byte)(l>>((size-i-1)<<3));
}
public static final byte[] toBytes(int i) {
return new byte[] { (byte)(i >>> 24), (byte)(i >>> 16), (byte)(i >>> 8), (byte)i};
}
public static final byte[] toBytes(short i) {
return new byte[] { (byte)(i>>8), (byte)i };
}
public static final void toBytes(short i,byte[] b,int offset) {
b[offset++] = (byte)(i>>8);
b[offset++] = (byte)i;
}
public static final void toBytes(int i,byte[] b,int offset) {
b[offset++] = (byte)(i>>24);
b[offset++] = (byte)(i>>16);
b[offset++] = (byte)(i>>8);
b[offset++] = (byte)i;
}
}
Show details
Hide details
Change log
r2
by thedwilliams on Jun 8, 2010
Diff
[No log message]
Go to:
/trunk/build
/trunk/build/pelops.jar
/trunk/lib
...k/lib/apache-cassandra-0.6.0.jar
/trunk/lib/libthrift-r917130.jar
/trunk/lib/slf4j-api-1.5.10.jar
/trunk/lib/uuid-3.2-sources.jar
/trunk/lib/uuid-3.2.jar
/trunk/src
/trunk/src/org
/trunk/src/org/wyki
/trunk/src/org/wyki/cassandra
...nk/src/org/wyki/cassandra/pelops
...cassandra/pelops/IOperation.java
...cassandra/pelops/KeyDeletor.java
...ndra/pelops/KeyspaceOperand.java
...ki/cassandra/pelops/Metrics.java
...ki/cassandra/pelops/Mutator.java
...ssandra/pelops/NumberHelper.java
...ki/cassandra/pelops/Operand.java
...yki/cassandra/pelops/Pelops.java
...yki/cassandra/pelops/Policy.java
...i/cassandra/pelops/Selector.java
...ssandra/pelops/StringHelper.java
...cassandra/pelops/ThriftPool.java
...cassandra/pelops/UuidHelper.java
/trunk/src/org/wyki/concurrency
.../concurrency/AutoResetEvent.java
...yki/concurrency/IResetEvent.java
...oncurrency/ManualResetEvent.java
/trunk/src/org/wyki/networking
.../src/org/wyki/networking/utility
...g/utility/NetworkAlgorithms.java
/trunk/src/org/wyki/portability
.../portability/ILoggerFactory.java
...yki/portability/SystemProxy.java
Project members,
sign in
to write a code review
Older revisions
All revisions of this file
File info
Size: 1723 bytes, 67 lines
View raw file
Powered by
Google Project Hosting