Search in sources :

Example 6 with Transaction

use of org.apache.fluo.api.client.Transaction in project incubator-rya by apache.

the class FluoQueryMetadataDAOIT method projectionMetadataTest.

@Test
public void projectionMetadataTest() {
    final FluoQueryMetadataDAO dao = new FluoQueryMetadataDAO();
    // Create the object that will be serialized.
    final ProjectionMetadata.Builder builder = ProjectionMetadata.builder("nodeId");
    builder.setVarOrder(new VariableOrder("y;s;d"));
    builder.setProjectedVars(new VariableOrder("x;y;z"));
    builder.setChildNodeId("childNodeId");
    builder.setParentNodeId("parentNodeId");
    final ProjectionMetadata originalMetadata = builder.build();
    try (FluoClient fluoClient = FluoFactory.newClient(super.getFluoConfiguration())) {
        // Write it to the Fluo table.
        try (Transaction tx = fluoClient.newTransaction()) {
            dao.write(tx, originalMetadata);
            tx.commit();
        }
        // Read it from the Fluo table.
        ProjectionMetadata storedMetdata = null;
        try (Snapshot sx = fluoClient.newSnapshot()) {
            storedMetdata = dao.readProjectionMetadata(sx, "nodeId");
        }
        // Ensure the deserialized object is the same as the serialized one.
        assertEquals(originalMetadata, storedMetdata);
    }
}
Also used : Snapshot(org.apache.fluo.api.client.Snapshot) FluoClient(org.apache.fluo.api.client.FluoClient) Transaction(org.apache.fluo.api.client.Transaction) VariableOrder(org.apache.rya.indexing.pcj.storage.accumulo.VariableOrder) Test(org.junit.Test)

Example 7 with Transaction

use of org.apache.fluo.api.client.Transaction in project incubator-rya by apache.

the class FluoQueryMetadataDAOIT method aggregationMetadataTest_noGroupByVarOrders.

@Test
public void aggregationMetadataTest_noGroupByVarOrders() {
    final FluoQueryMetadataDAO dao = new FluoQueryMetadataDAO();
    // Create the object that will be serialized.
    final AggregationMetadata originalMetadata = AggregationMetadata.builder("nodeId").setVarOrder(new VariableOrder("totalCount")).setParentNodeId("parentNodeId").setChildNodeId("childNodeId").addAggregation(new AggregationElement(AggregationType.COUNT, "count", "totalCount")).addAggregation(new AggregationElement(AggregationType.AVERAGE, "privae", "avgPrice")).build();
    try (FluoClient fluoClient = FluoFactory.newClient(super.getFluoConfiguration())) {
        // Write it to the Fluo table.
        try (Transaction tx = fluoClient.newTransaction()) {
            dao.write(tx, originalMetadata);
            tx.commit();
        }
        // Read it from the Fluo table.
        AggregationMetadata storedMetadata = null;
        try (Snapshot sx = fluoClient.newSnapshot()) {
            storedMetadata = dao.readAggregationMetadata(sx, "nodeId");
        }
        // Ensure the deserialized object is the same as the serialized one.
        assertEquals(originalMetadata, storedMetadata);
    }
}
Also used : Snapshot(org.apache.fluo.api.client.Snapshot) AggregationElement(org.apache.rya.api.function.aggregation.AggregationElement) FluoClient(org.apache.fluo.api.client.FluoClient) Transaction(org.apache.fluo.api.client.Transaction) VariableOrder(org.apache.rya.indexing.pcj.storage.accumulo.VariableOrder) Test(org.junit.Test)

Example 8 with Transaction

use of org.apache.fluo.api.client.Transaction in project incubator-rya by apache.

the class FluoQueryMetadataDAOIT method filterMetadataTest.

@Test
public void filterMetadataTest() {
    final FluoQueryMetadataDAO dao = new FluoQueryMetadataDAO();
    // Create the object that will be serialized.
    final FilterMetadata.Builder builder = FilterMetadata.builder("nodeId");
    builder.setVarOrder(new VariableOrder("e;f"));
    builder.setParentNodeId("parentNodeId");
    builder.setChildNodeId("childNodeId");
    builder.setFilterSparql("originalSparql");
    final FilterMetadata originalMetadata = builder.build();
    try (FluoClient fluoClient = FluoFactory.newClient(super.getFluoConfiguration())) {
        // Write it to the Fluo table.
        try (Transaction tx = fluoClient.newTransaction()) {
            dao.write(tx, originalMetadata);
            tx.commit();
        }
        // Read it from the Fluo table.
        FilterMetadata storedMetadata = null;
        try (Snapshot sx = fluoClient.newSnapshot()) {
            storedMetadata = dao.readFilterMetadata(sx, "nodeId");
        }
        // Ensure the deserialized object is the same as the serialized one.
        assertEquals(originalMetadata, storedMetadata);
    }
}
Also used : Snapshot(org.apache.fluo.api.client.Snapshot) FluoClient(org.apache.fluo.api.client.FluoClient) Transaction(org.apache.fluo.api.client.Transaction) VariableOrder(org.apache.rya.indexing.pcj.storage.accumulo.VariableOrder) Test(org.junit.Test)

