コード例 #1
0
 /// <summary>
 /// Equality for Batch Triples
 /// </summary>
 /// <param name="obj">Object to test</param>
 /// <returns></returns>
 public override bool Equals(object obj)
 {
     if (obj is BatchTriple)
     {
         BatchTriple other = (BatchTriple)obj;
         return(this._graphID == other.GraphID && this._t.Equals(other.Triple));
     }
     else
     {
         return(false);
     }
 }
コード例 #2
0
        /// <summary>
        /// Saves a Triple from a Graph into the Database
        /// </summary>
        /// <param name="t">Triple to save</param>
        /// <param name="graphID">Database Graph ID</param>
        public virtual void SaveTriple(Triple t, string graphID)
        {
            if (this._writer.ThreadState == ThreadState.Stopped || this._writer.ThreadState == ThreadState.StopRequested)
            {
                throw new RdfStorageException("The Background Writer process of this Manager has already been terminated, if you are using this Manager instance multiple times then you should ensure the PreserveState property is set to true");
            }

            BatchTriple b = new BatchTriple(t, graphID);

            lock (this._writerBuffer)
            {
                this._writerBuffer.AddLast(b);
            }
        }
コード例 #3
0
 /// <summary>
 /// Saves a Triple from the Buffer into the Database
 /// </summary>
 /// <param name="b">Batch Triple information</param>
 /// <remarks>Can assume an open Database connection</remarks>
 protected abstract void SaveTripleInternal(BatchTriple b);
コード例 #4
0
        /// <summary>
        /// Saves a Triple from a Graph into the Database
        /// </summary>
        /// <param name="t">Triple to save</param>
        /// <param name="graphID">Database Graph ID</param>
        public virtual void SaveTriple(Triple t, string graphID)
        {
            if (this._writer.ThreadState == ThreadState.Stopped || this._writer.ThreadState == ThreadState.StopRequested)
            {
                throw new RdfStorageException("The Background Writer process of this Manager has already been terminated, if you are using this Manager instance multiple times then you should ensure the PreserveState property is set to true");
            }

            BatchTriple b = new BatchTriple(t, graphID);

            lock (this._writerBuffer)
            {
                this._writerBuffer.AddLast(b);
            }
        }
コード例 #5
0
 /// <summary>
 /// Saves a Triple from the Buffer into the Database
 /// </summary>
 /// <param name="b">Batch Triple information</param>
 /// <remarks>Can assume an open Database connection</remarks>
 protected abstract void SaveTripleInternal(BatchTriple b);
コード例 #6
0
        /// <summary>
        /// Saves a Triple from a Graph into the Database
        /// </summary>
        /// <param name="b">Triple to save</param>
        protected override void SaveTripleInternal(BatchTriple b)
        {
            //if (this._noTrans) this.Open(true);

            Triple t = b.Triple;
            String graphID = b.GraphID;

            bool create;
            int id = this.GetNextTripleID(t, out create);

            if (create) {
                //Get the IDs for the Nodes
                String s, p, o;
                s = this.SaveNode(t.Subject);
                p = this.SaveNode(t.Predicate);
                o = this.SaveNode(t.Object);

                //Doesn't exist so add to Database
                String addTriple = "INSERT INTO TRIPLES (tripleID, tripleSubject, triplePredicate, tripleObject, tripleHash) VALUES (" + id + ", " + s + ", " + p + ", " + o + ", " + t.GetHashCode() + ")";
                try
                {
                    this.ExecuteNonQuery(addTriple);
                }
                catch (SqlException sqlEx)
                {
                    this.Close(true, true);
                    throw new RdfStorageException("Unable to create a Triple record in the Database for Triple " + t.ToString(), sqlEx);
                }
            }

            //Is it already linked to the Graph?
            String isLinked = "SELECT * FROM GRAPH_TRIPLES WHERE graphID=" + graphID + " AND tripleID=" + id;
            if (this.ExecuteScalar(isLinked) == null)
            {
                //Add a link
                String addTriple = "INSERT INTO GRAPH_TRIPLES (graphID, tripleID) VALUES (" + graphID + ", " + id + ")";
                try
                {
                    this.ExecuteNonQuery(addTriple);
                }
                catch (SqlException sqlEx)
                {
                    this.Close(true, true);
                    throw new RdfStorageException("Unable to link a Triple record to a Graph in the Database", sqlEx);
                }
            }

            //this.Close(false);
        }