Package org.renjin.eval

Examples of org.renjin.eval.Session


    }
    try {

      // initialize our master context here; a fresh but shallow copy will
      // be forked on each incoming request
      Session session = new SessionBuilder()
      .withFileSystemManager(fileSystemManager)
      .withDefaultPackages()
      .build();
     
      session.setWorkingDirectory(fileSystemManager.resolveFile("file:///"));
     
      return session;
    } catch (IOException e) {
      LOG.log(Level.SEVERE, "Failed to initialize master context", e);
      throw new RuntimeException(e);
View Full Code Here


    }

    configureLogging();

    try {
      Session session = createSession();

      if(options.has("e")) {
        evaluateExpression(session, (String) options.valueOf("e"));
      } else if(options.has("f")) {
        evaluateFile(session, (String) options.valueOf("f"));
View Full Code Here

  }

  public static Session createSession() throws Exception {
    threadPool = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());

    Session session = new SessionBuilder()
        .bind(PackageLoader.class, new AetherPackageLoader())
        .bind(VectorPipeliner.class, new MultiThreadedVectorPipeliner(threadPool))
        .build();
    Environment replEnv = session.getGlobalEnvironment().insertAbove(new HashFrame());
    loadDefaultPackages(session);
    return session;
  }
View Full Code Here

  @Test
  public void rootFile() throws IOException {
    DefaultLocalFileProvider localFileProvider = new DefaultLocalFileProvider();
    FileSystemManager fsm = AppEngineContextFactory.createFileSystemManager(localFileProvider);

    Session session = new SessionBuilder()
    .withFileSystemManager(fsm)
    .build();
   
    session.setWorkingDirectory(FileSystemUtils.workingDirectory(fsm));
  
    Context context = session.getTopLevelContext();

    context.evaluate( Symbol.get("search") );
  }
View Full Code Here

    if(!(exp instanceof PairList)) {
      throw new UnsupportedOperationException("Expected to find a pairlist in " + dataFile + ", found a " + exp.getTypeName());
    }
   
    String logicalDatasetName = stripExtension(dataFile.getName());
    Session session = new SessionBuilder().withoutBasePackage().build();
    writePairList(logicalDatasetName, session, (PairList)exp);
  }
View Full Code Here

    args.add("sep", StringVector.valueOf(sep));

    FunctionCall readTable = FunctionCall.newCall(Symbol.get("::"), Symbol.get("utils"), Symbol.get("read.table"));
    FunctionCall call = new FunctionCall(readTable, args.build());

    Session session = new SessionBuilder().build();
    SEXP dataFrame = session.getTopLevelContext().evaluate(call);

    PairList.Builder pairList = new PairList.Builder();
    pairList.add(logicalDatasetName, dataFrame);

    writePairList(logicalDatasetName, session, pairList.build());
View Full Code Here

   * namespace are considered part of the dataset.
   *
   */
  private void processRScript(File scriptFile, String logicalDatasetName) throws IOException {

    Session session = new SessionBuilder().build();
    FileReader reader = new FileReader(scriptFile);
    ExpressionVector source = RParser.parseAllSource(reader);
    reader.close();
   
    session.getTopLevelContext().evaluate(source);
   
    PairList.Builder pairList = new PairList.Builder();
    for(Symbol symbol : session.getGlobalEnvironment().getSymbolNames()) {
      if(!symbol.getPrintName().startsWith(".")) {
        pairList.add(symbol, session.getGlobalEnvironment().getVariable(symbol));
      }
    }  
    writePairList(logicalDatasetName, session, pairList.build());
  }
View Full Code Here

  public static void main(String[] args) throws IOException {
    // Evaluate the base sources into the base namespace environment
 
    Session session = new SessionBuilder()
    .withoutBasePackage()
    .build();
   
    Context context = session.getTopLevelContext();
    Environment baseNamespaceEnv = context.getNamespaceRegistry().getBase().getNamespaceEnvironment();
    Context evalContext = context.beginEvalContext(baseNamespaceEnv);
   
    File baseSourceRoot = new File("src/main/R/base");
    evalSources(evalContext, baseSourceRoot);
View Full Code Here

    }
  }
 
  private Session createSession(File workingDir) throws IOException  {

    Session session = SessionBuilder.buildDefault();
    session.setWorkingDirectory(
        session.getFileSystemManager()
          .resolveFile(workingDir.toURI().toString()));
   
    session.setStdErr(reporter.getStdOutWriter());
    session.setStdOut(reporter.getStdOutWriter());
   
    if(defaultPackages.isEmpty()) {
      System.err.println("No default packages specified");
    }
   
View Full Code Here

      return;
    }
   
    reporter.startFunction("root");
   
    Session session = createSession(sourceFile.getParentFile());

    // Examples assume that the package is already on the search path
    if(sourceFile.getName().endsWith(".Rd")) {
      loadLibrary(session, namespaceUnderTest);
    }
   
    UnsupportedTerminal term = new UnsupportedTerminal();
    InputStream in = new ByteArrayInputStream(sourceText.getBytes(Charsets.UTF_8));
    ConsoleReader consoleReader = new ConsoleReader(in, reporter.getStdOut(), term);
    JlineRepl repl = new JlineRepl(session, consoleReader);
    repl.setEcho(true);
    repl.setStopOnError(true);

    try {
      repl.run();
      reporter.functionSucceeded();
   
    } catch(Throwable e) {
      reporter.functionThrew(e);
      return;
    }
   
    // look for "junit-style" test functions.
    // This is renjin's own convention, but it's nice to be
    // able to see the results of many tests rather than
    // topping at the first error
    for(Symbol name : session.getGlobalEnvironment().getSymbolNames()) {
      if(name.getPrintName().startsWith("test.")) {
        SEXP value = session.getGlobalEnvironment().getVariable(name);
        if(isZeroArgFunction(value)) {
          executeTestFunction(session.getTopLevelContext(), name);
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.renjin.eval.Session

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.