コード例 #1
0
 /** put(null,x) throws NPE */
 public void testPut1_NullPointerException() {
   try {
     ConcurrentNavigableMap c = map5();
     c.put(null, "whatever");
     shouldThrow();
   } catch (NullPointerException success) {
   }
 }
コード例 #2
0
 private static int estimateRowOverhead(final int count) {
   // calculate row overhead
   try (final OpOrder.Group group = new OpOrder().start()) {
     int rowOverhead;
     MemtableAllocator allocator = MEMORY_POOL.newAllocator();
     ConcurrentNavigableMap<PartitionPosition, Object> partitions = new ConcurrentSkipListMap<>();
     final Object val = new Object();
     for (int i = 0; i < count; i++)
       partitions.put(
           allocator.clone(
               new BufferDecoratedKey(new LongToken(i), ByteBufferUtil.EMPTY_BYTE_BUFFER), group),
           val);
     double avgSize = ObjectSizes.measureDeep(partitions) / (double) count;
     rowOverhead =
         (int) ((avgSize - Math.floor(avgSize)) < 0.05 ? Math.floor(avgSize) : Math.ceil(avgSize));
     rowOverhead -= ObjectSizes.measureDeep(new LongToken(0));
     rowOverhead += AtomicBTreePartition.EMPTY_SIZE;
     allocator.setDiscarding();
     allocator.setDiscarded();
     return rowOverhead;
   }
 }
コード例 #3
0
 /** pollLastEntry returns entries in order */
 public void testDescendingPollLastEntry() {
   ConcurrentNavigableMap map = dmap5();
   Map.Entry e = map.pollLastEntry();
   assertEquals(m5, e.getKey());
   assertEquals("E", e.getValue());
   e = map.pollLastEntry();
   assertEquals(m4, e.getKey());
   map.put(m5, "E");
   e = map.pollLastEntry();
   assertEquals(m5, e.getKey());
   assertEquals("E", e.getValue());
   e = map.pollLastEntry();
   assertEquals(m3, e.getKey());
   map.remove(m2);
   e = map.pollLastEntry();
   assertEquals(m1, e.getKey());
   try {
     e.setValue("E");
     shouldThrow();
   } catch (UnsupportedOperationException success) {
   }
   e = map.pollLastEntry();
   assertNull(e);
 }
コード例 #4
0
 /** pollLastEntry returns entries in order */
 public void testPollLastEntry() {
   ConcurrentNavigableMap map = map5();
   Map.Entry e = map.pollLastEntry();
   assertEquals(five, e.getKey());
   assertEquals("E", e.getValue());
   e = map.pollLastEntry();
   assertEquals(four, e.getKey());
   map.put(five, "E");
   e = map.pollLastEntry();
   assertEquals(five, e.getKey());
   assertEquals("E", e.getValue());
   e = map.pollLastEntry();
   assertEquals(three, e.getKey());
   map.remove(two);
   e = map.pollLastEntry();
   assertEquals(one, e.getKey());
   try {
     e.setValue("E");
     shouldThrow();
   } catch (UnsupportedOperationException success) {
   }
   e = map.pollLastEntry();
   assertNull(e);
 }