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
4 changes: 2 additions & 2 deletions console/src/test/java/com/arcadedb/console/ConsoleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/
package com.arcadedb.console;

import com.arcadedb.database.DatabaseFactory;
import com.arcadedb.exception.DatabaseOperationException;
import com.arcadedb.server.TestServerHelper;
import com.arcadedb.utility.FileUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
Expand All @@ -42,7 +42,7 @@ public void populate() throws IOException {
@AfterEach
public void drop() {
console.close();
Assertions.assertTrue(DatabaseFactory.getActiveDatabaseInstances().isEmpty(), "Found active databases: " + DatabaseFactory.getActiveDatabaseInstances());
TestServerHelper.checkActiveDatabases();
FileUtils.deleteRecursively(new File("target/databases"));
}

Expand Down
22 changes: 11 additions & 11 deletions engine/src/main/java/com/arcadedb/database/BaseRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.arcadedb.graph.Edge;
import com.arcadedb.graph.Vertex;

import java.util.Objects;
import java.util.*;

public abstract class BaseRecord implements Record {
protected final DatabaseInternal database;
Expand Down Expand Up @@ -113,45 +113,45 @@ public Document asDocument() {
@Override
public Document asDocument(boolean loadContent) {
if (this instanceof Edge)
throw new ClassCastException("Cannot cast an edge to a document");
throw new ClassCastException("Cannot cast the edge " + getIdentity() + " to a document");
if (this instanceof Vertex)
throw new ClassCastException("Cannot cast a vertex to a document");
throw new ClassCastException("Cannot cast the vertex " + getIdentity() + " to a document");
throw new ClassCastException("Current record is not a document");
}

@Override
public Vertex asVertex() {
if (this instanceof Edge)
throw new ClassCastException("Cannot cast an edge to a vertex");
throw new ClassCastException("Cannot cast the edge " + getIdentity() + " to a vertex");
if (this instanceof Document)
throw new ClassCastException("Cannot cast a document to a vertex");
throw new ClassCastException("Cannot cast the document " + getIdentity() + " to a vertex");
throw new ClassCastException("Current record is not a vertex");
}

@Override
public Vertex asVertex(final boolean loadContent) {
if (this instanceof Edge)
throw new ClassCastException("Cannot cast an edge to a vertex");
throw new ClassCastException("Cannot cast the edge " + getIdentity() + " to a vertex");
if (this instanceof Document)
throw new ClassCastException("Cannot cast a document to a vertex");
throw new ClassCastException("Cannot cast the document " + getIdentity() + " to a vertex");
throw new ClassCastException("Current record is not a vertex");
}

@Override
public Edge asEdge() {
if (this instanceof Vertex)
throw new ClassCastException("Cannot cast a vertex to an edge");
throw new ClassCastException("Cannot cast the vertex " + getIdentity() + " to an edge");
if (this instanceof Document)
throw new ClassCastException("Cannot cast a document to an edge");
throw new ClassCastException("Cannot cast the document " + getIdentity() + " to an edge");
throw new ClassCastException("Current record is not a edge");
}

@Override
public Edge asEdge(boolean loadContent) {
if (this instanceof Vertex)
throw new ClassCastException("Cannot cast a vertex to an edge");
throw new ClassCastException("Cannot cast the vertex " + getIdentity() + " to an edge");
if (this instanceof Document)
throw new ClassCastException("Cannot cast a document to an edge");
throw new ClassCastException("Cannot cast the document " + getIdentity() + " to an edge");
throw new ClassCastException("Current record is not a edge");
}
}
5 changes: 3 additions & 2 deletions engine/src/main/java/com/arcadedb/database/Binary.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void append(final Binary toCopy) {
final int contentSize = toCopy.size();
if (contentSize > 0) {
checkForAllocation(buffer.position(), contentSize);
buffer.put(toCopy.content, 0, contentSize);
buffer.put(toCopy.content, toCopy.getContentBeginOffset(), contentSize);
}
}

Expand Down Expand Up @@ -608,7 +608,8 @@ protected void checkForAllocation(final int offset, final int bytesToWrite) {
newSize = allocationChunkSize;

final byte[] newContent = new byte[newSize];
System.arraycopy(content, 0, newContent, 0, content.length);
if (size > 0)
System.arraycopy(content, 0, newContent, 0, content.length);
this.content = newContent;

final int oldPosition = this.buffer.position();
Expand Down
4 changes: 2 additions & 2 deletions engine/src/main/java/com/arcadedb/database/RID.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import com.arcadedb.graph.Vertex;
import com.arcadedb.utility.NumberUtils;

import java.io.Serializable;
import java.util.Objects;
import java.io.*;
import java.util.*;

/**
* It represents the logical address of a record in the database. The record id is composed by the bucket id (the bucket containing the record) and the offset
Expand Down
Loading