Visitar URL original
Multi page records (#335) · humemai/arcadedb-embedded-python@d35ac0c · GitHub
Skip to content

Commit d35ac0c

Browse files
authored
Multi page records (#335)
* First release supporting create, delete, read and scan of multi-page records. Partial done with update, still missing some work on it Issue #332 * Completed multi-chunk update * Fixed last tests
1 parent 817a6bc commit d35ac0c

29 files changed

Lines changed: 566 additions & 176 deletions

File tree

‎console/src/test/java/com/arcadedb/console/ConsoleTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
*/
1919
package com.arcadedb.console;
2020

21-
import com.arcadedb.database.DatabaseFactory;
2221
import com.arcadedb.exception.DatabaseOperationException;
22+
import com.arcadedb.server.TestServerHelper;
2323
import com.arcadedb.utility.FileUtils;
2424
import org.junit.jupiter.api.AfterEach;
2525
import org.junit.jupiter.api.Assertions;
@@ -42,7 +42,7 @@ public void populate() throws IOException {
4242
@AfterEach
4343
public void drop() {
4444
console.close();
45-
Assertions.assertTrue(DatabaseFactory.getActiveDatabaseInstances().isEmpty(), "Found active databases: " + DatabaseFactory.getActiveDatabaseInstances());
45+
TestServerHelper.checkActiveDatabases();
4646
FileUtils.deleteRecursively(new File("target/databases"));
4747
}
4848

‎engine/src/main/java/com/arcadedb/database/BaseRecord.java‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import com.arcadedb.graph.Edge;
2323
import com.arcadedb.graph.Vertex;
2424

25-
import java.util.Objects;
25+
import java.util.*;
2626

2727
public abstract class BaseRecord implements Record {
2828
protected final DatabaseInternal database;
@@ -113,45 +113,45 @@ public Document asDocument() {
113113
@Override
114114
public Document asDocument(boolean loadContent) {
115115
if (this instanceof Edge)
116-
throw new ClassCastException("Cannot cast an edge to a document");
116+
throw new ClassCastException("Cannot cast the edge " + getIdentity() + " to a document");
117117
if (this instanceof Vertex)
118-
throw new ClassCastException("Cannot cast a vertex to a document");
118+
throw new ClassCastException("Cannot cast the vertex " + getIdentity() + " to a document");
119119
throw new ClassCastException("Current record is not a document");
120120
}
121121

122122
@Override
123123
public Vertex asVertex() {
124124
if (this instanceof Edge)
125-
throw new ClassCastException("Cannot cast an edge to a vertex");
125+
throw new ClassCastException("Cannot cast the edge " + getIdentity() + " to a vertex");
126126
if (this instanceof Document)
127-
throw new ClassCastException("Cannot cast a document to a vertex");
127+
throw new ClassCastException("Cannot cast the document " + getIdentity() + " to a vertex");
128128
throw new ClassCastException("Current record is not a vertex");
129129
}
130130

131131
@Override
132132
public Vertex asVertex(final boolean loadContent) {
133133
if (this instanceof Edge)
134-
throw new ClassCastException("Cannot cast an edge to a vertex");
134+
throw new ClassCastException("Cannot cast the edge " + getIdentity() + " to a vertex");
135135
if (this instanceof Document)
136-
throw new ClassCastException("Cannot cast a document to a vertex");
136+
throw new ClassCastException("Cannot cast the document " + getIdentity() + " to a vertex");
137137
throw new ClassCastException("Current record is not a vertex");
138138
}
139139

140140
@Override
141141
public Edge asEdge() {
142142
if (this instanceof Vertex)
143-
throw new ClassCastException("Cannot cast a vertex to an edge");
143+
throw new ClassCastException("Cannot cast the vertex " + getIdentity() + " to an edge");
144144
if (this instanceof Document)
145-
throw new ClassCastException("Cannot cast a document to an edge");
145+
throw new ClassCastException("Cannot cast the document " + getIdentity() + " to an edge");
146146
throw new ClassCastException("Current record is not a edge");
147147
}
148148

149149
@Override
150150
public Edge asEdge(boolean loadContent) {
151151
if (this instanceof Vertex)
152-
throw new ClassCastException("Cannot cast a vertex to an edge");
152+
throw new ClassCastException("Cannot cast the vertex " + getIdentity() + " to an edge");
153153
if (this instanceof Document)
154-
throw new ClassCastException("Cannot cast a document to an edge");
154+
throw new ClassCastException("Cannot cast the document " + getIdentity() + " to an edge");
155155
throw new ClassCastException("Current record is not a edge");
156156
}
157157
}

‎engine/src/main/java/com/arcadedb/database/Binary.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public void append(final Binary toCopy) {
140140
final int contentSize = toCopy.size();
141141
if (contentSize > 0) {
142142
checkForAllocation(buffer.position(), contentSize);
143-
buffer.put(toCopy.content, 0, contentSize);
143+
buffer.put(toCopy.content, toCopy.getContentBeginOffset(), contentSize);
144144
}
145145
}
146146

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

610610
final byte[] newContent = new byte[newSize];
611-
System.arraycopy(content, 0, newContent, 0, content.length);
611+
if (size > 0)
612+
System.arraycopy(content, 0, newContent, 0, content.length);
612613
this.content = newContent;
613614

614615
final int oldPosition = this.buffer.position();

‎engine/src/main/java/com/arcadedb/database/RID.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
import com.arcadedb.graph.Vertex;
2424
import com.arcadedb.utility.NumberUtils;
2525

26-
import java.io.Serializable;
27-
import java.util.Objects;
26+
import java.io.*;
27+
import java.util.*;
2828

2929
/**
3030
* 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

0 commit comments

Comments
 (0)