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

strange problems using the processor by java API #18

Open
seralf opened this issue Apr 7, 2017 · 5 comments
Open

strange problems using the processor by java API #18

seralf opened this issue Apr 7, 2017 · 5 comments

Comments

@seralf
Copy link
Contributor

seralf commented Apr 7, 2017

Hi

I'm currently trying to use the processor inside a data management workflow for a small POC: we are using CSVW as datasource (a CSV of ~5Mb, exposed on an "internal" http endpoint).

For my test I'm calling the processor from the shell and it works ok, instead when calling it from a Java wrapper (from Eclipse, with maven) sometimes it ends giving me no errors at all and producing less data!
Can there be issues related to dependencies, memory configuration, bad multithread or anyt other kind of requirements that I should be aware of and I could have missed?
What you suggest to check? Or on the other hand can you suggest me how to wrap the processor from Java? So I'll be able by myself to look for what I'm missing.

Thanks in advance.

@seralf
Copy link
Contributor Author

seralf commented Apr 10, 2017

For example I've used the following sequence (re-constructed following the sequence of calls on the Main.main on github):

package mypackage;

import ...

public class ExampleMainFromJava {

  public static void main(String[] args) {

    try {
      // TODO: delete repositories folder

      File mapping_file = Paths
          .get("some/path/my-mappingrml.ttl")
          .toFile();

      File outputFile = Paths.get("some/other/path/dump.ttl").toFile();

      RMLDocRetrieval mapDocRetrieval = new RMLDocRetrieval();
      final Repository repository = mapDocRetrieval.getMappingDoc(mapping_file.toString(), RDFFormat.TURTLE);

      // HERE I could work with the internal repository (for example for syncronize data on my endpoint)
      // check mapping
      if (repository == null) {
        System.err.println("Problem retrieving the RML Mapping Document");
        System.exit(1);
      }

      StdRMLMappingFactory mappingFactory = new StdRMLMappingFactory(); // skolemization?
      RMLMapping mapping = mappingFactory.extractRMLMapping(repository);

      String graphName = "";
      java.util.Map<String, String> parameters = null;
      String[] exeTriplesMap = null;

      String outputFormat = Rio.getWriterFormatForFileName(outputFile.toString()).getName().toLowerCase();

      RMLEngine engine = new StdRMLEngine(outputFile.toString());

      // exploded method:  engine.run(...);

      final RMLDataset runningDataset = engine.chooseSesameDataSet("dataset", outputFile.toString(), outputFormat);
      engine.runRMLMapping(runningDataset, mapping, graphName, parameters, exeTriplesMap);

     // close the repository
     runningDataset.closeRepository();

      Thread.sleep(2000);
      System.exit(0);

    } catch (Throwable e) {
      System.err.println("\n\n\n\nSOMETHING WENT WRONG!");
      e.printStackTrace(System.err);
    }
  }

}

@canarvaeza
Copy link

Hey, do you solve this?, do you have some code about how to use the processor on your own program?

@seralf
Copy link
Contributor Author

seralf commented Mar 27, 2018

Hi no I didn't resolve the issue, it's rather weird.

However in order to create a small POC re-using the code from Java, you could take a look at the code above

@canarvaeza
Copy link

I have a web app created with maven, so can you help me in how i can reuse the code?.
Copy pasting the folders to my project structure (to use the classes) or what is the best approach?

@seralf
Copy link
Contributor Author

seralf commented Mar 27, 2018 via email

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