Skip to content

Commit

Permalink
Merge branch '3.1.x' into laa_3.1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii0lomakin committed Sep 3, 2020
2 parents c53643a + 19df6ef commit fd726ee
Show file tree
Hide file tree
Showing 24 changed files with 228 additions and 24 deletions.
2 changes: 1 addition & 1 deletion client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<parent>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-parent</artifactId>
<version>3.1.2-SNAPSHOT</version>
<version>3.1.3-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<parent>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-parent</artifactId>
<version>3.1.2-SNAPSHOT</version>
<version>3.1.3-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,8 @@ protected synchronized void setOrderType(SequenceOrderType orderType) {
}

protected synchronized SequenceOrderType getOrderType() {
byte val = tlDocument.get().field(FIELD_ORDER_TYPE);
return SequenceOrderType.fromValue(val);
Byte val = tlDocument.get().field(FIELD_ORDER_TYPE);
return val == null ? SequenceOrderType.ORDER_POSITIVE : SequenceOrderType.fromValue(val);
}

protected synchronized void setIncrement(int value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ private void init(
secondValue = ((List) secondValue).get(0);
}
secondValue = unboxOResult(secondValue);
// TODO unwind collections!
Object thirdValue = thirdValueCombinations.get(i).execute((OResult) null, ctx);
if (thirdValue instanceof List
&& ((List) thirdValue).size() == 1
Expand All @@ -447,6 +448,44 @@ private void init(
secondValue = convertToIndexDefinitionTypes(secondValue, indexDef.getTypes());
thirdValue = convertToIndexDefinitionTypes(thirdValue, indexDef.getTypes());
} catch (Exception e) {
// manage subquery that returns a single collection
if (secondValue instanceof Collection && secondValue.equals(thirdValue)) {
((Collection) secondValue)
.forEach(
item -> {
Object itemVal = convertToIndexDefinitionTypes(item, indexDef.getTypes());
if (index.supportsOrderedIterations()) {

Object from = toBetweenIndexKey(indexDef, itemVal);
Object to = toBetweenIndexKey(indexDef, itemVal);
if (from == null && to == null) {
// manage null value explicitly, as the index API does not seem to work
// correctly in this
// case
stream = getStreamForNullKey();
storeAcquiredStream(stream);
} else {
stream =
index.streamEntriesBetween(
from, fromKeyIncluded, to, toKeyIncluded, isOrderAsc());
storeAcquiredStream(stream);
}

} else if (additionalRangeCondition == null
&& allEqualities((OAndBlock) condition)) {
stream = index.streamEntries(toIndexKey(indexDef, itemVal), isOrderAsc());
storeAcquiredStream(stream);
} else if (isFullTextIndex(index)) {
stream = index.streamEntries(toIndexKey(indexDef, itemVal), isOrderAsc());
storeAcquiredStream(stream);
} else {
throw new UnsupportedOperationException(
"Cannot evaluate " + this.condition + " on index " + index);
}
nextStreams.add(stream);
});
}

// some problems in key conversion, so the params do not match the key types
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ public boolean isCacheable() {
public OBooleanExpression rewriteIndexChainsAsSubqueries(OCommandContext ctx, OClass clazz) {
for (OBooleanExpression exp : subBlocks) {
exp.rewriteIndexChainsAsSubqueries(ctx, clazz);
// this is on purpose. Multiple optimizations in this case in an AND block can
// lead to wrong results (no intersection)
return this;
}
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5264,7 +5264,12 @@ private ORawBuffer readRecord(final ORecordId rid, final boolean prefetchRecords
}

if (transaction.get() != null) {
final OCluster cluster = doGetAndCheckCluster(rid.getClusterId());
final OCluster cluster;
try {
cluster = doGetAndCheckCluster(rid.getClusterId());
} catch (IllegalArgumentException e) {
throw OException.wrapException(new ORecordNotFoundException(rid), e);
}
// Disabled this assert have no meaning anymore
// assert iLockingStrategy.equals(LOCKING_STRATEGY.DEFAULT);
return doReadRecord(cluster, rid, prefetchRecords);
Expand All @@ -5281,8 +5286,12 @@ private ORawBuffer readRecord(final ORecordId rid, final boolean prefetchRecords
}
checkOpenness();
checkIfThreadIsBlocked();

final OCluster cluster = doGetAndCheckCluster(rid.getClusterId());
final OCluster cluster;
try {
cluster = doGetAndCheckCluster(rid.getClusterId());
} catch (IllegalArgumentException e) {
throw OException.wrapException(new ORecordNotFoundException(rid), e);
}
return doReadRecord(cluster, rid, prefetchRecords);
} finally {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4239,4 +4239,140 @@ public void testSimpleRangeQueryWithOutIndex() {
Assert.assertFalse(result.hasNext());
result.close();
}

@Test
public void testComplexIndexChain() {

// A -b-> B -c-> C -d-> D.name
// C.name

String classNamePrefix = "testComplexIndexChain_";
OClass a = db.getMetadata().getSchema().createClass(classNamePrefix + "A");
OClass b = db.getMetadata().getSchema().createClass(classNamePrefix + "C");
OClass c = db.getMetadata().getSchema().createClass(classNamePrefix + "B");
OClass d = db.getMetadata().getSchema().createClass(classNamePrefix + "D");

a.createProperty("b", OType.LINK, b).createIndex(OClass.INDEX_TYPE.NOTUNIQUE);
b.createProperty("c", OType.LINK, c).createIndex(OClass.INDEX_TYPE.NOTUNIQUE);
c.createProperty("d", OType.LINK, d).createIndex(OClass.INDEX_TYPE.NOTUNIQUE);
c.createProperty("name", OType.STRING).createIndex(OClass.INDEX_TYPE.NOTUNIQUE);
d.createProperty("name", OType.STRING).createIndex(OClass.INDEX_TYPE.NOTUNIQUE);

OElement dDoc = db.newElement(d.getName());
dDoc.setProperty("name", "foo");
dDoc.save();

OElement cDoc = db.newElement(c.getName());
cDoc.setProperty("name", "foo");
cDoc.setProperty("d", dDoc);
cDoc.save();

OElement bDoc = db.newElement(b.getName());
bDoc.setProperty("c", cDoc);
bDoc.save();

OElement aDoc = db.newElement(a.getName());
aDoc.setProperty("b", bDoc);
aDoc.save();

try (OResultSet rs =
db.query(
"SELECT FROM "
+ classNamePrefix
+ "A WHERE b.c.name IN ['foo'] AND b.c.d.name IN ['foo']")) {
Assert.assertTrue(rs.hasNext());
}

try (OResultSet rs =
db.query(
"SELECT FROM " + classNamePrefix + "A WHERE b.c.name = 'foo' AND b.c.d.name = 'foo'")) {
Assert.assertTrue(rs.hasNext());
Assert.assertTrue(
rs.getExecutionPlan().get().getSteps().stream()
.anyMatch(x -> x instanceof FetchFromIndexStep));
}
}

@Test
public void testIndexWithSubquery() {
String classNamePrefix = "testIndexWithSubquery_";
db.command("create class " + classNamePrefix + "Ownership extends V abstract;").close();
db.command("create class " + classNamePrefix + "User extends V;").close();
db.command("create property " + classNamePrefix + "User.id String;").close();
db.command(
"create index "
+ classNamePrefix
+ "User.id ON "
+ classNamePrefix
+ "User(id) unique;")
.close();
db.command(
"create class " + classNamePrefix + "Report extends " + classNamePrefix + "Ownership;")
.close();
db.command("create property " + classNamePrefix + "Report.id String;").close();
db.command("create property " + classNamePrefix + "Report.label String;").close();
db.command("create property " + classNamePrefix + "Report.format String;").close();
db.command("create property " + classNamePrefix + "Report.source String;").close();
db.command("create class " + classNamePrefix + "hasOwnership extends E;").close();
db.command("insert into " + classNamePrefix + "User content {id:\"admin\"};");
db.command(
"insert into "
+ classNamePrefix
+ "Report content {format:\"PDF\", id:\"rep1\", label:\"Report 1\", source:\"Report1.src\"};")
.close();
db.command(
"insert into "
+ classNamePrefix
+ "Report content {format:\"CSV\", id:\"rep2\", label:\"Report 2\", source:\"Report2.src\"};")
.close();
db.command(
"create edge "
+ classNamePrefix
+ "hasOwnership from (select from "
+ classNamePrefix
+ "User) to (select from "
+ classNamePrefix
+ "Report);")
.close();

try (OResultSet rs =
db.query(
"select from "
+ classNamePrefix
+ "Report where id in (select out('"
+ classNamePrefix
+ "hasOwnership').id from "
+ classNamePrefix
+ "User where id = 'admin');")) {
Assert.assertTrue(rs.hasNext());
rs.next();
Assert.assertTrue(rs.hasNext());
rs.next();
Assert.assertFalse(rs.hasNext());
}

db.command(
"create index "
+ classNamePrefix
+ "Report.id ON "
+ classNamePrefix
+ "Report(id) unique;")
.close();

try (OResultSet rs =
db.query(
"select from "
+ classNamePrefix
+ "Report where id in (select out('"
+ classNamePrefix
+ "hasOwnership').id from "
+ classNamePrefix
+ "User where id = 'admin');")) {
Assert.assertTrue(rs.hasNext());
rs.next();
Assert.assertTrue(rs.hasNext());
rs.next();
Assert.assertFalse(rs.hasNext());
}
}
}
7 changes: 6 additions & 1 deletion distributed/config/hazelcast.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
the specific language governing permissions and ~ limitations under the License. -->

<hazelcast
xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.3.xsd"
xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.12.xsd"
xmlns="http://www.hazelcast.com/schema/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<group>
<name>orientdb</name>
Expand Down Expand Up @@ -37,6 +37,11 @@
<multicast-group>235.1.1.1</multicast-group>
<multicast-port>2434</multicast-port>
</multicast>
<kubernetes enabled="false">
<pod-label-name>orientdb-cluster-member</pod-label-name>
<pod-label-value>true</pod-label-value>
<service-port>2434</service-port>
</kubernetes>
</join>
</network>
<executor-service>
Expand Down
10 changes: 8 additions & 2 deletions distributed/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<parent>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-parent</artifactId>
<version>3.1.2-SNAPSHOT</version>
<version>3.1.3-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

Expand All @@ -37,7 +37,7 @@
<name>OrientDB Distributed Server</name>

<properties>
<hz.version>3.10.6</hz.version>
<hz.version>3.12.8</hz.version>
<javac.src.version>1.6</javac.src.version>
<javac.target.version>1.6</javac.target.version>
<jar.manifest.mainclass>com.orientechnologies.orient.server.OServerMain</jar.manifest.mainclass>
Expand Down Expand Up @@ -135,6 +135,12 @@
<artifactId>hazelcast</artifactId>
<version>${hz.version}</version>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-kubernetes</artifactId>
<version>1.5.3</version>
<scope>runtime</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ public void terminateServer() {
if (dm != null) {
HazelcastInstance hz = dm.getHazelcastInstance();
final Node node = getHazelcastNode(hz);
node.getConnectionManager().shutdown();
if (node.getNetworkingService() != null) {
node.getNetworkingService().shutdown();
}
node.shutdown(true);
hz.getLifecycleService().terminate();
}
Expand Down
2 changes: 1 addition & 1 deletion distribution-tp2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<parent>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-parent</artifactId>
<version>3.1.2-SNAPSHOT</version>
<version>3.1.3-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<parent>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-parent</artifactId>
<version>3.1.2-SNAPSHOT</version>
<version>3.1.3-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion etl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-parent</artifactId>
<version>3.1.2-SNAPSHOT</version>
<version>3.1.3-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion graphdb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-parent</artifactId>
<version>3.1.2-SNAPSHOT</version>
<version>3.1.3-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<artifactId>orientdb-graphdb</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions history.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@

This document contains the last changes of OrientDB Community Edition.

-----------------------------------------------------------------------------------------------------------------------------------
VERSION 3.1.2 - (August, 20 2020)
- Release Notes: https://github.com/orientechnologies/orientdb/wiki/OrientDB-3.1-Release-Notes#312---20-august-2020

-----------------------------------------------------------------------------------------------------------------------------------
VERSION 3.1.1 - (July, 8 2020)
- Release Notes: https://github.com/orientechnologies/orientdb/wiki/OrientDB-3.1-Release-Notes#311---7-july-2020
Expand Down
2 changes: 1 addition & 1 deletion jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-parent</artifactId>
<version>3.1.2-SNAPSHOT</version>
<version>3.1.3-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion lucene/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-parent</artifactId>
<version>3.1.2-SNAPSHOT</version>
<version>3.1.3-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<artifactId>orientdb-lucene</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion object/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<parent>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-parent</artifactId>
<version>3.1.2-SNAPSHOT</version>
<version>3.1.3-SNAPSHOT</version>
</parent>

<artifactId>orientdb-object</artifactId>
Expand Down
Loading

0 comments on commit fd726ee

Please sign in to comment.