You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2017/10/03 14:03:23 UTC
[09/37] ignite git commit: IGNITE-6509: SQL: Added
QueryEntity.notNullFields property. This closes #2769.
IGNITE-6509: SQL: Added QueryEntity.notNullFields property. This closes #2769.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2108d0c5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2108d0c5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2108d0c5
Branch: refs/heads/ignite-2.3
Commit: 2108d0c5ebc6dbf8fabfa6a81c588356d99fcab7
Parents: 7868843
Author: devozerov <vo...@gridgain.com>
Authored: Thu Sep 28 16:57:22 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Thu Sep 28 16:57:22 2017 +0300
----------------------------------------------------------------------
.../org/apache/ignite/cache/QueryEntity.java | 24 +++++++++++++++++---
.../processors/query/QueryEntityEx.java | 7 +-----
.../internal/processors/query/QueryUtils.java | 11 ++-------
.../query/IgniteSqlNotNullConstraintTest.java | 8 +++----
4 files changed, 28 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2108d0c5/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java b/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java
index b824209..0b82d6a 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java
@@ -83,6 +83,9 @@ public class QueryEntity implements Serializable {
/** Table name. */
private String tableName;
+ /** Fields that must have non-null value. NB: DO NOT remove underscore to avoid clashes with QueryEntityEx. */
+ private Set<String> _notNullFields;
+
/**
* Creates an empty query entity.
*/
@@ -109,6 +112,8 @@ public class QueryEntity implements Serializable {
idxs = other.idxs != null ? new ArrayList<>(other.idxs) : null;
tableName = other.tableName;
+
+ _notNullFields = other._notNullFields != null ? new HashSet<>(other._notNullFields) : null;
}
/**
@@ -360,7 +365,19 @@ public class QueryEntity implements Serializable {
* @return Set of names of fields that must have non-null values.
*/
@Nullable public Set<String> getNotNullFields() {
- return null;
+ return _notNullFields;
+ }
+
+ /**
+ * Sets names of fields that must checked for null.
+ *
+ * @param notNullFields Set of names of fields that must have non-null values.
+ * @return {@code this} for chaining.
+ */
+ public QueryEntity setNotNullFields(@Nullable Set<String> notNullFields) {
+ this._notNullFields = notNullFields;
+
+ return this;
}
/**
@@ -614,13 +631,14 @@ public class QueryEntity implements Serializable {
F.eq(keyFields, entity.keyFields) &&
F.eq(aliases, entity.aliases) &&
F.eqNotOrdered(idxs, entity.idxs) &&
- F.eq(tableName, entity.tableName);
+ F.eq(tableName, entity.tableName) &&
+ F.eq(_notNullFields, entity._notNullFields);
}
/** {@inheritDoc} */
@Override public int hashCode() {
return Objects.hash(keyType, valType, keyFieldName, valueFieldName, fields, keyFields, aliases, idxs,
- tableName);
+ tableName, _notNullFields);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/2108d0c5/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryEntityEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryEntityEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryEntityEx.java
index ec0d5fa..a697882 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryEntityEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryEntityEx.java
@@ -62,12 +62,7 @@ public class QueryEntityEx extends QueryEntity {
return notNullFields;
}
- /**
- * Sets names of fields that must checked for null.
- *
- * @param notNullFields Set of names of fields that must have non-null values.
- * @return {@code this} for chaining.
- */
+ /** {@inheritDoc} */
public QueryEntity setNotNullFields(@Nullable Set<String> notNullFields) {
this.notNullFields = notNullFields;
http://git-wip-us.apache.org/repos/asf/ignite/blob/2108d0c5/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java
index 3e96db2..e76a6ca 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java
@@ -213,7 +213,7 @@ public class QueryUtils {
return entity;
}
- QueryEntity normalEntity = new QueryEntity();
+ QueryEntity normalEntity = entity instanceof QueryEntityEx ? new QueryEntityEx() : new QueryEntity();
// Propagate plain properties.
normalEntity.setKeyType(entity.getKeyType());
@@ -222,14 +222,7 @@ public class QueryUtils {
normalEntity.setKeyFields(entity.getKeyFields());
normalEntity.setKeyFieldName(entity.getKeyFieldName());
normalEntity.setValueFieldName(entity.getValueFieldName());
-
- if (!F.isEmpty(entity.getNotNullFields())) {
- QueryEntityEx normalEntity0 = new QueryEntityEx(normalEntity);
-
- normalEntity0.setNotNullFields(entity.getNotNullFields());
-
- normalEntity = normalEntity0;
- }
+ normalEntity.setNotNullFields(entity.getNotNullFields());
// Normalize table name.
String normalTblName = entity.getTableName();
http://git-wip-us.apache.org/repos/asf/ignite/blob/2108d0c5/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlNotNullConstraintTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlNotNullConstraintTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlNotNullConstraintTest.java
index 607dea8..b724f02 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlNotNullConstraintTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlNotNullConstraintTest.java
@@ -144,7 +144,7 @@ public class IgniteSqlNotNullConstraintTest extends GridCommonAbstractTest {
cfg.setAtomicityMode(atomicityMode);
cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
- QueryEntityEx qe = new QueryEntityEx(new QueryEntity(Integer.class, Person.class));
+ QueryEntity qe = new QueryEntity(new QueryEntity(Integer.class, Person.class));
qe.setNotNullFields(Collections.singleton("name"));
@@ -188,7 +188,7 @@ public class IgniteSqlNotNullConstraintTest extends GridCommonAbstractTest {
/** */
public void testQueryEntityGetSetNotNullFields() throws Exception {
- QueryEntityEx qe = new QueryEntityEx();
+ QueryEntity qe = new QueryEntity();
assertNull(qe.getNotNullFields());
@@ -205,9 +205,9 @@ public class IgniteSqlNotNullConstraintTest extends GridCommonAbstractTest {
/** */
public void testQueryEntityEquals() throws Exception {
- QueryEntityEx a = new QueryEntityEx();
+ QueryEntity a = new QueryEntity();
- QueryEntityEx b = new QueryEntityEx();
+ QueryEntity b = new QueryEntity();
assertEquals(a, b);