Coder Social home page Coder Social logo

bio4j / angulillos Goto Github PK

View Code? Open in Web Editor NEW
7.0 5.0 2.0 1.36 MB

Java 8 library for strongly typed graph data

License: GNU Affero General Public License v3.0

Scala 0.97% Java 99.03%
bio4j traversal java schema tinkerpop graph-schema graph graphs graph-database data-model

angulillos's Introduction

Angulillos<?>

Angulillos is a Java 8 library for strongly typed graph data.

You write graph schemas using the Java type system, and graph traversals are statically checked. The same schemas and traversals can then be used with any implementation of the Angulillos API, such as bio4j/angulillos-titan.

Why not TinkerPop?

Angulillos fixes the untypedness of TinkerPop at two different levels that we could call structural and model-specific:

  • Structural You can write nonsensical traversals like "source of a vertex"
  • Model No notion of graph schema. You can write "give me users followed by tweet"

Where to start

The tests include a simple Twitter graph schema and some generic traversals:

For something more complex take a look at bio4j/bio4j, which includes several interconnected graph schemas with hundreds of types.

angulillos's People

Contributors

eparejatobes avatar laughedelic avatar pablopareja avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

angulillos's Issues

Restructure methods for adjacent edges/vertices

I have rough an idea on how to improve all these inOneE, inOptionalE, inManyE, etc. For that we'll need to make arities useful:

  • split arity on two: in-arity and out-arity (there already are separate traits for this)
  • add representation type to arity (E, Optional<E>, Stream<E>)
  • put those arity specific in/out methods to the arity traits
  • call them from the typed graph/vertex interfaces

Something like

    sealed trait Arity { 

      type C[E]
      def narrow(edges: Stream[E]): C[E]
    }

    trait ExactlyOne extends Arity { type C[E] = E; ... }
    trait AtMostOne  extends Arity { type C[E] = Option[E]; ... }
    trait ManyOrNone extends Arity { type C[E] = Stream[E]; ... }


    trait InArity extends Arity
    trait OutArity extends Arity

    trait FromExactlyOne extends InArity with ExactlyOne
    trait FromAtMostOne  extends InArity with AtMostOne
    trait FromManyOrNone extends InArity with ManyOrNone

    trait ToExactlyOne extends OutArity with ExactlyOne
    trait ToAtMostOne  extends OutArity with AtMostOne
    trait ToManyOrNone extends OutArity with ManyOrNone

then in the TypedVertex:

  default <
    // src
    S extends TypedVertex<S,ST,SG,I,RV,RE>,
    ST extends TypedVertex.Type<S,ST,SG,I,RV,RE>,
    SG extends TypedGraph<SG,I,RV,RE>,
    // rel
    R extends TypedEdge<S,ST,SG, R,RT,RTA, RG,I,RV,RE, N,NT,G>,
    RT extends TypedEdge.Type<S,ST,SG, R,RT,RTA, RG,I,RV,RE, N,NT,G>,
    RTA extends TypedEdge.Type.Arity<...>,       // some magic here, please???
    RG extends TypedGraph<RG,I,RV,RE>
  >
  RTA<E> inE(RT relType) { return relType.arity.narrow(graph().inE(relType, self()); }

@eparejatobes WDYT?
Sorry for using scala here, but I think you got the idea. Do you think it's doable in Java?

Deprecate AtLeastOne arity

There are only three types of outE/inE methods, they return

  • E for arity One
  • Optional<E> for arity AtMostOne
  • Stream<E> for arity Any (Many)

As there is no NonEmptyStream<> in Java, let's deprecate the AtLeastOne arity.

Problem with Index stuff in TypedGraphs

I just ran into this:

SEVERE: Exception retrieving protein P0DM41
Sep 04, 2014 10:38:32 AM com.bio4j.model.uniprot.programs.ImportUniprot importUniprot
SEVERE: null
Sep 04, 2014 10:38:32 AM com.bio4j.model.uniprot.programs.ImportUniprot importUniprot
SEVERE: com.ohnosequences.typedGraphs.titan.TitanTypedVertexIndex$Default.query(TitanTypedVertexIndex.java:67)
Sep 04, 2014 10:38:32 AM com.bio4j.model.uniprot.programs.ImportUniprot importUniprot
SEVERE: com.ohnosequences.typedGraphs.TypedElementIndex$Unique.getElement(TypedElementIndex.java:38)
Sep 04, 2014 10:38:32 AM com.bio4j.model.uniprot.programs.ImportUniprot importUniprot
SEVERE: com.ohnosequences.typedGraphs.TypedVertexIndex$Unique.getVertex(TypedVertexIndex.java:41)
Sep 04, 2014 10:38:32 AM com.bio4j.model.uniprot.programs.ImportUniprot importUniprot
SEVERE: com.bio4j.model.uniprot.programs.ImportUniprot.importUniprot(ImportUniprot.java:337)
Sep 04, 2014 10:38:32 AM com.bio4j.model.uniprot.programs.ImportUniprot importUniprot
SEVERE: com.bio4j.titan.model.uniprot.programs.ImportUniprotTitan.execute(ImportUniprotTitan.java:56)
Sep 04, 2014 10:38:32 AM com.bio4j.model.uniprot.programs.ImportUniprot importUniprot
SEVERE: com.ohnosequences.util.ExecuteFromFile.main(ExecuteFromFile.java:66)
Sep 04, 2014 10:38:32 AM com.bio4j.model.uniprot.programs.ImportUniprot importUniprot
SEVERE: com.bio4j.titan.programs.ImportTitanDB.main(ImportTitanDB.java:11)

It seems to be some internal null value exception thrown in TitanTypedVertexIndex class.
@eparejatobes Any ideas why?

Bio4j induced requirements

@pablopareja I did some general clean up and implemented some extra stuff for Titan; all this is in 0.2.0-SNAPSHOT. Please use this issue for feature requests that you surely will be identifying as the work in bio4j/bio4j-titan#14 progresses. The idea is that you shouldn't need to use anything from the raw Titan API.

Advanced schema graph

Not only creating types/labels in the DB, but also creating a real graph, i.e. connecting DB-specific edge-type presentation with its source/target types with an edge, etc. So that you can query the DB for the schema structure.

In TitanDB this is straightforward, because EdgeLabel implements TitanVertex. This needs some investigation for other possible backends.

Problem when using last version published

Now the following piece of code:

TitanNode.Type

gives the following error:

Error:(55, 34) java: com.ohnosequences.typedGraphs.titan.TitanNode.Type is not public in com.ohnosequences.typedGraphs.titan.TitanNode; cannot be accessed from outside package

Is that normal?

IMPORTANT - moving to Bio4j, renaming

Hey @ohnosequences/coders I want to move this to the bio4j org; it makes much more sense there, and we could attract contributors much more easily. The other thing is the name: typed-graphs is just awful. Suggestions?

Typed vertex queries

Add support.


old

At the moment it's just lying there, without any connection with the rest of the things.

Consider adding locks to Transaction

Neo4j has entity-level locks in the scope of a transaction, which is a really useful feature. I think we could safely add this to the Transaction interface here, throwing UnsupportedOperation if missing from an implementation.

Split interfaces on read/write-only

I would split typed and untyped graph interfaces on parts with

  • writing methods (addVertex/addEdge, setProperty, commit)
  • reading methods (the rest)
  • and probably indexes-related stuff

In the writing part we can add general methods for schema initialization. Then it's used for importing data.

The reading part is used for working with an instance of already imported data.

@eparejatobes WDYT?

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.