>From Michael Blow <[email protected]>:

Michael Blow has uploaded this change for review. ( 
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20479?usp=email )


Change subject: [NO ISSUE][*DB][COMMON] Reduce logging on dataset async flush 
batches
......................................................................

[NO ISSUE][*DB][COMMON] Reduce logging on dataset async flush batches

Change-Id: I1c2aaa1dbaadf00173e4e955c15c835e5b461ed7
---
M 
asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/DatasetLifecycleManager.java
A 
asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/MathUtil.java
A 
asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/ShortSortedBitSet.java
A 
asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/ShortUtil.java
A 
asterixdb/asterix-common/src/test/java/org/apache/asterix/test/utils/MathUtilTest.java
A 
asterixdb/asterix-common/src/test/java/org/apache/asterix/test/utils/ShortSortedBitSetTest.java
6 files changed, 580 insertions(+), 1 deletion(-)



  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb 
refs/changes/79/20479/1

diff --git 
a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/DatasetLifecycleManager.java
 
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/DatasetLifecycleManager.java
index 96f7241..7ed4a51 100644
--- 
a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/DatasetLifecycleManager.java
+++ 
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/DatasetLifecycleManager.java
@@ -47,6 +47,7 @@
 import org.apache.asterix.common.transactions.IRecoveryManager;
 import org.apache.asterix.common.transactions.LogRecord;
 import org.apache.asterix.common.transactions.LogType;
+import org.apache.asterix.common.utils.ShortSortedBitSet;
 import org.apache.asterix.common.utils.StoragePathUtil;
 import org.apache.hyracks.api.application.INCServiceContext;
 import org.apache.hyracks.api.exceptions.ErrorCode;
@@ -69,6 +70,8 @@
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;

+import it.unimi.dsi.fastutil.shorts.ShortSortedSet;
+
 public class DatasetLifecycleManager implements IDatasetLifecycleManager, 