Example 9 with Transaction

use of org.apache.fluo.api.client.Transaction in project incubator-rya by apache.

the class BatchIT method createSpanBatch.

private void createSpanBatch(FluoClient fluoClient, String nodeId, BatchInformation batch) {
    try (Transaction tx = fluoClient.newTransaction()) {
        BatchInformationDAO.addBatch(tx, nodeId, batch);
        tx.commit();
    }
}
Also used : Transaction(org.apache.fluo.api.client.Transaction)

Example 10 with Transaction

use of org.apache.fluo.api.client.Transaction in project incubator-rya by apache.

the class BatchIT method createSpanBatches.

private void createSpanBatches(FluoClient fluoClient, List<String> ids, List<String> prefixes, int batchSize) {
    Preconditions.checkArgument(ids.size() == prefixes.size());
    try (Transaction tx = fluoClient.newTransaction()) {
        for (int i = 0; i < ids.size(); i++) {
            String id = ids.get(i);
            String bsPrefix = prefixes.get(i);
            URI uri = vf.createURI(bsPrefix);
            Bytes prefixBytes = BindingHashShardingFunction.getShardedScanPrefix(id, uri);
            NodeType type = NodeType.fromNodeId(id).get();
            Column bsCol = type.getResultColumn();
            SpanBatchDeleteInformation.Builder builder = SpanBatchDeleteInformation.builder().setBatchSize(batchSize).setColumn(bsCol);
            if (type == NodeType.JOIN) {
                builder.setSpan(Span.prefix(type.getNodeTypePrefix()));
                builder.setNodeId(java.util.Optional.of(id));
            } else {
                builder.setSpan(Span.prefix(prefixBytes));
            }
            BatchInformationDAO.addBatch(tx, id, builder.build());
        }
        tx.commit();
    }
}
Also used : Bytes(org.apache.fluo.api.data.Bytes) Transaction(org.apache.fluo.api.client.Transaction) Column(org.apache.fluo.api.data.Column) NodeType(org.apache.rya.indexing.pcj.fluo.app.NodeType) URI(org.openrdf.model.URI) RyaURI(org.apache.rya.api.domain.RyaURI) SpanBatchDeleteInformation(org.apache.rya.indexing.pcj.fluo.app.batch.SpanBatchDeleteInformation)

Aggregations

Transaction (org.apache.fluo.api.client.Transaction)28 Test (org.junit.Test)17 FluoClient (org.apache.fluo.api.client.FluoClient)15 Snapshot (org.apache.fluo.api.client.Snapshot)13 VariableOrder (org.apache.rya.indexing.pcj.storage.accumulo.VariableOrder)11 NodeType (org.apache.rya.indexing.pcj.fluo.app.NodeType)5 Bytes (org.apache.fluo.api.data.Bytes)4 SpanBatchDeleteInformation (org.apache.rya.indexing.pcj.fluo.app.batch.SpanBatchDeleteInformation)3 HashSet (java.util.HashSet)2 Column (org.apache.fluo.api.data.Column)2 RyaStatement (org.apache.rya.api.domain.RyaStatement)2 AggregationElement (org.apache.rya.api.function.aggregation.AggregationElement)2 TripleRowResolverException (org.apache.rya.api.resolver.triple.TripleRowResolverException)2 FluoQueryMetadataDAO (org.apache.rya.indexing.pcj.fluo.app.query.FluoQueryMetadataDAO)2 ColumnScanner (org.apache.fluo.api.client.scanner.ColumnScanner)1 RowScanner (org.apache.fluo.api.client.scanner.RowScanner)1 ColumnValue (org.apache.fluo.api.data.ColumnValue)1 RyaURI (org.apache.rya.api.domain.RyaURI)1 FluoQueryStringBuilder (org.apache.rya.indexing.pcj.fluo.api.ListFluoQueries.FluoQueryStringBuilder)1 BindingSetRow (org.apache.rya.indexing.pcj.fluo.app.BindingSetRow)1