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 2015/12/30 11:33:34 UTC
[1/5] ignite git commit: IGNITE-2263: Removed "F.viewListReadOnly" -
it is no longer needed.
Repository: ignite
Updated Branches:
refs/heads/ignite-2263 59b15072d -> 7fa4ba03b
IGNITE-2263: Removed "F.viewListReadOnly" - it is no longer needed.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/80ccd1c4
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/80ccd1c4
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/80ccd1c4
Branch: refs/heads/ignite-2263
Commit: 80ccd1c4fcd5c69d5cec20d40555752ee4e0d7b6
Parents: 59b1507
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Dec 30 13:20:04 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Dec 30 13:20:04 2015 +0300
----------------------------------------------------------------------
.../ignite/internal/util/IgniteUtils.java | 4 +-
.../ignite/internal/util/lang/GridFunc.java | 44 +-------------------
2 files changed, 3 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/80ccd1c4/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index be4851d..0f9f300 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -8492,7 +8492,7 @@ public abstract class IgniteUtils {
throw new IgniteCheckedException("Addresses can not be resolved [addr=" + addrs +
", hostNames=" + hostNames + ']');
- return F.viewListReadOnly(res, F.<InetAddress>identity());
+ return Collections.unmodifiableList(res);
}
/**
@@ -8539,7 +8539,7 @@ public abstract class IgniteUtils {
res.add(new InetSocketAddress(addr, port));
}
- return F.viewListReadOnly(res, F.<InetSocketAddress>identity());
+ return Collections.unmodifiableList(res);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/80ccd1c4/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
index 703991e..7922f2c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
@@ -734,6 +734,7 @@ public class GridFunc {
* @param obj One or more elements.
* @return Concatenated array.
*/
+ @SuppressWarnings("unchecked")
public static <T> T[] concat(@Nullable T[] arr, T... obj) {
T[] newArr;
@@ -1401,49 +1402,6 @@ public class GridFunc {
}
/**
- * Creates read-only light-weight view on given list with provided transformation.
- * Resulting list will only "have" {@code transformed} elements. Note that only wrapping
- * list will be created and no duplication of data will occur.
- *
- * @param c Input list that serves as a base for the view.
- * @param trans Transformation closure.
- * @param <T1> Type of the list.
- * @return Light-weight view on given list with provided transformation.
- */
- @SuppressWarnings("RedundantTypeArguments")
- public static <T1, T2> List<T2> viewListReadOnly(@Nullable final List<? extends T1> c,
- final IgniteClosure<? super T1, T2> trans) {
- A.notNull(trans, "trans");
-
- if (isEmpty(c))
- return Collections.emptyList();
-
- assert c != null;
-
- return new GridSerializableList<T2>() {
- /** */
- private static final long serialVersionUID = 3126625219739967068L;
-
- @Override public T2 get(int idx) {
- return trans.apply(c.get(idx));
- }
-
- @NotNull
- @Override public Iterator<T2> iterator() {
- return F.<T1, T2>iterator(c, trans, true);
- }
-
- @Override public int size() {
- return c.size();
- }
-
- @Override public boolean isEmpty() {
- return c.isEmpty();
- }
- };
- }
-
- /**
* Creates light-weight view on given map with provided predicates. Resulting map will
* only "have" keys for which all provided predicates, if any, evaluates to {@code true}.
* Note that only wrapping map will be created and no duplication of data will occur.
[2/5] ignite git commit: IGNITE-2263: Removed "F.viewReadOnly(...,
BiClosure, ...)" - it is no longer needed.
Posted by vo...@apache.org.
IGNITE-2263: Removed "F.viewReadOnly(..., BiClosure, ...)" - it is no longer needed.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9bd3150d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9bd3150d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9bd3150d
Branch: refs/heads/ignite-2263
Commit: 9bd3150d4acb2f12852ff99d831d43be14319d38
Parents: 80ccd1c
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Dec 30 13:23:43 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Dec 30 13:23:43 2015 +0300
----------------------------------------------------------------------
.../ignite/internal/util/lang/GridFunc.java | 120 -------------------
1 file changed, 120 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9bd3150d/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
index 7922f2c..9be08a7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
@@ -1607,126 +1607,6 @@ public class GridFunc {
}
/**
- * Read-only view on map that supports transformation of values and key filtering. Resulting map will
- * only "have" keys for which all provided predicates, if any, evaluates to {@code true}.
- * Note that only wrapping map will be created and no duplication of data will occur.
- * Also note that if array of given predicates is not empty then method {@code size()}
- * uses full iteration through the entry set.
- *
- * @param m Input map that serves as a base for the view.
- * @param trans Transformer for map value transformation.
- * @param p Optional predicates. If predicates are not provided - all will be in the view.
- * @param <K> Type of the key.
- * @param <V> Type of the input map value.
- * @param <V1> Type of the output map value.
- * @return Light-weight view on given map with provided predicate and transformer.
- */
- public static <K0, K extends K0, V0, V extends V0, V1> Map<K, V1> viewReadOnly(@Nullable final Map<K, V> m,
- final IgniteBiClosure<K, V, V1> trans, @Nullable final IgnitePredicate<? super K>... p) {
- A.notNull(trans, "trans");
-
- if (isEmpty(m) || isAlwaysFalse(p))
- return Collections.emptyMap();
-
- assert m != null;
-
- return new GridSerializableMap<K, V1>() {
- /** Entry predicate. */
- private IgnitePredicate<Entry<K, V>> ep = new P1<Map.Entry<K, V>>() {
- @Override public boolean apply(Entry<K, V> e) {
- return isAll(e.getKey(), p);
- }
- };
-
- @NotNull
- @Override public Set<Entry<K, V1>> entrySet() {
- return new GridSerializableSet<Map.Entry<K, V1>>() {
- @NotNull
- @Override public Iterator<Entry<K, V1>> iterator() {
- return new Iterator<Entry<K, V1>>() {
- private Iterator<Entry<K, V>> it = iterator0(m.entrySet(), true, ep);
-
- @Override public boolean hasNext() {
- return it.hasNext();
- }
-
- @Override public Entry<K, V1> next() {
- final Entry<K, V> e = it.next();
-
- return new Entry<K, V1>() {
- @Override public K getKey() {
- return e.getKey();
- }
-
- @Override public V1 getValue() {
- return trans.apply(e.getKey(), e.getValue());
- }
-
- @Override public V1 setValue(V1 val) {
- throw new UnsupportedOperationException(
- "Put is not supported for readonly map view.");
- }
- };
- }
-
- @Override public void remove() {
- throw new UnsupportedOperationException("Remove is not support for readonly map view.");
- }
- };
- }
-
- @Override public int size() {
- return F.size(m.keySet(), p);
- }
-
- @SuppressWarnings({"unchecked"})
- @Override public boolean remove(Object o) {
- throw new UnsupportedOperationException("Remove is not support for readonly map view.");
- }
-
- @SuppressWarnings({"unchecked"})
- @Override public boolean contains(Object o) {
- return F.isAll((Map.Entry<K, V>)o, ep) && m.entrySet().contains(o);
- }
-
- @Override public boolean isEmpty() {
- return !iterator().hasNext();
- }
- };
- }
-
- @Override public boolean isEmpty() {
- return entrySet().isEmpty();
- }
-
- @SuppressWarnings({"unchecked"})
- @Nullable @Override public V1 get(Object key) {
- if (isAll((K) key, p)) {
- V v = m.get(key);
-
- if (v != null)
- return trans.apply((K)key, v);
- }
-
- return null;
- }
-
- @Nullable @Override public V1 put(K key, V1 val) {
- throw new UnsupportedOperationException("Put is not supported for readonly map view.");
- }
-
- @Override public V1 remove(Object key) {
- throw new UnsupportedOperationException("Remove is not supported for readonly map view.");
- }
-
- @SuppressWarnings({"unchecked"})
- @Override public boolean containsKey(Object key) {
- return isAll((K)key, p) && m.containsKey(key);
- }
- };
- }
-
- /**
* Read-only map view of a collection. Resulting map is a lightweight view of an input collection,
* with filtered elements of an input collection as keys, and closure execution results
* as values. The map will only contain keys for which all provided predicates, if any, evaluate
[5/5] ignite git commit: IGNITE-2263: Slight optimization for
F.concat(Iterator ...)
Posted by vo...@apache.org.
IGNITE-2263: Slight optimization for F.concat(Iterator ...)
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7fa4ba03
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7fa4ba03
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7fa4ba03
Branch: refs/heads/ignite-2263
Commit: 7fa4ba03b9141290d22f6f43fd50062f75b1e0ca
Parents: 8225a41
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Dec 30 13:34:30 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Dec 30 13:34:30 2015 +0300
----------------------------------------------------------------------
.../org/apache/ignite/internal/util/lang/GridFunc.java | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7fa4ba03/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
index ea7c2f2..736e933 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
@@ -736,17 +736,15 @@ public class GridFunc {
}
/**
- * Concatenates multiple iterators as single one.
+ * Concatenate two iterators.
*
- * @param iters Iterators.
+ * @param iter1 Iterator 1.
+ * @param iter2 Iterator 2.
* @return Single iterator.
*/
@SuppressWarnings("unchecked")
- public static <T> Iterator<T> concat(Iterator<T> ... iters) {
- if (iters.length == 1)
- return iters[0];
-
- return concat(asList(iters).iterator());
+ public static <T> Iterator<T> concat(Iterator<T> iter1, Iterator<T> iter2) {
+ return concat(asList(iter1, iter2).iterator());
}
/**
[4/5] ignite git commit: IGNITE-2263: F.rand(Object ...) is no longer
needed.
Posted by vo...@apache.org.
IGNITE-2263: F.rand(Object ...) is no longer needed.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8225a413
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8225a413
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8225a413
Branch: refs/heads/ignite-2263
Commit: 8225a41322df31b2740760af11eb5a199003aef1
Parents: cdd8cf1
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Dec 30 13:32:02 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Dec 30 13:32:02 2015 +0300
----------------------------------------------------------------------
.../apache/ignite/internal/util/lang/GridFunc.java | 14 --------------
.../cache/GridCacheLuceneQueryIndexTest.java | 4 +++-
2 files changed, 3 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/8225a413/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
index a412716..ea7c2f2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
@@ -553,20 +553,6 @@ public class GridFunc {
}
/**
- * Gets random value from given array. This operation
- * does not iterate through array elements and returns immediately.
- *
- * @param c Input collection.
- * @param <T> Type of the collection.
- * @return Random value from the input collection.
- */
- public static <T> T rand(T... c) {
- A.notNull(c, "c");
-
- return c[ThreadLocalRandom8.current().nextInt(c.length)];
- }
-
- /**
* Concatenates an element to a collection. If {@code copy} flag is {@code true}, then
* a new collection will be created and the element and passed in collection will be
* copied into the new one. The returned collection will be modifiable. If {@code copy}
http://git-wip-us.apache.org/repos/asf/ignite/blob/8225a413/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLuceneQueryIndexTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLuceneQueryIndexTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLuceneQueryIndexTest.java
index 59a3eca..1e868b7 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLuceneQueryIndexTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLuceneQueryIndexTest.java
@@ -21,6 +21,7 @@ import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Callable;
+import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
@@ -335,7 +336,8 @@ public class GridCacheLuceneQueryIndexTest extends GridCommonAbstractTest {
map = new HashMap<>();
}
- map.put(new ObjectKey(String.valueOf(i)), F.rand(vals));
+ map.put(new ObjectKey(String.valueOf(i)),
+ vals[ThreadLocalRandom.current().nextInt(vals.length)]);
}
if (!map.isEmpty()) {
[3/5] ignite git commit: IGNITE-2263: Optimzied shortcut for "isAll"
method.
Posted by vo...@apache.org.
IGNITE-2263: Optimzied shortcut for "isAll" method.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/cdd8cf15
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/cdd8cf15
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/cdd8cf15
Branch: refs/heads/ignite-2263
Commit: cdd8cf154698581a399c5a42b97e8aa8fe9f95de
Parents: 9bd3150
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Dec 30 13:31:06 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Dec 30 13:31:06 2015 +0300
----------------------------------------------------------------------
.../org/apache/ignite/internal/util/lang/GridFunc.java | 12 ++++++++++++
1 file changed, 12 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/cdd8cf15/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
index 9be08a7..a412716 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
@@ -2656,6 +2656,17 @@ public class GridFunc {
}
/**
+ * Shortcut for {@link #isAll(Object, org.apache.ignite.lang.IgnitePredicate[])} method with only single predicate.
+ *
+ * @param t Value to test.
+ * @param p Predicate.
+ * @return {@code True} if test is passed.
+ */
+ public static <T> boolean isAll(@Nullable T t, @Nullable IgnitePredicate<? super T> p) {
+ return p == null || p.apply(t);
+ }
+
+ /**
* Tests if all provided predicates evaluate to {@code true} for given value. Note that
* evaluation will be short-circuit when first predicate evaluated to {@code false} is found.
*
@@ -2666,6 +2677,7 @@ public class GridFunc {
* @return Returns {@code true} if given set of predicates is {@code null}, is empty, or all predicates
* evaluate to {@code true} for given value, {@code false} otherwise.
*/
+ @SuppressWarnings("unchecked")
public static <T> boolean isAll(@Nullable T t, @Nullable IgnitePredicate<? super T>... p) {
if (p != null)
for (IgnitePredicate<? super T> r : p)