git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: Robin Rosenberg <robin.rosenberg@dewire.com>,
	Marek Zawirski <marek.zawirski@gmail.com>
Cc: git@vger.kernel.org, "Shawn O. Pearce" <spearce@spearce.org>
Subject: [JGIT PATCH 04/10] Document PackedObjectInfo and make it public for reuse
Date: Mon, 23 Jun 2008 22:10:02 -0400	[thread overview]
Message-ID: <1214273408-70793-5-git-send-email-spearce@spearce.org> (raw)
In-Reply-To: <1214273408-70793-4-git-send-email-spearce@spearce.org>

Classes outside of transport may wish to use this abstraction,
so we mark it public, expose the offset field, and document
as much of the API as possible.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../spearce/jgit/transport/PackedObjectInfo.java   |   33 ++++++++++++++++++--
 1 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/PackedObjectInfo.java b/org.spearce.jgit/src/org/spearce/jgit/transport/PackedObjectInfo.java
index eaedee9..58feada 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/PackedObjectInfo.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/PackedObjectInfo.java
@@ -41,7 +41,14 @@ package org.spearce.jgit.transport;
 import org.spearce.jgit.lib.AnyObjectId;
 import org.spearce.jgit.lib.ObjectId;
 
-class PackedObjectInfo extends ObjectId {
+/**
+ * Description of an object stored in a pack file, including offset.
+ * <p>
+ * When objects are stored in packs Git needs the ObjectId and the offset
+ * (starting position of the object data) to perform random-access reads of
+ * objects from the pack. This extension of ObjectId includes the offset.
+ */
+public class PackedObjectInfo extends ObjectId {
 	private long offset;
 
 	PackedObjectInfo(final long headerOffset, final AnyObjectId id) {
@@ -50,10 +57,30 @@ class PackedObjectInfo extends ObjectId {
 	}
 
 	/**
-	 * @return offset in pack when object has been already written, or -1 if it
+	 * Create a new structure to remember information about an object.
+	 * 
+	 * @param id
+	 *            the identity of the object the new instance tracks.
+	 */
+	public PackedObjectInfo(final AnyObjectId id) {
+		super(id);
+	}
+
+	/**
+	 * @return offset in pack when object has been already written, or 0 if it
 	 *         has not been written yet
 	 */
-	long getOffset() {
+	public long getOffset() {
 		return offset;
 	}
+
+	/**
+	 * Set the offset in pack when object has been written to.
+	 * 
+	 * @param offset
+	 *            offset where written object starts
+	 */
+	public void setOffset(final long offset) {
+		this.offset = offset;
+	}
 }
-- 
1.5.6.74.g8a5e

  reply	other threads:[~2008-06-24  2:11 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-24  2:09 [JGIT PATCH 00/10] Support writing pack index version 2 Shawn O. Pearce
2008-06-24  2:09 ` [JGIT PATCH 01/10] Extract inner ObjectEntry from IndexPack class Shawn O. Pearce
2008-06-24  2:10   ` [JGIT PATCH 02/10] Make ObjectEntry's position field private Shawn O. Pearce
2008-06-24  2:10     ` [JGIT PATCH 03/10] Rename ObjectEntry to PackedObjectInfo Shawn O. Pearce
2008-06-24  2:10       ` Shawn O. Pearce [this message]
2008-06-24  2:10         ` [JGIT PATCH 05/10] Refactor pack index writing to a common API Shawn O. Pearce
2008-06-24  2:10           ` [JGIT PATCH 06/10] Reuse the magic tOc constant for pack index headers Shawn O. Pearce
2008-06-24  2:10             ` [JGIT PATCH 07/10] Add 64 bit network byte order encoding to NB Shawn O. Pearce
2008-06-24  2:10               ` [JGIT PATCH 08/10] Compute packed object entry CRC32 data during IndexPack Shawn O. Pearce
2008-06-24  2:10                 ` [JGIT PATCH 09/10] Add support for writing pack index v2 files Shawn O. Pearce
2008-06-24  2:10                   ` [JGIT PATCH 10/10] Default IndexPack to honor pack.indexversion configuration Shawn O. Pearce
2008-06-25  4:01             ` [JGIT PATCH 06/10 v2] Reuse the magic tOc constant for pack index headers Shawn O. Pearce
2008-06-24 22:48 ` [JGIT PATCH 00/10] Support writing pack index version 2 Robin Rosenberg
2008-06-25  3:54   ` Shawn O. Pearce

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1214273408-70793-5-git-send-email-spearce@spearce.org \
    --to=spearce@spearce.org \
    --cc=git@vger.kernel.org \
    --cc=marek.zawirski@gmail.com \
    --cc=robin.rosenberg@dewire.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).