예제 #1
0
        bool Equals(StringListComparer other)
        {
            if (ReferenceEquals(_key, other._key))
            {
                return(true);
            }
            if (_key == null || other._key == null)
            {
                return(false);
            }

            if (_key.Count != other._key.Count)
            {
                return(false);
            }

            for (int i = 0; i < _key.Count; i++)
            {
                string a = _key[i];
                string b = other._key[i];
                if (string.CompareOrdinal(a, b) != 0)
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #2
0
        public void GetLevels(Thrift.ColumnChunk columnChunk, out int maxRepetitionLevel, out int maxDefinitionLevel)
        {
            maxRepetitionLevel = 0;
            maxDefinitionLevel = 0;

            int           i    = 0;
            List <string> path = columnChunk.Meta_data.Path_in_schema;

            var comparer = new StringListComparer(path);

            if (_memoizedLevels.TryGetValue(comparer, out Tuple <int, int> t))
            {
                maxRepetitionLevel = t.Item1;
                maxDefinitionLevel = t.Item2;
                return;
            }

            int fieldCount = _fileMeta.Schema.Count;

            foreach (string pp in path)
            {
                while (i < fieldCount)
                {
                    SchemaElement schemaElement = _fileMeta.Schema[i];
                    if (string.CompareOrdinal(schemaElement.Name, pp) == 0)
                    {
                        Thrift.SchemaElement se = schemaElement;

                        bool repeated = (se.__isset.repetition_type && se.Repetition_type == Thrift.FieldRepetitionType.REPEATED);
                        bool defined  = (se.Repetition_type == Thrift.FieldRepetitionType.REQUIRED);

                        if (repeated)
                        {
                            maxRepetitionLevel += 1;
                        }
                        if (!defined)
                        {
                            maxDefinitionLevel += 1;
                        }

                        break;
                    }

                    i++;
                }
            }

            _memoizedLevels.Add(comparer, Tuple.Create(maxRepetitionLevel, maxDefinitionLevel));
        }