Ticket #2170: 0001-ticket-2170-fixed-wrong-behaviour-of-complex-numbers.patch

File 0001-ticket-2170-fixed-wrong-behaviour-of-complex-numbers.patch, 7.1 KB (added by apercov, 5 years ago)

Patch fixing some of the mentioned problems. (See the comments for the list of fixed queries)

  • bin/errtxts

    From fd502092e75afdb34ef48290549dade399539dfc Mon Sep 17 00:00:00 2001
    From: Arsenij Percov <a.percov@jacobs-university.de>
    Date: Wed, 25 Sep 2019 17:31:26 +0200
    Subject: [PATCH] ticket:2170 - fixed wrong behaviour of complex numbers
    
    Summary: Added support for complex numbers using unsigned shorts or longs. Fixed error messages for non-compatible imaginary and real parts provided in query.
    
    Test Plan: Queries from ticket.
    
    Reviewers: dmisev
    
    Differential Revision: http://codereview.rasdaman.org/D955
    ---
     bin/errtxts              |  2 +-
     qlparser/oql.yy          | 16 +++++++++--
     qlparser/qtatomicdata.cc | 59 ++++++++++++++++++++++++++++++++++++++++
     qlparser/qtatomicdata.hh |  3 ++
     raslib/test/errtxts      |  2 +-
     5 files changed, 78 insertions(+), 4 deletions(-)
    
    diff --git a/bin/errtxts b/bin/errtxts
    index 6528c654c..30333e469 100644
    a b  
    7272308^E^Parsing error: Unexpected end of query.
    7373309^E^Parsing error: Unknown error.
    7474310^E^Lexical analysing error $errorNo in line $lineNo, column $columnNo: Unexpected characters $token.
    75 311^E^Parsing error $errorNo in line $lineNo, column $columnNo, token $token: Complex constructor must have both arguments of the same type (i.e. float or double).
     75311^E^Parsing error $errorNo in line $lineNo, column $columnNo, token $token: Complex constructor must have both arguments of the same type.
    7676312^E^Parsing error $errorNo in line $lineNo, column $columnNo, token $token: Variable already defined.
    7777313^E^Parsing error $errorNo in line $lineNo, column $columnNo, token $token: Only constant interval bounds allowed.
    7878314^E^Parsing error $errorNo in line $lineNo, column $columnNo, token $token: Too few arguments in function call.
  • qlparser/oql.yy

    diff --git a/qlparser/oql.yy b/qlparser/oql.yy
    index 2f40f602f..9902fc953 100644
    a b inductionExp: SQRT LRPAR generalExp RRPAR  
    34473447        }
    34483448    | COMPLEX LRPAR generalExp COMMA generalExp RRPAR
    34493449    {
     3450       
    34503451        $$ = new QtConstructComplex($3, $5);
    34513452        $$->setParseInfo(*($1.info));
    34523453        parseQueryTree->removeDynamicObject($3);
    atomicLit: BooleanLit  
    38463847  | COMPLEX LRPAR intLitExp COMMA intLitExp RRPAR
    38473848        {
    38483849          // this should construct a complex type
    3849           // for both float and double cell type
     3850          // for both long and short cell type
    38503851          if($3.bytes+$5.bytes== 2u * sizeof(int) || $3.bytes + $5.bytes == 2u * sizeof(short) || $3.bytes + $5.bytes == 2u * sizeof(long)) {
    3851             $$ = new QtAtomicData($3.svalue, $5.svalue, $3.bytes + $5.bytes);
     3852            if ($3.negative && !$5.negative){
     3853        $$ = new QtAtomicData($3.svalue, $5.uvalue, $3.bytes + $5.bytes);
     3854      }
     3855      else if ($3.negative && $5.negative){
     3856        $$ = new QtAtomicData($3.svalue, $5.svalue, $3.bytes + $5.bytes);
     3857      }
     3858      else if (!$3.negative && $5.negative){
     3859        $$ = new QtAtomicData($3.uvalue, $5.svalue, $3.bytes + $5.bytes);
     3860      }
     3861      else if (!$3.negative && !$5.negative){
     3862        $$ = new QtAtomicData($3.uvalue, $5.uvalue, $3.bytes + $5.bytes);
     3863      }
    38523864          } else {
    38533865            if(parseError) delete parseError;
    38543866            parseError = new ParseInfo(311, $2.info->getToken().c_str(),
  • qlparser/qtatomicdata.cc

    diff --git a/qlparser/qtatomicdata.cc b/qlparser/qtatomicdata.cc
    index 681caa2f2..9f170cc67 100755
    a b QtAtomicData::QtAtomicData(r_Long valRe, r_Long valIm, unsigned short size)  
    248248    valueType->makeFromCLong(valueBuffer + (static_cast<GenericComplexType *>(const_cast<BaseType *>(valueType)))->getImOffset(), &dummyIm);
    249249}
    250250
     251
     252QtAtomicData::QtAtomicData(r_ULong valRe, r_ULong valIm, unsigned short size)
     253    : QtScalarData()
     254{
     255    r_ULong dummyRe = valRe;
     256    r_ULong dummyIm = valIm;
     257
     258    if (size == 2 * sizeof(r_ULong))
     259    {
     260        valueType = TypeFactory::mapType("CInt32");
     261    }
     262    else
     263    {
     264        valueType = TypeFactory::mapType("CInt16");
     265    }
     266
     267    valueBuffer = new char[valueType->getSize()];
     268    valueType->makeFromCULong(valueBuffer + (static_cast<GenericComplexType *>(const_cast<BaseType *>(valueType)))->getReOffset(), &dummyRe);
     269    valueType->makeFromCULong(valueBuffer + (static_cast<GenericComplexType *>(const_cast<BaseType *>(valueType)))->getImOffset(), &dummyIm);
     270}
     271
     272QtAtomicData::QtAtomicData(r_Long valRe, r_ULong valIm, unsigned short size)
     273    : QtScalarData()
     274{
     275    r_Long dummyRe = valRe;
     276    r_ULong dummyIm = valIm;
     277    if (size == 2 * sizeof(r_ULong))
     278    {
     279        valueType = TypeFactory::mapType("CInt32");
     280    }
     281    else
     282    {
     283        valueType = TypeFactory::mapType("CInt16");
     284    }
     285
     286    valueBuffer = new char[valueType->getSize()];
     287    valueType->makeFromCLong(valueBuffer + (static_cast<GenericComplexType *>(const_cast<BaseType *>(valueType)))->getReOffset(), &dummyRe);
     288    valueType->makeFromCULong(valueBuffer + (static_cast<GenericComplexType *>(const_cast<BaseType *>(valueType)))->getImOffset(), &dummyIm);
     289}
     290
     291QtAtomicData::QtAtomicData(r_ULong valRe, r_Long valIm, unsigned short size)
     292    : QtScalarData()
     293{
     294    r_ULong dummyRe = valRe;
     295    r_Long dummyIm = valIm;
     296
     297    if (size == 2 * sizeof(r_ULong))
     298    {
     299        valueType = TypeFactory::mapType("CInt32");
     300    }
     301    else
     302    {
     303        valueType = TypeFactory::mapType("CInt16");
     304    }
     305
     306    valueBuffer = new char[valueType->getSize()];
     307    valueType->makeFromCULong(valueBuffer + (static_cast<GenericComplexType *>(const_cast<BaseType *>(valueType)))->getReOffset(), &dummyRe);
     308    valueType->makeFromCLong(valueBuffer + (static_cast<GenericComplexType *>(const_cast<BaseType *>(valueType)))->getImOffset(), &dummyIm);
     309}
     310 No newline at end of file
  • qlparser/qtatomicdata.hh

    diff --git a/qlparser/qtatomicdata.hh b/qlparser/qtatomicdata.hh
    index 79b09a3bd..076c2411a 100644
    a b public:  
    8888    /// constructor getting complex data
    8989    QtAtomicData(double valRe, double valIm, unsigned short size);
    9090    QtAtomicData(r_Long valRe, r_Long valIm, unsigned short size);
     91    QtAtomicData(r_ULong valRe, r_ULong valIm, unsigned short size);
     92    QtAtomicData(r_Long valRe, r_ULong valIm, unsigned short size);
     93    QtAtomicData(r_ULong valRe, r_Long valIm, unsigned short size);
    9194
    9295    /// copy constructor
    9396    QtAtomicData(const QtAtomicData &obj);
  • raslib/test/errtxts

    diff --git a/raslib/test/errtxts b/raslib/test/errtxts
    index 0004f3024..7faf68c6d 100755
    a b  
    5858308^E^Parsing error: Unexpected end of query.
    5959309^E^Parsing error: Unknown error.
    6060310^E^Lexical analysing error $errorNo in line $lineNo, column $columnNo: Unexpected characters $token.
    61 311^E^Parsing error $errorNo in line $lineNo, column $columnNo, token $token: Complex constructor must have both arguments of the same type (i.e. float or double).
     61311^E^Parsing error $errorNo in line $lineNo, column $columnNo, token $token: Complex constructor must have both arguments of the same type.
    6262312^E^Parsing error $errorNo in line $lineNo, column $columnNo, token $token: Variable already defined.
    6363313^E^Parsing error $errorNo in line $lineNo, column $columnNo, token $token: Only constant interval bounds allowed.
    6464#