Skip to content

Commit 598dbd0

Browse files
Merge remote-tracking branch 'origin/rid-set-sbtree' into rid-set-sbtree
2 parents ac1a1e5 + accba4f commit 598dbd0

File tree

3 files changed

+64
-37
lines changed

3 files changed

+64
-37
lines changed

core/src/main/java/com/orientechnologies/orient/core/db/record/ORecordLazyMultiValue.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ public interface ORecordLazyMultiValue extends ODetachable, OSizeable {
2424

2525
/**
2626
* Browse all the set to convert all the items into records.
27+
*
28+
* It converts only items that already loaded into memory from storage. To convert records that will be fetched from disk later
29+
* use {@link #setAutoConvertToRecord(boolean)}
2730
*/
2831
public void convertLinks2Records();
2932

@@ -38,4 +41,4 @@ public interface ORecordLazyMultiValue extends ODetachable, OSizeable {
3841

3942
public void setAutoConvertToRecord(boolean convertToRecord);
4043

41-
}
44+
}

core/src/main/java/com/orientechnologies/orient/core/db/record/ridbag/sbtree/OSBTreeRidBag.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.util.NavigableMap;
3030
import java.util.NoSuchElementException;
3131
import java.util.Set;
32+
import java.util.TreeMap;
3233
import java.util.UUID;
3334
import java.util.WeakHashMap;
3435
import java.util.concurrent.ConcurrentSkipListMap;
@@ -132,7 +133,14 @@ public Iterator<OIdentifiable> rawIterator() {
132133

133134
@Override
134135
public void convertLinks2Records() {
135-
throw new UnsupportedOperationException();
136+
TreeMap<OIdentifiable, Change> newChanges = new TreeMap<OIdentifiable, Change>();
137+
for (Map.Entry<OIdentifiable, Change> entry : changes.entrySet()) {
138+
final OIdentifiable key = entry.getKey().getRecord();
139+
newChanges.put((key == null) ? entry.getKey() : key, entry.getValue());
140+
}
141+
142+
changes.clear();
143+
changes.putAll(newChanges);
136144
}
137145

138146
@Override
@@ -960,7 +968,7 @@ public Map<OIdentifiable, Change> deserializeChanges(byte[] stream, int offset)
960968
offset += Change.SIZE;
961969

962970
final OIdentifiable identifiable;
963-
if (rid.isTemporary())
971+
if (rid.isTemporary() && rid.getRecord() != null)
964972
identifiable = rid.getRecord();
965973
else
966974
identifiable = rid;

graphdb/src/test/java/com/tinkerpop/blueprints/impls/orient/OrientCommitMT.java

Lines changed: 50 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
package com.tinkerpop.blueprints.impls.orient;
22

3-
import com.orientechnologies.orient.core.config.OGlobalConfiguration;
4-
import com.orientechnologies.orient.core.id.ORID;
5-
import com.orientechnologies.orient.core.metadata.schema.OClass;
6-
import com.orientechnologies.orient.core.metadata.schema.OType;
7-
import com.tinkerpop.blueprints.Vertex;
8-
import org.junit.*;
9-
103
import java.io.File;
114
import java.io.FileNotFoundException;
5+
import java.io.IOException;
126
import java.io.PrintStream;
13-
import java.util.*;
7+
import java.util.ArrayList;
8+
import java.util.List;
9+
import java.util.Random;
1410
import java.util.concurrent.CountDownLatch;
1511
import java.util.concurrent.atomic.AtomicInteger;
1612

13+
import org.junit.AfterClass;
14+
import org.junit.Assert;
15+
import org.junit.Before;
16+
import org.junit.Ignore;
17+
import org.junit.Test;
18+
19+
import com.orientechnologies.orient.client.db.ODatabaseHelper;
20+
import com.orientechnologies.orient.client.remote.OServerAdmin;
21+
import com.orientechnologies.orient.core.config.OGlobalConfiguration;
22+
import com.orientechnologies.orient.core.id.ORID;
23+
import com.orientechnologies.orient.core.metadata.schema.OClass;
24+
import com.orientechnologies.orient.core.metadata.schema.OType;
25+
import com.tinkerpop.blueprints.Vertex;
26+
1727
public class OrientCommitMT {
1828
public static final String DB_URL = "remote:localhost/avltreetest";
1929
public static final String DB_USER = "admin";
@@ -33,25 +43,41 @@ public class OrientCommitMT {
3343
final AtomicInteger idGenerator = new AtomicInteger(1);
3444

3545
private static Random random = new Random();
36-
private static final OrientGraphFactory factory = new OrientGraphFactory(DB_URL);
37-
38-
@BeforeClass
39-
public static void beforeClass() {
40-
factory.setupPool(5, 10);
41-
// OrientGraph graph = new OrientGraph(DB_URL, DB_USER, DB_PASSWORD);
42-
// graph.drop();
43-
}
46+
private static OrientGraphFactory factory;
4447

4548
@Before
46-
public void setUp() {
49+
public void setUp() throws IOException {
50+
if (DB_URL.startsWith("remote:")) {
51+
OServerAdmin serverAdmin = new OServerAdmin(DB_URL);
52+
serverAdmin.connect("root", ODatabaseHelper.getServerRootPassword());
53+
54+
if (serverAdmin.existsDatabase("plocal")) {
55+
serverAdmin.dropDatabase("plocal");
56+
}
57+
serverAdmin.createDatabase(DB_URL, "graph", "plocal");
58+
} else {
59+
OrientGraph graph = new OrientGraph(DB_URL, DB_USER, DB_PASSWORD);
60+
graph.drop();
61+
}
62+
factory = new OrientGraphFactory(DB_URL).setupPool(5, 10);
63+
4764
buildSchemaAndSeed();
4865
this.isValidData = true;
4966
}
5067

5168
@AfterClass
52-
public static void afterClass() {
53-
// OrientGraph graph = new OrientGraph(DB_URL, DB_USER, DB_PASSWORD);
54-
// graph.drop();
69+
public static void afterClass() throws IOException {
70+
if (DB_URL.startsWith("remote:")) {
71+
OServerAdmin serverAdmin = new OServerAdmin(DB_URL);
72+
serverAdmin.connect("root", ODatabaseHelper.getServerRootPassword());
73+
74+
if (serverAdmin.existsDatabase("plocal")) {
75+
serverAdmin.dropDatabase("plocal");
76+
}
77+
} else {
78+
OrientGraph graph = new OrientGraph(DB_URL, DB_USER, DB_PASSWORD);
79+
graph.drop();
80+
}
5581
}
5682

5783
@Test
@@ -127,14 +153,6 @@ public String getFailureMessage() {
127153
return this.failureMessage;
128154
}
129155

130-
/**
131-
* @param threadCount
132-
* - number of thread to run
133-
* @param maxSleepTime
134-
* @param maxOpCount
135-
* @param initialCacheSize
136-
* @param runtimeInMin
137-
*/
138156
private void executeTest(final int threadCount, final int maxSleepTime, final int maxOpCount, final int initialCacheSize,
139157
final int runtimeInMin) {
140158
CountDownLatch endLatch = new CountDownLatch(threadCount);
@@ -342,8 +360,9 @@ private boolean isInDatabase(final ORID id, OrientGraph orientGraph) throws Exce
342360
* operation in the temp cache.
343361
*
344362
* @param tempCache
363+
* cached objects
345364
*/
346-
private void updateCache(final List<TempCacheObject> tempCache) {
365+
private void updateCache(final List<TempCacheObject> tempCache) {
347366
for (TempCacheObject tempCacheObject : tempCache) {
348367
ORID id = tempCacheObject.getOrientId();
349368
Operation operation = tempCacheObject.getOperation();
@@ -463,13 +482,10 @@ public Integer getCustomId() {
463482
}
464483

465484
public String toString() {
466-
StringBuilder stringObject = new StringBuilder();
467-
stringObject.append("Operation:").append(this.operation).append(", ORID:").append(this.orientId).append(", CustomId:")
468-
.append(this.customId);
469-
return stringObject.toString();
485+
return "Operation:" + this.operation + ", ORID:" + this.orientId + ", CustomId:" + this.customId;
470486
}
471487

472-
}
488+
}
473489
}
474490

475491
/**

0 commit comments

Comments
 (0)