Skip to content

Commit

Permalink
Debugging duplicate case.
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-brandizi committed Aug 28, 2023
1 parent f672519 commit 5cb37ee
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

import org.apache.jena.query.QuerySolution;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -38,7 +39,7 @@
@Component
@Scope ( scopeName = "pgmakerSession" )
public class GraphMLRelationExportHandler extends PGRelationHandler
{
{
@Autowired
private GraphMLDataManager graphmlDataMgr;

Expand All @@ -54,21 +55,27 @@ public void accept ( Set<QuerySolution> relRecords )
this.renameThread ( "graphmlRelX:" );
log.trace ( "Begin of {} relations", relRecords.size () );

Set<Integer> ondexIds = ConcurrentHashMap.newKeySet();

RdfDataManager rdfMgr = this.getRdfDataManager ();
for ( QuerySolution row : relRecords )
{
PGRelation pgRelation = rdfMgr.getPGRelation ( row );
rdfMgr.setPGRelationProps ( pgRelation, this.getRelationPropsSparql () );

// TODO: remove, debug
int relOndexId = Optional.ofNullable ( pgRelation.getProperties ().get ( "ondexId" ) )
.map ( pv -> ((Set<Object>) pv) )
.filter ( pvset -> !pvset.isEmpty () )
.map ( pvset -> pvset.iterator ().next () )
.map ( String::valueOf )
.map ( Integer::valueOf )
.orElse ( -1 );
if ( relOndexId == 677351 ) log.warn ( "====> THE TEST REL IS HERE (HANDLER) <======" );
// TODO: remove, debug
int relOndexId = Optional.ofNullable ( pgRelation.getProperties ().get ( "ondexId" ) )
.map ( pv -> ((Set<Object>) pv) )
.filter ( pvset -> !pvset.isEmpty () )
.map ( pvset -> pvset.iterator ().next () )
.map ( String::valueOf )
.map ( Integer::valueOf )
.orElse ( -1 );

if ( ondexIds.contains ( relOndexId ) )
log.warn ( "==== DUPED ID {} IN PROCESSOR", relOndexId );
else
ondexIds.add ( relOndexId );

String type = pgRelation.getType ();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package uk.ac.rothamsted.kg.rdf2pg.graphml.export.support;

import java.util.Collections;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;

import org.apache.jena.query.QuerySolution;
Expand All @@ -24,6 +27,8 @@
@Component @Scope ( scopeName = "pgmakerSession" )
public class GraphMLRelationExportProcessor extends PGRelationMakeProcessor<GraphMLRelationExportHandler>
{
private static Set<Integer> ondexIds = ConcurrentHashMap.newKeySet();

public GraphMLRelationExportProcessor ()
{
super ();
Expand All @@ -49,24 +54,18 @@ public void process ( RdfDataManager rdfMgr, Object...opts )
solProc -> rdfMgr.processRelationIris ( handler.getRelationTypesSparql (),
qsol -> {

int relOndexId = Optional.ofNullable ( qsol.get ( "ondexId" ) )
.filter ( RDFNode::isLiteral )
.map ( RDFNode::asLiteral )
.map ( Literal::getInt )
.orElse ( -1 );
int relOndexId = Optional.ofNullable ( qsol.get ( "ondexId" ) )
.filter ( RDFNode::isLiteral )
.map ( RDFNode::asLiteral )
.map ( Literal::getInt )
.orElse ( -1 );

if ( relOndexId == 677351 ) log.warn ( "====> THE TEST REL IS HERE (BEFORE) <======" );
if ( ondexIds.contains ( relOndexId ) )
log.warn ( "==== DUPED ID {} IN PROCESSOR", relOndexId );
else
ondexIds.add ( relOndexId );

solProc.accept ( qsol );

relOndexId = Optional.ofNullable ( qsol.get ( "ondexId" ) )
.filter ( RDFNode::isLiteral )
.map ( RDFNode::asLiteral )
.map ( Literal::getInt )
.orElse ( -1 );

if ( relOndexId == 677351 ) log.warn ( "====> THE TEST REL IS HERE (AFTER) <======" );

}
);

Expand Down

0 comments on commit 5cb37ee

Please sign in to comment.