From a2f07ecd2e248966957a8ea70d772276359b02e8 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Mon, 9 Mar 2009 07:29:34 +0000 Subject: Implemented FetchAssetMetadataSet in DB backends. This method fetches metadata for a subset of the entries in the assets database. This functionality is used in the ForEach calls in the asset storage providers in AssetInventoryServer. With this implemented, frontends such as the BrowseFrontend should now work. - MySQL: implemented, sanity tested - SQLite: implemented, sanity tested - MSSQL: implemented, not tested - NHibernate: not implemented --- OpenSim/Data/MySQL/MySQLAssetData.cs | 51 ++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 2211d4c..466f5db 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -28,6 +28,7 @@ using System; using System.Data; using System.Reflection; +using System.Collections.Generic; using log4net; using MySql.Data.MySqlClient; using OpenMetaverse; @@ -311,6 +312,56 @@ namespace OpenSim.Data.MySQL return assetExists; } + /// + /// Returns a list of AssetMetadata objects. The list is a subset of + /// the entire data set offset by containing + /// elements. + /// + /// The number of results to discard from the total data set. + /// The number of rows the returned list should contain. + /// A list of AssetMetadata objects. + public override List FetchAssetMetadataSet(int start, int count) + { + List retList = new List(count); + + lock (_dbConnection) + { + _dbConnection.CheckConnection(); + + MySqlCommand cmd = new MySqlCommand("SELECT name,description,assetType,temporary,id FROM assets LIMIT ?start, ?count", _dbConnection.Connection); + cmd.Parameters.AddWithValue("?start", start); + cmd.Parameters.AddWithValue("?count", count); + + try + { + using (MySqlDataReader dbReader = cmd.ExecuteReader()) + { + while (dbReader.Read()) + { + AssetMetadata metadata = new AssetMetadata(); + metadata.Name = (string) dbReader["name"]; + metadata.Description = (string) dbReader["description"]; + metadata.Type = (sbyte) dbReader["assetType"]; + metadata.Temporary = (bool) dbReader["temporary"]; // Not sure if this is correct. + metadata.FullID = new UUID((string) dbReader["id"]); + + // Current SHA1s are not stored/computed. + metadata.SHA1 = new byte[] {}; + + retList.Add(metadata); + } + } + } + catch (Exception e) + { + m_log.Error("[ASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString() + Environment.NewLine + "Attempting reconnection"); + _dbConnection.Reconnect(); + } + } + + return retList; + } + #endregion /// -- cgit v1.1