Created
August 29, 2017 20:17
-
-
Save AnkitAggarwalPEC/7b13e51952f89ac826ea240d0e44b610 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PrimitiveArrayCast{ | |
public: | |
static Status SafeCast(const PrimitiveArray& input , const std::shared_ptr<DataType> & target_type, MemoryPool * pool , std::shared_ptr <PrimitiveArray> * out){ | |
//! Check if types are equal | |
if(input.type()->Equals(target_type)){ | |
//! We can simply reinterpret | |
//!! Cannot Call Set Data as it is decalred as protected | |
out->get()->SetData(input.data()) ; | |
} | |
else{ | |
//! New memory has to be allocated | |
std::unique_ptr <ArrayBuilder> * builder; | |
MakeBuilder(pool, target_type , builder); | |
//! Append Cannot be called as it is not decalared | |
builder->Append(input.raw_values(),input.length(),nullptr); | |
builder->Finish(out->get()); | |
} | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment