Skip to content

Commit

Permalink
fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulimo committed Feb 16, 2025
1 parent fadc1b4 commit a85ae52
Show file tree
Hide file tree
Showing 12 changed files with 157 additions and 107 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
using System;
// Licensed under the Apache License, Version 2.0 (the "License")
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections.Generic;
using System.IO;

namespace FlowtideDotNet.Connector.DeltaLake.Internal.Delta.DeletionVectors.RoaringBitmap
{
/// <summary>
/// Code from https://github.com/Tornhoof/RoaringBitmap/tree/master which is archived
/// </summary>
internal class ArrayContainer : Container, IEquatable<ArrayContainer>
{
public static readonly ArrayContainer One;
Expand Down Expand Up @@ -31,7 +46,7 @@ private ArrayContainer(int cardinality, ushort[] data)
public override int ArraySizeInBytes => m_Cardinality * sizeof(ushort);


public bool Equals(ArrayContainer other)
public bool Equals(ArrayContainer? other)
{
if (ReferenceEquals(this, other))
{
Expand Down Expand Up @@ -231,7 +246,7 @@ public int AndNotArray(ulong[] bitmap)
return extraCardinality;
}

public override bool Equals(object obj)
public override bool Equals(object? obj)
{
var ac = obj as ArrayContainer;
return ac != null && Equals(ac);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
using System;
// Licensed under the Apache License, Version 2.0 (the "License")
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices;

namespace FlowtideDotNet.Connector.DeltaLake.Internal.Delta.DeletionVectors.RoaringBitmap
{
/// <summary>
/// Code from https://github.com/Tornhoof/RoaringBitmap/tree/master which is archived
/// </summary>
internal class BitmapContainer : Container, IEquatable<BitmapContainer>
{
private const int BitmapLength = 1024;
Expand Down Expand Up @@ -62,7 +77,7 @@ private BitmapContainer(int cardinality, ushort[] values, bool negated) : this(n

public override int ArraySizeInBytes => MaxCapacity / 8;

public bool Equals(BitmapContainer other)
public bool Equals(BitmapContainer? other)
{
if (ReferenceEquals(this, other))
{
Expand Down Expand Up @@ -297,7 +312,7 @@ internal int FillArray(ushort[] data)
return m_Cardinality;
}

public override bool Equals(object obj)
public override bool Equals(object? obj)
{
var bc = obj as BitmapContainer;
return bc != null && Equals(bc);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
using System;
// Licensed under the Apache License, Version 2.0 (the "License")
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections.Generic;

namespace FlowtideDotNet.Connector.DeltaLake.Internal.Delta.DeletionVectors.RoaringBitmap
{
/// <summary>
/// Code from https://github.com/Tornhoof/RoaringBitmap/tree/master which is archived
/// </summary>
internal abstract class Container : IEquatable<Container>
{
public const int MaxSize = 4096; // everything <= is an ArrayContainer
Expand All @@ -12,7 +27,7 @@ internal abstract class Container : IEquatable<Container>

public abstract int ArraySizeInBytes { get; }

public bool Equals(Container other)
public bool Equals(Container? other)
{
if (ReferenceEquals(this, other))
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
using System;
// Licensed under the Apache License, Version 2.0 (the "License")
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace FlowtideDotNet.Connector.DeltaLake.Internal.Delta.DeletionVectors.RoaringBitmap
{
/// <summary>
/// Code from https://github.com/Tornhoof/RoaringBitmap/tree/master which is archived
/// </summary>
internal class RoaringArray : IEnumerable<int>, IEquatable<RoaringArray>
{
private const int SerialCookieNoRuncontainer = 12346;
Expand Down Expand Up @@ -65,7 +80,7 @@ IEnumerator IEnumerable.GetEnumerator()
return GetEnumerator();
}

public bool Equals(RoaringArray other)
public bool Equals(RoaringArray? other)
{
if (ReferenceEquals(this, other))
{
Expand Down Expand Up @@ -174,8 +189,8 @@ private int AdvanceUntil(ushort key, int index)
{
var xLength = x.m_Size;
var yLength = y.m_Size;
List<ushort> keys = null;
List<Container> containers = null;
List<ushort>? keys = null;
List<Container>? containers = null;
var size = 0;
var xPos = 0;
var yPos = 0;
Expand All @@ -195,7 +210,7 @@ private int AdvanceUntil(ushort key, int index)
containers = new List<Container>(length);
}
keys.Add(xKey);
containers.Add(c);
containers!.Add(c);
size++;
}
xPos++;
Expand All @@ -210,7 +225,7 @@ private int AdvanceUntil(ushort key, int index)
yPos = y.AdvanceUntil(xKey, yPos);
}
}
return new RoaringArray(size, keys, containers);
return new RoaringArray(size, keys!, containers!);
}

public static RoaringArray operator ^(RoaringArray x, RoaringArray y)
Expand Down Expand Up @@ -377,7 +392,7 @@ public static RoaringArray AndNot(RoaringArray x, RoaringArray y)
return new RoaringArray(size, keys, containers);
}

public override bool Equals(object obj)
public override bool Equals(object? obj)
{
var ra = obj as RoaringArray;
return ra != null && Equals(ra);
Expand Down Expand Up @@ -444,7 +459,7 @@ public static void Serialize(RoaringArray roaringArray, Stream stream)
var container = values[k];
ArrayContainer ac;
BitmapContainer bc;
if ((ac = container as ArrayContainer) != null)
if ((ac = (container as ArrayContainer)!) != null)
{
if (ac.Equals(ArrayContainer.One))
{
Expand All @@ -457,7 +472,7 @@ public static void Serialize(RoaringArray roaringArray, Stream stream)
ArrayContainer.Serialize(ac, binaryWriter);
}
}
else if ((bc = container as BitmapContainer) != null)
else if ((bc = (container as BitmapContainer)!) != null)
{
if (bc.Equals(BitmapContainer.One))
{
Expand Down Expand Up @@ -505,7 +520,7 @@ public static RoaringArray Deserialize(Stream stream)
var isBitmap = new bool[size];


byte[] bitmapOfRunContainers = null;
byte[]? bitmapOfRunContainers = null;
if (hasRun)
{
bitmapOfRunContainers = binaryReader.ReadBytes((size + 7) / 8);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
using System;
// Licensed under the Apache License, Version 2.0 (the "License")
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace FlowtideDotNet.Connector.DeltaLake.Internal.Delta.DeletionVectors.RoaringBitmap
{
/// <summary>
/// Code from https://github.com/Tornhoof/RoaringBitmap/tree/master which is archived
/// </summary>
public class RoaringBitmap : IEnumerable<int>, IEquatable<RoaringBitmap>
{
private readonly RoaringArray m_HighLowContainer;
Expand All @@ -27,7 +42,7 @@ IEnumerator IEnumerable.GetEnumerator()
return GetEnumerator();
}

public bool Equals(RoaringBitmap other)
public bool Equals(RoaringBitmap? other)
{
if (ReferenceEquals(this, other))
{
Expand Down Expand Up @@ -140,7 +155,7 @@ public static RoaringBitmap AndNot(RoaringBitmap x, RoaringBitmap y)
return new RoaringBitmap(RoaringArray.AndNot(x.m_HighLowContainer, y.m_HighLowContainer));
}

public override bool Equals(object obj)
public override bool Equals(object? obj)
{
var ra = obj as RoaringArray;
return ra != null && Equals(ra);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
using System;
// Licensed under the Apache License, Version 2.0 (the "License")
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -8,6 +20,9 @@

namespace FlowtideDotNet.Connector.DeltaLake.Internal.Delta.DeletionVectors.RoaringBitmap
{
/// <summary>
/// Code from https://github.com/Tornhoof/RoaringBitmap/tree/master which is archived
/// </summary>
internal class RoaringBitmapArray : IEnumerable<long>, IDeleteVector
{
private RoaringBitmap[] _bitmaps;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
using System;
// Licensed under the Apache License, Version 2.0 (the "License")
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Runtime.CompilerServices;

/// <summary>
/// Code from https://github.com/Tornhoof/RoaringBitmap/tree/master which is archived
/// </summary>
namespace FlowtideDotNet.Connector.DeltaLake.Internal.Delta.DeletionVectors.RoaringBitmap
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
using FlowtideDotNet.Connector.DeltaLake.Internal.Delta.Actions;
// Licensed under the Apache License, Version 2.0 (the "License")
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using FlowtideDotNet.Connector.DeltaLake.Internal.Delta.Actions;
using FlowtideDotNet.Connector.DeltaLake.Internal.Delta.Utils;
using Parquet.Serialization;
using Stowage;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -198,26 +209,6 @@ public static async Task<DeltaTable> ReadTable(IFileStorage storage, IOPath tabl
return null;
}

private static async Task ReadCheckpoint(IFileStorage storage, LogTransactionFile checkpoint, List<DeltaBaseAction> actionsList, Dictionary<DeltaFileKey, DeltaAddAction> addFiles)
{
// Read the checkpoint file
using var checkpointData = await storage.OpenRead(checkpoint.IOEntry.Path);
var actions = await ParquetSerializer.DeserializeAsync<DeltaAction>(checkpointData);

foreach (var action in actions)
{
if (action.Add != null)
{
addFiles.Add(action.Add.GetKey(), action.Add);
}
if (action.Remove != null)
{
addFiles.Remove(action.Remove.GetKey());
}
actionsList.Add(ToGenericAction(action)!);
}
}

public static async Task<IReadOnlyList<LogTransactionFile>> ReadTransactionLog(IFileStorage storage, IOPath tableName)
{
// Read the transaction log
Expand Down
Loading

0 comments on commit a85ae52

Please sign in to comment.