public override PackedObjectLoader getBaseLoader(WindowCursor curs)
 {
     PackedObjectLoader or = pack.Get(curs, deltaBase);
     if (or == null)
         throw new MissingObjectException(deltaBase, "delta base");
     return or;
 }
        public override void materialize(WindowCursor curs)
        {
            if (cachedBytes != null)
            {
                return;
            }

            if (objectType != OBJ_COMMIT)
            {
                UnpackedObjectCache.Entry cache = pack.readCache(dataOffset);
                if (cache != null)
                {
                    curs.release();
                    cachedBytes = cache.data;
                    return;
                }
            }

            try
            {
                cachedBytes = pack.decompress(dataOffset, objectSize, curs);
                curs.release();
                if (objectType != OBJ_COMMIT)
                    pack.saveCache(dataOffset, cachedBytes, objectType);
            }
            catch (IOException dfe)
            {
                CorruptObjectException coe;
                coe = new CorruptObjectException("object at " + dataOffset + " in "
                        + pack.File.FullName + " has bad zlib stream", dfe);
                throw coe;
            }
        }
        public override void materialize(WindowCursor curs)
        {
            if (cachedBytes != null)
            {
                return;
            }

            if (objectType != OBJ_COMMIT)
            {
                UnpackedObjectCache.Entry cache = pack.readCache(dataOffset);
                if (cache != null)
                {
                    curs.release();
                    objectType = cache.type;
                    objectSize = cache.data.Length;
                    cachedBytes = cache.data;
                    return;
                }
            }

            try
            {
                PackedObjectLoader baseLoader = getBaseLoader(curs);
                baseLoader.materialize(curs);
                cachedBytes = BinaryDelta.Apply(baseLoader.getCachedBytes(),
                        pack.decompress(dataOffset, deltaSize, curs));
                curs.release();
                objectType = baseLoader.getType();
                objectSize = cachedBytes.Length;
                if (objectType != OBJ_COMMIT)
                    pack.saveCache(dataOffset, cachedBytes, objectType);
            }
            catch (IOException dfe)
            {
                CorruptObjectException coe;
                coe = new CorruptObjectException("object at " + dataOffset + " in "
                        + pack.File.FullName + " has bad zlib stream", dfe);
                throw coe;
            }
        }
예제 #4
0
 /// <summary>
 /// Slow half of <see cref="openObject(WindowCursor, AnyObjectId)"/>.
 /// </summary>
 /// <param name="curs">
 /// temporary working space associated with the calling thread.
 /// </param>
 /// <param name="objectName">Name of the object to open.</param>
 /// <param name="objectId">identity of the object to open.</param>
 /// <returns>
 /// A <see cref="ObjectLoader"/> for accessing the data of the named
 /// object, or null if the object does not exist.
 /// </returns>
 public virtual ObjectLoader openObject2(WindowCursor curs, string objectName,
         AnyObjectId objectId)
 {
     // Assume the search took place during openObject1.
     return null;
 }
예제 #5
0
 /// <summary>
 /// Open the object from all packs containing it.
 /// <para />
 /// If any alternates are present, their packs are also considered.
 /// </summary>
 /// <param name="out">
 /// Result collection of loaders for this object, filled with
 /// loaders from all packs containing specified object
 /// </param>
 /// <param name="windowCursor">
 /// Temporary working space associated with the calling thread.
 /// </param>
 /// <param name="objectId"><see cref="ObjectId"/> of object to search for.</param>
 public void OpenObjectInAllPacks(ICollection<PackedObjectLoader> @out, WindowCursor windowCursor, AnyObjectId objectId)
 {
     OpenObjectInAllPacksImplementation(@out, windowCursor, objectId);
     foreach (ObjectDatabase alt in getAlternates())
     {
         alt.OpenObjectInAllPacksImplementation(@out, windowCursor, objectId);
     }
 }
예제 #6
0
 public override ObjectLoader openObject2(WindowCursor curs, string objectName, AnyObjectId objectId)
 {
     try
     {
         return new UnpackedObjectLoader(fileFor(objectName), objectId);
     }
     catch (FileNotFoundException)
     {
         return null;
     }
     catch (DirectoryNotFoundException)
     {
         return null;
     }
 }
