private static JournalMetadata CreateMetadata <T>(EPartitionType configValue,
                                                          string workingDir, params string[] symbols)
        {
            var jconf = new JournalElement
            {
                DefaultPath   = workingDir,
                PartitionType = configValue
            };

            if (symbols != null)
            {
                foreach (string sym in symbols)
                {
                    var se = new SymbolElement
                    {
                        AvgSize           = 20,
                        HintDistinctCount = 100,
                        MaxSize           = 120,
                        Name = sym
                    };
                    jconf.Columns.Add(se);
                }
            }
            var meta = JournalBuilder.CreateNewJournalMetadata(jconf, typeof(T));

            return(meta);
        }
        private JournalMetadata CreateMetadata <T>(JournalElement conf = null, string[] privateFields = null)
        {
            var settings = conf ?? new JournalElement();
            var meta     = JournalBuilder.CreateNewJournalMetadata(settings, typeof(T));

            return(meta);
        }
        public string ShouldCheckColumsMatch(string colNames)
        {
            var noConfMeta = CreateMetadata <FieldTypes>();

            var conf = new JournalElement
            {
                Columns = colNames.Split(new[] { ',' })
                          .Select(n =>
                {
                    var column = noConfMeta.GetColumnByPropertyName(n);
                    return(column.DataType.ColumnType == EFieldType.String
                            ? new StringElement {
                        Name = n
                    }
                            : new ColumnElement {
                        Name = n, ColumnType = column.DataType.ColumnType
                    });
                }).ToList(),
                FromDisk = true
            };

            var meta = CreateMetadata <FieldTypes>(conf);

            return(string.Join(",", meta.Columns.Select(c => c.PropertyName)));
        }
示例#4
0
 public static IJournal <T> CreateJournal <T>(JournalElement config, EFileAccess access = EFileAccess.Read)
 {
     return(new JournalBuilder(config ?? ReadConfig <T>())
            .WithAccess(access)
            .WithSerializerFactoryName(MetadataConstants.THRIFT_SERIALIZER_NAME)
            .ToJournal <T>());
 }
示例#5
0
 public static IJournal <T> CreateJournal <T>(JournalElement config, TimeSpan latency, EFileAccess access = EFileAccess.Read)
 {
     return(new JournalBuilder(config)
            .WithAccess(access)
            .WithSerializerFactoryName(MetadataConstants.THRIFT_SERIALIZER_NAME)
            .WithServerTasksLatency(latency)
            .ToJournal <T>());
 }
        private static string ExecuteLamdaOnJournal <TKey>(Func <IQueryable <Quote>, IQueryable <Quote> > lambda, int increment,
                                                           JournalElement config, Expression <Func <Quote, TKey> > latestBy, bool createNulls = false)
        {
            using (var qj = Utils.CreateJournal <Quote>(config, EFileAccess.ReadWrite))
            {
                AppendRecords(qj, 0, increment, createNulls);
                var rdr = qj.OpenReadTx();

                var qts = lambda(rdr.Items.LatestBy(latestBy));

                // Act.
                var result = qts.AsEnumerable().Select(q => q.Timestamp);

                // Verify.
                return(string.Join(",", result));
            }
        }
示例#7
0
 private IJournal <T> CreateJournal <T>(JournalElement config, EFileAccess readWrite = EFileAccess.Read)
 {
     return(new JournalBuilder(config).WithAccess(readWrite).ToJournal <T>());
 }
 public RecordSerializerFactory(JournalElement config)
 {
     _config = config;
 }
示例#9
0
    public void AddElementToViewport(string ItemNameString, string ToolTipString, string SpriteResourceString)
    {
        ResizeContentWindow();
        GameObject    newObj = new GameObject(ItemNameString);
        RectTransform rect   = newObj.AddComponent <RectTransform>();

        //Resize the rect so it fits better in the background
        rect.sizeDelta = ItemSpriteSize;

        //Load a sprite from the string
        Sprite         ImageSprite    = Resources.Load <Sprite>("Items/Sprites/" + SpriteResourceString);
        JournalElement JournalElement = rect.gameObject.AddComponent <JournalElement>();

        //Add selectable component and add to list
        rect.gameObject.AddComponent <Selectable>();
        m_JournalElements.Add(rect.gameObject.GetComponent <Selectable>());

        //set up selectable navigation
        for (int i = 0; i < m_JournalElements.Count; i++)
        {
            Navigation elementNav = m_JournalElements[i].navigation;

            if (elementNav.mode != Navigation.Mode.Explicit)
            {
                elementNav.mode = Navigation.Mode.Explicit;
            }

            //if first item in journal
            if (i == 0 && m_JournalElements.Count > 1)
            {
                elementNav.selectOnUp    = m_JournalElements[m_JournalElements.Count - 1];
                elementNav.selectOnLeft  = m_JournalElements[m_JournalElements.Count - 1];
                elementNav.selectOnDown  = m_JournalElements[1];
                elementNav.selectOnRight = m_JournalElements[1];
            }
            else if (i != 0 && i != m_JournalElements.Count - 1) //if journal element in between the first and last
            {
                elementNav.selectOnUp    = m_JournalElements[i - 1];
                elementNav.selectOnLeft  = m_JournalElements[i - 1];
                elementNav.selectOnDown  = m_JournalElements[i + 1];
                elementNav.selectOnRight = m_JournalElements[i + 1];
            }
            else if (i != 0 && i == m_JournalElements.Count - 1) //if last element in journal
            {
                elementNav.selectOnUp    = m_JournalElements[i - 1];
                elementNav.selectOnLeft  = m_JournalElements[i - 1];
                elementNav.selectOnDown  = m_JournalElements[0];
                elementNav.selectOnRight = m_JournalElements[0];
            }

            m_JournalElements[i].navigation = elementNav;
        }

        //if the first item in the list has has not been set yet, set it
        if (firstItemInJournal == null)
        {
            firstItemInJournal = rect.gameObject;
        }

        //Add a background to the item that is being added
        GameObject    BackgroundObj    = new GameObject("ItemBackground");
        RectTransform BackgroundRect   = BackgroundObj.AddComponent <RectTransform>();
        Sprite        BackgroundSprite = Resources.Load <Sprite>(BackgroundSpritePath);
        Image         BackgroundImage  = BackgroundObj.AddComponent <Image>();

        BackgroundImage.sprite = BackgroundSprite;
        //Have the background be the parent object to ensure the sprite draws on top
        BackgroundObj.transform.SetParent(ContentWindow);

        //Initialize a new Journal element and add it to the content's children
        JournalElement.Init(ImageSprite, SpriteResourceString, ToolTipString, ContentWindow);
        newObj.transform.SetParent(BackgroundObj.transform);
    }
 private static string ExecuteLamdaOnJournal(Func <IQueryable <Quote>, IQueryable <Quote> > lambda,
                                             int increment,
                                             JournalElement config, bool createNulls = false)
 {
     return(ExecuteLamdaOnJournal(lambda, increment, config, q => q.Sym, createNulls));
 }