Esempio n. 1
0
 internal DBLob(DBCollection cl)
 {
     this._cl          = cl;
     this._connection  = cl.CollSpace.SequoiaDB.Connection;
     this._isBigEndian = cl.isBigEndian;
     _id         = ObjectId.Empty;
     _mode       = -1;
     _size       = 0;
     _readOffset = -1;
     _createTime = 0;
     _isOpen     = false;
     _contextID  = -1;
 }
Esempio n. 2
0
 internal DBCursor(SDBMessage rtnSDBMessage, DBCollection dbc)
 {
     this.dbc   = dbc;
     connection = dbc.CollSpace.SequoiaDB.Connection;
     hint       = new BsonDocument();
     hint.Add("", SequoiadbConstants.CLIENT_RECORD_ID_INDEX);
     sdbMessage               = new SDBMessage();
     reqId                    = rtnSDBMessage.RequestID;
     sdbMessage.NodeID        = SequoiadbConstants.ZERO_NODEID;
     sdbMessage.ContextIDList = rtnSDBMessage.ContextIDList;
     contextId                = sdbMessage.ContextIDList[0];
     sdbMessage.NumReturned   = -1;           // return data count
     list         = rtnSDBMessage.ObjectList; // while using fineOne, ObjectList may have data
     hasMore      = true;
     isBigEndian  = dbc.isBigEndian;
     isClosed     = false;
     this.DBQuery = new DBQuery();
 }
Esempio n. 3
0
        /* \fn void UpdateCurrent(BsonDocument modifier)
         *  \brief Update the current Bson of this cursor
         *  \param modifier The updating rule
         *  \exception SequoiaDB.BaseException
         *  \exception System.Exception
         */

        /*
         * public void UpdateCurrent(BsonDocument modifier)
         * {
         *  if (modifier == null)
         *      throw new BaseException("SDB_INVALIDARG");
         *  if (dbc == null)
         *      throw new BaseException("SDB_CLT_OBJ_NOT_EXIST");
         *  BsonDocument current;
         *  if (( current = Current()) != null )
         *  {
         *      BsonDocument matcher = new BsonDocument();
         *      matcher.Add(SequoiadbConstants.OID, current[SequoiadbConstants.OID].AsObjectId);
         *      dbc.Update(matcher, modifier, hint);
         *      BsonDocument dummy = new BsonDocument();
         *      list[index] = dbc.Query(matcher, dummy, dummy, dummy).Next();
         *  }
         * }
         */

        /* \fn void DeleteCurrent()
         *  \brief Delete the current Bson of this cursor
         *  \exception SequoiaDB.BaseException
         *  \exception System.Exception
         */
        /*
         * public void DeleteCurrent()
         * {
         *  if ( Current() != null )
         *      dbc.Delete( list[index] );
         *  list.RemoveAt(index);
         *  if (index >= list.Count)
         *      index = -1;
         * }
         */

        private void ReadNextBuffer()
        {
            if (connection == null)
            {
                throw new BaseException("SDB_NOT_CONNECTED");
            }
            if (-1 == contextId)
            {
                hasMore = false;
                index   = -1;
                dbc     = null;
                list    = null;
                return;
            }

            sdbMessage.OperationCode = Operation.OP_GETMORE;
            sdbMessage.RequestID     = reqId;
            byte[] request = SDBMessageHelper.BuildGetMoreRequest(sdbMessage, isBigEndian);
            connection.SendMessage(request);
            SDBMessage rtnSDBMessage = SDBMessageHelper.MsgExtractReply(connection.ReceiveMessage(isBigEndian), isBigEndian);

            rtnSDBMessage = SDBMessageHelper.CheckRetMsgHeader(sdbMessage, rtnSDBMessage);

            int flags = rtnSDBMessage.Flags;

            if (flags == SequoiadbConstants.SDB_DMS_EOC)
            {
                hasMore = false;
                index   = -1;
                dbc     = null;
                list    = null;
            }
            else if (flags != 0)
            {
                throw new BaseException(flags);
            }
            else
            {
                reqId = rtnSDBMessage.RequestID;
                list  = rtnSDBMessage.ObjectList;
            }
        }
 internal DBCursor(SDBMessage rtnSDBMessage, DBCollection dbc)
     : base(rtnSDBMessage, dbc)
 {
     this.m_Enumerator = new DBCursorEnumerator <TDocument>(this);
 }