Package org.jrdf.graph

Examples of org.jrdf.graph.Graph


        return application.getGraphsDir();
    }

    private void refreshGraphsModel() {
        final File file = new File(handler.getDir(), graphsFile);
        final Graph modelsGraph = new RdfReader().parseNTriples(file);
        final Models model = new ModelsImpl(modelsGraph);
        this.resources = model.getResources();
    }
View Full Code Here


        }
    }

    private void testPerformance(int numberToAdd, int numberToFind, int numberToUpdate) throws Exception {
        checkParameters(numberToAdd, numberToFind, numberToUpdate);
        Graph graph = getGraph();
        //new ParsePerformanceImpl(getMapFactory()).parse(graph, this);
        new AddPerformanceImpl(NUMBER_OF_PREDICATES, SUBJECT_PREFIX, PREDICATE_PREFIX, OBJECT_PREFIX).addPerformance(
            numberToAdd == 0 ? NUMBER_OF_NODES_TO_ADD : numberToAdd, graph, this);
        new WritePerformanceImpl().writePerformance(graph, this, getBlankNodeRegistry());
        new FindPerformanceImpl(numberToFind == 0 ? NUMBER_OF_NODES_TO_FIND : numberToFind, SUBJECT_PREFIX
View Full Code Here

public class DiskPerformance extends AbstractGraphPerformance {
    private final TempDirectoryHandler dirHandler = new TempDirectoryHandler();
    private JRDFFactory factory = SortedDiskJRDFFactory.getFactory();

    protected Graph getGraph() {
        Graph newGraph = factory.getNewGraph();
        newGraph.clear();
        return newGraph;
    }
View Full Code Here

    @Override
    public void parseOneFile(Project project, ProjectMetadata metadata,
            ImportingJob job, String fileSource, InputStream input, int limit,
            JSONObject options, List<Exception> exceptions) {
       
        Graph graph;
        switch (mode) {
        case NT:
            graph = rdfReader.parseNTriples(input);
            break;
        case N3:
            graph = rdfReader.parseN3(input);
            break;
        case RDFXML:
            graph = rdfReader.parseRdfXml(input);            
            break;
        default:
            throw new IllegalArgumentException("Unknown parsing mode");   
        }
       
        ClosableIterable<Triple> triples = graph.find(ANY_SUBJECT_NODE, ANY_PREDICATE_NODE, ANY_OBJECT_NODE);
        try {
            Map<String, List<Row>> subjectToRows = new HashMap<String, List<Row>>();
            Column subjectColumn = new Column(project.columnModel.allocateNewCellIndex(), "subject");
            project.columnModel.addColumn(0, subjectColumn, false);
            project.columnModel.setKeyColumnIndex(0);
View Full Code Here

        ReadableIndex<Long> readIndex = new ReadableIndexImpl(structureIndexes);
        WritableIndex<Long> writeIndex = new WritableIndexImpl(structureIndexes);
        LongIndex[] longIndexes = new LongIndex[]{new LongIndexAdapter(structureIndexes[0]),
            new LongIndexAdapter(structureIndexes[1]), new LongIndexAdapter(structureIndexes[2])};
        IteratorTrackingCollectionFactory collectionFactory = base.createCollectionFactory(graphNumber);
        Graph graph = new OrderedGraphFactoryImpl(longIndexes, nodePool, collectionFactory).getGraph();
        final long curMaxMoleculeId = readIndex.getMaxMoleculeId();
        Localizer localizer = new LocalizerImpl(nodePool, STRING_MAPPER);
        MoleculeLocalizer moleculeLocalizer = new MoleculeLocalizerImpl(localizer, curMaxMoleculeId);
        return new MoleculeGraphImpl(writeIndex, readIndex, moleculeLocalizer, graph, nodePool);
    }
View Full Code Here

        Localizer localizer = new LocalizerImpl(nodePool, STRING_MAPPER);
        MoleculeLocalizer moleculeLocalizer = new MoleculeLocalizerImpl(localizer);
        LongIndex[] longIndexes = new LongIndex[]{new LongIndexAdapter(structureIndexes[0]),
            new LongIndexAdapter(structureIndexes[1]), new LongIndexAdapter(structureIndexes[2])};
        IteratorTrackingCollectionFactory collectionFactory = new MemCollectionFactory();
        Graph graph = new OrderedGraphFactoryImpl(longIndexes, nodePool, collectionFactory).getGraph();
        return new MoleculeGraphImpl(writeIndex, readIndex, moleculeLocalizer, graph, nodePool);
    }
View Full Code Here

        LongIndex[] indexes = createIndexes();
        NodePoolFactory nodePoolFactory = new BdbNodePoolFactory(BDB_HANDLER, graphNumber);
        openIndexes.addAll(asList(indexes));
        openFactories.add(nodePoolFactory);
        collectionFactory = new BdbCollectionFactory(BDB_HANDLER, "collection" + graphNumber);
        final Graph graph = new OrderedGraphFactoryImpl(indexes, nodePoolFactory, collectionFactory).getGraph();
        graph.clear();
        return graph;
    }
View Full Code Here

        printOutTriples("foo");
        printOutTriples("bar");
    }

    private static void printOutTriples(String name) throws GraphException {
        Graph existingGraph = JRDF_FACTORY.getExistingGraph(name);
        long noTriples = existingGraph.getNumberOfTriples();
        System.out.println("Existing graph recovered " + name + ", found " + noTriples);
        System.out.println("Got: " + existingGraph);
    }
View Full Code Here

        System.out.println("Got: " + existingGraph);
    }

    private static void createNewTriples() throws GraphException {
        System.out.println("Creating new graphs");
        Graph fooGraph = JRDF_FACTORY.getNewGraph("foo");
        Graph barGraph = JRDF_FACTORY.getNewGraph("bar");
        GraphElementFactory barElementFactory = barGraph.getElementFactory();
        URI uri1 = URI.create("urn:hello");
        URI uri2 = URI.create("urn:there");
        Resource resource = barElementFactory.createResource(uri1);
        resource.addValue(uri1, uri2);
        resource.addValue(uri2, uri2);
View Full Code Here

    public static void main(String[] args) throws Exception {
        URL url = getDocumentURL(args);
        InputStream in = getInputStream(url);
        try {
            final Graph jrdfMem = JRDF_FACTORY.getNewGraph();
            Parser parser = new GraphRdfXmlParser(jrdfMem, new MemMapFactory());
            parser.parse(in, toEscapedString(url));
            ClosableIterable<Triple> triples = jrdfMem.find(ANY_SUBJECT_NODE, ANY_PREDICATE_NODE, ANY_OBJECT_NODE);
            try {
                for (Triple triple : triples) {
                    System.out.println("Graph: " + triple);
                }
                System.out.println("Total number of statements: " + jrdfMem.getNumberOfTriples());
            } finally {
                triples.iterator().close();
            }
        } finally {
            in.close();
View Full Code Here

TOP

Related Classes of org.jrdf.graph.Graph

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.