Пример #1
0
        void GetRowsResponseMessageHandler(GetRowsResponseMessage message)
        {
            Console.WriteLine("GetRowsResponseMessageReceived()");
            GetRowsResponseMessage GRRM = (GetRowsResponseMessage)message;
            Table table = tableDataRequests [GRRM.RequestID];

            BD2.Frontend.Table.Model.Table frontendTable = frontendInstance.GetTable(table.Name);
            frontendInstance.Flush();
            List <BD2.Frontend.Table.Model.Column> fcs = new List <BD2.Frontend.Table.Model.Column> ();

            Console.WriteLine("Table: {0}", table.Name);
            Console.WriteLine("Enumerating columns...");
            if (!tableColumns.ContainsKey(table))
            {
                Console.WriteLine("tableColumns doesn't have the key");
            }
            Console.WriteLine("Column Count: {0}", tableColumns [table].Count);

            foreach (Column c in tableColumns[table])
            {
                BD2.Frontend.Table.Model.Column frontendColumn = frontendInstance.GetColumn(c.Name, System.Type.GetType(c.TFQN), !c.Mandatory, c.Size);
                int cc = fcs.Count;
                fcs.Add(frontendColumn);
                if (fcs.Count == cc)
                {
                    throw new Exception("FATAL column ID collision detected");
                }
                //TODO:Avoid creating duplicates,create columnsets for each table, Associate columnSets and tables, Add data to tables
            }
            frontendInstance.Flush();
            int rc = 0;

            BD2.Frontend.Table.Column[] cols = new BD2.Frontend.Table.Column[fcs.Count];
            fcs.CopyTo(cols);
            BD2.Frontend.Table.Model.ColumnSet columnSet = frontendInstance.GetColumnSet(cols);
            frontendInstance.Flush();
            foreach (BD2.Conv.Frontend.Table.Row r in message.Rows)
            {
                frontendInstance.CreateRow(frontendTable, columnSet, new byte[][] { }, r.Fields);
                rc++;
            }
            Console.WriteLine(rc);
            frontendInstance.Flush();
            AREGetRows.Set();
        }
Пример #2
0
        public static void Main(string[] args)
        {
            typeof(BD2.Frontend.Table.Row).GetCustomAttributes(true);
            typeof(BD2.Frontend.Table.Table).GetCustomAttributes(true);
            typeof(BD2.Frontend.Table.Relation).GetCustomAttributes(true);
            typeof(BD2.Frontend.Table.Column).GetCustomAttributes(true);
            typeof(BD2.Frontend.Table.ColumnSet).GetCustomAttributes(true);
            string databaseName = "Esfand";

            BD2.Core.Database db = new BD2.Core.Database(new BD2.Chunk.ChunkRepository[] { new BD2.Repo.Leveldb.Repository("/home/behrooz/Test") },
                                                         new BD2.Core.FrontendBase[] { new BD2.Frontend.Table.Frontend(new BD2.Frontend.Table.GenericValueDeserializer()) }, new byte[] { }, databaseName);
            BD2.Frontend.Table.FrontendInstance frontendInstance =
                (BD2.Frontend.Table.FrontendInstance)(db.GetFrontend("BD2.Frontend.Table")).GetInstanse(db.GetSnapshot("Primary"));
            //use the db here
            BD2.Frontend.Table.Table M = (BD2.Frontend.Table.Table)frontendInstance.GetTable("Moshtary");
            foreach (var R in frontendInstance.GetRows(M))
            {
                object[] values = R.GetValues();
                values [0] = null;
                frontendInstance.CreateRow(M, R.ColumnSet, new byte[][] { R.ObjectID }, values);
            }
            //
            frontendInstance.Flush();
        }