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

Adding support for parse URI for hostnames #1569

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7314873
Redical rewrite to properly validate URI
hyperbolic2346 Nov 14, 2023
45f0452
Merge remote-tracking branch 'upstream/branch-23.12' into mwilson/par…
hyperbolic2346 Nov 14, 2023
c64623c
updating to add support for utf8 and escaped hex
hyperbolic2346 Nov 15, 2023
0be1f29
Fixing IPv6 issue and code cleanup
hyperbolic2346 Nov 15, 2023
498b391
Adding host support for parse_uri
hyperbolic2346 Nov 15, 2023
c6508bb
updating some edge cases found in java tests and running formatter
hyperbolic2346 Nov 15, 2023
ba1bf34
Merge remote-tracking branch 'upstream/branch-23.12' into mwilson/par…
hyperbolic2346 Nov 15, 2023
e66faae
Merge remote-tracking branch 'upstream/branch-23.12' into mwilson/par…
hyperbolic2346 Nov 15, 2023
5ab5b91
removing some cruft debug
hyperbolic2346 Nov 15, 2023
f2be14d
Updates from extra test cases
hyperbolic2346 Nov 17, 2023
493abcb
updates based on test failures for edges
hyperbolic2346 Nov 20, 2023
688385f
fixing test strings
hyperbolic2346 Nov 20, 2023
a131d00
updating fragment verification
hyperbolic2346 Nov 21, 2023
a0ad229
Adding more tests
hyperbolic2346 Nov 21, 2023
f744579
merging in latest parse protocol changes
hyperbolic2346 Nov 21, 2023
aafb3bb
fixing invalid utf8 bytestream validation
hyperbolic2346 Nov 21, 2023
dc098f9
Merge remote-tracking branch 'upstream/branch-23.12' into mwilson/par…
hyperbolic2346 Nov 21, 2023
e8f40c1
Fixing uninitialized memory issue
hyperbolic2346 Nov 21, 2023
bef362f
Merge remote-tracking branch 'upstream/branch-24.02' into mwilson/par…
hyperbolic2346 Nov 21, 2023
1f1ac22
updating from comments
hyperbolic2346 Nov 22, 2023
6486714
Merge branch 'branch-23.12' into mwilson/parse_uri_validation
hyperbolic2346 Nov 30, 2023
b54c69a
fixing an edge case with ports and userinfo
hyperbolic2346 Nov 30, 2023
b785e06
updates from review comments
hyperbolic2346 Nov 30, 2023
a78a9a0
changing from device buffer to uvector
hyperbolic2346 Nov 30, 2023
4b6a2f4
Merge remote-tracking branch 'upstream/branch-23.12' into mwilson/par…
hyperbolic2346 Nov 30, 2023
49e43d5
Merge remote-tracking branch 'upstream/branch-24.02' into mwilson/par…
hyperbolic2346 Nov 30, 2023
3401316
Merge branch 'mwilson/parse_uri_validation' into mwilson/parse_uri_host
hyperbolic2346 Nov 30, 2023
a5c9a5c
updating tests to better support the matrix of options
hyperbolic2346 Nov 30, 2023
96cedd3
Merge remote-tracking branch 'upstream/branch-24.02' into mwilson/par…
hyperbolic2346 Dec 4, 2023
70f8b4e
updating tests
hyperbolic2346 Dec 4, 2023
b8d4862
Fixing invalid uri's like .. and .www
hyperbolic2346 Dec 5, 2023
0b33a11
const all the things
hyperbolic2346 Dec 5, 2023
173752f
clang format
hyperbolic2346 Dec 5, 2023
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
14 changes: 14 additions & 0 deletions src/main/cpp/src/ParseURIJni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,18 @@ JNIEXPORT jlong JNICALL Java_com_nvidia_spark_rapids_jni_ParseURI_parseProtocol(
}
CATCH_STD(env, 0);
}

JNIEXPORT jlong JNICALL Java_com_nvidia_spark_rapids_jni_ParseURI_parseHost(JNIEnv* env,
jclass,
jlong input_column)
{
JNI_NULL_CHECK(env, input_column, "input column is null", 0);

try {
cudf::jni::auto_set_device(env);
auto const input = reinterpret_cast<cudf::column_view const*>(input_column);
return cudf::jni::ptr_as_jlong(spark_rapids_jni::parse_uri_to_host(*input).release());
}
CATCH_STD(env, 0);
}
}
23 changes: 17 additions & 6 deletions src/main/cpp/src/parse_uri.cu
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,10 @@ bool __device__ validate_domain_name(string_view name)
{
// domain name can be alphanum or -.
// slash can not be the first of last character of the domain name or around a .
bool last_was_slash = false;
bool last_was_period = false;
bool numeric_start = false;
bool last_was_slash = false;
bool last_was_period = false;
bool numeric_start = false;
int characters_before_period = 0;
for (auto iter = name.begin(); iter < name.end(); ++iter) {
auto const c = *iter;
if (!is_alphanum(c) && c != '-' && c != '.') { return false; }
Expand All @@ -311,12 +312,14 @@ bool __device__ validate_domain_name(string_view name)
last_was_slash = true;
last_was_period = false;
} else if (c == '.') {
if (last_was_slash) { return false; }
last_was_period = true;
last_was_slash = false;
if (last_was_slash || last_was_period || characters_before_period == 0) { return false; }
last_was_period = true;
last_was_slash = false;
characters_before_period = 0;
} else {
last_was_period = false;
last_was_slash = false;
characters_before_period++;
}
}

Expand Down Expand Up @@ -847,4 +850,12 @@ std::unique_ptr<column> parse_uri_to_protocol(strings_column_view const& input,
return detail::parse_uri(input, detail::URI_chunks::PROTOCOL, stream, mr);
}

std::unique_ptr<column> parse_uri_to_host(strings_column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::parse_uri(input, detail::URI_chunks::HOST, stream, mr);
}

} // namespace spark_rapids_jni
13 changes: 13 additions & 0 deletions src/main/cpp/src/parse_uri.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,17 @@ std::unique_ptr<cudf::column> parse_uri_to_protocol(
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());

/**
* @brief Parse host and copy from the input string column to the output char buffer.
*
* @param input Input string column of URIs to parse
* @param stream Stream on which to operate.
* @param mr Memory resource for returned column
* @return std::unique_ptr<column> String column of hosts parsed.
*/
std::unique_ptr<cudf::column> parse_uri_to_host(
cudf::strings_column_view const& input,
rmm::cuda_stream_view stream = rmm::cuda_stream_default,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());

} // namespace spark_rapids_jni
Loading