-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update mapreduce & scripts to get representative value of a class
- Loading branch information
Binh Vu
committed
Aug 29, 2023
1 parent
4fe6a3b
commit 744893f
Showing
17 changed files
with
555 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"type": "cargo", | ||
"command": "run", | ||
"args": [ | ||
"--package", | ||
"kgdata", | ||
"--bin", | ||
"kgdata", | ||
"--features", | ||
"pyo3/auto-initialize" | ||
], | ||
"problemMatcher": [ | ||
"$rustc" | ||
], | ||
"group": "build", | ||
"label": "rust: run kgdata" | ||
} | ||
] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use anyhow::Result; | ||
use hashbrown::HashSet; | ||
use kgdata::mapreduce::*; | ||
use kgdata::python::scripts::GetRepresentativeValue; | ||
use kgdata::{error::into_pyerr, mapreduce::from_jl_files, python::scripts::EntityTypesAndDegrees}; | ||
use pyo3::prelude::*; | ||
|
||
fn main() -> PyResult<()> { | ||
let args = GetRepresentativeValue { | ||
data_dir: "/Volumes/research/kgdata/data/dbpedia/20221201".to_string(), | ||
class_ids: HashSet::from_iter(vec!["http://dbpedia.org/ontology/Person".to_string()]), | ||
kgname: "dbpedia".to_string(), | ||
topk: 1000, | ||
}; | ||
|
||
// Python::with_gil(|py| { | ||
// let res = GetRepresentativeValue::calculate_stats(py, &args).unwrap(); | ||
// println!("{:?}", res); | ||
// }); | ||
|
||
println!("Hello, world!"); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use rayon::prelude::*; | ||
|
||
use super::ParallelDataset; | ||
|
||
#[derive(Clone)] | ||
pub struct FoldOp<D: ParallelDataset, ID, F> { | ||
pub base: D, | ||
pub identity: ID, | ||
pub op: F, | ||
} | ||
|
||
impl<T, D, ID, F> IntoParallelIterator for FoldOp<D, ID, F> | ||
where | ||
D: ParallelDataset, | ||
F: (Fn(T, D::Item) -> T) + Sync + Send, | ||
ID: Fn() -> T + Sync + Send, | ||
T: Send, | ||
{ | ||
type Iter = rayon::iter::Fold<D::Iter, ID, F>; | ||
type Item = T; | ||
|
||
fn into_par_iter(self) -> Self::Iter { | ||
self.base.into_par_iter().fold(self.identity, self.op) | ||
} | ||
} | ||
|
||
impl<D, T, ID, F> ParallelDataset for FoldOp<D, ID, F> | ||
where | ||
D: ParallelDataset, | ||
F: (Fn(T, D::Item) -> T) + Sync + Send, | ||
ID: Fn() -> T + Sync + Send, | ||
T: Send, | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.