2 * Copyright (C) 2009, Google Inc.
6 * Redistribution and use in source and binary forms, with or
7 * without modification, are permitted provided that the following
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * - Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
18 * - Neither the name of the Git Development Community nor the
19 * names of its contributors may be used to endorse or promote
20 * products derived from this software without specific prior
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
24 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
25 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
28 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
33 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
35 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 package org
.spearce
.jgit
.lib
;
40 /** Configuration parameters for {@link WindowCache}. */
41 public class WindowCacheConfig
{
42 /** 1024 (number of bytes in one kibibyte/kilobyte) */
43 public static final int KB
= 1024;
45 /** 1024 {@link #KB} (number of bytes in one mebibyte/megabyte) */
46 public static final int MB
= 1024 * KB
;
48 private int packedGitLimit
;
50 private int packedGitWindowSize
;
52 private boolean packedGitMMAP
;
54 private int deltaBaseCacheLimit
;
56 /** Create a default configuration. */
57 public WindowCacheConfig() {
58 packedGitLimit
= 10 * MB
;
59 packedGitWindowSize
= 8 * KB
;
60 packedGitMMAP
= false;
61 deltaBaseCacheLimit
= 10 * MB
;
65 * @return maximum number bytes of heap memory to dedicate to caching pack
66 * file data. <b>Default is 10 MB.</b>
68 public int getPackedGitLimit() {
69 return packedGitLimit
;
74 * maximum number bytes of heap memory to dedicate to caching
77 public void setPackedGitLimit(final int newLimit
) {
78 packedGitLimit
= newLimit
;
82 * @return size in bytes of a single window mapped or read in from the pack
83 * file. <b>Default is 8 KB.</b>
85 public int getPackedGitWindowSize() {
86 return packedGitWindowSize
;
91 * size in bytes of a single window read in from the pack file.
93 public void setPackedGitWindowSize(final int newSize
) {
94 packedGitWindowSize
= newSize
;
98 * @return true enables use of Java NIO virtual memory mapping for windows;
99 * false reads entire window into a byte[] with standard read calls.
100 * <b>Default false.</b>
102 public boolean isPackedGitMMAP() {
103 return packedGitMMAP
;
108 * true enables use of Java NIO virtual memory mapping for
109 * windows; false reads entire window into a byte[] with standard
112 public void setPackedGitMMAP(final boolean usemmap
) {
113 packedGitMMAP
= usemmap
;
117 * @return maximum number of bytes to cache in {@link UnpackedObjectCache}
118 * for inflated, recently accessed objects, without delta chains.
119 * <b>Default 10 MB.</b>
121 public int getDeltaBaseCacheLimit() {
122 return deltaBaseCacheLimit
;
127 * maximum number of bytes to cache in
128 * {@link UnpackedObjectCache} for inflated, recently accessed
129 * objects, without delta chains.
131 public void setDeltaBaseCacheLimit(final int newLimit
) {
132 deltaBaseCacheLimit
= newLimit
;