private bool TryBuildNextCell(Field f, Dictionary <string, LazyColumnEnumerator> pathToColumn, out object cell) { switch (f.SchemaType) { case SchemaType.Data: LazyColumnEnumerator dce = pathToColumn[f.Path]; //MoveNext returns either an element or a list-like structure for columns that are repeated if (!dce.MoveNext()) { cell = null; return(false); } cell = dce.Current; break; case SchemaType.Map: bool mcok = TryBuildMapCell((MapField)f, pathToColumn, out IReadOnlyList <Row> mapRow); cell = mapRow; return(mcok); case SchemaType.Struct: bool scok = TryBuildStructCell((StructField)f, pathToColumn, out Row scRow); cell = scRow; return(scok); case SchemaType.List: return(TryBuildListCell((ListField)f, pathToColumn, out cell)); default: throw OtherExtensions.NotImplemented(f.SchemaType.ToString()); } return(true); }
private static object CreateElement(Field field, int index, Dictionary <string, IList> columns) { if (field.SchemaType == SchemaType.Map) { return(((MapField)field).CreateCellValue(columns, index)); } else if (field.SchemaType == SchemaType.Struct) { return(Extract(((StructField)field).Fields, index, columns)); } else if (field.SchemaType == SchemaType.List) { ListField lf = (ListField)field; if (lf.Item.SchemaType == SchemaType.Struct) { StructField structField = (StructField)lf.Item; Dictionary <string, IList> elementColumns = CreateFieldColumns(structField.Fields, index, columns, out int count); var rows = new List <Row>(count); for (int i = 0; i < count; i++) { Row row = Extract(structField.Fields, i, elementColumns); rows.Add(row); } return(rows); } else if (lf.Item.SchemaType == SchemaType.Data) { DataField dataField = (DataField)lf.Item; IList values = GetFieldPathValues(dataField, index, columns); return(values); } else { throw OtherExtensions.NotImplementedForPotentialAssholesAndMoaners($"reading {lf.Item.SchemaType} from lists"); } } else { if (!columns.TryGetValue(field.Path, out IList values)) { throw new ParquetException($"something terrible happened, there is no column by name '{field.Name}' and path '{field.Path}'"); } return(values[index]); } }
public MainViewInteractionsVM() { Application.Current.MainWindow.KeyDown += (s, e) => { switch (e.Key) { case Key.Q: OpenQuestionsAnimationTrigger = OtherExtensions.ReverceAnimationTriggerValue(OpenQuestionsAnimationTrigger); break; } }; SettingsIconClickCommand = new DelegateCommand(() => OpenSettingsAnimationTrigger = OtherExtensions.ReverceAnimationTriggerValue(OpenSettingsAnimationTrigger) ); }
private static Dictionary <string, IList> CreateFieldColumns( IEnumerable <Field> fields, int index, Dictionary <string, IList> columns, out int count) { var elementColumns = new Dictionary <string, IList>(); count = int.MaxValue; foreach (Field field in fields) { string key = field.Path; switch (field.SchemaType) { case SchemaType.Data: IList value = columns[key][index] as IList; elementColumns[key] = value; if (value.Count < count) { count = value.Count; } break; case SchemaType.List: var listField = (ListField)field; Dictionary <string, IList> listColumns = CreateFieldColumns(new[] { listField.Item }, index, columns, out int listCount); elementColumns.AddRange(listColumns); count = Math.Min(count, listColumns.Min(kvp => kvp.Value.Count)); break; case SchemaType.Struct: var structField = (StructField)field; Dictionary <string, IList> structColumns = CreateFieldColumns(structField.Fields, index, columns, out int structCount); elementColumns.AddRange(structColumns); count = Math.Min(count, structColumns.Min(kvp => kvp.Value.Count)); break; default: throw OtherExtensions.NotImplementedForPotentialAssholesAndMoaners($"extracting {field.SchemaType} columns"); } } return(elementColumns); }
public static IDataTypeHandler Match(Field field) { switch (field.SchemaType) { case SchemaType.Struct: return(new StructureDataTypeHandler()); case SchemaType.Map: return(new MapDataTypeHandler()); case SchemaType.List: return(new ListDataTypeHandler()); case SchemaType.Data: return(Match(((DataField)field).DataType)); default: throw OtherExtensions.NotImplemented($"matching {field.SchemaType}"); } }
static void AddList(Dictionary <string, IList> columns, ListField listField, object value) { /* * Value slicing can happen only when entering a list and in no other cases. * Only list is changing hierarchy dramatically. */ switch (listField.Item.SchemaType) { case SchemaType.Struct: StructField structField = (StructField)listField.Item; IEnumerable <Row> rows = value as IEnumerable <Row>; var deepColumns = new Dictionary <string, IList>(); foreach (Row row in rows) { Append(deepColumns, structField.Fields, row); } SliceIn(columns, deepColumns); break; case SchemaType.Data: DataField dataField = (DataField)listField.Item; IDataTypeHandler handler = DataTypeFactory.Match(dataField); IList values = handler.CreateEmptyList(dataField.HasNulls, dataField.IsArray, 0); foreach (object v in (IEnumerable)value) { values.Add(v); } GetValues(columns, dataField, true, true).Add(values); break; default: throw OtherExtensions.NotImplementedForPotentialAssholesAndMoaners($"adding {listField.Item.SchemaType} to list"); } }
public void GetNameTest() { Assert.AreEqual(int.MaxValue.ToString(), OtherExtensions.GetName <int, int>(x => int.MaxValue)); }
public void GetNameTest2() { Assert.AreEqual("32", OtherExtensions.GetName <int, int>(x => 32)); }
private void WriteBitpacked() { //int header = 0x1; throw OtherExtensions.NotImplementedForPotentialAssholesAndMoaners("bitpacked encoding"); }
public int[] getPrimes(int iFrom, int iTo) { return(OtherExtensions.Slice(_iaPrimes, iFrom, iTo)); }