XIndex tables work with the following IData successors internally available in STSdb W4.0:

    public interface IData
    {
    }
    public class Data<TSlot0> : IData
    {
        public TSlot0 Slot0;
    }
    
    public class Data<TSlot0, TSlot1> : IData
    {
        public TSlot0 Slot0;
        public TSlot1 Slot1;
    }
    
    public class Data<TSlot0, TSlot1, TSlot2> : IData
    {
        public TSlot0 Slot0;
        public TSlot1 Slot1;
        public TSlot2 Slot2;
    }
    
    ...

Current version supports Data classes with up to 64 slots for keys and records. Each slot can be from any primitive type available in 1.1.

The code below shows the example from [1] but working with the non-generic XIndex class directly:

//writing
    using (IStorageEngine engine = STSdb.FromFile("stsdb4.sys", "stsdb4.dat"))
    {
        IIndex<IData, IData> table = engine.OpenXIndex(DataType.Int32, DataType.String, "table");

        for (int i = 0; i < 1000000; i++)
        {
            table[new Data<int>(i)] = new Data<string>(i.ToString());
        }

        table.Flush();
        engine.Commit();
    }


    //reading
    using (IStorageEngine engine = STSdb.FromFile("stsdb4.sys", "stsdb4.dat"))
    {
        IIndex<IData, IData> table = engine.OpenXIndex(DataType.Int32, DataType.String, "table");

        foreach (var row in table) //table.Forward(), table.Backward()
        {
            Data<int> key = (Data<int>)row.Key;
            Data<string> record = (Data<string>)row.Value;

            Console.WriteLine("{0} 1}", key.Slot0, record.Slot0);
        }
    }

Last edited Aug 17, 2013 at 9:51 AM by SvetoslavMateev, version 1

Comments

No comments yet.