Skip to content
Permalink
Browse files
clean up warnings
Change-Id: I5c216c377afc6961d28215dfa2bcee6621bbc104
  • Loading branch information
javeme authored and zhoney committed Nov 22, 2018
1 parent ad3cc89 commit 3d0bf54191724c2cc3a13e09e6a1cb3bd4b0eefb
Show file tree
Hide file tree
Showing 19 changed files with 81 additions and 110 deletions.
@@ -191,7 +191,7 @@ private void checkBackendVersionOrExit() {
for (String graph : this.graphs()) {
HugeGraph hugegraph = this.graph(graph);
if (InMemoryDBStoreProvider.matchType(hugegraph.backend())) {
continue;
hugegraph.initBackend();
}
BackendStoreInfo info = new BackendStoreInfo(hugegraph);
if (!info.exist()) {
@@ -49,7 +49,8 @@
import com.datastax.driver.core.exceptions.InvalidQueryException;
import com.datastax.driver.core.schemabuilder.SchemaBuilder;

public abstract class CassandraStore extends AbstractBackendStore {
public abstract class CassandraStore
extends AbstractBackendStore<CassandraSessionPool.Session> {

private static final Logger LOG = Log.logger(CassandraStore.class);

@@ -21,38 +21,39 @@

import com.baidu.hugegraph.type.HugeType;

public abstract class AbstractBackendStore implements BackendStore {
public abstract class AbstractBackendStore<Session extends BackendSession>
implements BackendStore {

private final MetaDispatcher dispatcher;
private final MetaDispatcher<Session> dispatcher;

public AbstractBackendStore() {
this.dispatcher = new MetaDispatcher();
this.dispatcher = new MetaDispatcher<>();
}

protected MetaDispatcher metaDispatcher() {
protected MetaDispatcher<Session> metaDispatcher() {
return this.dispatcher;
}

public <Session extends BackendSession>
void registerMetaHandler(String name, MetaHandler<Session> handler) {
public void registerMetaHandler(String name, MetaHandler<Session> handler) {
this.dispatcher.registerMetaHandler(name, handler);
}

// Get metadata by key
@Override
public <R> R metadata(HugeType type, String meta, Object[] args) {
BackendSession session = this.session(type);
MetaDispatcher dispatcher = null;
Session session = this.session(type);
MetaDispatcher<Session> dispatcher = null;
if (type == null) {
dispatcher = this.metaDispatcher();
} else {
BackendTable table = this.table(type);
BackendTable<Session, ?> table = this.table(type);
dispatcher = table.metaDispatcher();
}
return dispatcher.dispatchMetaHandler(session, meta, args);
}

protected abstract BackendTable table(HugeType type);
protected abstract BackendTable<Session, ?> table(HugeType type);

// NOTE: Need to support passing null
protected abstract BackendSession session(HugeType type);
protected abstract Session session(HugeType type);
}
@@ -38,11 +38,11 @@

private final String table;

private final MetaDispatcher dispatcher;
private final MetaDispatcher<Session> dispatcher;

public BackendTable(String table) {
this.table = table;
this.dispatcher = new MetaDispatcher();
this.dispatcher = new MetaDispatcher<>();

this.registerMetaHandlers();
}
@@ -51,7 +51,7 @@ public String table() {
return this.table;
}

public MetaDispatcher metaDispatcher() {
public MetaDispatcher<Session> metaDispatcher() {
return this.dispatcher;
}

@@ -22,25 +22,25 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import com.baidu.hugegraph.backend.BackendException;
import com.baidu.hugegraph.exception.NotSupportException;

public class MetaDispatcher {
public class MetaDispatcher<Session extends BackendSession> {

protected final Map<String, MetaHandler> metaHandlers;
protected final Map<String, MetaHandler<Session>> metaHandlers;

public MetaDispatcher() {
this.metaHandlers = new ConcurrentHashMap<>();
}

public void registerMetaHandler(String meta, MetaHandler handler) {
public void registerMetaHandler(String meta, MetaHandler<Session> handler) {
this.metaHandlers.put(meta, handler);
}

@SuppressWarnings("unchecked")
public <R> R dispatchMetaHandler(BackendSession session,
public <R> R dispatchMetaHandler(Session session,
String meta, Object[] args) {
if (!this.metaHandlers.containsKey(meta)) {
throw new BackendException("Invalid metadata name '%s'", meta);
throw new NotSupportException("metadata '%s'", meta);
}
return (R) this.metaHandlers.get(meta).handle(session, meta, args);
}
@@ -38,9 +38,7 @@
import com.baidu.hugegraph.backend.store.BackendMutation;
import com.baidu.hugegraph.backend.store.BackendSession;
import com.baidu.hugegraph.backend.store.BackendStoreProvider;
import com.baidu.hugegraph.backend.store.MetaDispatcher;
import com.baidu.hugegraph.config.HugeConfig;
import com.baidu.hugegraph.exception.NotSupportException;
import com.baidu.hugegraph.type.HugeType;
import com.baidu.hugegraph.util.Log;

@@ -57,7 +55,8 @@
* 1.remove by id + condition
* 2.append/subtract edge-property
*/
public abstract class InMemoryDBStore extends AbstractBackendStore {
public abstract class InMemoryDBStore
extends AbstractBackendStore<BackendSession> {

private static final Logger LOG = Log.logger(InMemoryDBStore.class);

@@ -76,11 +75,6 @@ public InMemoryDBStore(final BackendStoreProvider provider,
this.tables = new HashMap<>();
}

@Override
public <R> R metadata(HugeType type, String meta, Object[] args) {
throw new NotSupportException("InMemoryDBStore.metadata()");
}

protected void registerTableManager(HugeType type, InMemoryDBTable table) {
this.tables.put(type, table);
}
@@ -101,12 +95,7 @@ protected final InMemoryDBTable table(HugeType type) {

@Override
protected BackendSession session(HugeType type) {
throw new NotSupportException("InMemoryDBStore.session()");
}

@Override
protected MetaDispatcher metaDispatcher() {
throw new NotSupportException("InMemoryDBStore.metaDispatcher()");
return null;
}

@Override
@@ -1391,6 +1391,7 @@ private <T> void traverseByLabel(SchemaLabel label,
Function<T, Boolean> filt = e -> {
return ((HugeElement) e).label().equals(label.name());
};
@SuppressWarnings("resource")
Iterator<T> itor = new FilterIterator<>(fetcher.apply(query), filt);
while (itor.hasNext()) {
consumer.accept(itor.next());
@@ -255,7 +255,7 @@ protected boolean checkDependenciesSuccess() {
return true;
}
for (Id dependency : this.dependencies) {
HugeTask task = this.callable.scheduler().task(dependency);
HugeTask<?> task = this.callable.scheduler().task(dependency);
if (!task.completed()) {
// Dependent task not completed, re-schedule self
this.callable.scheduler().schedule(this);
@@ -455,7 +455,7 @@ public static <V> HugeTask<V> fromVertex(Vertex vertex) {
return task;
}

private static <T> Collector<T, ?, Set<T>> toOrderSet() {
private static <V> Collector<V, ?, Set<V>> toOrderSet() {
return Collectors.toCollection(InsertionOrderUtil::newSet);
}

@@ -457,16 +457,17 @@ public static <V> Iterator<V> filterResult(

public static void convAllHasSteps(Traversal.Admin<?, ?> traversal) {
// Extract all has steps in traversal
@SuppressWarnings("rawtypes")
List<HasStep> steps = TraversalHelper
.getStepsOfAssignableClassRecursively(
HasStep.class, traversal);
HugeGraph graph = (HugeGraph) traversal.getGraph().get();
for (HasStep step : steps) {
for (HasStep<?> step : steps) {
TraversalUtil.convHasStep(graph, step);
}
}

public static void convHasStep(HugeGraph graph, HasStep step) {
public static void convHasStep(HugeGraph graph, HasStep<?> step) {
HasContainerHolder holder = step;
for (HasContainer has : holder.getHasContainers()) {
convPredicateValue(graph, has);
@@ -502,7 +503,7 @@ private static boolean isSysProp(String key) {
}
}

@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "rawtypes" })
private static void collectPredicates(List<P<Object>> results,
List<P<?>> predicates) {
for (P<?> p : predicates) {
@@ -40,14 +40,13 @@
import com.baidu.hugegraph.backend.store.BackendFeatures;
import com.baidu.hugegraph.backend.store.BackendMutation;
import com.baidu.hugegraph.backend.store.BackendStoreProvider;
import com.baidu.hugegraph.backend.store.MetaDispatcher;
import com.baidu.hugegraph.backend.store.hbase.HbaseSessions.Session;
import com.baidu.hugegraph.config.HugeConfig;
import com.baidu.hugegraph.exception.NotSupportException;
import com.baidu.hugegraph.type.HugeType;
import com.baidu.hugegraph.util.E;
import com.baidu.hugegraph.util.Log;

public abstract class HbaseStore extends AbstractBackendStore {
public abstract class HbaseStore extends AbstractBackendStore<Session> {

private static final Logger LOG = Log.logger(HbaseStore.class);

@@ -86,7 +85,7 @@ protected final HbaseTable table(HugeType type) {
}

@Override
protected HbaseSessions.Session session(HugeType type) {
protected Session session(HugeType type) {
this.checkOpened();
return this.sessions.session();
}
@@ -160,14 +159,14 @@ public void mutate(BackendMutation mutation) {
}

this.checkOpened();
HbaseSessions.Session session = this.sessions.session();
Session session = this.sessions.session();

for (Iterator<BackendAction> it = mutation.mutation(); it.hasNext();) {
this.mutate(session, it.next());
}
}

private void mutate(HbaseSessions.Session session, BackendAction item) {
private void mutate(Session session, BackendAction item) {
BackendEntry entry = item.entry();
HbaseTable table = this.table(entry.type());

@@ -193,7 +192,7 @@ private void mutate(HbaseSessions.Session session, BackendAction item) {
@Override
public Iterator<BackendEntry> query(Query query) {
this.checkOpened();
HbaseSessions.Session session = this.sessions.session();
Session session = this.sessions.session();
HbaseTable table = this.table(HbaseTable.tableType(query));
return table.query(session, query);
}
@@ -299,7 +298,7 @@ public void beginTx() {
@Override
public void commitTx() {
this.checkOpened();
HbaseSessions.Session session = this.sessions.session();
Session session = this.sessions.session();

try {
session.commit();
@@ -313,11 +312,6 @@ public void rollbackTx() {
// pass
}

@Override
public MetaDispatcher metaDispatcher() {
throw new NotSupportException("HBaseStore.metaDispatcher()");
}

private void checkOpened() {
E.checkState(this.sessions != null,
"HBase store has not been initialized");
@@ -134,7 +134,7 @@ public synchronized Session session() {
}

public void checkSessionConnected() {
MysqlSessions.Session session = this.session();
Session session = this.session();
E.checkState(session != null, "MySQL session has not been initialized");
E.checkState(!session.closed(), "MySQL session has been closed");
}

0 comments on commit 3d0bf54

Please sign in to comment.