Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

BitmapIndex.java 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /*
  2. * Copyright (C) 2012, Google Inc. and others
  3. *
  4. * This program and the accompanying materials are made available under the
  5. * terms of the Eclipse Distribution License v. 1.0 which is available at
  6. * https://www.eclipse.org/org/documents/edl-v10.php.
  7. *
  8. * SPDX-License-Identifier: BSD-3-Clause
  9. */
  10. package org.eclipse.jgit.lib;
  11. import java.util.Iterator;
  12. import org.eclipse.jgit.internal.storage.file.PackBitmapIndex;
  13. import com.googlecode.javaewah.EWAHCompressedBitmap;
  14. /**
  15. * A compressed bitmap representation of the entire object graph.
  16. *
  17. * @since 3.0
  18. */
  19. public interface BitmapIndex {
  20. /**
  21. * Get the bitmap for the id. The returned bitmap is immutable and the
  22. * bitwise operations return the result of the operation in a new Bitmap.
  23. *
  24. * @param objectId
  25. * the object ID
  26. * @return the Bitmap for the objectId or null, if one does not exist.
  27. */
  28. Bitmap getBitmap(AnyObjectId objectId);
  29. /**
  30. * Create a new {@code BitmapBuilder} based on the values in the index.
  31. *
  32. * @return a new {@code BitmapBuilder} based on the values in the index.
  33. */
  34. BitmapBuilder newBitmapBuilder();
  35. /**
  36. * A bitmap representation of ObjectIds that can be iterated to return the
  37. * underlying {@code ObjectId}s or operated on with other {@code Bitmap}s.
  38. */
  39. public interface Bitmap extends Iterable<BitmapObject> {
  40. /**
  41. * Bitwise-OR the current bitmap with the value from the other
  42. * bitmap.
  43. *
  44. * @param other
  45. * the other bitmap
  46. * @return a bitmap that is the bitwise-OR.
  47. */
  48. Bitmap or(Bitmap other);
  49. /**
  50. * Bitwise-AND-NOT the current bitmap with the value from the other
  51. * bitmap.
  52. *
  53. * @param other
  54. * the other bitmap
  55. * @return a bitmap that is the bitwise-AND-NOT.
  56. */
  57. Bitmap andNot(Bitmap other);
  58. /**
  59. * Bitwise-XOR the current bitmap with the value from the other
  60. * bitmap.
  61. *
  62. * @param other
  63. * the other bitmap
  64. * @return a bitmap that is the bitwise-XOR.
  65. */
  66. Bitmap xor(Bitmap other);
  67. /**
  68. * Returns an iterator over a set of elements of type BitmapObject. The
  69. * BitmapObject instance is reused across calls to
  70. * {@link Iterator#next()} for performance reasons.
  71. *
  72. * @return an Iterator.
  73. */
  74. @Override
  75. Iterator<BitmapObject> iterator();
  76. /**
  77. * Returns the corresponding raw compressed EWAH bitmap of the bitmap.
  78. *
  79. * @return the corresponding {@code EWAHCompressedBitmap}
  80. * @since 5.8
  81. */
  82. EWAHCompressedBitmap retrieveCompressed();
  83. }
  84. /**
  85. * A builder for a bitmap. The bitwise operations update the builder and
  86. * return a reference to the current builder.
  87. */
  88. public interface BitmapBuilder extends Bitmap {
  89. /**
  90. * Whether the bitmap has the id set.
  91. *
  92. * @param objectId
  93. * the object ID
  94. * @return whether the bitmap currently contains the object ID
  95. */
  96. boolean contains(AnyObjectId objectId);
  97. /**
  98. * Adds the id to the bitmap.
  99. *
  100. * @param objectId
  101. * the object ID
  102. * @param type
  103. * the Git object type. See {@link Constants}.
  104. * @return the current builder.
  105. * @since 4.2
  106. */
  107. BitmapBuilder addObject(AnyObjectId objectId, int type);
  108. /**
  109. * Remove the id from the bitmap.
  110. *
  111. * @param objectId
  112. * the object ID
  113. */
  114. void remove(AnyObjectId objectId);
  115. /**
  116. * Bitwise-OR the current bitmap with the value from the other bitmap.
  117. *
  118. * @param other
  119. * the other bitmap
  120. * @return the current builder.
  121. */
  122. @Override
  123. BitmapBuilder or(Bitmap other);
  124. /**
  125. * Bitwise-AND-NOT the current bitmap with the value from the other
  126. * bitmap.
  127. *
  128. * @param other
  129. * the other bitmap
  130. * @return the current builder.
  131. */
  132. @Override
  133. BitmapBuilder andNot(Bitmap other);
  134. /**
  135. * Bitwise-XOR the current bitmap with the value from the other bitmap.
  136. *
  137. * @param other
  138. * the other bitmap
  139. * @return the current builder.
  140. */
  141. @Override
  142. BitmapBuilder xor(Bitmap other);
  143. /** @return the fully built immutable bitmap */
  144. Bitmap build();
  145. /**
  146. * Determines if the entire bitmap index is contained in the bitmap. If
  147. * it is, the matching bits are removed from the bitmap and true is
  148. * returned. If the bitmap index is null, false is returned.
  149. *
  150. * @param bitmapIndex
  151. * the bitmap index to check if it is completely contained
  152. * inside of the current bitmap.
  153. * @return {@code true} if the bitmap index was a complete match.
  154. */
  155. boolean removeAllOrNone(PackBitmapIndex bitmapIndex);
  156. /** @return the number of elements in the bitmap. */
  157. int cardinality();
  158. /**
  159. * Get the BitmapIndex for this BitmapBuilder.
  160. *
  161. * @return the BitmapIndex for this BitmapBuilder
  162. *
  163. * @since 4.2
  164. */
  165. BitmapIndex getBitmapIndex();
  166. }
  167. }