Skip to content

OrientDB

Daniel Smith edited this page Sep 14, 2016 · 15 revisions

Working with data using OrientDB graph database

Export data from Analytics Toolkit to OrientDB database

  1. Create an instance of OrientDB and an instance of the Analytics Toolkit from TAP Services >Marketplace. See Creating a service instance.

  2. Bind your Analytics Toolkit instance with your OrientDB instance. See Binding Services to learn how to bind two instances.

  3. Use Jupyter notebook to export data from the Analytics Toolkit to OrientDB. See Creating a Jupyter Notebook.

Export a graph to OrientDB database

The export to OrientDB API creates an OrientDB database with the specified name and exports the Analytics Toolkit graph to the database. The API returns summary statistics for the exported data.

graph.export_to_orientdb(“DatabaseName”)

Import data from OrientDB database to Analytics Toolkit

Importedgraph = ta.Graph(ta.OrientDBGraph(“DatabaseName”)
inspect the imported graph data
Importedgraph.vertices['input'].inspect()
importedgraph.vertices['input'].inspect()
importedgraph.edges['input'].inspect() 

Example: Export data from the Analytics Toolkit in Parquet graph format to OrientDB database and import it back as a new Parquet graph

Import the Analytics Toolkit

import trustedanalytics as ta
ta.connect(“atk_credentials_file”)

The Datasets

schema = [('viewer', str), ('profile', ta.int32), ('movie', str), ('rating', ta.int32)]
data1 = [['fred',0,'Croods',5],
          ['fred',0,'Jurassic Park',5],
          ['fred',0,'2001',2],
          ['fred',0,'Ice Age',4],
          ['wilma',0,'Jurassic Park',3],
          ['wilma',0,'2001',5],
          ['wilma',0,'Ice Age',4],
          ['pebbles',1,'Croods',4],
          ['pebbles',1,'Land Before Time',3],
         ['pebbles',1,'Ice Age',5]]
data2 = [['betty',0,'Croods',5],
          ['betty',0,'Jurassic Park',3],
          ['betty',0,'Land Before Time',4],
          ['betty',0,'Ice Age',3],
          ['barney',0,'Croods',5],
          ['barney',0,'Jurassic Park',5],
          ['barney',0,'Land Before Time',3],
          ['barney',0,'Ice Age',5],
          ['bamm bamm',1,'Croods',5],
 ['bamm bamm',1,'Land Before Time',3]]
frame = ta.Frame(ta.UploadRows(data1, schema))
frame2 = ta.Frame(ta.UploadRows(data2, schema))

Create Parquet graph using the given schema and datasets

graph = ta.Graph()
graph.define_vertex_type('viewer')
graph.define_vertex_type('film')
graph.define_edge_type('rating', 'viewer', 'film')
graph.vertices['viewer'].add_vertices(frame, 'viewer', ['profile'])
graph.vertices['film'].add_vertices(frame, 'movie')
graph.edges['rating'].add_edges(frame, 'viewer', 'movie', ['rating'])

Inspect the graph data

graph.vertices['viewer'].inspect()
graph.vertices['film'].inspect()
graph.edges['rating'].inspect()

Export the graph to OrientDB database

graph.export_to_orientdb(“DatabaseName”)

Import data from OrientDB database to Analytics Toolkit in Parquet graph format

Importedgraph = ta.Graph(ta.OrientDBGraph(“DatabaseName”)
inspect the imported graph data
Importedgraph.vertices['viewer'].inspect()
importedgraph.vertices['film'].inspect()
importedgraph.edges['rating'].inspect()

Accessing the OrientDB Dashboard

Opening OrientDB studio from TAP

How to deploy the OrientDB-dashboard application manually on TAP

  1. Setup your environment to run Cloud Foundry commands (CF) on your machine: Install the CloudFoundry CLI package from https://github.com/cloudfoundry/cli/releases. On RedHat/CentOS, however, run these commands instead:

     ‘wget --content-disposition https://cli.run.pivotal.io/stable?release=redhat64’
    

    This downloads the pre-packaged RPM to your local machine.

Now run the command to install this package:

    ‘sudo yum install <path to the cf_cli RPM>’

To test your ‘cf-cli’ installation, run the ‘cf’ command and verify that the usage message is displayed.

  1. Deploy the OrientDB-dashboard application on TAP

Create a new directory in your Linux machine.

Download the zip file of OrientDB-dashboard repository from https://github.com/trustedanalytics/orientdb-dashboard in the created directory

Unzip it and delete the original zip file or move it to another location.

Edit the manifest file, changing the “orientdb-dashboard” application name to the name of your previously created instance of the OrientDB service.

Push your app with the code from your branch.

   ‘cf push -f <PATH_TO_MANIFEST_FILE>’
  1. To access your OrientDB-dashboard application:

From the TAP console, navigate to Applications and search for an application name “orientdb-dashboard”.

Click on the URL in your application row to access the OrientDB studio webpage.

Opening an existing OrientDB database

  1. From the OrientDB studio webpage, select the database name from the drop-down menu, as shown below. Opening OrientDB Dashboard
  2. Enter the user credentials. The default username is “admin” and password is “admin”, or the root user name and password are predefined in the database configuration file. (You can change user credentials once you open the database.)

Changing user credentials, creating users and roles for OrientDB from OrientDB studio

From the OrientDB studio page, open the database with default credentials and select >Security from the top-level menu. You can then select the default users roles or modify them. New users and roles can be added. Opening OrientDB Dashboard

More information for OrientDB studio can be found at http://orientdb.com/docs/2.0/orientdb-studio.wiki/Home-page.html

Clone this wiki locally