prasanth7499's Profile

29
Points

Questions
0

Answers
14

  • Asked on February 3, 2019 in Apache-spark.

    In programming language theory, lazy evaluation, or call-by-need  is an evolution staergy which delays the evaluation of an expression until its value is needed  and which also avoids repeated evaluations . The sharing can reduce the running time of certain functions by an exponential factor over other non-strict evaluation strategies, such as call-by-name.

    The benefits of lazy evaluation include:

    • The ability to define control flow (structures) as abstractions instead of primitives.
    • The ability to define potentially infinite data structures. This allows for more straightforward implementation of some algorithms.
    • Performance increases by avoiding needless calculations, and avoiding error conditions when evaluating compound expressions.
    • 860 views
    • 10 answers
    • 0 votes
  • from pyspark.sql.functions import col, when, lit
    
    df.withColumn('d', when(
         ((col('A') == 'S') & (col('B') == 'S') & (col('C')=='S'))
       | ((col('A') == 'S') & (col('B') == 'NS') & (col('C')=='S'))
     , lit('S')
     ).otherwise(lit('NS'))
    ).show()
    • 7052 views
    • 8 answers
    • 0 votes
  • Asked on February 3, 2019 in Apache-spark.

    scala> val rdd = sc.parallelize(List(("a", (1,1,1)), ("b", (1,1,1)), ("a", (1,1,1)), ("a", (1,1,1)), ("b", (1,1,1)), ("b", (1,1,1)), ("b", (1,1,1)), ("b", (1,1,1))))
    scala> rdd.reduceByKey((x, y) => (x._1 + y._1, x._2 + y._2, x._3 + y._3)).collect

    • 826 views
    • 9 answers
    • 0 votes
  • You can press Alt+Enter to open a context menu that contains refactoring actions available in the current cursor position.

    • 543 views
    • 6 answers
    • 0 votes
  • var authOptions = {
        method: 'POST',
        url: 'http://10.254.147.184:7777/auth/oauth/token',
        data: qs.stringify(data),
        headers: {
            'Authorization': 'Basic Y2xpZW50OnNlY3JldA==',
            'Content-Type': 'application/x-www-form-urlencoded'
        },
        json: true
      };
      return dispatch => {
        return axios(authOptions)
        .then(function(response){
          console.log(response.data);
          console.log(response.status);
        })
        .catch(function(error){
          console.log(error);
        });
    • 3570 views
    • 9 answers
    • 0 votes
  • main.cpp
    @
    #include <QApplication>
    #include <QWidget>
    #include <QResizeEvent>
    #include “ExtDebug.h”

    class mwid : public QWidget{
    // the Q_OBJECT macro creates “undefined reference to vtable” errors
    //public:
    // Q_OBJECT
    signals:
    void mySizeChanged(int width, int height);

    public slots:
    void resizeEvent(QResizeEvent * ev){
    Q_UNUSED(ev);
    // if you remove next line, the rest of the code works just fine
    emit mySizeChanged(300, 200);
    }
    };

    int main(int argc, char *argv[]){
    QApplication app(argc, argv);

    mwid * mainWin = new mwid;
    mainWin->setMinimumSize(320, 240);
    ExtDebug * dbgWin = new ExtDebug(mainWin);

    mainWin->connect(mainWin, SIGNAL(mySizeChanged(int,int)),
    dbgWin, SLOT(resize(int,int)));

    mainWin->show();

    int ret = app.exec();

    delete mainWin;
    mainWin = nullptr;
    dbgWin = nullptr;

    return ret;
    }
    @

    ExtDebug.h
    @
    #ifndef EXTDEBUG_H
    #define EXTDEBUG_H

    #include <QObject>
    #include <QWidget>
    #include <QLineEdit>
    #include <QTextEdit>

    class ExtDebug : public QObject{
    public:

    QTextEdit * output;
    QLineEdit * input;

    ExtDebug(QWidget * parent);
    ~ExtDebug();

    public slots:
    void resize(int width, int height);
    };

    #endif // EXTDEBUG_H
    @

    ExtDebug.cpp
    @
    #include “ExtDebug.h”

    ExtDebug::ExtDebug(QWidget * parent){
    output = new QTextEdit(parent);
    output->setMinimumWidth(parent->minimumWidth());
    output->setMinimumHeight(parent->minimumHeight() – 20);
    output->move(0,0);

    input = new QLineEdit(parent);
    input->setMinimumWidth(parent->minimumWidth());
    input->setMinimumHeight(20);
    input->move(0, output->height());
    }

    ExtDebug::~ExtDebug(){
    delete input;
    delete output;

    input = nullptr;
    output = nullptr;
    }

    void ExtDebug::resize(int width, int height){
    output->resize(width, height – 20);

    input->resize(width, 20);
    input->move(0, height);
    }
    @

    • 1304 views
    • 10 answers
    • 0 votes
  • Broadcast variables allow the programmer to keep a read-only variable cached on each machine rather than shipping a copy of it with tasks.

    Considering the above, what are the use cases of broadcast variables? What problems do broadcast variables solve?

    When we create any broadcast variable like below, the variable reference, here it is broadcastVar available in all the nodes in the cluster?

    val broadcastVar = sc.broadcast(Array(1, 2, 3)
    • 705 views
    • 10 answers
    • 0 votes
  • Asked on January 28, 2019 in Ruby on Rails.
    @recipients   = "#{user.email}"
    @from         = "[email protected]"
    @subject      = "Hi"
    @content_type = "text/html"
    • 2183 views
    • 13 answers
    • 0 votes
  • collection.find().sort({datefield: -1}, function(err, cursor){...});
    • 9684 views
    • 13 answers
    • 0 votes
  • PYTHONPATH=$SPARK_HOME/python/:$PYTHONPATH
    PYTHONPATH=$SPARK_HOME/python/lib/py4j-0.9-src.zip:$PYTHONPATH
    export PYTHONPATH
    • 1592 views
    • 13 answers
    • 0 votes