Ai
1 Star 0 Fork 0

收拾旧河山/ extmem-c-database-query-processing

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
test.c 1.67 KB
一键复制 编辑 原始数据 按行查看 历史
收拾旧河山 提交于 2022-12-26 20:38 +08:00 . done
#include <stdlib.h>
#include <stdio.h>
#include "extmem.h"
int main1(int argc, char **argv)
{
Buffer buf; /* A buffer */
unsigned char *blk; /* A pointer to a block */
int i = 0;
/* Initialize the buffer */
if (!initBuffer(520, 64, &buf))
{
perror("Buffer Initialization Failed!\n");
return -1;
}
/* Get a new block in the buffer */
blk = getNewBlockInBuffer(&buf);
/* Fill data into the block */
for (i = 0; i < 8; i++)
*(blk + i) = 'a' + i;
/* Write the block to the hard disk */
if (writeBlockToDisk(blk, 8888, &buf) != 0)
{
perror("Writing Block Failed!\n");
return -1;
}
/* Read the block from the hard disk */
if ((blk = readBlockFromDisk(1, &buf)) == NULL)
{
perror("Reading Block Failed!\n");
return -1;
}
/* Process the data in the block */
int X = -1;
int Y = -1;
int addr = -1;
char str[5];
printf("block 1:\n");
for (i = 0; i < 7; i++) //一个blk存7个元组加一个地址
{
for (int k = 0; k < 4; k++)
{
str[k] = *(blk + i*8 + k);
}
X = atoi(str); ;
for (int k = 0; k < 4; k++)
{
str[k] = *(blk + i*8 + 4 + k);
}
Y = atoi(str);
printf("(%d, %d) ", X, Y);
}
for (int k = 0; k < 4; k++)
{
str[k] = *(blk + i*8 + k);
}
addr = atoi(str);
printf("\nnext address = %d \n", addr);
printf("\n");
printf("IO's is %ld\n", buf.numIO); /* Check the number of IO's */
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Hmount/extmem-c-database-query-processing.git
git@gitee.com:Hmount/extmem-c-database-query-processing.git
Hmount
extmem-c-database-query-processing
extmem-c-database-query-processing
master

搜索帮助