Skip to content
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

Misc improvements from #128 #129

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions src/NexusMods.MnemonicDB.Abstractions/ISliceDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

namespace NexusMods.MnemonicDB.Abstractions;

/// <summary>
/// Represents a slice descriptor.
/// </summary>
public interface ISliceDescriptor
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace NexusMods.MnemonicDB.Abstractions.Query.SliceDescriptors;
/// <summary>
/// A slice descriptor for all the entities in a partition via the EAVT Index.
/// </summary>
public struct AllEntitiesInPartition(PartitionId partitionId) : ISliceDescriptor
public readonly struct AllEntitiesInPartition(PartitionId partitionId) : ISliceDescriptor
{
/// <inheritdoc />
public void Reset<T>(T iterator) where T : ILowLevelIterator, allows ref struct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ namespace NexusMods.MnemonicDB.Abstractions.Query.SliceDescriptors;
/// <summary>
/// A slice for all reverse attributes in a given partition
/// </summary>
/// <param name="partitionId"></param>
public class AllReverseAttributesInPartition(PartitionId partitionId) : ISliceDescriptor
public readonly struct AllReverseAttributesInPartition(PartitionId partitionId) : ISliceDescriptor
{
/// <inheritdoc />
public void Reset<T>(T iterator) where T : ILowLevelIterator, allows ref struct
Expand Down Expand Up @@ -45,8 +44,9 @@ public bool ShouldContinue(ReadOnlySpan<byte> keySpan)
/// <inheritdoc />
public void Deconstruct(out Datom from, out Datom to, out bool isReversed)
{
var fromValue = new byte[8];
var toValue = new byte[8];
var fromValue = GC.AllocateUninitializedArray<byte>(sizeof(ulong));
var toValue = GC.AllocateUninitializedArray<byte>(sizeof(ulong));

MemoryMarshal.Write(fromValue, partitionId.MinValue);
MemoryMarshal.Write(toValue, partitionId.MaxValue);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace NexusMods.MnemonicDB.Abstractions.Query.SliceDescriptors;
/// <summary>
/// A slice descriptor for a backreference from a given entity via a given attribute
/// </summary>
public class BackRefSlice(AttributeId aid, EntityId eid) : ISliceDescriptor
public readonly struct BackRefSlice(AttributeId aid, EntityId eid) : ISliceDescriptor
{
/// <inheritdoc />
public void Reset<T>(T iterator) where T : ILowLevelIterator, allows ref struct
Expand Down Expand Up @@ -43,8 +43,9 @@ public bool ShouldContinue(ReadOnlySpan<byte> keySpan)
/// <inheritdoc />
public void Deconstruct(out Datom from, out Datom to, out bool isReversed)
{
var valueMemory = new byte[sizeof(ulong)];
MemoryMarshal.Write(valueMemory.AsSpan(), eid);
var valueMemory = GC.AllocateUninitializedArray<byte>(sizeof(ulong));
MemoryMarshal.Write(valueMemory, eid);

from = new Datom(new KeyPrefix(EntityId.MinValueNoPartition, aid, TxId.MinValue, false, ValueTag.Reference, IndexType.VAETCurrent), valueMemory);
to = new Datom(new KeyPrefix(EntityId.MaxValueNoPartition, aid, TxId.MaxValue, false, ValueTag.Reference, IndexType.VAETCurrent), valueMemory);
isReversed = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace NexusMods.MnemonicDB.Abstractions.Query.SliceDescriptors;
/// <summary>
/// Forward slice for a transaction id
/// </summary>
public struct TxIdSlice(TxId txId) : ISliceDescriptor
public readonly struct TxIdSlice(TxId txId) : ISliceDescriptor
{
/// <inheritdoc />
public void Reset<T>(T iterator) where T : ILowLevelIterator, allows ref struct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace NexusMods.MnemonicDB.Storage.RocksDbBackend;

public readonly struct IteratorWrapper(Iterator iterator) : ILowLevelIterator
internal readonly struct IteratorWrapper(Iterator iterator) : ILowLevelIterator
{
public void SeekTo(ReadOnlySpan<byte> span)
{
Expand Down
Loading