예제 #7
0
        /**
         * Open an object from this database.
         * <p>
         * Alternates (if present) are searched automatically.
         *
         * @param curs
         *            temporary working space associated with the calling thread.
         * @param objectId
         *            identity of the object to open.
         * @return a {@link ObjectLoader} for accessing the data of the named
         *         object, or null if the object does not exist.
         * @
         */
        public virtual ObjectLoader openObject(WindowCursor curs, AnyObjectId objectId)
        {
            if (objectId == null)
                return null;
            ObjectLoader ldr;

            ldr = openObjectImpl1(curs, objectId);
            if (ldr != null)
            {
                return ldr;
            }

            ldr = openObjectImpl2(curs, objectId.ToString(), objectId);
            if (ldr != null)
            {
                return ldr;
            }
            return null;
        }
예제 #8
0
 public ObjectLoader OpenObject(WindowCursor curs, AnyObjectId id)
 {
     return openObject(curs, id);
 }
예제 #9
0
 /**
  * Open the object from all packs containing it.
  * <p>
  * If any alternates are present, their packs are also considered.
  *
  * @param out
  *            result collection of loaders for this object, filled with
  *            loaders from all packs containing specified object
  * @param curs
  *            temporary working space associated with the calling thread.
  * @param objectId
  *            id of object to search for
  * @
  */
 public virtual void openObjectInAllPacks(List<PackedObjectLoader> @out,
         WindowCursor curs, AnyObjectId objectId)
 {
     openObjectInAllPacks1(@out, curs, objectId);
     foreach (ObjectDatabase alt in getAlternates())
     {
         alt.openObjectInAllPacks1(@out, curs, objectId);
     }
 }
예제 #10
0
 public override PackedObjectLoader getBaseLoader(WindowCursor curs)
 {
     return pack.ResolveBase(curs, deltaBase);
 }
예제 #11
0
        private ObjectLoader OpenObjectImpl2(WindowCursor curs, string objectName, AnyObjectId objectId)
        {
            ObjectLoader ldr = openObject2(curs, objectName, objectId);
            if (ldr != null)
            {
                return ldr;
            }

            foreach (ObjectDatabase alt in getAlternates())
            {
                ldr = alt.OpenObjectImpl2(curs, objectName, objectId);
                if (ldr != null)
                {
                    return ldr;
                }
            }

            return null;
        }
예제 #12
0
 /**
  * Copy raw object representation from storage to provided output stream.
  * <p>
  * Copied data doesn't include object header. User must provide temporary
  * buffer used during copying by underlying I/O layer.
  * </p>
  *
  * @param out
  *            output stream when data is copied. No buffering is guaranteed.
  * @param buf
  *            temporary buffer used during copying. Recommended size is at
  *            least few kB.
  * @param curs
  *            temporary thread storage during data access.
  * @
  *             when the object cannot be read.
  * @see #beginCopyRawData()
  */
 public void copyRawData(Stream @out, byte[] buf, WindowCursor curs)
 {
     pack.copyRawData(this, @out, buf, curs);
 }
예제 #13
0
 /**
  * Force this object to be loaded into memory and pinned in this loader.
  * <p>
  * Once materialized, subsequent get operations for the following methods
  * will always succeed without raising an exception, as all information is
  * pinned in memory by this loader instance.
  * <ul>
  * <li>{@link #getType()}</li>
  * <li>{@link #getSize()}</li>
  * <li>{@link #getBytes()}, {@link #getCachedBytes}</li>
  * <li>{@link #getRawSize()}</li>
  * <li>{@link #getRawType()}</li>
  * </ul>
  *
  * @param curs
  *            temporary thread storage during data access.
  * @
  *             the object cannot be read.
  */
 public abstract void materialize(WindowCursor curs);
예제 #14
0
 /// <summary>
 /// Open object in all packs containing specified object.
 /// </summary>
 /// <param name="objectId"><see cref="ObjectId"/> of object to search for</param>
 /// <param name="resultLoaders">
 /// Result collection of loaders for this object, filled with
 /// loaders from all packs containing specified object
 /// </param>
 /// <param name="windowCursor">
 /// Temporary working space associated with the calling thread.
 /// </param>
 public void OpenObjectInAllPacks(AnyObjectId objectId, ICollection<PackedObjectLoader> resultLoaders,
     WindowCursor windowCursor)
 {
     _objectDatabase.OpenObjectInAllPacks(resultLoaders, windowCursor, objectId);
 }
예제 #15
0
 /// <summary>
 /// Open object in all packs containing specified object.
 /// </summary>
 /// <param name="objectId">id of object to search for</param>
 /// <param name="windowCursor">
 /// Temporary working space associated with the calling thread.
 /// </param>
 /// <returns>
 /// Collection of loaders for this object, from all packs containing
 /// this object
 /// </returns>
 public IEnumerable<PackedObjectLoader> OpenObjectInAllPacks(AnyObjectId objectId, WindowCursor windowCursor)
 {
     var result = new List<PackedObjectLoader>();
     OpenObjectInAllPacks(objectId, result, windowCursor);
     return result;
 }
