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

Duplicate element in linkedlist #34

Open
ilikecola opened this issue Mar 5, 2019 · 2 comments
Open

Duplicate element in linkedlist #34

ilikecola opened this issue Mar 5, 2019 · 2 comments

Comments

@ilikecola
Copy link

ilikecola commented Mar 5, 2019

Hello nkons,
I have a question about LinkedList in

//Sorting: evaluate first the logical table mappings without reference to a parent triples map
LinkedList<LogicalTableMapping> first = new LinkedList<LogicalTableMapping>();
LinkedList<LogicalTableMapping> second = new LinkedList<LogicalTableMapping>();
for (LogicalTableMapping ltm : mappingDocument.getLogicalTableMappings()) {
for (PredicateObjectMap p : ltm.getPredicateObjectMaps()) {
if (p.getRefObjectMap() != null &&
p.getRefObjectMap().getParentTriplesMapUri() != null &&
StringUtils.isNotBlank(p.getRefObjectMap().getParentTriplesMapUri())) {
second.add(ltm);
} else {
first.add(ltm);
}
}
}
first.addAll(second);
mappingDocument.setLogicalTableMappings(first);

If there are some predicateObjectMappings in one LogicalTableMapping, there will be many duplicate element in linkedlist first or second.

So will these duplicate elements be parsed twice or more in the below loop?

for (LogicalTableMapping logicalTableMapping : mappingDocument.getLogicalTableMappings()) {

Thank you very much!

@nkons
Copy link
Owner

nkons commented Mar 29, 2019

Hi,

Thanks for your question.

Not sure I understand it though; did you run in and noticed that duplicates were generated? If so, could you please share your input data?

Is the question about what processing takes place in memory? If so, then in the second loop, there is only a getter; no additional processing takes place.

Also to mention that the lists first and second have no duplicates as the former contains predicate object maps for which RefObjectMap is not null, and the latter the ones for which RefObjectMap is null.

Did this answer your question? Happy to dig deeper if needed.

Best,
Nikos

@ilikecola
Copy link
Author

Hi Nikos,

I am sorry for my bad description.
Imagining that we have this r2rml material:

`
@Prefix rr: http://www.w3.org/ns/r2rml#.
@Prefix xsd: http://www.w3.org/2001/XMLSchema#.
@Prefix ex: http://example.com/ns#.
ex:TriplesMap_Dept
rr:logicalTable [ rr:tableName "DEPT_CN" ];
rr:subjectMap [
rr:template "http://data.example.com/department/{DEPTNO}";
rr:class ex:Department;
];
rr:predicateObjectMap [
rr:predicate ex:deptNum;
rr:objectMap [ rr:column "DEPTNO" ; rr:datatype xsd:integer ];
];
rr:predicateObjectMap [
rr:predicate ex:deptName;
rr:objectMap [ rr:column "DNAME" ; rr:language "zh-cn" ];
];
rr:predicateObjectMap [
rr:predicate ex:deptLocation;
rr:objectMap [ rr:column "LOC" ; rr:language "zh-cn" ];
].

ex:TriplesMap_Emp
rr:logicalTable [ rr:tableName "EMP_CN" ];
rr:subjectMap [
rr:template "http://data.example.com/employee/{EMPNO}";
rr:class ex:Employee;
];
rr:predicateObjectMap [
rr:predicate ex:empNum;
rr:objectMap [ rr:column "EMPNO" ; rr:datatype xsd:integer ];
];
rr:predicateObjectMap [
rr:predicate ex:empName;
rr:objectMap [ rr:column "ENAME" ; rr:language "zh-cn" ];
];
rr:predicateObjectMap [
rr:predicate ex:jobType;
rr:objectMap [ rr:column "JOB" ; rr:language "zh-cn" ];
];
rr:predicateObjectMap [
rr:predicate ex:worksForDeptNum;
rr:objectMap [ rr:column "DEPTNO" ; rr:dataType xsd:integer ];
];
rr:predicateObjectMap [
rr:predicate ex:worksForDept;
rr:objectMap [
rr:parentTriplesMap ex:TriplesMap_Dept ;
rr:joinCondition [ rr:child "DEPTNO"; rr:parent "DEPTNO" ]]].
`

According to the first loop, every rr:predicateObjectMap for which RefObjectMap is null will make its LogicalTableMapping be added into the first linkedlist.

In our example, ex:TriplesMap_Dept will be added into the first linkedlist three times because there are three rr:predicateObjectMap for which RefObjectMap is null. ex:TriplesMap_Emp will be added into the first linkedlist four times and be added into second linkedlist once because there are four rr:predicateObjectMap for which RefObjectMap is null and one rr:predicateObjectMap is not null.

And I confirmed by add a break-point at end of first loop to watch elements in the first linkedlist.

Is that correct?

And I also confirmed that if there is only one Jena RDF result model across all process, duplicates in linkedlist will not cause any more triples but I try to use multiple model to reduce memory usage which will make duplicates in linkedlist parsed twice or more.

If there are any unclear descriptions, please question me. Thank you very much!

Jason

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants