like operations in Pentaho

Let us discuss about How to implement Like operations in Pentaho.Here, I have designed the transformation to handle like operation which is same as like clause in database. See the below Transformation design. See the values in the Generate rows components. See the code written in Modified JavaScript Value Component.Here if you see I have used function “getOcuranceString” which will give value in terms of number of occurrences of a substring in the main string. In other words, we can say if it returns value 0 that means value which…

Return Value Optimization(RVO)

Let us try to understand RVO(Return value optimization) with the help of below example: #include <iostream> using namespace std; class base { unsigned int m_mem1; unsigned int m_mem2; public: base(unsigned int x, unsigned int y): m_mem1(x), m_mem2(y) { cout << “base C’tor” << endl; } ~base() { cout << “base d’tor” << endl; } base(const base& b) { m_mem1 = b. m_mem1; m_mem2 = b. m_mem2; cout << “Copy C’tor” << endl; } static base getNewInstance() { base b(10,20); return b; } }; int main() { base b = base::getNewInstance();…

inline function

inline function is a function which is expanded inline i.e. function definition is copied to a place where it is called.When a function called in program, CPU does following: a) Stores the address of instruction following the function call. b) Push function arguments on the stack c) Transfer the control to the function definition. d) Execute the function e) Transfer the control to the address stored at step a. When execution time of function is less than the switching time from calling to called function, then this becomes overhead. To…

Friend function

Friend function is a function, which can access the private and protected data member of a class. Using keyword friend, we can make function a friend function. Below is the prototype for friend function friend <return-type>  function(<className>); Example: #include <iostream> using namespace std; class base { unsigned int m_int; public: base() { m_int = 20; } friend ostream& operator<<(ostream& s, const base& b); }; //Source File ostream& operator<<(ostream& s, const base& b) { s << b.m_int ; return s; } int main() { base b; cout << b << endl;…

Run Queries using CLI on Athena Tables

Today, I will discuss about Athena APIs which can be used in automation using shell scripting to fetch the Table data to perform validations like count, date, sum (aggregate functions), duplicate .I will explain the APIs using count validation in Athena. Get the Total records Details of the Athena tables using Athena APIs.STEP 1 : Use the below Command to get the query execution id for count Query of particular Table.API Used : start-query-executionaws athena start-query-execution –query-string “SELECT count(*) FROM $S3-Schema.$S3-Table” | grep [a-z] |awk -F “:” ‘{print $2}’|sed -e…

const member function

const member function does not allow to modify nonstatic data member value of an object. Below is the prototype for const function: <return-value> function() const;const function with empty definition look like: <return-value> <className>::function() const {}From the above you can see that with the const keyword, we can make function a const function. const function makes this pointer as pointer to a const because of this reason, we cannot modify object data i.e. nonstatic data member of an object. const function can be called from const object as well as non-const…

Mutable storage class specifier

mutable is the one of the storage specifier in C++. In general, const function does not allow to modify data members of an object who called it. However, with the help of mutable specifier, we can achieve it.Simple example shows use of mutable specifier. #include <iostream>using namespace std;class base { unsigned int m_int; mutable unsigned int m_mutableInt;public: base(unsigned int x, unsigned int y) { m_int = x; m_mutableInt = y; } void read() const { //const function m_int = 40; // Error: This is not allowed. m_mutableInt = 10; //…

Static function

Static function is used to access static data members of a class.Static function is called using class name and scope resolution operator. We do not need an object to call static function. //Header fileclass singleton {    static singleton* m_instance;    singleton() {}    singleton& operator=(const singleton& );    singleton(const singleton& );     public:    ~singleton() {}    static singleton* getInstance(); }; //Source file singleton* singleton::m_instance = NULL;singleton* singleton::getInstance() {  //static function accessing static data member m_instance    if (NULL == m_instance) {        return new singleton;  …

Static member

When we add a static data member in class, it will have only one copy per class.Let us understand with an example.//Header file#include <iostream>using namespace std;class base {     static unsigned int m_classMember; //static data member    unsigned int m_objectMember; //nonstatic data memberpublic:    base() {         m_objectMember = 0;        ++ m_classMember;         ++ m_objectMember;       cout << “Count: “ << m_classMember  << “ “ << m_objectMember <<           endl;    }}; //Source file:unsigned int…

this pointer

Let us understand with an example how and where this pointer is used. class employee { unsigned int m_age; unsigned int m_salary; employee(unsigned int age, unsigned int salary) { m_age = age; // same as this->m_age = age; m_salary = salary; //same as this->m_salary = salary }void update(unsigned int age, unsigned int salary) { m_age = age; // same as this->m_age = age; m_salary = salary; //same as this->m_salary = salary }}; int main() { employee emp(40, 45000); emp.update(40, 50000); return 0; } In the above example, employee object viz.…