Merge branch 'column_store'
Co-authored-by: wangt1xiuyi <13547954130@163.com> Co-authored-by: yangqise7en <877793735@qq.com> Co-authored-by: Zach41 <zach_41@163.com>
This commit is contained in:
		
							
								
								
									
										84
									
								
								deps/oblib/unittest/lib/codec/test_fast_delta.cpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										84
									
								
								deps/oblib/unittest/lib/codec/test_fast_delta.cpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,84 @@ | ||||
| #include <vector> | ||||
| #include <memory> | ||||
| #include <limits> | ||||
| #include <random> | ||||
| #include <cmath> | ||||
|  | ||||
| #include "lib/codec/ob_fast_delta.h" | ||||
|  | ||||
| #include "gtest/gtest.h" | ||||
|  | ||||
| namespace oceanbase | ||||
| { | ||||
| namespace common | ||||
| { | ||||
|  | ||||
| int do_test() { | ||||
|     int N = 4096; | ||||
|     uint32_t * datain = (uint32_t *)malloc(N * sizeof(uint32_t)); | ||||
|     uint32_t * buffer = (uint32_t *)malloc(N * sizeof(uint32_t)); | ||||
|     uint32_t * recovdata = (uint32_t *)malloc(N * sizeof(uint32_t)); | ||||
|  | ||||
|  | ||||
|     for (int length = 0; length <= N;) { | ||||
|         printf("length = %d \n", length); | ||||
|         for (uint32_t gap = 1; gap <= 387420489; gap *= 3) { | ||||
|             for (int k = 0; k < length; ++k) | ||||
|                 datain[k] = gap * (k+1); | ||||
|             compute_deltas(datain, length, buffer, 0); | ||||
|             for (int k = 0; k < length; ++k) { | ||||
|                 if(buffer[k] != gap) { | ||||
|                     printf("bug. buffer[%d]=%d expected %d \n",k,buffer[k],gap); | ||||
|                     return -1; | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             compute_prefix_sum(buffer, length, recovdata, 0); | ||||
|             for(int k = 0; k < length; ++k) { | ||||
|                 if(datain[k] != recovdata[k]) { | ||||
|                     printf("bug.\n"); | ||||
|                     return -1; | ||||
|                 } | ||||
|             } | ||||
|             compute_deltas_inplace(datain, length, 0); | ||||
|             for (int k = 0; k < length; ++k) { | ||||
|                 if(datain[k] != gap) { | ||||
|                     printf("bug."); | ||||
|                     return -1; | ||||
|                 } | ||||
|             } | ||||
|             compute_prefix_sum_inplace(datain, length, 0); | ||||
|             for(int k = 0; k < length; ++k) { | ||||
|                 if(datain[k] != recovdata[k]) { | ||||
|                     printf("bug.\n"); | ||||
|                     return -1; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if (length < 128) | ||||
|             ++length; | ||||
|         else { | ||||
|             length *= 2; | ||||
|         } | ||||
|     } | ||||
|     free(datain); | ||||
|     free(buffer); | ||||
|     free(recovdata); | ||||
|     printf("Code looks good.\n"); | ||||
|     return 0; | ||||
| } | ||||
|  | ||||
| TEST(CompositeCodecTest, emptyArray) | ||||
| { | ||||
|   ASSERT_EQ(0, do_test()); | ||||
| } | ||||
|  | ||||
| } // namespace common | ||||
| } // namespace oceanbase | ||||
|  | ||||
| int main(int argc, char **argv) | ||||
| { | ||||
|   ::testing::InitGoogleTest(&argc,argv); | ||||
|   return RUN_ALL_TESTS(); | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 chaser-ch
					chaser-ch