/* Copyright (c) 2012-2013 The Ohio State University. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include #include #include #include #include #include #include #include #include "../include/common.h" /* * @file rle.c * Compress a sorted foreign key column in LINEORDER table using Run Length encoding. * * Input: * @inputColumn: the column to be compressed using RLE. * @outputColumn: the name of the compressed column. */ int main(int argc, char ** argv){ if(argc != 3){ printf("./rleCompresssion inputColumn outputColumn\n"); exit(-1); } int inFd = open(argv[1],O_RDONLY); if(inFd == -1){ printf("Failed to open input file\n"); exit(-1); } int outFd = open(argv[2],O_RDWR|O_CREAT); if(outFd == -1){ printf("Failed to create output column\n"); exit(-1); } struct columnHeader header; read(inFd, &header, sizeof(struct columnHeader)); int blockTotal = header.blockTotal; long tupleOffset = 0; long offset = 0; for(int i=0;i