ILifeCycleComponent {

     private static final Logger LOGGER = LogManager.getLogger();
@@ -500,12 +503,16 @@
     @Override
     public synchronized void asyncFlushMatchingIndexes(Predicate<ILSMIndex> 
indexPredicate)
             throws HyracksDataException {
+        ShortSortedSet partitions = new ShortSortedBitSet();
         for (DatasetResource dsr : datasets.values()) {
             for (PrimaryIndexOperationTracker opTracker : dsr.getOpTrackers()) 
{
                 synchronized (opTracker) {
                     asyncFlush(dsr, opTracker, indexPredicate);
+                    partitions.add((short) opTracker.partition);
                 }
             }
+            LOGGER.info("Async flushed dataset " + dsr.getDatasetID() + ", 
partitions " + partitions);
+            partitions.clear();
         }
     }

@@ -515,7 +522,6 @@
         for (ILSMIndex lsmIndex : 
dsr.getDatasetInfo().getDatasetPartitionOpenIndexes(partition)) {
             LSMIOOperationCallback ioCallback = (LSMIOOperationCallback) 
lsmIndex.getIOOperationCallback();
             if (needsFlush(opTracker, lsmIndex, ioCallback) && 
indexPredicate.test(lsmIndex)) {
-                LOGGER.info("Async flushing {}", opTracker);
                 opTracker.setFlushOnExit(true);
                 opTracker.flushIfNeeded();
                 break;
diff --git 
a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/MathUtil.java
 
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/MathUtil.java
new file mode 100644
index 0000000..c435427
--- /dev/null
+++ 
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/MathUtil.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.common.utils;
+
+import it.unimi.dsi.fastutil.longs.Long2ByteMap;
+import it.unimi.dsi.fastutil.longs.Long2ByteOpenHashMap;
+
+public class MathUtil {
+
+    private static final Long2ByteMap LOG2_MAP;
+
+    static {
+        LOG2_MAP = new Long2ByteOpenHashMap();
+        for (byte i = 0; i < Long.SIZE; i++) {
+            LOG2_MAP.put(1L << i, i);
+        }
+    }
+
+    private MathUtil() {
+    }
+
+    public static long maxUnsigned(long a, long b) {
+        return Long.compareUnsigned(a, b) > 0 ? a : b;
+    }
+
+    public static long minUnsigned(long a, long b) {
+        return Long.compareUnsigned(a, b) < 0 ? a : b;
+    }
+
+    public static long log2Unsigned(long value) {
+        final byte result = LOG2_MAP.getOrDefault(value, Byte.MIN_VALUE);
+        if (result < 0) {
+            throw new IllegalArgumentException("cannot resolve log2 value for 
" + Long.toUnsignedString(value, 16));
+        }
+        return result;
+    }
+}
diff --git 
a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/ShortSortedBitSet.java
 
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/ShortSortedBitSet.java
new file mode 100644
index 0000000..3b16ea9
--- /dev/null
+++ 
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/ShortSortedBitSet.java
@@ -0,0 +1,232 @@
+/*
+ * 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.asterix.common.utils;
+
+import java.util.Arrays;
+import java.util.NoSuchElementException;
+
+import it.unimi.dsi.fastutil.shorts.AbstractShortSortedSet;
+import it.unimi.dsi.fastutil.shorts.ShortBidirectionalIterator;
+import it.unimi.dsi.fastutil.shorts.ShortCollection;
+import it.unimi.dsi.fastutil.shorts.ShortComparator;
+import it.unimi.dsi.fastutil.shorts.ShortComparators;
+import it.unimi.dsi.fastutil.shorts.ShortSortedSet;
+
+public class ShortSortedBitSet extends AbstractShortSortedSet {
+
+    private static final short BITS_PER_ELEMENT = Long.SIZE;
+    private long[] storage;
+
+    public ShortSortedBitSet(int initialMaxValue) {
+        storage = new long[initialMaxValue / BITS_PER_ELEMENT + 1];
+    }
+
+    public ShortSortedBitSet() {
+        this(1);
+    }
+
+    public ShortSortedBitSet(ShortCollection initial) {
+        this();
+        addAll(initial);
+    }
+
+    public ShortSortedBitSet(short[] initial) {
+        this(Math.max(initial.length - 1, 1));
+        for (short value : initial) {
+            add(value);
+        }
+    }
+
+    @Override
+    public boolean contains(short k) {
+        checkRange(k);
+        int elementIndex = k / BITS_PER_ELEMENT;
+        int bitIndex = k % BITS_PER_ELEMENT;
+        return storage.length > elementIndex && (storage[elementIndex] & 1L << 
bitIndex) != 0;
+    }
+
+    private void checkRange(int k) {
+        if (k < 0) {
+            throw new IllegalArgumentException("negative values not 
supported");
+        }
+    }
+
+    @Override
+    public boolean add(short k) {
+        checkRange(k);
+        int elementIndex = k / BITS_PER_ELEMENT;
+        int bitIndex = k % BITS_PER_ELEMENT;
+        ensureCapacity(elementIndex);
+        boolean absent = (storage[elementIndex] & 1L << bitIndex) == 0;
+        storage[elementIndex] |= 1L << bitIndex;
+        return absent;
+    }
+
+    @Override
+    public boolean remove(short k) {
+        checkRange(k);
+        int elementIndex = k / BITS_PER_ELEMENT;
+        int bitIndex = k % BITS_PER_ELEMENT;
+        if (storage.length <= elementIndex) {
+            return false;
+        }
+        boolean present = (storage[elementIndex] & 1L << bitIndex) != 0;
+        storage[elementIndex] &= ~(1L << bitIndex);
+        return present;
+    }
+
+    @Override
+    public void clear() {
+        Arrays.fill(storage, 0L);
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (o.getClass() == getClass()) {
+            return Arrays.equals(storage, ((ShortSortedBitSet) o).storage);
+        }
+        return super.equals(o);
+    }
+
+    @Override
+    public int hashCode() {
+        return Arrays.hashCode(storage);
+    }
+
+    private void ensureCapacity(int index) {
+        if (storage.length <= index) {
+            long[] newStorage = new long[index + 1];
+            System.arraycopy(storage, 0, newStorage, 0, storage.length);
+            storage = newStorage;
+        }
+    }
+
+    @Override
+    public ShortSortedSet subSet(short fromElement, short toElement) {
+        throw new UnsupportedOperationException("nyi");
+    }
+
+    @Override
+    public ShortSortedSet headSet(short toElement) {
+        throw new UnsupportedOperationException("nyi");
+    }
+
+    @Override
+    public ShortSortedSet tailSet(short fromElement) {
+        throw new UnsupportedOperationException("nyi");
+    }
+
+    @Override
+    public ShortComparator comparator() {
+        return ShortComparators.NATURAL_COMPARATOR;
+    }
+
+    @Override
+    public short firstShort() {
+        for (int index = 0; index < storage.length; index++) {
+            if (storage[index] != 0) {
+                return (short) (index * BITS_PER_ELEMENT
+                        + (short) 
MathUtil.log2Unsigned(Long.lowestOneBit(storage[index])));
+            }
+        }
+        return -1;
+    }
+
+    @Override
+    public short lastShort() {
+        for (int index = storage.length - 1; index >= 0; index--) {
+            if (storage[index] != 0) {
+                return (short) (index * BITS_PER_ELEMENT
+                        + (short) 
MathUtil.log2Unsigned(Long.highestOneBit(storage[index])));
+            }
+        }
+        return -1;
+    }
+
+    @Override
+    public int size() {
+        int size = 0;
+        for (long element : storage) {
+            size += Long.bitCount(element);
+        }
+        return size;
+    }
+
+    @Override
+    public ShortBidirectionalIterator iterator() {
+        final short firstShort = firstShort();
+        return iterator(firstShort, firstShort);
+    }
+
+    @Override
+    public ShortBidirectionalIterator iterator(short fromElement) {
+        return iterator(firstShort(), fromElement);
+    }
+
+    @Override
+    public String toString() {
+        return ShortUtil.toCompactString(iterator());
+    }
+
+    private ShortBidirectionalIterator iterator(final short first, final short 
fromElement) {
+        return new ShortBidirectionalIterator() {
+            final short last = lastShort();
+            short position = fromElement;
+            short lastReturned = -1;
+
+            @Override
+            public short previousShort() {
+                for (; position >= first; position--) {
+                    if ((storage[position / BITS_PER_ELEMENT] & 1L << 
(position % BITS_PER_ELEMENT)) != 0) {
+                        lastReturned = position;
+                        return position--;
+                    }
+                }
+                throw new NoSuchElementException();
+            }
+
+            @Override
+            public boolean hasPrevious() {
+                return first >= 0 && position >= first;
+            }
+
+            @Override
+            public short nextShort() {
+                for (; position <= last; position++) {
+                    if ((storage[position / BITS_PER_ELEMENT] & 1L << 
(position % BITS_PER_ELEMENT)) != 0) {
+                        lastReturned = position;
+                        return position++;
+                    }
+                }
+                throw new NoSuchElementException();
+            }
+
+            @Override
+            public boolean hasNext() {
+                return last >= 0 && position <= last;
+            }
+
+            @Override
+            public void remove() {
+                ShortSortedBitSet.this.remove(lastReturned);
+            }
+        };
+    }
+
+}
diff --git 
a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/ShortUtil.java
 
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/ShortUtil.java
new file mode 100644
index 0000000..00bc139
--- /dev/null
+++ 
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/ShortUtil.java
@@ -0,0 +1,101 @@
+/*
+ * 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.asterix.common.utils;
+
+import java.util.NoSuchElementException;
+
+import it.unimi.dsi.fastutil.shorts.ShortIterator;
+
+public class ShortUtil {
+    private ShortUtil() {
+        throw new AssertionError("do not instantiate");
+    }
+
+    /**
+     * Returns a compact string representation of the supplied {@link 
ShortIterator}, enclosed
+     * by square-brackets ([]), comma-delimited, collapsing ranges together 
with a hyphen (-).
+     * Only provides reasonable results if the contents of the iterator are 
sorted.
+     */
+    public static String toCompactString(ShortIterator iter) {
+        if (!iter.hasNext()) {
+            return "[]";
+        }
+        StringBuilder builder = new StringBuilder();
+        builder.append('[');
+        appendCompact(iter, builder);
+        builder.append(']');
+        return builder.toString();
+    }
+
+    /**
+     * Returns a compact string representation of the supplied short array, 
enclosed
+     * by square-brackets ([]), comma-delimited, collapsing ranges together 
with a hyphen (-).
+     * Only provides reasonable results if the contents of the iterator are 
sorted.
+     */
+    public static String toCompactString(short[] iter) {
+        return toCompactString(wrap(iter));
+    }
+
+    /**
+     * Appends the contents of the supplied {@link ShortIterator} to the 
{@link StringBuilder} instance,
+     * comma-delimited, collapsing ranges together with a hyphen (-).  Only 
provides reasonable
+     * results if the contents of the iterator are sorted.
+     */
+    public static void appendCompact(ShortIterator iter, StringBuilder 
builder) {
+        short rangeStart = iter.nextShort();
+        builder.append(rangeStart);
+        short current = rangeStart;
+        short prev = current;
+        while (iter.hasNext()) {
+            current = iter.nextShort();
+            if (current != prev + 1) {
+                // end any range we were in:
+                if (rangeStart != prev) {
+                    builder.append('-').append(prev);
+                }
+                builder.append(",").append(current);
+                rangeStart = current;
+            }
+            prev = current;
+        }
+        if (rangeStart != prev) {
+            builder.append('-').append(prev);
+        }
+    }
+
+    public static ShortIterator wrap(short... vbuckets) {
+        return new ShortIterator() {
+            int index = 0;
+
+            @Override
+            public short nextShort() {
+                try {
+                    return vbuckets[index++];
+                } catch (ArrayIndexOutOfBoundsException e) {
+                    throw new NoSuchElementException();
+                }
+            }
+
+            @Override
+            public boolean hasNext() {
+                return index < vbuckets.length;
+            }
+        };
+    }
+}
diff --git 
a/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/utils/MathUtilTest.java
 
b/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/utils/MathUtilTest.java
new file mode 100644
index 0000000..70c77b7
--- /dev/null
+++ 
b/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/utils/MathUtilTest.java
@@ -0,0 +1,79 @@
+/*
+ * 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.asterix.test.utils;
+
+import org.apache.asterix.common.utils.MathUtil;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class MathUtilTest {
+    private static final Logger LOGGER = LogManager.getLogger();
+    private static final int BENCHMARK_ITERATIONS = 5000000;
+    private final double LOG_2 = Math.log(2);
+
+    @Test
+    public void test() {
+        for (int i = 0; i < Long.SIZE; i++) {
+            long value = 1L << i;
+            Assert.assertEquals(Long.toUnsignedString(value, 16),
+                    value == Long.MIN_VALUE ? Long.SIZE - 1 : (long) 
(Math.log(value) / LOG_2),
+                    MathUtil.log2Unsigned(value));
+        }
+    }
+
+    @Test
+    public void benchmarkLookupTable() {
+        lookupTableRun();
+        lookupTableRun();
+    }
+
+    @Test
+    public void benchmarkMathLog() {
+        mathLogRun();
+        mathLogRun();
+    }
+
+    private void lookupTableRun() {
+        long start = System.nanoTime();
+        for (int j = 0; j < BENCHMARK_ITERATIONS; j++) {
+            for (int i = 0; i < Long.SIZE; i++) {
+                final long value = 1L << i;
+                MathUtil.log2Unsigned(value);
+            }
+        }
+        LOGGER.info("total time for {} iterations of lookup table: {}ns", 
BENCHMARK_ITERATIONS * Long.SIZE,
+                System.nanoTime() - start);
+    }
+
+    private void mathLogRun() {
+        long ignored = 0;
+        long start = System.nanoTime();
+        for (int j = 0; j < BENCHMARK_ITERATIONS; j++) {
+            for (int i = 0; i < Long.SIZE; i++) {
+                final long value = 1L << i;
+                ignored += (long) (Math.log(value) / LOG_2);
+            }
+        }
+        LOGGER.info("total time for {} iterations of Math.log(n) / 
Math.log(2): {}ns", BENCHMARK_ITERATIONS * Long.SIZE,
+                System.nanoTime() - start);
+    }
+}
diff --git 
a/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/utils/ShortSortedBitSetTest.java
 
b/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/utils/ShortSortedBitSetTest.java
new file mode 100644
index 0000000..561e647
--- /dev/null
+++ 
b/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/utils/ShortSortedBitSetTest.java
@@ -0,0 +1,108 @@
+/*
+ * 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.asterix.test.utils;
+
+import java.util.Random;
+
+import org.apache.asterix.common.utils.ShortSortedBitSet;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.Assert;
+import org.junit.Test;
+
+import it.unimi.dsi.fastutil.shorts.ShortIterator;
+import it.unimi.dsi.fastutil.shorts.ShortSortedSet;
+
+public class ShortSortedBitSetTest {
+    private static final Logger LOGGER = LogManager.getLogger();
+
+    @Test
+    public void test() {
+        Random r = new Random();
+        ShortSortedSet set = new ShortSortedBitSet();
+        short uniques = 0;
+        for (short i = 0; i < 500; i++) {
+            uniques += set.add((short) r.nextInt(1000)) ? 1 : 0;
+        }
+        LOGGER.info("set {}", set);
+        LOGGER.info("set contains {} unique elements", uniques);
+        Assert.assertEquals("set size() != number of uniques", uniques, 
set.size());
+        for (short values : set) {
+            uniques--;
+        }
+        Assert.assertEquals("iteration count != number of uniques", 0, 
uniques);
+        int size = set.size();
+        short removed = 0;
+        for (ShortIterator iter = set.iterator(); iter.hasNext();) {
+            iter.nextShort();
+            iter.remove();
+            removed++;
+        }
+        Assert.assertEquals("removed count != before size", size, removed);
+        Assert.assertEquals("new size != 0", 0, set.size());
+        for (ShortIterator iter = set.iterator(); iter.hasNext();) {
+            Assert.fail("got iteration on empty set: " + iter.nextShort());
+        }
+        for (short value : set) {
+            Assert.fail("got iteration on empty set: " + value);
+        }
+    }
+
+    @Test
+    public void testSingletonSets() {
+        for (short i = 0; i <= 16384; i++) {
+            testSingletonSet(i);
+        }
+    }
+
+    private void testSingletonSet(short key) {
+        LOGGER.log(key % 1024 == 0 ? Level.INFO : Level.DEBUG, "testing {}", 
key);
+        ShortSortedSet set = new ShortSortedBitSet();
+        set.add(key);
+        final int size = set.size();
+        LOGGER.debug("singleton set {} contains {} unique elements", set, 
size);
+        Assert.assertEquals("singleton size != 1", 1, size);
+        for (short values : set) {
+            LOGGER.debug("got value: {}", values);
+        }
+        int removed = 0;
+        for (ShortIterator iter = set.iterator(); iter.hasNext();) {
+            iter.nextShort();
+            iter.remove();
+            removed++;
+        }
+        Assert.assertEquals("removed count != before size", size, removed);
+        Assert.assertEquals("new size != 0", 0, set.size());
+    }
+
+    @Test
+    public void emptySetTest() {
+        ShortSortedSet set = new ShortSortedBitSet();
+        LOGGER.info("set {}", set);
+        LOGGER.info("set contains {} unique elements", set.size());
+        for (ShortIterator iter = set.iterator(); iter.hasNext();) {
+            Assert.fail("got iteration on empty set: " + iter.nextShort());
+        }
+        for (short value : set) {
+            Assert.fail("got iteration on empty set: " + value);
+        }
+    }
+}

--
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20479?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://asterix-gerrit.ics.uci.edu/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: asterixdb
Gerrit-Branch: phoenix
Gerrit-Change-Id: I1c2aaa1dbaadf00173e4e955c15c835e5b461ed7
Gerrit-Change-Number: 20479
Gerrit-PatchSet: 1
Gerrit-Owner: Michael Blow <[email protected]>

Reply via email to