any ranges OK
authorVictor Grishchenko <victor.grishchenko@gmail.com>
Fri, 21 May 2010 12:44:37 +0000 (14:44 +0200)
committerVictor Grishchenko <victor.grishchenko@gmail.com>
Fri, 21 May 2010 12:44:37 +0000 (14:44 +0200)
bins.cpp
bins.h
tests/binstest2.cpp

index 5f41017..6376bad 100644 (file)
--- a/bins.cpp
+++ b/bins.cpp
@@ -493,10 +493,11 @@ void    binmap_t::map16 (uint16_t* target, bin64_t range) {
 
 
 void    binmap_t::to_coarse_bitmap (uint16_t* bits, bin64_t range, uint8_t height) {
-    assert(range.layer()-height>=4);
+    //assert(range.layer()-height>=4);
     int height16 = range.layer()-height-4;
     int wordwidth = height16 > 0 ? (1 << height16) : 1;
-    int offset = range.offset() << height16;
+    int offset = height16 > 0 ? (range.offset() << height16) : 
+                                (range.offset() >> -height16); 
     for(int i=0; i<wordwidth; i++) 
         map16(bits+i,bin64_t(height+4,offset+i));
 }
diff --git a/bins.h b/bins.h
index 88c248c..df48c48 100644 (file)
--- a/bins.h
+++ b/bins.h
@@ -114,7 +114,7 @@ public:
     void        twist (uint64_t mask);
     
     /** Convert binmap to a conventional flat bitmap; only bits corresponding
-        to solid filled bins are set to 1. Won't work for ranges < 16 bit.
+        to solid filled bins are set to 1.
         @param range  the bin (the range) to cover
         @param height aggregation level; use 2**height bins (2**height base
                 layer bits per one bitmap bit). 
index b30b5c2..db5da55 100644 (file)
@@ -440,6 +440,14 @@ TEST(BinsTest,CoarseBitmap) {
     bin.to_coarse_bitmap(i16,bin64_t(7,0),3);
     EXPECT_EQ(1,i32);
     
+    i32 = 0;
+    bin.to_coarse_bitmap(i16,bin64_t(4,0),3);
+    EXPECT_EQ(1,i32);
+    
+    i32 = 0;
+    bin.to_coarse_bitmap(i16,bin64_t(2,0),1);
+    EXPECT_EQ(3,i32&3);
+    
 }
 
 /*TEST(BinsTest,AddSub) {