Giter Club home page Giter Club logo

marklogicsparkexamples's Introduction

MarkLogic Spark Examples

Example application that demonstrate how to use MarkLogic Connector For Hadoop with Apache Spark. For the details refer to the following blog on MarkLogic Developer Community How to use MarkLogic in Apache Spark applications.

Prerequisites

  1. You have Hadoop 2.7.1 or above and Spark 1.3.1 or above setup. MarkLogic Connector For Hadoop is supported against Hortonworks Data Platform (HDP) and Cloudera Distribution of Hadoop (CDH). Recent releases of HDP and CDH come bundled with Apache Spark.
  2. You have MarkLogic 8.0.3 or above installed and running.
  3. You have walked through the Getting Started with the MarkLogic Connector for Hadoop and successfully ran the HelloWorld Sample Application within Hadoop environment.

Build

MarkLogic Spark Examples have dependency on marklogic-mapreduce2-2.1.x.jar and marklogic-xcc-8.0.x.jar libraries. Before you build, you need to put these jar files in your local repository for use in your builds, since they don't exist in any public repository like Maven Central. Once you have added these jars in your local repository, pull down the code from https://github.com/HemantPuranik/MarkLogicSparkExamples and run

mvn package

This will download the other dependencies from public repository and create the file /target/SparkExamples-1.0-SNAPSHOT.jar.

Setup

#####Setup Database#####

  1. Unzip the sample data available in sample directory.
  2. Use mlcp to import data within ConsumerComplaints.csv file into a MarkLogic database.
  3. Configure the XDBC app server and attach it to this database.
  4. Update configuration file marklogic-spark-count.xml available in conf directory with the host, port and user information.

#####Setup Spark Environment#####

On the machine where you plan to run the spark application,

  1. Copy the configuration file marklogic-spark-count.xml to your working directory on the machine.
  2. Copy the jar file SparkExamples-1.0-SNAPSHOT.jar to the /lib sub-directory within your working directory.

Usage

In order to run MarkLogicWordCount example within Spark environment, navigate to the SPARK Home directory on the machine where you plan to run the spark application and Run spark-submit script as shown below

./bin/spark-submit --jars $LIBJARS --master local[2] \
					--class com.marklogic.spark.examples.MarkLogicWordCount \
					[my_working_directory]/lib/SparkExamples-1.0-SNAPSHOT.jar \
					[my_working_directory]/marklogic-spark-count.xml \
					hdfs://[target_directory]/mlsparkcount

Successful execution will produce the desired output in the target hdfs location specified in the last parameter.

Next Steps

We plan to add more example applications to this project as we encounter the need for it. If you'd like to know more about MarkLogic architecture see this article.

marklogicsparkexamples's People

Contributors

hemantpuranik avatar

Watchers

James Cloos avatar Anthony Roach avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.