5151import com .arcadedb .graph .Edge ;
5252import com .arcadedb .graph .GraphBatch ;
5353import com .arcadedb .graph .GraphEngine ;
54+ import com .arcadedb .graph .GraphTraversalProviderRegistry ;
5455import com .arcadedb .graph .MutableVertex ;
5556import com .arcadedb .graph .Vertex ;
5657import com .arcadedb .graph .VertexInternal ;
57- import com .arcadedb .graph .GraphTraversalProviderRegistry ;
5858import com .arcadedb .graph .olap .GraphAnalyticalView ;
5959import com .arcadedb .graph .olap .GraphAnalyticalViewPersistence ;
6060import com .arcadedb .graph .olap .GraphAnalyticalViewRegistry ;
133133 * @author Luca Garulli (l.garulli@arcadedata.com)
134134 */
135135public class LocalDatabase extends RWLockContext implements DatabaseInternal {
136- public static final int EDGE_LIST_INITIAL_CHUNK_SIZE = 64 ;
137- public static final int MAX_RECOMMENDED_EDGE_LIST_CHUNK_SIZE = 8192 ;
138- private static final Set <String > SUPPORTED_FILE_EXT = Set .of (
136+ public static final int EDGE_LIST_INITIAL_CHUNK_SIZE = 64 ;
137+ public static final int MAX_RECOMMENDED_EDGE_LIST_CHUNK_SIZE = 8192 ;
138+
139+ private static final Set <String > SUPPORTED_FILE_EXT = Set .of (
139140 Dictionary .DICT_EXT ,
140141 LocalBucket .BUCKET_EXT ,
141142 LSMTreeIndexMutable .NOTUNIQUE_INDEX_EXT ,
@@ -147,57 +148,50 @@ public class LocalDatabase extends RWLockContext implements DatabaseInternal {
147148 TimeSeriesBucket .BUCKET_EXT ,
148149 HashIndexBucket .UNIQUE_INDEX_EXT ,
149150 HashIndexBucket .NOTUNIQUE_INDEX_EXT );
150- public final AtomicLong indexCompactions =
151- new AtomicLong ();
152- protected final String name ;
153- protected final ComponentFile .MODE mode ;
154- protected final ContextConfiguration configuration ;
155- protected final String databasePath ;
156- protected final BinarySerializer serializer ;
157- protected final RecordFactory recordFactory =
158- new RecordFactory ();
159- protected final GraphEngine graphEngine ;
160- protected final WALFileFactory walFactory ;
161- protected final DocumentIndexer indexer ;
162- protected final DatabaseStats stats =
163- new DatabaseStats ();
164- protected FileManager fileManager ;
165- protected LocalSchema schema ;
166- protected TransactionManager transactionManager ;
167- protected volatile DatabaseAsyncExecutorImpl async = null ;
168- protected final Lock asyncLock =
169- new ReentrantLock ();
170- protected boolean autoTransaction = false ;
171- protected volatile boolean open = false ;
172- private boolean readYourWrites = true ;
173- private final Map <CALLBACK_EVENT , List <Callable <Void >>> callbacks ;
174- private final StatementCache statementCache ;
175- private final ExecutionPlanCache executionPlanCache ;
176- private final CypherStatementCache cypherStatementCache ;
177- private final CypherPlanCache cypherPlanCache ;
178- private final File configurationFile ;
179- private DatabaseInternal wrappedDatabaseInstance = this ;
180- private final SecurityManager security ;
181- private final Map <String , Object > wrappers = new HashMap <>();
182- private File lockFile ;
183- private RandomAccessFile lockFileIO ;
184- private FileChannel lockFileIOChannel ;
185- private FileLock lockFileLock ;
186- private final RecordEventsRegistry events =
187- new RecordEventsRegistry ();
188- private final ConcurrentHashMap <String , QueryEngine > reusableQueryEngines =
189- new ConcurrentHashMap <>();
190- private final ConcurrentHashMap <String , Object > globalVariables =
191- new ConcurrentHashMap <>();
192- private TRANSACTION_ISOLATION_LEVEL transactionIsolationLevel =
193- TRANSACTION_ISOLATION_LEVEL .READ_COMMITTED ;
194- private long openedOn ;
195- private long lastUpdatedOn ;
196- private long lastUsedOn ;
197- private int cachedHashCode = 0 ;
151+
152+ public final AtomicLong indexCompactions = new AtomicLong ();
153+ protected final String name ;
154+ protected final ComponentFile .MODE mode ;
155+ protected final ContextConfiguration configuration ;
156+ protected final String databasePath ;
157+ protected final BinarySerializer serializer ;
158+ protected final RecordFactory recordFactory = new RecordFactory ();
159+ protected final GraphEngine graphEngine ;
160+ protected final WALFileFactory walFactory ;
161+ protected final DocumentIndexer indexer ;
162+ protected final DatabaseStats stats = new DatabaseStats ();
163+ protected FileManager fileManager ;
164+ protected LocalSchema schema ;
165+ protected TransactionManager transactionManager ;
166+ protected volatile DatabaseAsyncExecutorImpl async = null ;
167+ protected final Lock asyncLock = new ReentrantLock ();
168+ protected boolean autoTransaction = false ;
169+ protected volatile boolean open = false ;
170+ private boolean readYourWrites = true ;
171+ private final Map <CALLBACK_EVENT , List <Callable <Void >>> callbacks ;
172+ private final StatementCache statementCache ;
173+ private final ExecutionPlanCache executionPlanCache ;
174+ private final CypherStatementCache cypherStatementCache ;
175+ private final CypherPlanCache cypherPlanCache ;
176+ private final File configurationFile ;
177+ private DatabaseInternal wrappedDatabaseInstance = this ;
178+ private final SecurityManager security ;
179+ private final Map <String , Object > wrappers = new HashMap <>();
180+ private File lockFile ;
181+ private RandomAccessFile lockFileIO ;
182+ private FileChannel lockFileIOChannel ;
183+ private FileLock lockFileLock ;
184+ private final RecordEventsRegistry events = new RecordEventsRegistry ();
185+ private final ConcurrentHashMap <String , QueryEngine > reusableQueryEngines = new ConcurrentHashMap <>();
186+ private final ConcurrentHashMap <String , Object > globalVariables = new ConcurrentHashMap <>();
187+ private TRANSACTION_ISOLATION_LEVEL transactionIsolationLevel = TRANSACTION_ISOLATION_LEVEL .READ_COMMITTED ;
188+ private long openedOn ;
189+ private long lastUpdatedOn ;
190+ private long lastUsedOn ;
191+ private int cachedHashCode = 0 ;
198192
199193 protected LocalDatabase (final String path , final ComponentFile .MODE mode , final ContextConfiguration configuration ,
200- final SecurityManager security , final Map <CALLBACK_EVENT , List <Callable <Void >>> callbacks ) {
194+ final SecurityManager security , final Map <CALLBACK_EVENT , List <Callable <Void >>> callbacks ) {
201195 try {
202196 this .mode = mode ;
203197 this .configuration = configuration ;
@@ -600,7 +594,7 @@ public void scanType(final String typeName, final boolean polymorphic, final Doc
600594
601595 @ Override
602596 public void scanType (final String typeName , final boolean polymorphic , final DocumentCallback callback ,
603- final ErrorRecordCallback errorRecordCallback ) {
597+ final ErrorRecordCallback errorRecordCallback ) {
604598 stats .scanType .incrementAndGet ();
605599
606600 executeInReadLock (() -> {
@@ -643,7 +637,7 @@ public void scanBucket(final String bucketName, final RecordCallback callback) {
643637
644638 @ Override
645639 public void scanBucket (final String bucketName , final RecordCallback callback ,
646- final ErrorRecordCallback errorRecordCallback ) {
640+ final ErrorRecordCallback errorRecordCallback ) {
647641 stats .scanBucket .incrementAndGet ();
648642
649643 executeInReadLock (() -> {
@@ -826,7 +820,7 @@ record = recordFactory.newImmutableRecord(wrappedDatabaseInstance, type, rid, ty
826820
827821 @ Override
828822 public IndexCursor lookupByKey (final String type , final String keyName , final Object keyValue ) {
829- return lookupByKey (type , new String []{ keyName }, new Object []{ keyValue });
823+ return lookupByKey (type , new String [] { keyName }, new Object [] { keyValue });
830824 }
831825
832826 @ Override
@@ -1191,8 +1185,8 @@ public boolean transaction(final TransactionScope txBlock, final boolean joinCur
11911185
11921186 @ Override
11931187 public boolean transaction (final TransactionScope txBlock , final boolean joinCurrentTx , int attempts ,
1194- final OkCallback ok ,
1195- final ErrorCallback error ) {
1188+ final OkCallback ok ,
1189+ final ErrorCallback error ) {
11961190 if (txBlock == null )
11971191 throw new IllegalArgumentException ("Transaction block is null" );
11981192
@@ -1319,11 +1313,11 @@ public MutableVertex newVertex(final String typeName) {
13191313 }
13201314
13211315 public Edge newEdgeByKeys (final String sourceVertexType , final String [] sourceVertexKeyNames ,
1322- final Object [] sourceVertexKeyValues , final String destinationVertexType ,
1323- final String [] destinationVertexKeyNames ,
1324- final Object [] destinationVertexKeyValues , final boolean createVertexIfNotExist ,
1325- final String edgeType ,
1326- final boolean bidirectional , final Object ... properties ) {
1316+ final Object [] sourceVertexKeyValues , final String destinationVertexType ,
1317+ final String [] destinationVertexKeyNames ,
1318+ final Object [] destinationVertexKeyValues , final boolean createVertexIfNotExist ,
1319+ final String edgeType ,
1320+ final boolean bidirectional , final Object ... properties ) {
13271321 if (sourceVertexKeyNames == null )
13281322 throw new IllegalArgumentException ("Source vertex key is null" );
13291323
@@ -1375,10 +1369,10 @@ public Edge newEdgeByKeys(final String sourceVertexType, final String[] sourceVe
13751369
13761370 @ Deprecated
13771371 public Edge newEdgeByKeys (final Vertex sourceVertex , final String destinationVertexType ,
1378- final String [] destinationVertexKeyNames ,
1379- final Object [] destinationVertexKeyValues , final boolean createVertexIfNotExist ,
1380- final String edgeType ,
1381- final boolean bidirectional , final Object ... properties ) {
1372+ final String [] destinationVertexKeyNames ,
1373+ final Object [] destinationVertexKeyValues , final boolean createVertexIfNotExist ,
1374+ final String edgeType ,
1375+ final boolean bidirectional , final Object ... properties ) {
13821376 if (!bidirectional && ((EdgeType ) schema .getType (edgeType )).isBidirectional ())
13831377 throw new IllegalArgumentException ("Edge type '" + edgeType + "' is not bidirectional" );
13841378
@@ -1387,10 +1381,10 @@ public Edge newEdgeByKeys(final Vertex sourceVertex, final String destinationVer
13871381 }
13881382
13891383 public Edge newEdgeByKeys (final Vertex sourceVertex , final String destinationVertexType ,
1390- final String [] destinationVertexKeyNames ,
1391- final Object [] destinationVertexKeyValues , final boolean createVertexIfNotExist ,
1392- final String edgeType ,
1393- final Object ... properties ) {
1384+ final String [] destinationVertexKeyNames ,
1385+ final Object [] destinationVertexKeyValues , final boolean createVertexIfNotExist ,
1386+ final String edgeType ,
1387+ final Object ... properties ) {
13941388 if (sourceVertex == null )
13951389 throw new IllegalArgumentException ("Source vertex is null" );
13961390
@@ -1501,7 +1495,7 @@ public ResultSet command(final String language, final String query, final Object
15011495
15021496 @ Override
15031497 public ResultSet command (final String language , final String query , final ContextConfiguration configuration ,
1504- final Object ... parameters ) {
1498+ final Object ... parameters ) {
15051499 checkDatabaseIsOpen (true , "Cannot execute command on a read only database" );
15061500 stats .commands .incrementAndGet ();
15071501 return getQueryEngine (language ).command (query , configuration , parameters );
@@ -1514,7 +1508,7 @@ public ResultSet command(final String language, final String query, final Map<St
15141508
15151509 @ Override
15161510 public ResultSet command (final String language , final String query , final ContextConfiguration configuration ,
1517- final Map <String , Object > parameters ) {
1511+ final Map <String , Object > parameters ) {
15181512 checkDatabaseIsOpen (true , "Cannot execute command on a read only database" );
15191513 stats .commands .incrementAndGet ();
15201514 return getQueryEngine (language ).command (query , configuration , parameters );
0 commit comments