// File: /workspace/github_c_makefile_star2_O0/CkTD[P]btree/table_test2.c
// Function: main
int main()
{
    TableOpenFlag   flag;
    Table          *table;
    TableRows      *rows;
    TableRow       *row;
    uint64_t        i,j,n,count;
    

    flag.dir = "test_table";
    flag.create_if_missing = 1;
    flag.error_if_exist = 0;

    table = table_open(flag);
    
    printf("在第0列上建立索引...");
    if( table_create_index(table, 0) == 0)
    {
        printf("create index on column 0 successfully\n");
    }
    else
    {
        printf("index on column 0 already exist!\n");
    }


    printf("插入 1000000 行随机数据，每一行所有属性相同...\n");
    for(i = 0; i < 1000000; i++)
    {
        row = table_row_new();
        n = rand() % 1000000;
        for(j=0;j<100;j++)
            table_row_set_property(row, j, n );
        table_append(table, row);
        if (n<=1010 && n >=1000)
            printf("\t插入一个属性都为 %ld 的行\n", n);
    }

    printf("查找 第0个属性的范围在 1000 到 10010 的行，limit = 100.\n");
    rows = table_search_range(table, 0, 1000, 1010, 100);
    count = table_rows_get_counts(rows);
    for(i = 0; i < count; i++)
    {
        row = table_rows_get_row(rows, i);
        printf("\tROW %lu, first 10 properties: ", i);
        for(j = 0; j < 10; j++)
        {
            printf("%lu ", table_row_get_property(row, j));
        }
        printf("\n");
    }
    table_rows_destory(rows);

    printf("关闭表(刷磁盘)....\n");
    table_close(table);
    printf("done\n");
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl $0x0, -0x4(%rbp)
leaq 0x1a7c(%rip), %rax      # 0x6c92
movq %rax, -0x18(%rbp)
movl $0x1, -0x10(%rbp)
movl $0x0, -0xc(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x4600
movq %rax, -0x20(%rbp)
leaq 0x1a5d(%rip), %rdi      # 0x6c9d
movb $0x0, %al
callq 0x1080
movq -0x20(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4450
cmpl $0x0, %eax
jne 0x5269
leaq 0x1a5a(%rip), %rdi      # 0x6cba
movb $0x0, %al
callq 0x1080
jmp 0x5277
leaq 0x1a71(%rip), %rdi      # 0x6ce1
movb $0x0, %al
callq 0x1080
leaq 0x1a85(%rip), %rdi      # 0x6d03
movb $0x0, %al
callq 0x1080
movq $0x0, -0x38(%rbp)
cmpq $0xf4240, -0x38(%rbp)   # imm = 0xF4240
jae 0x532e
movb $0x0, %al
callq 0x3df0
movq %rax, -0x30(%rbp)
callq 0x1180
movl $0xf4240, %ecx          # imm = 0xF4240
cltd
idivl %ecx
movslq %edx, %rax
movq %rax, -0x48(%rbp)
movq $0x0, -0x40(%rbp)
cmpq $0x64, -0x40(%rbp)
jae 0x52e8
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0x3e30
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x52c2
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x4340
cmpq $0x3f2, -0x48(%rbp)     # imm = 0x3F2
ja 0x531b
cmpq $0x3e8, -0x48(%rbp)     # imm = 0x3E8
jb 0x531b
movq -0x48(%rbp), %rsi
leaq 0x1a30(%rip), %rdi      # 0x6d44
movb $0x0, %al
callq 0x1080
jmp 0x531d
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x528d
leaq 0x1a35(%rip), %rdi      # 0x6d6a
movb $0x0, %al
callq 0x1080
movq -0x20(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x3e8, %edx            # imm = 0x3E8
movl $0x3f2, %ecx            # imm = 0x3F2
movl $0x64, %r8d
callq 0x3fe0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x3e60
movq %rax, -0x50(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x50(%rbp), %rax
jae 0x53f9
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x3e80
movq %rax, -0x30(%rbp)
movq -0x38(%rbp), %rsi
leaq 0x1a19(%rip), %rdi      # 0x6db1
movb $0x0, %al
callq 0x1080
movq $0x0, -0x40(%rbp)
cmpq $0xa, -0x40(%rbp)
jae 0x53da
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x3e10
movq %rax, %rsi
leaq 0xf0e(%rip), %rdi       # 0x62d3
movb $0x0, %al
callq 0x1080
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x53a7
leaq 0x1920(%rip), %rdi      # 0x6d01
movb $0x0, %al
callq 0x1080
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x5372
movq -0x28(%rbp), %rdi
callq 0x3ee0
leaq 0x19c8(%rip), %rdi      # 0x6dd1
movb $0x0, %al
callq 0x1080
movq -0x20(%rbp), %rdi
callq 0x4ae0
leaq 0x19cb(%rip), %rdi      # 0x6deb
movb $0x0, %al
callq 0x1080
xorl %eax, %eax
addq $0x50, %rsp
popq %rbp
retq