Git Product home page Git Product logo

sterlingdb's People

Contributors

jplane avatar petermorlion avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sterlingdb's Issues

Deserializing WriteableBitmap throws exception on WinRT

Hello,

I have an object that has a WriteableBitmap property. When deserializing this on WinRT the following exception is thrown. I'm using await when I invoke LoadAsync. Invoking LoadAsync inside dispatcher.RunAsync does not help. Can you help please?

many thanks,

Remco

   HResult=-2147417842
   Message=The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD))
   Source=Windows.UI.Xaml
   StackTrace:
        at Windows.UI.Xaml.Media.Imaging.WriteableBitmap..ctor(Int32 pixelWidth, Int32 pixelHeight)
        at Wintellect.Sterling.WinRT.PlatformAdapter.<GetBitmapSerializer>b__5(BinaryReader br) in c:\Users\Remco\Downloads\SterlingDB-master\SterlingDB-master\Wintellect.Sterling.WinRT\PlatformAdapter.cs:line 85
        at Wintellect.Sterling.Core.Serialization.ExtendedSerializer.Deserialize(Type type, BinaryReader reader) in c:\Users\Remco\Downloads\SterlingDB-master\SterlingDB-master\Wintellect.Sterling.Core\Serialization\ExtendedSerializer.cs:line 123
        at Wintellect.Sterling.Core.Serialization.AggregateSerializer.<>c__DisplayClass7.<CanSerialize>b__4(BinaryReader reader) in c:\Users\Remco\Downloads\SterlingDB-master\SterlingDB-master\Wintellect.Sterling.Core\Serialization\AggregateSerializer.cs:line 79
        at Wintellect.Sterling.Core.Serialization.AggregateSerializer.Deserialize(Type type, BinaryReader reader) in c:\Users\Remco\Downloads\SterlingDB-master\SterlingDB-master\Wintellect.Sterling.Core\Serialization\AggregateSerializer.cs:line 148
        at Wintellect.Sterling.Core.Serialization.SerializationHelper._Deserialize(BinaryReader br, CycleCache cache) in c:\Users\Remco\Downloads\SterlingDB-master\SterlingDB-master\Wintellect.Sterling.Core\Serialization\SerializationHelper.cs:line 541
        at Wintellect.Sterling.Core.Serialization.SerializationHelper._IteratePropertiesUntilEndOfFileIsReached(BinaryReader br, CycleCache cache, Type typeResolved, Object instance) in c:\Users\Remco\Downloads\SterlingDB-master\SterlingDB-master\Wintellect.Sterling.Core\Serialization\SerializationHelper.cs:line 603
        at Wintellect.Sterling.Core.Serialization.SerializationHelper.Load(Type type, Object key, BinaryReader br, CycleCache cache) in c:\Users\Remco\Downloads\SterlingDB-master\SterlingDB-master\Wintellect.Sterling.Core\Serialization\SerializationHelper.cs:line 473
        at Wintellect.Sterling.Core.Database.BaseDatabaseInstance.<_Load>d__44`1.MoveNext() in c:\Users\Remco\Downloads\SterlingDB-master\SterlingDB-master\Wintellect.Sterling.Core\Database\BaseDatabaseInstance.cs:line 774

Add cache functionality

Is it possible to add different caching strategies, so you can configure data to automatically expire and be removed from sterling db.

For example rolling cache, so data older than month auto expires and be removed. Make this configurable for all objects in the object tree.

Example: contact.Picture.Expires(new TimeSpan())

This will be very helpful when storing large amounts of data on budget devices.

Integrating this option in sterling could be much better for performance.

Loading objects for a specified type fail

When calling the load Method T equals FeedItem. In the lambda I get an exception because it is read from db in a different object. This problem only occurs when the application is restarted on my Phone. As long as the application keeps running all queries and succeed.

//BaseDatabaseInstance.cs
public ITableDefinition CreateTableDefinition<T, TKey>(Func<T, TKey> keyFunction) where T : class, new()
        {
            return new TableDefinition<T, TKey>(Driver,
                                                ( key => _Load<T>( typeof( T ), key, new CycleCache() ).Result ),
                                                keyFunction);
        }

The call to _Load eventually reaches this code in SerializationHelper... Where on line 408 (last line in this snippet) the code creates an instance of type FeedItem. So Far so Good.

/// <summary>
        ///     Recursive load operation
        /// </summary>
        /// <param name="type">The type to save (passed to support NULL)</param>
        /// <param name="key">The associated key (for cycle detection)</param>
        /// <param name="br">The reader</param>
        /// <param name="cache">Cycle cache</param>
        public object Load(Type type, object key, BinaryReader br, CycleCache cache)
        {
            _logManager.Log(SterlingLogLevel.Verbose,
                            string.Format("Sterling is de-serializing type {0}", type.FullName), null);

            if (_DeserializeNull(br))
            {
                return null;
            }

            // make a template
            var instance = Activator.CreateInstance(type);

In this same method eventually we reach following code (line 455) Here the typeIndexer suddenly changes the type to Notification. This is where everything fails. Since Notification is a totally different type.

            else
            {
                type = Type.GetType(_typeIndexer(br.ReadInt32()));
                if (instance.GetType() != type)
                {
                    instance = Activator.CreateInstance(type);
                }

                // push to the stack
                cache.Add(type, instance, key);

                // build the reflection cache);
                if (!_propertyCache.ContainsKey(type))
                {
                    //_CacheProperties(type);
                    _CacheProperties(type);
                }
            }

This is my database format

public class MyDatabase : BaseDatabaseInstance
    {
        public const string FeedItemInstanceIdIndex = "FeedItemInstanceIdIndex";
        public const string NotificationInstanceIdIndex = "NotificationInstanceIdIndex";
        public const string NotificationUnreadIndex = "NotificationUnreadIndex";

        protected override List<ITableDefinition> RegisterTables()
        {
            return new List<ITableDefinition>
            {
                CreateTableDefinition<Instance, int>(i => i.Id),
                CreateTableDefinition<FeedItem, int>(f => f.Id)
                    .WithIndex<FeedItem, int, int>(FeedItemInstanceIdIndex, fi => fi.InstanceId),
                CreateTableDefinition<Notification, int>(n => n.Id)
                    .WithIndex<Notification, int, int>(NotificationInstanceIdIndex, n => n.InstanceId)
                    .WithIndex<Notification, bool, int>(NotificationUnreadIndex, n => n.Unread)
            };
        }
    }

Any Idea how to solve this?

Any releases?

Are there any planned nuget releases of this Sterling Fork?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.