-
Notifications
You must be signed in to change notification settings - Fork 11
GoFS Interaction with Jython
Jython is a java implementation of Python that combines expressive power with clarity. Python programs are typically 2-10X shorter than the equivalent Java program. This translates directly to increased programmer productivity. The seamless interaction between Python and Java allows developers to freely mix the two languages both during development and in shipping products. The rest of this document explains about the interaction of GoFS API using Jython.
Below link explains about the installation of Jython
http://wiki.python.org/jython/InstallationInstructions
-
Add gofs-core-1.0.0-SNAPSHOT.jar in sys.path of the script
Code Snippet:
import sys
import os.path
sys.path.append(os.path.realpath('path/to/gofs-core-1.0.0-SNAPSHOT.jar')) -
Import the 'edu.usc.pgroup.goffish.gofs.partition.gml' package in the script
-
Create IPartition object by passing the Partition ID, Graph Template File, List of Graph Instance Files arguments to parseGML API
gmlPartition = GMLPartition.parseGML(partitionId, FileInputStream(path/to/graphTemplate), GMLFileIterable(path/to/graphInstances)))
-
Add dependent jars of GoFS project in sys.path of the script. Dependent jars can be found under \lib directory of GoFS deployment package zip file
-
Import the necessary java packages such as 'edu.usc.pgroup.goffish.gofs.slice' and 'edu.usc.pgroup.goffish.gofs.namenode' in the script
-
Create ISliceManager object by passing the Partition Slice ID, ISliceSerializer and IStorageManager arguments
sliceManager = SliceManager(partitionSliceID, sliceSerializer, storageManager)
paritionSliceID - slice id of the graph partition. slice id can be obtained from INameNode mapping
sliceSerializer - GoFS supports Java and Kryo Serialization. By default, Java Serialization will be considered
storageManager - File Manager to store the slice files of Graph Template and Graph Instances of the partition
Write Graph Template:
sliceManager.writeTemplate(gmlPartition)
Read Graph Template:
graphPartition = sliceManager.readPartition()
Write Graph Instances:
sliceManager.writeInstances(gmlPartition)
[Make sure writePartition() is invoked before calling writeInstances() method]
Read Graph Instances:
sliceManager.readInstances(subGraph, startTime, endTime, vertexProperties, edgeProperties)
subGraph - subgraph to retrieve instances for
startTime - earliest time to retrieve instances for
endTime - latest time to retrieve instances for
vertexProperties - properties to retrieve for vertices
edgeProperties - properties to retrieve for edges
**Note: Refer GoFS Java documentation for exact argument types **