Shared Concepts and Topics

Alongside-HDFS Execution by Using the Hadoop Engine

The following LIBNAME statement sets up a libref that you can use to access data that are stored in HDFS and have metadata in Hive:

libname hdoopLib hadoop
        server       = "hpa.sas.com"
        user         = XXXXX
        password     = YYYYY
        database     = myDB
        config       = "demo.xml" ;

For more information about LIBNAME options available for the Hadoop engine, see the LIBNAME topic in the Hadoop section of SAS/ACCESS for Relational Databases: Reference. The configuration file that you specify in the CONFIG= option contains information that is needed to access the Hive server. It also contains information that enables this configuration file to be used to access data in HDFS without using the Hive server. This information can also be used to specify replication factors and block sizes that are used when the engine writes data to HDFS.

The following DATA step uses the Hadoop engine to distribute to HDFS the simData data set that was used in the previous sections. The engine creates metadata for the data set in Hive.

data hdoopLib.simData;
    set simData;
run;

After you have loaded data or if you are accessing preexisting data in HDFS that have metadata in Hive, you can access this data alongside HDFS by using high-performance analytical procedures. The following HPLOGISTIC procedure statements perform the analysis in alongside-HDFS mode. These statements are similar to the PROC HPLOGISTIC example in the previous sections.

proc hplogistic data=hdoopLib.simData;
   class a b c;
   model y = a b c x1 x2 x3;
   performance host = "compute_appliance.sas.com" nodes=8;
run;

Figure 2.12 shows the "Performance Information" and "Data Access Information" tables. You see that the procedure ran in distributed mode and that the input data were read in parallel asymmetric mode. The numeric results shown in Figure 2.13 agree with the previous analyses.

Figure 2.12: Alongside-HDFS Execution by Using the Hadoop Engine

The HPLOGISTIC Procedure

Performance Information
Host Nodecompute_appliance.sas.com
Execution ModeDistributed
Number of Compute Nodes8
Number of Threads per Node40

Data Access Information
DataEngineRolePath
GRIDLIB.SIMDATAHADOOPInputParallel, Asymmetric


Figure 2.13: Alongside-HDFS Execution by Using the Hadoop Engine

Model Information
Data SourceGRIDLIB.SIMDATA
Response Variabley
Class ParameterizationGLM
DistributionBinary
Link FunctionLogit
Optimization TechniqueNewton-Raphson with Ridging

Parameter Estimates
ParameterEstimateStandard
Error
DFt ValuePr > |t|
Intercept5.70110.2539Infty22.45<.0001
a 0-0.010200.06627Infty-0.150.8777
a 10....
b 00.71240.06558Infty10.86<.0001
b 10....
c 00.80360.06456Infty12.45<.0001
c 10....
x10.019750.000614Infty32.15<.0001
x2-0.047280.003098Infty-15.26<.0001
x3-0.10170.009470Infty-10.74<.0001


The Hadoop engine also enables you to access tables in HDFS that are stored in various formats and that are not registered in Hive. You can use the HDMD procedure to generate metadata for tables that are stored in the following file formats:

  • delimited text

  • fixed-record length binary

  • sequence files

  • XML text

To read any other kind of file in Hadoop, you can write a custom file reader plug-in in Java for use with PROC HDMD. For more information about LIBNAME options available for the Hadoop engine, see the LIBNAME topic in the Hadoop section of SAS/ACCESS for Relational Databases: Reference.

The following example shows how you can use PROC HDMD to register metadata for CSV data independently from Hive and then analyze these data by using high-performance analytical procedures. The CSV data in the table csvExample.csv is stored in HDFS in the directory /user/demo/data. Each record in this table consists of the following fields, in the order shown and separated by commas.

  1. a string of at most six characters

  2. a numeric field with values of 0 or 1

  3. a numeric field with real numbers

Suppose you want to fit a logistic regression model to these data, where the second field represents a target variable named Success, the third field represents a regressor named Dose, and the first field represents a classification variable named Group.

The first step is to use PROC HDMD to create metadata that are needed to interpret the table, as in the following statements:

libname hdoopLib hadoop
                 server       = "hpa.sas.com"
                 user         = XXXXX
                 password     = YYYYY
                 HDFS_PERMDIR = "/user/demo/data"
                 HDFS_METADIR = "/user/demo/meta"
                 config       = "demo.xml"
                 DBCREATE_TABLE_EXTERNAL=YES;

proc hdmd name=hdoopLib.csvExample data_file='csvExample.csv'
          format=delimited encoding=utf8 sep = ',';

     column Group    char(6);
     column Success  double;
     column Dose     double;
run;

The metadata that are created by PROC HDMD for this table are stored in the directory /user/demo/meta that you specified in the HDFS_METADIR = option in the preceding LIBNAME statement. After you create the metadata, you can execute high-performance analytical procedures with these data by using the hdoopLib libref. For example, the following statements fit a logistic regression model to the CSV data that are stored in the csvExample.csv table:

proc hplogistic data=hdoopLib.csvExample;
    class Group;
    model Success = Dose;
    performance host     = "compute_appliance.sas.com"
                gridmode = asym
                nodes    = 8;
run;

Figure 2.14 shows the results of this analysis. You see that the procedure ran in distributed mode and that the input data were read in parallel asymmetric mode. The metadata that you created by using the HDMD procedure have been used successfully in executing this analysis.

Figure 2.14: Alongside-HDFS Execution with CSV Data

The HPLOGISTIC Procedure

Performance Information
Host Nodecompute_appliance.sas.com
Execution ModeDistributed
Number of Compute Nodes8
Number of Threads per Node40

Data Access Information
DataEngineRolePath
GRIDLIB.CSVEXAMPLEHADOOPInputParallel, Asymmetric

Model Information
Data SourceGRIDLIB.CSVEXAMPLE
Response VariableSuccess
Class ParameterizationGLM
DistributionBinary
Link FunctionLogit
Optimization TechniqueNewton-Raphson with Ridging

Class Level Information
ClassLevelsValues
Group3group1 group2 group3

Number of Observations Read1000
Number of Observations Used1000

Parameter Estimates
ParameterEstimateStandard
Error
DFt ValuePr > |t|
Intercept0.12430.1295Infty0.960.3371
Dose-0.26740.2216Infty-1.210.2277