Github user c0s commented on a diff in the pull request:

    https://github.com/apache/bigtop/pull/266#discussion_r131512670
  
    --- Diff: bigtop-tests/smoke-tests/hive/TestMethods.java ---
    @@ -0,0 +1,194 @@
    +
    +//Author: Bharat Modi
    +// A masterclass containing methods which aid in the replication of access 
to hadoop
    +import java.io.BufferedInputStream;
    +import java.io.File;
    +import java.io.FileInputStream;
    +import java.io.IOException;
    +import java.io.InputStream;
    +import java.io.OutputStream;
    +import java.net.URI;
    +import java.net.URISyntaxException;
    +import java.sql.ResultSet;
    +import java.sql.ResultSetMetaData;
    +import java.sql.SQLException;
    +import java.sql.Statement;
    +import java.util.ArrayList;
    +import java.util.Arrays;
    +
    +import javax.xml.parsers.DocumentBuilder;
    +import javax.xml.parsers.DocumentBuilderFactory;
    +import javax.xml.parsers.ParserConfigurationException;
    +
    +import org.apache.hadoop.conf.Configuration;
    +import org.apache.hadoop.fs.FileSystem;
    +import org.apache.hadoop.fs.Path;
    +import org.apache.hadoop.io.IOUtils;
    +import org.w3c.dom.Document;
    +import org.w3c.dom.Element;
    +import org.w3c.dom.Node;
    +import org.w3c.dom.NodeList;
    +import org.xml.sax.SAXException;
    +public class TestMethods {
    +
    +   protected static String propertyValue(String propertyFile, String 
propertyName) throws ParserConfigurationException, SAXException, IOException, 
URISyntaxException{
    +           String configLocation = System.getenv("HADOOP_CONF_DIR");
    +           File file = new File(configLocation+"/"+propertyFile);
    +           DocumentBuilderFactory documentBuilderFactory = 
DocumentBuilderFactory
    +                           .newInstance();
    +           DocumentBuilder documentBuilder = 
documentBuilderFactory.newDocumentBuilder();
    +           Document document = documentBuilder.parse(file);
    +           document.getDocumentElement().normalize();
    +           Element docElement = document.getDocumentElement();
    +           NodeList nodeList = docElement.getElementsByTagName("property");
    +           ArrayList<String> names = new ArrayList<String>();
    +           ArrayList<String> values = new ArrayList<String>();
    +           if (nodeList != null) {
    +                   int length = nodeList.getLength();
    +                   for (int i = 0; i < length; i++) {
    +                           if (nodeList.item(i).getNodeType() == 
Node.ELEMENT_NODE) {
    +                                   Element element = (Element) 
nodeList.item(i);
    +                                   if 
(element.getNodeName().contains("property")) {
    +                                           names.add( 
element.getElementsByTagName("name").item(0).getTextContent());
    +                                           values.add( 
element.getElementsByTagName("value").item(0).getTextContent());
    +
    +                                   }
    +                           }
    +                   }
    +           }
    +           String[] nameslist = names.toArray(new String[names.size()]);
    +           String[] valueslist = values.toArray(new String[values.size()]);
    +           int valuePosition = 
Arrays.asList(nameslist).indexOf(propertyName);
    +           String propertyValue = valueslist[valuePosition].toString();
    +           return propertyValue;
    +   }
    +
    +
    +   protected static void dropTable(Statement stmt, String newTableName) 
throws SQLException{
    +           stmt.executeUpdate("DROP TABLE IF EXISTS " + newTableName);
    +   }
    +
    +   protected static void createTable(Statement stmt, String newTableName, 
String columnNames, String delimiter) throws SQLException{
    +           stmt.execute("CREATE TABLE "
    +                           + newTableName
    +                           + " ("+columnNames+") ROW FORMAT DELIMITED 
FIELDS TERMINATED BY '"+delimiter+"'");
    +           System.out.println("Creating Table "+ newTableName +"\n");
    +   }
    +
    +   protected static void describeTable(Statement stmt, String 
newTableName) throws SQLException{
    +           ResultSet res;
    +           String sql = "describe " + newTableName;
    +           System.out.println("Running: " + sql);
    +           res = stmt.executeQuery(sql);
    +           while (res.next()) {
    +                   System.out.println(res.getString(1) + "\t" + 
res.getString(2)
    +                                   + "\t" + res.getString(3)+ "\t");
    +           }
    +   }
    +
    +   protected static void showTables(Statement stmt, String sql) throws 
SQLException{
    +           ResultSet res;
    +           System.out.println("Running: " + sql +"\n");
    +           res = stmt.executeQuery(sql);
    +           ResultSetMetaData rsmd = res.getMetaData();
    +           int columnsNumber = rsmd.getColumnCount();
    +
    +
    +           while (res.next()) {
    +
    --- End diff --
    
    no need for blank lines between the body of a loop and its first line


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to