예제 #16
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="windowCursor">
 /// Temporary working space associated with the calling thread.
 /// </param>
 /// <param name="id">SHA-1 of an object.</param>
 /// <returns>
 /// A <see cref="ObjectLoader"/> for accessing the data of the named
 /// object, or null if the object does not exist.
 /// </returns>
 public ObjectLoader OpenObject(WindowCursor windowCursor, AnyObjectId id)
 {
     return _objectDatabase.openObject(windowCursor, id);
 }
예제 #17
0
 /// <summary>
 /// Open the object from all packs containing it.
 /// <para />
 /// If any alternates are present, their packs are also considered.
 /// </summary>
 /// <param name="out">
 /// Result collection of loaders for this object, filled with
 /// loaders from all packs containing specified object.
 /// </param>
 /// <param name="windowCursor">
 /// Temporary working space associated with the calling thread.
 /// </param>
 /// <param name="objectId"><see cref="ObjectId"/> of object to search for.</param>
 public virtual void OpenObjectInAllPacksImplementation(ICollection<PackedObjectLoader> @out, WindowCursor windowCursor, AnyObjectId objectId)
 {
     // Assume no pack support
 }
 /**
  * @param curs
  *            temporary thread storage during data access.
  * @return the object loader for the base object
  * @
  */
 public abstract PackedObjectLoader getBaseLoader(WindowCursor curs);
예제 #19
0
        private ObjectLoader OpenObjectImpl1(WindowCursor curs,
                 AnyObjectId objectId)
        {
            ObjectLoader ldr = openObject1(curs, objectId);
            if (ldr != null)
            {
                return ldr;
            }

            foreach (ObjectDatabase alt in getAlternates())
            {
                ldr = alt.OpenObjectImpl1(curs, objectId);
                if (ldr != null)
                {
                    return ldr;
                }
            }

            if (tryAgain1())
            {
                ldr = openObject1(curs, objectId);
                if (ldr != null)
                {
                    return ldr;
                }
            }

            return null;
        }
예제 #20
0
 /**
  * @param curs
  *            temporary working space associated with the calling thread.
  * @param id
  *            SHA-1 of an object.
  * 
  * @return a {@link ObjectLoader} for accessing the data of the named
  *         object, or null if the object does not exist.
  * @
  */
 public ObjectLoader openObject(WindowCursor curs, AnyObjectId id)
 {
     return objectDatabase.openObject(curs, id);
 }
 public override PackedObjectLoader GetBaseLoader(WindowCursor curs)
 {
     return PackFile.ResolveBase(curs, _deltaBase);
 }
예제 #22
0
        ///**
        // * Open object in all packs containing specified object.
        // *
        // * @param objectId
        // *            id of object to search for
        // * @param resultLoaders
        // *            result collection of loaders for this object, filled with
        // *            loaders from all packs containing specified object
        // * @param curs
        // *            temporary working space associated with the calling thread.
        // * @
        // */

        public void openObjectInAllPacks(AnyObjectId objectId, List<PackedObjectLoader> resultLoaders, WindowCursor curs)
        {
            objectDatabase.openObjectInAllPacks(resultLoaders, curs, objectId);
        }
예제 #23
0
 /**
  * @param id
  *            SHA-1 of an object.
  * 
  * @return a {@link ObjectLoader} for accessing the data of the named
  *         object, or null if the object does not exist.
  * @
  */
 public ObjectLoader OpenObject(AnyObjectId id)
 {
     WindowCursor wc = new WindowCursor();
     try
     {
         return openObject(wc, id);
     }
     finally
     {
         wc.release();
     }
 }
예제 #24
0
 /**
  * Open the object from all packs containing it.
  *
  * @param out
  *            result collection of loaders for this object, filled with
  *            loaders from all packs containing specified object
  * @param curs
  *            temporary working space associated with the calling thread.
  * @param objectId
  *            id of object to search for
  * @
  */
 public virtual void openObjectInAllPacks1(List<PackedObjectLoader> @out,
         WindowCursor curs, AnyObjectId objectId)
 {
     // Assume no pack support
 }
