~ubuntu-branches/ubuntu/hardy/libpgjava/hardy

« back to all changes in this revision

Viewing changes to src/interfaces/jdbc/org/postgresql/core/BytePoolDim2.java

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Vandyck
  • Date: 2005-04-21 14:25:11 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20050421142511-wibh5vc31fkrorx7
Tags: 7.4.7-3
Built with sources...

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package org.postgresql.core;
2
 
 
3
 
public class BytePoolDim2
4
 
{
5
 
        int maxsize = 32;
6
 
        ObjectPool notusemap[] = new ObjectPool[maxsize + 1];
7
 
        ObjectPool inusemap[] = new ObjectPool[maxsize + 1];
8
 
 
9
 
        public BytePoolDim2()
10
 
        {
11
 
                for (int i = 0; i <= maxsize; i++)
12
 
                {
13
 
                        inusemap[i] = new SimpleObjectPool();
14
 
                        notusemap[i] = new SimpleObjectPool();
15
 
                }
16
 
        }
17
 
 
18
 
        public byte[][] allocByte(int size)
19
 
        {
20
 
                // For now until the bug can be removed
21
 
                return new byte[size][0];
22
 
                /*
23
 
                                if (size > maxsize){
24
 
                                return new byte[size][0];
25
 
                        }
26
 
                                ObjectPool not_usel = notusemap[size];
27
 
                                ObjectPool in_usel =  inusemap[size];
28
 
 
29
 
                                byte b[][] = null;
30
 
 
31
 
                                if (!not_usel.isEmpty()) {
32
 
                                Object o = not_usel.remove();
33
 
                                b = (byte[][]) o;
34
 
                        } else
35
 
                                b = new byte[size][0];
36
 
                                in_usel.add(b);
37
 
                                return b;
38
 
                */
39
 
        }
40
 
 
41
 
        public void release(byte[][] b)
42
 
        {
43
 
                if (b.length > maxsize)
44
 
                {
45
 
                        return;
46
 
                }
47
 
                ObjectPool not_usel = notusemap[b.length];
48
 
                ObjectPool in_usel = inusemap[b.length];
49
 
 
50
 
                in_usel.remove(b);
51
 
                not_usel.add(b);
52
 
        }
53
 
 
54
 
        /*
55
 
         * Deallocate the object cache.
56
 
         * PM 17/01/01: Commented out this code as it blows away any hope of
57
 
         * multiple queries on the same connection. I'll redesign the allocation
58
 
         * code to use some form of Statement context, so the buffers are per
59
 
         * Statement and not per Connection/PG_Stream as it is now.
60
 
         */
61
 
        public void deallocate()
62
 
        {
63
 
                //for(int i = 0; i <= maxsize; i++){
64
 
                //        notusemap[i].addAll(inusemap[i]);
65
 
                //        inusemap[i].clear();
66
 
                //}
67
 
        }
68
 
}
69