Skip to content

Commit

Permalink
Revert "[Compatibility] Added GEOSEARCHSTORE command and bug fix in G…
Browse files Browse the repository at this point in the history
…EOSEARCH…" (#751)

This reverts commit d17f489.
  • Loading branch information
TalZaccai authored Oct 25, 2024
1 parent d17f489 commit 9a08ff3
Show file tree
Hide file tree
Showing 19 changed files with 24 additions and 825 deletions.
76 changes: 2 additions & 74 deletions libs/common/RespReadUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -729,22 +729,6 @@ public static bool ReadBoolWithLengthHeader(out bool result, ref byte* ptr, byte
/// <param name="end">The current end of the RESP message.</param>
/// <returns>True if a RESP string was successfully read.</returns>
public static bool ReadStringWithLengthHeader(out string result, ref byte* ptr, byte* end)
{
ReadSpanWithLengthHeader(out var resultSpan, ref ptr, end);
result = Encoding.UTF8.GetString(resultSpan);
return true;
}

/// <summary>
/// Tries to read a RESP-formatted string as span including its length header from the given ASCII-encoded
/// RESP message and, if successful, moves the given ptr to the end of the string value.
/// NOTE: We use ReadUnsignedLengthHeader because server does not accept $-1\r\n headers
/// </summary>
/// <param name="result">If parsing was successful, contains the extracted string value.</param>
/// <param name="ptr">The starting position in the RESP message. Will be advanced if parsing is successful.</param>
/// <param name="end">The current end of the RESP message.</param>
/// <returns>True if a RESP string was successfully read.</returns>
public static bool ReadSpanWithLengthHeader(out ReadOnlySpan<byte> result, ref byte* ptr, byte* end)
{
result = null;

Expand All @@ -769,7 +753,7 @@ public static bool ReadSpanWithLengthHeader(out ReadOnlySpan<byte> result, ref b
RespParsingException.ThrowUnexpectedToken(*(ptr - 2));
}

result = new ReadOnlySpan<byte>(keyPtr, length);
result = Encoding.UTF8.GetString(new ReadOnlySpan<byte>(keyPtr, length));

return true;
}
Expand Down Expand Up @@ -874,40 +858,10 @@ public static bool ReadErrorAsString(out string result, ref byte* ptr, byte* end
return ReadString(out result, ref ptr, end);
}

/// <summary>
/// Read error as span
/// </summary>
public static bool TryReadErrorAsSpan(out ReadOnlySpan<byte> result, ref byte* ptr, byte* end)
{
result = null;
if (ptr + 2 >= end)
return false;

// Error strings need to start with a '-'
if (*ptr != '-')
{
return false;
}

ptr++;

return ReadAsSapn(out result, ref ptr, end);
}

/// <summary>
/// Read integer as string
/// </summary>
public static bool ReadIntegerAsString(out string result, ref byte* ptr, byte* end)
{
var success = ReadIntegerAsSpan(out var resultSpan, ref ptr, end);
result = Encoding.UTF8.GetString(resultSpan);
return success;
}

/// <summary>
/// Read integer as string
/// </summary>
public static bool ReadIntegerAsSpan(out ReadOnlySpan<byte> result, ref byte* ptr, byte* end)
{
result = null;
if (ptr + 2 >= end)
Expand All @@ -921,7 +875,7 @@ public static bool ReadIntegerAsSpan(out ReadOnlySpan<byte> result, ref byte* pt

ptr++;

return ReadAsSapn(out result, ref ptr, end);
return ReadString(out result, ref ptr, end);
}

/// <summary>
Expand Down Expand Up @@ -1079,32 +1033,6 @@ public static bool ReadString(out string result, ref byte* ptr, byte* end)
return false;
}

/// <summary>
/// Read ASCII string as span without header until string terminator ('\r\n').
/// </summary>
public static bool ReadAsSapn(out ReadOnlySpan<byte> result, ref byte* ptr, byte* end)
{
result = null;

if (ptr + 1 >= end)
return false;

var start = ptr;

while (ptr < end - 1)
{
if (*(ushort*)ptr == MemoryMarshal.Read<ushort>("\r\n"u8))
{
result = new ReadOnlySpan<byte>(start, (int)(ptr - start));
ptr += 2;
return true;
}
ptr++;
}

return false;
}

/// <summary>
/// Read serialized data for migration
/// </summary>
Expand Down
221 changes: 0 additions & 221 deletions libs/resources/RespCommandsDocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2216,227 +2216,6 @@
}
]
},
{
"Command": "GEOSEARCHSTORE",
"Name": "GEOSEARCHSTORE",
"Summary": "Queries a geospatial index for members inside an area of a box or a circle, optionally stores the result.",
"Group": "Geo",
"Complexity": "O(N\u002Blog(M)) where N is the number of elements in the grid-aligned bounding box area around the shape provided as the filter and M is the number of items inside the shape",
"Arguments": [
{
"TypeDiscriminator": "RespCommandKeyArgument",
"Name": "DESTINATION",
"DisplayText": "destination",
"Type": "Key",
"KeySpecIndex": 0
},
{
"TypeDiscriminator": "RespCommandKeyArgument",
"Name": "SOURCE",
"DisplayText": "source",
"Type": "Key",
"KeySpecIndex": 1
},
{
"TypeDiscriminator": "RespCommandContainerArgument",
"Name": "FROM",
"Type": "OneOf",
"Arguments": [
{
"TypeDiscriminator": "RespCommandBasicArgument",
"Name": "MEMBER",
"DisplayText": "member",
"Type": "String",
"Token": "FROMMEMBER"
},
{
"TypeDiscriminator": "RespCommandContainerArgument",
"Name": "FROMLONLAT",
"Type": "Block",
"Token": "FROMLONLAT",
"Arguments": [
{
"TypeDiscriminator": "RespCommandBasicArgument",
"Name": "LONGITUDE",
"DisplayText": "longitude",
"Type": "Double"
},
{
"TypeDiscriminator": "RespCommandBasicArgument",
"Name": "LATITUDE",
"DisplayText": "latitude",
"Type": "Double"
}
]
}
]
},
{
"TypeDiscriminator": "RespCommandContainerArgument",
"Name": "BY",
"Type": "OneOf",
"Arguments": [
{
"TypeDiscriminator": "RespCommandContainerArgument",
"Name": "CIRCLE",
"Type": "Block",
"Arguments": [
{
"TypeDiscriminator": "RespCommandBasicArgument",
"Name": "RADIUS",
"DisplayText": "radius",
"Type": "Double",
"Token": "BYRADIUS"
},
{
"TypeDiscriminator": "RespCommandContainerArgument",
"Name": "UNIT",
"Type": "OneOf",
"Arguments": [
{
"TypeDiscriminator": "RespCommandBasicArgument",
"Name": "M",
"DisplayText": "m",
"Type": "PureToken",
"Token": "M"
},
{
"TypeDiscriminator": "RespCommandBasicArgument",
"Name": "KM",
"DisplayText": "km",
"Type": "PureToken",
"Token": "KM"
},
{
"TypeDiscriminator": "RespCommandBasicArgument",
"Name": "FT",
"DisplayText": "ft",
"Type": "PureToken",
"Token": "FT"
},
{
"TypeDiscriminator": "RespCommandBasicArgument",
"Name": "MI",
"DisplayText": "mi",
"Type": "PureToken",
"Token": "MI"
}
]
}
]
},
{
"TypeDiscriminator": "RespCommandContainerArgument",
"Name": "BOX",
"Type": "Block",
"Arguments": [
{
"TypeDiscriminator": "RespCommandBasicArgument",
"Name": "WIDTH",
"DisplayText": "width",
"Type": "Double",
"Token": "BYBOX"
},
{
"TypeDiscriminator": "RespCommandBasicArgument",
"Name": "HEIGHT",
"DisplayText": "height",
"Type": "Double"
},
{
"TypeDiscriminator": "RespCommandContainerArgument",
"Name": "UNIT",
"Type": "OneOf",
"Arguments": [
{
"TypeDiscriminator": "RespCommandBasicArgument",
"Name": "M",
"DisplayText": "m",
"Type": "PureToken",
"Token": "M"
},
{
"TypeDiscriminator": "RespCommandBasicArgument",
"Name": "KM",
"DisplayText": "km",
"Type": "PureToken",
"Token": "KM"
},
{
"TypeDiscriminator": "RespCommandBasicArgument",
"Name": "FT",
"DisplayText": "ft",
"Type": "PureToken",
"Token": "FT"
},
{
"TypeDiscriminator": "RespCommandBasicArgument",
"Name": "MI",
"DisplayText": "mi",
"Type": "PureToken",
"Token": "MI"
}
]
}
]
}
]
},
{
"TypeDiscriminator": "RespCommandContainerArgument",
"Name": "ORDER",
"Type": "OneOf",
"ArgumentFlags": "Optional",
"Arguments": [
{
"TypeDiscriminator": "RespCommandBasicArgument",
"Name": "ASC",
"DisplayText": "asc",
"Type": "PureToken",
"Token": "ASC"
},
{
"TypeDiscriminator": "RespCommandBasicArgument",
"Name": "DESC",
"DisplayText": "desc",
"Type": "PureToken",
"Token": "DESC"
}
]
},
{
"TypeDiscriminator": "RespCommandContainerArgument",
"Name": "COUNT-BLOCK",
"Type": "Block",
"ArgumentFlags": "Optional",
"Arguments": [
{
"TypeDiscriminator": "RespCommandBasicArgument",
"Name": "COUNT",
"DisplayText": "count",
"Type": "Integer",
"Token": "COUNT"
},
{
"TypeDiscriminator": "RespCommandBasicArgument",
"Name": "ANY",
"DisplayText": "any",
"Type": "PureToken",
"Token": "ANY",
"ArgumentFlags": "Optional"
}
]
},
{
"TypeDiscriminator": "RespCommandBasicArgument",
"Name": "STOREDIST",
"DisplayText": "storedist",
"Type": "PureToken",
"Token": "STOREDIST",
"ArgumentFlags": "Optional"
}
]
},
{
"Command": "GET",
"Name": "GET",
Expand Down
38 changes: 0 additions & 38 deletions libs/resources/RespCommandsInfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -1276,44 +1276,6 @@
}
]
},
{
"Command": "GEOSEARCHSTORE",
"Name": "GEOSEARCHSTORE",
"Arity": -8,
"Flags": "DenyOom, Write",
"FirstKey": 1,
"LastKey": 2,
"Step": 1,
"AclCategories": "Geo, Slow, Write",
"KeySpecifications": [
{
"BeginSearch": {
"TypeDiscriminator": "BeginSearchIndex",
"Index": 1
},
"FindKeys": {
"TypeDiscriminator": "FindKeysRange",
"LastKey": 0,
"KeyStep": 1,
"Limit": 0
},
"Flags": "OW, Update"
},
{
"BeginSearch": {
"TypeDiscriminator": "BeginSearchIndex",
"Index": 2
},
"FindKeys": {
"TypeDiscriminator": "FindKeysRange",
"LastKey": 0,
"KeyStep": 1,
"Limit": 0
},
"Flags": "RO, Access"
}
]
},
{
"Command": "GET",
"Name": "GET",
Expand Down
4 changes: 0 additions & 4 deletions libs/server/API/GarnetApiObjectCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,6 @@ public GarnetStatus GeoAdd(byte[] key, ref ObjectInput input, ref GarnetObjectSt
public GarnetStatus GeoCommands(byte[] key, ref ObjectInput input, ref GarnetObjectStoreOutput outputFooter)
=> storageSession.GeoCommands(key, ref input, ref outputFooter, ref objectContext);

/// <inheritdoc />
public GarnetStatus GeoSearchStore(ArgSlice key, ArgSlice destinationKey, ref ObjectInput input, ref SpanByteAndMemory output)
=> storageSession.GeoSearchStore(key, destinationKey, ref input, ref output, ref objectContext);

#endregion

#region List Methods
Expand Down
Loading

0 comments on commit 9a08ff3

Please sign in to comment.