Skip to content

Commit

Permalink
XForm: Cleanup.
Browse files Browse the repository at this point in the history
  - CodeFormat pass.
  - Added copyright comment to native code.
  - Remove unused and misspelled variable from TableTestHarness.
  • Loading branch information
Scott Louvau committed Feb 10, 2018
1 parent 85150a4 commit 13d0b2f
Show file tree
Hide file tree
Showing 26 changed files with 80 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Elfie/Elfie/Model/Strings/String8.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,7 @@ public bool Equals(String8 other)

int offset = other.Index - this.Index;
int end = this.Index + this.Length;
for(int i = this.Index; i < end; ++i)
for (int i = this.Index; i < end; ++i)
{
if (this.Array[i] != other.Array[i + offset]) return false;
}
Expand Down
8 changes: 5 additions & 3 deletions XForm/XForm.Generator/Model/WebRequestDisasters.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System;
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;

namespace XForm.Generator.Model
{
Expand All @@ -17,7 +20,7 @@ public DataCenterOutage(DateTime startTime, DateTime endTime, string dataCenter)
{
this.StartTime = startTime;
this.EndTime = endTime;
this.DataCenter = dataCenter ;
this.DataCenter = dataCenter;
}

public void Transform(WebRequest item)
Expand Down Expand Up @@ -107,5 +110,4 @@ public void Transform(WebRequest item)
}
}
}

}
2 changes: 1 addition & 1 deletion XForm/XForm.Generator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private static void Generate_WebRequestSample(string basePath, int randomSeed, i
for (int day = 0; day < numberOfDays; ++day)
{
generator = new WebRequestGenerator(users, r, asOfDate, (eventCount < 1001 ? 10 : 100));
if(day == 0) generator.Issue = new PremiumUserOutage(asOfDate.AddMinutes(18), asOfDate.AddMinutes(104), r);
if (day == 0) generator.Issue = new PremiumUserOutage(asOfDate.AddMinutes(18), asOfDate.AddMinutes(104), r);
BuildWebRequests(basePath, generator, eventCount, WebRequestWriteMode.UserIdentityOnly);
asOfDate = asOfDate.AddDays(-1);
}
Expand Down
3 changes: 3 additions & 0 deletions XForm/XForm.Native/BitVectorN.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#include "stdafx.h"
#include <intrin.h>
#include <nmmintrin.h>
Expand Down
3 changes: 3 additions & 0 deletions XForm/XForm.Native/BitVectorN.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#pragma once
using namespace System;

Expand Down
3 changes: 3 additions & 0 deletions XForm/XForm.Native/Comparer.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#pragma once
using namespace System;

Expand Down
3 changes: 3 additions & 0 deletions XForm/XForm.Native/Comparer16.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#include "stdafx.h"
#include <intrin.h>
#include <nmmintrin.h>
Expand Down
3 changes: 3 additions & 0 deletions XForm/XForm.Native/Comparer8.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#include "stdafx.h"
#include <intrin.h>
#include <nmmintrin.h>
Expand Down
3 changes: 3 additions & 0 deletions XForm/XForm.Native/ComparerSingle.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#include "stdafx.h"
#include <intrin.h>
#include <nmmintrin.h>
Expand Down
3 changes: 3 additions & 0 deletions XForm/XForm.Native/Operator.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#pragma once

// WARNING: Values must stay in sync with XForm.Query.Operator
Expand Down
3 changes: 3 additions & 0 deletions XForm/XForm.Native/String8N.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#include "stdafx.h"
#include <intrin.h>
#include <nmmintrin.h>
Expand Down
3 changes: 3 additions & 0 deletions XForm/XForm.Native/String8N.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#pragma once
using namespace System;

Expand Down
3 changes: 2 additions & 1 deletion XForm/XForm.Test/AssertCommand.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Threading;

using Microsoft.VisualStudio.TestTools.UnitTesting;

using XForm.Data;
using XForm.Extensions;
using XForm.Query;
Expand Down
7 changes: 6 additions & 1 deletion XForm/XForm.Test/Core/SamplerTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;

using Microsoft.VisualStudio.TestTools.UnitTesting;

using XForm.Core;
using XForm.Data;

Expand Down
2 changes: 1 addition & 1 deletion XForm/XForm.Test/IO/VariableIntegerReaderWriterTests.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.IO;
using System.Linq;

using Microsoft.VisualStudio.TestTools.UnitTesting;

using XForm.Data;
using XForm.IO;
using System.IO;
using XForm.Types;

namespace XForm.Test.IO
Expand Down
4 changes: 3 additions & 1 deletion XForm/XForm.Test/Query/XTableBasicTests.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Threading;

using Elfie.Test;

using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Threading;

using XForm.Data;
using XForm.Extensions;
using XForm.Query;
Expand Down
12 changes: 5 additions & 7 deletions XForm/XForm.Test/TableTestHarness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ public static XDatabaseContext DatabaseContext
}
}

public static object Strnig8Block { get; private set; }

