Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
274,000
GraphCommit<String> (@NotNull String line) { Pair<String, String[]> stringPair = parseCommitParents(line); return SimpleCommit.asStringCommit(stringPair.first, stringPair.second); }
parseCommitParentsAsString
274,001
GraphCommit<Integer> (@NotNull String line) { Pair<String, String[]> stringPair = parseCommitParents(line); return SimpleCommit.asIntegerCommit(stringPair.first, stringPair.second); }
parseCommitParentsAsInteger
274,002
int (@NotNull String s) { return Integer.parseInt(s, 16); }
createHash
274,003
List<String> (@NotNull String in) { String[] split = in.split("\n"); List<String> result = new ArrayList<>(); for (String line : split) { if (!line.isEmpty()) { result.add(line); } } return result; }
toLines
274,004
List<GraphCommit<String>> (@NotNull String input) { List<GraphCommit<String>> vcsCommitParents = new ArrayList<>(); for (String line : toLines(input)) { vcsCommitParents.add(CommitParser.parseCommitParentsAsString(line)); } return vcsCommitParents; }
parseStringCommitList
274,005
List<GraphCommit<Integer>> (@NotNull String input) { List<GraphCommit<Integer>> vcsCommitParents = new ArrayList<>(); for (String line : toLines(input)) { vcsCommitParents.add(CommitParser.parseCommitParentsAsInteger(line)); } return vcsCommitParents; }
parseIntegerCommitList
274,006
List<GraphCommit<String>> (@NotNull String in) { return CommitParser.parseStringCommitList(in); }
parseCommitList
274,007
String (String commit) { return commit; }
toStr
274,008
Integer (@NotNull String commit) { return CommitParser.createHash(commit); }
toInt
274,009
List<GraphCommit<Integer>> (@NotNull String in) { return CommitParser.parseIntegerCommitList(in); }
parseCommitList
274,010
String (Integer commit) { return Integer.toHexString(commit); }
toStr
274,011
Integer (@NotNull Integer commit) { return commit; }
toInt
274,012
void (String in, String out) { final CommitIdManager<CommitId> idManager = getCommitIdManager(); final List<GraphCommit<CommitId>> commits = idManager.parseCommitList(in); PermanentLinearGraphBuilder<CommitId> graphBuilder = PermanentLinearGraphBuilder.newInstance(commits); PermanentLinearGraphImpl graph = graphBuilder.build(); GraphLayout graphLayout = GraphLayoutBuilder.build(graph, (o1, o2) -> { CommitId id1 = commits.get(o1).getId(); CommitId id2 = commits.get(o2).getId(); return idManager.toStr(id1).compareTo(idManager.toStr(id2)); }); assertEquals(out, permanentGraphLayoutModelToStr(graphLayout, graph.nodesCount())); }
runTest
274,013
CommitIdManager<String> () { return CommitIdManager.STRING_COMMIT_ID_MANAGER; }
getCommitIdManager
274,014
CommitIdManager<Integer> () { return CommitIdManager.INTEGER_COMMIT_ID_MANAGER; }
getCommitIdManager
274,015
Set<Integer> (String str) { Set<Integer> result = new HashSet<>(); for (String subStr : str.split("\\s")) { result.add(Integer.parseInt(subStr)); } return result; }
parseBranchNodeIndex
274,016
void (String in, String out) { int i = in.indexOf(SEPARATOR); List<GraphCommit<CommitId>> commits = getCommitIdManager().parseCommitList(in.substring(0, i)); LinearGraph graph = PermanentLinearGraphBuilder.newInstance(commits).build(); Set<Integer> branches = parseBranchNodeIndex(in.substring(i + SEPARATOR.length())); ReachableNodes reachableNodes = new ReachableNodes(LinearGraphUtils.asLiteLinearGraph(graph)); assertEquals(out, containingBranchesGetterToStr(reachableNodes, branches, graph.nodesCount())); }
runTest
274,017
CommitIdManager<String> () { return CommitIdManager.STRING_COMMIT_ID_MANAGER; }
getCommitIdManager
274,018
CommitIdManager<Integer> () { return CommitIdManager.INTEGER_COMMIT_ID_MANAGER; }
getCommitIdManager
274,019
void (String in, String out) { final List<GraphCommit<CommitId>> commits = getCommitIdManager().parseCommitList(in); PermanentCommitsInfo<CommitId> commitsInfo = PermanentCommitsInfoImpl.newInstance(commits, new Int2ObjectOpenHashMap<>()); assertEquals(out, commitsInfoToStr(commitsInfo, commits.size(), getCommitIdManager().getToStrFunction())); }
runTest
274,020
CommitIdManager<String> () { return CommitIdManager.STRING_COMMIT_ID_MANAGER; }
getCommitIdManager
274,021
CommitIdManager<Integer> () { return CommitIdManager.INTEGER_COMMIT_ID_MANAGER; }
getCommitIdManager
274,022
void (String in, String out) { LinearGraph graph = LinearGraphParser.parse(in); EdgesInRowGenerator edgesInRowGenerator = new EdgesInRowGenerator(graph); assertEquals(out, edgesInRowToStr(edgesInRowGenerator, graph.nodesCount())); }
runTest
274,023
long () { return myTimestamp; }
getTimestamp
274,024
boolean (Object o) { if (this == o) return true; if (!(o instanceof GraphCommit commit)) return false; return getId().equals(commit.getId()); }
equals
274,025
int () { return getId().hashCode(); }
hashCode
274,026
List<CommitId> () { return this; }
getParents
274,027
String () { return getId().toString(); }
toString
274,028
CommitId () { return myId; }
getId
274,029
CommitId (int index) { if (myParents instanceof Object[] array) { if (index < 0 || index >= array.length) { throw new ArrayIndexOutOfBoundsException(index); } return (CommitId)array[index]; } if (index != 0) { throw new ArrayIndexOutOfBoundsException(index); } return (CommitId)myParents; }
get
274,030
int () { return myParents instanceof Object[] ? ((Object[])myParents).length : 1; }
size
274,031
GraphCommit<Integer> (int id, @NotNull List<Integer> parents, long timestamp) { if (parents.size() == 1) { return new IntGraphCommit.SingleParent(timestamp, id, parents.get(0)); } return new IntGraphCommit.MultiParent(timestamp, id, Ints.toArray(parents)); }
createIntCommit
274,032
Integer () { return myId; }
getId
274,033
int () { return 1; }
size
274,034
Integer (int index) { if (index != 0) throw new ArrayIndexOutOfBoundsException(index); return myParentId; }
get
274,035
int () { return myParents.length; }
size
274,036
Integer (int index) { return myParents[index]; }
get
274,037
NormalEdge (int up, int down) { return new NormalEdge(up, down); }
create
274,038
int () { return up; }
getUp
274,039
int () { return down; }
getDown
274,040
boolean (Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; NormalEdge that = (NormalEdge)o; if (up != that.up) return false; if (down != that.down) return false; return true; }
equals
274,041
int () { int result = up; result = 31 * result + down; return result; }
hashCode
274,042
int (int bitIndex) { return -bitIndex; }
toPositive
274,043
void (int bitIndex, boolean value) { if (bitIndex >= 0) { myPositiveSet.set(bitIndex, value); } else { myNegativeSet.set(toPositive(bitIndex), value); } }
set
274,044
void (int fromIndex, int toIndex, boolean value) { if (fromIndex > toIndex) { throw new IndexOutOfBoundsException("fromIndex: " + fromIndex + " > toIndex: " + toIndex); } if (fromIndex >= 0) { myPositiveSet.set(fromIndex, toIndex + 1, value); } else if (toIndex < 0) { myNegativeSet.set(toPositive(toIndex), toPositive(fromIndex) + 1, value); } else { myPositiveSet.set(0, toIndex + 1, value); myNegativeSet.set(toPositive(-1), toPositive(fromIndex) + 1, value); } }
set
274,045
boolean (int bitIndex) { if (bitIndex >= 0) { return myPositiveSet.get(bitIndex); } else { return myNegativeSet.get(toPositive(bitIndex)); } }
get
274,046
UnsignedBitSet () { return new UnsignedBitSet((BitSet)myPositiveSet.clone(), (BitSet)myNegativeSet.clone()); }
clone
274,047
void (int key, int value) { int[] values = myKeyToArrayMap.get(key); int[] newValues; if (values == null) { newValues = new int[]{value}; } else { newValues = new int[values.length + 1]; for (int i = 0; i < values.length; i++) { if (values[i] == value) return; newValues[i] = values[i]; } newValues[newValues.length - 1] = value; } myKeyToArrayMap.put(key, newValues); }
putValue
274,048
void (int key, int value) { int removeIndex = -1; int[] values = myKeyToArrayMap.get(key); if (values == null) return; for (int i = 0; i < values.length; i++) { if (values[i] == value) { removeIndex = i; break; } } if (removeIndex == -1) return; if (values.length == 1) { myKeyToArrayMap.remove(key); return; } int[] newValues = new int[values.length - 1]; for (int i = 0; i < newValues.length; i++) { if (i >= removeIndex) { newValues[i] = values[i + 1]; } else { newValues[i] = values[i]; } } myKeyToArrayMap.put(key, newValues); }
remove
274,049
Collection<Integer> (int key) { final int[] asArray = getAsArray(key); return new AbstractList<>() { @NotNull @Override public Integer get(int index) { return asArray[index]; } @Override public int size() { return asArray.length; } }; }
get
274,050
Integer (int index) { return asArray[index]; }
get
274,051
int () { return asArray.length; }
size
274,052
boolean () { return myKeyToArrayMap.isEmpty(); }
isEmpty
274,053
boolean (int key) { return myKeyToArrayMap.containsKey(key); }
containsKey
274,054
void () { myKeyToArrayMap.clear(); }
clear
274,055
boolean (@Nullable Integer value, int number) { return value != null && value == number; }
intEqual
274,056
boolean (@NotNull GraphEdge edge, int nodeIndex) { return intEqual(edge.getDownNodeIndex(), nodeIndex); }
isEdgeUp
274,057
boolean (@NotNull GraphEdge edge, int nodeIndex) { return intEqual(edge.getUpNodeIndex(), nodeIndex); }
isEdgeDown
274,058
boolean (@Nullable GraphEdge edge) { if (edge != null && edge.getType().isNormalEdge()) { assert edge.getUpNodeIndex() != null && edge.getDownNodeIndex() != null; return true; } return false; }
isNormalEdge
274,059
NormalEdge (@Nullable GraphEdge edge) { if (isNormalEdge(edge)) { assert edge.getUpNodeIndex() != null && edge.getDownNodeIndex() != null; return NormalEdge.create(edge.getUpNodeIndex(), edge.getDownNodeIndex()); } return null; }
asNormalEdge
274,060
int (@NotNull GraphEdge edge) { if (edge.getUpNodeIndex() != null) return edge.getUpNodeIndex(); assert edge.getDownNodeIndex() != null; return edge.getDownNodeIndex(); }
getNotNullNodeIndex
274,061
List<Integer> (@NotNull LinearGraph graph, final int nodeIndex) { return ContainerUtil.mapNotNull(graph.getAdjacentEdges(nodeIndex, EdgeFilter.NORMAL_UP), graphEdge -> graphEdge.getUpNodeIndex()); }
getUpNodes
274,062
List<Integer> (@NotNull LinearGraph graph, final int nodeIndex) { return ContainerUtil.mapNotNull(graph.getAdjacentEdges(nodeIndex, EdgeFilter.NORMAL_DOWN), graphEdge -> graphEdge.getDownNodeIndex()); }
getDownNodes
274,063
List<Integer> (@NotNull final LinearGraph graph, final int nodeIndex) { return ContainerUtil.mapNotNull(graph.getAdjacentEdges(nodeIndex, EdgeFilter.ALL), graphEdge -> { if (isEdgeDown(graphEdge, nodeIndex)) { if (graphEdge.getType() == GraphEdgeType.NOT_LOAD_COMMIT) return graphEdge.getTargetId(); return graphEdge.getDownNodeIndex(); } return null; }); }
getDownNodesIncludeNotLoad
274,064
LiteLinearGraph (@NotNull final LinearGraph graph) { return new LiteLinearGraph() { @Override public int nodesCount() { return graph.nodesCount(); } @NotNull @Override public List<Integer> getNodes(final int nodeIndex, @NotNull final NodeFilter filter) { return ContainerUtil.mapNotNull(graph.getAdjacentEdges(nodeIndex, filter.edgeFilter), edge -> { if (isEdgeUp(edge, nodeIndex)) return edge.getUpNodeIndex(); if (isEdgeDown(edge, nodeIndex)) return edge.getDownNodeIndex(); return null; }); } }; }
asLiteLinearGraph
274,065
int () { return graph.nodesCount(); }
nodesCount
274,066
List<Integer> (final int nodeIndex, @NotNull final NodeFilter filter) { return ContainerUtil.mapNotNull(graph.getAdjacentEdges(nodeIndex, filter.edgeFilter), edge -> { if (isEdgeUp(edge, nodeIndex)) return edge.getUpNodeIndex(); if (isEdgeDown(edge, nodeIndex)) return edge.getDownNodeIndex(); return null; }); }
getNodes
274,067
Cursor (boolean hand) { if (hand) { return Cursor.getPredefinedCursor(Cursor.HAND_CURSOR); } else { return Cursor.getDefaultCursor(); } }
getCursor
274,068
GraphEdge (@NotNull LinearGraph graph, int up, int down) { List<GraphEdge> edges = graph.getAdjacentEdges(up, EdgeFilter.NORMAL_DOWN); for (GraphEdge edge : edges) { if (intEqual(edge.getDownNodeIndex(), down)) { return edge; } } return null; }
getEdge
274,069
Set<Integer> (@NotNull final LinearGraph graph, @NotNull Collection<Integer> nodeIndexes) { return ContainerUtil.map2Set(nodeIndexes, nodeIndex -> graph.getNodeId(nodeIndex)); }
convertNodeIndexesToIds
274,070
Set<Integer> (@NotNull final LinearGraph graph, @NotNull Collection<Integer> ids) { List<Integer> result = ContainerUtil.mapNotNull(ids, id -> graph.getNodeIndex(id)); return new HashSet<>(result); }
convertIdsToNodeIndexes
274,071
int (@NotNull IntList deltaList) { int count = 0; for (int i = 0; i < deltaList.size(); i++) { count += sizeOf(deltaList.get(i)); } return count; }
countBytesAfterCompression
274,072
int (int value) { if (value < 0) value = ~value; value >>= BYTE_OFFSET - 1; for (int i = 1; i < 4; i++) { if (value == 0) return i; value >>= BYTE_OFFSET; } return 4; }
sizeOf
274,073
void (int startIndex, int value, int sizeOf, byte[] bytes) { for (int i = sizeOf - 1; i >= 0; i--) { bytes[startIndex + i] = (byte)value; value >>= BYTE_OFFSET; } }
writeDelta
274,074
int (int startIndex, int sizeOf, byte[] bytes) { int result = 0; boolean isNegative = bytes[startIndex] < 0; if (isNegative) { for (int i = 0; i < 4 - sizeOf; i++) { result <<= BYTE_OFFSET; result |= BYTE_MASK; } } for (int i = startIndex; i < startIndex + sizeOf; i++) { result <<= BYTE_OFFSET; result |= bytes[i] & BYTE_MASK; } return result; }
readDelta
274,075
int (int arraySize, int blockSize) { if (arraySize == 0) return 1; return (arraySize - 1) / blockSize + 1; }
groundPointCount
274,076
UpdatableIntToIntMap (@NotNull Predicate<? super Integer> thisIsVisible, int longSize) { return newInstance(new PredicateFlags(thisIsVisible, longSize)); }
newInstance
274,077
UpdatableIntToIntMap (@NotNull Flags visibleNodes) { return newInstance(visibleNodes, DEFAULT_BLOCK_SIZE); }
newInstance
274,078
UpdatableIntToIntMap (@NotNull Flags visibility, int blockSize) { int longSize = visibility.size(); if (longSize < 0) throw new NegativeArraySizeException("size < 0: " + longSize); if (longSize == 0) return IDIntToIntMap.EMPTY; int sumSize = (longSize - 1) / blockSize + 1; ListIntToIntMap listIntToIntMap = new ListIntToIntMap(visibility, longSize, blockSize, new int[sumSize]); listIntToIntMap.update(0, longSize - 1); return listIntToIntMap; }
newInstance
274,079
int () { return mySubSumOfBlocks[mySubSumOfBlocks.length - 1]; }
shortSize
274,080
int () { return myLongSize; }
longSize
274,081
int (int longIndex) { return longIndex / myBlockSize; }
getRelevantSumIndex
274,082
int (int shortIndex) { checkShortIndex(shortIndex); int blockIndex = lastInsertionPoint(mySubSumOfBlocks, shortIndex); int prefVisibleCount = 0; if (blockIndex > 0) prefVisibleCount = mySubSumOfBlocks[blockIndex - 1]; for (int longIndex = blockIndex * myBlockSize; longIndex < myLongSize; longIndex++) { if (myVisibility.get(longIndex)) prefVisibleCount++; if (prefVisibleCount > shortIndex) return longIndex; } throw new IllegalAccessError("This should never happen!"); }
getLongIndex
274,083
int (int longIndex) { checkLongIndex(longIndex); int blockIndex = getRelevantSumIndex(longIndex); int countVisible = calculateSumForBlock(blockIndex, longIndex); if (countVisible > 0) { return countVisible - 1; } else { return 0; } }
getShortIndex
274,084
int (int blockIndex, int lastLongIndex) { int sum = 0; if (blockIndex > 0) sum = mySubSumOfBlocks[blockIndex - 1]; for (int longIndex = blockIndex * myBlockSize; longIndex <= lastLongIndex; longIndex++) { if (myVisibility.get(longIndex)) sum++; } return sum; }
calculateSumForBlock
274,085
void (int startLongIndex, int endLongIndex) { checkUpdateParameters(startLongIndex, endLongIndex); int startSumIndex = getRelevantSumIndex(startLongIndex); int endSumIndex = getRelevantSumIndex(endLongIndex); int prevEndSum = mySubSumOfBlocks[endSumIndex]; for (int blockIndex = startSumIndex; blockIndex <= endSumIndex; blockIndex++) { int endIndex = Math.min(myLongSize, (blockIndex + 1) * myBlockSize); mySubSumOfBlocks[blockIndex] = calculateSumForBlock(blockIndex, endIndex - 1); } int sumDelta = mySubSumOfBlocks[endSumIndex] - prevEndSum; for (int blockIndex = endSumIndex + 1; blockIndex < mySubSumOfBlocks.length; blockIndex++) { mySubSumOfBlocks[blockIndex] += sumDelta; } }
update
274,086
int (int[] array, int key) { int l = 0; int u = array.length - 1; while (u > l) { int middle = (l + u) / 2; if (array[middle] <= key) { l = middle + 1; } else { u = middle; } } assert l == u; return l; }
lastInsertionPoint
274,087
IntDeltaCompressor (@NotNull IntList deltaList) { if (deltaList.size() < 0) throw new NegativeArraySizeException("size < 0: " + deltaList.size()); int bytesAfterCompression = ByteArrayUtils.countBytesAfterCompression(deltaList); Flags startedDeltaIndex = new BitSetFlags(bytesAfterCompression); byte[] compressedDeltas = new byte[bytesAfterCompression]; int currentStartIndex = 0; for (int i = 0; i < deltaList.size(); i++) { startedDeltaIndex.set(currentStartIndex, true); int value = deltaList.get(i); int sizeOf = ByteArrayUtils.sizeOf(value); ByteArrayUtils.writeDelta(currentStartIndex, value, sizeOf, compressedDeltas); currentStartIndex += sizeOf; } return new IntDeltaCompressor(compressedDeltas, startedDeltaIndex, deltaList.size()); }
newInstance
274,088
int (int left, int right) { if (left < 0 || left > right || right > size()) { throw new IllegalArgumentException("Size is: " + size() + ", but interval is: (" + left + ", " + right + ")"); } if (left == size()) return 0; int startIndex = myStartIndexMap.getLongIndex(left); int sum = 0; for (int i = 0; i < right - left; i++) { int sizeOf = getNextStartIndex(startIndex) - startIndex; sum += ByteArrayUtils.readDelta(startIndex, sizeOf, myCompressedDeltas); startIndex += sizeOf; } return sum; }
getSumOfInterval
274,089
int (int index) { if (index < 0 || index >= size()) throw new IllegalArgumentException("Size is: " + size() + ", but index is: " + index); int startIndex = myStartIndexMap.getLongIndex(index); int sizeOf = getNextStartIndex(startIndex) - startIndex; return ByteArrayUtils.readDelta(startIndex, sizeOf, myCompressedDeltas); }
get
274,090
int () { return myStartIndexMap.shortSize(); }
size
274,091
int (int currentIndex) { for (int i = currentIndex + 1; i < myStartedDeltaIndex.size(); i++) { if (myStartedDeltaIndex.get(i)) return i; } return myStartedDeltaIndex.size(); }
getNextStartIndex
274,092
SmartDeltaCompressor (@NotNull IntList deltaList) { if (deltaList.size() < 0) throw new NegativeArraySizeException("size < 0: " + deltaList.size()); int bytesAfterCompression = countBytesAfterCompression(deltaList); byte[] deltas = new byte[bytesAfterCompression]; int size = deltaList.size(); int groundPointCount = groundPointCount(size, 64); int[] groundIndexes = new int[groundPointCount]; long[] majorBits = new long[groundPointCount]; long[] minorBits = new long[groundPointCount]; int offset = 0; for (int main = 0; main < groundPointCount; main++) { groundIndexes[main] = offset; for (int rem = 0; rem < 64; rem++) { int index = main * 64 + rem; if (index >= size) break; int sizeOf = sizeOf(deltaList.get(index)); writeDelta(offset, deltaList.get(index), sizeOf, deltas); long mask = 1L << rem; /* 4 -> 11 3 -> 10 2 -> 01 1 -> 00 */ if (sizeOf == 3 || sizeOf == 4) majorBits[main] |= mask; if (sizeOf == 2 || sizeOf == 4) minorBits[main] |= mask; offset += sizeOf; } } return new SmartDeltaCompressor(size, deltas, majorBits, minorBits, groundIndexes); }
newInstance
274,093
int () { return mySize; }
size
274,094
int (int index) { int main = index >>> 6; // div 64 int rem = index & 0x3f; // mod 64 int shift = 63 - rem; long major = myMajorBits[main] << shift; long minor = myMinorBits[main] << shift; int sizeOf = (int)(2 * (major >>> 63) + (minor >>> 63) + 1); int endIndex = myStrongIndexes[main] + 2 * Long.bitCount(major) + Long.bitCount(minor) + rem + 1; return readDelta(endIndex - sizeOf, sizeOf, myDeltas); }
get
274,095
IntTimestampGetter (@NotNull TimestampGetter delegateGetter) { return newInstance(delegateGetter, DEFAULT_BLOCK_SIZE); }
newInstance
274,096
IntTimestampGetter (@NotNull TimestampGetter delegateGetter, int blockSize) { if (delegateGetter.size() < 0) throw new NegativeArraySizeException("delegateGetter.size() < 0: " + delegateGetter.size()); if (delegateGetter.size() == 0) throw new IllegalArgumentException("Empty TimestampGetter not supported"); long[] saveTimestamps = new long[(delegateGetter.size() - 1) / blockSize + 1]; for (int i = 0; i < saveTimestamps.length; i++) { saveTimestamps[i] = delegateGetter.getTimestamp(blockSize * i); } Int2LongOpenHashMap brokenDeltas = new Int2LongOpenHashMap(); int[] deltas = new int[delegateGetter.size()]; for (int i = 0; i < delegateGetter.size(); i++) { int blockIndex = i - (i % blockSize); long delta = delegateGetter.getTimestamp(i) - delegateGetter.getTimestamp(blockIndex); int intDelta = deltaToInt(delta); deltas[i] = intDelta; if (intDelta == BROKEN_DELTA) brokenDeltas.put(i, delta); } brokenDeltas.trim(); return new IntTimestampGetter(deltas, blockSize, saveTimestamps, brokenDeltas); }
newInstance
274,097
int (long delta) { if (delta >= 0 && delta <= MAX_DELTA) return (int)delta; if (delta < 0 && -delta <= MAX_DELTA) return (int)delta; return BROKEN_DELTA; }
deltaToInt
274,098
int () { return myDeltas.size(); }
size
274,099
long (int index) { checkRange(index); int relativeSaveIndex = index / myBlockSize; long timestamp = mySaveTimestamps[relativeSaveIndex]; return timestamp + getDelta(index); }
getTimestamp