Skip to content
Merged
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
13 changes: 12 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions LICENSE-3rdparty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11924,6 +11924,32 @@ third_party_libraries:
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
- package_name: foldhash
package_version: 0.1.5
repository: https://github.com/orlp/foldhash
license: Zlib
licenses:
- license: Zlib
text: |-
Copyright (c) 2024 Orson Peters

This software is provided 'as-is', without any express or implied warranty. In
no event will the authors be held liable for any damages arising from the use of
this software.

Permission is granted to anyone to use this software for any purpose, including
commercial applications, and to alter it and redistribute it freely, subject to
the following restrictions:

1. The origin of this software must not be misrepresented; you must not claim
that you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
not required.

2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.

3. This notice may not be removed or altered from any source distribution.
- package_name: form_urlencoded
package_version: 1.2.1
repository: https://github.com/servo/rust-url
Expand Down
2 changes: 1 addition & 1 deletion ddtelemetry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ tokio-util = { version = "0.7", features = ["codec"] }

tracing = { version = "0.1", default-features = false }
uuid = { version = "1.3", features = ["v4"] }
hashbrown = { version = "0.14", features = ["raw"] }
hashbrown = "0.15"

[dev-dependencies]
tracing-subscriber = "0.3.18"
Expand Down
35 changes: 18 additions & 17 deletions ddtelemetry/src/worker/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

use std::{collections::VecDeque, hash::Hash};

mod queuehasmpap {
use hashbrown::{hash_map::DefaultHashBuilder, raw::RawTable};
mod queuehashmap {
use hashbrown::{hash_table::HashTable, DefaultHashBuilder};
use std::{
collections::VecDeque,
hash::{BuildHasher, Hash},
};

pub struct QueueHashMap<K, V> {
table: RawTable<usize>,
table: HashTable<usize>,
hash_builder: DefaultHashBuilder,
items: VecDeque<(K, V)>,
popped: usize,
Expand Down Expand Up @@ -41,8 +41,9 @@ mod queuehasmpap {
pub fn pop_front(&mut self) -> Option<(K, V)> {
let (k, v) = self.items.pop_front()?;
let hash = make_hash(&self.hash_builder, &k);
let found = self.table.remove_entry(hash, |other| *other == self.popped);
debug_assert!(found.is_some());
if let Ok(entry) = self.table.find_entry(hash, |&other| other == self.popped) {
entry.remove();
}
debug_assert!(self.items.len() == self.table.len());
self.popped += 1;
Some((k, v))
Expand All @@ -52,8 +53,8 @@ mod queuehasmpap {
let hash = make_hash(&self.hash_builder, k);
let idx = self
.table
.get(hash, |other| &self.items[other - self.popped].0 == k)?;
Some(&self.items[idx - self.popped].1)
.find(hash, |other| &self.items[other - self.popped].0 == k)?;
Some(&self.items[*idx - self.popped].1)
}

pub fn get_idx(&self, idx: usize) -> Option<&(K, V)> {
Expand All @@ -62,11 +63,11 @@ mod queuehasmpap {

pub fn get_mut_or_insert(&mut self, key: K, default: V) -> (&mut V, bool) {
let hash = make_hash(&self.hash_builder, &key);
if let Some(&idx) = self
if let Some(idx) = self
.table
.get(hash, |other| self.items[other - self.popped].0 == key)
.find(hash, |other| self.items[other - self.popped].0 == key)
{
return (&mut self.items[idx - self.popped].1, false);
return (&mut self.items[*idx - self.popped].1, false);
}
self.insert_nocheck(hash, key, default);

Expand All @@ -79,12 +80,12 @@ mod queuehasmpap {
// If the key already exists, replace the previous value
pub fn insert(&mut self, key: K, value: V) -> (usize, bool) {
let hash = make_hash(&self.hash_builder, &key);
if let Some(&idx) = self
if let Some(idx) = self
.table
.get(hash, |other| self.items[other - self.popped].0 == key)
.find(hash, |other| self.items[other - self.popped].0 == key)
{
self.items[idx - self.popped].1 = value;
(idx, false)
self.items[*idx - self.popped].1 = value;
(*idx, false)
} else {
(self.insert_nocheck(hash, key, value), true)
}
Expand All @@ -108,7 +109,7 @@ mod queuehasmpap {
hash_builder,
..
} = self;
table.insert(hash, item_index, |i| {
table.insert_unique(hash, item_index, |i| {
make_hash(hash_builder, &items[i - *popped].0)
});
self.items.push_back((key, value));
Expand All @@ -119,7 +120,7 @@ mod queuehasmpap {
impl<K, V> Default for QueueHashMap<K, V> {
fn default() -> Self {
Self {
table: RawTable::new(),
table: HashTable::new(),
hash_builder: DefaultHashBuilder::default(),
items: VecDeque::new(),
popped: 0,
Expand All @@ -132,7 +133,7 @@ mod queuehasmpap {
}
}

pub use queuehasmpap::QueueHashMap;
pub use queuehashmap::QueueHashMap;

#[derive(Default)]
/// Stores telemetry data item, like dependencies and integrations
Expand Down
Loading