proj_name stringclasses 131
values | relative_path stringlengths 30 228 | class_name stringlengths 1 68 | func_name stringlengths 1 48 | masked_class stringlengths 78 9.82k | func_body stringlengths 46 9.61k | len_input int64 29 2.01k | len_output int64 14 1.94k | total int64 55 2.05k | relevant_context stringlengths 0 38.4k |
|---|---|---|---|---|---|---|---|---|---|
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/BackendSessionPool.java | BackendSessionPool | detectSession | class BackendSessionPool {
private static final Logger LOG = Log.logger(BackendSessionPool.class);
private final HugeConfig config;
private final String name;
private final ThreadLocal<BackendSession> threadLocalSession;
private final AtomicInteger sessionCount;
private final Map<Long, Backend... |
// Reconnect if the session idle time exceed specified value
long interval = TimeUnit.SECONDS.toMillis(this.reconnectDetectInterval);
long now = System.currentTimeMillis();
if (now - session.updated() > interval) {
session.reconnectIfNeeded();
}
session.updat... | 1,097 | 85 | 1,182 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/BackendStoreInfo.java | BackendStoreInfo | checkVersion | class BackendStoreInfo {
private static final Logger LOG = Log.logger(BackendStoreInfo.class);
private final BackendStoreProvider storeProvider;
private final HugeConfig config;
public BackendStoreInfo(HugeConfig config,
BackendStoreProvider storeProvider) {
this.... |
String driverVersion = this.storeProvider.driverVersion();
String storedVersion = this.storeProvider.loadSystemStore(this.config)
.storedVersion();
if (!driverVersion.equals(storedVersion)) {
LOG.error("The backend driver version '{}'... | 140 | 123 | 263 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/MetaDispatcher.java | MetaDispatcher | dispatchMetaHandler | class MetaDispatcher<Session extends BackendSession> {
protected final Map<String, MetaHandler<Session>> metaHandlers;
public MetaDispatcher() {
this.metaHandlers = new ConcurrentHashMap<>();
}
public void registerMetaHandler(String meta, MetaHandler<Session> handler) {
this.metaHandl... |
if (!this.metaHandlers.containsKey(meta)) {
throw new NotSupportException("metadata '%s'", meta);
}
return (R) this.metaHandlers.get(meta).handle(session, meta, args);
| 150 | 61 | 211 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/SystemSchemaStore.java | SystemSchemaStore | add | class SystemSchemaStore {
private static final int SYSTEM_SCHEMA_MAX_NUMS = 128;
private SchemaElement[] storeByIds;
private final Map<String, SchemaElement> storeByNames;
public SystemSchemaStore() {
this.storeByIds = new SchemaElement[SYSTEM_SCHEMA_MAX_NUMS];
this.storeByNames = Col... |
long idValue = schema.id().asLong();
assert idValue < 0L;
int index = (int) Math.abs(idValue);
if (index >= this.storeByIds.length) {
this.expandCapacity();
}
this.storeByIds[index] = schema;
this.storeByNames.put(schema.name(), schema);
| 383 | 95 | 478 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/TableDefine.java | TableDefine | column | class TableDefine {
private final Map<HugeKeys, String> columns;
private final List<HugeKeys> keys;
private final Map<String, String> typesMapping;
public TableDefine() {
this.columns = InsertionOrderUtil.newMap();
this.keys = InsertionOrderUtil.newList();
this.typesMapping = I... |
StringBuilder sb = new StringBuilder();
for (int i = 0; i < desc.length; i++) {
String type = desc[i];
// The first element of 'desc' is column data type, which may be
// mapped to actual data type supported by backend store
if (i == 0 && this.typesMappin... | 344 | 169 | 513 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/memory/InMemoryDBStoreProvider.java | InMemoryDBStoreProvider | driverVersion | class InMemoryDBStoreProvider extends AbstractBackendStoreProvider {
public static final String TYPE = "memory";
private static Map<String, InMemoryDBStoreProvider> providers = null;
public static boolean matchType(String type) {
return TYPE.equalsIgnoreCase(type);
}
public static synchr... |
/*
* Versions history:
* [1.0] HugeGraph-1328: supports backend table version checking
* [1.1] HugeGraph-1322: add support for full-text search
* [1.2] #296: support range sortKey feature
* [1.3] #270 & #398: support shard-index and vertex + sortkey prefix,
... | 480 | 239 | 719 | <methods>public non-sealed void <init>() ,public void clear() throws org.apache.hugegraph.backend.BackendException,public void close() throws org.apache.hugegraph.backend.BackendException,public void createSnapshot() ,public java.lang.String graph() ,public void init() ,public boolean initialized() ,public void listen(... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/RaftAddPeerJob.java | RaftAddPeerJob | execute | class RaftAddPeerJob extends SysJob<String> {
public static final String TASK_TYPE = "raft_add_peer";
@Override
public String type() {
return TASK_TYPE;
}
@Override
public String execute() throws Exception {<FILL_FUNCTION_BODY>}
} |
String input = this.task().input();
E.checkArgumentNotNull(input, "The input can't be null");
@SuppressWarnings("unchecked")
Map<String, Object> map = JsonUtil.fromJson(input, Map.class);
Object value = map.get("endpoint");
E.checkArgument(value instanceof String,
... | 87 | 131 | 218 | <methods>public non-sealed void <init>() ,public java.lang.String call() throws java.lang.Exception<variables> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/RaftBackendStore.java | RaftBackendStore | clear | class RaftBackendStore implements BackendStore {
private static final Logger LOG = Log.logger(RaftBackendStore.class);
private final BackendStore store;
private final RaftContext context;
private final ThreadLocal<MutationBatch> mutationBatch;
private final boolean isSafeRead;
public RaftBack... |
byte value = clearSpace ? (byte) 1 : (byte) 0;
byte[] bytes = StoreCommand.wrap(value);
this.submitAndWait(StoreAction.CLEAR, bytes);
| 1,877 | 53 | 1,930 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/RaftBackendStoreProvider.java | RaftBackendStoreProvider | init | class RaftBackendStoreProvider implements BackendStoreProvider {
private static final Logger LOG = Log.logger(RaftBackendStoreProvider.class);
private final BackendStoreProvider provider;
private final RaftContext context;
private RaftBackendStore schemaStore;
private RaftBackendStore graphStore;... |
this.checkOpened();
for (RaftBackendStore store : this.stores()) {
store.init();
}
this.notifyAndWaitEvent(Events.STORE_INIT);
LOG.debug("Graph '{}' store has been initialized", this.graph());
| 1,968 | 75 | 2,043 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/RaftClosure.java | RaftClosure | get | class RaftClosure<T> implements Closure {
private static final Logger LOG = Log.logger(RaftStoreClosure.class);
private final CompletableFuture<RaftResult<T>> future;
public RaftClosure() {
this.future = new CompletableFuture<>();
}
public T waitFinished() throws Throwable {
Raft... |
try {
return this.future.get(RaftContext.WAIT_RAFTLOG_TIMEOUT,
TimeUnit.MILLISECONDS);
} catch (ExecutionException e) {
throw new BackendException("ExecutionException", e);
} catch (InterruptedException e) {
throw new Backen... | 420 | 114 | 534 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/RaftGroupManagerImpl.java | RaftGroupManagerImpl | setLeader | class RaftGroupManagerImpl implements RaftGroupManager {
private final String group;
private final RaftNode raftNode;
private final RpcForwarder rpcForwarder;
public RaftGroupManagerImpl(RaftContext context) {
this.group = context.group();
this.raftNode = context.node();
this.r... |
PeerId newLeaderId = PeerId.parsePeer(endpoint);
Node node = this.raftNode.node();
// If expected endpoint has already been raft leader
if (node.getLeaderId().equals(newLeaderId)) {
return newLeaderId.toString();
}
if (this.raftNode.selfIsLeader()) {
... | 1,020 | 261 | 1,281 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/RaftRemovePeerJob.java | RaftRemovePeerJob | execute | class RaftRemovePeerJob extends SysJob<String> {
public static final String TASK_TYPE = "raft_remove_peer";
@Override
public String type() {
return TASK_TYPE;
}
@Override
public String execute() throws Exception {<FILL_FUNCTION_BODY>}
} |
String input = this.task().input();
E.checkArgumentNotNull(input, "The input can't be null");
@SuppressWarnings("unchecked")
Map<String, Object> map = JsonUtil.fromJson(input, Map.class);
Object value = map.get("endpoint");
E.checkArgument(value instanceof String,
... | 87 | 131 | 218 | <methods>public non-sealed void <init>() ,public java.lang.String call() throws java.lang.Exception<variables> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/StoreCommand.java | StoreCommand | fromBytes | class StoreCommand {
public static final int HEADER_SIZE = 2;
private final StoreType type;
private final StoreAction action;
private final byte[] data;
private final boolean forwarded;
public StoreCommand(StoreType type, StoreAction action, byte[] data) {
this(type, action, data, fal... |
StoreType type = StoreType.valueOf(bytes[0]);
StoreAction action = StoreAction.valueOf(bytes[1]);
return new StoreCommand(type, action, bytes);
| 475 | 48 | 523 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/StoreSerializer.java | StoreSerializer | writeMutations | class StoreSerializer {
private static final int MUTATION_SIZE = (int) (1 * Bytes.MB);
public static byte[] writeMutations(List<BackendMutation> mutations) {<FILL_FUNCTION_BODY>}
public static List<BackendMutation> readMutations(BytesBuffer buffer) {
int size = buffer.readVInt();
List<Bac... |
int estimateSize = mutations.size() * MUTATION_SIZE;
// The first two bytes are reserved for StoreType and StoreAction
BytesBuffer buffer = BytesBuffer.allocate(StoreCommand.HEADER_SIZE +
4 + estimateSize);
StoreCommand.writeHeader(buffe... | 1,005 | 130 | 1,135 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/StoreStateMachine.java | StoreStateMachine | onApplyLeader | class StoreStateMachine extends StateMachineAdapter {
private static final Logger LOG = Log.logger(StoreStateMachine.class);
private final RaftContext context;
private final StoreSnapshotFile snapshotFile;
public StoreStateMachine(RaftContext context) {
this.context = context;
this.sn... |
// Leader just take the command out from the closure
StoreCommand command = closure.command();
BytesBuffer buffer = BytesBuffer.wrap(command.data());
// The first two bytes are StoreType and StoreAction
StoreType type = StoreType.valueOf(buffer.read());
StoreAction actio... | 1,713 | 220 | 1,933 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/compress/CompressStrategyManager.java | CompressStrategyManager | addCompressStrategy | class CompressStrategyManager {
private static byte DEFAULT_STRATEGY = 1;
public static final byte SERIAL_STRATEGY = 1;
public static final byte PARALLEL_STRATEGY = 2;
public static final byte MAX_STRATEGY = 5;
private static CompressStrategy[] compressStrategies = new CompressStrategy[MAX_STRATEGY... |
if (compressStrategies.length <= index) {
CompressStrategy[] newCompressStrategies = new CompressStrategy[index + MAX_STRATEGY];
System.arraycopy(compressStrategies, 0, newCompressStrategies, 0,
compressStrategies.length);
compressStrategies = ne... | 405 | 110 | 515 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/compress/ParallelCompressStrategy.java | ZipArchiveScatterOutputStream | compressDirectoryToZipFile | class ZipArchiveScatterOutputStream {
private final ParallelScatterZipCreator creator;
public ZipArchiveScatterOutputStream(ExecutorService executorService) {
this.creator = new ParallelScatterZipCreator(executorService);
}
public void addEntry(ZipArchiveEntry entry, Input... |
if (dir == null) {
return;
}
if (dir.isFile()) {
addEntry(sourceDir, dir, scatterOutput, method);
return;
}
File[] files = Requires.requireNonNull(Objects.requireNonNull(dir.listFiles()), "files");
for (File file : files) {
... | 903 | 163 | 1,066 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/compress/SerialCompressStrategy.java | SerialCompressStrategy | compressZip | class SerialCompressStrategy implements CompressStrategy {
private static final Logger LOG = LoggerFactory.getLogger(SerialCompressStrategy.class);
@Override
public void compressZip(String rootDir, String sourceDir, String outputZipFile,
Checksum checksum) throws Throwable {<FI... |
LOG.info("Start to compress snapshot in serial strategy");
CompressUtil.compressZip(rootDir, sourceDir, outputZipFile, checksum);
| 167 | 42 | 209 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/rpc/AddPeerProcessor.java | AddPeerProcessor | processRequest | class AddPeerProcessor
extends RpcRequestProcessor<AddPeerRequest> {
private static final Logger LOG = Log.logger(AddPeerProcessor.class);
private final RaftContext context;
public AddPeerProcessor(RaftContext context) {
super(null, null);
this.context = context;
}
@Overr... |
LOG.debug("Processing AddPeerRequest {}", request.getClass());
RaftGroupManager nodeManager = this.context.raftNodeManager();
try {
nodeManager.addPeer(request.getEndpoint());
CommonResponse common = CommonResponse.newBuilder()
... | 155 | 171 | 326 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/rpc/ListPeersProcessor.java | ListPeersProcessor | processRequest | class ListPeersProcessor
extends RpcRequestProcessor<ListPeersRequest> {
private static final Logger LOG = Log.logger(ListPeersProcessor.class);
private final RaftContext context;
public ListPeersProcessor(RaftContext context) {
super(null, null);
this.context = context;
}
... |
LOG.debug("Processing ListPeersRequest {}", request.getClass());
RaftGroupManager nodeManager = this.context.raftNodeManager();
try {
CommonResponse common = CommonResponse.newBuilder()
.setStatus(true)
... | 155 | 198 | 353 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/rpc/RemovePeerProcessor.java | RemovePeerProcessor | processRequest | class RemovePeerProcessor
extends RpcRequestProcessor<RemovePeerRequest> {
private static final Logger LOG = Log.logger(RemovePeerProcessor.class);
private final RaftContext context;
public RemovePeerProcessor(RaftContext context) {
super(null, null);
this.context = context;
}... |
LOG.debug("Processing RemovePeerRequest {}", request.getClass());
RaftGroupManager nodeManager = this.context.raftNodeManager();
try {
nodeManager.removePeer(request.getEndpoint());
CommonResponse common = CommonResponse.newBuilder()
... | 155 | 171 | 326 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/rpc/RpcForwarder.java | RpcForwarder | forwardToLeader | class RpcForwarder {
private static final Logger LOG = Log.logger(RpcForwarder.class);
private final PeerId nodeId;
private final RaftClientService rpcClient;
public RpcForwarder(Node node) {
this.nodeId = node.getNodeId().getPeerId();
this.rpcClient = ((NodeImpl) node).getRpcService(... |
E.checkNotNull(leaderId, "leader id");
E.checkState(!leaderId.equals(this.nodeId),
"Invalid state: current node is the leader, there is " +
"no need to forward the request");
LOG.debug("The node {} forward request to leader {}",
this.n... | 809 | 571 | 1,380 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/rpc/SetLeaderProcessor.java | SetLeaderProcessor | processRequest | class SetLeaderProcessor
extends RpcRequestProcessor<SetLeaderRequest> {
private static final Logger LOG = Log.logger(SetLeaderProcessor.class);
private final RaftContext context;
public SetLeaderProcessor(RaftContext context) {
super(null, null);
this.context = context;
}
... |
LOG.debug("Processing SetLeaderRequest {}", request.getClass());
RaftGroupManager nodeManager = this.context.raftNodeManager();
try {
nodeManager.setLeader(request.getEndpoint());
CommonResponse common = CommonResponse.newBuilder()
... | 155 | 171 | 326 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/rpc/StoreCommandProcessor.java | StoreCommandProcessor | processRequest | class StoreCommandProcessor
extends RpcRequestProcessor<StoreCommandRequest> {
private static final Logger LOG = Log.logger(
StoreCommandProcessor.class);
private final RaftContext context;
public StoreCommandProcessor(RaftContext context) {
super(null, null);
this.con... |
LOG.debug("Processing StoreCommandRequest: {}", request.getAction());
RaftNode node = this.context.node();
try {
StoreCommand command = this.parseStoreCommand(request);
RaftStoreClosure closure = new RaftStoreClosure(command);
node.submitAndWait(command, clos... | 222 | 215 | 437 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/ram/IntIntMap.java | IntIntMap | readFrom | class IntIntMap implements RamMap {
// TODO: use com.carrotsearch.hppc.IntIntHashMap instead
private final int[] array;
public IntIntMap(int capacity) {
this.array = new int[capacity];
}
public void put(long key, int value) {
assert 0 <= key && key < Integer.MAX_VALUE;
thi... |
int size = buffer.readInt();
if (size > this.array.length) {
throw new HugeException("Invalid size %s, expect < %s",
size, this.array.length);
}
for (int i = 0; i < size; i++) {
int value = buffer.readInt();
this.ar... | 297 | 98 | 395 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/ram/IntLongMap.java | IntLongMap | readFrom | class IntLongMap implements RamMap {
// TODO: use com.carrotsearch.hppc.IntLongHashMap instead
private final long[] array;
private int size;
public IntLongMap(int capacity) {
this.array = new long[capacity];
this.size = 0;
}
public void put(int key, long value) {
if (k... |
int size = buffer.readInt();
if (size > this.array.length) {
throw new HugeException("Invalid size %s, expect < %s",
size, this.array.length);
}
for (int i = 0; i < size; i++) {
long value = buffer.readLong();
this.... | 431 | 106 | 537 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/ram/IntObjectMap.java | IntObjectMap | set | class IntObjectMap<V> implements RamMap {
private static final float DEFAULT_INITIAL_FACTOR = 0.25f;
private final int maxSize;
private volatile int currentSize;
private volatile Object[] array;
public IntObjectMap(int size) {
this.maxSize = size;
this.currentSize = (int) (size * ... |
if (key >= this.currentSize) {
this.expandCapacity();
}
this.array[key] = value;
| 457 | 38 | 495 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/IndexableTransaction.java | IndexableTransaction | reset | class IndexableTransaction extends AbstractTransaction {
public IndexableTransaction(HugeGraphParams graph, BackendStore store) {
super(graph, store);
}
@Override
public boolean hasUpdate() {
AbstractTransaction indexTx = this.indexTransaction();
boolean indexTxChanged = (index... |
super.reset();
// It's null when called by super AbstractTransaction()
AbstractTransaction indexTx = this.indexTransaction();
if (indexTx != null) {
indexTx.reset();
}
| 399 | 57 | 456 | <methods>public void <init>(org.apache.hugegraph.HugeGraphParams, org.apache.hugegraph.backend.store.BackendStore) ,public boolean autoCommit() ,public void close() ,public void commit() throws org.apache.hugegraph.backend.BackendException,public void commitIfGtSize(int) throws org.apache.hugegraph.backend.BackendExcep... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/SchemaIndexTransaction.java | SchemaIndexTransaction | queryByName | class SchemaIndexTransaction extends AbstractTransaction {
public SchemaIndexTransaction(HugeGraphParams graph, BackendStore store) {
super(graph, store);
}
@Watched(prefix = "index")
public void updateNameIndex(SchemaElement element, boolean removed) {
if (!this.needIndexForName()) {
... |
if (!this.needIndexForName()) {
return super.query(query);
}
IndexLabel il = IndexLabel.label(query.resultType());
String name = query.condition(HugeKeys.NAME);
E.checkState(name != null, "The name in condition can't be null " +
"wh... | 413 | 392 | 805 | <methods>public void <init>(org.apache.hugegraph.HugeGraphParams, org.apache.hugegraph.backend.store.BackendStore) ,public boolean autoCommit() ,public void close() ,public void commit() throws org.apache.hugegraph.backend.BackendException,public void commitIfGtSize(int) throws org.apache.hugegraph.backend.BackendExcep... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/config/AuthOptions.java | AuthOptions | instance | class AuthOptions extends OptionHolder {
private AuthOptions() {
super();
}
private static volatile AuthOptions instance;
public static synchronized AuthOptions instance() {<FILL_FUNCTION_BODY>}
public static final ConfigOption<String> AUTHENTICATOR =
new ConfigOption<>(
... |
if (instance == null) {
instance = new AuthOptions();
instance.registerOptions();
}
return instance;
| 1,044 | 35 | 1,079 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/io/GraphSONSchemaSerializer.java | GraphSONSchemaSerializer | writePropertyKey | class GraphSONSchemaSerializer {
public Map<HugeKeys, Object> writeVertexLabel(VertexLabel vertexLabel) {
HugeGraph graph = vertexLabel.graph();
assert graph != null;
Map<HugeKeys, Object> map = new LinkedHashMap<>();
map.put(HugeKeys.ID, vertexLabel.id().asLong());
map.put... |
HugeGraph graph = propertyKey.graph();
assert graph != null;
Map<HugeKeys, Object> map = new LinkedHashMap<>();
map.put(HugeKeys.ID, propertyKey.id().asLong());
map.put(HugeKeys.NAME, propertyKey.name());
map.put(HugeKeys.DATA_TYPE, propertyKey.dataType());
map.... | 1,211 | 240 | 1,451 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/io/HugeGraphSONModule.java | HugeElementSerializer | writePropertiesField | class HugeElementSerializer<T extends HugeElement>
extends StdSerializer<T> {
public HugeElementSerializer(Class<T> clazz) {
super(clazz);
}
public void writeIdField(String fieldName, Id id,
JsonGenerator generator)
throw... |
// Start write properties
generator.writeFieldName("properties");
generator.writeStartObject();
for (HugeProperty<?> property : properties) {
String key = property.key();
Object val = property.value();
try {
... | 184 | 208 | 392 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/io/HugeGryoModule.java | EdgeIdSerializer | writeEntry | class EdgeIdSerializer extends Serializer<EdgeId> {
@Override
public void write(Kryo kryo, Output output, EdgeId edgeId) {
byte[] idBytes = edgeId.asBytes();
output.write(idBytes.length);
output.writeBytes(edgeId.asBytes());
}
@Override
publi... |
/* Write columns size and data */
output.writeInt(schema.keySet().size());
for (Map.Entry<HugeKeys, Object> entry : schema.entrySet()) {
kryo.writeObject(output, entry.getKey());
kryo.writeClassAndObject(output, entry.getValue());
}
| 201 | 84 | 285 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/AlgorithmJob.java | AlgorithmJob | execute | class AlgorithmJob extends UserJob<Object> {
public static final String TASK_TYPE = "algorithm";
public static boolean check(String name, Map<String, Object> parameters) {
Algorithm algorithm = AlgorithmPool.instance().find(name);
if (algorithm == null) {
return false;
}
... |
String input = this.task().input();
E.checkArgumentNotNull(input, "The input can't be null");
@SuppressWarnings("unchecked")
Map<String, Object> map = JsonUtil.fromJson(input, Map.class);
Object value = map.get("algorithm");
E.checkArgument(value instanceof String,
... | 145 | 238 | 383 | <methods>public non-sealed void <init>() ,public java.lang.Object call() throws java.lang.Exception<variables> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/ComputerJob.java | ComputerJob | execute | class ComputerJob extends SysJob<Object> {
public static final String COMPUTER = "computer";
public static boolean check(String name, Map<String, Object> parameters) {
Computer computer = ComputerPool.instance().find(name);
if (computer == null) {
return false;
}
co... |
String input = this.task().input();
E.checkArgumentNotNull(input, "The input can't be null");
@SuppressWarnings("unchecked")
Map<String, Object> map = JsonUtil.fromJson(input, Map.class);
Object value = map.get("computer");
E.checkArgument(value instanceof String,
... | 179 | 241 | 420 | <methods>public non-sealed void <init>() ,public java.lang.Object call() throws java.lang.Exception<variables> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/EphemeralJobBuilder.java | EphemeralJobBuilder | schedule | class EphemeralJobBuilder<V> {
private final HugeGraph graph;
private String name;
private String input;
private EphemeralJob<V> job;
// Use negative task id for ephemeral task
private static int ephemeralTaskId = -1;
public static <T> EphemeralJobBuilder<T> of(final HugeGraph graph) {
... |
E.checkArgumentNotNull(this.name, "Job name can't be null");
E.checkArgumentNotNull(this.job, "Job can't be null");
HugeTask<V> task = new HugeTask<>(this.genTaskId(), null, this.job);
task.type(this.job.type());
task.name(this.name);
if (this.input != null) {
... | 346 | 153 | 499 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/GremlinJob.java | GremlinJob | execute | class GremlinJob extends UserJob<Object> {
public static final String TASK_TYPE = "gremlin";
public static final String TASK_BIND_NAME = "gremlinJob";
public static final int TASK_RESULTS_MAX_SIZE = (int) Query.DEFAULT_CAPACITY;
@Override
public String type() {
return TASK_TYPE;
}
... |
String input = this.task().input();
E.checkArgumentNotNull(input, "The input can't be null");
@SuppressWarnings("unchecked")
Map<String, Object> map = JsonUtil.fromJson(input, Map.class);
Object value = map.get("gremlin");
E.checkArgument(value instanceof String,
... | 367 | 544 | 911 | <methods>public non-sealed void <init>() ,public java.lang.Object call() throws java.lang.Exception<variables> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/JobBuilder.java | JobBuilder | schedule | class JobBuilder<V> {
private final HugeGraph graph;
private String name;
private String input;
private Job<V> job;
private Set<Id> dependencies;
public static <T> JobBuilder<T> of(final HugeGraph graph) {
return new JobBuilder<>(graph);
}
public JobBuilder(final HugeGraph gr... |
E.checkArgumentNotNull(this.name, "Job name can't be null");
E.checkArgumentNotNull(this.job, "Job callable can't be null");
E.checkArgument(this.job instanceof TaskCallable,
"Job must be instance of TaskCallable");
this.graph.taskScheduler().checkRequirement("s... | 298 | 282 | 580 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/AbstractAlgorithm.java | TopMap | shrinkIfNeeded | class TopMap<K> {
private final long topN;
private Map<K, MutableLong> tops;
public TopMap(long topN) {
this.topN = topN;
this.tops = new HashMap<>();
}
public int size() {
return this.tops.size();
}
public MutableLong get(K... |
assert limit != 0L;
if (this.tops.size() >= limit &&
(limit > 0L || limit == HugeTraverser.NO_LIMIT)) {
// Just do sort if limit=NO_LIMIT, else do sort and shrink
this.tops = HugeTraverser.topN(this.tops, true, limit);
}
| 438 | 95 | 533 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/AlgorithmPool.java | AlgorithmPool | get | class AlgorithmPool {
private static final AlgorithmPool INSTANCE = new AlgorithmPool();
static {
INSTANCE.register(new CountVertexAlgorithm());
INSTANCE.register(new CountEdgeAlgorithm());
INSTANCE.register(new DegreeCentralityAlgorithm());
INSTANCE.register(new StressCentral... |
Algorithm algorithm = this.algorithms.get(name);
E.checkArgument(algorithm != null,
"Not found algorithm '%s'", name);
return algorithm;
| 519 | 46 | 565 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/BfsTraverser.java | Node | addParent | class Node {
private Id[] parents;
private int pathCount;
private final int distance;
public Node(Node parentNode) {
this(0, parentNode.distance + 1);
}
public Node(int pathCount, int distance) {
this.pathCount = pathCount;
this.dist... |
// TODO: test if need to allocate more memory in advance
Id[] newParents = new Id[this.parents.length + 1];
System.arraycopy(this.parents, 0, newParents, 0,
this.parents.length);
newParents[newParents.length - 1] = parentId;
this.... | 226 | 95 | 321 | <methods>public void <init>(UserJob<java.lang.Object>) ,public void close() ,public org.apache.hugegraph.backend.id.Id jobId() ,public void updateProgress(long) <variables>protected final non-sealed java.util.concurrent.ExecutorService executor,private final non-sealed UserJob<java.lang.Object> job,protected long progr... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/Consumers.java | Consumers | consume | class Consumers<V> {
public static final int CPUS = Runtime.getRuntime().availableProcessors();
public static final int THREADS = 4 + CPUS / 4;
public static final int QUEUE_WORKER_SIZE = 1000;
private static final Logger LOG = Log.logger(Consumers.class);
private final ExecutorService executor;
... |
V elem;
try {
elem = this.queue.poll(1, TimeUnit.SECONDS);
} catch (InterruptedException e) {
// ignore
return true;
}
if (elem == null) {
return false;
}
// do job
this.consumer.accept(elem);
return... | 1,281 | 93 | 1,374 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/CountEdgeAlgorithm.java | Traverser | count | class Traverser extends AlgoTraverser {
public Traverser(UserJob<Object> job) {
super(job);
}
public Object count() {<FILL_FUNCTION_BODY>}
} |
Iterator<Edge> edges = this.edges(null);
Map<String, MutableLong> counts = new HashMap<>();
long total = 0L;
while (edges.hasNext()) {
Edge edge = edges.next();
String label = edge.label();
MutableLong count = counts.get(... | 60 | 174 | 234 | <methods>public non-sealed void <init>() ,public void checkParameters(Map<java.lang.String,java.lang.Object>) <variables>public static final int BATCH,public static final java.lang.String CATEGORY_AGGR,public static final java.lang.String CATEGORY_CENT,public static final java.lang.String CATEGORY_COMM,public static fi... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/CountVertexAlgorithm.java | Traverser | count | class Traverser extends AlgoTraverser {
public Traverser(UserJob<Object> job) {
super(job);
}
public Object count() {<FILL_FUNCTION_BODY>}
} |
Iterator<Vertex> vertices = this.vertices();
Map<String, MutableLong> counts = new HashMap<>();
long total = 0L;
while (vertices.hasNext()) {
Vertex vertex = vertices.next();
String label = vertex.label();
MutableLong cou... | 60 | 173 | 233 | <methods>public non-sealed void <init>() ,public void checkParameters(Map<java.lang.String,java.lang.Object>) <variables>public static final int BATCH,public static final java.lang.String CATEGORY_AGGR,public static final java.lang.String CATEGORY_CENT,public static final java.lang.String CATEGORY_COMM,public static fi... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/SubgraphStatAlgorithm.java | SubgraphStatAlgorithm | call | class SubgraphStatAlgorithm extends AbstractAlgorithm {
public static final String KEY_SUBGRAPH = "subgraph";
public static final String KEY_COPY_SCHEMA = "copy_schema";
private static final Logger LOG = Log.logger(SubgraphStatAlgorithm.class);
@Override
public String name() {
return "sub... |
HugeGraph graph = this.createTempGraph(job);
try (Traverser traverser = new Traverser(job)) {
this.initGraph(job.graph(), graph,
subgraph(parameters), copySchema(parameters));
UserJob<Object> tmpJob = new TempJob<>(graph, job, job.task());
... | 1,561 | 188 | 1,749 | <methods>public non-sealed void <init>() ,public void checkParameters(Map<java.lang.String,java.lang.Object>) <variables>public static final int BATCH,public static final java.lang.String CATEGORY_AGGR,public static final java.lang.String CATEGORY_CENT,public static final java.lang.String CATEGORY_COMM,public static fi... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/cent/AbstractCentAlgorithm.java | Traverser | substractPath | class Traverser extends AlgoTraverser {
public Traverser(UserJob<Object> job) {
super(job);
}
protected GraphTraversal<Vertex, Vertex> constructSource(
String sourceLabel,
long sourceSample,
String sourceCLabel) {
GraphTra... |
// t.select(Pop.all, "v").unfold().id()
return t.select(Pop.all, "v").flatMap(it -> {
List<?> path = (List<?>) it.get();
if (withBoundary) {
@SuppressWarnings("unchecked")
Iterator<HugeVertex> items = (Iterator<HugeVertex>)... | 1,119 | 254 | 1,373 | <methods>public non-sealed void <init>() ,public void checkParameters(Map<java.lang.String,java.lang.Object>) <variables>public static final int BATCH,public static final java.lang.String CATEGORY_AGGR,public static final java.lang.String CATEGORY_CENT,public static final java.lang.String CATEGORY_COMM,public static fi... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/cent/BetweennessCentralityAlgorithm.java | Traverser | computeBetweenness | class Traverser extends AbstractCentAlgorithm.Traverser {
public Traverser(UserJob<Object> job) {
super(job);
}
public Object betweennessCentrality(Directions direction,
String label,
int depth,... |
return t.fold(new HashMap<Id, MutableFloat>(), (results, it) -> {
@SuppressWarnings("unchecked")
Map.Entry<Id, List<?>> entry = (Map.Entry<Id, List<?>>) it;
@SuppressWarnings("unchecked")
List<List<Id>> paths = (List<List<Id>>) entry.getValue(... | 618 | 265 | 883 | <methods>public non-sealed void <init>() ,public java.lang.String category() ,public void checkParameters(Map<java.lang.String,java.lang.Object>) <variables>private static final Logger LOG |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/cent/BetweennessCentralityAlgorithmV2.java | Traverser | betweenessCentrality | class Traverser extends BfsTraverser<BetweennessNode> {
private Map<Id, MutableFloat> globalBetweennesses;
private Traverser(UserJob<Object> job) {
super(job);
}
private Object betweenessCentrality(Directions direction,
String la... |
assert depth > 0;
assert degree > 0L || degree == NO_LIMIT;
assert topN >= 0L || topN == NO_LIMIT;
this.globalBetweennesses = new HashMap<>();
Id edgeLabelId = this.getEdgeLabelIdOrNull(label);
// TODO: sample the startVertices
Itera... | 469 | 269 | 738 | <methods>public non-sealed void <init>() ,public java.lang.String category() ,public void checkParameters(Map<java.lang.String,java.lang.Object>) <variables>private static final Logger LOG |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/cent/ClosenessCentralityAlgorithm.java | Traverser | closenessCentrality | class Traverser extends AbstractCentAlgorithm.Traverser {
public Traverser(UserJob<Object> job) {
super(job);
}
public Object closenessCentrality(Directions direction,
String label,
int depth,
... |
assert depth > 0;
assert degree > 0L || degree == NO_LIMIT;
assert topN >= 0L || topN == NO_LIMIT;
GraphTraversal<Vertex, Vertex> t = constructSource(sourceLabel,
sourceSample,
... | 117 | 360 | 477 | <methods>public non-sealed void <init>() ,public java.lang.String category() ,public void checkParameters(Map<java.lang.String,java.lang.Object>) <variables>private static final Logger LOG |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/cent/ClosenessCentralityAlgorithmV2.java | Traverser | closenessCentrality | class Traverser extends BfsTraverser<BfsTraverser.Node> {
private final Map<Id, Float> globalCloseness;
private float startVertexCloseness;
private Traverser(UserJob<Object> job) {
super(job);
this.globalCloseness = new HashMap<>();
}
private Object cl... |
assert depth > 0;
assert degree > 0L || degree == NO_LIMIT;
assert topN >= 0L || topN == NO_LIMIT;
Id edgeLabelId = this.getEdgeLabelIdOrNull(label);
// TODO: sample the startVertices
Iterator<Vertex> startVertices = this.vertices(sourceLabel,
... | 348 | 264 | 612 | <methods>public non-sealed void <init>() ,public java.lang.String category() ,public void checkParameters(Map<java.lang.String,java.lang.Object>) <variables>private static final Logger LOG |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/cent/DegreeCentralityAlgorithm.java | Traverser | degreeCentrality | class Traverser extends AlgoTraverser {
public Traverser(UserJob<Object> job) {
super(job);
}
public Object degreeCentrality(Directions direction,
String label,
long topN) {<FILL_FUNCTION_BODY>}
... |
if (direction == null || direction == Directions.BOTH) {
return this.degreeCentralityForBothDir(label, topN);
}
assert direction == Directions.OUT || direction == Directions.IN;
assert topN >= 0L || topN == NO_LIMIT;
Iterator<Edge> edges = th... | 429 | 474 | 903 | <methods>public non-sealed void <init>() ,public java.lang.String category() ,public void checkParameters(Map<java.lang.String,java.lang.Object>) <variables>private static final Logger LOG |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/cent/EigenvectorCentralityAlgorithm.java | Traverser | eigenvectorCentrality | class Traverser extends AbstractCentAlgorithm.Traverser {
public Traverser(UserJob<Object> job) {
super(job);
}
public Object eigenvectorCentrality(Directions direction,
String label,
int depth,... |
assert depth > 0;
assert degree > 0L || degree == NO_LIMIT;
assert topN >= 0L || topN == NO_LIMIT;
// TODO: support parameters: Directions dir, String label
/*
* g.V().repeat(groupCount('m').by(id)
* .local(both().limit... | 117 | 319 | 436 | <methods>public non-sealed void <init>() ,public java.lang.String category() ,public void checkParameters(Map<java.lang.String,java.lang.Object>) <variables>private static final Logger LOG |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/cent/StressCentralityAlgorithm.java | StressCentralityAlgorithm | withBoundary | class StressCentralityAlgorithm extends AbstractCentAlgorithm {
public static final String KEY_WITH_BOUNDARY = "with_boundary";
@Override
public String name() {
return "stress_centrality";
}
@Override
public void checkParameters(Map<String, Object> parameters) {
super.checkPar... |
if (!parameters.containsKey(KEY_WITH_BOUNDARY)) {
return false;
}
return ParameterUtil.parameterBoolean(parameters, KEY_WITH_BOUNDARY);
| 602 | 49 | 651 | <methods>public non-sealed void <init>() ,public java.lang.String category() ,public void checkParameters(Map<java.lang.String,java.lang.Object>) <variables>private static final Logger LOG |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/cent/StressCentralityAlgorithmV2.java | Traverser | stressCentrality | class Traverser extends BfsTraverser<StressNode> {
private final Map<Id, MutableLong> globalStresses;
private Traverser(UserJob<Object> job) {
super(job);
this.globalStresses = new HashMap<>();
}
private Object stressCentrality(Directions direction,
... |
assert depth > 0;
assert degree > 0L || degree == NO_LIMIT;
assert topN >= 0L || topN == NO_LIMIT;
Id edgeLabelId = this.getEdgeLabelIdOrNull(label);
// TODO: sample the startVertices
Iterator<Vertex> startVertices = this.vertices(sourceLabel,
... | 481 | 246 | 727 | <methods>public non-sealed void <init>() ,public java.lang.String category() ,public void checkParameters(Map<java.lang.String,java.lang.Object>) <variables>private static final Logger LOG |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/comm/AbstractCommAlgorithm.java | AbstractCommAlgorithm | stableTimes | class AbstractCommAlgorithm extends AbstractAlgorithm {
private static final int MAX_TIMES = 2048;
@Override
public String category() {
return CATEGORY_COMM;
}
protected static int times(Map<String, Object> parameters) {
if (!parameters.containsKey(KEY_TIMES)) {
return... |
if (!parameters.containsKey(KEY_STABLE_TIMES)) {
return (int) DEFAULT_STABLE_TIMES;
}
int times = ParameterUtil.parameterInt(parameters, KEY_STABLE_TIMES);
HugeTraverser.checkPositiveOrNoLimit(times, KEY_STABLE_TIMES);
E.checkArgument(times <= MAX_TIMES,
... | 422 | 140 | 562 | <methods>public non-sealed void <init>() ,public void checkParameters(Map<java.lang.String,java.lang.Object>) <variables>public static final int BATCH,public static final java.lang.String CATEGORY_AGGR,public static final java.lang.String CATEGORY_CENT,public static final java.lang.String CATEGORY_COMM,public static fi... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/comm/ClusterCoefficientAlgorithm.java | ClusterCoefficientAlgorithm | workersWhenBoth | class ClusterCoefficientAlgorithm extends AbstractCommAlgorithm {
public static final String ALGO_NAME = "cluster_coefficient";
@Override
public String name() {
return ALGO_NAME;
}
@Override
public void checkParameters(Map<String, Object> parameters) {
direction(parameters);
... |
Directions direction = direction(parameters);
int workers = workers(parameters);
E.checkArgument(direction == Directions.BOTH || workers <= 0,
"The workers must be not set when direction!=BOTH, " +
"but got workers=%s and direction=%s",
... | 454 | 89 | 543 | <methods>public non-sealed void <init>() ,public java.lang.String category() <variables>private static final int MAX_TIMES |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/comm/KCoreAlgorithm.java | Traverser | kcore | class Traverser extends AlgoTraverser {
public Traverser(UserJob<Object> job, int workers) {
super(job, ALGO_NAME, workers);
}
public Object kcore(String sourceLabel, String sourceCLabel,
Directions dir, String label, int k, double alpha,
... |
HugeGraph graph = this.graph();
KcoreTraverser traverser = new KcoreTraverser(graph);
JsonMap kcoresJson = new JsonMap();
kcoresJson.startObject();
kcoresJson.appendKey("kcores");
kcoresJson.startList();
Set<Set<Id>> kcores = new Has... | 353 | 340 | 693 | <methods>public non-sealed void <init>() ,public java.lang.String category() <variables>private static final int MAX_TIMES |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/comm/LouvainAlgorithm.java | LouvainAlgorithm | call | class LouvainAlgorithm extends AbstractCommAlgorithm {
public static final String ALGO_NAME = "louvain";
@Override
public String name() {
return ALGO_NAME;
}
@Override
public void checkParameters(Map<String, Object> parameters) {
times(parameters);
stableTimes(paramete... |
String label = sourceLabel(parameters);
String clabel = sourceCLabel(parameters);
long degree = degree(parameters);
boolean skipIsolated = skipIsolated(parameters);
int workers = workers(parameters);
Long clearPass = clearPass(parameters);
Long modPass = showMod... | 562 | 352 | 914 | <methods>public non-sealed void <init>() ,public java.lang.String category() <variables>private static final int MAX_TIMES |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/comm/LouvainTraverser.java | Community | equals | class Community {
// community id (stored as a backend vertex)
private final Id cid;
// community members size of last pass [just for skip large community]
private int size = 0;
// community members size of origin vertex [just for debug members lost]
private float weight... |
if (!(object instanceof Community)) {
return false;
}
Community other = (Community) object;
return Objects.equals(this.cid, other.cid);
| 574 | 48 | 622 | <methods>public void <init>(UserJob<java.lang.Object>) ,public void close() ,public org.apache.hugegraph.backend.id.Id jobId() ,public void updateProgress(long) <variables>protected final non-sealed java.util.concurrent.ExecutorService executor,private final non-sealed UserJob<java.lang.Object> job,protected long progr... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/comm/LpaAlgorithm.java | Traverser | lpa | class Traverser extends AlgoTraverser {
private static final long LIMIT = MAX_QUERY_LIMIT;
private final Random R = new Random();
public Traverser(UserJob<Object> job, int workers) {
super(job, ALGO_NAME, workers);
}
public Object lpa(String sourceLabel, String ed... |
assert maxTimes > 0;
assert precision > 0d;
this.initSchema();
int times = maxTimes;
double changedPercent = 0d;
/*
* Iterate until:
* 1.it has stabilized
* 2.or the maximum number of times is reached
... | 1,384 | 257 | 1,641 | <methods>public non-sealed void <init>() ,public java.lang.String category() <variables>private static final int MAX_TIMES |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/comm/TriangleCountAlgorithm.java | Traverser | intersect | class Traverser extends AlgoTraverser {
protected static final String KEY_TRIANGLES = "triangles";
protected static final String KEY_TRIADS = "triads";
public Traverser(UserJob<Object> job, int workers) {
super(job, ALGO_NAME, workers);
}
protected Traverser(UserJo... |
long count = 0L;
Directions dir = Directions.OUT;
Id empty = IdGenerator.ZERO;
Iterator<Id> vertices;
for (Id v : adjVertices) {
vertices = this.adjacentVertices(v, dir, (Id) null, degree);
Id lastVertex = empty;
... | 1,408 | 208 | 1,616 | <methods>public non-sealed void <init>() ,public java.lang.String category() <variables>private static final int MAX_TIMES |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/comm/WeakConnectedComponent.java | Traverser | findMinComponent | class Traverser extends AlgoTraverser {
private final Map<Id, Id> vertexComponentMap = new HashMap<>();
public Traverser(UserJob<Object> job) {
super(job);
}
public Object connectedComponent(int maxTimes,
Directions direction,
... |
Id min = this.vertexComponentMap.get(sourceVertexId);
for (Id vertex : adjacentVertices) {
Id comp = this.vertexComponentMap.get(vertex);
if (comp != null && comp.compareTo(min) < 0) {
min = comp;
}
}
re... | 1,277 | 84 | 1,361 | <methods>public non-sealed void <init>() ,public java.lang.String category() <variables>private static final int MAX_TIMES |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/path/RingsDetectAlgorithm.java | Traverser | rings | class Traverser extends AlgoTraverser {
public Traverser(UserJob<Object> job, int workers) {
super(job, ALGO_NAME, workers);
}
public Object rings(String sourceLabel, String sourceCLabel,
Directions dir, String label, int depth,
... |
JsonMap ringsJson = new JsonMap();
ringsJson.startObject();
if (countOnly) {
ringsJson.appendKey("rings_count");
} else {
ringsJson.appendKey("rings");
ringsJson.startList();
}
SubGraphTraverser tra... | 110 | 451 | 561 | <methods>public non-sealed void <init>() ,public void checkParameters(Map<java.lang.String,java.lang.Object>) <variables>public static final int BATCH,public static final java.lang.String CATEGORY_AGGR,public static final java.lang.String CATEGORY_CENT,public static final java.lang.String CATEGORY_COMM,public static fi... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/rank/PageRankAlgorithm.java | DoublePair | equals | class DoublePair implements Comparable<DoublePair> {
private double left;
private double right;
private DoublePair(double left, double right) {
this.left = left;
this.right = right;
}
public void addLeft(double value) {
this.left += value;
... |
if (!(obj instanceof DoublePair)) {
return false;
}
DoublePair other = (DoublePair) obj;
return this.left == other.left && this.right == other.right;
| 405 | 53 | 458 | <methods>public non-sealed void <init>() ,public java.lang.String category() <variables>private static final int MAX_TIMES |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/similarity/FusiformSimilarityAlgorithm.java | FusiformSimilarityAlgorithm | topSimilars | class FusiformSimilarityAlgorithm extends AbstractAlgorithm {
public static final String ALGO_NAME = "fusiform_similarity";
public static final String KEY_MIN_NEIGHBORS = "min_neighbors";
public static final String KEY_MIN_SIMILARS = "min_similars";
public static final String KEY_TOP_SIMILARS = "top_s... |
if (!parameters.containsKey(KEY_TOP_SIMILARS)) {
return DEFAULT_TOP_SIMILARS;
}
int minSimilars = ParameterUtil.parameterInt(parameters,
KEY_TOP_SIMILARS);
HugeTraverser.checkNonNegative(minSimilars, KEY_TOP_SIMILARS);
... | 1,556 | 109 | 1,665 | <methods>public non-sealed void <init>() ,public void checkParameters(Map<java.lang.String,java.lang.Object>) <variables>public static final int BATCH,public static final java.lang.String CATEGORY_AGGR,public static final java.lang.String CATEGORY_CENT,public static final java.lang.String CATEGORY_COMM,public static fi... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/computer/LouvainComputer.java | LouvainComputer | stableTimes | class LouvainComputer extends AbstractComputer {
public static final String LOUVAIN = "louvain";
public static final String KEY_STABLE_TIMES = "stable_times";
public static final String KEY_PRECISION = "precision";
public static final String KEY_SHOW_MOD = "show_modularity";
public static final St... |
if (!parameters.containsKey(KEY_STABLE_TIMES)) {
return (int) DEFAULT_STABLE_TIMES;
}
int times = ParameterUtil.parameterInt(parameters, KEY_STABLE_TIMES);
HugeTraverser.checkPositiveOrNoLimit(times, KEY_STABLE_TIMES);
E.checkArgument(times <= MAX_TIMES,
... | 870 | 140 | 1,010 | <methods>public non-sealed void <init>() ,public java.lang.Object call(Job<java.lang.Object>, Map<java.lang.String,java.lang.Object>) ,public void checkParameters(Map<java.lang.String,java.lang.Object>) <variables>protected static final java.lang.String CATEGORY_COMM,protected static final java.lang.String CATEGORY_RAN... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/computer/LpaComputer.java | LpaComputer | property | class LpaComputer extends AbstractComputer {
public static final String LPA = "lpa";
public static final String PROPERTY = "property";
public static final String DEFAULT_PROPERTY = "id";
@Override
public String name() {
return LPA;
}
@Override
public String category() {
... |
if (!parameters.containsKey(PROPERTY)) {
return DEFAULT_PROPERTY;
}
String property = ParameterUtil.parameterString(parameters, PROPERTY);
E.checkArgument(property != null && !property.isEmpty(),
"The value of %s can not be null or empty", PROPERTY);
... | 278 | 90 | 368 | <methods>public non-sealed void <init>() ,public java.lang.Object call(Job<java.lang.Object>, Map<java.lang.String,java.lang.Object>) ,public void checkParameters(Map<java.lang.String,java.lang.Object>) <variables>protected static final java.lang.String CATEGORY_COMM,protected static final java.lang.String CATEGORY_RAN... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/computer/PageRankComputer.java | PageRankComputer | alpha | class PageRankComputer extends AbstractComputer {
public static final String PAGE_RANK = "page_rank";
public static final String ALPHA = "alpha";
public static final double DEFAULT_ALPHA = 0.15D;
@Override
public String name() {
return PAGE_RANK;
}
@Override
public String cat... |
if (!parameters.containsKey(ALPHA)) {
return DEFAULT_ALPHA;
}
double alpha = ParameterUtil.parameterDouble(parameters, ALPHA);
E.checkArgument(alpha > 0 && alpha < 1,
"The value of %s must be (0, 1), but got %s",
ALPHA, alpha);... | 266 | 96 | 362 | <methods>public non-sealed void <init>() ,public java.lang.Object call(Job<java.lang.Object>, Map<java.lang.String,java.lang.Object>) ,public void checkParameters(Map<java.lang.String,java.lang.Object>) <variables>protected static final java.lang.String CATEGORY_COMM,protected static final java.lang.String CATEGORY_RAN... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/EdgeLabelRemoveJob.java | EdgeLabelRemoveJob | removeEdgeLabel | class EdgeLabelRemoveJob extends SchemaJob {
@Override
public String type() {
return REMOVE_SCHEMA;
}
@Override
public Object execute() {
removeEdgeLabel(this.params(), this.schemaId());
return null;
}
private static void removeEdgeLabel(HugeGraphParams graph, Id i... |
GraphTransaction graphTx = graph.graphTransaction();
SchemaTransaction schemaTx = graph.schemaTransaction();
EdgeLabel edgeLabel = schemaTx.getEdgeLabel(id);
// If the edge label does not exist, return directly
if (edgeLabel == null) {
return;
}
if (e... | 106 | 411 | 517 | <methods>public non-sealed void <init>() ,public static java.lang.String formatTaskName(org.apache.hugegraph.type.HugeType, org.apache.hugegraph.backend.id.Id, java.lang.String) <variables>public static final java.lang.String CLEAR_OLAP,public static final java.lang.String CREATE_INDEX,public static final java.lang.Str... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/IndexLabelRebuildJob.java | IndexLabelRebuildJob | removeIndex | class IndexLabelRebuildJob extends SchemaJob {
@Override
public String type() {
return REBUILD_INDEX;
}
@Override
public Object execute() {
SchemaElement schema = this.schemaElement();
// If the schema does not exist, ignore it
if (schema != null) {
this... |
SchemaTransaction schemaTx = this.params().schemaTransaction();
GraphTransaction graphTx = this.params().graphTransaction();
for (Id id : indexLabelIds) {
IndexLabel il = schemaTx.getIndexLabel(id);
if (il == null || il.status() == SchemaStatus.CREATING) {
... | 1,231 | 229 | 1,460 | <methods>public non-sealed void <init>() ,public static java.lang.String formatTaskName(org.apache.hugegraph.type.HugeType, org.apache.hugegraph.backend.id.Id, java.lang.String) <variables>public static final java.lang.String CLEAR_OLAP,public static final java.lang.String CREATE_INDEX,public static final java.lang.Str... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/IndexLabelRemoveJob.java | IndexLabelRemoveJob | removeIndexLabel | class IndexLabelRemoveJob extends SchemaJob {
@Override
public String type() {
return REMOVE_SCHEMA;
}
@Override
public Object execute() {
removeIndexLabel(this.params(), this.schemaId());
return null;
}
protected static void removeIndexLabel(HugeGraphParams graph,... |
GraphTransaction graphTx = graph.graphTransaction();
SchemaTransaction schemaTx = graph.schemaTransaction();
IndexLabel indexLabel = schemaTx.getIndexLabel(id);
// If the index label does not exist, return directly
if (indexLabel == null) {
return;
}
... | 106 | 387 | 493 | <methods>public non-sealed void <init>() ,public static java.lang.String formatTaskName(org.apache.hugegraph.type.HugeType, org.apache.hugegraph.backend.id.Id, java.lang.String) <variables>public static final java.lang.String CLEAR_OLAP,public static final java.lang.String CREATE_INDEX,public static final java.lang.Str... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/OlapPropertyKeyClearJob.java | OlapPropertyKeyClearJob | clearIndexLabel | class OlapPropertyKeyClearJob extends IndexLabelRemoveJob {
@Override
public String type() {
return CLEAR_OLAP;
}
@Override
public Object execute() {
Id olap = this.schemaId();
// Clear olap data table
this.params().graphTransaction().clearOlapPk(olap);
//... |
Id olapIndexLabel = findOlapIndexLabel(graph, id);
if (olapIndexLabel == null) {
return;
}
GraphTransaction graphTx = graph.graphTransaction();
SchemaTransaction schemaTx = graph.schemaTransaction();
IndexLabel indexLabel = schemaTx.getIndexLabel(olapIndexLab... | 244 | 319 | 563 | <methods>public non-sealed void <init>() ,public java.lang.Object execute() ,public java.lang.String type() <variables> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/OlapPropertyKeyCreateJob.java | OlapPropertyKeyCreateJob | execute | class OlapPropertyKeyCreateJob extends SchemaJob {
@Override
public String type() {
return CREATE_OLAP;
}
@Override
public Object execute() {<FILL_FUNCTION_BODY>}
} |
SchemaTransaction schemaTx = this.params().schemaTransaction();
PropertyKey propertyKey = schemaTx.getPropertyKey(this.schemaId());
// Create olap index label schema
schemaTx.createIndexLabelForOlapPk(propertyKey);
// Create olap data table
this.params().graphTransaction... | 63 | 96 | 159 | <methods>public non-sealed void <init>() ,public static java.lang.String formatTaskName(org.apache.hugegraph.type.HugeType, org.apache.hugegraph.backend.id.Id, java.lang.String) <variables>public static final java.lang.String CLEAR_OLAP,public static final java.lang.String CREATE_INDEX,public static final java.lang.Str... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/OlapPropertyKeyRemoveJob.java | OlapPropertyKeyRemoveJob | execute | class OlapPropertyKeyRemoveJob extends OlapPropertyKeyClearJob {
@Override
public String type() {
return REMOVE_OLAP;
}
@Override
public Object execute() {<FILL_FUNCTION_BODY>}
} |
Id olap = this.schemaId();
// Remove olap data table
this.params().graphTransaction().removeOlapPk(olap);
// Remove corresponding index label and index data
Id indexLabel = findOlapIndexLabel(this.params(), olap);
if (indexLabel != null) {
removeIndexLabel(... | 67 | 155 | 222 | <methods>public non-sealed void <init>() ,public java.lang.Object execute() ,public java.lang.String type() <variables> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/SchemaJob.java | SchemaJob | updateSchema | class SchemaJob extends SysJob<Object> {
public static final String REMOVE_SCHEMA = "remove_schema";
public static final String REBUILD_INDEX = "rebuild_index";
public static final String CREATE_INDEX = "create_index";
public static final String CREATE_OLAP = "create_olap";
public static final Stri... |
try {
Method method = SchemaTransaction.class
.getDeclaredMethod("updateSchema",
SchemaElement.class);
method.setAccessible(true);
method.invoke(tx, schema);
} catch (NoSuchMethodException | IllegalAccessExce... | 828 | 107 | 935 | <methods>public non-sealed void <init>() ,public java.lang.Object call() throws java.lang.Exception<variables> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/VertexLabelRemoveJob.java | VertexLabelRemoveJob | removeVertexLabel | class VertexLabelRemoveJob extends SchemaJob {
@Override
public String type() {
return REMOVE_SCHEMA;
}
@Override
public Object execute() {
removeVertexLabel(this.params(), this.schemaId());
return null;
}
private static void removeVertexLabel(HugeGraphParams graph... |
GraphTransaction graphTx = graph.graphTransaction();
SchemaTransaction schemaTx = graph.schemaTransaction();
VertexLabel vertexLabel = schemaTx.getVertexLabel(id);
// If the vertex label does not exist, return directly
if (vertexLabel == null) {
return;
}
... | 107 | 553 | 660 | <methods>public non-sealed void <init>() ,public static java.lang.String formatTaskName(org.apache.hugegraph.type.HugeType, org.apache.hugegraph.backend.id.Id, java.lang.String) <variables>public static final java.lang.String CLEAR_OLAP,public static final java.lang.String CREATE_INDEX,public static final java.lang.Str... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/system/DeleteExpiredElementJob.java | DeleteExpiredElementJob | execute | class DeleteExpiredElementJob<V> extends DeleteExpiredJob<V> {
private static final String JOB_TYPE = "delete_expired_element";
private Set<HugeElement> elements;
public DeleteExpiredElementJob(Set<HugeElement> elements) {
E.checkArgument(elements != null && !elements.isEmpty(),
... |
LOG.debug("Delete expired elements: {}", this.elements);
HugeGraphParams graph = this.params();
GraphTransaction tx = graph.graphTransaction();
try {
for (HugeElement element : this.elements) {
element.remove();
}
tx.commit();
... | 162 | 151 | 313 | <methods>public non-sealed void <init>() ,public static void asyncDeleteExpiredObject(org.apache.hugegraph.HugeGraph, V) ,public static EphemeralJob<V> newDeleteExpiredElementJob(org.apache.hugegraph.job.system.JobCounters.JobCounter, V) <variables>protected static final org.apache.hugegraph.job.system.JobCounters JOB_... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/system/DeleteExpiredIndexJob.java | DeleteExpiredIndexJob | execute | class DeleteExpiredIndexJob<V> extends DeleteExpiredJob<V> {
private static final String JOB_TYPE = "delete_expired_index";
private final Set<HugeIndex> indexes;
public DeleteExpiredIndexJob(Set<HugeIndex> indexes) {
E.checkArgument(indexes != null && !indexes.isEmpty(),
"... |
LOG.debug("Delete expired indexes: {}", this.indexes);
HugeGraphParams graph = this.params();
GraphTransaction tx = graph.graphTransaction();
try {
for (HugeIndex index : this.indexes) {
this.deleteExpiredIndex(graph, index);
}
tx.com... | 422 | 162 | 584 | <methods>public non-sealed void <init>() ,public static void asyncDeleteExpiredObject(org.apache.hugegraph.HugeGraph, V) ,public static EphemeralJob<V> newDeleteExpiredElementJob(org.apache.hugegraph.job.system.JobCounters.JobCounter, V) <variables>protected static final org.apache.hugegraph.job.system.JobCounters JOB_... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/system/DeleteExpiredJob.java | DeleteExpiredJob | asyncDeleteExpiredObject | class DeleteExpiredJob<T> extends EphemeralJob<T> {
protected static final Logger LOG = Log.logger(DeleteExpiredJob.class);
private static final int MAX_JOBS = 1000;
protected static final JobCounters JOB_COUNTERS = new JobCounters();
public static <V> void asyncDeleteExpiredObject(HugeGraph graph, V... |
E.checkArgumentNotNull(object, "The object can't be null");
JobCounters.JobCounter jobCounter = JOB_COUNTERS.jobCounter(graph);
if (!jobCounter.addAndTriggerDelete(object)) {
return;
}
if (jobCounter.jobs() >= MAX_JOBS) {
LOG.debug("Pending delete expired... | 214 | 383 | 597 | <methods>public non-sealed void <init>() ,public T call() throws java.lang.Exception,public abstract T execute() throws java.lang.Exception,public abstract java.lang.String type() <variables> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/system/JobCounters.java | JobCounter | addElementAndTriggerDelete | class JobCounter {
private final AtomicInteger jobs;
private Set<HugeElement> elements;
private Set<HugeIndex> indexes;
private final int batchSize;
public JobCounter(int batchSize) {
this.jobs = new AtomicInteger(0);
this.elements = ConcurrentHashMap.ne... |
if (this.elements.size() >= this.batchSize) {
return true;
}
this.elements.add(element);
return this.elements.size() >= this.batchSize;
| 559 | 53 | 612 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/masterelection/ClusterRole.java | ClusterRole | equals | class ClusterRole {
private final String node;
private long clock;
private final int epoch;
private final String url;
public ClusterRole(String node, String url, int epoch) {
this(node, url, epoch, 1);
}
public ClusterRole(String node, String url, int epoch, long clock) {
... |
if (this == obj) {
return true;
}
if (!(obj instanceof ClusterRole)) {
return false;
}
ClusterRole clusterRole = (ClusterRole) obj;
return clock == clusterRole.clock &&
epoch == clusterRole.epoch &&
Objects.equals(nod... | 388 | 88 | 476 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/masterelection/GlobalMasterInfo.java | GlobalMasterInfo | masterInfo | class GlobalMasterInfo {
private final static NodeInfo NO_MASTER = new NodeInfo(false, "");
private volatile boolean supportElection;
private volatile NodeInfo masterNodeInfo;
private volatile Id nodeId;
private volatile NodeRole nodeRole;
public GlobalMasterInfo() {
this(NO_MASTER);... |
// final can avoid instruction rearrangement, visibility can be ignored
this.masterNodeInfo = new NodeInfo(isMaster, nodeUrl);
| 653 | 37 | 690 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/masterelection/RoleElectionOptions.java | RoleElectionOptions | instance | class RoleElectionOptions extends OptionHolder {
private RoleElectionOptions() {
super();
}
private static volatile RoleElectionOptions instance;
public static synchronized RoleElectionOptions instance() {<FILL_FUNCTION_BODY>}
public static final ConfigOption<Integer> EXCEEDS_FAIL_COUNT ... |
if (instance == null) {
instance = new RoleElectionOptions();
// Should initialize all static members first, then register.
instance.registerOptions();
}
return instance;
| 599 | 51 | 650 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/masterelection/StandardClusterRoleStore.java | StandardClusterRoleStore | updateIfNodePresent | class StandardClusterRoleStore implements ClusterRoleStore {
private static final Logger LOG = Log.logger(StandardClusterRoleStore.class);
private static final int RETRY_QUERY_TIMEOUT = 200;
private final HugeGraphParams graph;
private boolean firstTime;
public StandardClusterRoleStore(HugeGraph... |
// if epoch increase, update and return true
// if epoch equal, ignore different node, return false
Optional<Vertex> oldClusterRoleOpt = this.queryVertex();
if (oldClusterRoleOpt.isPresent()) {
ClusterRole oldClusterRole = this.from(oldClusterRoleOpt.get());
if (... | 1,255 | 388 | 1,643 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/masterelection/StandardRoleElectionStateMachine.java | WorkerState | merge | class WorkerState implements RoleState {
private ClusterRole clusterRole;
private int clock;
public WorkerState(ClusterRole clusterRole) {
this.clusterRole = clusterRole;
this.clock = 0;
}
@Override
public RoleState transform(StateMachineContext... |
if (state.clusterRole.epoch() > this.clusterRole.epoch()) {
this.clock = 0;
this.clusterRole = state.clusterRole;
} else if (state.clusterRole.epoch() < this.clusterRole.epoch()) {
throw new IllegalStateException("Epoch must increase");
... | 269 | 214 | 483 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/masterelection/StandardRoleListener.java | StandardRoleListener | unknown | class StandardRoleListener implements RoleListener {
private static final Logger LOG = Log.logger(StandardRoleListener.class);
private final TaskManager taskManager;
private final GlobalMasterInfo roleInfo;
private volatile boolean selfIsMaster;
public StandardRoleListener(TaskManager taskManag... |
if (this.selfIsMaster) {
this.taskManager.onAsRoleWorker();
LOG.info("Server {} change to worker role", context.config().node());
}
this.updateMasterInfo(context);
this.selfIsMaster = false;
| 595 | 70 | 665 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/EdgeLabel.java | EdgeLabel | sourceLabel | class EdgeLabel extends SchemaLabel {
public static final EdgeLabel NONE = new EdgeLabel(null, NONE_ID, UNDEF);
private Id sourceLabel = NONE_ID;
private Id targetLabel = NONE_ID;
private Frequency frequency;
private List<Id> sortKeys;
public EdgeLabel(final HugeGraph graph, Id id, String nam... |
E.checkArgument(this.sourceLabel == NONE_ID,
"Not allowed to set source label multi times " +
"of edge label '%s'", this.name());
this.sourceLabel = id;
| 1,096 | 56 | 1,152 | <methods>public void <init>(org.apache.hugegraph.HugeGraph, org.apache.hugegraph.backend.id.Id, java.lang.String) ,public void addIndexLabel(org.apache.hugegraph.backend.id.Id) ,public transient void addIndexLabels(org.apache.hugegraph.backend.id.Id[]) ,public boolean enableLabelIndex() ,public void enableLabelIndex(bo... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/SchemaElement.java | SchemaElement | equals | class SchemaElement implements Nameable, Typeable,
Cloneable {
public static final int MAX_PRIMITIVE_SYS_ID = 32;
public static final int NEXT_PRIMITIVE_SYS_ID = 8;
// ABS of system schema id must be below MAX_PRIMITIVE_SYS_ID
protected static final int V... |
if (!(obj instanceof SchemaElement)) {
return false;
}
SchemaElement other = (SchemaElement) obj;
return this.type() == other.type() && this.id.equals(other.id());
| 1,491 | 60 | 1,551 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/SchemaLabel.java | SchemaLabel | getLabelId | class SchemaLabel extends SchemaElement
implements Indexable, Propertiable {
private final Set<Id> properties;
private final Set<Id> nullableKeys;
private final Set<Id> indexLabels;
private boolean enableLabelIndex;
private long ttl;
private Id ttlStartTime;
public SchemaLabel(fina... |
E.checkNotNull(graph, "graph");
E.checkNotNull(type, "type");
E.checkNotNull(label, "label");
if (label instanceof Number) {
return IdGenerator.of(((Number) label).longValue());
} else if (label instanceof String) {
if (type.isVertex()) {
... | 1,170 | 204 | 1,374 | <methods>public void <init>(org.apache.hugegraph.HugeGraph, org.apache.hugegraph.backend.id.Id, java.lang.String) ,public org.apache.hugegraph.schema.SchemaElement copy() ,public boolean equals(java.lang.Object) ,public org.apache.hugegraph.HugeGraph graph() ,public boolean hasSameContent(org.apache.hugegraph.schema.Sc... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/SchemaManager.java | SchemaManager | getEdgeLabel | class SchemaManager {
private final SchemaTransaction transaction;
private HugeGraph graph;
public SchemaManager(SchemaTransaction transaction, HugeGraph graph) {
E.checkNotNull(transaction, "transaction");
E.checkNotNull(graph, "graph");
this.transaction = transaction;
thi... |
E.checkArgumentNotNull(name, "The name parameter can't be null");
EdgeLabel edgeLabel = this.transaction.getEdgeLabel(name);
checkExists(HugeType.EDGE_LABEL, edgeLabel, name);
return edgeLabel;
| 1,049 | 67 | 1,116 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/Userdata.java | Userdata | check | class Userdata extends HashMap<String, Object> {
private static final long serialVersionUID = -1235451175617197049L;
public static final String CREATE_TIME = "~create_time";
public static final String DEFAULT_VALUE = "~default_value";
public Userdata() {
}
public Userdata(Map<String, Object>... |
if (userdata == null) {
return;
}
switch (action) {
case INSERT:
case APPEND:
for (Map.Entry<String, Object> e : userdata.entrySet()) {
if (e.getValue() == null) {
throw new NotAllowException(
... | 150 | 165 | 315 | <methods>public void <init>() ,public void <init>(int) ,public void <init>(Map<? extends java.lang.String,? extends java.lang.Object>) ,public void <init>(int, float) ,public void clear() ,public java.lang.Object clone() ,public java.lang.Object compute(java.lang.String, BiFunction<? super java.lang.String,? super java... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/VertexLabel.java | VertexLabel | hasSameContent | class VertexLabel extends SchemaLabel {
public static final VertexLabel NONE = new VertexLabel(null, NONE_ID, UNDEF);
// OLAP_VL_ID means all of vertex label ids
private static final Id OLAP_VL_ID = IdGenerator.of(SchemaLabel.OLAP_VL_ID);
// OLAP_VL_NAME means all of vertex label names
private sta... |
return super.hasSameContent(other) &&
this.idStrategy == other.idStrategy &&
Objects.equal(this.graph.mapPkId2Name(this.primaryKeys),
other.graph.mapPkId2Name(other.primaryKeys));
| 777 | 68 | 845 | <methods>public void <init>(org.apache.hugegraph.HugeGraph, org.apache.hugegraph.backend.id.Id, java.lang.String) ,public void addIndexLabel(org.apache.hugegraph.backend.id.Id) ,public transient void addIndexLabels(org.apache.hugegraph.backend.id.Id[]) ,public boolean enableLabelIndex() ,public void enableLabelIndex(bo... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/builder/AbstractBuilder.java | AbstractBuilder | lockCheckAndCreateSchema | class AbstractBuilder {
private final SchemaTransaction transaction;
private final HugeGraph graph;
public AbstractBuilder(SchemaTransaction transaction, HugeGraph graph) {
E.checkNotNull(transaction, "transaction");
E.checkNotNull(graph, "graph");
this.transaction = transaction;
... |
String graph = this.transaction.graphName();
LockUtil.Locks locks = new LockUtil.Locks(graph);
try {
locks.lockWrites(LockUtil.hugeType2Group(type),
IdGenerator.of(name));
return callback.apply(name);
} finally {
locks.unl... | 542 | 88 | 630 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeEdgeProperty.java | HugeEdgeProperty | equals | class HugeEdgeProperty<V> extends HugeProperty<V> {
public HugeEdgeProperty(HugeElement owner, PropertyKey key, V value) {
super(owner, key, value);
}
@Override
public HugeType type() {
return this.pkey.aggregateType().isNone() ?
HugeType.PROPERTY : HugeType.AGGR_PROPERT... |
if (!(obj instanceof Property)) {
return false;
}
return ElementHelper.areEqual(this, obj);
| 370 | 34 | 404 | <methods>public void <init>(org.apache.hugegraph.structure.HugeElement, org.apache.hugegraph.schema.PropertyKey, V) ,public org.apache.hugegraph.structure.HugeElement element() ,public boolean equals(java.lang.Object) ,public int hashCode() ,public java.lang.Object id() ,public boolean isAggregateType() ,public boolean... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeFeatures.java | HugeElementFeatures | willAllowId | class HugeElementFeatures implements ElementFeatures {
@Override
public boolean supportsAddProperty() {
return true;
}
@Override
public boolean supportsRemoveProperty() {
return true;
}
@Override
public boolean supportsStringIds(... |
if (!this.supportsUserSuppliedIds()) {
return false;
} else {
return this.supportsAnyIds() ||
this.supportsCustomIds() && id instanceof Id ||
this.supportsStringIds() && id instanceof String ||
... | 222 | 99 | 321 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeProperty.java | HugeProperty | equals | class HugeProperty<V> implements Property<V>, GraphType {
protected final HugeElement owner;
protected final PropertyKey pkey;
protected final V value;
public HugeProperty(HugeElement owner, PropertyKey pkey, V value) {
E.checkArgument(owner != null, "Property owner can't be null");
E.... |
if (!(obj instanceof HugeProperty)) {
return false;
}
HugeProperty<?> other = (HugeProperty<?>) obj;
return this.owner.equals(other.owner) && this.pkey.equals(other.pkey);
| 526 | 70 | 596 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeVertexProperty.java | HugeVertexProperty | equals | class HugeVertexProperty<V> extends HugeProperty<V>
implements VertexProperty<V> {
public HugeVertexProperty(HugeElement owner, PropertyKey key, V value) {
super(owner, key, value);
}
@Override
public HugeType type() {
return this.pkey.aggregateType().isNone() ?
... |
if (!(obj instanceof VertexProperty)) {
return false;
}
@SuppressWarnings("unchecked")
VertexProperty<V> other = (VertexProperty<V>) obj;
return this.id().equals(other.id());
| 399 | 67 | 466 | <methods>public void <init>(org.apache.hugegraph.structure.HugeElement, org.apache.hugegraph.schema.PropertyKey, V) ,public org.apache.hugegraph.structure.HugeElement element() ,public boolean equals(java.lang.Object) ,public int hashCode() ,public java.lang.Object id() ,public boolean isAggregateType() ,public boolean... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/EphemeralJobQueue.java | BatchEphemeralJob | execute | class BatchEphemeralJob extends EphemeralJob<Object> {
private static final long PAGE_SIZE = Query.COMMIT_BATCH;
private static final String BATCH_EPHEMERAL_JOB = "batch-ephemeral-job";
private static final long MAX_CONSUME_COUNT = 2 * PAGE_SIZE;
private WeakReference<EphemeralJobQueue... |
boolean stop = false;
Object result = null;
int consumeCount = 0;
InterruptedException interruptedException = null;
EphemeralJobQueue queue;
List<EphemeralJob<?>> batchJobs = new ArrayList<>();
while (!stop) {
if (inter... | 593 | 412 | 1,005 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/HugeServerInfo.java | P | unhide | class P {
public static final String SERVER = Graph.Hidden.hide("server");
public static final String ID = T.id.getAccessor();
public static final String LABEL = T.label.getAccessor();
public static final String NAME = "~server_name";
public static final String ROLE = "~server... |
final String prefix = Graph.Hidden.hide("server_");
if (key.startsWith(prefix)) {
return key.substring(prefix.length());
}
return key;
| 167 | 52 | 219 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/TaskCallable.java | TaskCallable | empty | class TaskCallable<V> implements Callable<V> {
private static final Logger LOG = Log.logger(TaskCallable.class);
private static final String ERROR_COMMIT = "Failed to commit changes: ";
private static final Set<String> ERROR_MESSAGES = ImmutableSet.of(
/*
* "The max length of byte... |
return new TaskCallable<V>() {
@Override
public V call() throws Exception {
throw e;
}
};
| 1,265 | 39 | 1,304 | <no_super_class> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.