Repository: flink Updated Branches: refs/heads/master 1b93b3242 -> d938c5f59
http://git-wip-us.apache.org/repos/asf/flink/blob/760a0d9e/flink-runtime/src/test/java/org/apache/flink/runtime/util/MathUtilTest.java ---------------------------------------------------------------------- diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/util/MathUtilTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/util/MathUtilTest.java deleted file mode 100644 index 6ffb64c..0000000 --- a/flink-runtime/src/test/java/org/apache/flink/runtime/util/MathUtilTest.java +++ /dev/null @@ -1,101 +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.apache.flink.runtime.util; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.fail; - -import org.junit.Test; - -public class MathUtilTest { - - @Test - public void testLog2Computation() { - assertEquals(0, MathUtils.log2floor(1)); - assertEquals(1, MathUtils.log2floor(2)); - assertEquals(1, MathUtils.log2floor(3)); - assertEquals(2, MathUtils.log2floor(4)); - assertEquals(2, MathUtils.log2floor(5)); - assertEquals(2, MathUtils.log2floor(7)); - assertEquals(3, MathUtils.log2floor(8)); - assertEquals(3, MathUtils.log2floor(9)); - assertEquals(4, MathUtils.log2floor(16)); - assertEquals(4, MathUtils.log2floor(17)); - assertEquals(13, MathUtils.log2floor((0x1 << 13) + 1)); - assertEquals(30, MathUtils.log2floor(Integer.MAX_VALUE)); - assertEquals(31, MathUtils.log2floor(-1)); - - try { - MathUtils.log2floor(0); - fail(); - } - catch (ArithmeticException aex) {} - } - - @Test - public void testRoundDownToPowerOf2() { - assertEquals(0, MathUtils.roundDownToPowerOf2(0)); - assertEquals(1, MathUtils.roundDownToPowerOf2(1)); - assertEquals(2, MathUtils.roundDownToPowerOf2(2)); - assertEquals(2, MathUtils.roundDownToPowerOf2(3)); - assertEquals(4, MathUtils.roundDownToPowerOf2(4)); - assertEquals(4, MathUtils.roundDownToPowerOf2(5)); - assertEquals(4, MathUtils.roundDownToPowerOf2(6)); - assertEquals(4, MathUtils.roundDownToPowerOf2(7)); - assertEquals(8, MathUtils.roundDownToPowerOf2(8)); - assertEquals(8, MathUtils.roundDownToPowerOf2(9)); - assertEquals(8, MathUtils.roundDownToPowerOf2(15)); - assertEquals(16, MathUtils.roundDownToPowerOf2(16)); - assertEquals(16, MathUtils.roundDownToPowerOf2(17)); - assertEquals(16, MathUtils.roundDownToPowerOf2(31)); - assertEquals(32, MathUtils.roundDownToPowerOf2(32)); - assertEquals(32, MathUtils.roundDownToPowerOf2(33)); - assertEquals(32, MathUtils.roundDownToPowerOf2(42)); - assertEquals(32, MathUtils.roundDownToPowerOf2(63)); - assertEquals(64, MathUtils.roundDownToPowerOf2(64)); - assertEquals(64, MathUtils.roundDownToPowerOf2(125)); - assertEquals(16384, MathUtils.roundDownToPowerOf2(25654)); - assertEquals(33554432, MathUtils.roundDownToPowerOf2(34366363)); - assertEquals(33554432, MathUtils.roundDownToPowerOf2(63463463)); - assertEquals(1073741824, MathUtils.roundDownToPowerOf2(1852987883)); - assertEquals(1073741824, MathUtils.roundDownToPowerOf2(Integer.MAX_VALUE)); - } - - @Test - public void testPowerOfTwo() { - assertTrue(MathUtils.isPowerOf2(1)); - assertTrue(MathUtils.isPowerOf2(2)); - assertTrue(MathUtils.isPowerOf2(4)); - assertTrue(MathUtils.isPowerOf2(8)); - assertTrue(MathUtils.isPowerOf2(32768)); - assertTrue(MathUtils.isPowerOf2(65536)); - assertTrue(MathUtils.isPowerOf2(1 << 30)); - assertTrue(MathUtils.isPowerOf2(1L + Integer.MAX_VALUE)); - assertTrue(MathUtils.isPowerOf2(1L << 41)); - assertTrue(MathUtils.isPowerOf2(1L << 62)); - - assertFalse(MathUtils.isPowerOf2(3)); - assertFalse(MathUtils.isPowerOf2(5)); - assertFalse(MathUtils.isPowerOf2(567923)); - assertFalse(MathUtils.isPowerOf2(Integer.MAX_VALUE)); - assertFalse(MathUtils.isPowerOf2(Long.MAX_VALUE)); - } -} http://git-wip-us.apache.org/repos/asf/flink/blob/760a0d9e/flink-runtime/src/test/java/org/apache/flink/runtime/util/UnionIteratorTest.java ---------------------------------------------------------------------- diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/util/UnionIteratorTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/util/UnionIteratorTest.java deleted file mode 100644 index 2a79b1f..0000000 --- a/flink-runtime/src/test/java/org/apache/flink/runtime/util/UnionIteratorTest.java +++ /dev/null @@ -1,142 +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.apache.flink.runtime.util; - -import org.apache.flink.util.TraversableOnceException; -import org.junit.Test; - -import java.util.Arrays; -import java.util.Collections; -import java.util.Iterator; -import java.util.NoSuchElementException; - -import static org.junit.Assert.*; - -public class UnionIteratorTest { - - @Test - public void testUnion() { - try { - UnionIterator<Integer> iter = new UnionIterator<>(); - - // should succeed and be empty - assertFalse(iter.iterator().hasNext()); - - iter.clear(); - - try { - iter.iterator().next(); - fail("should fail with an exception"); - } catch (NoSuchElementException e) { - // expected - } - - iter.clear(); - iter.addList(Arrays.asList(1, 2, 3, 4, 5, 6, 7)); - iter.addList(Collections.<Integer>emptyList()); - iter.addList(Arrays.asList(8, 9, 10, 11)); - - int val = 1; - for (int i : iter) { - assertEquals(val++, i); - } - } - catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test - public void testTraversableOnce() { - try { - UnionIterator<Integer> iter = new UnionIterator<>(); - - // should succeed - iter.iterator(); - - // should fail - try { - iter.iterator(); - fail("should fail with an exception"); - } catch (TraversableOnceException e) { - // expected - } - - // should fail again - try { - iter.iterator(); - fail("should fail with an exception"); - } catch (TraversableOnceException e) { - // expected - } - - // reset the thing, keep it empty - iter.clear(); - - // should succeed - iter.iterator(); - - // should fail - try { - iter.iterator(); - fail("should fail with an exception"); - } catch (TraversableOnceException e) { - // expected - } - - // should fail again - try { - iter.iterator(); - fail("should fail with an exception"); - } catch (TraversableOnceException e) { - // expected - } - - // reset the thing, add some data - iter.clear(); - iter.addList(Arrays.asList(1, 2, 3, 4, 5, 6, 7)); - - // should succeed - Iterator<Integer> ints = iter.iterator(); - assertNotNull(ints.next()); - assertNotNull(ints.next()); - assertNotNull(ints.next()); - - // should fail if called in the middle of operations - try { - iter.iterator(); - fail("should fail with an exception"); - } catch (TraversableOnceException e) { - // expected - } - - // reset the thing, keep it empty - iter.clear(); - - // should succeed again - assertFalse(iter.iterator().hasNext()); - - } - catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } -} http://git-wip-us.apache.org/repos/asf/flink/blob/760a0d9e/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/functions/source/SocketTextStreamFunction.java ---------------------------------------------------------------------- diff --git a/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/functions/source/SocketTextStreamFunction.java b/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/functions/source/SocketTextStreamFunction.java index 4211806..21e4394 100644 --- a/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/functions/source/SocketTextStreamFunction.java +++ b/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/functions/source/SocketTextStreamFunction.java @@ -18,7 +18,7 @@ package org.apache.flink.streaming.api.functions.source; import org.apache.flink.annotation.PublicEvolving; -import org.apache.flink.runtime.util.IOUtils; +import org.apache.flink.util.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/flink/blob/760a0d9e/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/operators/windowing/AbstractAlignedProcessingTimeWindowOperator.java ---------------------------------------------------------------------- diff --git a/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/operators/windowing/AbstractAlignedProcessingTimeWindowOperator.java b/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/operators/windowing/AbstractAlignedProcessingTimeWindowOperator.java index af341a6..0a8c6b5 100644 --- a/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/operators/windowing/AbstractAlignedProcessingTimeWindowOperator.java +++ b/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/operators/windowing/AbstractAlignedProcessingTimeWindowOperator.java @@ -26,7 +26,7 @@ import org.apache.flink.api.common.typeutils.TypeSerializer; import org.apache.flink.api.java.functions.KeySelector; import org.apache.flink.core.memory.DataInputView; import org.apache.flink.runtime.state.StateHandle; -import org.apache.flink.runtime.util.MathUtils; +import org.apache.flink.util.MathUtils; import org.apache.flink.streaming.api.operators.AbstractUdfStreamOperator; import org.apache.flink.streaming.api.operators.TimestampedCollector; import org.apache.flink.streaming.api.operators.OneInputStreamOperator; http://git-wip-us.apache.org/repos/asf/flink/blob/760a0d9e/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/operators/windowing/AccumulatingKeyedTimePanes.java ---------------------------------------------------------------------- diff --git a/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/operators/windowing/AccumulatingKeyedTimePanes.java b/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/operators/windowing/AccumulatingKeyedTimePanes.java index 9b353fe..79ef4c6 100644 --- a/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/operators/windowing/AccumulatingKeyedTimePanes.java +++ b/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/operators/windowing/AccumulatingKeyedTimePanes.java @@ -20,7 +20,7 @@ package org.apache.flink.streaming.runtime.operators.windowing; import org.apache.flink.annotation.Internal; import org.apache.flink.api.java.functions.KeySelector; -import org.apache.flink.runtime.util.UnionIterator; +import org.apache.flink.util.UnionIterator; import org.apache.flink.streaming.api.functions.windowing.WindowFunction; import org.apache.flink.streaming.api.operators.AbstractStreamOperator; import org.apache.flink.streaming.api.windowing.windows.TimeWindow; http://git-wip-us.apache.org/repos/asf/flink/blob/760a0d9e/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/operators/windowing/KeyMap.java ---------------------------------------------------------------------- diff --git a/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/operators/windowing/KeyMap.java b/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/operators/windowing/KeyMap.java index 67a2aac..52c321c 100644 --- a/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/operators/windowing/KeyMap.java +++ b/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/operators/windowing/KeyMap.java @@ -20,7 +20,7 @@ package org.apache.flink.streaming.runtime.operators.windowing; import org.apache.flink.annotation.Internal; import org.apache.flink.api.common.functions.ReduceFunction; -import org.apache.flink.runtime.util.MathUtils; +import org.apache.flink.util.MathUtils; import java.util.Arrays; import java.util.Comparator; http://git-wip-us.apache.org/repos/asf/flink/blob/760a0d9e/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/partitioner/HashPartitioner.java ---------------------------------------------------------------------- diff --git a/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/partitioner/HashPartitioner.java b/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/partitioner/HashPartitioner.java index 82f0141..3c93fb7 100644 --- a/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/partitioner/HashPartitioner.java +++ b/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/partitioner/HashPartitioner.java @@ -20,7 +20,7 @@ package org.apache.flink.streaming.runtime.partitioner; import org.apache.flink.annotation.Internal; import org.apache.flink.api.java.functions.KeySelector; import org.apache.flink.runtime.plugable.SerializationDelegate; -import org.apache.flink.runtime.util.MathUtils; +import org.apache.flink.util.MathUtils; import org.apache.flink.streaming.runtime.streamrecord.StreamRecord; /** http://git-wip-us.apache.org/repos/asf/flink/blob/760a0d9e/flink-streaming-java/src/test/java/org/apache/flink/streaming/api/IterateTest.java ---------------------------------------------------------------------- diff --git a/flink-streaming-java/src/test/java/org/apache/flink/streaming/api/IterateTest.java b/flink-streaming-java/src/test/java/org/apache/flink/streaming/api/IterateTest.java index 27a1e3c..c4343f6 100644 --- a/flink-streaming-java/src/test/java/org/apache/flink/streaming/api/IterateTest.java +++ b/flink-streaming-java/src/test/java/org/apache/flink/streaming/api/IterateTest.java @@ -29,7 +29,7 @@ import org.apache.flink.api.java.functions.KeySelector; import org.apache.flink.api.java.tuple.Tuple2; import org.apache.flink.runtime.jobgraph.JobGraph; import org.apache.flink.runtime.jobgraph.JobVertex; -import org.apache.flink.runtime.util.MathUtils; +import org.apache.flink.util.MathUtils; import org.apache.flink.streaming.api.datastream.DataStream; import org.apache.flink.streaming.api.datastream.DataStreamSink; import org.apache.flink.streaming.api.datastream.IterativeStream; http://git-wip-us.apache.org/repos/asf/flink/blob/760a0d9e/flink-streaming-java/src/test/java/org/apache/flink/streaming/api/StreamingOperatorsITCase.java ---------------------------------------------------------------------- diff --git a/flink-streaming-java/src/test/java/org/apache/flink/streaming/api/StreamingOperatorsITCase.java b/flink-streaming-java/src/test/java/org/apache/flink/streaming/api/StreamingOperatorsITCase.java index a77eddd..4f11993 100644 --- a/flink-streaming-java/src/test/java/org/apache/flink/streaming/api/StreamingOperatorsITCase.java +++ b/flink-streaming-java/src/test/java/org/apache/flink/streaming/api/StreamingOperatorsITCase.java @@ -23,7 +23,7 @@ import org.apache.flink.api.common.functions.MapFunction; import org.apache.flink.api.common.functions.RichMapFunction; import org.apache.flink.api.java.tuple.Tuple2; import org.apache.flink.core.fs.FileSystem; -import org.apache.flink.runtime.util.MathUtils; +import org.apache.flink.util.MathUtils; import org.apache.flink.streaming.api.collector.selector.OutputSelector; import org.apache.flink.streaming.api.datastream.DataStream; import org.apache.flink.streaming.api.datastream.SplitStream; http://git-wip-us.apache.org/repos/asf/flink/blob/760a0d9e/flink-streaming-scala/src/test/scala/org/apache/flink/streaming/api/scala/StreamingOperatorsITCase.scala ---------------------------------------------------------------------- diff --git a/flink-streaming-scala/src/test/scala/org/apache/flink/streaming/api/scala/StreamingOperatorsITCase.scala b/flink-streaming-scala/src/test/scala/org/apache/flink/streaming/api/scala/StreamingOperatorsITCase.scala index 0988e41..d353468 100644 --- a/flink-streaming-scala/src/test/scala/org/apache/flink/streaming/api/scala/StreamingOperatorsITCase.scala +++ b/flink-streaming-scala/src/test/scala/org/apache/flink/streaming/api/scala/StreamingOperatorsITCase.scala @@ -20,10 +20,10 @@ package org.apache.flink.streaming.api.scala import org.apache.flink.api.common.functions.{RichMapFunction, FoldFunction} import org.apache.flink.core.fs.FileSystem -import org.apache.flink.runtime.util.MathUtils import org.apache.flink.streaming.api.functions.source.SourceFunction import org.apache.flink.streaming.api.functions.source.SourceFunction.SourceContext import org.apache.flink.test.util.TestBaseUtils +import org.apache.flink.util.MathUtils import org.junit.rules.TemporaryFolder import org.junit.{After, Before, Rule, Test}