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/traversal/algorithm/CollectionPathsTraverser.java | NearestTraverser | processOneForBackward | class NearestTraverser extends Traverser {
public NearestTraverser(HugeTraverser traverser,
TraverseStrategy strategy,
Collection<Id> sources, Collection<Id> targets,
EdgeStep step, int depth, long capacity,
... |
Node sourcee = this.targets.get(sourceV).get(0);
// If have loop, skip target
if (sourcee.contains(targetV)) {
return;
}
// If cross point exists, path found, concat them
if (this.sourcesAll.containsKey(targetV)) {
... | 657 | 217 | 874 | <methods>public void <init>(org.apache.hugegraph.HugeGraph) ,public static void checkCapacity(long) ,public static void checkCapacity(long, long, java.lang.String) ,public static void checkDegree(long) ,public static void checkLimit(long) ,public static void checkNonNegative(long, java.lang.String) ,public static void ... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/CountTraverser.java | CountTraverser | count | class CountTraverser extends HugeTraverser {
private boolean containsTraversed = false;
private long dedupSize = 1000000L;
private final Set<Id> dedupSet = newIdSet();
private final MutableLong count = new MutableLong(0L);
public CountTraverser(HugeGraph graph) {
super(graph);
}
p... |
E.checkNotNull(source, "source vertex id");
this.checkVertexExist(source, "source vertex");
E.checkArgument(steps != null && !steps.isEmpty(),
"The steps can't be empty");
checkDedupSize(dedupSize);
this.containsTraversed = containsTraversed;
thi... | 494 | 511 | 1,005 | <methods>public void <init>(org.apache.hugegraph.HugeGraph) ,public static void checkCapacity(long) ,public static void checkCapacity(long, long, java.lang.String) ,public static void checkDegree(long) ,public static void checkLimit(long) ,public static void checkNonNegative(long, java.lang.String) ,public static void ... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/CustomizePathsTraverser.java | WeightNode | weights | class WeightNode extends Node {
private final double weight;
public WeightNode(Id id, Node parent, double weight) {
super(id, parent);
this.weight = weight;
}
public List<Double> weights() {<FILL_FUNCTION_BODY>}
} |
List<Double> weights = newList();
WeightNode current = this;
while (current.parent() != null) {
weights.add(current.weight);
current = (WeightNode) current.parent();
}
Collections.reverse(weights);
return weights;
... | 77 | 76 | 153 | <methods>public void <init>(org.apache.hugegraph.HugeGraph) ,public static void checkCapacity(long) ,public static void checkCapacity(long, long, java.lang.String) ,public static void checkDegree(long) ,public static void checkLimit(long) ,public static void checkNonNegative(long, java.lang.String) ,public static void ... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/CustomizedCrosspointsTraverser.java | CustomizedCrosspointsTraverser | crosspointsPaths | class CustomizedCrosspointsTraverser extends HugeTraverser {
private final EdgeRecord edgeResults;
public CustomizedCrosspointsTraverser(HugeGraph graph) {
super(graph);
this.edgeResults = new EdgeRecord(false);
}
private static CrosspointsPaths intersectionPaths(List<HugeVertex> sour... |
E.checkArgument(vertices.hasNext(),
"The source vertices can't be empty");
E.checkArgument(!pathPatterns.isEmpty(),
"The steps pattern can't be empty");
checkCapacity(capacity);
checkLimit(limit);
MultivaluedMap<Id, Node> initialSo... | 1,059 | 715 | 1,774 | <methods>public void <init>(org.apache.hugegraph.HugeGraph) ,public static void checkCapacity(long) ,public static void checkCapacity(long, long, java.lang.String) ,public static void checkDegree(long) ,public static void checkLimit(long) ,public static void checkNonNegative(long, java.lang.String) ,public static void ... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/EdgeExistenceTraverser.java | EdgeExistenceTraverser | queryEdgeExistence | class EdgeExistenceTraverser extends HugeTraverser {
public EdgeExistenceTraverser(HugeGraph graph) {
super(graph);
}
public Iterator<Edge> queryEdgeExistence(Id sourceId, Id targetId, String label,
String sortValues, long limit) {<FILL_FUNCTION_BODY>}
... |
// If no label provided, fallback to a slow query by filtering
if (label == null || label.isEmpty()) {
return queryByNeighbors(sourceId, targetId, limit);
}
EdgeLabel edgeLabel = graph().edgeLabel(label);
ConditionQuery conditionQuery = new ConditionQuery(HugeType.E... | 167 | 256 | 423 | <methods>public void <init>(org.apache.hugegraph.HugeGraph) ,public static void checkCapacity(long) ,public static void checkCapacity(long, long, java.lang.String) ,public static void checkDegree(long) ,public static void checkLimit(long) ,public static void checkNonNegative(long, java.lang.String) ,public static void ... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/JaccardSimilarTraverser.java | JaccardSimilarTraverser | jaccardSimilarsSingle | class JaccardSimilarTraverser extends OltpTraverser {
public JaccardSimilarTraverser(HugeGraph graph) {
super(graph);
}
private static void reachCapacity(long count, long capacity) {
if (capacity != NO_LIMIT && count > capacity) {
throw new HugeException("Reach capacity '%s'", ... |
long count = 0L;
Set<Id> accessed = newIdSet();
accessed.add(source);
reachCapacity(++count, capacity);
// Query neighbors
Set<Id> layer1s = this.adjacentVertices(source, step);
this.vertexIterCounter.addAndGet(1L);
this.edgeIterCounter.addAndGet(layer1... | 1,406 | 628 | 2,034 | <methods>public void close() ,public static void destroy() <variables>private static final java.lang.String EXECUTOR_NAME,private static org.apache.hugegraph.util.Consumers.ExecutorPool executors |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/KneighborTraverser.java | KneighborTraverser | customizedKneighbor | class KneighborTraverser extends OltpTraverser {
public KneighborTraverser(HugeGraph graph) {
super(graph);
}
public Set<Id> kneighbor(Id sourceV, Directions dir,
String label, int depth,
long degree, long limit) {
E.checkNotNull(so... |
E.checkNotNull(source, "source vertex id");
this.checkVertexExist(source, "source vertex");
checkPositive(maxDepth, "k-neighbor max_depth");
checkLimit(limit);
KneighborRecords records = new KneighborRecords(true,
source, ... | 454 | 290 | 744 | <methods>public void close() ,public static void destroy() <variables>private static final java.lang.String EXECUTOR_NAME,private static org.apache.hugegraph.util.Consumers.ExecutorPool executors |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/KoutTraverser.java | KoutTraverser | customizedKout | class KoutTraverser extends OltpTraverser {
public KoutTraverser(HugeGraph graph) {
super(graph);
}
public Set<Id> kout(Id sourceV, Directions dir, String label,
int depth, boolean nearest,
long degree, long capacity, long limit) {
E.checkNot... |
E.checkNotNull(source, "source vertex id");
this.checkVertexExist(source, "source vertex");
checkPositive(maxDepth, "k-out max_depth");
checkCapacity(capacity);
checkLimit(limit);
long[] depth = new long[1];
depth[0] = maxDepth;
KoutRecords records = new... | 1,178 | 330 | 1,508 | <methods>public void close() ,public static void destroy() <variables>private static final java.lang.String EXECUTOR_NAME,private static org.apache.hugegraph.util.Consumers.ExecutorPool executors |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/PathTraverser.java | PathTraverser | forward | class PathTraverser {
protected final HugeTraverser traverser;
protected final long capacity;
protected final long limit;
protected int stepCount;
protected int totalSteps; // TODO: delete or implement abstract method
protected Map<Id, List<HugeTraverser.Node>> sources;
protected Map<Id, L... |
EdgeStep currentStep = this.nextStep(true);
if (currentStep == null) {
return;
}
this.beforeTraverse(true);
// Traversal vertices of previous level
this.traverseOneLayer(this.sources, currentStep, this::forward);
this.afterTraverse(currentStep, tru... | 1,645 | 90 | 1,735 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/PathsTraverser.java | Traverser | forward | class Traverser {
private final PathsRecords record;
private final Id label;
private final long degree;
private final long capacity;
private final long limit;
private final PathSet paths;
private long vertexCounter;
private long edgeCounter;
pu... |
Iterator<Edge> edges;
this.record.startOneLayer(true);
while (this.record.hasNextKey()) {
Id vid = this.record.nextKey();
if (vid.equals(targetV)) {
continue;
}
edges = edgesOfVertex(vid, direction... | 605 | 233 | 838 | <methods>public void <init>(org.apache.hugegraph.HugeGraph) ,public static void checkCapacity(long) ,public static void checkCapacity(long, long, java.lang.String) ,public static void checkDegree(long) ,public static void checkLimit(long) ,public static void checkNonNegative(long, java.lang.String) ,public static void ... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/PersonalRankTraverser.java | PersonalRankTraverser | calcNewRanks | class PersonalRankTraverser extends HugeTraverser {
private final double alpha;
private final long degree;
private final int maxDepth;
public PersonalRankTraverser(HugeGraph graph, double alpha,
long degree, int maxDepth) {
super(graph);
this.alpha = al... |
Map<Id, Double> newRanks = newMap();
BiFunction<Set<Id>, Directions, Set<Id>> neighborIncrRanks;
neighborIncrRanks = (seeds, dir) -> {
Set<Id> tmpSeeds = newIdSet();
for (Id seed : seeds) {
Double oldRank = ranks.get(seed);
E.checkState(ol... | 1,030 | 416 | 1,446 | <methods>public void <init>(org.apache.hugegraph.HugeGraph) ,public static void checkCapacity(long) ,public static void checkCapacity(long, long, java.lang.String) ,public static void checkDegree(long) ,public static void checkLimit(long) ,public static void checkNonNegative(long, java.lang.String) ,public static void ... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/PredictionTraverser.java | PredictionTraverser | adamicAdar | class PredictionTraverser extends OltpTraverser {
public PredictionTraverser(HugeGraph graph) {
super(graph);
}
public double adamicAdar(Id source, Id target, Directions dir,
String label, long degree, int limit) {<FILL_FUNCTION_BODY>}
public double resourceAlloca... |
Set<Id> neighbors = checkAndGetCommonNeighbors(source, target, dir,
label, degree, limit);
EdgeStep step = label == null ? new EdgeStep(graph(), dir) :
new EdgeStep(graph(), dir, ImmutableList.of(label));
double sum... | 438 | 151 | 589 | <methods>public void close() ,public static void destroy() <variables>private static final java.lang.String EXECUTOR_NAME,private static org.apache.hugegraph.util.Consumers.ExecutorPool executors |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/SameNeighborTraverser.java | SameNeighborTraverser | sameNeighbors | class SameNeighborTraverser extends HugeTraverser {
public SameNeighborTraverser(HugeGraph graph) {
super(graph);
}
public Set<Id> sameNeighbors(Id vertex, Id other, Directions direction,
String label, long degree, int limit) {
E.checkNotNull(vertex, "verte... |
E.checkNotNull(vertexIds, "vertex ids");
E.checkArgument(vertexIds.size() >= 2, "vertex_list size can't " +
"be less than 2");
for (Id id : vertexIds) {
this.checkVertexExist(id, "vertex");
}
E.checkNotNull(direction, "d... | 478 | 419 | 897 | <methods>public void <init>(org.apache.hugegraph.HugeGraph) ,public static void checkCapacity(long) ,public static void checkCapacity(long, long, java.lang.String) ,public static void checkDegree(long) ,public static void checkLimit(long) ,public static void checkNonNegative(long, java.lang.String) ,public static void ... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/TemplatePathsTraverser.java | Traverser | afterTraverse | class Traverser extends PathTraverser {
protected final List<RepeatEdgeStep> steps;
protected boolean withRing;
protected int sourceIndex;
protected int targetIndex;
protected boolean sourceFinishOneStep;
protected boolean targetFinishOneStep;
public Traverse... |
Map<Id, List<Node>> all = forward ? this.sourcesAll :
this.targetsAll;
this.addNewVerticesToAll(all);
this.reInitCurrentStepIfNeeded(step, forward);
this.stepCount++;
| 1,567 | 68 | 1,635 | <methods>public void <init>(org.apache.hugegraph.HugeGraph) ,public static void checkCapacity(long) ,public static void checkCapacity(long, long, java.lang.String) ,public static void checkDegree(long) ,public static void checkLimit(long) ,public static void checkNonNegative(long, java.lang.String) ,public static void ... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/iterator/NestedIterator.java | NestedIterator | pathEdges | class NestedIterator extends WrappedIterator<Edge> {
private final int MAX_CACHED_COUNT = 1000;
/**
* Set<Id> visited: visited vertex-ids of all parent-tree
* used to exclude visited vertex
*/
private final boolean nearest;
private final Set<Id> visited;
private final int MAX_VISITED... |
List<HugeEdge> edges = new ArrayList<>();
HugeEdge edge = this.cache.get(edgePointer);
if (this.parentIterator instanceof NestedIterator) {
NestedIterator parent = (NestedIterator) this.parentIterator;
int parentEdgePointer = this.parentEdgePointerMap.get(makeEdgeIndex(e... | 1,362 | 119 | 1,481 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/records/AbstractRecords.java | AbstractRecords | code | class AbstractRecords implements Records {
private final ObjectIntMapping<Id> idMapping;
private final RecordType type;
private final boolean concurrent;
private Record currentRecord;
private Record parentRecord;
public AbstractRecords(RecordType type, boolean concurrent) {
this.type =... |
if (id.number()) {
long l = id.asLong();
if (0 <= l && l <= Integer.MAX_VALUE) {
return (int) l;
}
}
int code = this.idMapping.object2Code(id);
assert code > 0;
return -code;
| 322 | 82 | 404 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/records/DoubleWayMultiPathsRecords.java | DoubleWayMultiPathsRecords | linkPathLayer | class DoubleWayMultiPathsRecords extends AbstractRecords {
private final Stack<Record> sourceRecords;
private final Stack<Record> targetRecords;
private IntIterator parentRecordKeys;
private int currentKey;
private boolean movingForward;
private long accessed;
public DoubleWayMultiPathsRe... |
PathSet results = new PathSet();
if (layerIndex == 0) {
Id sid = this.id(id);
results.add(new Path(Lists.newArrayList(sid)));
return results;
}
Id current = this.id(id);
Record layer = all.elementAt(layerIndex);
IntIterator iterator =... | 1,269 | 166 | 1,435 | <methods>public void <init>(org.apache.hugegraph.traversal.algorithm.records.record.RecordType, boolean) <variables>private final non-sealed boolean concurrent,private org.apache.hugegraph.traversal.algorithm.records.record.Record currentRecord,private final non-sealed ObjectIntMapping<org.apache.hugegraph.backend.id.I... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/records/KneighborRecords.java | KneighborRecords | paths | class KneighborRecords extends SingleWayMultiPathsRecords {
public KneighborRecords(boolean concurrent,
Id source, boolean nearest) {
super(RecordType.INT, concurrent, source, nearest);
}
@Override
public int size() {
return (int) this.accessed();
}
... |
PathSet paths = new PathSet();
Stack<Record> records = this.records();
for (int i = 1; i < records.size(); i++) {
IntIterator iterator = records.get(i).keys();
while ((limit == NO_LIMIT || limit > 0L) && iterator.hasNext()) {
paths.add(this.linkPath(i, it... | 370 | 118 | 488 | <methods>public void <init>(org.apache.hugegraph.traversal.algorithm.records.record.RecordType, boolean, org.apache.hugegraph.backend.id.Id, boolean) ,public long accessed() ,public void addPath(org.apache.hugegraph.backend.id.Id, org.apache.hugegraph.backend.id.Id) ,public void addPathToRecord(int, int, org.apache.hug... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/records/KoutRecords.java | KoutRecords | ids | class KoutRecords extends SingleWayMultiPathsRecords {
// Non-zero depth is used for deepFirst traverse mode.
// In such case, startOneLayer/finishOneLayer should not be called,
// instead, we should use addFullPath
private final int depth;
public KoutRecords(boolean concurrent, Id source, boolean... |
List<Id> ids = CollectionFactory.newList(CollectionType.EC);
IntIterator iterator = this.records().peek().keys();
while ((limit == NO_LIMIT || limit-- > 0L) && iterator.hasNext()) {
ids.add(this.id(iterator.next()));
}
return ids;
| 621 | 89 | 710 | <methods>public void <init>(org.apache.hugegraph.traversal.algorithm.records.record.RecordType, boolean, org.apache.hugegraph.backend.id.Id, boolean) ,public long accessed() ,public void addPath(org.apache.hugegraph.backend.id.Id, org.apache.hugegraph.backend.id.Id) ,public void addPathToRecord(int, int, org.apache.hug... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/records/PathsRecords.java | PathsRecords | findPath | class PathsRecords extends DoubleWayMultiPathsRecords {
public PathsRecords(boolean concurrent, Id sourceV, Id targetV) {
super(RecordType.ARRAY, concurrent, sourceV, targetV);
}
@Watched
@Override
public PathSet findPath(Id target, Function<Id, Boolean> filter,
... |
assert all;
int targetCode = this.code(target);
int parentCode = this.current();
PathSet paths = PathSet.EMPTY;
// Traverse backtrace is not allowed, stop now
if (this.parentsContain(targetCode)) {
return paths;
}
// Add to current layer
... | 113 | 201 | 314 | <methods>public void <init>(org.apache.hugegraph.traversal.algorithm.records.record.RecordType, boolean, org.apache.hugegraph.backend.id.Id, org.apache.hugegraph.backend.id.Id) ,public long accessed() ,public void finishOneLayer() ,public boolean hasNextKey() ,public org.apache.hugegraph.backend.id.Id nextKey() ,public... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/records/SingleWayMultiPathsRecords.java | SingleWayMultiPathsRecords | findPath | class SingleWayMultiPathsRecords extends AbstractRecords {
protected final int sourceCode;
private final Stack<Record> records;
private final boolean nearest;
private final IntSet accessedVertices;
private final EdgeRecord edgeResults;
private IntIterator parentRecordKeys;
public SingleWay... |
PathSet paths = new PathSet();
for (int i = 1; i < this.records.size(); i++) {
IntIterator iterator = this.records.get(i).keys();
while (iterator.hasNext()) {
paths.add(this.linkPath(i, iterator.next()));
}
}
return paths;
| 1,199 | 92 | 1,291 | <methods>public void <init>(org.apache.hugegraph.traversal.algorithm.records.record.RecordType, boolean) <variables>private final non-sealed boolean concurrent,private org.apache.hugegraph.traversal.algorithm.records.record.Record currentRecord,private final non-sealed ObjectIntMapping<org.apache.hugegraph.backend.id.I... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/records/record/Int2IntRecord.java | Int2IntRecord | get | class Int2IntRecord implements Record {
private final IntMap layer;
public Int2IntRecord() {
this.layer = CollectionFactory.newIntMap();
}
@Override
public IntIterator keys() {
return this.layer.keys();
}
@Override
public boolean containsKey(int node) {
return... |
int value = this.layer.get(node);
if (value == IntMap.NULL_VALUE) {
return IntIterator.EMPTY;
}
return IntIterator.wrap(value);
| 258 | 53 | 311 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/records/record/Int2SetRecord.java | Int2SetRecord | addPath | class Int2SetRecord implements Record {
private final IntObjectHashMap<IntHashSet> layer;
public Int2SetRecord() {
this.layer = new IntObjectHashMap<>();
}
@Override
public IntIterator keys() {
return IntIterator.wrap(this.layer.keySet().intIterator());
}
@Override
pu... |
IntHashSet values = this.layer.get(node);
if (values != null) {
values.add(parent);
} else {
// TODO: use one sorted-array instead to store all values
this.layer.put(node, IntHashSet.newSetWith(parent));
}
| 257 | 79 | 336 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/records/record/RecordFactory.java | RecordFactory | newRecord | class RecordFactory {
public static Record newRecord(RecordType type) {
return newRecord(type, false);
}
public static Record newRecord(RecordType type, boolean concurrent) {<FILL_FUNCTION_BODY>}
} |
Record record;
switch (type) {
case INT:
record = new Int2IntRecord();
break;
case SET:
record = new Int2SetRecord();
break;
case ARRAY:
record = new Int2ArrayRecord();
br... | 64 | 132 | 196 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/records/record/SyncRecord.java | SyncRecord | keys | class SyncRecord implements Record {
private final Object lock;
private final Record record;
public SyncRecord(Record record) {
this(record, null);
}
public SyncRecord(Record record, Object newLock) {
if (record == null) {
throw new IllegalArgumentException(
... |
/*
* Another threads call addPath() will change IntIterator inner array,
* but in kout/kneighbor scenario it's ok because keys() and addPath()
* won't be called simultaneously on same Record.
*/
synchronized (this.lock) {
return this.record.keys();
... | 347 | 83 | 430 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/steps/Steps.java | Steps | handleStepEntity | class Steps {
protected final Map<Id, StepEntity> edgeSteps;
protected final Map<Id, StepEntity> vertexSteps;
protected final Directions direction;
protected final long degree;
protected final long skipDegree;
public Steps(HugeGraph graph, Directions direction,
Map<String, Map... |
Map<Id, Object> properties = null;
if (entry.getValue() != null) {
properties = TraversalUtil.transProperties(graph, entry.getValue());
}
return new StepEntity(id, entry.getKey(), properties);
| 1,329 | 65 | 1,394 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/strategy/ConcurrentTraverseStrategy.java | ConcurrentTraverseStrategy | addNewVerticesToAll | class ConcurrentTraverseStrategy extends OltpTraverser
implements TraverseStrategy {
public ConcurrentTraverseStrategy(HugeGraph graph) {
super(graph);
}
@Override
public Map<Id, List<Node>> newMultiValueMap() {
return new OltpTraverser.ConcurrentMultiValuedMap<>();
}
... |
ConcurrentMultiValuedMap<Id, Node> vertices =
(ConcurrentMultiValuedMap<Id, Node>) targets;
for (Map.Entry<Id, List<Node>> entry : newVertices.entrySet()) {
vertices.addAll(entry.getKey(), entry.getValue());
}
| 313 | 78 | 391 | <methods>public void close() ,public static void destroy() <variables>private static final java.lang.String EXECUTOR_NAME,private static org.apache.hugegraph.util.Consumers.ExecutorPool executors |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/strategy/SingleTraverseStrategy.java | SingleTraverseStrategy | addNewVerticesToAll | class SingleTraverseStrategy extends OltpTraverser
implements TraverseStrategy {
public SingleTraverseStrategy(HugeGraph graph) {
super(graph);
}
@Override
public void traverseOneLayer(Map<Id, List<Node>> vertices,
EdgeStep step,
... |
MultivaluedMap<Id, Node> vertices =
(MultivaluedMap<Id, Node>) targets;
for (Map.Entry<Id, List<Node>> entry : newVertices.entrySet()) {
vertices.addAll(entry.getKey(), entry.getValue());
}
| 293 | 74 | 367 | <methods>public void close() ,public static void destroy() <variables>private static final java.lang.String EXECUTOR_NAME,private static org.apache.hugegraph.util.Consumers.ExecutorPool executors |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/ConditionP.java | ConditionP | eq | class ConditionP extends P<Object> {
private static final long serialVersionUID = 9094970577400072902L;
private ConditionP(final BiPredicate<Object, Object> predicate,
Object value) {
super(predicate, value);
}
public static ConditionP textContains(Object value) {
... |
// EQ that can compare two array
return new ConditionP(Condition.RelationType.EQ, value);
| 254 | 30 | 284 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeCountStep.java | HugeCountStep | processNextStart | class HugeCountStep<S extends Element>
extends AbstractStep<S, Long> {
private static final long serialVersionUID = -679873894532085972L;
private final HugeGraphStep<?, S> originGraphStep;
private boolean done = false;
public HugeCountStep(final Traversal.Admin<?, ?> traversal,
... |
if (this.done) {
throw FastNoSuchElementException.instance();
}
this.done = true;
@SuppressWarnings({"unchecked", "rawtypes"})
Step<Long, Long> step = (Step) this;
return this.getTraversal().getTraverserGenerator()
.generate(this.originGrap... | 340 | 102 | 442 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeCountStepStrategy.java | HugeCountStepStrategy | apply | class HugeCountStepStrategy
extends AbstractTraversalStrategy<ProviderOptimizationStrategy>
implements ProviderOptimizationStrategy {
private static final long serialVersionUID = -3910433925919057771L;
private static final HugeCountStepStrategy INSTANCE;
static {
INSTANCE = new Hu... |
TraversalUtil.convAllHasSteps(traversal);
// Extract CountGlobalStep
List<CountGlobalStep> steps = TraversalHelper.getStepsOfClass(
CountGlobalStep.class, traversal);
if (steps.isEmpty()) {
return;
}
// Find HugeGraphStep before count()
... | 289 | 487 | 776 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeGraphStep.java | HugeGraphStep | makeQuery | class HugeGraphStep<S, E extends Element>
extends GraphStep<S, E> implements QueryHolder {
private static final long serialVersionUID = -679873894532085972L;
private static final Logger LOG = Log.logger(HugeGraphStep.class);
private final List<HasContainer> hasContainers = new ArrayList<>();
... |
Query query;
if (this.hasContainers.isEmpty()) {
// Query all
query = new Query(type);
} else {
ConditionQuery q = new ConditionQuery(type);
query = TraversalUtil.fillConditionQuery(q, this.hasContainers, graph);
}
query = this.in... | 1,503 | 99 | 1,602 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeGraphStepStrategy.java | HugeGraphStepStrategy | apply | class HugeGraphStepStrategy
extends AbstractTraversalStrategy<ProviderOptimizationStrategy>
implements ProviderOptimizationStrategy {
private static final long serialVersionUID = -2952498905649139719L;
private static final HugeGraphStepStrategy INSTANCE;
static {
INSTANCE = new Hu... |
TraversalUtil.convAllHasSteps(traversal);
// Extract conditions in GraphStep
List<GraphStep> steps = TraversalHelper.getStepsOfClass(
GraphStep.class, traversal);
for (GraphStep originStep : steps) {
TraversalUtil.trySetGraph(originStep,
... | 244 | 241 | 485 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugePrimaryKeyStrategy.java | HugePrimaryKeyStrategy | apply | class HugePrimaryKeyStrategy
extends AbstractTraversalStrategy<TraversalStrategy.ProviderOptimizationStrategy>
implements ProviderOptimizationStrategy {
private static final long serialVersionUID = 6307847098226016416L;
private static final HugePrimaryKeyStrategy INSTANCE = new HugePrimaryKeySt... |
List<Step> removeSteps = new LinkedList<>();
Mutating curAddStep = null;
List<Step> stepList = traversal.getSteps();
for (int i = 0, s = stepList.size(); i < s; i++) {
Step step = stepList.get(i);
if (i == 0 && step instanceof AddVertexStartStep) {
... | 152 | 501 | 653 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeScriptTraversal.java | HugeScriptTraversal | applyStrategies | class HugeScriptTraversal<S, E> extends DefaultTraversal<S, E> {
private static final long serialVersionUID = 4617322697747299673L;
private final String script;
private final String language;
private final Map<String, Object> bindings;
private final Map<String, String> aliases;
private Object... |
ScriptEngine engine = SingleGremlinScriptEngineManager.get(this.language);
Bindings bindings = engine.createBindings();
bindings.putAll(this.bindings);
@SuppressWarnings("rawtypes")
TraversalStrategy[] strategies = this.getStrategies().toList()
... | 281 | 445 | 726 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeVertexStep.java | HugeVertexStep | flatMap | class HugeVertexStep<E extends Element>
extends VertexStep<E> implements QueryHolder {
private static final long serialVersionUID = -7850636388424382454L;
private static final Logger LOG = Log.logger(HugeVertexStep.class);
private final List<HasContainer> hasContainers = new ArrayList<>();
/... |
boolean queryVertex = this.returnsVertex();
boolean queryEdge = this.returnsEdge();
assert queryVertex || queryEdge;
if (queryVertex) {
this.iterator = (Iterator<E>) this.vertices(traverser);
} else {
assert queryEdge;
this.iterator = (Iterato... | 1,884 | 105 | 1,989 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeVertexStepByBatch.java | HugeVertexStepByBatch | lastTimeResults | class HugeVertexStepByBatch<E extends Element>
extends HugeVertexStep<E> {
private static final long serialVersionUID = -3609787815053052222L;
private BatchMapperIterator<Traverser.Admin<Vertex>, E> batchIterator;
private Traverser.Admin<Vertex> head;
private Iterator<E> iterator;
public ... |
/*
* NOTE: fetch page from this iterator, can only get page info of
* the lowest level, may lost info of upper levels.
*/
return this.iterator;
| 891 | 49 | 940 | <methods>public void <init>(VertexStep<E>) ,public void addHasContainer(HasContainer) ,public boolean equals(java.lang.Object) ,public List<HasContainer> getHasContainers() ,public int hashCode() ,public Iterator<?> lastTimeResults() ,public org.apache.hugegraph.backend.query.Query queryInfo() ,public java.lang.String ... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeVertexStepStrategy.java | HugeVertexStepStrategy | containsTree | class HugeVertexStepStrategy
extends AbstractTraversalStrategy<ProviderOptimizationStrategy>
implements ProviderOptimizationStrategy {
private static final long serialVersionUID = 491355700217483162L;
private static final HugeVertexStepStrategy INSTANCE;
static {
INSTANCE = new Hu... |
boolean hasTree = !TraversalHelper.getStepsOfClass(
TreeStep.class, traversal).isEmpty();
if (hasTree) {
return true;
} else if (traversal instanceof EmptyTraversal) {
return false;
}
TraversalParent parent = traversal.getParent();
... | 912 | 104 | 1,016 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/Blob.java | Blob | equals | class Blob implements Comparable<Blob> {
public static final Blob EMPTY = new Blob(new byte[0]);
private final byte[] bytes;
private Blob(byte[] bytes) {
E.checkNotNull(bytes, "bytes");
this.bytes = bytes;
}
public byte[] bytes() {
return this.bytes;
}
public sta... |
if (!(obj instanceof Blob)) {
return false;
}
Blob other = (Blob) obj;
return Arrays.equals(this.bytes, other.bytes);
| 304 | 50 | 354 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/CompressUtil.java | CompressUtil | decompressTar | class CompressUtil {
public static void compressTar(String inputDir, String outputFile,
Checksum checksum) throws IOException {
LZ4Factory factory = LZ4Factory.fastestInstance();
LZ4Compressor compressor = factory.fastCompressor();
int blockSize = RaftCont... |
Path source = Paths.get(sourceFile);
Path target = Paths.get(outputDir);
if (Files.notExists(source)) {
throw new IOException(String.format(
"The source file %s doesn't exists", source));
}
LZ4Factory factory = LZ4Factory.fastestInstance();
... | 1,595 | 389 | 1,984 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/ConfigUtil.java | ConfigUtil | buildConfig | class ConfigUtil {
private static final Logger LOG = Log.logger(ConfigUtil.class);
private static final String NODE_GRAPHS = "graphs";
private static final String CONF_SUFFIX = ".properties";
private static final String CHARSET = "UTF-8";
public static void checkGremlinConfig(String conf) {
... |
E.checkArgument(StringUtils.isNotEmpty(configText),
"The config text can't be null or empty");
PropertiesConfiguration propConfig = new PropertiesConfiguration();
try {
Reader in = new StringReader(configText);
propConfig.read(in);
} catch... | 1,018 | 104 | 1,122 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/CopyUtil.java | CopyUtil | cloneObject | class CopyUtil {
@SuppressWarnings("unchecked")
public static <T> T cloneObject(T o, T clone) throws Exception {<FILL_FUNCTION_BODY>}
private static Object cloneArray(Object value) {
Class<?> valueType = value.getClass();
assert valueType.isArray() &&
valueType.getComponentT... |
if (clone == null) {
clone = (T) o.getClass().newInstance();
}
for (Field field : o.getClass().getDeclaredFields()) {
field.setAccessible(true);
Object value = field.get(o);
if (value == null || Modifier.isFinal(field.getModifiers())) {
... | 320 | 271 | 591 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/FixedTimerWindowRateLimiter.java | FixedTimerWindowRateLimiter | tryAcquire | class FixedTimerWindowRateLimiter implements RateLimiter {
private final Timer timer;
private final LongAdder count;
private final int limit;
public FixedTimerWindowRateLimiter(int limitPerSecond) {
this.timer = new Timer("RateAuditLog", true);
this.count = new LongAdder();
thi... |
if (count.intValue() >= limit) {
return false;
}
count.increment();
return true;
| 214 | 37 | 251 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/FixedWatchWindowRateLimiter.java | FixedWatchWindowRateLimiter | tryAcquire | class FixedWatchWindowRateLimiter implements RateLimiter {
private final LongAdder count;
private final Stopwatch watch;
private final int limit;
public FixedWatchWindowRateLimiter(int limitPerSecond) {
this.limit = limitPerSecond;
this.watch = Stopwatch.createStarted();
this.c... |
if (count.intValue() < limit) {
count.increment();
return true;
}
// Reset only if 1000ms elapsed
if (watch.elapsed(TimeUnit.MILLISECONDS) >= RESET_PERIOD) {
count.reset();
watch.reset();
count.increment();
return ... | 123 | 106 | 229 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/GZipUtil.java | GZipUtil | decompress | class GZipUtil {
private static final int BUF_SIZE = (int) (4 * Bytes.KB);
public static String md5(String input) {
return DigestUtils.md5Hex(input);
}
public static BytesBuffer compress(byte[] data) {
int estimateSize = data.length >> 3;
BytesBuffer output = BytesBuffer.alloc... |
int estimateSize = data.length << 3;
BytesBuffer output = BytesBuffer.allocate(estimateSize);
Inflater inflater = new Inflater();
inflater.setInput(data);
byte[] buffer = new byte[BUF_SIZE];
while (!inflater.finished()) {
try {
int count = in... | 236 | 159 | 395 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/JsonUtil.java | JsonUtil | fromJson | class JsonUtil {
private static final ObjectMapper MAPPER = new ObjectMapper();
private static final ImmutableSet<String> SPECIAL_FLOATS;
static {
SimpleModule module = new SimpleModule();
SPECIAL_FLOATS = ImmutableSet.of("-Infinity", "Infinity", "NaN");
module.addSerializer(RawJs... |
E.checkState(json != null,
"Json value can't be null for '%s'",
typeRef.getType());
try {
ObjectReader reader = MAPPER.readerFor(typeRef);
return reader.readValue(json);
} catch (IOException e) {
throw new HugeExcepti... | 962 | 103 | 1,065 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/KryoUtil.java | KryoUtil | toKryoWithType | class KryoUtil {
private static final ThreadLocal<Kryo> KRYOS = new ThreadLocal<>();
public static Kryo kryo() {
Kryo kryo = KRYOS.get();
if (kryo != null) {
return kryo;
}
kryo = new Kryo();
registerSerializers(kryo);
KRYOS.set(kryo);
retur... |
try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
Output output = new Output(bos, 256)) {
kryo().writeClassAndObject(output, value);
output.flush();
return bos.toByteArray();
} catch (IOException e) {
throw new BackendException("F... | 589 | 96 | 685 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/LZ4Util.java | LZ4Util | decompress | class LZ4Util {
protected static final float DEFAULT_BUFFER_RATIO = 1.5f;
public static BytesBuffer compress(byte[] bytes, int blockSize) {
return compress(bytes, blockSize, DEFAULT_BUFFER_RATIO);
}
public static BytesBuffer compress(byte[] bytes, int blockSize, float bufferRatio) {
f... |
float ratio = bufferRatio <= 0.0F ? DEFAULT_BUFFER_RATIO : bufferRatio;
LZ4Factory factory = LZ4Factory.fastestInstance();
LZ4FastDecompressor decompressor = factory.fastDecompressor();
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
int initBufferSize = Math.min(Ma... | 376 | 279 | 655 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/ParameterUtil.java | ParameterUtil | parameterString | class ParameterUtil {
public static Object parameter(Map<String, Object> parameters, String key) {
Object value = parameters.get(key);
E.checkArgument(value != null,
"Expect '%s' in parameters: %s",
key, parameters);
return value;
}
p... |
Object value = parameter(parameters, key);
E.checkArgument(value instanceof String,
"Expect string value for parameter '%s': '%s'",
key, value);
return (String) value;
| 436 | 55 | 491 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/Reflection.java | Reflection | loadClass | class Reflection {
private static final Logger LOG = Log.logger(Reflection.class);
private static final Class<?> REFLECTION_CLAZZ;
private static final Method REGISTER_FILEDS_TO_FILTER_METHOD;
private static final Method REGISTER_METHODS_TO_FILTER_METHOD;
public static final String JDK_INTERNAL_R... |
try {
return Class.forName(clazz);
} catch (ClassNotFoundException e) {
throw new HugeException(e.getMessage(), e);
}
| 929 | 46 | 975 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/StringEncoding.java | StringEncoding | writeAsciiString | class StringEncoding {
private static final MessageDigest DIGEST;
private static final byte[] BYTES_EMPTY = new byte[0];
private static final String STRING_EMPTY = "";
private static final int BLOCK_SIZE = 4096;
static {
final String ALG = "SHA-256";
try {
DIGEST = Mess... |
E.checkArgument(CharMatcher.ascii().matchesAllOf(value),
"'%s' must be ASCII string", value);
int len = value.length();
if (len == 0) {
array[offset++] = (byte) 0x80;
return offset;
}
int i = 0;
do {
int c = va... | 1,259 | 178 | 1,437 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/CollectionFactory.java | CollectionFactory | newMap | class CollectionFactory {
private final CollectionType type;
public CollectionFactory() {
this.type = CollectionType.EC;
}
public CollectionFactory(CollectionType type) {
this.type = type;
}
public <V> List<V> newList() {
return newList(this.type);
}
public <... |
switch (type) {
case EC:
return new UnifiedMap<>(map);
case JCF:
return new HashMap<>(map);
case FU:
return new Object2ObjectOpenHashMap<>(map);
default:
throw new AssertionError(
... | 1,894 | 89 | 1,983 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/IdSet.java | IdSet | remove | class IdSet extends AbstractSet<Id> {
private final LongHashSet numberIds;
private final Set<Id> nonNumberIds;
public IdSet(CollectionType type) {
this.numberIds = new LongHashSet();
this.nonNumberIds = CollectionFactory.newSet(type);
}
@Override
public int size() {
re... |
if (id.type() == Id.IdType.LONG) {
return this.numberIds.remove(id.asLong());
} else {
return this.nonNumberIds.remove(id);
}
| 573 | 57 | 630 | <methods>public boolean equals(java.lang.Object) ,public int hashCode() ,public boolean removeAll(Collection<?>) <variables> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/Int2IntsMap.java | Int2IntsMap | add | class Int2IntsMap {
private static final int INIT_KEY_CAPACITY = 16;
private static final int CHUNK_SIZE = 10;
private static final int EXPANSION_FACTOR = 2;
private static final int OFFSET_NEXT_FREE = 0;
private static final int OFFSET_SIZE = 1;
private static final int OFFSET_FIRST_CHUNK_DAT... |
if (this.chunkMap.containsKey(key)) {
int firstChunk = this.chunkMap.get(key);
/*
* The nextFree represent the position where the next element
* will be located.
*/
int nextFree = this.chunkTable[firstChunk + OFFSET_NEXT_FREE];
... | 1,491 | 517 | 2,008 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/collection/ObjectIntMappingFactory.java | SingleThreadObjectIntMapping | object2Code | class SingleThreadObjectIntMapping<V>
implements ObjectIntMapping<V> {
private static final int MAGIC = 1 << 16;
private static final int MAX_OFFSET = 10;
private final IntObjectHashMap<V> int2IdMap;
public SingleThreadObjectIntMapping() {
this.int2IdMap = new ... |
int code = object.hashCode();
// TODO: improve hash algorithm
for (int i = 1; i > 0; i <<= 1) {
for (int j = 0; j < MAX_OFFSET; j++) {
if (code <= 0) {
if (code == 0) {
code = 1;
... | 248 | 300 | 548 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/version/CoreVersion.java | CoreVersion | check | class CoreVersion {
public static final String NAME = "hugegraph-core";
public static final String DEFAULT_VERSION = "1.3.0";
/**
* The second parameter of Version.of() is for IDE running without JAR
*/
public static final Version VERSION = Version.of(CoreVersion.class, DEFAULT_VERSION);
... |
// Check the version of hugegraph-common
VersionUtil.check(CommonVersion.VERSION, "1.0", "1.55", CommonVersion.NAME);
| 182 | 42 | 224 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-dist/src/main/java/org/apache/hugegraph/cmd/ConfDumper.java | ConfDumper | writeOption | class ConfDumper {
public static final String EOL = System.getProperty("line.separator");
private static final Logger LOG = Log.logger(ConfDumper.class);
public static void main(String[] args)
throws ConfigurationException, IOException {
E.checkArgument(args.length == 1,
... |
StringBuilder sb = new StringBuilder();
sb.append("# ").append(option.desc()).append(EOL);
sb.append(option.name()).append("=").append(value).append(EOL);
sb.append(EOL);
// Write to output file
FileUtils.write(output, sb.toString(), true);
| 277 | 86 | 363 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-dist/src/main/java/org/apache/hugegraph/cmd/InitStore.java | InitStore | initGraph | class InitStore {
private static final Logger LOG = Log.logger(InitStore.class);
// 6~8 retries may be needed under high load for Cassandra backend
private static final int RETRIES = 10;
// Less than 5000 may cause mismatch exception with Cassandra backend
private static final long RETRY_INTERVAL ... |
LOG.info("Init graph with config file: {}", configPath);
HugeConfig config = new HugeConfig(configPath);
// Forced set RAFT_MODE to false when initializing backend
config.setProperty(CoreOptions.RAFT_MODE.name(), "false");
HugeGraph graph = (HugeGraph) GraphFactory.open(config);... | 820 | 251 | 1,071 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-dist/src/main/java/org/apache/hugegraph/cmd/StoreDumper.java | StoreDumper | dump | class StoreDumper {
private final HugeGraph graph;
private static final Logger LOG = Log.logger(StoreDumper.class);
public StoreDumper(String conf) {
this.graph = HugeFactory.open(conf);
}
public void dump(HugeType table, long offset, long limit) {<FILL_FUNCTION_BODY>}
private Backe... |
BackendStore store = this.backendStore(table);
Query query = new Query(table);
Iterator<BackendEntry> rs = store.query(query);
for (long i = 0; i < offset && rs.hasNext(); i++) {
rs.next();
}
LOG.info("Dump table {} (offset {} limit {}):", table, offset, li... | 436 | 166 | 602 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-dist/src/main/java/org/apache/hugegraph/dist/DistOptions.java | DistOptions | instance | class DistOptions extends OptionHolder {
private DistOptions() {
super();
}
private static volatile DistOptions instance;
public static synchronized DistOptions instance() {<FILL_FUNCTION_BODY>}
public static final ConfigListOption<String> BACKENDS =
new ConfigListOption<>(
... |
if (instance == null) {
instance = new DistOptions();
instance.registerOptions();
}
return instance;
| 113 | 35 | 148 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-dist/src/main/java/org/apache/hugegraph/dist/HugeGraphServer.java | HugeGraphServer | main | class HugeGraphServer {
private static final Logger LOG = Log.logger(HugeGraphServer.class);
private final RestServer restServer;
private final GremlinServer gremlinServer;
public static void register() {
RegisterUtil.registerBackends();
RegisterUtil.registerPlugins();
Registe... |
if (args.length != 2) {
String msg = "Start HugeGraphServer need to pass 2 parameters, " +
"they are the config files of GremlinServer and " +
"RestServer, for example: conf/gremlin-server.yaml " +
"conf/rest-server.properti... | 666 | 392 | 1,058 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-dist/src/main/java/org/apache/hugegraph/dist/HugeGremlinServer.java | HugeGremlinServer | start | class HugeGremlinServer {
private static final Logger LOG = Log.logger(HugeGremlinServer.class);
public static GremlinServer start(String conf, String graphsDir,
EventHub hub) throws Exception {<FILL_FUNCTION_BODY>}
} |
// Start GremlinServer with inject traversal source
LOG.info(GremlinServer.getHeader());
final Settings settings;
try {
settings = Settings.read(conf);
} catch (Exception e) {
LOG.error("Can't found the configuration file at '{}' or " +
... | 75 | 319 | 394 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-dist/src/main/java/org/apache/hugegraph/dist/RegisterUtil.java | RegisterUtil | registerMysql | class RegisterUtil {
private static final Logger LOG = Log.logger(RegisterUtil.class);
static {
OptionSpace.register("core", CoreOptions.instance());
OptionSpace.register("dist", DistOptions.instance());
OptionSpace.register("masterElection", RoleElectionOptions.instance());
}
... |
// Register config
OptionSpace.register("mysql",
"org.apache.hugegraph.backend.store.mysql.MysqlOptions");
// Register serializer
SerializerFactory.register("mysql",
"org.apache.hugegraph.backend.store.mysql.MysqlSerializer... | 1,758 | 123 | 1,881 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-example/src/main/java/org/apache/hugegraph/example/Example3.java | Example3 | loadNeighborRankData | class Example3 {
private static final Logger LOG = Log.logger(Example3.class);
public static void main(String[] args) throws Exception {
LOG.info("Example3 start!");
HugeGraph graph = ExampleUtil.loadGraph();
Example3.loadNeighborRankData(graph);
Example3.loadPersonalRankData... |
SchemaManager schema = graph.schema();
schema.propertyKey("name").asText().ifNotExist().create();
schema.vertexLabel("person")
.properties("name")
.useCustomizeStringId()
.ifNotExist()
.create();
schema.vertexLabel("movie")
... | 669 | 875 | 1,544 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-example/src/main/java/org/apache/hugegraph/example/ExampleUtil.java | ExampleUtil | waitAllTaskDone | class ExampleUtil {
private static final Logger LOG = Log.logger(ExampleUtil.class);
private static boolean registered = false;
public static void registerPlugins() {
if (registered) {
return;
}
registered = true;
RegisterUtil.registerCassandra();
Regi... |
TaskScheduler scheduler = graph.taskScheduler();
Iterator<HugeTask<Object>> tasks = scheduler.tasks(null, -1L, null);
while (tasks.hasNext()) {
try {
scheduler.waitUntilTaskCompleted(tasks.next().id(), 20L);
} catch (TimeoutException e) {
... | 458 | 114 | 572 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-example/src/main/java/org/apache/hugegraph/example/PerfExample1.java | PerfExample1 | testInsert | class PerfExample1 extends PerfExampleBase {
public static void main(String[] args) throws Exception {
PerfExample1 tester = new PerfExample1();
tester.test(args);
// Stop daemon thread
HugeFactory.shutdown(30L);
}
@Override
protected void initSchema(SchemaManager sche... |
List<Object> personIds = new ArrayList<>(PERSON_NUM * multiple);
List<Object> softwareIds = new ArrayList<>(SOFTWARE_NUM * multiple);
for (int time = 0; time < times; time++) {
LOG.debug("============== random person vertex ===============");
for (int i = 0; i < PERSON_... | 417 | 668 | 1,085 | <methods>public non-sealed void <init>() ,public int test(java.lang.String[]) throws java.lang.Exception,public void testInsertPerf(org.apache.hugegraph.example.PerfExampleBase.GraphManager, int, int, int) throws java.lang.Exception,public void testQueryEdgePerf(org.apache.hugegraph.example.PerfExampleBase.GraphManager... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-example/src/main/java/org/apache/hugegraph/example/PerfExample2.java | PerfExample2 | testInsert | class PerfExample2 extends PerfExampleBase {
public static void main(String[] args) throws Exception {
PerfExample2 tester = new PerfExample2();
tester.test(args);
// Stop daemon thread
HugeFactory.shutdown(30L);
}
@Override
protected void initSchema(SchemaManager sche... |
List<Object> personIds = new ArrayList<>(PERSON_NUM * multiple);
List<Object> softwareIds = new ArrayList<>(SOFTWARE_NUM * multiple);
for (int time = 0; time < times; time++) {
LOG.debug("============== random person vertex ===============");
for (int i = 0; i < PERSON_... | 292 | 560 | 852 | <methods>public non-sealed void <init>() ,public int test(java.lang.String[]) throws java.lang.Exception,public void testInsertPerf(org.apache.hugegraph.example.PerfExampleBase.GraphManager, int, int, int) throws java.lang.Exception,public void testQueryEdgePerf(org.apache.hugegraph.example.PerfExampleBase.GraphManager... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-example/src/main/java/org/apache/hugegraph/example/PerfExample3.java | PerfExample3 | testInsert | class PerfExample3 extends PerfExampleBase {
private static final Logger LOG = Log.logger(PerfExample3.class);
public static void main(String[] args) throws Exception {
PerfExample3 tester = new PerfExample3();
tester.test(args);
// Stop daemon thread
HugeFactory.shutdown(30L)... |
final int TIMES = times * multiple;
final int BATCH = 100;
long total = 0;
// Insert in order
for (int i = 0; i < TIMES; i++) {
for (int j = 0; j < BATCH; j++) {
String name = String.format("p-%08d", total++);
Vertex v = graph.addVerte... | 613 | 164 | 777 | <methods>public non-sealed void <init>() ,public int test(java.lang.String[]) throws java.lang.Exception,public void testInsertPerf(org.apache.hugegraph.example.PerfExampleBase.GraphManager, int, int, int) throws java.lang.Exception,public void testQueryEdgePerf(org.apache.hugegraph.example.PerfExampleBase.GraphManager... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-example/src/main/java/org/apache/hugegraph/example/PerfExample4.java | PerfExample4 | testQueryVertex | class PerfExample4 extends PerfExample3 {
private static final Logger LOG = Log.logger(PerfExample3.class);
/**
* Main method
*
* @param args 3 arguments, 1st should be 1, meaning single thread,
* product of 2nd and 3rd is total number of "person" vertices
* @throws Interr... |
int total = threads * multiple * 100;
for (int i = 1; i <= total; i *= 10) {
LOG.info(">>>> limit {} <<<<", i);
long current = System.currentTimeMillis();
List<Vertex> persons = graph.traversal().V()
.hasLabel("person")
... | 243 | 299 | 542 | <methods>public non-sealed void <init>() ,public static void main(java.lang.String[]) throws java.lang.Exception<variables>private static final Logger LOG |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-example/src/main/java/org/apache/hugegraph/example/TaskExample.java | TaskExample | testTask | class TaskExample {
private static final Logger LOG = Log.logger(TaskExample.class);
public static void main(String[] args) throws Exception {
LOG.info("TaskExample start!");
HugeGraph graph = ExampleUtil.loadGraph();
testTask(graph);
graph.close();
// Stop daemon thr... |
Id id = IdGenerator.of(8);
String callable = "org.apache.hugegraph.example.TaskExample$TestTask";
HugeTask<?> task = new HugeTask<>(id, null, callable, "test-parameter");
task.type("type-1");
task.name("test-task");
TaskScheduler scheduler = graph.taskScheduler();
... | 302 | 447 | 749 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-example/src/main/java/org/apache/hugegraph/example/ThreadRangePerfTest.java | ThreadRangePerfTest | main | class ThreadRangePerfTest {
private static final Logger LOG = Log.logger(ThreadRangePerfTest.class);
public static void main(String[] args) throws Exception {<FILL_FUNCTION_BODY>}
} |
if (args.length != 6) {
LOG.info("Usage: minThread maxThread threadStep " +
"times multiple profile");
return;
}
int minThread = Integer.parseInt(args[0]);
int maxThread = Integer.parseInt(args[1]);
int threadStep = Integer.parseInt(... | 59 | 313 | 372 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-hbase/src/main/java/org/apache/hugegraph/backend/store/hbase/HbaseFeatures.java | HbaseFeatures | supportsTransaction | class HbaseFeatures implements BackendFeatures {
private boolean enablePartition;
public HbaseFeatures(boolean enablePartition) {
this.enablePartition = enablePartition;
}
@Override
public boolean supportsScanToken() {
return false;
}
@Override
public boolean supports... |
// TODO: Supports tx through BufferedMutator and range-lock
return false;
| 640 | 25 | 665 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-hbase/src/main/java/org/apache/hugegraph/backend/store/hbase/HbaseMetrics.java | HbaseMetrics | formatMetrics | class HbaseMetrics implements BackendMetrics {
private final HbaseSessions hbase;
public HbaseMetrics(HbaseSessions hbase) {
E.checkArgumentNotNull(hbase, "HBase connection is not opened");
this.hbase = hbase;
}
@Override
public Map<String, Object> metrics() {
Map<String, ... |
Map<String, Object> metrics = InsertionOrderUtil.newMap();
Size memMax = serverMetrics.getMaxHeapSize();
Size memUsed = serverMetrics.getUsedHeapSize();
long memUsedBytes = (long) memUsed.get(Size.Unit.BYTE);
metrics.put(MEM_MAX, memMax.get(Size.Unit.MEGABYTE));
metrics... | 1,461 | 408 | 1,869 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-hbase/src/main/java/org/apache/hugegraph/backend/store/hbase/HbaseOptions.java | HbaseOptions | instance | class HbaseOptions extends OptionHolder {
private HbaseOptions() {
super();
}
private static volatile HbaseOptions instance;
public static synchronized HbaseOptions instance() {<FILL_FUNCTION_BODY>}
public static final ConfigOption<String> HBASE_HOSTS =
new ConfigOption<>(
... |
if (instance == null) {
instance = new HbaseOptions();
instance.registerOptions();
}
return instance;
| 1,103 | 36 | 1,139 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-hbase/src/main/java/org/apache/hugegraph/backend/store/hbase/HbaseSerializer.java | HbaseSerializer | getPartition | class HbaseSerializer extends BinarySerializer {
private static final Logger LOG = Log.logger(HbaseSerializer.class);
private final short vertexLogicPartitions;
private final short edgeLogicPartitions;
public HbaseSerializer(HugeConfig config) {
super(false, true, config.get(HbaseOptions.HBASE... |
int hashcode = Arrays.hashCode(id.asBytes());
short partition = 1;
if (type.isEdge()) {
partition = (short) (hashcode % this.edgeLogicPartitions);
} else if (type.isVertex()) {
partition = (short) (hashcode % this.vertexLogicPartitions);
}
return ... | 209 | 105 | 314 | <methods>public void <init>() ,public void <init>(HugeConfig) ,public void <init>(boolean, boolean, boolean) ,public static void increaseOne(byte[]) ,public org.apache.hugegraph.backend.store.BackendEntry parse(org.apache.hugegraph.backend.store.BackendEntry) ,public org.apache.hugegraph.structure.HugeEdge readEdge(org... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-hbase/src/main/java/org/apache/hugegraph/backend/store/hbase/HbaseStoreProvider.java | HbaseStoreProvider | driverVersion | class HbaseStoreProvider extends AbstractBackendStoreProvider {
protected String namespace() {
return this.graph().toLowerCase();
}
@Override
protected BackendStore newSchemaStore(HugeConfig config, String store) {
return new HbaseStore.HbaseSchemaStore(config, this, this.namespace(), ... |
/*
* 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] #287: support pagination when doing index query
* [1.4] #270 ... | 234 | 320 | 554 | <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-hbase/src/main/java/org/apache/hugegraph/backend/store/hbase/HbaseTables.java | Edge | parseRowColumns | class Edge extends HbaseTable {
public static final String TABLE_SUFFIX = HugeType.EDGE.string();
public Edge(String store, boolean out, boolean enablePartition) {
super(joinTableName(store, table(out)), enablePartition);
}
private static String table(boolean out) {
... |
/*
* Collapse owner-vertex id from edge id, NOTE: unneeded to
* collapse if BinarySerializer.keyWithIdPrefix set to true
*/
byte[] key = row.getRow();
if (enablePartition) {
key = Arrays.copyOfRange(key, entry.id().length() + 2,... | 333 | 217 | 550 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-mysql/src/main/java/org/apache/hugegraph/backend/store/mysql/MysqlEntryIterator.java | MysqlEntryIterator | fetch | class MysqlEntryIterator extends BackendEntryIterator {
private final ResultSetWrapper results;
private final BiFunction<BackendEntry, BackendEntry, BackendEntry> merger;
private BackendEntry next;
private BackendEntry lastest;
private boolean exceedLimit;
public MysqlEntryIterator(ResultSetW... |
assert this.current == null;
if (this.next != null) {
this.current = this.next;
this.next = null;
}
try {
while (this.results.next()) {
MysqlBackendEntry entry = this.row2Entry(this.results.resultSet());
this.lastest =... | 1,131 | 327 | 1,458 | <methods>public void <init>(org.apache.hugegraph.backend.query.Query) ,public static final void checkInterrupted() ,public boolean hasNext() ,public transient java.lang.Object metadata(java.lang.String, java.lang.Object[]) ,public org.apache.hugegraph.backend.store.BackendEntry next() <variables>public static final lon... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-mysql/src/main/java/org/apache/hugegraph/backend/store/mysql/MysqlOptions.java | MysqlOptions | instance | class MysqlOptions extends OptionHolder {
protected MysqlOptions() {
super();
}
private static volatile MysqlOptions instance;
public static synchronized MysqlOptions instance() {<FILL_FUNCTION_BODY>}
public static final ConfigOption<String> JDBC_DRIVER =
new ConfigOption<>(
... |
if (instance == null) {
instance = new MysqlOptions();
instance.registerOptions();
}
return instance;
| 734 | 37 | 771 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-mysql/src/main/java/org/apache/hugegraph/backend/store/mysql/MysqlSerializer.java | MysqlSerializer | parseProperties | class MysqlSerializer extends TableSerializer {
public MysqlSerializer(HugeConfig config) {
super(config);
}
@Override
public MysqlBackendEntry newBackendEntry(HugeType type, Id id) {
return new MysqlBackendEntry(type, id);
}
@Override
protected TableBackendEntry newBacken... |
String properties = row.column(HugeKeys.PROPERTIES);
// Query edge will wrapped by a vertex, whose properties is empty
if (properties.isEmpty()) {
return;
}
@SuppressWarnings("unchecked")
Map<String, Object> props = JsonUtil.fromJson(properties, Map.class);
... | 1,062 | 191 | 1,253 | <methods>public void <init>(HugeConfig) ,public org.apache.hugegraph.backend.serializer.TableBackendEntry newBackendEntry(org.apache.hugegraph.type.HugeType, org.apache.hugegraph.backend.id.Id) ,public org.apache.hugegraph.structure.HugeEdge readEdge(org.apache.hugegraph.HugeGraph, org.apache.hugegraph.backend.store.Ba... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-mysql/src/main/java/org/apache/hugegraph/backend/store/mysql/MysqlStoreProvider.java | MysqlStoreProvider | driverVersion | class MysqlStoreProvider extends AbstractBackendStoreProvider {
protected String database() {
return this.graph().toLowerCase();
}
@Override
protected BackendStore newSchemaStore(HugeConfig config, String store) {
return new MysqlSchemaStore(this, this.database(), store);
}
@O... |
/*
* 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,
... | 219 | 336 | 555 | <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-mysql/src/main/java/org/apache/hugegraph/backend/store/mysql/MysqlTables.java | Edge | delete | class Edge extends MysqlTableTemplate {
public static final String TABLE_SUFFIX = HugeType.EDGE.string();
private final Directions direction;
private final String delByLabelTemplate;
public Edge(String store, Directions direction) {
this(store, direction, TYPES_MAPPING);
... |
// Let super class do delete if not deleting edge by label
List<Object> idParts = this.idColumnValue(entry.id());
if (idParts.size() > 1 || !entry.columns().isEmpty()) {
super.delete(session, entry);
return;
}
// The only elem... | 1,452 | 100 | 1,552 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-mysql/src/main/java/org/apache/hugegraph/backend/store/mysql/MysqlUtil.java | MysqlUtil | escapeString | class MysqlUtil {
public static String escapeAndWrapString(String value) {
return escapeString(value, true);
}
public static String escapeString(String value) {
return escapeString(value, false);
}
private static String escapeString(String value, boolean wrap) {<FILL_FUNCTION_BODY... |
int length = value.length();
if (!isEscapeNeededForString(value, length)) {
if (!wrap) {
return value;
}
StringBuilder buf = new StringBuilder(length + 2);
buf.append('\'').append(value).append('\'');
return buf.toString();
... | 317 | 431 | 748 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-mysql/src/main/java/org/apache/hugegraph/backend/store/mysql/ResultSetWrapper.java | ResultSetWrapper | close | class ResultSetWrapper implements AutoCloseable {
private final ResultSet resultSet;
private final Statement statement;
public ResultSetWrapper(ResultSet resultSet, Statement statement) {
this.resultSet = resultSet;
this.statement = statement;
}
public boolean next() throws SQLExc... |
try {
if (this.resultSet != null) {
this.resultSet.close();
}
} catch (SQLException e) {
throw new BackendException("Failed to close ResultSet", e);
} finally {
try {
if (this.statement != null) {
... | 147 | 122 | 269 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-palo/src/main/java/org/apache/hugegraph/backend/store/palo/PaloFeatures.java | PaloFeatures | supportsQueryByLabel | class PaloFeatures implements BackendFeatures {
@Override
public boolean supportsScanToken() {
return false;
}
@Override
public boolean supportsScanKeyPrefix() {
return false;
}
@Override
public boolean supportsScanKeyRange() {
return false;
}
@Overrid... |
/*
* Create a rollup table on vertices/edges can speed up query by label,
* but it will store data in vertices/edges again.
* See: https://github.com/baidu/palo/wiki/Data-Model%2C-Rollup-%26
* -Prefix-Index
*/
return false;
| 503 | 90 | 593 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-palo/src/main/java/org/apache/hugegraph/backend/store/palo/PaloFile.java | PaloFile | scan | class PaloFile extends File {
private static final long serialVersionUID = -1918775445693598353L;
public PaloFile(String dir, String subDir, String fileName) {
this(Paths.get(dir, subDir, fileName).toString());
}
public PaloFile(String path, int id, int part) {
this(Paths.get(path, fo... |
File directory = FileUtils.getFile(path);
if (!directory.exists()) {
return ImmutableList.of();
}
File[] subDirs = directory.listFiles((dir, name) -> {
return tableDirs.contains(name);
});
if (subDirs == null || subDirs.length == 0) {
... | 1,170 | 290 | 1,460 | <methods>public void <init>(java.lang.String) ,public void <init>(java.net.URI) ,public void <init>(java.lang.String, java.lang.String) ,public void <init>(java.io.File, java.lang.String) ,public boolean canExecute() ,public boolean canRead() ,public boolean canWrite() ,public int compareTo(java.io.File) ,public boolea... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-palo/src/main/java/org/apache/hugegraph/backend/store/palo/PaloHttpClient.java | PaloHttpClient | buildUrl | class PaloHttpClient {
private final RestClient client;
public PaloHttpClient(HugeConfig config, String database) {
String url = this.buildUrl(config, database);
String username = config.get(PaloOptions.PALO_USERNAME);
String password = config.get(PaloOptions.PALO_PASSWORD);
In... |
String host = config.get(PaloOptions.PALO_HOST);
Integer port = config.get(PaloOptions.PALO_HTTP_PORT);
return String.format("http://%s:%s/api/%s/", host, port, database);
| 374 | 71 | 445 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-palo/src/main/java/org/apache/hugegraph/backend/store/palo/PaloOptions.java | PaloOptions | instance | class PaloOptions extends OptionHolder {
private PaloOptions() {
super();
}
private static volatile PaloOptions instance;
public static synchronized PaloOptions instance() {<FILL_FUNCTION_BODY>}
public static final ConfigOption<String> PALO_HOST =
new ConfigOption<>(
... |
if (instance == null) {
instance = new PaloOptions();
instance.registerOptions();
}
return instance;
| 596 | 36 | 632 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-palo/src/main/java/org/apache/hugegraph/backend/store/palo/PaloSerializer.java | PaloSerializer | writeEnableLabelIndex | class PaloSerializer extends MysqlSerializer {
public PaloSerializer(HugeConfig config) {
super(config);
}
@Override
protected void writeEnableLabelIndex(SchemaLabel schema,
TableBackendEntry entry) {<FILL_FUNCTION_BODY>}
@Override
protected vo... |
Byte enable = (byte) (schema.enableLabelIndex() ? 1 : 0);
entry.column(HugeKeys.ENABLE_LABEL_INDEX, enable);
| 143 | 45 | 188 | <methods>public void <init>(HugeConfig) ,public org.apache.hugegraph.backend.store.mysql.MysqlBackendEntry newBackendEntry(org.apache.hugegraph.type.HugeType, org.apache.hugegraph.backend.id.Id) ,public org.apache.hugegraph.backend.store.BackendEntry writeOlapVertex(org.apache.hugegraph.structure.HugeVertex) <variables... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-palo/src/main/java/org/apache/hugegraph/backend/store/palo/PaloSessions.java | PaloLoadTask | run | class PaloLoadTask extends TimerTask {
private static final String DF = "yyyy-MM-dd-HH-mm-ss";
private final SafeDateFormat dateFormat = new SafeDateFormat(DF);
/**
* There exist two running palo load task corresponds to two stores,
* `SchemaStore -> SchemaLoadTask` and `Grap... |
LOG.debug("The Load task:{} ready to run", PaloSessions.this);
// Scan the directory to get all file size
String path = config().get(PaloOptions.PALO_TEMP_DIR);
List<PaloFile> paloFiles = PaloFile.scan(path, this.tableDirs);
// Do nothing if there is no file ... | 877 | 183 | 1,060 | <methods>public void <init>(HugeConfig, java.lang.String, java.lang.String) ,public HugeConfig config() ,public void createDatabase() ,public java.lang.String database() ,public void dropDatabase() ,public java.lang.String escapedDatabase() ,public boolean existsDatabase() ,public boolean existsTable(java.lang.String) ... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-palo/src/main/java/org/apache/hugegraph/backend/store/palo/PaloStore.java | PaloStore | openSessionPool | class PaloStore extends MysqlStore {
private static final Logger LOG = Log.logger(PaloStore.class);
public PaloStore(BackendStoreProvider provider,
String database, String name) {
super(provider, database, name);
}
@Override
protected PaloSessions openSessionPool(Huge... |
LOG.info("Open palo session pool for {}", this);
return new PaloSessions(config, this.database(), this.store(),
this.tableNames());
| 146 | 45 | 191 | <methods>public void <init>(org.apache.hugegraph.backend.store.BackendStoreProvider, java.lang.String, java.lang.String) ,public void beginTx() ,public void clear(boolean) ,public void close() ,public void commitTx() ,public java.lang.String database() ,public org.apache.hugegraph.backend.store.BackendFeatures features... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-palo/src/main/java/org/apache/hugegraph/backend/store/palo/PaloStoreProvider.java | PaloStoreProvider | driverVersion | class PaloStoreProvider extends MysqlStoreProvider {
private static final BackendFeatures FEATURES = new PaloFeatures();
@Override
protected BackendStore newSchemaStore(HugeConfig config, String store) {
return new PaloSchemaStore(this, this.database(), store);
}
@Override
protected B... |
/*
* 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,
... | 1,073 | 319 | 1,392 | <methods>public non-sealed void <init>() ,public java.lang.String driverVersion() ,public java.lang.String type() <variables> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-palo/src/main/java/org/apache/hugegraph/backend/store/palo/PaloTable.java | PaloTable | insert | class PaloTable extends MysqlTable {
private static final Logger LOG = Log.logger(PaloTable.class);
public PaloTable(String table) {
super(table);
}
@Override
public void createTable(MysqlSessions.Session session,
TableDefine tableDefine) {
StringBuilde... |
assert session instanceof PaloSessions.Session;
PaloSessions.Session paloSession = (PaloSessions.Session) session;
Set<HugeKeys> columnNames = this.tableDefine().columnNames();
// Ensure column order match with table define
List<Object> columnValues = new ArrayList<>(columnName... | 584 | 146 | 730 | <methods>public void <init>(java.lang.String) ,public void append(org.apache.hugegraph.backend.store.mysql.MysqlSessions.Session, org.apache.hugegraph.backend.serializer.TableBackendEntry.Row) ,public void clear(org.apache.hugegraph.backend.store.mysql.MysqlSessions.Session) ,public void delete(org.apache.hugegraph.bac... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-palo/src/main/java/org/apache/hugegraph/backend/store/palo/PaloTables.java | Index | mergeEntries | class Index extends PaloTableTemplate {
public Index(String table) {
super(table);
}
@Override
protected BackendEntry mergeEntries(BackendEntry e1, BackendEntry e2) {<FILL_FUNCTION_BODY>}
protected abstract String entryId(MysqlBackendEntry entry);
} |
MysqlBackendEntry current = (MysqlBackendEntry) e1;
MysqlBackendEntry next = (MysqlBackendEntry) e2;
E.checkState(current == null || current.type().isIndex(),
"The current entry must be null or INDEX");
E.checkState(next != null && next.type().i... | 88 | 212 | 300 | <no_super_class> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-postgresql/src/main/java/org/apache/hugegraph/backend/store/postgresql/PostgresqlOptions.java | PostgresqlOptions | instance | class PostgresqlOptions extends MysqlOptions {
private PostgresqlOptions() {
super();
}
private static volatile PostgresqlOptions instance;
public static synchronized PostgresqlOptions instance() {<FILL_FUNCTION_BODY>}
public static final ConfigOption<String> POSTGRESQL_CONNECT_DATABASE ... |
if (instance == null) {
instance = new PostgresqlOptions();
instance.registerOptions();
}
return instance;
| 153 | 37 | 190 | <methods>public static synchronized org.apache.hugegraph.backend.store.mysql.MysqlOptions instance() <variables>public static final ConfigOption<java.lang.String> JDBC_DRIVER,public static final ConfigOption<java.lang.Boolean> JDBC_FORCED_AUTO_RECONNECT,public static final ConfigOption<java.lang.String> JDBC_PASSWORD,p... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-postgresql/src/main/java/org/apache/hugegraph/backend/store/postgresql/PostgresqlSerializer.java | PostgresqlSerializer | writeIndex | class PostgresqlSerializer extends MysqlSerializer {
public PostgresqlSerializer(HugeConfig config) {
super(config);
}
@Override
public BackendEntry writeIndex(HugeIndex index) {<FILL_FUNCTION_BODY>}
} |
TableBackendEntry entry = newBackendEntry(index);
/*
* When field-values is null and elementIds size is 0, it is
* meaningful for deletion of index data in secondary/range index.
*/
if (index.fieldValues() == null && index.elementIds().isEmpty()) {
entry.c... | 70 | 265 | 335 | <methods>public void <init>(HugeConfig) ,public org.apache.hugegraph.backend.store.mysql.MysqlBackendEntry newBackendEntry(org.apache.hugegraph.type.HugeType, org.apache.hugegraph.backend.id.Id) ,public org.apache.hugegraph.backend.store.BackendEntry writeOlapVertex(org.apache.hugegraph.structure.HugeVertex) <variables... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-postgresql/src/main/java/org/apache/hugegraph/backend/store/postgresql/PostgresqlSessions.java | PostgresqlSessions | createDatabase | class PostgresqlSessions extends MysqlSessions {
private static final Logger LOG = Log.logger(PostgresqlSessions.class);
private static final String COCKROACH_DB_CREATE =
"CREATE DATABASE %s ENCODING='UTF-8'";
private static final String POSTGRESQL_DB_CREATE = COCKROACH_DB_CREATE +
... |
// Create database with non-database-session
LOG.debug("Create database: {}", this.database());
String sql = this.buildCreateDatabase(this.database());
try (Connection conn = this.openWithoutDB(0)) {
try {
conn.createStatement().execute(sql);
} c... | 768 | 238 | 1,006 | <methods>public void <init>(HugeConfig, java.lang.String, java.lang.String) ,public HugeConfig config() ,public void createDatabase() ,public java.lang.String database() ,public void dropDatabase() ,public java.lang.String escapedDatabase() ,public boolean existsDatabase() ,public boolean existsTable(java.lang.String) ... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-postgresql/src/main/java/org/apache/hugegraph/backend/store/postgresql/PostgresqlStoreProvider.java | PostgresqlStoreProvider | driverVersion | class PostgresqlStoreProvider extends MysqlStoreProvider {
private static final Logger LOG = Log.logger(PostgresqlStoreProvider.class);
@Override
protected BackendStore newSchemaStore(HugeConfig config, String store) {
return new PostgresqlSchemaStore(this, this.database(), store);
}
@Ove... |
/*
* Versions history:
* [1.0] #441: supports PostgreSQL and Cockroach backend
* [1.1] #270 & #398: support shard-index and vertex + sortkey prefix,
* also split range table to rangeInt, rangeFloat,
* rangeLong and rangeDouble
... | 1,507 | 289 | 1,796 | <methods>public non-sealed void <init>() ,public java.lang.String driverVersion() ,public java.lang.String type() <variables> |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-postgresql/src/main/java/org/apache/hugegraph/backend/store/postgresql/PostgresqlTable.java | PostgresqlTable | buildUpdateForcedParams | class PostgresqlTable extends MysqlTable {
private String orderByKeysTemplate = null;
public PostgresqlTable(String table) {
super(table);
}
@Override
protected String buildDropTemplate() {
return String.format("DROP TABLE IF EXISTS %s CASCADE;", this.table());
}
@Overrid... |
List<Object> params = new ArrayList<>();
List<Object> allColumns = this.buildColumnsParams(entry);
params.addAll(allColumns);
params.addAll(allColumns);
return params;
| 1,098 | 57 | 1,155 | <methods>public void <init>(java.lang.String) ,public void append(org.apache.hugegraph.backend.store.mysql.MysqlSessions.Session, org.apache.hugegraph.backend.serializer.TableBackendEntry.Row) ,public void clear(org.apache.hugegraph.backend.store.mysql.MysqlSessions.Session) ,public void delete(org.apache.hugegraph.bac... |
apache_incubator-hugegraph | incubator-hugegraph/hugegraph-server/hugegraph-postgresql/src/main/java/org/apache/hugegraph/backend/store/postgresql/PostgresqlTables.java | Counters | increaseCounter | class Counters extends PostgresqlTableTemplate {
public Counters() {
super(new MysqlTables.Counters(TYPES_MAPPING));
}
public long getCounter(Session session, HugeType type) {
MysqlTables.Counters table = (MysqlTables.Counters) this.template;
return table.ge... |
String update = String.format(
"INSERT INTO %s (%s, %s) VALUES ('%s', %s) " +
"ON CONFLICT (%s) DO UPDATE SET ID = %s.ID + %s;",
this.table(), formatKey(HugeKeys.SCHEMA_TYPE),
formatKey(HugeKeys.ID), type.name(), increment,
... | 139 | 172 | 311 | <no_super_class> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.