1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-01 06:46:55 +03:00

clang format apply

This commit is contained in:
Leonid Fedorov
2022-01-21 16:43:49 +00:00
parent 6b6411229f
commit 04752ec546
1376 changed files with 393460 additions and 412662 deletions

View File

@ -38,75 +38,72 @@ using namespace std;
void usage(char* name)
{
cerr << "Usage: " << name << " dict_block_filename" << endl;
exit(0);
cerr << "Usage: " << name << " dict_block_filename" << endl;
exit(0);
}
void parseDictBlock(char* block)
{
uint16_t* offsets;
uint16_t* freeBytes;
u_int64_t* contPtr;
int offsetIndex, size;
char sig[BLOCK_SIZE + 1];
uint16_t* offsets;
uint16_t* freeBytes;
u_int64_t* contPtr;
int offsetIndex, size;
char sig[BLOCK_SIZE + 1];
freeBytes = reinterpret_cast<uint16_t*>(&block[0]);
contPtr = reinterpret_cast<u_int64_t*>(&block[2]);
offsets = reinterpret_cast<uint16_t*>(&block[10]);
freeBytes = reinterpret_cast<uint16_t*>(&block[0]);
contPtr = reinterpret_cast<u_int64_t*>(&block[2]);
offsets = reinterpret_cast<uint16_t*>(&block[10]);
cout << "Free Bytes: " << *freeBytes << endl;
cout << "Continuation Pointer: 0x" << hex << *contPtr << dec << endl;
cout << "Free Bytes: " << *freeBytes << endl;
cout << "Continuation Pointer: 0x" << hex << *contPtr << dec << endl;
for (offsetIndex = 0; offsets[offsetIndex + 1] != 0xffff; offsetIndex++)
{
size = offsets[offsetIndex] - offsets[offsetIndex + 1];
memcpy(sig, &block[offsets[offsetIndex + 1]], size);
sig[size] = '\0';
cout << "Offset #" << offsetIndex + 1 << ": size=" << size << " offset=" << offsets[offsetIndex + 1]
<< endl;
for (offsetIndex = 0; offsets[offsetIndex + 1] != 0xffff; offsetIndex++)
{
size = offsets[offsetIndex] - offsets[offsetIndex + 1];
memcpy(sig, &block[offsets[offsetIndex + 1]], size);
sig[size] = '\0';
cout << "Offset #" << offsetIndex + 1 << ": size=" << size << " offset="
<< offsets[offsetIndex + 1] << endl;
// Use these lines instead for non-ascii data.
// cout << " Signature: 0x";
// for (i = 0; i < size; i++)
// cout << hex << (((int) sig[i]) & 0xff);
cout << " Signature: " << sig;
cout << dec << endl;
}
// Use these lines instead for non-ascii data.
// cout << " Signature: 0x";
// for (i = 0; i < size; i++)
// cout << hex << (((int) sig[i]) & 0xff);
cout << " Signature: " << sig;
cout << dec << endl;
}
}
int main(int argc, char** argv)
{
int fd, err;
char buf[BLOCK_SIZE];
int fd, err;
char buf[BLOCK_SIZE];
if (argc != 2)
usage(argv[0]);
if (argc != 2)
usage(argv[0]);
fd = open(argv[1], O_RDONLY);
fd = open(argv[1], O_RDONLY);
if (fd < 0)
{
perror("open");
exit(1);
}
if (fd < 0)
{
perror("open");
exit(1);
}
err = read(fd, buf, BLOCK_SIZE);
err = read(fd, buf, BLOCK_SIZE);
if (err < 0)
{
perror("read");
exit(1);
}
if (err < 0)
{
perror("read");
exit(1);
}
if (err != BLOCK_SIZE)
{
cerr << "Failed to read the file in one op, check the filelength and try again."
<< endl;
exit(1);
}
if (err != BLOCK_SIZE)
{
cerr << "Failed to read the file in one op, check the filelength and try again." << endl;
exit(1);
}
parseDictBlock(buf);
exit(0);
parseDictBlock(buf);
exit(0);
}