Skip to content

Commit

Permalink
chore: reset writeOlapVertex
Browse files Browse the repository at this point in the history
  • Loading branch information
VGalaxies committed Jan 15, 2024
1 parent 9a5a7d4 commit 2c84ac0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -427,24 +427,24 @@ public BackendEntry writeVertex(HugeVertex vertex) {

@Override
public BackendEntry writeOlapVertex(HugeVertex vertex) {
// TODO: adapt to hstore (merge olap table)
BinaryBackendEntry entry = newBackendEntry(HugeType.OLAP, vertex.id());
BytesBuffer buffer = BytesBuffer.allocate(8 + 16);

HugeProperty<?> hugeProperty = vertex.getProperties().iterator().next();
PropertyKey propertyKey = hugeProperty.propertyKey();
Collection<HugeProperty<?>> properties = vertex.getProperties();
if (properties.size() != 1) {
E.checkArgument(false,
"Expect 1 property for olap vertex, but got %s",
properties.size());
}
HugeProperty<?> property = properties.iterator().next();
PropertyKey propertyKey = property.propertyKey();
buffer.writeVInt(SchemaElement.schemaId(propertyKey.id()));
buffer.writeProperty(propertyKey, hugeProperty.value());

// olap表合并, key为 {property_key_id}{vertex_id}
BytesBuffer bufferName =
BytesBuffer.allocate(1 + propertyKey.id().length() + 1 + vertex.id().length());
bufferName.writeId(propertyKey.id());
byte[] idBytes = bufferName.writeId(vertex.id()).bytes();
buffer.writeProperty(propertyKey, property.value());

// Fill column
BinaryBackendEntry entry = new BinaryBackendEntry(HugeType.OLAP,
new BinaryId(idBytes, vertex.id()));

byte[] name = entry.id().asBytes();
byte[] name = this.keyWithIdPrefix ?
entry.id().asBytes() : BytesBuffer.BYTES_EMPTY;
entry.column(name, buffer.bytes());
entry.subId(propertyKey.id());
entry.olap(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.util.CloseableIterator;
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
import org.junit.After;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -156,6 +157,12 @@ public void initSchema() {
.create();
}

@After
public void resetGraphMode() {
// In OLAP-related tests, if an error occurs midway, the graph mode will not be reset.
graph().readMode(GraphReadMode.OLTP_ONLY);
}

protected void initPersonIndex(boolean indexCity) {
SchemaManager schema = graph().schema();

Expand Down

0 comments on commit 2c84ac0

Please sign in to comment.