top_port=sqlCtx.sql("SELECT dstport, count(dstport) as c1 FROM records GROUP BY dstport ORDER BY c1 DESC LIMIT 10").map(lambdax:(x.dstport,x.c1)).collect()
print"Top ports:"
print"{:>6} {:>12}".format("Port","Count")
top_dport=sqlCtx.sql("SELECT dstport, count(dstport) as c1 FROM records GROUP BY dstport ORDER BY c1 DESC LIMIT 10").map(lambdax:(x.dstport,x.c1)).collect()
print"Top Dest ports:"
print"{:>6} {:>12}".format("Dest Port","Count")
forport,countintop_port:
print"{:>6} {:>12}".format(port,count)
top_sport=sqlCtx.sql("SELECT srcport, count(srcport) as c1 FROM records GROUP BY srcport ORDER BY c1 DESC LIMIT 10").map(lambdax:(x.srcport,x.c1)).collect()