Remove getRawSize, getRawType from ObjectLoader

These were only used by PackWriter to help it filter object
representations.  Their only user disappeared when we rewrote the
object selection code path to use the new representation type.

Change-Id: I9ed676bfe4f87fcf94aa21e53bda43115912e145
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
Shawn O. Pearce 2010-06-26 17:47:53 -07:00
parent 86547022f0
commit 68518ca3aa
10 changed files with 5 additions and 100 deletions

View File

@ -71,7 +71,7 @@ public void test003_lookupCompressedObject() throws IOException {
assertNotNull(or); assertNotNull(or);
assertEquals(Constants.OBJ_TREE, or.getType()); assertEquals(Constants.OBJ_TREE, or.getType());
assertEquals(35, or.getSize()); assertEquals(35, or.getSize());
assertEquals(7736, or.getObjectOffset()); assertEquals(7736, or.objectOffset);
pr.close(); pr.close();
} }
@ -85,6 +85,6 @@ public void test004_lookupDeltifiedObject() throws IOException {
assertTrue(or instanceof PackedObjectLoader); assertTrue(or instanceof PackedObjectLoader);
assertEquals(Constants.OBJ_BLOB, or.getType()); assertEquals(Constants.OBJ_BLOB, or.getType());
assertEquals(18009, or.getSize()); assertEquals(18009, or.getSize());
assertEquals(516, ((PackedObjectLoader) or).getObjectOffset()); assertEquals(516, ((PackedObjectLoader) or).objectOffset);
} }
} }

View File

@ -77,7 +77,7 @@ public void setUp() throws Exception {
final TestObject o = new TestObject(); final TestObject o = new TestObject();
o.id = ObjectId.fromString(parts[0]); o.id = ObjectId.fromString(parts[0]);
o.setType(parts[1]); o.setType(parts[1]);
o.rawSize = Integer.parseInt(parts[2]); // parts[2] is the inflate size
// parts[3] is the size-in-pack // parts[3] is the size-in-pack
o.offset = Long.parseLong(parts[4]); o.offset = Long.parseLong(parts[4]);
toLoad.add(o); toLoad.add(o);
@ -130,8 +130,7 @@ private void doCacheTests() throws IOException {
assertNotNull(or); assertNotNull(or);
assertTrue(or instanceof PackedObjectLoader); assertTrue(or instanceof PackedObjectLoader);
assertEquals(o.type, or.getType()); assertEquals(o.type, or.getType());
assertEquals(o.rawSize, or.getRawSize()); assertEquals(o.offset, ((PackedObjectLoader) or).objectOffset);
assertEquals(o.offset, ((PackedObjectLoader) or).getObjectOffset());
} }
} }
@ -140,8 +139,6 @@ private class TestObject {
int type; int type;
int rawSize;
long offset; long offset;
void setType(final String typeStr) throws CorruptObjectException { void setType(final String typeStr) throws CorruptObjectException {

View File

@ -89,17 +89,4 @@ public final byte[] getBytes() {
* @return the cached bytes of this object. Do not modify it. * @return the cached bytes of this object. Do not modify it.
*/ */
public abstract byte[] getCachedBytes(); public abstract byte[] getCachedBytes();
/**
* @return raw object type from object header, as stored in storage (pack,
* loose file). This may be different from {@link #getType()} result
* for packs (see {@link Constants}).
*/
public abstract int getRawType();
/**
* @return raw size of object from object header (pack, loose file).
* Interpretation of this value depends on {@link #getRawType()}.
*/
public abstract long getRawSize();
} }

View File

@ -48,11 +48,6 @@
import java.io.IOException; import java.io.IOException;
import org.eclipse.jgit.JGitText;
import org.eclipse.jgit.errors.CorruptObjectException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
/** Reads a deltified object which uses an offset to find its base. */ /** Reads a deltified object which uses an offset to find its base. */
class DeltaOfsPackedObjectLoader extends DeltaPackedObjectLoader { class DeltaOfsPackedObjectLoader extends DeltaPackedObjectLoader {
private final long deltaBase; private final long deltaBase;
@ -67,18 +62,4 @@ protected PackedObjectLoader getBaseLoader(final WindowCursor curs)
throws IOException { throws IOException {
return pack.resolveBase(curs, deltaBase); return pack.resolveBase(curs, deltaBase);
} }
@Override
public int getRawType() {
return Constants.OBJ_OFS_DELTA;
}
@Override
ObjectId getDeltaBase() throws IOException {
final ObjectId id = pack.findObjectForOffset(deltaBase);
if (id == null)
throw new CorruptObjectException(
JGitText.get().offsetWrittenDeltaBaseForObjectNotFoundInAPack);
return id;
}
} }

View File

@ -104,11 +104,6 @@ void materialize(final WindowCursor curs) throws IOException {
} }
} }
@Override
public long getRawSize() {
return deltaSize;
}
/** /**
* @param curs * @param curs
* temporary thread storage during data access. * temporary thread storage during data access.

View File

@ -49,7 +49,6 @@
import java.io.IOException; import java.io.IOException;
import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectId;
/** Reads a deltified object which uses an {@link ObjectId} to find its base. */ /** Reads a deltified object which uses an {@link ObjectId} to find its base. */
@ -69,14 +68,4 @@ protected PackedObjectLoader getBaseLoader(final WindowCursor curs)
throw new MissingObjectException(deltaBase, "delta base"); throw new MissingObjectException(deltaBase, "delta base");
return or; return or;
} }
@Override
public int getRawType() {
return Constants.OBJ_REF_DELTA;
}
@Override
ObjectId getDeltaBase() throws IOException {
return deltaBase;
}
} }

