Ejemplo n.º 1
0
        public Exceptional<BackwardEdgeStream> LoadBackwardEdge(ObjectLocation myEdgeLocation)
        {
            #region data

            BackwardEdgeStream retDBBackwardEdge = null;

            #endregion

            var existExcept = _IGraphFSSession.ObjectStreamExists(myEdgeLocation, DBConstants.DBBACKWARDEDGESTREAM);

            if (existExcept.Failed())
                return new Exceptional<BackwardEdgeStream>(existExcept);

            if (existExcept.Value == Trinary.TRUE)
            {
                var loadException = _IGraphFSSession.GetFSObject<BackwardEdgeStream>(myEdgeLocation, DBConstants.DBBACKWARDEDGESTREAM, null, null, 0, false);

                if (loadException.Failed())
                    return new Exceptional<BackwardEdgeStream>(loadException);

                retDBBackwardEdge = loadException.Value;
            }
            else
            {
                retDBBackwardEdge = new BackwardEdgeStream(myEdgeLocation);
            }

            return new Exceptional<BackwardEdgeStream>(retDBBackwardEdge);
        }
Ejemplo n.º 2
0
        internal Exceptional<Boolean> DeleteObjectReferences(ObjectUUID myObjectUUID, BackwardEdgeStream myObjectBackwardEdges, DBContext dbContext)
        {
            foreach (var item in myObjectBackwardEdges)
            {
                var type = dbContext.DBTypeManager.GetTypeByUUID(item.Key.TypeUUID);

                if (type == null)
                {
                    return new Exceptional<Boolean>(new Error_TypeDoesNotExist(""));
                }

                foreach (var objID in item.Value.GetAllEdgeDestinations(dbContext.DBObjectCache))
                {
                    if (objID.Failed())
                    {
                        return new Exceptional<Boolean>(objID);
                    }

                    var attr = objID.Value.GetAttribute(item.Key.AttrUUID);

                    if (attr is IReferenceEdge)
                    {
                        var removeResult = ((IReferenceEdge)attr).RemoveUUID(myObjectUUID);
                        if (removeResult)
                        {
                            #region Sucessfully removed the single edge ref - so remove the attribute

                            if (attr is ASingleReferenceEdgeType)
                            {
                                objID.Value.RemoveAttribute(item.Key.AttrUUID);
                            }

                            #endregion
                        }
                        else
                        {
                            return new Exceptional<bool>(new Error_NotImplemented(new System.Diagnostics.StackTrace(true)));
                        }
                    }

                    var flushExcept = dbContext.DBObjectManager.FlushDBObject(objID.Value);

                    if (!flushExcept.Success())
                        return new Exceptional<bool>(flushExcept.IErrors.First());
                }
            }

            return new Exceptional<bool>(true);
        }
Ejemplo n.º 3
0
        /*
        public BulkInsertDBO Insert(ObjectUUID myObjectUUID)
        {
            var DBObjectStream = new DBObjectStream(_Type, new Dictionary<AttributeUUID, AObject>());
            UnitTestHelper.SetPrivateField("_ObjectUUID", DBObjectStream, myObjectUUID);
            DBObjectStream.ObjectLocation = new ObjectLocation(DBObjectStream.ObjectLocation.Path, DBObjectStream.ObjectUUID.ToHexString());

            return new BulkInsertDBO(_GraphDBSession.GetTypeManager(), _Type, DBObjectStream, this);
        }

        public BulkInsertBE InsertBackwardedge(ObjectUUID myObjectUUID)
        {
            var BackwardEdgeStream = new BackwardEdgeStream(new ObjectLocation(_Type.ObjectLocation, DBConstants.DBObjectsLocation, myObjectUUID.ToHexString()));

            return new BulkInsertBE(_GraphDBSession.GetTypeManager(), _Type, BackwardEdgeStream, this);
        }
        */
        /// <summary>
        /// Internal method which will be invoked from BulkInsertDBO.Flush() for each new DBObject.
        /// </summary>
        /// <param name="myDBObjectStream"></param>
        /// <param name="myBackwardEdgeStream"></param>
        internal void Insert(DBObjectStream myDBObjectStream, BackwardEdgeStream myBackwardEdgeStream, ulong EdgesCount, ulong BackwardEdgesCount)
        {
            if (myDBObjectStream != null && _LastDBO != null)
            {
                _GraphFSSession.StoreFSObject(_LastDBO, true).FailedAction(e =>
                {
                    throw new GraphDBException(e.IErrors);
                });
            }
            if (myDBObjectStream != null)
            {
                _LastDBO = myDBObjectStream;
            }

            #region The first item need to be write in the usual way

            if (_Count <= 1)
            {
                (_GraphFSSession.SessionToken.SessionInfo as FSSessionInfo).FSSettings.UseRevisionsForParentDirectories = true;
            }
            else
            {
                (_GraphFSSession.SessionToken.SessionInfo as FSSessionInfo).FSSettings.UseRevisionsForParentDirectories = false;
            }

            #endregion

            if (myBackwardEdgeStream != null && _LastBackwardEdge != null)
            {
                _GraphFSSession.StoreFSObject(_LastBackwardEdge, true).FailedAction(e =>
                {
                    throw new GraphDBException(e.IErrors);
                });
            }
            if (myBackwardEdgeStream != null)
            {
                _LastBackwardEdge = myBackwardEdgeStream;
            }

            _Count++;
            _EdgesCount += EdgesCount;
            _BackwardEdgesCount += BackwardEdgesCount;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// This will store the last DBOject and finish the insert process by flushing the parent and allocationMap.
        /// </summary>
        public Exceptional Flush()
        {
            (_GraphFSSession.SessionToken.SessionInfo as FSSessionInfo).FSSettings.UseRevisionsForParentDirectories = true;
            (_GraphFSSession.SessionToken.SessionInfo as FSSessionInfo).FSSettings.ReflushAllocationMap = true;

            if (_LastDBO != null)
                _GraphFSSession.StoreFSObject(_LastDBO, true);
            if (_LastBackwardEdge != null)
                _GraphFSSession.StoreFSObject(_LastBackwardEdge, true);

            _LastDBO = null;
            _LastBackwardEdge = null;
            return _DBTransaction.Commit();
        }
Ejemplo n.º 5
0
 /// <summary>
 /// This will close the BulkInsert and flushes all DBObjects.
 /// </summary>
 public void Dispose()
 {
     Flush();
     _LastDBO = null;
     _LastBackwardEdge = null;
     _GraphDBSession = null;
     _GraphFSSession = null;
     _Type = null;
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Adds a new BackwardEdge from the current DBObject to the destination attribute identified by <paramref name="myBackwardEdgeAttribute"/>.
        /// Do not forget to call Flush() after doing all changes!
        /// </summary>
        /// <param name="myBackwardEdgeAttribute">The destination type and attribute</param>
        /// <param name="myObjectReference">The destination DBObject</param>
        /// <returns></returns>
        public BulkInsertDBO AddBackwardEdge(EdgeKey myBackwardEdgeAttribute, ObjectUUID myObjectReference)
        {
            if (_BackwardEdge == null)
                _BackwardEdge = new BackwardEdgeStream(_DBObjectStream.ObjectLocation);
            _BackwardEdge.AddBackwardEdge(myBackwardEdgeAttribute, myObjectReference, _DBContext.DBObjectManager);

            BackwardEdgesCount++;

            return this;
        }