I want to get started with using Avro with Map Reduce. Can Someone suggest a good tutorial / example to get started with. I couldnt find much through the internet search.
javascript + jquery : https://codepen.io/GentjanLikaj/pen/dyPXLXX
$( "#btn1" ).click(function() {
$( "table" ).remove();
var text1 = document.getElementById('text').value;
var text1=text1.replace(/(\r\n|\n|\r)/gm,"");
var sep = document.getElementById('sep').value;
var aray = text1.split(sep);
var formato = '';
var univoco = '
';
var null1 = '
';
var html = 'ColummnName Format Null ';
$.each(aray, function(i, val) {
html += '' + val + ' ' + formato + ' ' + null1 + ' ';
});
html += '
';
$("#table").append(html);
});
$( "#btn2").click(function() {
$( "#avro" ).empty();
var myRows = {myRows:[]};
var $th = $('#tbl th');
$('#tbl tbody tr').each(function(i, tr){
var obj = {},
$tds = $(tr).find('td');
$td1 = $(tr).find('select.form').children("option:selected");
$tds2 = $(tr).find('#checkbox');
$tds3 = $(tr).find('#null');
$th.each(function(){
obj['name'] = $tds.eq(0).text();
var type=$td1.eq(0).val();
var nullv=$tds3.eq(0).is(':checked');
if (type=='date') {
type={type:"int", logicalType:"date"};
}else if (nullv == true) {
type = [type ,'null' ];
}
else{
type;
}
obj['type'] = type;
// obj['univoco'] = $tds2.eq(0).is(':checked');
// obj['null'] = $tds3.eq(0).is(':checked');
});
myRows.myRows.push(obj);
});
console.log(JSON.stringify(myRows));
var header = '{
    "type": "record" ,
    "namespace": "Mezzora" ,
    "name": "ReportDSL" ,
    "fields": [
';
$('#avro').append(header);
text ='          '+JSON.stringify(myRows.myRows[0]) +"
";
$('#avro').append(text);
var i;
for (i = 1; i < myRows.myRows.length; i++) {
text ='          ,'+ JSON.stringify(myRows.myRows[i]) +"
";
$('#avro').append(text);
}
var footer = '        ]
}';
$('#avro').append(footer);
});
$( "#btn3").click(function() {
$( "#sql" ).empty();
var myRows = {myRows:[]};
var $th = $('#tbl th');
$('#tbl tbody tr').each(function(i, tr){
var obj = {},
$tds = $(tr).find('td');
$td1 = $(tr).find('select.form').children("option:selected");
$tds2 = $(tr).find('#checkbox');
$tds3 = $(tr).find('#null');
$th.each(function(){
obj['name'] = $tds.eq(0).text();
var type=$td1.eq(0).val();
var nullv=$tds3.eq(0).is(':checked');
if (nullv == false) {
type= type +' not null';
}else if (nullv == true) {
type = type +' null' ;
}else{
if (type == 'string') {
type = 'varchar(50)';
}else{
type;
}
}
obj['type'] = type;
// obj['univoco'] = $tds2.eq(0).is(':checked');
// obj['null'] = $tds3.eq(0).is(':checked');
});
myRows.myRows.push(obj);
});
console.log(JSON.stringify(myRows));
var header = 'CREATE TABLE [schema].[tblName]   (
';
$('#sql').append(header);
var i;
for (i = 0; i < myRows.myRows.length; i++) {
text ='          '+ JSON.stringify(myRows.myRows[i].name).replace('\"',' ').replace('\"',' ') +JSON.stringify(myRows.myRows[i].type).replace('\"',' ').replace('\"',' ') +",
";
$('#sql').append(text);
}
var footer = ');';
$('#sql').append(footer);
});
.parent {
display: grid;
grid-template-columns: repeat(10, 1fr);
grid-template-rows: repeat(12, 1fr);
grid-column-gap: 20px;
grid-row-gap: 0px;
}
.div1 { grid-area: 1 / 2 / 2 / 11; }
.div2 { grid-area: 5 / 6 / 6 / 7; }
.div3 { grid-area: 3 / 1 / 5 / 12; }
.div4 { grid-area: 2 / 1 / 3 / 2; }
.div5 { grid-area: 6 / 1 / 13 / 4; }
.div6 { grid-area: 6 / 4 / 13 / 8; }
.div7 { grid-area: 6 / 8 / 13 / 12; }
.div6 , .div7{
border: 1px solid black;
margin-right: 10px;
}
#btn1{
margin-bottom: 30px;
}
Insert the text and the separator and press the button:
Separatetor
Avro Format
SQL Create