Skip to content

Commit

Permalink
Merge pull request #24 from mukunku/v2.2.1
Browse files Browse the repository at this point in the history
fix: fill weight overflow when there are too many columns (#22)
  • Loading branch information
mukunku authored Dec 8, 2020
2 parents 149b13b + 54721d8 commit bd28852
Show file tree
Hide file tree
Showing 8 changed files with 358 additions and 324 deletions.
13 changes: 13 additions & 0 deletions src/ParquetFileViewer/Constants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ParquetFileViewer
{
public static class Constants
{
public const string FILL_WEIGHT_EXCEPTION_MESSAGE = "FillWeight";
}
}
Original file line number Diff line number Diff line change
@@ -1,72 +1,72 @@
using System;
using System.Windows.Forms;

namespace ParquetFileViewer
{
public class DelayedOnChangedTextBox : TextBox
{
private Timer m_delayedTextChangedTimer;

public event EventHandler DelayedTextChanged;

public DelayedOnChangedTextBox()
: base()
{
this.DelayedTextChangedTimeout = 1 * 1000;
}

public DelayedOnChangedTextBox(int secondsDelay)
: base()
{
this.DelayedTextChangedTimeout = secondsDelay * 1000;
}

protected override void Dispose(bool disposing)
{
if (m_delayedTextChangedTimer != null)
{
m_delayedTextChangedTimer.Stop();
if (disposing)
m_delayedTextChangedTimer.Dispose();
}

base.Dispose(disposing);
}

public int DelayedTextChangedTimeout { get; set; }

protected virtual void OnDelayedTextChanged(EventArgs e)
{
this.DelayedTextChanged?.Invoke(this, e);
}

protected override void OnTextChanged(EventArgs e)
{
this.InitializeDelayedTextChangedEvent();
base.OnTextChanged(e);
}

private void InitializeDelayedTextChangedEvent()
{
if (m_delayedTextChangedTimer != null)
m_delayedTextChangedTimer.Stop();

if (m_delayedTextChangedTimer == null || m_delayedTextChangedTimer.Interval != this.DelayedTextChangedTimeout)
{
m_delayedTextChangedTimer = new Timer();
m_delayedTextChangedTimer.Tick += new EventHandler(HandleDelayedTextChangedTimerTick);
m_delayedTextChangedTimer.Interval = this.DelayedTextChangedTimeout;
}

m_delayedTextChangedTimer.Start();
}

private void HandleDelayedTextChangedTimerTick(object sender, EventArgs e)
{
Timer timer = sender as Timer;
timer.Stop();

this.OnDelayedTextChanged(EventArgs.Empty);
}
}
}
using System;
using System.Windows.Forms;

namespace ParquetFileViewer.Controls
{
public class DelayedOnChangedTextBox : TextBox
{
private Timer m_delayedTextChangedTimer;

public event EventHandler DelayedTextChanged;

public DelayedOnChangedTextBox()
: base()
{
this.DelayedTextChangedTimeout = 1 * 1000;
}

public DelayedOnChangedTextBox(int secondsDelay)
: base()
{
this.DelayedTextChangedTimeout = secondsDelay * 1000;
}

protected override void Dispose(bool disposing)
{
if (m_delayedTextChangedTimer != null)
{
m_delayedTextChangedTimer.Stop();
if (disposing)
m_delayedTextChangedTimer.Dispose();
}

base.Dispose(disposing);
}

public int DelayedTextChangedTimeout { get; set; }

protected virtual void OnDelayedTextChanged(EventArgs e)
{
this.DelayedTextChanged?.Invoke(this, e);
}

protected override void OnTextChanged(EventArgs e)
{
this.InitializeDelayedTextChangedEvent();
base.OnTextChanged(e);
}

private void InitializeDelayedTextChangedEvent()
{
if (m_delayedTextChangedTimer != null)
m_delayedTextChangedTimer.Stop();

if (m_delayedTextChangedTimer == null || m_delayedTextChangedTimer.Interval != this.DelayedTextChangedTimeout)
{
m_delayedTextChangedTimer = new Timer();
m_delayedTextChangedTimer.Tick += new EventHandler(HandleDelayedTextChangedTimerTick);
m_delayedTextChangedTimer.Interval = this.DelayedTextChangedTimeout;
}

m_delayedTextChangedTimer.Start();
}

private void HandleDelayedTextChangedTimerTick(object sender, EventArgs e)
{
Timer timer = sender as Timer;
timer.Stop();

this.OnDelayedTextChanged(EventArgs.Empty);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Text;
using System.Threading.Tasks;

namespace ParquetFileViewer
namespace ParquetFileViewer.Helpers
{
public class CustomScriptBasedSchemaAdapter
{
Expand Down Expand Up @@ -135,11 +135,11 @@ private string MakeList(DataColumnCollection columns)
{
if (!flag)
{
stringBuilder.Append(", ");
stringBuilder.Append(" , ");
}
string str = this.MakeSafe(column.ColumnName);
string typeFor = this.GetTypeFor(column);
stringBuilder.AppendFormat("{0} {1}", str, typeFor);
stringBuilder.Append($"{Environment.NewLine} {str} {typeFor}");
flag = false;
}
return stringBuilder.ToString();
Expand Down
24 changes: 24 additions & 0 deletions src/ParquetFileViewer/Helpers/ExtensionMethods.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Collections.Generic;
using System.Data;
using System.Windows.Forms;

namespace ParquetFileViewer.Helpers
{
public static class ExtensionMethods
{
/// <summary>
/// Returns a list of all column names within a given datatable
/// </summary>
/// <param name="datatable">The datatable to retrieve the column names from</param>
/// <returns></returns>
public static IList<string> GetColumnNames(this DataTable datatable)
{
List<string> columns = new List<string>(datatable.Columns.Count);
foreach (DataColumn column in datatable.Columns)
{
columns.Add(column.ColumnName);
}
return columns;
}
}
}
Loading

0 comments on commit bd28852

Please sign in to comment.