Search in sources :

Example 6 with Nullable

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

the class TerminalImpl method doResizeIfNecessary.

@Nullable
@Override
public TerminalSize doResizeIfNecessary() {
    TerminalSize currentTerminalSize = queryTerminalSize();
    if (!currentTerminalSize.equals(cachedTerminalSize)) {
        cachedTerminalSize = currentTerminalSize;
        updateTerminalSize(cachedTerminalSize.getColumns(), cachedTerminalSize.getRows());
        return cachedTerminalSize;
    }
    return null;
}
Also used : TerminalSize(org.apache.hadoop.hbase.hbtop.terminal.TerminalSize) Nullable(edu.umd.cs.findbugs.annotations.Nullable)

Example 7 with Nullable

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

the class TableStateManager method readMetaState.

@Nullable
private TableState readMetaState(TableName tableName) throws IOException {
    TableState.State state = tableName2State.get(tableName);
    if (state != null) {
        return new TableState(tableName, state);
    }
    TableState tableState = MetaTableAccessor.getTableState(master.getConnection(), tableName);
    if (tableState != null) {
        tableName2State.putIfAbsent(tableName, tableState.getState());
    }
    return tableState;
}
Also used : TableState(org.apache.hadoop.hbase.client.TableState) Nullable(edu.umd.cs.findbugs.annotations.Nullable)

Example 8 with Nullable

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

the class CatalogFamilyFormat method getRegionLocations.

/**
 * Returns an HRegionLocationList extracted from the result.
 * @return an HRegionLocationList containing all locations for the region range or null if we
 *         can't deserialize the result.
 */
@Nullable
public static RegionLocations getRegionLocations(final Result r) {
    if (r == null) {
        return null;
    }
    RegionInfo regionInfo = getRegionInfo(r, HConstants.REGIONINFO_QUALIFIER);
    if (regionInfo == null) {
        return null;
    }
    List<HRegionLocation> locations = new ArrayList<>(1);
    NavigableMap<byte[], NavigableMap<byte[], byte[]>> familyMap = r.getNoVersionMap();
    locations.add(getRegionLocation(r, regionInfo, 0));
    NavigableMap<byte[], byte[]> infoMap = familyMap.get(HConstants.CATALOG_FAMILY);
    if (infoMap == null) {
        return new RegionLocations(locations);
    }
    // iterate until all serverName columns are seen
    int replicaId = 0;
    byte[] serverColumn = getServerColumn(replicaId);
    SortedMap<byte[], byte[]> serverMap;
    serverMap = infoMap.tailMap(serverColumn, false);
    if (serverMap.isEmpty()) {
        return new RegionLocations(locations);
    }
    for (Map.Entry<byte[], byte[]> entry : serverMap.entrySet()) {
        replicaId = parseReplicaIdFromServerColumn(entry.getKey());
        if (replicaId < 0) {
            break;
        }
        HRegionLocation location = getRegionLocation(r, regionInfo, replicaId);
        // have HRL's in RegionLocations object with null ServerName. They are handled as null HRLs.
        if (location.getServerName() == null) {
            locations.add(null);
        } else {
            locations.add(location);
        }
    }
    return new RegionLocations(locations);
}
Also used : NavigableMap(java.util.NavigableMap) ArrayList(java.util.ArrayList) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) NavigableMap(java.util.NavigableMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) SortedMap(java.util.SortedMap) Nullable(edu.umd.cs.findbugs.annotations.Nullable)

Example 9 with Nullable

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

the class StatementPatternMatcherTest method getSp.

/**
 * Fetch the {@link StatementPattern} from a SPARQL string.
 *
 * @param sparql - A SPARQL query that contains only a single Statement Patern. (not nul)
 * @return The {@link StatementPattern} that was in the query, if it could be found. Otherwise {@code null}
 * @throws Exception The statement pattern could not be found in the parsed SPARQL query.
 */
@Nullable
public static StatementPattern getSp(final String sparql) throws Exception {
    requireNonNull(sparql);
    final AtomicReference<StatementPattern> statementPattern = new AtomicReference<>();
    final ParsedQuery parsed = new SPARQLParser().parseQuery(sparql, null);
    parsed.getTupleExpr().visitChildren(new QueryModelVisitorBase<Exception>() {

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

Example 10 with Nullable

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

the class FilterEvaluatorTest 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