Search in sources :

Example 1 with Nullable

use of edu.umd.cs.findbugs.annotations.Nullable in project hbase by apache.

the class MetaTableAccessor method getRegionsFromMergeQualifier.

/**
   * Get regions from the merge qualifier of the specified merged region
   * @return null if it doesn't contain merge qualifier, else two merge regions
   * @throws IOException
   */
@Nullable
public static Pair<HRegionInfo, HRegionInfo> getRegionsFromMergeQualifier(Connection connection, byte[] regionName) throws IOException {
    Result result = getRegionResult(connection, regionName);
    HRegionInfo mergeA = getHRegionInfo(result, HConstants.MERGEA_QUALIFIER);
    HRegionInfo mergeB = getHRegionInfo(result, HConstants.MERGEB_QUALIFIER);
    if (mergeA == null && mergeB == null) {
        return null;
    }
    return new Pair<>(mergeA, mergeB);
}
Also used : Result(org.apache.hadoop.hbase.client.Result) Pair(org.apache.hadoop.hbase.util.Pair) Nullable(edu.umd.cs.findbugs.annotations.Nullable)

Example 2 with Nullable

use of edu.umd.cs.findbugs.annotations.Nullable in project incubator-rya by apache.

the class MultiProjectionEvaluatorTest method getMultiProjection.

/**
 * Get the first {@link MultiProjection} node from a SPARQL query.
 *
 * @param sparql - The query that contains a single Projection node.
 * @return The first {@link MultiProjection} that is encountered.
 * @throws Exception The query could not be parsed.
 */
@Nullable
public static MultiProjection getMultiProjection(final String sparql) throws Exception {
    requireNonNull(sparql);
    final AtomicReference<MultiProjection> multiProjection = new AtomicReference<>();
    final ParsedQuery parsed = new SPARQLParser().parseQuery(sparql, null);
    parsed.getTupleExpr().visit(new QueryModelVisitorBase<Exception>() {

        @Override
        public void meet(final MultiProjection node) throws Exception {
            multiProjection.set(node);
        }
    });
    return multiProjection.get();
}
Also used : SPARQLParser(org.openrdf.query.parser.sparql.SPARQLParser) ParsedQuery(org.openrdf.query.parser.ParsedQuery) AtomicReference(java.util.concurrent.atomic.AtomicReference) MultiProjection(org.openrdf.query.algebra.MultiProjection) Nullable(edu.umd.cs.findbugs.annotations.Nullable)

Example 3 with Nullable

use of edu.umd.cs.findbugs.annotations.Nullable in project incubator-rya by apache.

the class ProjectionEvaluatorTest method getProjection.

/**
 * Get the first {@link Projection} node from a SPARQL query.
 *
 * @param sparql - The query that contains a single Projection node.
 * @return The first {@link Projection} that is encountered.
 * @throws Exception The query could not be parsed.
 */
@Nullable
public static Projection getProjection(final String sparql) throws Exception {
    requireNonNull(sparql);
    final AtomicReference<Projection> projection = new AtomicReference<>();
    final ParsedQuery parsed = new SPARQLParser().parseQuery(sparql, null);
    parsed.getTupleExpr().visit(new QueryModelVisitorBase<Exception>() {

        @Override
        public void meet(final Projection node) throws Exception {
            projection.set(node);
        }
    });
    return projection.get();
}
Also used : SPARQLParser(org.openrdf.query.parser.sparql.SPARQLParser) ParsedQuery(org.openrdf.query.parser.ParsedQuery) Projection(org.openrdf.query.algebra.Projection) AtomicReference(java.util.concurrent.atomic.AtomicReference) Nullable(edu.umd.cs.findbugs.annotations.Nullable)

Example 4 with Nullable

use of edu.umd.cs.findbugs.annotations.Nullable in project incubator-rya by apache.

the class RdfTestUtil method getMultiProjection.

/**
 * Get the first {@link MultiProjection} node from a SPARQL query.
 *
 * @param sparql - The query that contains a single Projection node.
 * @return The first {@link MultiProjection} that is encountered.
 * @throws Exception The query could not be parsed.
 */
@Nullable
public static MultiProjection getMultiProjection(final String sparql) throws Exception {
    requireNonNull(sparql);
    final AtomicReference<MultiProjection> multiProjection = new AtomicReference<>();
    final ParsedQuery parsed = new SPARQLParser().parseQuery(sparql, null);
    parsed.getTupleExpr().visit(new QueryModelVisitorBase<Exception>() {

        @Override
        public void meet(final MultiProjection node) throws Exception {
            multiProjection.set(node);
        }
    });
    return multiProjection.get();
}
Also used : SPARQLParser(org.openrdf.query.parser.sparql.SPARQLParser) ParsedQuery(org.openrdf.query.parser.ParsedQuery) AtomicReference(java.util.concurrent.atomic.AtomicReference) MultiProjection(org.openrdf.query.algebra.MultiProjection) Nullable(edu.umd.cs.findbugs.annotations.Nullable)

Example 5 with Nullable

use of edu.umd.cs.findbugs.annotations.Nullable in project incubator-rya by apache.

the class RdfTestUtil method getFilter.

/**
 * Get the first {@link Filter} node from a SPARQL query.
 *
 * @param sparql - The query that contains a single Projection node.
 * @return The first {@link Filter} that is encountered.
 * @throws Exception The query could not be parsed.
 */
@Nullable
public static Filter getFilter(final String sparql) throws Exception {
    requireNonNull(sparql);
    final AtomicReference<Filter> filter = new AtomicReference<>();
    final ParsedQuery parsed = new SPARQLParser().parseQuery(sparql, null);
    parsed.getTupleExpr().visit(new QueryModelVisitorBase<Exception>() {

        @Override
        public void meet(final Filter node) throws Exception {
            filter.set(node);
        }
    });
    return filter.get();
}
Also used : SPARQLParser(org.openrdf.query.parser.sparql.SPARQLParser) Filter(org.openrdf.query.algebra.Filter) ParsedQuery(org.openrdf.query.parser.ParsedQuery) AtomicReference(java.util.concurrent.atomic.AtomicReference) Nullable(edu.umd.cs.findbugs.annotations.Nullable)

Aggregations

Nullable (edu.umd.cs.findbugs.annotations.Nullable)17 AtomicReference (java.util.concurrent.atomic.AtomicReference)9 ParsedQuery (org.openrdf.query.parser.ParsedQuery)8 SPARQLParser (org.openrdf.query.parser.sparql.SPARQLParser)8 Result (org.apache.hadoop.hbase.client.Result)3 TableState (org.apache.hadoop.hbase.client.TableState)3 TerminalSize (org.apache.hadoop.hbase.hbtop.terminal.TerminalSize)3 MultiProjection (org.openrdf.query.algebra.MultiProjection)3 Filter (org.openrdf.query.algebra.Filter)2 Projection (org.openrdf.query.algebra.Projection)2 StatementPattern (org.openrdf.query.algebra.StatementPattern)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 NavigableMap (java.util.NavigableMap)1 SortedMap (java.util.SortedMap)1 Get (org.apache.hadoop.hbase.client.Get)1 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)1 Table (org.apache.hadoop.hbase.client.Table)1