Results 1 to 4 of 4

Thread: Struct support ?

  1. #1
    Junior Member
    Join Date
    Oct 2015
    Posts
    5

    Default Struct support ?

    Hi,

    I need some help. I'm trying to test your Key/value store engine (v 4.0.8) for a new Social Network plateform writen un C# (large parts in unsafe code to use native memory to avoid GC pauses). But it doesn't work. As a Key for my tables, i'm using a simple struct. This struct is used as field type in various key types too. I've discover that structs are not supported, only classes are supported both as key and value.

    My struct is the above :

    [System.Runtime.InteropServices.StructLayout(LayoutKind.Explicit)]
        public struct UOId : IFormattable, IComparable, IComparable<UOId>, IEquatable<UOId> {
            public static int _STRING_LENGHT = 23;
            private static int[] chrv = null;
            private static object _locker;
            private static UOId _baseId = new UOId();
            private static ulong _incrementalId = 1;
    
    
            [System.Runtime.InteropServices.FieldOffset(0)]
            public ulong _objectId;
    
    
            [System.Runtime.InteropServices.FieldOffset(6)]
            public ushort _serverId;
    
    
            [System.Runtime.InteropServices.FieldOffset(5)]
            public byte _flags;
    
    
            // -------- For encoding
            [System.Runtime.InteropServices.FieldOffset(0)]
            public byte _high;
    
    
            [System.Runtime.InteropServices.FieldOffset(7)]
            public byte _low;
    
    ....
    
    You can see that the struct is an ulong over wich are wrapped some sub fields. It's a basic technic to build fast composed sortable identifiers.

    At this time i'm blocked by this problem. Perhaps there is a simple technic to use this struct both as key and as field type in various classes used as key ?

    Thank you.

  2. #2
    Junior Member
    Join Date
    Oct 2015
    Posts
    5

    Default

    Precision : by starting from the sample code, this doesn't work anymore...

    public struct Key {
    public string Symbol { get; set; }
    public DateTime Timestamp { get; set; }
    }

  3. #3

    Default

    Greetins.

    Structs are supported by the engine. We will review your case.

    Thank you for the report!

  4. #4

    Default

    Greetings.


    There was a bug which is now fixed.
    You can download the latest version with the bug fix 4.0.0: Downloads.


    Thank you for your report!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
2002 - 2014 STS Soft SC. All Rights reserved.
STSdb, Waterfall Tree and WTree are registered trademarks of STS Soft SC.