1
+ package com .higherfrequencytrading .chronicle .impl ;
2
+
3
+ import com .higherfrequencytrading .chronicle .tools .ChronicleTools ;
4
+
5
+ import java .io .IOException ;
6
+ import java .nio .ByteOrder ;
7
+
8
+ /**
9
+
10
+ * @since 2013-06-30
11
+ */
12
+ public class ChronicleBuilder {
13
+
14
+ public static IndexedChronicleBuilder newIndexedChronicleBuilder (String basePath ) {
15
+ return new IndexedChronicleBuilder (basePath );
16
+ }
17
+
18
+ public static IntIndexedChronicleBuilder newIntIndexedChronicleBuilder (String basePath ) {
19
+ return new IntIndexedChronicleBuilder (basePath );
20
+ }
21
+
22
+ public static class IndexedChronicleBuilder {
23
+
24
+ protected String basePath ;
25
+ protected int dataBitSizeHint =
26
+ ChronicleTools .is64Bit () ? IndexedChronicle .DEFAULT_DATA_BITS_SIZE : IndexedChronicle .DEFAULT_DATA_BITS_SIZE32 ;
27
+ protected ByteOrder byteOrder = ByteOrder .nativeOrder ();
28
+ protected boolean minimiseByteBuffers = !ChronicleTools .is64Bit ();
29
+ protected boolean synchronousMode = false ;
30
+ protected boolean useUnsafe = false ;
31
+
32
+ public IndexedChronicleBuilder (String basePath ) {
33
+ this .basePath = basePath ;
34
+ }
35
+
36
+ public IndexedChronicleBuilder dataBitSizeHint (int dataBitSizeHint ) {
37
+ this .dataBitSizeHint = dataBitSizeHint ;
38
+ return this ;
39
+ }
40
+
41
+ public IndexedChronicleBuilder byteOrder (ByteOrder byteOrder ) {
42
+ this .byteOrder = byteOrder ;
43
+ return this ;
44
+ }
45
+
46
+ public IndexedChronicleBuilder minimiseByteBuffers (boolean minimiseByteBuffers ) {
47
+ this .minimiseByteBuffers = minimiseByteBuffers ;
48
+ return this ;
49
+ }
50
+
51
+ public IndexedChronicleBuilder useSynchronousMode (boolean synchronousMode ) {
52
+ this .synchronousMode = synchronousMode ;
53
+ return this ;
54
+ }
55
+
56
+ public IndexedChronicleBuilder useUnsafe (boolean useUnsafe ) {
57
+ this .useUnsafe = useUnsafe ;
58
+ return this ;
59
+ }
60
+
61
+ public IndexedChronicle build () throws IOException {
62
+ IndexedChronicle indexedChronicle =
63
+ new IndexedChronicle (basePath , dataBitSizeHint , byteOrder , minimiseByteBuffers , synchronousMode );
64
+ indexedChronicle .useUnsafe (useUnsafe );
65
+ return indexedChronicle ;
66
+ }
67
+ }
68
+
69
+ public static class IntIndexedChronicleBuilder extends IndexedChronicleBuilder {
70
+
71
+ public IntIndexedChronicleBuilder (String basePath ) {
72
+ super (basePath );
73
+ }
74
+
75
+ @ Override
76
+ public IntIndexedChronicle build () throws IOException {
77
+ IntIndexedChronicle intIndexedChronicle = new IntIndexedChronicle (basePath , dataBitSizeHint , byteOrder );
78
+ intIndexedChronicle .useUnsafe (useUnsafe );
79
+ return intIndexedChronicle ;
80
+ }
81
+ }
82
+
83
+
84
+ }
0 commit comments