Skip to content

Commit a94de41

Browse files
committed
Rename some KeySubspace.FromKey(..) into CreateDynamic(..) or CreateTyped(..)
1 parent 07fa586 commit a94de41

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

FoundationDB.Client/Layers/Directories/FdbDirectoryLayer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ internal FdbDirectoryLayer(IDynamicKeySubspace nodeSubspace, IDynamicKeySubspace
160160
[NotNull]
161161
public static FdbDirectoryLayer Create(Slice prefix, IEnumerable<string> path = null, IKeyEncoding encoding = null)
162162
{
163-
var subspace = KeySubspace.FromKey(prefix, encoding ?? TypeSystem.Tuples);
163+
var subspace = KeySubspace.CreateDynamic(prefix, encoding ?? TypeSystem.Tuples);
164164
var location = path != null ? ParsePath(path) : STuple.Empty;
165165
return new FdbDirectoryLayer(subspace.Partition[FdbKey.Directory], subspace, location);
166166
}

FoundationDB.Client/Subspaces/KeySubspace.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static KeySubspace FromKey(Slice prefix)
6565
/// <summary>Initializes a new dynamic subspace with the given binary <paramref name="prefix"/> and key <paramref name="encoder"/>.</summary>
6666
/// <returns>A subspace that can handle keys of any types and size.</returns>
6767
[Pure, NotNull]
68-
public static DynamicKeySubspace FromKey(Slice prefix, [NotNull] IDynamicKeyEncoder encoder)
68+
public static DynamicKeySubspace CreateDynamic(Slice prefix, [NotNull] IDynamicKeyEncoder encoder)
6969
{
7070
Contract.NotNull(encoder, nameof(encoder));
7171
return new DynamicKeySubspace(prefix, encoder);
@@ -74,67 +74,67 @@ public static DynamicKeySubspace FromKey(Slice prefix, [NotNull] IDynamicKeyEnco
7474
/// <summary>Initializes a new subspace with the given binary <paramref name="prefix"/>, that uses a dynamic key <paramref name="encoding"/>.</summary>
7575
/// <returns>A subspace that can handle keys of any types and size.</returns>
7676
[Pure, NotNull]
77-
public static DynamicKeySubspace FromKey(Slice prefix, [NotNull] IKeyEncoding encoding)
77+
public static DynamicKeySubspace CreateDynamic(Slice prefix, [NotNull] IKeyEncoding encoding)
7878
{
7979
Contract.NotNull(encoding, nameof(encoding));
8080
return new DynamicKeySubspace(prefix, encoding.GetDynamicEncoder());
8181
}
8282

8383
/// <summary>Initializes a new subspace with the given binary <paramref name="prefix"/>, that uses a typed key <paramref name="encoding"/>.</summary>
8484
/// <returns>A subspace that can handle keys of type <typeparamref name="T1"/>.</returns>
85-
public static TypedKeySubspace<T1> FromKey<T1>(Slice prefix, [CanBeNull] IKeyEncoding encoding = null)
85+
public static TypedKeySubspace<T1> CreateTyped<T1>(Slice prefix, [CanBeNull] IKeyEncoding encoding = null)
8686
{
8787
return new TypedKeySubspace<T1>(prefix, (encoding ?? TypeSystem.Tuples).GetEncoder<T1>());
8888
}
8989

9090
/// <summary>Initializes a new subspace with the given binary <paramref name="prefix"/>, that uses a typed key <paramref name="encoder"/>.</summary>
9191
/// <returns>A subspace that can handle keys of type <typeparamref name="T1"/>.</returns>
92-
public static TypedKeySubspace<T1> FromKey<T1>(Slice prefix, [NotNull] IKeyEncoder<T1> encoder)
92+
public static TypedKeySubspace<T1> CreateTyped<T1>(Slice prefix, [NotNull] IKeyEncoder<T1> encoder)
9393
{
9494
Contract.NotNull(encoder, nameof(encoder));
9595
return new TypedKeySubspace<T1>(prefix, encoder);
9696
}
9797

9898
/// <summary>Initializes a new subspace with the given binary <paramref name="prefix"/>, that uses a typed key <paramref name="encoding"/>.</summary>
9999
/// <returns>A subspace that can handle composite keys of type (<typeparamref name="T1"/>, <typeparamref name="T2"/>).</returns>
100-
public static TypedKeySubspace<T1, T2> FromKey<T1, T2>(Slice prefix, [CanBeNull] IKeyEncoding encoding = null)
100+
public static TypedKeySubspace<T1, T2> CreateTyped<T1, T2>(Slice prefix, [CanBeNull] IKeyEncoding encoding = null)
101101
{
102102
return new TypedKeySubspace<T1, T2>(prefix, (encoding ?? TypeSystem.Tuples).GetEncoder<T1, T2>());
103103
}
104104

105105
/// <summary>Initializes a new subspace with the given binary <paramref name="prefix"/>, that uses a typed key <paramref name="encoder"/>.</summary>
106106
/// <returns>A subspace that can handle composite keys of type (<typeparamref name="T1"/>, <typeparamref name="T2"/>).</returns>
107-
public static TypedKeySubspace<T1, T2> FromKey<T1, T2>(Slice prefix, [NotNull] ICompositeKeyEncoder<T1, T2> encoder)
107+
public static TypedKeySubspace<T1, T2> CreateTyped<T1, T2>(Slice prefix, [NotNull] ICompositeKeyEncoder<T1, T2> encoder)
108108
{
109109
Contract.NotNull(encoder, nameof(encoder));
110110
return new TypedKeySubspace<T1, T2>(prefix, encoder);
111111
}
112112

113113
/// <summary>Initializes a new subspace with the given binary <paramref name="prefix"/>, that uses a typed key <paramref name="encoding"/>.</summary>
114114
/// <returns>A subspace that can handle composite keys of type (<typeparamref name="T1"/>, <typeparamref name="T2"/>, <typeparamref name="T3"/>).</returns>
115-
public static TypedKeySubspace<T1, T2, T3> FromKey<T1, T2, T3>(Slice prefix, [CanBeNull] IKeyEncoding encoding = null)
115+
public static TypedKeySubspace<T1, T2, T3> CreateTyped<T1, T2, T3>(Slice prefix, [CanBeNull] IKeyEncoding encoding = null)
116116
{
117117
return new TypedKeySubspace<T1, T2, T3>(prefix, (encoding ?? TypeSystem.Tuples).GetEncoder<T1, T2, T3>());
118118
}
119119

120120
/// <summary>Initializes a new subspace with the given binary <paramref name="prefix"/>, that uses a typed key <paramref name="encoder"/>.</summary>
121121
/// <returns>A subspace that can handle composite keys of type (<typeparamref name="T1"/>, <typeparamref name="T2"/>, <typeparamref name="T3"/>).</returns>
122-
public static TypedKeySubspace<T1, T2, T3> FromKey<T1, T2, T3>(Slice prefix, [NotNull] ICompositeKeyEncoder<T1, T2, T3> encoder)
122+
public static TypedKeySubspace<T1, T2, T3> CreateTyped<T1, T2, T3>(Slice prefix, [NotNull] ICompositeKeyEncoder<T1, T2, T3> encoder)
123123
{
124124
Contract.NotNull(encoder, nameof(encoder));
125125
return new TypedKeySubspace<T1, T2, T3>(prefix, encoder);
126126
}
127127

128128
/// <summary>Initializes a new subspace with the given binary <paramref name="prefix"/>, that uses a typed key <paramref name="encoding"/>.</summary>
129129
/// <returns>A subspace that can handle composite keys of type (<typeparamref name="T1"/>, <typeparamref name="T2"/>, <typeparamref name="T3"/>).</returns>
130-
public static TypedKeySubspace<T1, T2, T3, T4> FromKey<T1, T2, T3, T4>(Slice prefix, [CanBeNull] IKeyEncoding encoding = null)
130+
public static TypedKeySubspace<T1, T2, T3, T4> CreateTyped<T1, T2, T3, T4>(Slice prefix, [CanBeNull] IKeyEncoding encoding = null)
131131
{
132132
return new TypedKeySubspace<T1, T2, T3, T4>(prefix, (encoding ?? TypeSystem.Tuples).GetEncoder<T1, T2, T3, T4>());
133133
}
134134

135135
/// <summary>Initializes a new subspace with the given binary <paramref name="prefix"/>, that uses a typed key <paramref name="encoder"/>.</summary>
136136
/// <returns>A subspace that can handle composite keys of type (<typeparamref name="T1"/>, <typeparamref name="T2"/>, <typeparamref name="T3"/>).</returns>
137-
public static TypedKeySubspace<T1, T2, T3, T4> FromKey<T1, T2, T3, T4>(Slice prefix, [NotNull] ICompositeKeyEncoder<T1, T2, T3, T4> encoder)
137+
public static TypedKeySubspace<T1, T2, T3, T4> CreateTyped<T1, T2, T3, T4>(Slice prefix, [NotNull] ICompositeKeyEncoder<T1, T2, T3, T4> encoder)
138138
{
139139
Contract.NotNull(encoder, nameof(encoder));
140140
return new TypedKeySubspace<T1, T2, T3, T4>(prefix, encoder);

FoundationDB.Tests/SubspaceFacts.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void Test_Empty_Subspace_Is_Empty()
5252
[Category("LocalCluster")]
5353
public void Test_Subspace_With_Binary_Prefix()
5454
{
55-
var subspace = KeySubspace.FromKey(new byte[] { 42, 255, 0, 127 }.AsSlice(), TypeSystem.Tuples);
55+
var subspace = KeySubspace.CreateDynamic(new byte[] { 42, 255, 0, 127 }.AsSlice(), TypeSystem.Tuples);
5656

5757
Assert.That(subspace.GetPrefix().ToString(), Is.EqualTo("*<FF><00><7F>"));
5858
Assert.That(KeySubspace.Copy(subspace), Is.Not.SameAs(subspace));
@@ -117,7 +117,7 @@ public void Test_Cannot_Create_Or_Partition_Subspace_With_Slice_Nil()
117117
[Category("LocalCluster")]
118118
public void Test_Subspace_With_Tuple_Prefix()
119119
{
120-
var subspace = KeySubspace.FromKey(TuPack.EncodeKey("hello"), TypeSystem.Tuples);
120+
var subspace = KeySubspace.CreateDynamic(TuPack.EncodeKey("hello"), TypeSystem.Tuples);
121121

122122
Assert.That(subspace.GetPrefix().ToString(), Is.EqualTo("<02>hello<00>"));
123123
Assert.That(KeySubspace.Copy(subspace), Is.Not.SameAs(subspace));
@@ -149,7 +149,7 @@ public void Test_Subspace_With_Tuple_Prefix()
149149
public void Test_Subspace_Partitioning_With_Binary_Suffix()
150150
{
151151
// start from a parent subspace
152-
var parent = KeySubspace.FromKey(Slice.Empty, TypeSystem.Tuples);
152+
var parent = KeySubspace.CreateDynamic(Slice.Empty, TypeSystem.Tuples);
153153
Assert.That(parent.GetPrefix().ToString(), Is.EqualTo("<empty>"));
154154

155155
// create a child subspace using a tuple
@@ -176,7 +176,7 @@ public void Test_Subspace_Partitioning_With_Binary_Suffix()
176176
[Test]
177177
public void Test_DynamicKeySpace_API()
178178
{
179-
var location = KeySubspace.FromKey(Slice.FromString("PREFIX"), TypeSystem.Tuples);
179+
var location = KeySubspace.CreateDynamic(Slice.FromString("PREFIX"), TypeSystem.Tuples);
180180

181181
Assert.That(location[Slice.FromString("SUFFIX")].ToString(), Is.EqualTo("PREFIXSUFFIX"));
182182

@@ -229,7 +229,7 @@ public void Test_DynamicKeySpace_API()
229229
[Test]
230230
public void Test_TypedKeySpace_T1()
231231
{
232-
var location = KeySubspace.FromKey<string>(Slice.FromString("PREFIX"));
232+
var location = KeySubspace.CreateTyped<string>(Slice.FromString("PREFIX"));
233233
Assert.That(location.KeyEncoder, Is.Not.Null, "Should have a Key Encoder");
234234
Assert.That(location.KeyEncoder.Encoding, Is.SameAs(TypeSystem.Tuples), "Encoder should use Tuple type system");
235235

0 commit comments

Comments
 (0)