Skip to content

Review sample file columns and apps. #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ApacheOrcDotNet.OptimizedReaderTest.App/Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ namespace ApacheOrcDotNet.OptimizedReaderTest.App
{
public class Configs
{
public string Source { get; set; }
public string Symbol { get; set; }
public string Vendor { get; set; }
public string Product { get; set; }
public TimeSpan BeginTime { get; set; }
public TimeSpan EndTime { get; set; }
}
Expand Down
8 changes: 4 additions & 4 deletions src/ApacheOrcDotNet.OptimizedReaderTest.App/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ namespace ApacheOrcDotNet.OptimizedReaderTest.App
{
public class Item
{
public string Source { get; set; }
public string Symbol { get; set; }
public decimal? Time { get; set; }
public long? Size { get; set; }
public string StringDictionaryV2 { get; set; }
public string StringDirectV2 { get; set; }
public decimal? Decimal { get; set; }
public long? Integer { get; set; }
public DateTime? Date { get; set; }
public double? Double { get; set; }
public float? Float { get; set; }
Expand Down
25 changes: 12 additions & 13 deletions src/ApacheOrcDotNet.OptimizedReaderTest.App/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ static async Task Main(string[] args)
;

var uri = config.GetValue("uri", string.Empty);
var source = config.GetValue("source", string.Empty);
var symbol = config.GetValue("symbol", string.Empty);
var vendor = config.GetValue("vendor", string.Empty);
var product = config.GetValue("product", string.Empty);
var beginTime = config.GetValue("beginTime", "00:00:00");
var endTime = config.GetValue("endTime", "23:45:00");

var isValidBeginTime = TimeSpan.TryParse(beginTime, CultureInfo.InvariantCulture, out var parsedBeginTime);
var isValidEndTime = TimeSpan.TryParse(endTime, CultureInfo.InvariantCulture, out var parsedEndTime);

if (uri.Length ==0 || source.Length == 0 || symbol.Length == 0 || !isValidBeginTime || !isValidEndTime || (parsedEndTime < parsedBeginTime))
if (uri.Length ==0 || vendor.Length == 0 || product.Length == 0 || !isValidBeginTime || !isValidEndTime || (parsedEndTime < parsedBeginTime))
{
Console.WriteLine("Usage: --uri orcFileUri --source sourceName --symbol symbolName --beginTime hh:mm:ss --endTime hh:mm:ss");
Console.WriteLine("Usage: --uri orcFileUri --vendor vendorName --product productName --beginTime hh:mm:ss --endTime hh:mm:ss");
Console.WriteLine();
Console.WriteLine("Examples:");
Console.WriteLine(@" dotnet run --uri file://c:/path/to/testFile.orc --source CTSPillarNetworkB --symbol SPY --beginTime 09:43:20 --endTime 09:43:21");
Console.WriteLine(@" dotnet run --uri https://s3.amazonaws.com/some/path/testFile.orc --source CTSPillarNetworkB --symbol SPY --beginTime 09:43:20 --endTime 09:43:21");
Console.WriteLine(@" dotnet run --uri file://c:/path/to/testFile.orc --vendor xyz --product test --beginTime 09:43:20 --endTime 09:43:21");
Console.WriteLine(@" dotnet run --uri https://s3.amazonaws.com/some/path/testFile.orc --vendor xyz --product test --beginTime 09:43:20 --endTime 09:43:21");
Console.WriteLine();
Console.WriteLine(@" You can use files under ApacheOrcDotNet.OptimizedReader.Test/Data to test the readers:");
Console.WriteLine(@" - optimized_reader_test_file.orc");
Expand All @@ -45,16 +45,16 @@ static async Task Main(string[] args)
Console.WriteLine("Running.. CTRL+C to exit.");
Console.WriteLine();
Console.WriteLine($"Pid: {Environment.ProcessId}");
Console.WriteLine($"source: '{source}'");
Console.WriteLine($"symbol: '{symbol}'");
Console.WriteLine($"vendor: '{vendor}'");
Console.WriteLine($"product: '{product}'");
Console.WriteLine($"beginTime: '{beginTime}'");
Console.WriteLine($"endTime: '{endTime}'");
Console.WriteLine();

var configs = new Configs
{
Source = source,
Symbol = symbol,
Vendor = vendor,
Product = product,
BeginTime = parsedBeginTime,
EndTime = parsedEndTime
};
Expand All @@ -79,9 +79,8 @@ static async Task Main(string[] args)
//await (new ReadFilteredApp(uri, configs, fileByteRangeProviderFactory)).Run();

//// Sample app 5
//// This requires a test file with a sorce,symbol,time,price and size fields.
//// (Or the test class below can be updated to use different fields)
//await Task.Run(() => (new TradeDataSourceApp(uri, configs, fileByteRangeProviderFactory)).Run());
//// Simulates the usage of the buffers as a specialized data source, filtered by vendor,product and sale time.
//await Task.Run(() => (new SampleDataSourceApp(uri, configs, fileByteRangeProviderFactory)).Run());

stopWatch.Stop();

Expand Down
42 changes: 21 additions & 21 deletions src/ApacheOrcDotNet.OptimizedReaderTest.App/ReadAllApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public async Task Run()
watch.Start();

// Columns
var sourceColumn = reader.GetColumn("source");
var symbolColumn = reader.GetColumn("symbol");
var timeColumn = reader.GetColumn("time");
var sizeColumn = reader.GetColumn("size");
var stringDictionaryV2Column = reader.GetColumn("stringDictionaryV2");
var stringDirectV2Column = reader.GetColumn("stringDirectV2");
var decimalColumn = reader.GetColumn("decimal");
var integerColumn = reader.GetColumn("integer");
var dateColumn = reader.GetColumn("date");
var doubleColumn = reader.GetColumn("double");
var floatColumn = reader.GetColumn("float");
Expand All @@ -45,10 +45,10 @@ public async Task Run()
var booleanColumn = reader.GetColumn("boolean");

// Buffers
var sourceColumnBuffer = reader.CreateStringColumnBuffer(sourceColumn);
var symbolColumnBuffer = reader.CreateStringColumnBuffer(symbolColumn);
var timeColumnBuffer = reader.CreateDecimalColumnBuffer(timeColumn);
var sizeColumnBuffer = reader.CreateIntegerColumnBuffer(sizeColumn);
var stringDictionaryV2ColumnBuffer = reader.CreateStringColumnBuffer(stringDictionaryV2Column);
var stringDirectV2ColumnBuffer = reader.CreateStringColumnBuffer(stringDirectV2Column);
var decimalColumnBuffer = reader.CreateDecimalColumnBuffer(decimalColumn);
var integerColumnBuffer = reader.CreateIntegerColumnBuffer(integerColumn);
var dateColumnBuffer = reader.CreateDateColumnBuffer(dateColumn);
var doubleColumnBuffer = reader.CreateDoubleColumnBuffer(doubleColumn);
var floatColumnBuffer = reader.CreateFloatColumnBuffer(floatColumn);
Expand All @@ -63,15 +63,15 @@ public async Task Run()

for (var stripeId = 0; stripeId < reader.GetNumberOfStripes(); stripeId++)
{
var numRowEntryIndexes = reader.GetNumberOfRowGroupEntries(stripeId, timeColumn.Id);
var numRowEntryIndexes = reader.GetNumberOfRowGroupEntries(stripeId, decimalColumn.Id);

for (var rowEntryIndex = 0; rowEntryIndex < numRowEntryIndexes; rowEntryIndex++)
{
await Task.WhenAll(
reader.LoadDataAsync(stripeId, rowEntryIndex, sourceColumnBuffer),
reader.LoadDataAsync(stripeId, rowEntryIndex, symbolColumnBuffer),
reader.LoadDataAsync(stripeId, rowEntryIndex, timeColumnBuffer),
reader.LoadDataAsync(stripeId, rowEntryIndex, sizeColumnBuffer),
reader.LoadDataAsync(stripeId, rowEntryIndex, stringDictionaryV2ColumnBuffer),
reader.LoadDataAsync(stripeId, rowEntryIndex, stringDirectV2ColumnBuffer),
reader.LoadDataAsync(stripeId, rowEntryIndex, decimalColumnBuffer),
reader.LoadDataAsync(stripeId, rowEntryIndex, integerColumnBuffer),
reader.LoadDataAsync(stripeId, rowEntryIndex, dateColumnBuffer),
reader.LoadDataAsync(stripeId, rowEntryIndex, doubleColumnBuffer),
reader.LoadDataAsync(stripeId, rowEntryIndex, floatColumnBuffer),
Expand All @@ -85,10 +85,10 @@ await Task.WhenAll(
{
totalCount++;

var source = sourceColumnBuffer.Values[idx];
var symbol = symbolColumnBuffer.Values[idx];
var time = timeColumnBuffer.Values[idx];
var size = sizeColumnBuffer.Values[idx];
var stringDictionaryV2 = stringDictionaryV2ColumnBuffer.Values[idx];
var stringDirectV2 = stringDirectV2ColumnBuffer.Values[idx];
var @decimal = decimalColumnBuffer.Values[idx];
var integer = integerColumnBuffer.Values[idx];
var date = dateColumnBuffer.Values[idx];
var dobl = doubleColumnBuffer.Values[idx];
var sing = floatColumnBuffer.Values[idx];
Expand All @@ -100,10 +100,10 @@ await Task.WhenAll(
if (outputData)
{
Console.WriteLine($"" +
$"{source}," +
$"{symbol}," +
$"{(time.HasValue ? time.Value.ToString(CultureInfo.InvariantCulture).PadRight(15, '0') : string.Empty)}," +
$"{size}" +
$"{stringDictionaryV2}," +
$"{stringDirectV2}," +
$"{(@decimal.HasValue ? @decimal.Value.ToString(CultureInfo.InvariantCulture).PadRight(15, '0') : string.Empty)}," +
$"{integer}" +
$" " +
$"{(date.HasValue ? date.Value.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture) : string.Empty)}," +
$"{dobl}," +
Expand Down
8 changes: 4 additions & 4 deletions src/ApacheOrcDotNet.OptimizedReaderTest.App/ReadAllOldApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public void Run()
if (outputData)
{
Console.WriteLine($"" +
$"{item.Source}," +
$"{item.Symbol}," +
$"{(item.Time.HasValue ? item.Time.Value.ToString(CultureInfo.InvariantCulture).PadRight(15, '0') : string.Empty)}," +
$"{item.Size}" +
$"{item.StringDictionaryV2}," +
$"{item.StringDirectV2}," +
$"{(item.Decimal.HasValue ? item.Decimal.Value.ToString(CultureInfo.InvariantCulture).PadRight(15, '0') : string.Empty)}," +
$"{item.Integer}" +
$" " +
$"{(item.Date.HasValue ? item.Date.Value.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture) : string.Empty)}," +
$"{item.Double}," +
Expand Down
38 changes: 19 additions & 19 deletions src/ApacheOrcDotNet.OptimizedReaderTest.App/ReadCompareApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public async Task Run()
watch.Start();

// Columns
var sourceColumn = orcReaderNew.GetColumn("source");
var symbolColumn = orcReaderNew.GetColumn("symbol");
var timeColumn = orcReaderNew.GetColumn("time");
var sizeColumn = orcReaderNew.GetColumn("size");
var stringDictionaryV2Column = orcReaderNew.GetColumn("stringDictionaryV2");
var stringDirectV2Column = orcReaderNew.GetColumn("stringDirectV2");
var decimalColumn = orcReaderNew.GetColumn("decimal");
var integerColumn = orcReaderNew.GetColumn("integer");
var dateColumn = orcReaderNew.GetColumn("date");
var doubleColumn = orcReaderNew.GetColumn("double");
var floatColumn = orcReaderNew.GetColumn("float");
Expand All @@ -60,10 +60,10 @@ public async Task Run()
var booleanColumn = orcReaderNew.GetColumn("boolean");

// Buffers
var sourceColumnBuffer = orcReaderNew.CreateStringColumnBuffer(sourceColumn);
var symbolColumnBuffer = orcReaderNew.CreateStringColumnBuffer(symbolColumn);
var timeColumnBuffer = orcReaderNew.CreateDecimalColumnBuffer(timeColumn);
var sizeColumnBuffer = orcReaderNew.CreateIntegerColumnBuffer(sizeColumn);
var stringDictionaryV2ColumnBuffer = orcReaderNew.CreateStringColumnBuffer(stringDictionaryV2Column);
var stringDirectV2ColumnBuffer = orcReaderNew.CreateStringColumnBuffer(stringDirectV2Column);
var decimalColumnBuffer = orcReaderNew.CreateDecimalColumnBuffer(decimalColumn);
var integerColumnBuffer = orcReaderNew.CreateIntegerColumnBuffer(integerColumn);
var dateColumnBuffer = orcReaderNew.CreateDateColumnBuffer(dateColumn);
var doubleColumnBuffer = orcReaderNew.CreateDoubleColumnBuffer(doubleColumn);
var floatColumnBuffer = orcReaderNew.CreateFloatColumnBuffer(floatColumn);
Expand All @@ -80,15 +80,15 @@ public async Task Run()

for (var stripeId = 0; stripeId < orcReaderNew.GetNumberOfStripes(); stripeId++)
{
var numRowEntryIndexes = orcReaderNew.GetNumberOfRowGroupEntries(stripeId, timeColumn.Id);
var numRowEntryIndexes = orcReaderNew.GetNumberOfRowGroupEntries(stripeId, decimalColumn.Id);

for (var rowEntryIndex = 0; rowEntryIndex < numRowEntryIndexes; rowEntryIndex++)
{
await Task.WhenAll(
orcReaderNew.LoadDataAsync(stripeId, rowEntryIndex, sourceColumnBuffer),
orcReaderNew.LoadDataAsync(stripeId, rowEntryIndex, symbolColumnBuffer),
orcReaderNew.LoadDataAsync(stripeId, rowEntryIndex, timeColumnBuffer),
orcReaderNew.LoadDataAsync(stripeId, rowEntryIndex, sizeColumnBuffer),
orcReaderNew.LoadDataAsync(stripeId, rowEntryIndex, stringDictionaryV2ColumnBuffer),
orcReaderNew.LoadDataAsync(stripeId, rowEntryIndex, stringDirectV2ColumnBuffer),
orcReaderNew.LoadDataAsync(stripeId, rowEntryIndex, decimalColumnBuffer),
orcReaderNew.LoadDataAsync(stripeId, rowEntryIndex, integerColumnBuffer),
orcReaderNew.LoadDataAsync(stripeId, rowEntryIndex, dateColumnBuffer),
orcReaderNew.LoadDataAsync(stripeId, rowEntryIndex, doubleColumnBuffer),
orcReaderNew.LoadDataAsync(stripeId, rowEntryIndex, floatColumnBuffer),
Expand All @@ -102,10 +102,10 @@ await Task.WhenAll(
{
totalCount++;

var source = sourceColumnBuffer.Values[idx];
var symbol = symbolColumnBuffer.Values[idx];
var time = timeColumnBuffer.Values[idx];
var size = sizeColumnBuffer.Values[idx];
var stringDictionaryV2 = stringDictionaryV2ColumnBuffer.Values[idx];
var stringDirectV2 = stringDirectV2ColumnBuffer.Values[idx];
var @decimal = decimalColumnBuffer.Values[idx];
var integer = integerColumnBuffer.Values[idx];
var date = dateColumnBuffer.Values[idx];
var dobl = doubleColumnBuffer.Values[idx];
var sing = floatColumnBuffer.Values[idx];
Expand All @@ -122,8 +122,8 @@ await Task.WhenAll(

var item = (Item)oldReaderItemsEnumerator.Current;

if (source != item.Source || symbol != item.Symbol || time != item.Time || size != item.Size)
throw new InvalidDataException($"{source},{symbol},{time},{size} != {item.Source},{item.Symbol},{item.Time},{item.Size}");
if (stringDictionaryV2 != item.StringDictionaryV2 || stringDirectV2 != item.StringDirectV2 || @decimal != item.Decimal || integer != item.Integer)
throw new InvalidDataException($"{stringDictionaryV2},{stringDirectV2},{@decimal},{integer} != {item.StringDictionaryV2},{item.StringDirectV2},{item.Decimal},{item.Integer}");

if (date != item.Date || dobl != item.Double || sing != item.Float || timeStamp != item.TimeStamp)
throw new InvalidDataException($"{date},{dobl},{sing},{timeStamp} != {item.Date},{item.Double},{item.Float},{item.TimeStamp}");
Expand Down
Loading