Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions console/src/main/java/com/arcadedb/console/Console.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.arcadedb.database.DatabaseInternal;
import com.arcadedb.database.Document;
import com.arcadedb.database.TransactionContext;
import com.arcadedb.engine.DatabaseChecker;
import com.arcadedb.engine.PaginatedFile;
import com.arcadedb.exception.ArcadeDBException;
import com.arcadedb.graph.Edge;
Expand Down Expand Up @@ -162,8 +161,6 @@ private boolean execute(final String line) throws IOException {
if (line != null && !line.isEmpty()) {
if (line.startsWith("begin"))
executeBegin();
else if (line.startsWith("check database"))
executeCheckDatabase();
else if (line.startsWith("close"))
executeClose();
else if (line.startsWith("commit"))
Expand Down Expand Up @@ -271,16 +268,6 @@ private void executeClose() {
}
}

private void executeCheckDatabase() {
if (localDatabase == null)
throw new ConsoleException("Database is closed");

if (localDatabase.isTransactionActive())
localDatabase.commit();

new DatabaseChecker().check(localDatabase, 1);
}

private void executeConnect(final String line) {
final String url = line.substring("connect".length()).trim();

Expand Down
44 changes: 42 additions & 2 deletions engine/src/main/grammar/SQLGrammar.jjt
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ TOKEN:
|
< CACHE: ( "c" | "C" ) ( "a" | "A" ) ( "c" | "C" ) ( "h" | "H" ) ( "e" | "E" ) >
|
< CHECK: ( "c" | "C" ) ( "h" | "H" ) ( "e" | "E" ) ( "c" | "C" ) ( "k" | "K" ) >
|
< CYCLE: ( "c" | "C" ) ( "y" | "Y" ) ( "c" | "C" ) ( "l" | "L" ) ( "e" | "E" ) >
|
< NOLIMIT: ( "n" | "N" ) ( "o" | "O" ) ( "l" | "L" ) ( "i" | "I" ) ( "m" | "M" ) ( "i" | "I" ) ( "t" | "T" ) >
Expand Down Expand Up @@ -309,6 +311,8 @@ TOKEN:
|
< FAIL: ( "F" | "f") ( "A" | "a") ( "I" | "i") ( "L" | "l") >
|
< FIX: ( "F" | "f") ( "I" | "i") ( "X" | "x") >
|
< ISOLATION: ( "I" | "i") ( "S" | "s") ( "O" | "o") ( "L" | "l") ( "A" | "a") ( "T" | "t") ( "I" | "i") ( "O" | "o") ( "N" | "n") >
|
< SLEEP: ( "S" | "s") ( "L" | "l") ( "E" | "e") ( "E" | "e") ( "P" | "p") >
Expand Down Expand Up @@ -648,6 +652,19 @@ Rid Rid():
{ return jjtThis; }
}


BucketIdentifier BucketIdentifier():
{}
{
(
jjtThis.bucketId = PInteger()
|
jjtThis.bucketName = PString()
)
{ return jjtThis; }
}


/** Root productions. */
Statement parse() :
{Statement result;}
Expand Down Expand Up @@ -750,6 +767,8 @@ Identifier Identifier():
|
token = <CUSTOM>
|
token = <CHECK>
|
token = <ON>
|
token = <OFF>
Expand Down Expand Up @@ -928,8 +947,6 @@ PInteger PInteger():
{ return jjtThis; }
}



FloatingPoint FloatingPoint():
{
String stringValue;
Expand Down Expand Up @@ -1082,6 +1099,8 @@ Statement StatementInternal():
result = ExportDatabaseStatement()
|
result = BackupDatabaseStatement()
|
result = CheckDatabaseStatement()
)
)
|
Expand Down Expand Up @@ -4247,3 +4266,24 @@ BackupDatabaseStatement BackupDatabaseStatement():
)
{return jjtThis; }
}

