You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2020/06/02 13:26:33 UTC
[GitHub] [ignite] akuznetsov-gridgain opened a new pull request #7886: IGNITE-13104 Fixed incorrect logic in spring-data repositories for fi…ndAllById() and deleteAllById() methods. Code cleanup.
akuznetsov-gridgain opened a new pull request #7886:
URL: https://github.com/apache/ignite/pull/7886
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite] asfgit closed pull request #7886: IGNITE-13104 Fixed incorrect logic in spring-data repositories for findAllById() and deleteAllById() methods. Code cleanup.
Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #7886:
URL: https://github.com/apache/ignite/pull/7886
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite] akuznetsov-gridgain commented on a change in pull request #7886: IGNITE-13104 Fixed incorrect logic in spring-data repositories for findAllById() and deleteAllById() methods. Code cleanup.
Posted by GitBox <gi...@apache.org>.
akuznetsov-gridgain commented on a change in pull request #7886:
URL: https://github.com/apache/ignite/pull/7886#discussion_r434303887
##########
File path: modules/spring-data-2.0/src/main/java/org/apache/ignite/springdata20/repository/support/IgniteRepositoryImpl.java
##########
@@ -105,20 +106,39 @@ public IgniteRepositoryImpl(IgniteCache<ID, T> cache) {
};
}
- /** {@inheritDoc} */
- @Override public Iterable<T> findAllById(Iterable<ID> ids) {
+ /**
+ * @param ids Collection of IDs.
+ * @return Collection transformed to set.
+ */
+ private Set<ID> toSet(Iterable<ID> ids) {
Review comment:
Fixed
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite] akuznetsov-gridgain commented on a change in pull request #7886: IGNITE-13104 Fixed incorrect logic in spring-data repositories for findAllById() and deleteAllById() methods. Code cleanup.
Posted by GitBox <gi...@apache.org>.
akuznetsov-gridgain commented on a change in pull request #7886:
URL: https://github.com/apache/ignite/pull/7886#discussion_r434565583
##########
File path: modules/spring-data/src/main/java/org/apache/ignite/springdata/repository/support/IgniteRepositoryImpl.java
##########
@@ -101,20 +102,37 @@ public IgniteRepositoryImpl(IgniteCache<ID, T> cache) {
};
}
- /** {@inheritDoc} */
- @Override public Iterable<T> findAll(Iterable<ID> ids) {
+ /**
+ * @param ids Collection of IDs.
+ * @return Collection transformed to set.
+ */
+ private Set<ID> toSet(Iterable<ID> ids) {
if (ids instanceof Set)
- return cache.getAll((Set<ID>)ids).values();
+ return (Set<ID>)ids;
+
+ Iterator<ID> itr = ids.iterator();
+
+ if (!itr.hasNext())
+ return emptySet();
+
+ ID key = itr.next();
+
+ Set<ID> keys = key instanceof Comparable ? new TreeSet<>() : new HashSet<>();
Review comment:
@alamar This is not possible, because repository declared as Repository<V, K>
Where "K" - is a type for keys, so all keys will be of same type.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite] akuznetsov-gridgain commented on a change in pull request #7886: IGNITE-13104 Fixed incorrect logic in spring-data repositories for findAllById() and deleteAllById() methods. Code cleanup.
Posted by GitBox <gi...@apache.org>.
akuznetsov-gridgain commented on a change in pull request #7886:
URL: https://github.com/apache/ignite/pull/7886#discussion_r435004751
##########
File path: modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCrudSelfTest.java
##########
@@ -20,38 +20,49 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.TreeSet;
import org.apache.ignite.springdata.misc.ApplicationConfiguration;
import org.apache.ignite.springdata.misc.Person;
+import org.apache.ignite.springdata.misc.PersonKey;
import org.apache.ignite.springdata.misc.PersonRepository;
+import org.apache.ignite.springdata.misc.PersonRepositoryWithCompoundKey;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
/**
- *
+ * CRUID tests.
Review comment:
Typo fixed. Green visa from bot recceived.
##########
File path: modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCrudSelfTest.java
##########
@@ -20,38 +20,49 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.TreeSet;
import org.apache.ignite.springdata.misc.ApplicationConfiguration;
import org.apache.ignite.springdata.misc.Person;
+import org.apache.ignite.springdata.misc.PersonKey;
import org.apache.ignite.springdata.misc.PersonRepository;
+import org.apache.ignite.springdata.misc.PersonRepositoryWithCompoundKey;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
/**
- *
+ * CRUID tests.
Review comment:
Typo fixed. Green visa from bot received.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite] alamar commented on a change in pull request #7886: IGNITE-13104 Fixed incorrect logic in spring-data repositories for findAllById() and deleteAllById() methods. Code cleanup.
Posted by GitBox <gi...@apache.org>.
alamar commented on a change in pull request #7886:
URL: https://github.com/apache/ignite/pull/7886#discussion_r434406085
##########
File path: modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCrudSelfTest.java
##########
@@ -20,38 +20,49 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.TreeSet;
import org.apache.ignite.springdata.misc.ApplicationConfiguration;
import org.apache.ignite.springdata.misc.Person;
+import org.apache.ignite.springdata.misc.PersonKey;
import org.apache.ignite.springdata.misc.PersonRepository;
+import org.apache.ignite.springdata.misc.PersonRepositoryWithCompoundKey;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
/**
- *
+ * CRUID tests.
Review comment:
What's CRUID?
##########
File path: modules/spring-data/src/main/java/org/apache/ignite/springdata/repository/support/IgniteRepositoryImpl.java
##########
@@ -101,20 +102,37 @@ public IgniteRepositoryImpl(IgniteCache<ID, T> cache) {
};
}
- /** {@inheritDoc} */
- @Override public Iterable<T> findAll(Iterable<ID> ids) {
+ /**
+ * @param ids Collection of IDs.
+ * @return Collection transformed to set.
+ */
+ private Set<ID> toSet(Iterable<ID> ids) {
if (ids instanceof Set)
- return cache.getAll((Set<ID>)ids).values();
+ return (Set<ID>)ids;
+
+ Iterator<ID> itr = ids.iterator();
+
+ if (!itr.hasNext())
+ return emptySet();
+
+ ID key = itr.next();
+
+ Set<ID> keys = key instanceof Comparable ? new TreeSet<>() : new HashSet<>();
Review comment:
What happens if not all keys are comparable? I understand this is rare and undesirable case but it is possible. We should at least reflect it somewhere.
##########
File path: modules/spring-data-2.0/src/main/java/org/apache/ignite/springdata20/repository/support/IgniteRepositoryImpl.java
##########
@@ -105,20 +106,37 @@ public IgniteRepositoryImpl(IgniteCache<ID, T> cache) {
};
}
- /** {@inheritDoc} */
- @Override public Iterable<T> findAllById(Iterable<ID> ids) {
+ /**
+ * @param ids Collection of IDs.
+ * @return Collection transformed to set.
+ */
+ private Set<ID> toSet(Iterable<ID> ids) {
if (ids instanceof Set)
- return cache.getAll((Set<ID>)ids).values();
+ return (Set<ID>)ids;
+
+ Iterator<ID> itr = ids.iterator();
+
+ if (!itr.hasNext())
+ return emptySet();
+
+ ID key = itr.next();
+
+ Set<ID> keys = key instanceof Comparable ? new TreeSet<>() : new HashSet<>();
Review comment:
here also
##########
File path: modules/spring-data-2.2/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCrudSelfTest.java
##########
@@ -23,37 +23,48 @@
import java.util.List;
import java.util.Optional;
import java.util.TreeSet;
+import javax.cache.CacheException;
import org.apache.ignite.springdata.misc.ApplicationConfiguration;
import org.apache.ignite.springdata.misc.Person;
+import org.apache.ignite.springdata.misc.PersonKey;
import org.apache.ignite.springdata.misc.PersonRepository;
+import org.apache.ignite.springdata.misc.PersonRepositoryWithCompoundKey;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
/**
- *
+ * CRUID tests.
Review comment:
What's CRUID?
##########
File path: modules/spring-data-2.2/src/main/java/org/apache/ignite/springdata22/repository/support/IgniteRepositoryImpl.java
##########
@@ -105,20 +106,37 @@ public IgniteRepositoryImpl(IgniteCache<ID, T> cache) {
};
}
- /** {@inheritDoc} */
- @Override public Iterable<T> findAllById(Iterable<ID> ids) {
+ /**
+ * @param ids Collection of IDs.
+ * @return Collection transformed to set.
+ */
+ private Set<ID> toSet(Iterable<ID> ids) {
if (ids instanceof Set)
- return cache.getAll((Set<ID>)ids).values();
+ return (Set<ID>)ids;
+
+ Iterator<ID> itr = ids.iterator();
+
+ if (!itr.hasNext())
+ return emptySet();
+
+ ID key = itr.next();
+
+ Set<ID> keys = key instanceof Comparable ? new TreeSet<>() : new HashSet<>();
Review comment:
here also
##########
File path: modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCrudSelfTest.java
##########
@@ -23,37 +23,48 @@
import java.util.List;
import java.util.Optional;
import java.util.TreeSet;
+import javax.cache.CacheException;
import org.apache.ignite.springdata.misc.ApplicationConfiguration;
import org.apache.ignite.springdata.misc.Person;
+import org.apache.ignite.springdata.misc.PersonKey;
import org.apache.ignite.springdata.misc.PersonRepository;
+import org.apache.ignite.springdata.misc.PersonRepositoryWithCompoundKey;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
/**
- *
+ * CRUID tests.
Review comment:
here also
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite] akuznetsov-gridgain commented on a change in pull request #7886: IGNITE-13104 Fixed incorrect logic in spring-data repositories for findAllById() and deleteAllById() methods. Code cleanup.
Posted by GitBox <gi...@apache.org>.
akuznetsov-gridgain commented on a change in pull request #7886:
URL: https://github.com/apache/ignite/pull/7886#discussion_r434566277
##########
File path: modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCrudSelfTest.java
##########
@@ -20,38 +20,49 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.TreeSet;
import org.apache.ignite.springdata.misc.ApplicationConfiguration;
import org.apache.ignite.springdata.misc.Person;
+import org.apache.ignite.springdata.misc.PersonKey;
import org.apache.ignite.springdata.misc.PersonRepository;
+import org.apache.ignite.springdata.misc.PersonRepositoryWithCompoundKey;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
/**
- *
+ * CRUID tests.
Review comment:
@alamar This is a typo, CRUD abbreviation should be used: Create/Read/Update/Delete
I will fix typo later.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite] akuznetsov-gridgain commented on a change in pull request #7886: IGNITE-13104 Fixed incorrect logic in spring-data repositories for findAllById() and deleteAllById() methods. Code cleanup.
Posted by GitBox <gi...@apache.org>.
akuznetsov-gridgain commented on a change in pull request #7886:
URL: https://github.com/apache/ignite/pull/7886#discussion_r435004847
##########
File path: modules/spring-data-2.2/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCrudSelfTest.java
##########
@@ -23,37 +23,48 @@
import java.util.List;
import java.util.Optional;
import java.util.TreeSet;
+import javax.cache.CacheException;
import org.apache.ignite.springdata.misc.ApplicationConfiguration;
import org.apache.ignite.springdata.misc.Person;
+import org.apache.ignite.springdata.misc.PersonKey;
import org.apache.ignite.springdata.misc.PersonRepository;
+import org.apache.ignite.springdata.misc.PersonRepositoryWithCompoundKey;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
/**
- *
+ * CRUID tests.
Review comment:
Fixed
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite] smoldachev commented on a change in pull request #7886: IGNITE-13104 Fixed incorrect logic in spring-data repositories for findAllById() and deleteAllById() methods. Code cleanup.
Posted by GitBox <gi...@apache.org>.
smoldachev commented on a change in pull request #7886:
URL: https://github.com/apache/ignite/pull/7886#discussion_r435199127
##########
File path: modules/spring-data-2.2/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCrudSelfTest.java
##########
@@ -332,22 +305,55 @@ public void testUpdateQueryMixedCase() {
}
/**
- * Update with a wrong @Query
+ * Update with a wrong @Query.
*/
@Test
public void testWrongUpdateQuery() {
- final String newSecondName = "updatedUniqueSecondName";
- int rowsUpdated = 0;
- try {
- rowsUpdated = repo.setWrongFixedSecondName(newSecondName, "uniquePerson");
- }
- catch (Exception e) {
- //expected
- }
+ expected.expect(CacheException.class);
+ int rowsUpdated = repo.setWrongFixedSecondName("updatedUniqueSecondName", "uniquePerson");
assertEquals(0, rowsUpdated);
List<Person> person = repo.findByFirstName("uniquePerson");
assertEquals(person.get(0).getSecondName(), "uniqueLastName");
}
+
+ /** */
+ private List<PersonKey> fillData() {
Review comment:
Move to bottom of the class.
##########
File path: modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCrudSelfTest.java
##########
@@ -226,12 +209,49 @@ public void testDeleteAll() {
assertEquals(0, repo.count());
}
- /**
- *
- */
+ /** */
private void fillInRepository() {
for (int i = 0; i < CACHE_SIZE; i++)
repo.save(i, new Person("person" + Integer.toHexString(i),
"lastName" + Integer.toHexString((i + 16) % 256)));
}
+
+ /** */
+ private List<PersonKey> fillData() {
Review comment:
Move to bottom of the class
##########
File path: modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCrudSelfTest.java
##########
@@ -332,22 +305,55 @@ public void testUpdateQueryMixedCase() {
}
/**
- * Update with a wrong @Query
+ * Update with a wrong @Query.
*/
@Test
public void testWrongUpdateQuery() {
- final String newSecondName = "updatedUniqueSecondName";
- int rowsUpdated = 0;
- try {
- rowsUpdated = repo.setWrongFixedSecondName(newSecondName, "uniquePerson");
- }
- catch (Exception e) {
- //expected
- }
+ expected.expect(CacheException.class);
+ int rowsUpdated = repo.setWrongFixedSecondName("updatedUniqueSecondName", "uniquePerson");
assertEquals(0, rowsUpdated);
List<Person> person = repo.findByFirstName("uniquePerson");
assertEquals(person.get(0).getSecondName(), "uniqueLastName");
}
+
+ /** */
+ private List<PersonKey> fillData() {
Review comment:
Let's moe to bottom of the class
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite] akuznetsov-gridgain commented on a change in pull request #7886: IGNITE-13104 Fixed incorrect logic in spring-data repositories for findAllById() and deleteAllById() methods. Code cleanup.
Posted by GitBox <gi...@apache.org>.
akuznetsov-gridgain commented on a change in pull request #7886:
URL: https://github.com/apache/ignite/pull/7886#discussion_r435919441
##########
File path: modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCrudSelfTest.java
##########
@@ -332,22 +305,55 @@ public void testUpdateQueryMixedCase() {
}
/**
- * Update with a wrong @Query
+ * Update with a wrong @Query.
*/
@Test
public void testWrongUpdateQuery() {
- final String newSecondName = "updatedUniqueSecondName";
- int rowsUpdated = 0;
- try {
- rowsUpdated = repo.setWrongFixedSecondName(newSecondName, "uniquePerson");
- }
- catch (Exception e) {
- //expected
- }
+ expected.expect(CacheException.class);
+ int rowsUpdated = repo.setWrongFixedSecondName("updatedUniqueSecondName", "uniquePerson");
assertEquals(0, rowsUpdated);
List<Person> person = repo.findByFirstName("uniquePerson");
assertEquals(person.get(0).getSecondName(), "uniqueLastName");
}
+
+ /** */
+ private List<PersonKey> fillData() {
Review comment:
Fixed.
##########
File path: modules/spring-data-2.2/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCrudSelfTest.java
##########
@@ -332,22 +305,55 @@ public void testUpdateQueryMixedCase() {
}
/**
- * Update with a wrong @Query
+ * Update with a wrong @Query.
*/
@Test
public void testWrongUpdateQuery() {
- final String newSecondName = "updatedUniqueSecondName";
- int rowsUpdated = 0;
- try {
- rowsUpdated = repo.setWrongFixedSecondName(newSecondName, "uniquePerson");
- }
- catch (Exception e) {
- //expected
- }
+ expected.expect(CacheException.class);
+ int rowsUpdated = repo.setWrongFixedSecondName("updatedUniqueSecondName", "uniquePerson");
assertEquals(0, rowsUpdated);
List<Person> person = repo.findByFirstName("uniquePerson");
assertEquals(person.get(0).getSecondName(), "uniqueLastName");
}
+
+ /** */
+ private List<PersonKey> fillData() {
Review comment:
Fixed.
##########
File path: modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCrudSelfTest.java
##########
@@ -226,12 +209,49 @@ public void testDeleteAll() {
assertEquals(0, repo.count());
}
- /**
- *
- */
+ /** */
private void fillInRepository() {
for (int i = 0; i < CACHE_SIZE; i++)
repo.save(i, new Person("person" + Integer.toHexString(i),
"lastName" + Integer.toHexString((i + 16) % 256)));
}
+
+ /** */
+ private List<PersonKey> fillData() {
Review comment:
Fixed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite] nva commented on a change in pull request #7886: IGNITE-13104 Fixed incorrect logic in spring-data repositories for findAllById() and deleteAllById() methods. Code cleanup.
Posted by GitBox <gi...@apache.org>.
nva commented on a change in pull request #7886:
URL: https://github.com/apache/ignite/pull/7886#discussion_r434270960
##########
File path: modules/spring-data-2.0/src/main/java/org/apache/ignite/springdata20/repository/support/IgniteRepositoryImpl.java
##########
@@ -105,20 +106,39 @@ public IgniteRepositoryImpl(IgniteCache<ID, T> cache) {
};
}
- /** {@inheritDoc} */
- @Override public Iterable<T> findAllById(Iterable<ID> ids) {
+ /**
+ * @param ids Collection of IDs.
+ * @return Collection transformed to set.
+ */
+ private Set<ID> toSet(Iterable<ID> ids) {
Review comment:
Try something like this
```
private Set<ID> toSet(Iterable<ID> ids) {
if (ids instanceof Set)
return (Set<ID>)ids;
Iterator<ID> itr = ids.iterator();
if (!itr.hasNext())
return emptySet();
ID key = itr.next();
Set<ID> keys = key instanceof Comparable ? new TreeSet<>() : new HashSet<>();
keys.add(key);
while (itr.hasNext()) {
key = itr.next();
keys.add(key);
}
return keys;
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org