Skip to content
Snippets Groups Projects

Add a flyweight copy() to SwhGraphProperties to make it threadsafe

Closed Antoine Pietri requested to merge generated-differential-D8191-source into master
3 unresolved threads

See #4422 (closed) for details.


Migrated from D8191 (view on Phabricator)

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
48 50 }
49 51 }
50 52
53 public NodeTypesMap(LongBigList nodeTypesMap) {
54 this.nodeTypesMap = nodeTypesMap;
55 }
56
57 @Override
58 public NodeTypesMap copy() {
59 return new NodeTypesMap(
60 (nodeTypesMap instanceof LongMappedBigList) ? ((LongMappedBigList) nodeTypesMap).copy() : nodeTypesMap);
61 }
  • Jared
    Jared @JaredR26 started a thread on the diff
  • 150 150 @Override
    151 151 public SwhUnidirectionalGraph copy() {
    152 152 return new SwhUnidirectionalGraph(this.graph.copy(),
    153 this.labelledGraph != null ? this.labelledGraph.copy() : null, this.properties);
    153 this.labelledGraph != null ? this.labelledGraph.copy() : null, this.properties.copy());
    • I'm not sure it matters, but because this.graph can refer to the underlying graph of this.labelledGraph (Line 71, inside loadLabelledGraphOnly), that would result in double-copying. (When you first wrote the copy function, we hadn't yet found the need to assign the underlying to graph) I'm sure it is low overhead, but would it be better to first copy this.labelledGraph and then assign g.g again if labelledGraph exists?

    • Please register or sign in to reply
  • Jared
    Jared @JaredR26 started a thread on the diff
  • 68 69 this.nodeTypesMap = nodeTypesMap;
    69 70 }
    70 71
    72 protected SwhGraphProperties(String path, NodeIdMap nodeIdMap, NodeTypesMap nodeTypesMap,
    73 LongBigList authorTimestamp, ShortBigList authorTimestampOffset, LongBigList committerTimestamp,
    74 ShortBigList committerTimestampOffset, LongBigList contentLength, LongArrayBitVector contentIsSkipped,
    75 IntBigList authorId, IntBigList committerId, ByteBigList messageBuffer, LongBigList messageOffsets,
    76 ByteBigList tagNameBuffer, LongBigList tagNameOffsets, MappedFrontCodedStringBigList edgeLabelNames) {
    77 this.path = path;
    78 this.nodeIdMap = nodeIdMap;
    79 this.nodeTypesMap = nodeTypesMap;
    80 this.authorTimestamp = authorTimestamp;
    81 this.authorTimestampOffset = authorTimestampOffset;
    82 this.committerTimestamp = committerTimestamp;
    83 this.committerTimestampOffset = committerTimestampOffset;
    84 this.contentLength = contentLength;
    • FYI, timestamps and content lengths were already threadsafe for reading for me, or if it wasn't, it didn't cause any issues I found. edgeLabelNames and nodeIdMap were the problems, and I'm guessing any of the other string ones.

    • Please register or sign in to reply
  • Merge request was accepted

  • Jared approved this merge request

    approved this merge request

  • vlorentz mentioned in issue #4759 (closed)

    mentioned in issue #4759 (closed)

  • vlorentz mentioned in merge request !253 (merged)

    mentioned in merge request !253 (merged)

  • Merged via !253 (merged)

  • closed

  • Please register or sign in to reply
    Loading