CheckDatabaseStatement CheckDatabaseStatement():
{
BucketIdentifier lastBucket;
String lastType;
}
{
(
<CHECK> <DATABASE>
[ <TYPE>
lastType = PString() { jjtThis.types.add(lastType); }
( <COMMA> lastType = PString() { jjtThis.types.add(lastType); } )*
]
[ <BUCKET>
lastBucket = BucketIdentifier() { jjtThis.buckets.add(lastBucket); }
( <COMMA> lastBucket = BucketIdentifier() { jjtThis.buckets.add(lastBucket); } )*
]
[ <FIX> { jjtThis.fix = true; } ]
)
{return jjtThis; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public class EmbeddedDatabase extends RWLockContext implements DatabaseInternal
protected final String databasePath;
protected final BinarySerializer serializer = new BinarySerializer();
protected final RecordFactory recordFactory = new RecordFactory();
protected final GraphEngine graphEngine = new GraphEngine();
protected final GraphEngine graphEngine;
protected final WALFileFactory walFactory;
protected final DocumentIndexer indexer;
protected final QueryEngineManager queryEngineManager;
Expand Down Expand Up @@ -158,6 +158,7 @@ protected EmbeddedDatabase(final String path, final PaginatedFile.MODE mode, fin

indexer = new DocumentIndexer(this);
queryEngineManager = new QueryEngineManager();
graphEngine = new GraphEngine(this);

} catch (Exception e) {
if (e instanceof DatabaseOperationException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public CreateIncomingEdgeAsyncTask(final RID sourceVertex, final Identifiable de
}

public void execute(final DatabaseAsyncExecutorImpl.AsyncThread async, final DatabaseInternal database) {
database.getGraphEngine().connectIncomingEdge(database, destinationVertex, sourceVertexRID, edge.getIdentity());
database.getGraphEngine().connectIncomingEdge(destinationVertex, sourceVertexRID, edge.getIdentity());

if (callback != null)
callback.call((Edge) edge.getRecord(), false, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public CreateOutgoingEdgesAsyncTask(final VertexInternal sourceVertex, final Lis
}

public void execute(final DatabaseAsyncExecutorImpl.AsyncThread async, final DatabaseInternal database) {
final List<Edge> edges = database.getGraphEngine().newEdges(database, sourceVertex, connections, edgeBidirectional);
final List<Edge> edges = database.getGraphEngine().newEdges(sourceVertex, connections, edgeBidirectional);

if (callback != null)
callback.call(edges);
Expand Down
24 changes: 20 additions & 4 deletions engine/src/main/java/com/arcadedb/engine/Bucket.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
import com.arcadedb.exception.DatabaseOperationException;
import com.arcadedb.exception.RecordNotFoundException;
import com.arcadedb.log.LogManager;
import com.arcadedb.schema.DocumentType;
import com.arcadedb.schema.EdgeType;
import com.arcadedb.schema.VertexType;
import com.arcadedb.security.SecurityDatabaseUser;
import com.arcadedb.utility.FileUtils;

Expand Down Expand Up @@ -271,7 +274,7 @@ protected Map<String, Long> check(final int verboseLevel) {
LogManager.instance().log(this, Level.INFO, "- Checking bucket '%s' (totalPages=%d spaceOnDisk=%s pageSize=%s)...", null, name, totalPages,
FileUtils.getSizeAsString(totalPages * pageSize), FileUtils.getSizeAsString(pageSize));

long totalRecords = 0;
long totalAllocatedRecords = 0;
long totalActiveRecords = 0;
long totalPlaceholderRecords = 0;
long totalSurrogateRecords = 0;
Expand All @@ -293,7 +296,7 @@ protected Map<String, Long> check(final int verboseLevel) {
final int recordPositionInPage = (int) page.readUnsignedInt(PAGE_RECORD_TABLE_OFFSET + positionInPage * INT_SERIALIZED_SIZE);
final long[] recordSize = page.readNumberAndSize(recordPositionInPage);

totalRecords++;
totalAllocatedRecords++;

if (recordSize[0] == 0) {
pageDeletedRecords++;
Expand Down Expand Up @@ -330,18 +333,31 @@ protected Map<String, Long> check(final int verboseLevel) {

if (verboseLevel > 1)
LogManager.instance()
.log(this, Level.INFO, "-- Total records=%d (actives=%d deleted=%d placeholders=%d surrogates=%d) avgPageUsed=%.2f%%", null, totalRecords,
.log(this, Level.INFO, "-- Total records=%d (actives=%d deleted=%d placeholders=%d surrogates=%d) avgPageUsed=%.2f%%", null, totalAllocatedRecords,
totalActiveRecords, totalDeletedRecords, totalPlaceholderRecords, totalSurrogateRecords, avgPageUsed);

stats.put("pageSize", (long) pageSize);
stats.put("totalRecords", totalRecords);
stats.put("totalPages", (long) totalPages);
stats.put("totalAllocatedRecords", totalAllocatedRecords);
stats.put("totalActiveRecords", totalActiveRecords);
stats.put("totalPlaceholderRecords", totalPlaceholderRecords);
stats.put("totalSurrogateRecords", totalSurrogateRecords);
stats.put("totalDeletedRecords", totalDeletedRecords);
stats.put("totalMaxOffset", totalMaxOffset);

DocumentType type = database.getSchema().getTypeByBucketId(id);
if (type instanceof VertexType) {
stats.put("totalAllocatedVertices", totalAllocatedRecords);
stats.put("totalActiveVertices", totalActiveRecords);
} else if (type instanceof EdgeType) {
stats.put("totalAllocatedEdges", totalAllocatedRecords);
stats.put("totalActiveEdges", totalActiveRecords);
}

stats.put("warnings", 0L);
stats.put("autoFix", 0L);
stats.put("errors", 0L);

return stats;
}

Expand Down
Loading