Skip to content

Commit cef3404

Browse files
authored
New output model (#11)
add new data output model fix travis windows build
1 parent bb838c8 commit cef3404

File tree

91 files changed

+3256
-206
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+3256
-206
lines changed

.travis/install-dependencies-x86_64.sh

+7
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,10 @@ else
3737

3838
echo ${MINICONDA_VERSION} > ${MINICONDA_HOME}/travis-${MINICONDA_VERSION}-20191015.txt
3939
fi
40+
41+
##########################
42+
# INSTALL RUST for Travis Windows
43+
if [ "${TRAVIS_OS_NAME}" = "windows" ]; then
44+
echo "Install x86_64-pc-windows-msvc target on windows"
45+
rustup target add x86_64-pc-windows-msvc
46+
fi

drepr/Cargo.lock

+10-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

drepr/engine/Cargo.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
22
[package]
33
name = "engine"
4-
version = "1.0.5" # ___PKG_VERSION___: DO NOT MODIFY the version here. Update it via version_manager.py!
4+
version = "1.0.6" # ___PKG_VERSION___: DO NOT MODIFY the version here. Update it via version_manager.py!
55
authors = ["Binh Vu <[email protected]>"]
66
edition = "2018"
77

@@ -30,6 +30,7 @@ fancy-regex = "0.1.0"
3030
lazy_static = "1.3.0"
3131

3232
[dependencies.cpython]
33-
version = "0.2.1"
33+
#version = "0.3.1"
34+
git = "https://github.com/binh-vu/rust-cpython"
3435
# Note: enable this feature generating error when running test or building binary package. See README.md for more information
3536
#features = ["extension-module"]

drepr/engine/src/execution_plans/classes_map_plan/class_map_plan.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,18 @@ impl<'a> ClassMapPlan<'a> {
6767
}
6868
GraphNode::LiteralNode(n) => {
6969
literal_props.push(LiteralProp {
70-
predicate_id: desc.semantic_model.get_edge(class_id, n.node_id).unwrap().edge_id,
70+
predicate_id: eid,
7171
value: n.val.clone(),
7272
});
7373
}
7474
GraphNode::ClassNode(n) => {
7575
let attribute = &desc.attributes[class2subj[n.node_id]];
76-
let predicate_id = desc.semantic_model.get_edge(class_id, n.node_id).unwrap().edge_id;
76+
let predicate_id = eid;
7777
// a class node is optional if all of its properties are optional
7878
let is_target_optional = desc.semantic_model.outgoing_edges[n.node_id]
7979
.iter().all(|&eid| edges_optional[eid]);
8080
let alignments = inference.get_alignments(subj, attribute.id);
81-
81+
8282
let prop = if n.is_blank_node(&desc.semantic_model) {
8383
ObjectProp::BlankObject(BlankObject {
8484
attribute,
@@ -106,7 +106,7 @@ impl<'a> ClassMapPlan<'a> {
106106
.collect::<HashSet<_>>(),
107107
})
108108
};
109-
109+
110110
if removed_edges[predicate_id] {
111111
buffered_object_props.push(prop);
112112
} else {

drepr/engine/src/execution_plans/classes_map_plan/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl<'a> ClassesMapExecutionPlan<'a> {
8282

8383
let write_mode = WriteMode::create(
8484
!cls_plan.is_optional(), cls_plan.subject.is_unique(),
85-
match &cls_plan.subject {
85+
match &cls_plan.subject {
8686
Subject::BlankSubject(_) => Some(true),
8787
Subject::InternalIDSubject(s) => if s.missing_values.len() > 0 && s.is_optional {
8888
// uri is missing sometime so we have to use blank node
@@ -98,7 +98,7 @@ impl<'a> ClassesMapExecutionPlan<'a> {
9898
// always uri
9999
Some(false)
100100
},
101-
}, obj_blank_or_uri);
101+
}, obj_blank_or_uri);
102102

103103
class_write_modes[cls_plan.class_id] = write_mode;
104104
}

drepr/engine/src/execution_plans/classes_map_plan/subject.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl<'a> Subject<'a> {
7272
// always true for blank
7373
Subject::BlankSubject(_) => true,
7474
Subject::InternalIDSubject(s) => s.attr.unique,
75-
Subject::ExternalIDSubject(s) => s.real_id.0.unique
75+
Subject::ExternalIDSubject(s) => s.real_id.0.unique,
7676
}
7777
}
7878
}

drepr/engine/src/executors/classes_map/mod.rs

+20-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::executors::classes_map::generic_algo::generic_class_map;
77
use crate::executors::preprocessing::exec_preprocessing;
88
use crate::lang::{Description, Resource};
99
use crate::writers::stream_writer::{OutputFormat};
10-
use crate::writers::stream_writer::{GraphJSONWriter, TTLStreamWriter};
10+
use crate::writers::stream_writer::{GraphJSONWriter, TTLStreamWriter, GraphPyWriter};
1111
use crate::writers::stream_writer::stream_writer::{StreamWriterResult, WriteResult};
1212
use crate::execution_plans::classes_map_plan::class_map_plan::ClassMapExecStrategy;
1313
#[cfg(feature = "enable-exec-macro-cls-map")]
@@ -55,6 +55,17 @@ pub fn classes_map(resource_files: &[PhysicalResource], desc: &Description, plan
5555
}
5656
};
5757
readers.push(reader);
58+
},
59+
Resource::NPDict(_) => {
60+
let reader = match &resource_files[i] {
61+
PhysicalResource::File(fpath) => {
62+
Box::new(JSONRAReader::from_file(fpath))
63+
}
64+
PhysicalResource::String(content) => {
65+
Box::new(JSONRAReader::from_str(content))
66+
}
67+
};
68+
readers.push(reader);
5869
}
5970
_ => unimplemented!()
6071
}
@@ -74,12 +85,18 @@ pub fn classes_map(resource_files: &[PhysicalResource], desc: &Description, plan
7485
&format!("{}.edge", fpath),
7586
&desc.semantic_model))
7687
}
77-
PhysicalOutput::String { format: OutputFormat::TTL } => {
88+
PhysicalOutput::File { fpath: _, format: OutputFormat::GraphPy } => {
89+
unimplemented!()
90+
}
91+
PhysicalOutput::Memory { format: OutputFormat::TTL } => {
7892
Box::new(TTLStreamWriter::write2str(&desc.semantic_model))
7993
}
80-
PhysicalOutput::String { format: OutputFormat::GraphJSON } => {
94+
PhysicalOutput::Memory { format: OutputFormat::GraphJSON } => {
8195
Box::new(GraphJSONWriter::write2str(&desc.semantic_model))
8296
}
97+
PhysicalOutput::Memory { format: OutputFormat::GraphPy } => {
98+
Box::new(GraphPyWriter::write2mem(&desc.semantic_model))
99+
}
83100
};
84101

85102
writer.begin();

drepr/engine/src/executors/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ pub enum PhysicalResource {
2020
pub enum PhysicalOutput {
2121
#[serde(rename = "file")]
2222
File { fpath: String, format: OutputFormat },
23-
#[serde(rename = "string")]
24-
String { format: OutputFormat },
23+
#[serde(rename = "memory")]
24+
Memory { format: OutputFormat }
2525
}
2626

2727
#[derive(Deserialize, Serialize, Debug, Clone)]
@@ -45,7 +45,7 @@ impl Executor {
4545
// let edges_optional = vec![true; self.description.semantic_model.edges.len()];
4646
let output_format = match &self.output {
4747
PhysicalOutput::File { fpath: _, format } => format,
48-
PhysicalOutput::String { format } => format
48+
PhysicalOutput::Memory { format } => format
4949
};
5050
let exec_plan = ClassesMapExecutionPlan::new(&self.description, output_format, &self.edges_optional);
5151
ExecutionPlan::ClassesMap(exec_plan)
@@ -56,7 +56,7 @@ impl PhysicalOutput {
5656
pub fn get_format(&self) -> &OutputFormat {
5757
match self {
5858
PhysicalOutput::File { fpath: _, format } => format,
59-
PhysicalOutput::String { format } => format
59+
PhysicalOutput::Memory { format } => format
6060
}
6161
}
6262
}

drepr/engine/src/functions/filter_func.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl<'a, F> FilterFunc<'a, F>
2828
}
2929
}
3030
StepExpr::Range(r) => {
31-
let mut end = r.get_end(reader.len());
31+
let end = r.get_end(reader.len());
3232
let mut idx = [Index::Idx(r.start)];
3333
for i in (r.start..end).step_by(r.step).rev() {
3434
idx[0] = Index::Idx(i);

drepr/engine/src/lang/resource.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ pub enum Resource {
1010
JSON(usize),
1111
#[serde(rename = "spreadsheet")]
1212
Spreadsheet(usize),
13-
#[serde(rename = "netcdf")]
14-
NetCDF(usize),
13+
#[serde(rename = "netcdf4")]
14+
NetCDF4(usize),
15+
#[serde(rename = "np-dict")]
16+
NPDict(usize)
1517
}
1618

1719
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]

drepr/engine/src/lang/semantic_model/node.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ impl ClassNode {
6565

6666
format!("{}{}", short_lbl, self.node_id)
6767
}
68-
69-
68+
7069
pub fn is_blank_node(&self, sm: &SemanticModel) -> bool {
7170
for &e in &sm.outgoing_edges[self.node_id] {
7271
if sm.edges[e].rel_label == DREPR_URI {

0 commit comments

Comments
 (0)