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/SQLite/SQLiteAssetData.cs | 50 ++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'OpenSim/Data/SQLite') diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs index 1b42198..6a323e1 100644 --- a/OpenSim/Data/SQLite/SQLiteAssetData.cs +++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs @@ -28,6 +28,7 @@ using System; using System.Data; using System.Reflection; +using System.Collections.Generic; using log4net; using Mono.Data.SqliteClient; using OpenMetaverse; @@ -49,6 +50,7 @@ namespace OpenSim.Data.SQLite /// Artificial constructor called upon plugin load /// private const string SelectAssetSQL = "select * from assets where UUID=:UUID"; + private const string SelectAssetMetadataSQL = "select Name, Description, Type, Temporary, UUID from assets limit :start, :count"; private const string DeleteAssetSQL = "delete from assets where UUID=:UUID"; private const string InsertAssetSQL = "insert into assets(UUID, Name, Description, Type, Local, Temporary, Data) values(:UUID, :Name, :Description, :Type, :Local, :Temporary, :Data)"; private const string UpdateAssetSQL = "update assets set Name=:Name, Description=:Description, Type=:Type, Local=:Local, Temporary=:Temporary, Data=:Data where UUID=:UUID"; @@ -256,6 +258,54 @@ namespace OpenSim.Data.SQLite return asset; } + private static AssetMetadata buildAssetMetadata(IDataReader row) + { + AssetMetadata metadata = new AssetMetadata(); + + metadata.FullID = new UUID((string) row["UUID"]); + metadata.Name = (string) row["Name"]; + metadata.Description = (string) row["Description"]; + metadata.Type = Convert.ToSByte(row["Type"]); + metadata.Temporary = Convert.ToBoolean(row["Temporary"]); // Not sure if this is correct. + + // Current SHA1s are not stored/computed. + metadata.SHA1 = new byte[] {}; + + return metadata; + } + + /// + /// 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 (this) + { + using (SqliteCommand cmd = new SqliteCommand(SelectAssetMetadataSQL, m_conn)) + { + cmd.Parameters.Add(new SqliteParameter(":start", start)); + cmd.Parameters.Add(new SqliteParameter(":count", count)); + + using (IDataReader reader = cmd.ExecuteReader()) + { + while (reader.Read()) + { + AssetMetadata metadata = buildAssetMetadata(reader); + retList.Add(metadata); + } + } + } + } + + return retList; + } /*********************************************************************** * -- cgit v1.1