예제 #25
0
        ///**
        // * Open object in all packs containing specified object.
        // *
        // * @param objectId
        // *            id of object to search for
        // * @param curs
        // *            temporary working space associated with the calling thread.
        // * @return collection of loaders for this object, from all packs containing
        // *         this object
        // * @
        // */
        //public ICollection<PackedObjectLoader> OpenObjectInAllPacks(AnyObjectId objectId, WindowCursor cursor)
        //{
        //    ICollection<PackedObjectLoader> result = new LinkedList<PackedObjectLoader>();
        //    OpenObjectInAllPacks(objectId, result, cursor);
        //    return result;
        //}

        public List<PackedObjectLoader> openObjectInAllPacks(AnyObjectId objectId, WindowCursor curs)
        {
            List<PackedObjectLoader> result = new List<PackedObjectLoader>();
            openObjectInAllPacks(objectId, result, curs);
            return result;
        }
예제 #26
0
        public override void OpenObjectInAllPacksImplementation(ICollection<PackedObjectLoader> @out, WindowCursor windowCursor, AnyObjectId objectId)
        {
            PackFile[] pList = Packs();
            while (true)
            {
                SEARCH:
                foreach (PackFile p in pList)
                {
                    try
                    {
                        PackedObjectLoader ldr = p.Get(windowCursor, objectId);
                        if (ldr != null)
                        {
                            @out.Add(ldr);
                        }
                    }
                    catch (PackMismatchException)
                    {
                        // Pack was modified; refresh the entire pack list.
                        //
                        pList = ScanPacks(pList);
                        goto SEARCH;
                    }
                    catch (IOException)
                    {
                        // Assume the pack is corrupted.
                        //
                        RemovePack(p);
                    }
                }

                break;
            }
        }
예제 #27
0
 public override ObjectLoader openObject1(WindowCursor curs, AnyObjectId objectId)
 {
     PackFile[] pList = packs();
     for (; ; )
     {
     SEARCH:
         foreach (PackFile p in pList)
         {
             try
             {
                 PackedObjectLoader ldr = p.Get(curs, objectId);
                 if (ldr != null)
                 {
                     ldr.materialize(curs);
                     return ldr;
                 }
             }
             catch (PackMismatchException)
             {
                 // Pack was modified; refresh the entire pack list.
                 //
                 pList = scanPacks(pList);
                 goto SEARCH;
             }
             catch (IOException)
             {
                 // Assume the pack is corrupted.
                 //
                 removePack(p);
             }
         }
         return null;
     }
 }
예제 #28
0
        /// <summary>
        /// Open an object from this database.
        /// <para />
        /// Alternates (if present) are searched automatically.
        /// </summary>
        /// <param name="curs">
        /// Temporary working space associated with the calling thread.
        /// </param>
        /// <param name="objectId">Identity of the object to open.</param>
        /// <returns>
        /// A <see cref="ObjectLoader"/> for accessing the data of the named
        /// object, or null if the object does not exist.
        /// </returns>
        public ObjectLoader openObject(WindowCursor curs, AnyObjectId objectId)
        {
            if (objectId == null) return null;

            ObjectLoader ldr = OpenObjectImpl1(curs, objectId);
            if (ldr != null)
            {
                return ldr;
            }

            ldr = OpenObjectImpl2(curs, objectId.Name, objectId);
            if (ldr != null)
            {
                return ldr;
            }
            return null;
        }
예제 #29
0
 public override void openObjectInAllPacks1(List<PackedObjectLoader> @out, WindowCursor curs, AnyObjectId objectId)
 {
     PackFile[] pList = packs();
     for (; ; )
     {
     SEARCH:
         foreach (PackFile p in pList)
         {
             try
             {
                 PackedObjectLoader ldr = p.Get(curs, objectId);
                 if (ldr != null)
                 {
                     @out.Add(ldr);
                 }
             }
             catch (PackMismatchException)
             {
                 // Pack was modified; refresh the entire pack list.
                 //
                 pList = scanPacks(pList);
                 goto SEARCH;
             }
             catch (IOException)
             {
                 // Assume the pack is corrupted.
                 //
                 removePack(p);
             }
         }
         break;
     }
 }
예제 #30
0
 /// <summary>
 /// Fast half of <see cref="openObject(WindowCursor, AnyObjectId)"/>.
 /// </summary>
 /// <param name="curs">
 /// temporary working space associated with the calling thread.
 /// </param>
 /// <param name="objectId">identity of the object to open.</param>
 /// <returns>
 /// A <see cref="ObjectLoader"/> for accessing the data of the named
 /// object, or null if the object does not exist.
 /// </returns>
 public abstract ObjectLoader openObject1(WindowCursor curs,
         AnyObjectId objectId);