use of edu.umd.cs.findbugs.annotations.Nullable in project incubator-rya by apache.
the class RdfTestUtil 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();
}
use of edu.umd.cs.findbugs.annotations.Nullable in project incubator-rya by apache.
the class RdfTestUtil 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();
}
use of edu.umd.cs.findbugs.annotations.Nullable in project hbase by apache.
the class HBaseTestingUtil method findLastTableState.
@Nullable
public TableState findLastTableState(final TableName table) throws IOException {
final AtomicReference<TableState> lastTableState = new AtomicReference<>(null);
ClientMetaTableAccessor.Visitor visitor = new ClientMetaTableAccessor.Visitor() {
@Override
public boolean visit(Result r) throws IOException {
if (!Arrays.equals(r.getRow(), table.getName())) {
return false;
}
TableState state = CatalogFamilyFormat.getTableState(r);
if (state != null) {
lastTableState.set(state);
}
return true;
}
};
MetaTableAccessor.scanMeta(getConnection(), null, null, ClientMetaTableAccessor.QueryType.TABLE, Integer.MAX_VALUE, visitor);
return lastTableState.get();
}
use of edu.umd.cs.findbugs.annotations.Nullable in project hbase by apache.
the class MetaTableAccessor method getTableState.
/**
* Fetch table state for given table from META table
* @param conn connection to use
* @param tableName table to fetch state for
*/
@Nullable
public static TableState getTableState(Connection conn, TableName tableName) throws IOException {
if (tableName.equals(TableName.META_TABLE_NAME)) {
return new TableState(tableName, TableState.State.ENABLED);
}
Table metaHTable = getMetaHTable(conn);
Get get = new Get(tableName.getName()).addColumn(HConstants.TABLE_FAMILY, HConstants.TABLE_STATE_QUALIFIER);
Result result = metaHTable.get(get);
return CatalogFamilyFormat.getTableState(result);
}
use of edu.umd.cs.findbugs.annotations.Nullable in project hbase by apache.
the class FSTableDescriptors method get.
/**
* Get the current table descriptor for the given table, or null if none exists.
* <p/>
* Uses a local cache of the descriptor but still checks the filesystem on each call if
* {@link #fsvisited} is not {@code true}, i.e, we haven't done a full scan yet, to see if a newer
* file has been created since the cached one was read.
*/
@Override
@Nullable
public TableDescriptor get(TableName tableName) {
invocations++;
if (usecache) {
// Look in cache of descriptors.
TableDescriptor cachedtdm = this.cache.get(tableName);
if (cachedtdm != null) {
cachehits++;
return cachedtdm;
}
// we do not need to go to fs any more
if (fsvisited) {
return null;
}
}
TableDescriptor tdmt = null;
try {
tdmt = getTableDescriptorFromFs(fs, getTableDir(tableName), fsreadonly).map(Pair::getSecond).orElse(null);
} catch (IOException ioe) {
LOG.debug("Exception during readTableDecriptor. Current table name = " + tableName, ioe);
}
// last HTD written wins
if (usecache && tdmt != null) {
this.cache.put(tableName, tdmt);
}
return tdmt;
}
Aggregations