Bobinas P4G
  • Login
  • Public

    • Public
    • Groups
    • Popular
    • People

Conversation

Notices

  1. 🎓 Dr. Freemo :jpf: 🇳🇱 (freemo@qoto.org)'s status on Tuesday, 24-Dec-2019 14:28:12 UTC 🎓 Dr. Freemo :jpf: 🇳🇱 🎓 Dr. Freemo :jpf: 🇳🇱

    So Gremlin Python ( Tinkerpop 3 ) does not have transaction support. So only way to get transaction like behavior is to make sure you do everything in a single database traversal.

    Because I am writing an ORM / OGM model as my base that means I needed to implement something that looks like optimistic locking all my own (only works on immutable write-only graphs). Its a huge pain in the ass.

    Anyway after half a day I finally figured out this is the traversal I need to resolve my optimistic lock when creating a single new node in the DB:

    session.g.E().has('dirty',1).aggregate('x').fold().V().has('dirty',1).aggregate('x').choose(__.V().hasLabel('account').has("fingerprint", "DEADF00D").hasNot('dirty').count().is_(0), __.select('x').unfold().properties('dirty').drop()).iterate()

    #programming #coding #Tinkerpop #tinkerpop3 #graphdb #graphtheory #python #gremlin

    In conversation Tuesday, 24-Dec-2019 14:28:12 UTC from qoto.org permalink
    • 🎓 Dr. Freemo :jpf: 🇳🇱 (freemo@qoto.org)'s status on Tuesday, 24-Dec-2019 14:44:07 UTC 🎓 Dr. Freemo :jpf: 🇳🇱 🎓 Dr. Freemo :jpf: 🇳🇱
      in reply to

      it looks for all nodes that have a property called "fingerprint" with a value called "DEADF00D" that does not have a property called "dirty".. If there are no nodes that match that criteria then it takes all nodes and edges with a property of "dirty" and a value of "1" and drops the dirty property from it.

      I had to implement something akin to optimistic locking which means when i add a bunch of nodes and edges to the graph at first they get added one at a time with a property set called "dirty" and a value that is some sort of UUID for all the nodes/edges in the transaction.

      Then I write a step that validates it and either drops the dirty property if the transaction is successful or if the transaction fails then all nodes/edges that are dirty are dropped entierly and the transaction can be reattempted.

      In conversation Tuesday, 24-Dec-2019 14:44:07 UTC permalink

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • Privacy
  • Source
  • Version
  • Contact

Bobinas P4G is a social network. It runs on GNU social, version 2.0.1-beta0, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All Bobinas P4G content and data are available under the Creative Commons Attribution 3.0 license.