void parseOneEntry(AnyObjectId noteOn, AnyObjectId noteData) { growIfFull(); notes[cnt++] = new Note(noteOn, noteData.copy()); }
@Override InMemoryNoteBucket set(AnyObjectId noteOn, AnyObjectId noteData, ObjectReader or) throws IOException { int p = search(noteOn); if (0 <= p) { if (noteData != null) { notes[p].setData(noteData.copy()); return this; } else { System.arraycopy(notes, p + 1, notes, p, cnt - p - 1); cnt--; return 0 < cnt ? this : null; } } else if (noteData != null) { if (shouldSplit()) { return split().set(noteOn, noteData, or); } else { growIfFull(); p = -(p + 1); if (p < cnt) System.arraycopy(notes, p, notes, p + 1, cnt - p); notes[p] = new Note(noteOn, noteData.copy()); cnt++; return this; } } else { return this; } }
/** {@inheritDoc} */ @Override public Note merge(Note base, Note ours, Note theirs, ObjectReader reader, ObjectInserter inserter) throws IOException { if (ours == null) return theirs; if (theirs == null) return ours; if (ours.getData().equals(theirs.getData())) return ours; ObjectLoader lo = reader.open(ours.getData()); ObjectLoader lt = reader.open(theirs.getData()); try (UnionInputStream union = new UnionInputStream(lo.openStream(), lt.openStream())) { ObjectId noteData = inserter.insert(Constants.OBJ_BLOB, lo.getSize() + lt.getSize(), union); return new Note(ours, noteData); } } }
void parseOneEntry(AnyObjectId noteOn, AnyObjectId noteData) { growIfFull(); notes[cnt++] = new Note(noteOn, noteData.copy()); }
void parseOneEntry(AnyObjectId noteOn, AnyObjectId noteData) { growIfFull(); notes[cnt++] = new Note(noteOn, noteData.copy()); }
InMemoryNoteBucket set(AnyObjectId noteOn, AnyObjectId noteData, ObjectReader or) throws IOException { int p = search(noteOn); if (0 <= p) { if (noteData != null) { notes[p].setData(noteData.copy()); return this; } else { System.arraycopy(notes, p + 1, notes, p, cnt - p - 1); cnt--; return 0 < cnt ? this : null; } } else if (noteData != null) { if (shouldSplit()) { return split().set(noteOn, noteData, or); } else { growIfFull(); p = -(p + 1); if (p < cnt) System.arraycopy(notes, p, notes, p + 1, cnt - p); notes[p] = new Note(noteOn, noteData.copy()); cnt++; return this; } } else { return this; } }
@Override InMemoryNoteBucket set(AnyObjectId noteOn, AnyObjectId noteData, ObjectReader or) throws IOException { int p = search(noteOn); if (0 <= p) { if (noteData != null) { notes[p].setData(noteData.copy()); return this; } else { System.arraycopy(notes, p + 1, notes, p, cnt - p - 1); cnt--; return 0 < cnt ? this : null; } } else if (noteData != null) { if (shouldSplit()) { return split().set(noteOn, noteData, or); } else { growIfFull(); p = -(p + 1); if (p < cnt) System.arraycopy(notes, p, notes, p + 1, cnt - p); notes[p] = new Note(noteOn, noteData.copy()); cnt++; return this; } } else { return this; } }
private void add(T noteRecord) throws MissingObjectException, IncorrectObjectTypeException, IOException, RuntimeException { ObjectId noteContent = createNoteContent(noteRecord); if (ours.contains(reviewCommit)) { // merge the existing and the new note as if they are both new // means: base == null // there is not really a common ancestry for these two note revisions // use the same NoteMerger that is used from the NoteMapMerger NoteMerger noteMerger = new DefaultNoteMerger(); Note newNote = new Note(reviewCommit, noteContent); noteContent = noteMerger.merge(null, newNote, ours.getNote(reviewCommit), reader, inserter).getData(); } ours.set(reviewCommit, noteContent); }
/** {@inheritDoc} */ @Override public Note merge(Note base, Note ours, Note theirs, ObjectReader reader, ObjectInserter inserter) throws IOException { if (ours == null) return theirs; if (theirs == null) return ours; if (ours.getData().equals(theirs.getData())) return ours; ObjectLoader lo = reader.open(ours.getData()); ObjectLoader lt = reader.open(theirs.getData()); try (UnionInputStream union = new UnionInputStream(lo.openStream(), lt.openStream())) { ObjectId noteData = inserter.insert(Constants.OBJ_BLOB, lo.getSize() + lt.getSize(), union); return new Note(ours, noteData); } } }
public Note merge(Note base, Note ours, Note theirs, ObjectReader reader, ObjectInserter inserter) throws IOException { if (ours == null) return theirs; if (theirs == null) return ours; if (ours.getData().equals(theirs.getData())) return ours; ObjectLoader lo = reader.open(ours.getData()); ObjectLoader lt = reader.open(theirs.getData()); UnionInputStream union = new UnionInputStream(lo.openStream(), lt.openStream()); try { ObjectId noteData = inserter.insert(Constants.OBJ_BLOB, lo.getSize() + lt.getSize(), union); return new Note(ours, noteData); } finally { union.close(); } } }