[ https://issues.apache.org/jira/browse/RYA-165?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15487719#comment-15487719 ]
ASF GitHub Bot commented on RYA-165: ------------------------------------ Github user amihalik commented on a diff in the pull request: https://github.com/apache/incubator-rya/pull/90#discussion_r78598233 --- Diff: dao/accumulo.rya/src/main/java/mvm/rya/accumulo/utils/VisibilitySimplifier.java --- @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mvm.rya.accumulo.utils; + +import static java.util.Objects.requireNonNull; + +import javax.annotation.ParametersAreNonnullByDefault; + +import org.apache.accumulo.core.security.ColumnVisibility; + +import com.google.common.base.Charsets; + +/** + * Simplifies Accumulo visibility expressions. + */ +@ParametersAreNonnullByDefault +public class VisibilitySimplifier { + + /** + * Simplifies an Accumulo visibility expression. + * + * @param visibility - The expression to simplify. (not null) + * @return A simplified form of {@code visibility}. + */ + public String simplify(final String visibility) { + requireNonNull(visibility); + + String last = visibility; + String simplified = new String(new ColumnVisibility(visibility).flatten(), Charsets.UTF_8); + + while(!simplified.equals(last)) { --- End diff -- wow. Is this really necessary? I'm disappointed that you have to run this multiple times to completely flatten the expression. > Fluo PCJ maintenance should use ColumnVisibility.flatten() to simplify the > visibility expression > ------------------------------------------------------------------------------------------------ > > Key: RYA-165 > URL: https://issues.apache.org/jira/browse/RYA-165 > Project: Rya > Issue Type: Bug > Components: dao > Reporter: Puja Valiyil > Assignee: Kevin Chilton > Priority: Critical > > The Fluo application that maintains PCJ indices currently creates complex > visibility expressions that grow with every join that is part of the SPARQL > query. > For example, if you create a PCJ for the following SPARQL: > {code} > SELECT ?customer ?worker ?city { > ?customer <urn:talksTo> ?worker. > ?worker <urn:livesIn> ?city. > ?worker <urn:worksAt> <urn:BurgerJoint>. > } > {code} > And you insert the following Statements: > {code} > Statement: "<urn:Alice> <urn:talksTo> <urn:Bob>" Visibility: "u" > Statement: "<urn:Bob> <urn:livesIn> <urn:Happyville>" Visibility: "u" > Statement: "<urn:Bob> <urn:worksAt> <urn:BurgerJoin>" Visibility: "u" > {code} > Then the following result will be exported to the PCJ index: > {code} > BindingSet: {{"customer", "urn:Alice"}, {"worker","urn:Bob"}, {"city", > "urn:Happyville"} Visibility: "(u&u)&u" > {code} > That visibility expression could also be represented as just "u". > ColumnVisibility.flatten() calls may be used to iteratively simplify the > logical expression, so update the Fluo application to do so before exporting > the result. -- This message was sent by Atlassian JIRA (v6.3.4#6332)