# ignite-63
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/a6f9c9e6 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/a6f9c9e6 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/a6f9c9e6 Branch: refs/heads/ignite-63 Commit: a6f9c9e64ce3b656b340abd20f3912aa1110e52e Parents: e8d8562 Author: sboikov <semen.boi...@inria.fr> Authored: Fri Jan 23 01:22:30 2015 +0300 Committer: sboikov <semen.boi...@inria.fr> Committed: Fri Jan 23 01:22:34 2015 +0300 ---------------------------------------------------------------------- .../ScalarExamplesMultiNodeSelfTest.scala | 33 + .../tests/examples/ScalarExamplesSelfTest.scala | 118 ++ .../ScalarExamplesSelfTestSuite.scala | 39 + .../ScalarExamplesMultiNodeSelfTest.scala | 33 - .../tests/examples/ScalarExamplesSelfTest.scala | 118 -- .../ScalarExamplesSelfTestSuite.scala | 39 - .../ignite/scalar/ScalarConversions.scala | 1235 +++++++++++ .../org/apache/ignite/scalar/lang/Packet.scala | 23 + .../ignite/scalar/lang/ScalarAbsClosure.scala | 37 + .../scalar/lang/ScalarAbsClosureFunction.scala | 32 + .../ignite/scalar/lang/ScalarAbsClosureX.scala | 37 + .../scalar/lang/ScalarAbsClosureXFunction.scala | 34 + .../ignite/scalar/lang/ScalarAbsPredicate.scala | 34 + .../lang/ScalarAbsPredicateFunction.scala | 34 + .../scalar/lang/ScalarAbsPredicateX.scala | 37 + .../lang/ScalarAbsPredicateXFunction.scala | 34 + .../ignite/scalar/lang/ScalarClosure.scala | 34 + .../ignite/scalar/lang/ScalarClosure2.scala | 34 + .../scalar/lang/ScalarClosure2Function.scala | 34 + .../ignite/scalar/lang/ScalarClosure2X.scala | 37 + .../scalar/lang/ScalarClosure2XFunction.scala | 34 + .../ignite/scalar/lang/ScalarClosure3.scala | 34 + .../scalar/lang/ScalarClosure3Function.scala | 34 + .../ignite/scalar/lang/ScalarClosure3X.scala | 37 + .../scalar/lang/ScalarClosure3XFunction.scala | 34 + .../scalar/lang/ScalarClosureFunction.scala | 34 + .../ignite/scalar/lang/ScalarClosureX.scala | 37 + .../scalar/lang/ScalarClosureXFunction.scala | 34 + .../ignite/scalar/lang/ScalarInClosure.scala | 34 + .../ignite/scalar/lang/ScalarInClosure2.scala | 34 + .../scalar/lang/ScalarInClosure2Function.scala | 34 + .../ignite/scalar/lang/ScalarInClosure2X.scala | 37 + .../scalar/lang/ScalarInClosure2XFunction.scala | 34 + .../ignite/scalar/lang/ScalarInClosure3.scala | 34 + .../scalar/lang/ScalarInClosure3Function.scala | 34 + .../ignite/scalar/lang/ScalarInClosure3X.scala | 37 + .../scalar/lang/ScalarInClosure3XFunction.scala | 34 + .../scalar/lang/ScalarInClosureFunction.scala | 34 + .../ignite/scalar/lang/ScalarInClosureX.scala | 37 + .../scalar/lang/ScalarInClosureXFunction.scala | 34 + .../apache/ignite/scalar/lang/ScalarJob.scala | 32 + .../ignite/scalar/lang/ScalarOutClosure.scala | 46 + .../scalar/lang/ScalarOutClosureFunction.scala | 33 + .../ignite/scalar/lang/ScalarOutClosureX.scala | 37 + .../scalar/lang/ScalarOutClosureXFunction.scala | 34 + .../ignite/scalar/lang/ScalarPredicate.scala | 32 + .../ignite/scalar/lang/ScalarPredicate2.scala | 32 + .../scalar/lang/ScalarPredicate2Function.scala | 34 + .../ignite/scalar/lang/ScalarPredicate2X.scala | 37 + .../scalar/lang/ScalarPredicate2XFunction.scala | 34 + .../ignite/scalar/lang/ScalarPredicate3.scala | 32 + .../scalar/lang/ScalarPredicate3Function.scala | 34 + .../ignite/scalar/lang/ScalarPredicate3X.scala | 37 + .../scalar/lang/ScalarPredicate3XFunction.scala | 34 + .../scalar/lang/ScalarPredicateFunction.scala | 34 + .../ignite/scalar/lang/ScalarPredicateX.scala | 37 + .../scalar/lang/ScalarPredicateXFunction.scala | 34 + .../ignite/scalar/lang/ScalarReducer.scala | 47 + .../ignite/scalar/lang/ScalarReducer2.scala | 49 + .../scalar/lang/ScalarReducer2Function.scala | 36 + .../ignite/scalar/lang/ScalarReducer3.scala | 53 + .../scalar/lang/ScalarReducer3Function.scala | 37 + .../scalar/lang/ScalarReducerFunction.scala | 36 + .../org/apache/ignite/scalar/pimps/Packet.scala | 23 + .../apache/ignite/scalar/pimps/PimpedType.scala | 32 + .../ignite/scalar/pimps/ScalarCachePimp.scala | 69 + .../pimps/ScalarCacheProjectionPimp.scala | 2005 ++++++++++++++++++ .../ignite/scalar/pimps/ScalarGridPimp.scala | 94 + .../scalar/pimps/ScalarProjectionPimp.scala | 659 ++++++ .../scalar/pimps/ScalarTaskThreadContext.scala | 47 + .../scala/org/apache/ignite/scalar/scalar.scala | 457 ++++ .../org/gridgain/scalar/ScalarConversions.scala | 1235 ----------- .../scala/org/gridgain/scalar/lang/Packet.scala | 23 - .../gridgain/scalar/lang/ScalarAbsClosure.scala | 37 - .../scalar/lang/ScalarAbsClosureFunction.scala | 32 - .../scalar/lang/ScalarAbsClosureX.scala | 37 - .../scalar/lang/ScalarAbsClosureXFunction.scala | 34 - .../scalar/lang/ScalarAbsPredicate.scala | 34 - .../lang/ScalarAbsPredicateFunction.scala | 34 - .../scalar/lang/ScalarAbsPredicateX.scala | 37 - .../lang/ScalarAbsPredicateXFunction.scala | 34 - .../gridgain/scalar/lang/ScalarClosure.scala | 34 - .../gridgain/scalar/lang/ScalarClosure2.scala | 34 - .../scalar/lang/ScalarClosure2Function.scala | 34 - .../gridgain/scalar/lang/ScalarClosure2X.scala | 37 - .../scalar/lang/ScalarClosure2XFunction.scala | 34 - .../gridgain/scalar/lang/ScalarClosure3.scala | 34 - .../scalar/lang/ScalarClosure3Function.scala | 34 - .../gridgain/scalar/lang/ScalarClosure3X.scala | 37 - .../scalar/lang/ScalarClosure3XFunction.scala | 34 - .../scalar/lang/ScalarClosureFunction.scala | 34 - .../gridgain/scalar/lang/ScalarClosureX.scala | 37 - .../scalar/lang/ScalarClosureXFunction.scala | 34 - .../gridgain/scalar/lang/ScalarInClosure.scala | 34 - .../gridgain/scalar/lang/ScalarInClosure2.scala | 34 - .../scalar/lang/ScalarInClosure2Function.scala | 34 - .../scalar/lang/ScalarInClosure2X.scala | 37 - .../scalar/lang/ScalarInClosure2XFunction.scala | 34 - .../gridgain/scalar/lang/ScalarInClosure3.scala | 34 - .../scalar/lang/ScalarInClosure3Function.scala | 34 - .../scalar/lang/ScalarInClosure3X.scala | 37 - .../scalar/lang/ScalarInClosure3XFunction.scala | 34 - .../scalar/lang/ScalarInClosureFunction.scala | 34 - .../gridgain/scalar/lang/ScalarInClosureX.scala | 37 - .../scalar/lang/ScalarInClosureXFunction.scala | 34 - .../org/gridgain/scalar/lang/ScalarJob.scala | 32 - .../gridgain/scalar/lang/ScalarOutClosure.scala | 46 - .../scalar/lang/ScalarOutClosureFunction.scala | 33 - .../scalar/lang/ScalarOutClosureX.scala | 37 - .../scalar/lang/ScalarOutClosureXFunction.scala | 34 - .../gridgain/scalar/lang/ScalarPredicate.scala | 32 - .../gridgain/scalar/lang/ScalarPredicate2.scala | 32 - .../scalar/lang/ScalarPredicate2Function.scala | 34 - .../scalar/lang/ScalarPredicate2X.scala | 37 - .../scalar/lang/ScalarPredicate2XFunction.scala | 34 - .../gridgain/scalar/lang/ScalarPredicate3.scala | 32 - .../scalar/lang/ScalarPredicate3Function.scala | 34 - .../scalar/lang/ScalarPredicate3X.scala | 37 - .../scalar/lang/ScalarPredicate3XFunction.scala | 34 - .../scalar/lang/ScalarPredicateFunction.scala | 34 - .../gridgain/scalar/lang/ScalarPredicateX.scala | 37 - .../scalar/lang/ScalarPredicateXFunction.scala | 34 - .../gridgain/scalar/lang/ScalarReducer.scala | 47 - .../gridgain/scalar/lang/ScalarReducer2.scala | 49 - .../scalar/lang/ScalarReducer2Function.scala | 36 - .../gridgain/scalar/lang/ScalarReducer3.scala | 53 - .../scalar/lang/ScalarReducer3Function.scala | 37 - .../scalar/lang/ScalarReducerFunction.scala | 36 - .../org/gridgain/scalar/pimps/Packet.scala | 23 - .../org/gridgain/scalar/pimps/PimpedType.scala | 32 - .../gridgain/scalar/pimps/ScalarCachePimp.scala | 69 - .../pimps/ScalarCacheProjectionPimp.scala | 2005 ------------------ .../gridgain/scalar/pimps/ScalarGridPimp.scala | 94 - .../scalar/pimps/ScalarProjectionPimp.scala | 659 ------ .../scalar/pimps/ScalarTaskThreadContext.scala | 47 - .../main/scala/org/gridgain/scalar/scalar.scala | 457 ---- .../tests/ScalarAffinityRoutingSpec.scala | 68 + .../tests/ScalarCacheProjectionSpec.scala | 39 + .../scalar/tests/ScalarCacheQueriesSpec.scala | 601 ++++++ .../ignite/scalar/tests/ScalarCacheSpec.scala | 79 + .../scalar/tests/ScalarConversionsSpec.scala | 254 +++ .../scalar/tests/ScalarProjectionSpec.scala | 150 ++ .../scalar/tests/ScalarReturnableSpec.scala | 58 + .../apache/ignite/scalar/tests/ScalarSpec.scala | 37 + .../scalar/testsuites/ScalarSelfTestSuite.scala | 38 + .../tests/ScalarAffinityRoutingSpec.scala | 68 - .../tests/ScalarCacheProjectionSpec.scala | 39 - .../scalar/tests/ScalarCacheQueriesSpec.scala | 601 ------ .../gridgain/scalar/tests/ScalarCacheSpec.scala | 79 - .../scalar/tests/ScalarConversionsSpec.scala | 254 --- .../scalar/tests/ScalarProjectionSpec.scala | 150 -- .../scalar/tests/ScalarReturnableSpec.scala | 58 - .../org/gridgain/scalar/tests/ScalarSpec.scala | 37 - .../scalar/testsuites/ScalarSelfTestSuite.scala | 38 - 154 files changed, 8122 insertions(+), 8122 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/examples/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarExamplesMultiNodeSelfTest.scala ---------------------------------------------------------------------- diff --git a/examples/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarExamplesMultiNodeSelfTest.scala b/examples/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarExamplesMultiNodeSelfTest.scala new file mode 100644 index 0000000..3ca89b2 --- /dev/null +++ b/examples/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarExamplesMultiNodeSelfTest.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.tests.examples + +/** + * Scalar examples multi-node self test. + */ +class ScalarExamplesMultiNodeSelfTest extends ScalarExamplesSelfTest { + /** */ + protected override def beforeTest() { + startRemoteNodes() + } + + /** */ + protected override def getTestTimeout: Long = { + 10 * 60 * 1000 + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/examples/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarExamplesSelfTest.scala ---------------------------------------------------------------------- diff --git a/examples/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarExamplesSelfTest.scala b/examples/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarExamplesSelfTest.scala new file mode 100644 index 0000000..6bd11c9 --- /dev/null +++ b/examples/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarExamplesSelfTest.scala @@ -0,0 +1,118 @@ +/* + * 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.tests.examples + +import org.gridgain.scalar.examples._ +import org.gridgain.scalar.scalar +import org.scalatest.junit.JUnitSuiteLike +import org.gridgain.testframework.junits.common.GridAbstractExamplesTest + +/** + * Scalar examples self test. + */ +class ScalarExamplesSelfTest extends GridAbstractExamplesTest with JUnitSuiteLike { + /** */ + private def EMPTY_ARGS = Array.empty[String] + + /** */ + def testScalarCacheAffinityExample1() { + ScalarCacheAffinityExample1.main(EMPTY_ARGS) + } + + /** */ + def testScalarCacheAffinityExample2() { + ScalarCacheAffinityExample2.main(EMPTY_ARGS) + } + + /** */ + def testScalarCacheAffinitySimpleExample() { + ScalarCacheAffinitySimpleExample.main(EMPTY_ARGS) + } + + /** */ + def testScalarCacheExample() { + ScalarCacheExample.main(EMPTY_ARGS) + } + + /** */ + def testScalarCacheQueryExample() { + ScalarCacheQueryExample.main(EMPTY_ARGS) + } + + /** */ + def testScalarClosureExample() { + ScalarClosureExample.main(EMPTY_ARGS) + } + + /** */ + def testScalarContinuationExample() { + ScalarContinuationExample.main(EMPTY_ARGS) + } + + /** */ + def testScalarCreditRiskExample() { + ScalarCreditRiskExample.main(EMPTY_ARGS) + } + + /** */ + def testScalarPiCalculationExample() { + ScalarPiCalculationExample.main(EMPTY_ARGS) + } + + /** */ + def testScalarPingPongExample() { + scalar("modules/scalar/src/test/resources/spring-ping-pong-partner.xml") { + ScalarPingPongExample.main(EMPTY_ARGS) + } + } + + /** */ + def testScalarPopularNumbersRealTimeExample() { + ScalarCachePopularNumbersExample.main(EMPTY_ARGS) + } + + /** */ + def testScalarPrimeExample() { + ScalarPrimeExample.main(EMPTY_ARGS) + } + + /** */ + def testScalarScheduleCallableExample() { + ScalarScheduleExample.main(EMPTY_ARGS) + } + + /** */ + def testScalarStartStopExample() { + ScalarStartStopExample.main(EMPTY_ARGS) + } + + /** */ + def testScalarTaskExample() { + ScalarTaskExample.main(EMPTY_ARGS) + } + + /** */ + def testScalarWorldShortestMapReduceExample() { + ScalarWorldShortestMapReduce.main(EMPTY_ARGS) + } + + /** */ + def testScalarSnowflakeSchemaExample() { + ScalarSnowflakeSchemaExample.main(EMPTY_ARGS) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/examples/src/test/scala/org/apache/ignite/scalar/testsuites/ScalarExamplesSelfTestSuite.scala ---------------------------------------------------------------------- diff --git a/examples/src/test/scala/org/apache/ignite/scalar/testsuites/ScalarExamplesSelfTestSuite.scala b/examples/src/test/scala/org/apache/ignite/scalar/testsuites/ScalarExamplesSelfTestSuite.scala new file mode 100644 index 0000000..dcddc83 --- /dev/null +++ b/examples/src/test/scala/org/apache/ignite/scalar/testsuites/ScalarExamplesSelfTestSuite.scala @@ -0,0 +1,39 @@ +/* + * 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.testsuites + +import org.apache.ignite.IgniteSystemProperties +import org.scalatest._ +import org.gridgain.scalar.tests._ +import examples.{ScalarExamplesMultiNodeSelfTest, ScalarExamplesSelfTest} +import org.junit.runner.RunWith +import org.scalatest.junit.JUnitRunner +import IgniteSystemProperties._ +import org.gridgain.testframework.GridTestUtils + +/** + * + */ +@RunWith(classOf[JUnitRunner]) +class ScalarExamplesSelfTestSuite extends Suites( + new ScalarExamplesSelfTest, + new ScalarExamplesMultiNodeSelfTest +) { + System.setProperty(GG_OVERRIDE_MCAST_GRP, + GridTestUtils.getNextMulticastGroup(classOf[ScalarExamplesSelfTest])) +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/examples/src/test/scala/org/gridgain/scalar/tests/examples/ScalarExamplesMultiNodeSelfTest.scala ---------------------------------------------------------------------- diff --git a/examples/src/test/scala/org/gridgain/scalar/tests/examples/ScalarExamplesMultiNodeSelfTest.scala b/examples/src/test/scala/org/gridgain/scalar/tests/examples/ScalarExamplesMultiNodeSelfTest.scala deleted file mode 100644 index 3ca89b2..0000000 --- a/examples/src/test/scala/org/gridgain/scalar/tests/examples/ScalarExamplesMultiNodeSelfTest.scala +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.tests.examples - -/** - * Scalar examples multi-node self test. - */ -class ScalarExamplesMultiNodeSelfTest extends ScalarExamplesSelfTest { - /** */ - protected override def beforeTest() { - startRemoteNodes() - } - - /** */ - protected override def getTestTimeout: Long = { - 10 * 60 * 1000 - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/examples/src/test/scala/org/gridgain/scalar/tests/examples/ScalarExamplesSelfTest.scala ---------------------------------------------------------------------- diff --git a/examples/src/test/scala/org/gridgain/scalar/tests/examples/ScalarExamplesSelfTest.scala b/examples/src/test/scala/org/gridgain/scalar/tests/examples/ScalarExamplesSelfTest.scala deleted file mode 100644 index 6bd11c9..0000000 --- a/examples/src/test/scala/org/gridgain/scalar/tests/examples/ScalarExamplesSelfTest.scala +++ /dev/null @@ -1,118 +0,0 @@ -/* - * 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.tests.examples - -import org.gridgain.scalar.examples._ -import org.gridgain.scalar.scalar -import org.scalatest.junit.JUnitSuiteLike -import org.gridgain.testframework.junits.common.GridAbstractExamplesTest - -/** - * Scalar examples self test. - */ -class ScalarExamplesSelfTest extends GridAbstractExamplesTest with JUnitSuiteLike { - /** */ - private def EMPTY_ARGS = Array.empty[String] - - /** */ - def testScalarCacheAffinityExample1() { - ScalarCacheAffinityExample1.main(EMPTY_ARGS) - } - - /** */ - def testScalarCacheAffinityExample2() { - ScalarCacheAffinityExample2.main(EMPTY_ARGS) - } - - /** */ - def testScalarCacheAffinitySimpleExample() { - ScalarCacheAffinitySimpleExample.main(EMPTY_ARGS) - } - - /** */ - def testScalarCacheExample() { - ScalarCacheExample.main(EMPTY_ARGS) - } - - /** */ - def testScalarCacheQueryExample() { - ScalarCacheQueryExample.main(EMPTY_ARGS) - } - - /** */ - def testScalarClosureExample() { - ScalarClosureExample.main(EMPTY_ARGS) - } - - /** */ - def testScalarContinuationExample() { - ScalarContinuationExample.main(EMPTY_ARGS) - } - - /** */ - def testScalarCreditRiskExample() { - ScalarCreditRiskExample.main(EMPTY_ARGS) - } - - /** */ - def testScalarPiCalculationExample() { - ScalarPiCalculationExample.main(EMPTY_ARGS) - } - - /** */ - def testScalarPingPongExample() { - scalar("modules/scalar/src/test/resources/spring-ping-pong-partner.xml") { - ScalarPingPongExample.main(EMPTY_ARGS) - } - } - - /** */ - def testScalarPopularNumbersRealTimeExample() { - ScalarCachePopularNumbersExample.main(EMPTY_ARGS) - } - - /** */ - def testScalarPrimeExample() { - ScalarPrimeExample.main(EMPTY_ARGS) - } - - /** */ - def testScalarScheduleCallableExample() { - ScalarScheduleExample.main(EMPTY_ARGS) - } - - /** */ - def testScalarStartStopExample() { - ScalarStartStopExample.main(EMPTY_ARGS) - } - - /** */ - def testScalarTaskExample() { - ScalarTaskExample.main(EMPTY_ARGS) - } - - /** */ - def testScalarWorldShortestMapReduceExample() { - ScalarWorldShortestMapReduce.main(EMPTY_ARGS) - } - - /** */ - def testScalarSnowflakeSchemaExample() { - ScalarSnowflakeSchemaExample.main(EMPTY_ARGS) - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/examples/src/test/scala/org/gridgain/scalar/testsuites/ScalarExamplesSelfTestSuite.scala ---------------------------------------------------------------------- diff --git a/examples/src/test/scala/org/gridgain/scalar/testsuites/ScalarExamplesSelfTestSuite.scala b/examples/src/test/scala/org/gridgain/scalar/testsuites/ScalarExamplesSelfTestSuite.scala deleted file mode 100644 index dcddc83..0000000 --- a/examples/src/test/scala/org/gridgain/scalar/testsuites/ScalarExamplesSelfTestSuite.scala +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.testsuites - -import org.apache.ignite.IgniteSystemProperties -import org.scalatest._ -import org.gridgain.scalar.tests._ -import examples.{ScalarExamplesMultiNodeSelfTest, ScalarExamplesSelfTest} -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner -import IgniteSystemProperties._ -import org.gridgain.testframework.GridTestUtils - -/** - * - */ -@RunWith(classOf[JUnitRunner]) -class ScalarExamplesSelfTestSuite extends Suites( - new ScalarExamplesSelfTest, - new ScalarExamplesMultiNodeSelfTest -) { - System.setProperty(GG_OVERRIDE_MCAST_GRP, - GridTestUtils.getNextMulticastGroup(classOf[ScalarExamplesSelfTest])) -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/ScalarConversions.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/ScalarConversions.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/ScalarConversions.scala new file mode 100644 index 0000000..77d212c --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/ScalarConversions.scala @@ -0,0 +1,1235 @@ +/* + * 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 + +import org.apache.ignite.Ignite +import org.apache.ignite.cache.{GridCacheEntry, GridCache, GridCacheProjection} +import org.apache.ignite.cluster.ClusterGroup +import org.apache.ignite.compute.ComputeJob +import org.apache.ignite.lang._ +import org.gridgain.scalar.lang._ +import org.gridgain.scalar.pimps._ +import org.jetbrains.annotations._ +import collection._ +import scala.util.control.Breaks._ +import java.util.concurrent._ +import java.util.TimerTask +import org.apache.ignite.internal.util.lang._ +import scala.Tuple2 + +/** + * ==Overview== + * Mixin for `scalar` object providing `implicit` and `explicit` conversions between + * Java and Scala GridGain components. + * + * It is very important to review this class as it defines what `implicit` conversions + * will take place when using Scalar. Note that object `scalar` mixes in this + * trait and therefore brings with it all implicits into the scope. + */ +trait ScalarConversions { + /** + * Helper transformer from Java collection to Scala sequence. + * + * @param c Java collection to transform. + * @param f Transforming function. + */ + def toScalaSeq[A, B](@Nullable c: java.util.Collection[A], f: A => B): Seq[B] = { + assert(f != null) + + if (c == null) + return null + + val iter = c.iterator + + val lst = new mutable.ListBuffer[B] + + while (iter.hasNext) lst += f(iter.next) + + lst.toSeq + } + + /** + * Helper transformer from Java iterator to Scala sequence. + * + * @param i Java iterator to transform. + * @param f Transforming function. + */ + def toScalaSeq[A, B](@Nullable i: java.util.Iterator[A], f: A => B): Seq[B] = { + assert(f != null) + + if (i == null) + return null + + val lst = new mutable.ListBuffer[B] + + while (i.hasNext) lst += f(i.next) + + lst.toSeq + } + + /** + * Helper converter from Java iterator to Scala sequence. + * + * @param i Java iterator to convert. + */ + def toScalaSeq[A](@Nullable i: java.util.Iterator[A]): Seq[A] = + toScalaSeq(i, (e: A) => e) + + /** + * Helper transformer from Java iterable to Scala sequence. + * + * @param i Java iterable to transform. + * @param f Transforming function. + */ + def toScalaSeq[A, B](@Nullable i: java.lang.Iterable[A], f: A => B): Seq[B] = { + assert(f != null) + + if (i == null) return null + + toScalaSeq(i.iterator, f) + } + + /** + * Helper converter from Java iterable to Scala sequence. + * + * @param i Java iterable to convert. + */ + def toScalaSeq[A](@Nullable i: java.lang.Iterable[A]): Seq[A] = + toScalaSeq(i, (e: A) => e) + + /** + * Helper converter from Java collection to Scala sequence. + * + * @param c Java collection to convert. + */ + def toScalaSeq[A](@Nullable c: java.util.Collection[A]): Seq[A] = + toScalaSeq(c, (e: A) => e) + + /** + * Helper converter from Java entry collection to Scala iterable of pair. + * + * @param c Java collection to convert. + */ + def toScalaItr[K, V](@Nullable c: java.util.Collection[java.util.Map.Entry[K, V]]): Iterable[(K, V)] = { + val lst = new mutable.ListBuffer[(K, V)] + + c.toArray().foreach { + case f: java.util.Map.Entry[K, V] => lst += Tuple2(f.getKey(), f.getValue()) + } + + lst + } + + /** + * Helper transformer from Scala sequence to Java collection. + * + * @param s Scala sequence to transform. + * @param f Transforming function. + */ + def toJavaCollection[A, B](@Nullable s: Seq[A], f: A => B): java.util.Collection[B] = { + assert(f != null) + + if (s == null) return null + + val lst = new java.util.ArrayList[B](s.length) + + s.foreach(a => lst.add(f(a))) + + lst + } + + /** + * Helper converter from Scala sequence to Java collection. + * + * @param s Scala sequence to convert. + */ + def toJavaCollection[A](@Nullable s: Seq[A]): java.util.Collection[A] = + toJavaCollection(s, (e: A) => e) + + /** + * Helper transformer from Scala iterator to Java collection. + * + * @param i Scala iterator to transform. + * @param f Transforming function. + */ + def toJavaCollection[A, B](@Nullable i: Iterator[A], f: A => B): java.util.Collection[B] = { + assert(f != null) + + if (i == null) return null + + val lst = new java.util.ArrayList[B] + + i.foreach(a => lst.add(f(a))) + + lst + } + + /** + * Converts from `Symbol` to `String`. + * + * @param s Symbol to convert. + */ + implicit def fromSymbol(s: Symbol): String = + if (s == null) + null + else + s.toString().substring(1) + + /** + * Introduction of `^^` operator for `Any` type that will call `break`. + * + * @param v `Any` value. + */ + implicit def toReturnable(v: Any) = new { + // Ignore the warning below. + def ^^ { + break() + } + } + + + /** + * Explicit converter for `TimerTask`. Note that since `TimerTask` implements `Runnable` + * we can't use the implicit conversion. + * + * @param f Closure to convert. + * @return Time task instance. + */ + def timerTask(f: => Unit): TimerTask = new TimerTask { + def run() { + f + } + } + + /** + * Extension for `Tuple2`. + * + * @param t Tuple to improve. + */ + implicit def toTuple2x[T1, T2](t: (T1, T2)) = new { + def isSome: Boolean = + t._1 != null || t._2 != null + + def isNone: Boolean = + !isSome + + def isAll: Boolean = + t._1 != null && t._2 != null + + def opt1: Option[T1] = + Option(t._1) + + def opt2: Option[T2] = + Option(t._2) + } + + /** + * Extension for `Tuple3`. + * + * @param t Tuple to improve. + */ + implicit def toTuple3x[T1, T2, T3](t: (T1, T2, T3)) = new { + def isSome: Boolean = + t._1 != null || t._2 != null || t._3 != null + + def isNone: Boolean = + !isSome + + def isAll: Boolean = + t._1 != null && t._2 != null && t._3 != null + + def opt1: Option[T1] = + Option(t._1) + + def opt2: Option[T2] = + Option(t._2) + + def opt3: Option[T3] = + Option(t._3) + } + + /** + * Implicit converter from cache KV-pair predicate to cache entry predicate. Note that predicate + * will use peek() + * + * @param p Cache KV-pair predicate to convert. + */ + implicit def toEntryPred[K, V](p: (K, V) => Boolean): (_ >: GridCacheEntry[K, V]) => Boolean = + (e: GridCacheEntry[K, V]) => + p(e.getKey, e.getValue) + + /** + * Implicit converter from vararg of one-argument Scala functions to Java `GridPredicate`s. + * + * @param s Sequence of one-argument Scala functions to convert. + */ + implicit def toVarArgs[T](s: Seq[T => Boolean]): Seq[IgnitePredicate[_ >: T]] = + s.map((f: T => Boolean) => toPredicate(f)) + + /** + * Implicit converter from vararg of two-argument Scala functions to Java `GridPredicate2`s. + * + * @param s Sequence of two-argument Scala functions to convert. + */ + implicit def toVarArgs2[T1, T2](s: Seq[(T1, T2) => Boolean]): Seq[IgniteBiPredicate[_ >: T1, _ >: T2]] = + s.map((f: (T1, T2) => Boolean) => toPredicate2(f)) + + /** + * Implicit converter from vararg of three-argument Scala functions to Java `GridPredicate3`s. + * + * @param s Sequence of three-argument Scala functions to convert. + */ + implicit def toVarArgs3[T1, T2, T3](s: Seq[(T1, T2, T3) => Boolean]): + Seq[GridPredicate3[_ >: T1, _ >: T2, _ >: T3]] = + s.map((f: (T1, T2, T3) => Boolean) => toPredicate3(f)) + + /** + * Implicit converter from Scala function and Java `GridReducer`. + * + * @param r Scala function to convert. + */ + implicit def toReducer[E, R](r: Seq[E] => R): IgniteReducer[E, R] = + new ScalarReducer(r) + + /** + * Implicit converter from Java `GridReducer` to Scala function. + * + * @param r Java `GridReducer` to convert. + */ + implicit def fromReducer[E, R](r: IgniteReducer[E, R]): Seq[E] => R = + new ScalarReducerFunction[E, R](r) + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param r Java-side reducer to pimp. + */ + implicit def reducerDotScala[E, R](r: IgniteReducer[E, R]) = new { + def scala: Seq[E] => R = + fromReducer(r) + } + + /** + * Implicit converter from Scala function and Java `GridReducer2`. + * + * @param r Scala function to convert. + */ + implicit def toReducer2[E1, E2, R](r: (Seq[E1], Seq[E2]) => R): IgniteReducer2[E1, E2, R] = + new ScalarReducer2(r) + + /** + * Implicit converter from Java `GridReducer2` to Scala function. + * + * @param r Java `GridReducer2` to convert. + */ + implicit def fromReducer2[E1, E2, R](r: IgniteReducer2[E1, E2, R]): (Seq[E1], Seq[E2]) => R = + new ScalarReducer2Function[E1, E2, R](r) + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param r Java-side reducer to pimp. + */ + implicit def reducer2DotScala[E1, E2, R](r: IgniteReducer2[E1, E2, R]) = new { + def scala: (Seq[E1], Seq[E2]) => R = + fromReducer2(r) + } + + /** + * Implicit converter from Scala function and Java `GridReducer3`. + * + * @param r Scala function to convert. + */ + implicit def toReducer3[E1, E2, E3, R](r: (Seq[E1], Seq[E2], Seq[E3]) => R): IgniteReducer3[E1, E2, E3, R] = + new ScalarReducer3(r) + + /** + * Implicit converter from Java `GridReducer3` to Scala function. + * + * @param r Java `GridReducer3` to convert. + */ + implicit def fromReducer3[E1, E2, E3, R](r: IgniteReducer3[E1, E2, E3, R]): (Seq[E1], Seq[E2], Seq[E3]) => R = + new ScalarReducer3Function[E1, E2, E3, R](r) + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param r Java-side reducer to pimp. + */ + implicit def reducer3DotScala[E1, E2, E3, R](r: IgniteReducer3[E1, E2, E3, R]) = new { + def scala: (Seq[E1], Seq[E2], Seq[E3]) => R = + fromReducer3(r) + } + + /** + * Implicit converter from `Grid` to `ScalarGridPimp` "pimp". + * + * @param impl Grid to convert. + */ + implicit def toScalarGrid(impl: Ignite): ScalarGridPimp = + ScalarGridPimp(impl) + + /** + * Implicit converter from `GridProjection` to `ScalarProjectionPimp` "pimp". + * + * @param impl Grid projection to convert. + */ + implicit def toScalarProjection(impl: ClusterGroup): ScalarProjectionPimp[ClusterGroup] = + ScalarProjectionPimp(impl) + + /** + * Implicit converter from `GridCache` to `ScalarCachePimp` "pimp". + * + * @param impl Grid cache to convert. + */ + implicit def toScalarCache[K, V](impl: GridCache[K, V]): ScalarCachePimp[K, V] = + ScalarCachePimp[K, V](impl) + + /** + * Implicit converter from `GridCacheProjection` to `ScalarCacheProjectionPimp` "pimp". + * + * @param impl Grid cache projection to convert. + */ + implicit def toScalarCacheProjection[K, V](impl: GridCacheProjection[K, V]): ScalarCacheProjectionPimp[K, V] = + ScalarCacheProjectionPimp[K, V](impl) + + /** + * Implicit converter from Scala function to `ComputeJob`. + * + * @param f Scala function to convert. + */ + implicit def toJob(f: () => Any): ComputeJob = + new ScalarJob(f) + + /** + * Implicit converter from Scala tuple to `GridTuple2`. + * + * @param t Scala tuple to convert. + */ + implicit def toTuple2[A, B](t: (A, B)): IgniteBiTuple[A, B] = + new IgniteBiTuple[A, B](t._1, t._2) + + /** + * Implicit converter from `GridTuple2` to Scala tuple. + * + * @param t `GridTuple2` to convert. + */ + implicit def fromTuple2[A, B](t: IgniteBiTuple[A, B]): (A, B) = + (t.get1, t.get2) + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param t Java-side tuple to pimp. + */ + implicit def tuple2DotScala[A, B](t: IgniteBiTuple[A, B]) = new { + def scala: (A, B) = + fromTuple2(t) + } + + /** + * Implicit converter from Scala tuple to `GridTuple3`. + * + * @param t Scala tuple to convert. + */ + implicit def toTuple3[A, B, C](t: (A, B, C)): GridTuple3[A, B, C] = + new GridTuple3[A, B, C](t._1, t._2, t._3) + + /** + * Implicit converter from `GridTuple3` to Scala tuple. + * + * @param t `GridTuple3` to convert. + */ + implicit def fromTuple3[A, B, C](t: GridTuple3[A, B, C]): (A, B, C) = + (t.get1, t.get2, t.get3) + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param t Java-side tuple to pimp. + */ + implicit def tuple3DotScala[A, B, C](t: GridTuple3[A, B, C]) = new { + def scala: (A, B, C) = + fromTuple3(t) + } + + /** + * Implicit converter from Scala tuple to `GridTuple4`. + * + * @param t Scala tuple to convert. + */ + implicit def toTuple4[A, B, C, D](t: (A, B, C, D)): GridTuple4[A, B, C, D] = + new GridTuple4[A, B, C, D](t._1, t._2, t._3, t._4) + + /** + * Implicit converter from `GridTuple4` to Scala tuple. + * + * @param t `GridTuple4` to convert. + */ + implicit def fromTuple4[A, B, C, D](t: GridTuple4[A, B, C, D]): (A, B, C, D) = + (t.get1, t.get2, t.get3, t.get4) + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param t Java-side tuple to pimp. + */ + implicit def tuple4DotScala[A, B, C, D](t: GridTuple4[A, B, C, D]) = new { + def scala: (A, B, C, D) = + fromTuple4(t) + } + + /** + * Implicit converter from Scala tuple to `GridTuple5`. + * + * @param t Scala tuple to convert. + */ + implicit def toTuple5[A, B, C, D, E](t: (A, B, C, D, E)): GridTuple5[A, B, C, D, E] = + new GridTuple5[A, B, C, D, E](t._1, t._2, t._3, t._4, t._5) + + /** + * Implicit converter from `GridTuple5` to Scala tuple. + * + * @param t `GridTuple5` to convert. + */ + implicit def fromTuple5[A, B, C, D, E](t: GridTuple5[A, B, C, D, E]): (A, B, C, D, E) = + (t.get1, t.get2, t.get3, t.get4, t.get5) + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param t Java-side tuple to pimp. + */ + implicit def tuple5DotScala[A, B, C, D, E](t: GridTuple5[A, B, C, D, E]) = new { + def scala: (A, B, C, D, E) = + fromTuple5(t) + } + + /** + * Implicit converter from Scala function to `GridInClosure`. + * + * @param f Scala function to convert. + */ + implicit def toInClosure[T](f: T => Unit): IgniteInClosure[T] = + f match { + case (p: ScalarInClosureFunction[T]) => p.inner + case _ => new ScalarInClosure[T](f) + } + + /** + * Implicit converter from Scala function to `GridInClosureX`. + * + * @param f Scala function to convert. + */ + def toInClosureX[T](f: T => Unit): IgniteInClosureX[T] = + f match { + case (p: ScalarInClosureXFunction[T]) => p.inner + case _ => new ScalarInClosureX[T](f) + } + + /** + * Implicit converter from `GridInClosure` to Scala wrapping function. + * + * @param f Grid closure to convert. + */ + implicit def fromInClosure[T](f: IgniteInClosure[T]): T => Unit = + new ScalarInClosureFunction[T](f) + + /** + * Implicit converter from `GridInClosureX` to Scala wrapping function. + * + * @param f Grid closure to convert. + */ + implicit def fromInClosureX[T](f: IgniteInClosureX[T]): T => Unit = + new ScalarInClosureXFunction[T](f) + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param f Java-side closure to pimp. + */ + implicit def inClosureDotScala[T](f: IgniteInClosure[T]) = new { + def scala: T => Unit = + fromInClosure(f) + } + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param f Java-side closure to pimp. + */ + implicit def inClosureXDotScala[T](f: IgniteInClosureX[T]) = new { + def scala: T => Unit = + fromInClosureX(f) + } + + /** + * Implicit converter from Scala function to `GridInClosure2`. + * + * @param f Scala function to convert. + */ + implicit def toInClosure2[T1, T2](f: (T1, T2) => Unit): IgniteBiInClosure[T1, T2] = + f match { + case (p: ScalarInClosure2Function[T1, T2]) => p.inner + case _ => new ScalarInClosure2[T1, T2](f) + } + + /** + * Implicit converter from Scala function to `GridInClosure2X`. + * + * @param f Scala function to convert. + */ + implicit def toInClosure2X[T1, T2](f: (T1, T2) => Unit): IgniteInClosure2X[T1, T2] = + f match { + case (p: ScalarInClosure2XFunction[T1, T2]) => p.inner + case _ => new ScalarInClosure2X[T1, T2](f) + } + + /** + * Implicit converter from `GridInClosure2` to Scala wrapping function. + * + * @param f Grid closure to convert. + */ + implicit def fromInClosure2[T1, T2](f: IgniteBiInClosure[T1, T2]): (T1, T2) => Unit = + new ScalarInClosure2Function(f) + + /** + * Implicit converter from `GridInClosure2X` to Scala wrapping function. + * + * @param f Grid closure to convert. + */ + implicit def fromInClosure2X[T1, T2](f: IgniteInClosure2X[T1, T2]): (T1, T2) => Unit = + new ScalarInClosure2XFunction(f) + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param f Java-side closure to pimp. + */ + implicit def inClosure2DotScala[T1, T2](f: IgniteBiInClosure[T1, T2]) = new { + def scala: (T1, T2) => Unit = + fromInClosure2(f) + } + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param f Java-side closure to pimp. + */ + implicit def inClosure2XDotScala[T1, T2](f: IgniteInClosure2X[T1, T2]) = new { + def scala: (T1, T2) => Unit = + fromInClosure2X(f) + } + + /** + * Implicit converter from Scala function to `GridInClosure3`. + * + * @param f Scala function to convert. + */ + implicit def toInClosure3[T1, T2, T3](f: (T1, T2, T3) => Unit): GridInClosure3[T1, T2, T3] = + f match { + case (p: ScalarInClosure3Function[T1, T2, T3]) => p.inner + case _ => new ScalarInClosure3[T1, T2, T3](f) + } + + /** + * Implicit converter from Scala function to `GridInClosure3X`. + * + * @param f Scala function to convert. + */ + def toInClosure3X[T1, T2, T3](f: (T1, T2, T3) => Unit): GridInClosure3X[T1, T2, T3] = + f match { + case (p: ScalarInClosure3XFunction[T1, T2, T3]) => p.inner + case _ => new ScalarInClosure3X[T1, T2, T3](f) + } + + /** + * Implicit converter from `GridInClosure3` to Scala wrapping function. + * + * @param f Grid closure to convert. + */ + implicit def fromInClosure3[T1, T2, T3](f: GridInClosure3[T1, T2, T3]): (T1, T2, T3) => Unit = + new ScalarInClosure3Function(f) + + /** + * Implicit converter from `GridInClosure3X` to Scala wrapping function. + * + * @param f Grid closure to convert. + */ + implicit def fromInClosure3X[T1, T2, T3](f: GridInClosure3X[T1, T2, T3]): (T1, T2, T3) => Unit = + new ScalarInClosure3XFunction(f) + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param f Java-side closure to pimp. + */ + implicit def inClosure3DotScala[T1, T2, T3](f: GridInClosure3[T1, T2, T3]) = new { + def scala: (T1, T2, T3) => Unit = + fromInClosure3(f) + } + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param f Java-side closure to pimp. + */ + implicit def inClosure3XDotScala[T1, T2, T3](f: GridInClosure3X[T1, T2, T3]) = new { + def scala: (T1, T2, T3) => Unit = + fromInClosure3X(f) + } + + /** + * Implicit converter from Scala function to `GridOutClosure`. + * + * @param f Scala function to convert. + */ + implicit def toCallable[R](f: () => R): Callable[R] = + f match { + case p: ScalarOutClosureFunction[R] => p.inner + case _ => new ScalarOutClosure[R](f) + } + + /** + * Implicit converter from Scala function to `GridOutClosureX`. + * + * @param f Scala function to convert. + */ + def toOutClosureX[R](f: () => R): IgniteOutClosureX[R] = + f match { + case (p: ScalarOutClosureXFunction[R]) => p.inner + case _ => new ScalarOutClosureX[R](f) + } + + /** + * Implicit converter from `GridOutClosure` to Scala wrapping function. + * + * @param f Grid closure to convert. + */ + implicit def fromOutClosure[R](f: Callable[R]): () => R = + new ScalarOutClosureFunction[R](f) + + /** + * Implicit converter from `GridOutClosureX` to Scala wrapping function. + * + * @param f Grid closure to convert. + */ + implicit def fromOutClosureX[R](f: IgniteOutClosureX[R]): () => R = + new ScalarOutClosureXFunction[R](f) + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param f Java-side closure to pimp. + */ + implicit def outClosureDotScala[R](f: Callable[R]) = new { + def scala: () => R = + fromOutClosure(f) + } + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param f Java-side closure to pimp. + */ + implicit def outClosureXDotScala[R](f: IgniteOutClosureX[R]) = new { + def scala: () => R = + fromOutClosureX(f) + } + + /** + * Implicit converter from Scala function to `GridAbsClosure`. + * + * @param f Scala function to convert. + */ + implicit def toRunnable(f: () => Unit): Runnable = + f match { + case (f: ScalarAbsClosureFunction) => f.inner + case _ => new ScalarAbsClosure(f) + } + + /** + * Implicit converter from Scala function to `GridAbsClosureX`. + * + * @param f Scala function to convert. + */ + def toAbsClosureX(f: () => Unit): GridAbsClosureX = + f match { + case (f: ScalarAbsClosureXFunction) => f.inner + case _ => new ScalarAbsClosureX(f) + } + + /** + * Implicit converter from `GridAbsClosure` to Scala wrapping function. + * + * @param f Grid closure to convert. + */ + implicit def fromAbsClosure(f: GridAbsClosure): () => Unit = + new ScalarAbsClosureFunction(f) + + /** + * Implicit converter from `GridAbsClosureX` to Scala wrapping function. + * + * @param f Grid closure to convert. + */ + implicit def fromAbsClosureX(f: GridAbsClosureX): () => Unit = + new ScalarAbsClosureXFunction(f) + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param f Java-side absolute closure to pimp. + */ + implicit def absClosureDotScala(f: GridAbsClosure) = new { + def scala: () => Unit = + fromAbsClosure(f) + } + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param f Java-side absolute closure to pimp. + */ + implicit def absClosureXDotScala(f: GridAbsClosureX) = new { + def scala: () => Unit = + fromAbsClosureX(f) + } + + /** + * Implicit converter from Scala predicate to `GridAbsPredicate`. + * + * @param f Scala predicate to convert. + */ + implicit def toAbsPredicate(f: () => Boolean): GridAbsPredicate = + f match { + case (p: ScalarAbsPredicateFunction) => p.inner + case _ => new ScalarAbsPredicate(f) + } + + /** + * Implicit converter from Scala predicate to `GridAbsPredicateX`. + * + * @param f Scala predicate to convert. + */ + implicit def toAbsPredicateX(f: () => Boolean): GridAbsPredicateX = + f match { + case (p: ScalarAbsPredicateXFunction) => p.inner + case _ => new ScalarAbsPredicateX(f) + } + + /** + * Implicit converter from `GridAbsPredicate` to Scala wrapping predicate. + * + * @param p Grid predicate to convert. + */ + implicit def fromAbsPredicate(p: GridAbsPredicate): () => Boolean = + new ScalarAbsPredicateFunction(p) + + /** + * Implicit converter from `GridAbsPredicateX` to Scala wrapping predicate. + * + * @param p Grid predicate to convert. + */ + implicit def fromAbsPredicateX(p: GridAbsPredicateX): () => Boolean = + new ScalarAbsPredicateXFunction(p) + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param p Java-side predicate to pimp. + */ + implicit def absPredicateDotScala(p: GridAbsPredicate) = new { + def scala: () => Boolean = + fromAbsPredicate(p) + } + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param p Java-side predicate to pimp. + */ + implicit def absPredicateXDotScala(p: GridAbsPredicateX) = new { + def scala: () => Boolean = + fromAbsPredicateX(p) + } + + /** + * Implicit converter from `java.lang.Runnable` to `GridAbsClosure`. + * + * @param r Java runnable to convert. + */ + implicit def toAbsClosure2(r: java.lang.Runnable): GridAbsClosure = + GridFunc.as(r) + + /** + * Implicit converter from `java.util.concurrent.Callable` to `GridOutClosure`. + * + * @param c Java callable to convert. + */ + implicit def toOutClosure2[R](c: java.util.concurrent.Callable[R]): IgniteOutClosure[R] = + GridFunc.as0(c) + + /** + * Implicit converter from Scala predicate to Scala wrapping predicate. + * + * @param f Scala predicate to convert. + */ + implicit def toPredicate[T](f: T => Boolean) = + f match { + case null => null + case (p: ScalarPredicateFunction[T]) => p.inner + case _ => new ScalarPredicate[T](f) + } + + /** + * Implicit converter from Scala predicate to Scala wrapping predicate. + * + * @param f Scala predicate to convert. + */ + def toPredicateX[T](f: T => Boolean) = + f match { + case (p: ScalarPredicateXFunction[T]) => p.inner + case _ => new ScalarPredicateX[T](f) + } + + /** + * Implicit converter from `GridPredicate` to Scala wrapping predicate. + * + * @param p Grid predicate to convert. + */ + implicit def fromPredicate[T](p: IgnitePredicate[T]): T => Boolean = + new ScalarPredicateFunction[T](p) + + /** + * Implicit converter from `GridPredicate` to Scala wrapping predicate. + * + * @param p Grid predicate to convert. + */ + implicit def fromPredicateX[T](p: IgnitePredicateX[T]): T => Boolean = + new ScalarPredicateXFunction[T](p) + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param p Java-side predicate to pimp. + */ + implicit def predicateDotScala[T](p: IgnitePredicate[T]) = new { + def scala: T => Boolean = + fromPredicate(p) + } + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param p Java-side predicate to pimp. + */ + implicit def predicateXDotScala[T](p: IgnitePredicateX[T]) = new { + def scala: T => Boolean = + fromPredicateX(p) + } + + /** + * Implicit converter from Scala predicate to Scala wrapping predicate. + * + * @param f Scala predicate to convert. + */ + implicit def toPredicate2[T1, T2](f: (T1, T2) => Boolean) = + f match { + case (p: ScalarPredicate2Function[T1, T2]) => p.inner + case _ => new ScalarPredicate2[T1, T2](f) + } + + /** + * Implicit converter from Scala predicate to Scala wrapping predicate. + * + * @param f Scala predicate to convert. + */ + def toPredicate2X[T1, T2](f: (T1, T2) => Boolean) = + f match { + case (p: ScalarPredicate2XFunction[T1, T2]) => p.inner + case _ => new ScalarPredicate2X[T1, T2](f) + } + + /** + * Implicit converter from `GridPredicate2X` to Scala wrapping predicate. + * + * @param p Grid predicate to convert. + */ + implicit def fromPredicate2[T1, T2](p: IgniteBiPredicate[T1, T2]): (T1, T2) => Boolean = + new ScalarPredicate2Function[T1, T2](p) + + /** + * Implicit converter from `GridPredicate2X` to Scala wrapping predicate. + * + * @param p Grid predicate to convert. + */ + implicit def fromPredicate2X[T1, T2](p: IgnitePredicate2X[T1, T2]): (T1, T2) => Boolean = + new ScalarPredicate2XFunction[T1, T2](p) + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param p Java-side predicate to pimp. + */ + implicit def predicate2DotScala[T1, T2](p: IgniteBiPredicate[T1, T2]) = new { + def scala: (T1, T2) => Boolean = + fromPredicate2(p) + } + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param p Java-side predicate to pimp. + */ + implicit def predicate2XDotScala[T1, T2](p: IgnitePredicate2X[T1, T2]) = new { + def scala: (T1, T2) => Boolean = + fromPredicate2X(p) + } + + /** + * Implicit converter from Scala predicate to Scala wrapping predicate. + * + * @param f Scala predicate to convert. + */ + implicit def toPredicate3[T1, T2, T3](f: (T1, T2, T3) => Boolean) = + f match { + case (p: ScalarPredicate3Function[T1, T2, T3]) => p.inner + case _ => new ScalarPredicate3[T1, T2, T3](f) + } + + /** + * Implicit converter from Scala predicate to Scala wrapping predicate. + * + * @param f Scala predicate to convert. + */ + def toPredicate32[T1, T2, T3](f: (T1, T2, T3) => Boolean) = + f match { + case (p: ScalarPredicate3XFunction[T1, T2, T3]) => p.inner + case _ => new ScalarPredicate3X[T1, T2, T3](f) + } + + /** + * Implicit converter from `GridPredicate3X` to Scala wrapping predicate. + * + * @param p Grid predicate to convert. + */ + implicit def fromPredicate3[T1, T2, T3](p: GridPredicate3[T1, T2, T3]): (T1, T2, T3) => Boolean = + new ScalarPredicate3Function[T1, T2, T3](p) + + /** + * Implicit converter from `GridPredicate3X` to Scala wrapping predicate. + * + * @param p Grid predicate to convert. + */ + implicit def fromPredicate3X[T1, T2, T3](p: GridPredicate3X[T1, T2, T3]): (T1, T2, T3) => Boolean = + new ScalarPredicate3XFunction[T1, T2, T3](p) + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param p Java-side predicate to pimp. + */ + implicit def predicate3DotScala[T1, T2, T3](p: GridPredicate3[T1, T2, T3]) = new { + def scala: (T1, T2, T3) => Boolean = + fromPredicate3(p) + } + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param p Java-side predicate to pimp. + */ + implicit def predicate3XDotScala[T1, T2, T3](p: GridPredicate3X[T1, T2, T3]) = new { + def scala: (T1, T2, T3) => Boolean = + fromPredicate3X(p) + } + + /** + * Implicit converter from Scala closure to `GridClosure`. + * + * @param f Scala closure to convert. + */ + implicit def toClosure[A, R](f: A => R): IgniteClosure[A, R] = + f match { + case (c: ScalarClosureFunction[A, R]) => c.inner + case _ => new ScalarClosure[A, R](f) + } + + /** + * Implicit converter from Scala closure to `GridClosureX`. + * + * @param f Scala closure to convert. + */ + def toClosureX[A, R](f: A => R): IgniteClosureX[A, R] = + f match { + case (c: ScalarClosureXFunction[A, R]) => c.inner + case _ => new ScalarClosureX[A, R](f) + } + + /** + * Implicit converter from `GridClosure` to Scala wrapping closure. + * + * @param f Grid closure to convert. + */ + implicit def fromClosure[A, R](f: IgniteClosure[A, R]): A => R = + new ScalarClosureFunction[A, R](f) + + /** + * Implicit converter from `GridClosureX` to Scala wrapping closure. + * + * @param f Grid closure to convert. + */ + implicit def fromClosureX[A, R](f: IgniteClosureX[A, R]): A => R = + new ScalarClosureXFunction[A, R](f) + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param f Java-side closure to pimp. + */ + implicit def closureDotScala[A, R](f: IgniteClosure[A, R]) = new { + def scala: A => R = + fromClosure(f) + } + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param f Java-side closure to pimp. + */ + implicit def closureXDotScala[A, R](f: IgniteClosureX[A, R]) = new { + def scala: A => R = + fromClosureX(f) + } + + /** + * Implicit converter from Scala closure to `GridClosure2`. + * + * @param f Scala closure to convert. + */ + implicit def toClosure2[A1, A2, R](f: (A1, A2) => R): IgniteBiClosure[A1, A2, R] = + f match { + case (p: ScalarClosure2Function[A1, A2, R]) => p.inner + case _ => new ScalarClosure2[A1, A2, R](f) + } + + /** + * Implicit converter from Scala closure to `GridClosure2X`. + * + * @param f Scala closure to convert. + */ + def toClosure2X[A1, A2, R](f: (A1, A2) => R): IgniteClosure2X[A1, A2, R] = + f match { + case (p: ScalarClosure2XFunction[A1, A2, R]) => p.inner + case _ => new ScalarClosure2X[A1, A2, R](f) + } + + /** + * Implicit converter from `GridClosure2X` to Scala wrapping closure. + * + * @param f Grid closure to convert. + */ + implicit def fromClosure2[A1, A2, R](f: IgniteBiClosure[A1, A2, R]): (A1, A2) => R = + new ScalarClosure2Function[A1, A2, R](f) + + /** + * Implicit converter from `GridClosure2X` to Scala wrapping closure. + * + * @param f Grid closure to convert. + */ + implicit def fromClosure2X[A1, A2, R](f: IgniteClosure2X[A1, A2, R]): (A1, A2) => R = + new ScalarClosure2XFunction[A1, A2, R](f) + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param f Java-side closure to pimp. + */ + implicit def closure2DotScala[A1, A2, R](f: IgniteBiClosure[A1, A2, R]) = new { + def scala: (A1, A2) => R = + fromClosure2(f) + } + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param f Java-side closure to pimp. + */ + implicit def closure2XDotScala[A1, A2, R](f: IgniteClosure2X[A1, A2, R]) = new { + def scala: (A1, A2) => R = + fromClosure2X(f) + } + + /** + * Implicit converter from Scala closure to `GridClosure3X`. + * + * @param f Scala closure to convert. + */ + implicit def toClosure3[A1, A2, A3, R](f: (A1, A2, A3) => R): GridClosure3[A1, A2, A3, R] = + f match { + case (p: ScalarClosure3Function[A1, A2, A3, R]) => p.inner + case _ => new ScalarClosure3[A1, A2, A3, R](f) + } + + /** + * Implicit converter from Scala closure to `GridClosure3X`. + * + * @param f Scala closure to convert. + */ + def toClosure3X[A1, A2, A3, R](f: (A1, A2, A3) => R): GridClosure3X[A1, A2, A3, R] = + f match { + case (p: ScalarClosure3XFunction[A1, A2, A3, R]) => p.inner + case _ => new ScalarClosure3X[A1, A2, A3, R](f) + } + + /** + * Implicit converter from `GridClosure3` to Scala wrapping closure. + * + * @param f Grid closure to convert. + */ + implicit def fromClosure3[A1, A2, A3, R](f: GridClosure3[A1, A2, A3, R]): (A1, A2, A3) => R = + new ScalarClosure3Function[A1, A2, A3, R](f) + + /** + * Implicit converter from `GridClosure3X` to Scala wrapping closure. + * + * @param f Grid closure to convert. + */ + implicit def fromClosure3X[A1, A2, A3, R](f: GridClosure3X[A1, A2, A3, R]): (A1, A2, A3) => R = + new ScalarClosure3XFunction[A1, A2, A3, R](f) + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param f Java-side closure to pimp. + */ + implicit def closure3DotScala[A1, A2, A3, R](f: GridClosure3[A1, A2, A3, R]) = new { + def scala: (A1, A2, A3) => R = + fromClosure3(f) + } + + /** + * Pimp for adding explicit conversion method `scala`. + * + * @param f Java-side closure to pimp. + */ + implicit def closure3XDotScala[A1, A2, A3, R](f: GridClosure3X[A1, A2, A3, R]) = new { + def scala: (A1, A2, A3) => R = + fromClosure3X(f) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/Packet.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/Packet.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/Packet.scala new file mode 100644 index 0000000..913cf76 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/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 side adapters for implicits conversion. + */ +package object lang \ 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/lang/ScalarAbsClosure.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsClosure.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsClosure.scala new file mode 100644 index 0000000..f7eb429 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsClosure.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.lang.IgniteRunnable +import org.apache.ignite.internal.util.lang.GridPeerDeployAwareAdapter + +/** + * Peer deploy aware adapter for Java's `GridRunnable`. + */ +class ScalarAbsClosure(private val f: () => Unit) extends GridPeerDeployAwareAdapter with IgniteRunnable { + assert(f != null) + + peerDeployLike(f) + + /** + * Delegates to passed in function. + */ + def run() { + f() + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsClosureFunction.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsClosureFunction.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsClosureFunction.scala new file mode 100644 index 0000000..10d8833 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsClosureFunction.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 + +/** + * Wrapping Scala function for `GridAbsClosure`. + */ +class ScalarAbsClosureFunction(val inner: Runnable) extends (() => Unit) { + assert(inner != null) + + /** + * Delegates to passed in grid closure. + */ + def apply() { + inner.run() + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsClosureX.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsClosureX.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsClosureX.scala new file mode 100644 index 0000000..fd4a97c --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsClosureX.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.GridAbsClosureX + +/** + * Peer deploy aware adapter for Java's `GridAbsClosureX`. + */ +class ScalarAbsClosureX(private val f: () => Unit) extends GridAbsClosureX { + assert(f != null) + + /** + * Delegates to passed in function. + */ + @throws(classOf[IgniteCheckedException]) + def applyx() { + f() + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsClosureXFunction.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsClosureXFunction.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsClosureXFunction.scala new file mode 100644 index 0000000..5940293 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsClosureXFunction.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.{GridAbsClosureX} + +/** + * Wrapping Scala function for `GridAbsClosureX`. + */ +class ScalarAbsClosureXFunction(val inner: GridAbsClosureX) extends (() => Unit) { + assert(inner != null) + + /** + * Delegates to passed in grid closure. + */ + def apply() { + inner.applyx() + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsPredicate.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsPredicate.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsPredicate.scala new file mode 100644 index 0000000..0937a97 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsPredicate.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.GridAbsPredicate + +/** + * Peer deploy aware adapter for Java's `GridAbsPredicate`. + */ +class ScalarAbsPredicate(private val f: () => Boolean) extends GridAbsPredicate { + assert(f != null) + + /** + * Delegates to passed in function. + */ + def apply(): Boolean = { + f() + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsPredicateFunction.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsPredicateFunction.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsPredicateFunction.scala new file mode 100644 index 0000000..f3c5750 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsPredicateFunction.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.{GridAbsPredicate} + +/** + * Wrapping Scala function for `GridAbsPredicate`. + */ +class ScalarAbsPredicateFunction(val inner: GridAbsPredicate) extends (() => Boolean) { + assert(inner != null) + + /** + * Delegates to passed in grid predicate. + */ + def apply(): Boolean = { + inner.apply + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsPredicateX.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsPredicateX.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsPredicateX.scala new file mode 100644 index 0000000..c690b6a --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsPredicateX.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.GridAbsPredicateX + +/** + * Peer deploy aware adapter for Java's `GridAbsPredicateX`. + */ +class ScalarAbsPredicateX(private val f: () => Boolean) extends GridAbsPredicateX { + assert(f != null) + + /** + * Delegates to passed in function. + */ + @throws(classOf[IgniteCheckedException]) + def applyx(): Boolean = { + f() + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsPredicateXFunction.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsPredicateXFunction.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsPredicateXFunction.scala new file mode 100644 index 0000000..1535125 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarAbsPredicateXFunction.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.GridAbsPredicateX + +/** + * Wrapping Scala function for `GridAbsPredicateX`. + */ +class ScalarAbsPredicateXFunction(val inner: GridAbsPredicateX) extends (() => Boolean) { + assert(inner != null) + + /** + * Delegates to passed in grid predicate. + */ + def apply(): Boolean = { + inner.applyx + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure.scala new file mode 100644 index 0000000..4c1918a --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure.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 + +/** + * Peer deploy aware adapter for Java's `GridClosure`. + */ +class ScalarClosure[E, R](private val f: E => R) extends IgniteClosure[E, R] { + assert(f != null) + + /** + * Delegates to passed in function. + */ + def apply(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/ScalarClosure2.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure2.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure2.scala new file mode 100644 index 0000000..56f17c7 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure2.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.IgniteBiClosure + +/** + * Peer deploy aware adapter for Java's `GridClosure2`. + */ +class ScalarClosure2[E1, E2, R](private val f: (E1, E2) => R) extends IgniteBiClosure[E1, E2, R] { + assert(f != null) + + /** + * Delegates to passed in function. + */ + def apply(e1: E1, e2: E2): R = { + f(e1, e2) + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6f9c9e6/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure2Function.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure2Function.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure2Function.scala new file mode 100644 index 0000000..39d44dd --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure2Function.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.IgniteBiClosure + +/** + * Wrapping Scala function for `GridClosure2`. + */ +class ScalarClosure2Function[T1, T2, R](val inner: IgniteBiClosure[T1, T2, R]) extends ((T1, T2) => R) { + assert(inner != null) + + /** + * Delegates to passed in grid closure. + */ + def apply(t1: T1, t2: T2): R = { + 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/ScalarClosure2X.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure2X.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure2X.scala new file mode 100644 index 0000000..6ce0b75 --- /dev/null +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/lang/ScalarClosure2X.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.IgniteClosure2X + +/** + * Peer deploy aware adapter for Java's `GridClosure2X`. + */ +class ScalarClosure2X[E1, E2, R](private val f: (E1, E2) => R) extends IgniteClosure2X[E1, E2, R] { + assert(f != null) + + /** + * Delegates to passed in function. + */ + @throws(classOf[IgniteCheckedException]) + def applyx(e1: E1, e2: E2): R = { + f(e1, e2) + } +}