Package net.sf.afluentes

Examples of net.sf.afluentes.GraphReducer


import net.sf.afluentes.impl.GraphReducerImpl;

class Bhaskara {
      double delta(double a, double b, double c)
          throws InterruptedException, VerticesProcessingException {
        GraphReducer reducer;
        VertexBuilder<OpRes> subBuilder;
        VertexBuilder<OpRes> mulBuilder;
        Vertex<OpRes> delta;
        Vertex<OpRes> b2;
        Vertex<OpRes> ac;
        Vertex<OpRes> _4ac;   
       
/*11*/  reducer = new GraphReducerImpl();                      
           
/*13*/  subBuilder = reducer.addProcessor(new SubProcessor());
/*14*/  mulBuilder = reducer.addProcessor(new MulProcessor());
           
/*16*/  mulBuilder.createVertex(new OpRes(b, b));
        b2 = mulBuilder.getVertex();
       
/*19*/  mulBuilder.createVertex(new OpRes(a, c));
        ac = mulBuilder.getVertex();
       
/*22*/  mulBuilder.createVertex(new OpRes(4));
/*23*/  mulBuilder.appendEdge(ac, SetY.INSTANCE);
        _4ac = mulBuilder.getVertex();
       
/*26*/  subBuilder.createVertex(new OpRes());
/*27*/  subBuilder.appendEdge(b2, SetX.INSTANCE);
/*28*/  subBuilder.appendEdge(_4ac, SetY.INSTANCE);
        delta = subBuilder.getVertex();
      
/*31*/  reducer.reduceGraph(delta);
       
        return delta.getContent().result;
      }
View Full Code Here


        return delta.getContent().result;
      }

  Collection<Double> roots(double a, double b, double c)
      throws InterruptedException, VerticesProcessingException {
    GraphReducer reducer;
    VertexBuilder<OpRes> addBuilder;
    VertexBuilder<OpRes> subBuilder;
    VertexBuilder<OpRes> mulBuilder;
    VertexBuilder<OpRes> divBuilder;
    VertexBuilder<OpRes> sqrtBuilder;
    VertexBuilder<Collection<Double>> rootsBuilder;
    Vertex<OpRes> delta;
    DeltaListener listener;
    Vertex<Collection<Double>> roots;

    reducer = new GraphReducerImpl();

    addBuilder = reducer.addProcessor(new AddProcessor());
    subBuilder = reducer.addProcessor(new SubProcessor());
    mulBuilder = reducer.addProcessor(new MulProcessor());
    divBuilder = reducer.addProcessor(new DivProcessor());
    sqrtBuilder = reducer.addProcessor(new SqrtProcessor());
    rootsBuilder = reducer.addProcessor(new RootsProcessor());

    delta = createDelta(a, b, c, subBuilder, mulBuilder);

    listener = new DeltaListener();
    listener.a = a;
    listener.b = b;
    listener.c = c;
    listener.addBuilder = addBuilder;
    listener.subBuilder = subBuilder;
    listener.mulBuilder = mulBuilder;
    listener.divBuilder = divBuilder;
    listener.sqrtBuilder = sqrtBuilder;

    rootsBuilder.createVertex(new ArrayList<Double>(2));
    rootsBuilder.appendEdge(delta, listener);
    roots = rootsBuilder.getVertex();

    reducer.reduceGraph(roots);

    return roots.getContent();
  }
View Full Code Here

        void importOrders(DataSource dataSource, InputSource inputSource)
            throws SQLException, ParserConfigurationException, SAXException, IOException, InterruptedException, VerticesProcessingException {
          Connection connection;
          SingletonDataSource updateDataSource;
          ExecutorServiceFactory factory;
          GraphReducer reducer;
          GraphBuilder builder;
          OrdersParser parser;
          Vertex<Object> root;

          connection = null;
          try {
            connection = dataSource.getConnection();
            connection.setAutoCommit(false);
            updateDataSource = new SingletonDataSource(connection);

            factory = new FixedThreadPoolFactory(3);

            reducer = new GraphReducerImpl(factory);

            builder = new GraphBuilder();
            builder.rootBuilder = reducer.addProcessor(
              new SingleVertexProcessor<Object>());
            builder.selectCustomerBuilder = reducer.addProcessor(
              new SelectCustomerProcessor(dataSource), 50);
            builder.selectProductBuilder = reducer.addProcessor(
              new SelectProductProcessor(dataSource), 50);
            builder.insertOrderBuilder = reducer.addProcessor(
              new InsertOrderProcessor(updateDataSource), 50);
            builder.insertLineItemBuilder = reducer.addProcessor(
              new InsertLineItemProcessor(updateDataSource), 50);
 
            parser = new OrdersParser();
            parser.parse(builder, inputSource);
            root = builder.getRoot();
     
            reducer.reduceGraph(root);
          } catch (SQLException exception) {
            JdbcUtils.rollback(connection);
            throw exception;
          } catch (ParserConfigurationException exception) {
          JdbcUtils.rollback(connection);
View Full Code Here

TOP

Related Classes of net.sf.afluentes.GraphReducer

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.