MCPcopy Create free account
hub / github.com/alibaba/DataX / ClassSize

Class ClassSize

core/src/main/java/com/alibaba/datax/core/util/ClassSize.java:6–42  ·  view source on GitHub ↗

Created by liqiang on 15/12/12.

Source from the content-addressed store, hash-verified

4 * Created by liqiang on 15/12/12.
5 */
6public class ClassSize {
7
8 public static final int DefaultRecordHead;
9 public static final int ColumnHead;
10
11 //objectHead的大小
12 public static final int REFERENCE;
13 public static final int OBJECT;
14 public static final int ARRAY;
15 public static final int ARRAYLIST;
16 static {
17 //only 64位
18 REFERENCE = 8;
19
20 OBJECT = 2 * REFERENCE;
21
22 ARRAY = align(3 * REFERENCE);
23
24 // 16+8+24+16
25 ARRAYLIST = align(OBJECT + align(REFERENCE) + align(ARRAY) +
26 (2 * Long.SIZE / Byte.SIZE));
27 // 8+64+8
28 DefaultRecordHead = align(align(REFERENCE) + ClassSize.ARRAYLIST + 2 * Integer.SIZE / Byte.SIZE);
29 //16+4
30 ColumnHead = align(2 * REFERENCE + Integer.SIZE / Byte.SIZE);
31 }
32
33 public static int align(int num) {
34 return (int)(align((long)num));
35 }
36
37 public static long align(long num) {
38 //The 7 comes from that the alignSize is 8 which is the number of bytes
39 //stored and sent together
40 return ((num + 7) >> 3) << 3;
41 }
42}

Callers

nothing calls this directly

Calls 1

alignMethod · 0.95

Tested by

no test coverage detected