public static void AssertAreEqual(IXTable expected, IXTable actual, int pageSize)
{
// Reset both tables (so they can be used for repeated scenarios)
Expand Down Expand Up @@ -107,10 +105,10 @@ public static void AssertAreEqual(IXTable expected, IXTable actual, int pageSize
XArray actualArray = actualArrays[i].Slice(actualNextIndex, actualNextIndex + countToCompare);

firstMismatchedRow = FirstMismatchedRow(
expectedArray,
actualArray,
countToCompare,
expected.Columns[i].ColumnDetails.Name,
expectedArray,
actualArray,
countToCompare,
expected.Columns[i].ColumnDetails.Name,
out errorMessage);

if (!String.IsNullOrEmpty(errorMessage)) break;
Expand Down Expand Up @@ -290,7 +288,7 @@ public static String8[] ToString8(String[] values)
String8Block block = new String8Block();

String8[] result = new String8[values.Length];
for(int i = 0; i < values.Length; ++i)
for (int i = 0; i < values.Length; ++i)
{
result[i] = block.GetCopy(values[i]);
}
Expand Down
2 changes: 1 addition & 1 deletion XForm/XForm/Aggregators/CountAggregator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class CountAggregator : IAggregator, IFoundIndicesTracker
{
private int[] _countPerBucket;
private int _distinctCount;

public CountAggregator()
{
ColumnDetails = new ColumnDetails("Count", typeof(int));
Expand Down
2 changes: 1 addition & 1 deletion XForm/XForm/Aggregators/PercentageAggregator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static string WholePercentage(int count, int total)
if (count == total) return "100%";

float percentage = (float)count / (float)total;
return percentage.ToString("p0");
return percentage.ToString("p0");
}

public void Add(XArray rowIndices, int newDistinctCount)
Expand Down
1 change: 1 addition & 0 deletions XForm/XForm/Aggregators/SumAggregator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;

using XForm.Columns;
using XForm.Data;

Expand Down
6 changes: 5 additions & 1 deletion XForm/XForm/Core/Sampler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using System;
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;

using XForm.Data;

namespace XForm.Core
Expand Down
5 changes: 3 additions & 2 deletions XForm/XForm/Extensions/XTableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;

using XForm.Data;
using XForm.IO;
using XForm.IO.StreamProvider;
Expand Down Expand Up @@ -112,7 +113,7 @@ public static RunResult RunUntilTimeout(this IXTable pipeline, TimeSpan timeout,
using (CancellationTokenSource source = new CancellationTokenSource())
{
CancellationToken cancellationToken = source.Token;
if(timeout != TimeSpan.Zero && timeout != TimeSpan.MaxValue) source.CancelAfter(timeout);
if (timeout != TimeSpan.Zero && timeout != TimeSpan.MaxValue) source.CancelAfter(timeout);

RunResult result = new RunResult();
result.Timeout = timeout;
Expand All @@ -123,7 +124,7 @@ public static RunResult RunUntilTimeout(this IXTable pipeline, TimeSpan timeout,
int count = pipeline.Next(batchSize, cancellationToken);
result.RowCount += count;

if(cancellationToken.IsCancellationRequested)
if (cancellationToken.IsCancellationRequested)
{
break;
}
Expand Down
6 changes: 5 additions & 1 deletion XForm/XForm/Functions/IsNull.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using System;
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;

using XForm.Data;

namespace XForm.Functions
Expand Down
2 changes: 1 addition & 1 deletion XForm/XForm/IO/TabularFileWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;

using Microsoft.CodeAnalysis.Elfie.Model.Strings;
using Microsoft.CodeAnalysis.Elfie.Serialization;

using XForm.Data;
using XForm.IO.StreamProvider;
using XForm.Types;
using System.Threading;

namespace XForm.IO
{
Expand Down
12 changes: 8 additions & 4 deletions XForm/XForm/IO/VariableIntegerReaderWriter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using System;
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;

using XForm.Data;
using XForm.IO.StreamProvider;
using XForm.Types;
Expand Down Expand Up @@ -143,7 +147,7 @@ public void Append(XArray xarray)

public void Dispose()
{
if(_writer != null)
if (_writer != null)
{
_writer.Dispose();
_writer = null;
Expand All @@ -165,7 +169,7 @@ public VariableIntegerReader(IStreamProvider streamProvider, string columnPathPr
// Look for each potential size in descending order and build the right reader and converter
Type type = typeof(int);
string path = VariableIntegerWriter.PathForType(columnPathPrefix, typeof(int));
if(streamProvider.Attributes(path).Exists)
if (streamProvider.Attributes(path).Exists)
{
_reader = TypeProviderFactory.TryGetColumnReader(streamProvider, typeof(int), path, option, typeof(VariableIntegerReader));
_converter = null;
Expand Down Expand Up @@ -197,7 +201,7 @@ public XArray Read(ArraySelector selector)

public void Dispose()
{
if(_reader != null)
if (_reader != null)
{
_reader.Dispose();
_reader = null;
Expand Down
7 changes: 4 additions & 3 deletions XForm/XForm/Verbs/Peek.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Microsoft.CodeAnalysis.Elfie.Model.Strings;
using System;
using System.Collections.Generic;
using System.Threading;

using Microsoft.CodeAnalysis.Elfie.Model.Strings;

using XForm.Aggregators;
using XForm.Columns;
using XForm.Core;
Expand Down Expand Up @@ -101,7 +102,7 @@ private void PostSortAndFilter(XArray groups, XArray counts, int totalRowCount,
for (int i = 0; i < groups.Count; ++i)
{
int count = countsArray[counts.Index(i)];
if(count >= threshold)
if (count >= threshold)
{
finalIndices[groupCount] = i;
finalCounts[groupCount] = count;
Expand Down Expand Up @@ -168,7 +169,7 @@ private void BuildDictionary(CancellationToken cancellationToken)
Random r = new Random();

// Build a Dictionary and CountAggregator for each sample
GroupByDictionary[] dictionaries = new GroupByDictionary[SampleCount];
GroupByDictionary[] dictionaries = new GroupByDictionary[SampleCount];
CountAggregator[] counts = new CountAggregator[SampleCount];
int[][] remapArrays = new int[SampleCount][];
for (int i = 0; i < SampleCount; ++i)
Expand Down

0 comments on commit 13d0b2f

Please sign in to comment.