View File

@ -209,7 +209,7 @@ public boolean hasObject(final AnyObjectId id) throws IOException {
* @throws IOException * @throws IOException
* the pack file or the index could not be read. * the pack file or the index could not be read.
*/ */
public PackedObjectLoader get(final WindowCursor curs, final AnyObjectId id) PackedObjectLoader get(final WindowCursor curs, final AnyObjectId id)
throws IOException { throws IOException {
final long offset = idx().findOffset(id); final long offset = idx().findOffset(id);
return 0 < offset && !isCorrupt(offset) ? reader(curs, offset) : null; return 0 < offset && !isCorrupt(offset) ? reader(curs, offset) : null;

View File

@ -48,7 +48,6 @@
import java.io.IOException; import java.io.IOException;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectLoader; import org.eclipse.jgit.lib.ObjectLoader;
/** /**
@ -86,8 +85,6 @@ abstract class PackedObjectLoader extends ObjectLoader {
* <li>{@link #getType()}</li> * <li>{@link #getType()}</li>
* <li>{@link #getSize()}</li> * <li>{@link #getSize()}</li>
* <li>{@link #getBytes()}, {@link #getCachedBytes}</li> * <li>{@link #getBytes()}, {@link #getCachedBytes}</li>
* <li>{@link #getRawSize()}</li>
* <li>{@link #getRawType()}</li>
* </ul> * </ul>
* *
* @param curs * @param curs
@ -109,19 +106,4 @@ public final long getSize() {
public final byte[] getCachedBytes() { public final byte[] getCachedBytes() {
return cachedBytes; return cachedBytes;
} }
/**
* @return offset of object header within pack file
*/
final long getObjectOffset() {
return objectOffset;
}
/**
* @return id of delta base object for this object representation. null if
* object is not stored as delta.
* @throws IOException
* when delta base cannot read.
*/
abstract ObjectId getDeltaBase() throws IOException;
} }

View File

@ -214,14 +214,4 @@ public long getSize() {
public byte[] getCachedBytes() { public byte[] getCachedBytes() {
return bytes; return bytes;
} }
@Override
public int getRawType() {
return objectType;
}
@Override
public long getRawSize() {
return objectSize;
}
} }

View File

@ -52,7 +52,6 @@
import org.eclipse.jgit.JGitText; import org.eclipse.jgit.JGitText;
import org.eclipse.jgit.errors.CorruptObjectException; import org.eclipse.jgit.errors.CorruptObjectException;
import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
/** Reader for a non-delta (just deflated) object in a pack file. */ /** Reader for a non-delta (just deflated) object in a pack file. */
class WholePackedObjectLoader extends PackedObjectLoader { class WholePackedObjectLoader extends PackedObjectLoader {
@ -94,19 +93,4 @@ void materialize(final WindowCursor curs) throws IOException {
throw coe; throw coe;
} }
} }
@Override
public int getRawType() {
return objectType;
}
@Override
public long getRawSize() {
return objectSize;
}
@Override
ObjectId getDeltaBase() {
return null;
}
} }