Ejemplo n.º 1
0
RC QL_ProjNode::GetNext(RM_Record &rec) {
    RM_Record record;
    if (prevNode.GetNext(record) == QL_EOF) {
        return QL_EOF;
    }
    int i;
    int base = 0;
    char *prevRecord = record.GetContent();
    //投影操作
    for(i = 0; i < nAttrInfos; i++) {
        memcpy(buffer + base, prevRecord + offsetInPrev[i], attrInfos[i].attrLength);
        base += attrInfos[i].attrLength;
    }
    RID rid(-1, -1);
    rec = RM_Record(buffer, rid, tupleLength);
    return 0;
}
Ejemplo n.º 2
0
RC QL_JoinNode::GetNext(RM_Record &rec) {
    RM_Record leftRec;
    RM_Record rightRec;

    while(true) {
        if (bRightNodeEOF) {
            if (lSubNode.GetNext(leftRec) == QL_EOF)
                return QL_EOF;
            memcpy(buffer, leftRec.GetContent(), leftRec.GetRecordSize());
            bRightNodeEOF = false;
        }
        if (rSubNode.GetNext(rightRec) == QL_EOF) {
            bRightNodeEOF = true;
            rSubNode.Reset();
            continue;
        }
        memcpy(buffer + lSubNode.GetTupleLength(), rightRec.GetContent(), rSubNode.GetTupleLength());
        RID rid(-1, -1);
        rec = RM_Record(buffer, rid, tupleLength);
        return 0;
    }
}
Ejemplo n.º 3
0
void SM_Manager::DropIndex(const char *relName, const char* AttrName)
{
  RM_FileScan attribute_scanner(attribute_fh, STRING, RELNAME_LENGTH, 0, EQ_OP, 
                                (void*)relName, strlen(relName));
  RC ret;
  RM_Record record;
  Byte *mem;
  RID rid;
  int mark=0;
  while( (ret=attribute_scanner.GetNextRec(record)) != NOT_FOUND ){
    record.GetRid(rid);
  //  attribute_fh.DeleteRec(rid);
    record.GetData(mem);
    if (GenString((char *)(mem+RELNAME_LENGTH),ATTRNAME_LENGTH)==GenString((char *)AttrName,strlen(AttrName))){
      mark=*(int*)(mem+RELNAME_LENGTH+ATTRNAME_LENGTH+12);
      if(mark&1) mark=mark-1;
      memcpy((mem+RELNAME_LENGTH+ATTRNAME_LENGTH+12), &mark , 4);
      RM_Record rec=RM_Record(mem, attribute_fh.GetRecordSize(), rid);
      attribute_fh.UpdateRec(rec);
    }
  }
  attribute_fh.ForcePages();
}