How to resolve the algorithm Hash join step by step in the ECL programming language
How to resolve the algorithm Hash join step by step in the ECL programming language
Table of Contents
Problem Statement
An inner join is an operation that combines two data tables into one table, based on matching column values. The simplest way of implementing this operation is the nested loop join algorithm, but a more scalable alternative is the hash join algorithm. Implement the "hash join" algorithm, and demonstrate that it passes the test-case listed below. You should represent the tables as data structures that feel natural in your programming language. The "hash join" algorithm consists of two steps:
In pseudo-code, the algorithm could be expressed as follows: The order of the rows in the output table is not significant. If you're using numerically indexed arrays to represent table rows (rather than referring to columns by name), you could represent the output rows in the form [[27, "Jonah"], ["Jonah", "Whales"]].
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Hash join step by step in the ECL programming language
Source code in the ecl programming language
LeftRec := RECORD
UNSIGNED1 Age;
STRING6 Name;
END;
LeftFile := DATASET([{27,'Jonah'},{18,'Alan'},{28,'Glory'},{18,'Popeye'},{28,'Alan'}],LeftRec);
RightRec := RECORD
STRING6 Name;
STRING7 Nemesis;
END;
RightFile := DATASET([{'Jonah','Whales'},{'Jonah','Spiders'},{'Alan','Ghosts'},{'Alan','Zombies'},{'Glory','Buffy'}],
RightRec);
HashJoin := JOIN(LeftFile,RightFile,Left.Name = RIGHT.Name,HASH);
HashJoin;
//The HASH JOIN is built-in to the ECL JOIN by using the HASH JOIN Flag
/*
OUTPUT:
Age Name Nemesis
18 Alan Ghosts
18 Alan Zombies
28 Alan Ghosts
28 Alan Zombies
28 Glory Buffy
27 Jonah Whales
27 Jonah Spiders
*/
You may also check:How to resolve the algorithm Letter frequency step by step in the Aikido programming language
You may also check:How to resolve the algorithm Huffman coding step by step in the C programming language
You may also check:How to resolve the algorithm Spelling of ordinal numbers step by step in the Java programming language
You may also check:How to resolve the algorithm Quine step by step in the WDTE programming language
You may also check:How to resolve the algorithm Box the compass step by step in the Elixir programming language