http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure2XFunction.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure2XFunction.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure2XFunction.scala new file mode 100644 index 0000000..444359b --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure2XFunction.scala @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.internal.util.lang.{IgniteClosure2X} + +/** + * Wrapping Scala function for `GridClosure2X`. + */ +class ScalarClosure2XFunction[T1, T2, R](val inner: IgniteClosure2X[T1, T2, R]) extends ((T1, T2) => R) { + assert(inner != null) + + /** + * Delegates to passed in grid closure. + */ + def apply(t1: T1, t2: T2): R = { + inner.applyx(t1, t2) + } +}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure3.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure3.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure3.scala new file mode 100644 index 0000000..18b938d --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure3.scala @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.internal.util.lang.GridClosure3 + +/** + * Peer deploy aware adapter for Java's `GridClosure3`. + */ +class ScalarClosure3[E1, E2, E3, R](private val f: (E1, E2, E3) => R) extends GridClosure3[E1, E2, E3, R] { + assert(f != null) + + /** + * Delegates to passed in function. + */ + def apply(e1: E1, e2: E2, e3: E3): R = { + f(e1, e2, e3) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure3Function.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure3Function.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure3Function.scala new file mode 100644 index 0000000..820f454 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure3Function.scala @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.internal.util.lang.{GridClosure3} + +/** + * Wrapping Scala function for `GridClosure3`. + */ +class ScalarClosure3Function[T1, T2, T3, R](val inner: GridClosure3[T1, T2, T3, R]) extends ((T1, T2, T3) => R) { + assert(inner != null) + + /** + * Delegates to passed in grid closure. + */ + def apply(t1: T1, t2: T2, t3: T3): R = { + inner.apply(t1, t2, t3) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure3X.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure3X.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure3X.scala new file mode 100644 index 0000000..99a571c --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure3X.scala @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite._ +import org.gridgain.grid._ +import org.apache.ignite.internal.util.lang.GridClosure3X + +/** + * Peer deploy aware adapter for Java's `GridClosure3X`. + */ +class ScalarClosure3X[E1, E2, E3, R](private val f: (E1, E2, E3) => R) extends GridClosure3X[E1, E2, E3, R] { + assert(f != null) + + /** + * Delegates to passed in function. + */ + @throws(classOf[IgniteCheckedException]) + def applyx(e1: E1, e2: E2, e3: E3): R = { + f(e1, e2, e3) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure3XFunction.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure3XFunction.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure3XFunction.scala new file mode 100644 index 0000000..e7b90d0 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure3XFunction.scala @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.internal.util.lang.{GridClosure3X} + +/** + * Wrapping Scala function for `GridClosure3X`. + */ +class ScalarClosure3XFunction[T1, T2, T3, R](val inner: GridClosure3X[T1, T2, T3, R]) extends ((T1, T2, T3) => R) { + assert(inner != null) + + /** + * Delegates to passed in grid closure. + */ + def apply(t1: T1, t2: T2, t3: T3): R = { + inner.applyx(t1, t2, t3) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosureFunction.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosureFunction.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosureFunction.scala new file mode 100644 index 0000000..8cdd142 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosureFunction.scala @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.lang.IgniteClosure + +/** + * Wrapping Scala function for `GridClosure`. + */ +class ScalarClosureFunction[T, R](val inner: IgniteClosure[T, R]) extends (T => R) { + assert(inner != null) + + /** + * Delegates to passed in grid closure. + */ + def apply(t: T): R = { + inner.apply(t) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosureX.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosureX.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosureX.scala new file mode 100644 index 0000000..3431a5c --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosureX.scala @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite._ +import org.gridgain.grid._ +import org.apache.ignite.internal.util.lang.IgniteClosureX + +/** + * Peer deploy aware adapter for Java's `GridClosureX`. + */ +class ScalarClosureX[E, R](private val f: E => R) extends IgniteClosureX[E, R] { + assert(f != null) + + /** + * Delegates to passed in function. + */ + @throws(classOf[IgniteCheckedException]) + def applyx(e: E): R = { + f(e) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosureXFunction.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosureXFunction.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosureXFunction.scala new file mode 100644 index 0000000..89153ca --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosureXFunction.scala @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.internal.util.lang.IgniteClosureX + +/** + * Wrapping Scala function for `GridClosureX`. + */ +class ScalarClosureXFunction[T, R](val inner: IgniteClosureX[T, R]) extends (T => R) { + assert(inner != null) + + /** + * Delegates to passed in grid closure. + */ + def apply(t: T): R = { + inner.applyx(t) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure.scala new file mode 100644 index 0000000..04b4919 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure.scala @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.lang.IgniteInClosure + +/** + * Peer deploy aware adapter for Java's `GridInClosure`. + */ +class ScalarInClosure[T](private val f: T => Unit) extends IgniteInClosure[T] { + assert(f != null) + + /** + * Delegates to passed in function. + */ + def apply(t: T) { + f(t) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure2.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure2.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure2.scala new file mode 100644 index 0000000..0e4bf59 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure2.scala @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.lang.IgniteBiInClosure + +/** + * Peer deploy aware adapter for Java's `GridInClosure2`. + */ +class ScalarInClosure2[T1, T2](private val f: (T1, T2) => Unit) extends IgniteBiInClosure[T1, T2] { + assert(f != null) + + /** + * Delegates to passed in function. + */ + def apply(t1: T1, t2: T2) { + f(t1, t2) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure2Function.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure2Function.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure2Function.scala new file mode 100644 index 0000000..1802f35 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure2Function.scala @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.lang.IgniteBiInClosure + +/** + * Wrapping Scala function for `GridInClosure2`. + */ +class ScalarInClosure2Function[T1, T2](val inner: IgniteBiInClosure[T1, T2]) extends ((T1, T2) => Unit) { + assert(inner != null) + + /** + * Delegates to passed in grid closure. + */ + def apply(t1: T1, t2: T2) { + inner.apply(t1, t2) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure2X.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure2X.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure2X.scala new file mode 100644 index 0000000..cf236c1 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure2X.scala @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite._ +import org.gridgain.grid._ +import org.apache.ignite.internal.util.lang.IgniteInClosure2X + +/** + * Peer deploy aware adapter for Java's `GridInClosure2X`. + */ +class ScalarInClosure2X[T1, T2](private val f: (T1, T2) => Unit) extends IgniteInClosure2X[T1, T2] { + assert(f != null) + + /** + * Delegates to passed in function. + */ + @throws(classOf[IgniteCheckedException]) + def applyx(t1: T1, t2: T2) { + f(t1, t2) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure2XFunction.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure2XFunction.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure2XFunction.scala new file mode 100644 index 0000000..913b9c2 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure2XFunction.scala @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.internal.util.lang.IgniteInClosure2X + +/** + * Wrapping Scala function for `GridInClosure2X`. + */ +class ScalarInClosure2XFunction[T1, T2](val inner: IgniteInClosure2X[T1, T2]) extends ((T1, T2) => Unit) { + assert(inner != null) + + /** + * Delegates to passed in grid closure. + */ + def apply(t1: T1, t2: T2) { + inner.applyx(t1, t2) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure3.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure3.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure3.scala new file mode 100644 index 0000000..a1c0298 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure3.scala @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.internal.util.lang.GridInClosure3 + +/** + * Peer deploy aware adapter for Java's `GridInClosure3`. + */ +class ScalarInClosure3[T1, T2, T3](private val f: (T1, T2, T3) => Unit) extends GridInClosure3[T1, T2, T3] { + assert(f != null) + + /** + * Delegates to passed in function. + */ + def apply(t1: T1, t2: T2, t3: T3) { + f(t1, t2, t3) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure3Function.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure3Function.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure3Function.scala new file mode 100644 index 0000000..daaceee --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure3Function.scala @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.internal.util.lang.{GridInClosure3} + +/** + * Wrapping Scala function for `GridInClosure3`. + */ +class ScalarInClosure3Function[T1, T2, T3](val inner: GridInClosure3[T1, T2, T3]) extends ((T1, T2, T3) => Unit) { + assert(inner != null) + + /** + * Delegates to passed in grid closure. + */ + def apply(t1: T1, t2: T2, t3: T3) { + inner.apply(t1, t2, t3) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure3X.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure3X.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure3X.scala new file mode 100644 index 0000000..ee782b1 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure3X.scala @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite._ +import org.gridgain.grid._ +import org.apache.ignite.internal.util.lang.GridInClosure3X + +/** + * Peer deploy aware adapter for Java's `GridInClosure3X`. + */ +class ScalarInClosure3X[T1, T2, T3](private val f: (T1, T2, T3) => Unit) extends GridInClosure3X[T1, T2, T3] { + assert(f != null) + + /** + * Delegates to passed in function. + */ + @throws(classOf[IgniteCheckedException]) + def applyx(t1: T1, t2: T2, t3: T3) { + f(t1, t2, t3) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure3XFunction.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure3XFunction.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure3XFunction.scala new file mode 100644 index 0000000..ef650de --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosure3XFunction.scala @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.internal.util.lang.{GridInClosure3X} + +/** + * Wrapping Scala function for `GridInClosure3X`. + */ +class ScalarInClosure3XFunction[T1, T2, T3](val inner: GridInClosure3X[T1, T2, T3]) extends ((T1, T2, T3) => Unit) { + assert(inner != null) + + /** + * Delegates to passed in grid closure. + */ + def apply(t1: T1, t2: T2, t3: T3) { + inner.applyx(t1, t2, t3) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosureFunction.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosureFunction.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosureFunction.scala new file mode 100644 index 0000000..fbcdfb5 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosureFunction.scala @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.lang.IgniteInClosure + +/** + * Wrapping Scala function for `GridInClosure`. + */ +class ScalarInClosureFunction[T](val inner: IgniteInClosure[T]) extends (T => Unit) { + assert(inner != null) + + /** + * Delegates to passed in grid closure. + */ + def apply(t: T) { + inner.apply(t) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosureX.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosureX.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosureX.scala new file mode 100644 index 0000000..d037f95 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosureX.scala @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite._ +import org.gridgain.grid._ +import org.apache.ignite.internal.util.lang.IgniteInClosureX + +/** + * Peer deploy aware adapter for Java's `GridInClosureX`. + */ +class ScalarInClosureX[T](private val f: T => Unit) extends IgniteInClosureX[T] { + assert(f != null) + + /** + * Delegates to passed in function. + */ + @throws(classOf[IgniteCheckedException]) + def applyx(t: T) { + f(t) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosureXFunction.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosureXFunction.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosureXFunction.scala new file mode 100644 index 0000000..e64bc38 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarInClosureXFunction.scala @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.internal.util.lang.{IgniteInClosureX} + +/** + * Wrapping Scala function for `GridInClosureX`. + */ +class ScalarInClosureXFunction[T](val inner: IgniteInClosureX[T]) extends (T => Unit) { + assert(inner != null) + + /** + * Delegates to passed in grid closure. + */ + def apply(t: T) { + inner.applyx(t) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarJob.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarJob.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarJob.scala new file mode 100644 index 0000000..0a263c6 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarJob.scala @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.compute.ComputeJobAdapter + +/** + * Peer deploy aware adapter for Java's `ComputeJob`. + */ +class ScalarJob(private val inner: () => Any) extends ComputeJobAdapter { + assert(inner != null) + + /** + * Delegates to passed in function. + */ + def execute = inner().asInstanceOf[AnyRef] +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarOutClosure.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarOutClosure.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarOutClosure.scala new file mode 100644 index 0000000..994a39a --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarOutClosure.scala @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import java.util.concurrent.Callable +import org.apache.ignite.lang.IgniteOutClosure +import org.apache.ignite.internal.util.lang.GridPeerDeployAwareAdapter + +/** + * Peer deploy aware adapter for Java's `GridOutClosure`. + */ +class ScalarOutClosure[R](private val f: () => R) extends GridPeerDeployAwareAdapter + with IgniteOutClosure[R] with Callable[R] { + assert(f != null) + + peerDeployLike(f) + + /** + * Delegates to passed in function. + */ + def apply: R = { + f() + } + + /** + * Delegates to passed in function. + */ + def call: R = { + f() + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarOutClosureFunction.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarOutClosureFunction.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarOutClosureFunction.scala new file mode 100644 index 0000000..0fb3fc7 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarOutClosureFunction.scala @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import java.util.concurrent.Callable + +/** + * Wrapping Scala function for `Callable` and specifically for `GridOutClosure`. + */ +class ScalarOutClosureFunction[R](val inner: Callable[R]) extends (() => R) { + assert(inner != null) + + /** + * Delegates to passed in grid closure. + */ + def apply(): R = + inner.call() +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarOutClosureX.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarOutClosureX.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarOutClosureX.scala new file mode 100644 index 0000000..b3e8417 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarOutClosureX.scala @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite._ +import org.gridgain.grid._ +import org.apache.ignite.internal.util.lang.IgniteOutClosureX + +/** + * Peer deploy aware adapter for Java's `GridOutClosureX`. + */ +class ScalarOutClosureX[R](private val f: () => R) extends IgniteOutClosureX[R] { + assert(f != null) + + /** + * Delegates to passed in function. + */ + @throws(classOf[IgniteCheckedException]) + def applyx(): R = { + f() + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarOutClosureXFunction.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarOutClosureXFunction.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarOutClosureXFunction.scala new file mode 100644 index 0000000..dee618a --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarOutClosureXFunction.scala @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.internal.util.lang.{IgniteOutClosureX} + +/** + * Wrapping Scala function for `GridOutClosureX`. + */ +class ScalarOutClosureXFunction[R](val inner: IgniteOutClosureX[R]) extends (() => R) { + assert(inner != null) + + /** + * Delegates to passed in grid closure. + */ + def apply(): R = { + inner.applyx() + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate.scala new file mode 100644 index 0000000..73fa53d --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate.scala @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.lang.IgnitePredicate + +/** + * Peer deploy aware adapter for Java's `GridPredicate`. + */ +class ScalarPredicate[T](private val p: T => Boolean) extends IgnitePredicate[T] { + assert(p != null) + + /** + * Delegates to passed in function. + */ + def apply(e: T) = p(e) +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate2.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate2.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate2.scala new file mode 100644 index 0000000..ddeeae2 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate2.scala @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.lang.IgniteBiPredicate + +/** + * Peer deploy aware adapter for Java's `GridPredicate2`. + */ +class ScalarPredicate2[T1, T2](private val p: (T1, T2) => Boolean) extends IgniteBiPredicate[T1, T2] { + assert(p != null) + + /** + * Delegates to passed in function. + */ + def apply(e1: T1, e2: T2) = p(e1, e2) +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate2Function.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate2Function.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate2Function.scala new file mode 100644 index 0000000..f727bd9 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate2Function.scala @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.lang.IgniteBiPredicate + +/** + * Wrapping Scala function for `GridPredicate2`. + */ +class ScalarPredicate2Function[T1, T2](val inner: IgniteBiPredicate[T1, T2]) extends ((T1, T2) => Boolean) { + assert(inner != null) + + /** + * Delegates to passed in grid predicate. + */ + def apply(t1: T1, t2: T2): Boolean = { + inner.apply(t1, t2) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate2X.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate2X.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate2X.scala new file mode 100644 index 0000000..4dd5654 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate2X.scala @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite._ +import org.gridgain.grid._ +import org.apache.ignite.internal.util.lang.IgnitePredicate2X + +/** + * Peer deploy aware adapter for Java's `GridPredicate2X`. + */ +class ScalarPredicate2X[T1, T2](private val p: (T1, T2) => Boolean) extends IgnitePredicate2X[T1, T2] { + assert(p != null) + + /** + * Delegates to passed in function. + */ + @throws(classOf[IgniteCheckedException]) + def applyx(e1: T1, e2: T2): Boolean = { + p(e1, e2) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate2XFunction.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate2XFunction.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate2XFunction.scala new file mode 100644 index 0000000..d9ae654 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate2XFunction.scala @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.internal.util.lang.IgnitePredicate2X + +/** + * Wrapping Scala function for `GridPredicate2X`. + */ +class ScalarPredicate2XFunction[T1, T2](val inner: IgnitePredicate2X[T1, T2]) extends ((T1, T2) => Boolean) { + assert(inner != null) + + /** + * Delegates to passed in grid predicate. + */ + def apply(t1: T1, t2: T2): Boolean = { + inner.applyx(t1, t2) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate3.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate3.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate3.scala new file mode 100644 index 0000000..f3c576c --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate3.scala @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.internal.util.lang.GridPredicate3 + +/** + * Peer deploy aware adapter for Java's `GridPredicate3`. + */ +class ScalarPredicate3[T1, T2, T3](private val p: (T1, T2, T3) => Boolean) extends GridPredicate3[T1, T2, T3] { + assert(p != null) + + /** + * Delegates to passed in function. + */ + def apply(e1: T1, e2: T2, e3: T3) = p(e1, e2, e3) +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate3Function.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate3Function.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate3Function.scala new file mode 100644 index 0000000..5d2672d --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate3Function.scala @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.internal.util.lang.{GridPredicate3} + +/** + * Wrapping Scala function for `GridPredicate3`. + */ +class ScalarPredicate3Function[T1, T2, T3](val inner: GridPredicate3[T1, T2, T3]) extends ((T1, T2, T3) => Boolean) { + assert(inner != null) + + /** + * Delegates to passed in grid predicate. + */ + def apply(t1: T1, t2: T2, t3: T3): Boolean = { + inner.apply(t1, t2, t3) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate3X.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate3X.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate3X.scala new file mode 100644 index 0000000..7e44624 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate3X.scala @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite._ +import org.gridgain.grid._ +import org.apache.ignite.internal.util.lang.GridPredicate3X + +/** + * Peer deploy aware adapter for Java's `GridPredicate3X`. + */ +class ScalarPredicate3X[T1, T2, T3](private val p: (T1, T2, T3) => Boolean) extends GridPredicate3X[T1, T2, T3] { + assert(p != null) + + /** + * Delegates to passed in function. + */ + @throws(classOf[IgniteCheckedException]) + def applyx(e1: T1, e2: T2, e3: T3): Boolean = { + p(e1, e2, e3) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate3XFunction.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate3XFunction.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate3XFunction.scala new file mode 100644 index 0000000..8272c5d --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicate3XFunction.scala @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.internal.util.lang.{GridPredicate3X} + +/** + * Wrapping Scala function for `GridPredicate3X`. + */ +class ScalarPredicate3XFunction[T1, T2, T3](val inner: GridPredicate3X[T1, T2, T3]) extends ((T1, T2, T3) => Boolean) { + assert(inner != null) + + /** + * Delegates to passed in grid predicate. + */ + def apply(t1: T1, t2: T2, t3: T3): Boolean = { + inner.applyx(t1, t2, t3) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicateFunction.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicateFunction.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicateFunction.scala new file mode 100644 index 0000000..f583d54 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicateFunction.scala @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.lang.IgnitePredicate + +/** + * Wrapping Scala function for `GridPredicate`. + */ +class ScalarPredicateFunction[T](val inner: IgnitePredicate[T]) extends (T => Boolean) { + assert(inner != null) + + /** + * Delegates to passed in grid predicate. + */ + def apply(t: T): Boolean = { + inner.apply(t) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicateX.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicateX.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicateX.scala new file mode 100644 index 0000000..f5b0d33 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicateX.scala @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite._ +import org.gridgain.grid._ +import org.apache.ignite.internal.util.lang.IgnitePredicateX + +/** + * Peer deploy aware adapter for Java's `GridPredicateX`. + */ +class ScalarPredicateX[T](private val p: T => Boolean) extends IgnitePredicateX[T] { + assert(p != null) + + /** + * Delegates to passed in function. + */ + @throws(classOf[IgniteCheckedException]) + def applyx(e: T): Boolean = { + p(e) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicateXFunction.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicateXFunction.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicateXFunction.scala new file mode 100644 index 0000000..7b26126 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarPredicateXFunction.scala @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.internal.util.lang.IgnitePredicateX + +/** + * Wrapping Scala function for `GridPredicateX`. + */ +class ScalarPredicateXFunction[T](val inner: IgnitePredicateX[T]) extends (T => Boolean) { + assert(inner != null) + + /** + * Delegates to passed in grid predicate. + */ + def apply(t: T) = { + inner.applyx(t) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarReducer.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarReducer.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarReducer.scala new file mode 100644 index 0000000..56645eb --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarReducer.scala @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.lang.IgniteReducer + +import collection._ + +/** + * Peer deploy aware adapter for Java's `GridReducer`. + */ +class ScalarReducer[E, R](private val r: Seq[E] => R) extends IgniteReducer[E, R] { + assert(r != null) + + private val buf = new mutable.ListBuffer[E] + + /** + * Delegates to passed in function. + */ + def reduce = r(buf.toSeq) + + /** + * Collects given value. + * + * @param e Value to collect for later reduction. + */ + def collect(e: E) = { + buf += e + + true + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarReducer2.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarReducer2.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarReducer2.scala new file mode 100644 index 0000000..f3f9377 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarReducer2.scala @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import collection._ +import org.apache.ignite.internal.util.lang.IgniteReducer2 + +/** + * Peer deploy aware adapter for Java's `GridReducer2`. + */ +class ScalarReducer2[E1, E2, R](private val r: (Seq[E1], Seq[E2]) => R) extends IgniteReducer2[E1, E2, R] { + assert(r != null) + + private val buf1 = new mutable.ListBuffer[E1] + private val buf2 = new mutable.ListBuffer[E2] + + /** + * Delegates to passed in function. + */ + def apply = r(buf1.toSeq, buf2.toSeq) + + /** + * Collects given values. + * + * @param e1 Value to collect for later reduction. + * @param e2 Value to collect for later reduction. + */ + def collect(e1: E1, e2: E2) = { + buf1 += e1 + buf2 += e2 + + true + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarReducer2Function.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarReducer2Function.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarReducer2Function.scala new file mode 100644 index 0000000..34818c1 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarReducer2Function.scala @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.internal.util.lang.{IgniteReducer2} + +/** + * Wrapping Scala function for `GridReducer2`. + */ +class ScalarReducer2Function[E1, E2, R](val inner: IgniteReducer2[E1, E2, R]) extends ((Seq[E1], Seq[E2]) => R) { + assert(inner != null) + + /** + * Delegates to passed in grid reducer. + */ + def apply(s1: Seq[E1], s2: Seq[E2]) = { + for (e1 <- s1; e2 <- s2) inner.collect(e1, e2) + + inner.apply() + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarReducer3.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarReducer3.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarReducer3.scala new file mode 100644 index 0000000..56761dc --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarReducer3.scala @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import collection._ +import org.apache.ignite.internal.util.lang.IgniteReducer3 + +/** + * Peer deploy aware adapter for Java's `GridReducer3`. + */ +class ScalarReducer3[E1, E2, E3, R](private val r: (Seq[E1], Seq[E2], Seq[E3]) => R) + extends IgniteReducer3[E1, E2, E3, R] { + assert(r != null) + + private val buf1 = new mutable.ListBuffer[E1] + private val buf2 = new mutable.ListBuffer[E2] + private val buf3 = new mutable.ListBuffer[E3] + + /** + * Delegates to passed in function. + */ + def apply = r(buf1.toSeq, buf2.toSeq, buf3.toSeq) + + /** + * Collects given values. + * + * @param e1 Value to collect for later reduction. + * @param e2 Value to collect for later reduction. + * @param e3 Value to collect for later reduction. + */ + def collect(e1: E1, e2: E2, e3: E3) = { + buf1 += e1 + buf2 += e2 + buf3 += e3 + + true + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarReducer3Function.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarReducer3Function.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarReducer3Function.scala new file mode 100644 index 0000000..f697986 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarReducer3Function.scala @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.internal.util.lang.{IgniteReducer3} + +/** + * Wrapping Scala function for `GridReducer3`. + */ +class ScalarReducer3Function[E1, E2, E3, R](val inner: IgniteReducer3[E1, E2, E3, R]) extends + ((Seq[E1], Seq[E2], Seq[E3]) => R) { + assert(inner != null) + + /** + * Delegates to passed in grid reducer. + */ + def apply(s1: Seq[E1], s2: Seq[E2], s3: Seq[E3]) = { + for (e1 <- s1; e2 <- s2; e3 <- s3) inner.collect(e1, e2, e3) + + inner.apply() + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarReducerFunction.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarReducerFunction.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarReducerFunction.scala new file mode 100644 index 0000000..b0ad4c0 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarReducerFunction.scala @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.lang + +import org.apache.ignite.lang.IgniteReducer + +/** + * Wrapping Scala function for `GridReducer`. + */ +class ScalarReducerFunction[E1, R](val inner: IgniteReducer[E1, R]) extends (Seq[E1] => R) { + assert(inner != null) + + /** + * Delegates to passed in grid reducer. + */ + def apply(s: Seq[E1]) = { + s foreach inner.collect _ + + inner.reduce() + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/pimps/Packet.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/pimps/Packet.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/pimps/Packet.scala new file mode 100644 index 0000000..79e5eb8 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/pimps/Packet.scala @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar + +/** + * Contains Scala "Pimp" implementations for main GridGain entities. + */ +package object pimps \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/pimps/PimpedType.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/pimps/PimpedType.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/pimps/PimpedType.scala new file mode 100644 index 0000000..20dff39 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/pimps/PimpedType.scala @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.pimps + +/** + * Sub class to create a wrapper type for `X` as documentation that the sub class follows the + * 'pimp my library' pattern. http://www.artima.com/weblogs/viewpost.jsp?thread=179766 + * <p/> + * The companion object provides an implicit conversion to unwrap `value`. + */ +trait PimpedType[X] { + val value: X +} + +object PimpedType { + implicit def UnwrapPimpedType[X](p: PimpedType[X]): X = p.value +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/pimps/ScalarCachePimp.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/pimps/ScalarCachePimp.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/pimps/ScalarCachePimp.scala new file mode 100644 index 0000000..c5a60f5 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/pimps/ScalarCachePimp.scala @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gridgain.scalar.pimps + +import org.apache.ignite.cache.GridCache + +/** + * ==Overview== + * Defines Scalar "pimp" for `GridCache` on Java side. + * + * Essentially this class extends Java `GridProjection` interface with Scala specific + * API adapters using primarily implicit conversions defined in `ScalarConversions` object. What + * it means is that you can use functions defined in this class on object + * of Java `GridProjection` type. Scala will automatically (implicitly) convert it into + * Scalar's pimp and replace the original call with a call on that pimp. + * + * Note that Scalar provide extensive library of implicit conversion between Java and + * Scala GridGain counterparts in `ScalarConversions` object + * + * ==Suffix '$' In Names== + * Symbol `$` is used in names when they conflict with the names in the base Java class + * that Scala pimp is shadowing or with Java package name that your Scala code is importing. + * Instead of giving two different names to the same function we've decided to simply mark + * Scala's side method with `$` suffix. + */ +class ScalarCachePimp[K, V] extends ScalarCacheProjectionPimp[K, V] with Ordered[GridCache[K, V]] { + /** + * Compares this cache name to the given cache name. + * + * @param that Another cache instance to compare names with. + */ + def compare(that: GridCache[K, V]): Int = that.name.compareTo(value.name) +} + +/** + * Companion object. + */ +object ScalarCachePimp { + /** + * Creates new Scalar cache pimp with given Java-side implementation. + * + * @param impl Java-side implementation. + */ + def apply[K, V](impl: GridCache[K, V]) = { + if (impl == null) + throw new NullPointerException("impl") + + val pimp = new ScalarCachePimp[K, V] + + pimp.impl = impl + + pimp + } +}