[Opensim-dev] [Opensim-commits] r8236 - in trunk/OpenSim: ApplicationPlugins/Rest/Inventory Data/MSSQL Data/MySQL Data/NHibernate Data/SQLite Data/Tests Framework Framework/AssetLoader/Filesystem Framework/Communications/Cache Framework/Communications/Capabilities Grid/AssetServer Region/ClientStack/LindenUDP Region/Communications/Hypergrid Region/Environment/Modules/Agent/AssetTransaction Region/Environment/Modules/Agent/TextureSender Region/Environment/Modules/Avatar/Inventory/Archiver Region/Environment/Modules/Scripting/DynamicTexture Region/Environment/Modules/World/Archiver Region/Environment/Modules/World/Estate Region/Environment/Scenes Region/Environment/Scenes/Hypergrid Region/ScriptEngine/Shared/Api/Implementation

Mike Mazur mmazur at gmail.com
Fri Feb 6 05:52:42 UTC 2009


Hi,

On Thu, 05 Feb 2009 09:04:45 -0500
Sean Dague <sdague at gmail.com> wrote:

> Mike Mazur wrote:
> <snip>
> > Of these columns, everything except data (and probably id) is
> > actually metadata that describes the asset. In the database it
> > makes sense to store all this information in the same table since
> > there's a tight coupling between the data and its metadata.
> 
> These are either tightly coupled things, or not.  If they are tightly
> coupled they are 1 object, 1 database table, and 1 level of xml.
> 
> If they are not tightly coupled they are 2 things.  2 objects, 2
> database tables, and 2 levels of xml.
> 
> Anything else is madness, and definitely the wrong direction IMHO.
> There is no explanation that's going to convince me that 2 objects
> should map to 1 table, so don't bother trying. :)

Alright, an asset and its metadata are either two things or one thing.
After some reading I'm beginning to see the reason behind your strong
conviction. In  the interest of not changing the DB schema, let's try
to solve this by treating the asset data and its metadata as one object.

To do this, the AssetBase class can inherit from the AssetMetadata
class. The result would be as follows:

  class AssetMetadata
  {
    string _name;
    string _description;
    // etc...

    public virtual string Name
    {
      get { return _name; }
      set { _name = value; }
    }
    // etc
  }

  class AssetBase : AssetMetadata
  {
    byte[] _data;

    public virtual byte[] Data
    {
      get { return _data; }
      set { _data = value; }
    }
  }

This way the AssetBase class pretty much remains as-is, and the
AssetMetadata class can be used on its own to represent just the
metadata. One class (AssetBase) mapped to one table (assets), and no
changes to the mappers are necessary.

Would this work? One thing I'm not sure about is how NHibernate would
handle fetching only metadata or persisting AssetMetadata objects. This
is pretty straightforward in the other AssetStores already in OpenSim.

Thanks,
Mike



More information about the Opensim-dev mailing list