Source Code Cross Referenced for kelondroObjectBuffer.java in  » Search-Engine » yacy » de » anomic » kelondro » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Search Engine » yacy » de.anomic.kelondro 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // kelondroObjectBuffer.java
002:        // ------------------------
003:        // (C) by Michael Peter Christen; mc@anomic.de
004:        // first published on http://www.anomic.de
005:        // Frankfurt, Germany, 2006
006:        //
007:        // This is a part of the kelondro database, which is a part of YaCy
008:        //
009:        // $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $
010:        // $LastChangedRevision: 1986 $
011:        // $LastChangedBy: orbiter $
012:        //
013:        //
014:        // LICENSE
015:        // 
016:        // This program is free software; you can redistribute it and/or modify
017:        // it under the terms of the GNU General Public License as published by
018:        // the Free Software Foundation; either version 2 of the License, or
019:        // (at your option) any later version.
020:        //
021:        // This program is distributed in the hope that it will be useful,
022:        // but WITHOUT ANY WARRANTY; without even the implied warranty of
023:        // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
024:        // GNU General Public License for more details.
025:        //
026:        // You should have received a copy of the GNU General Public License
027:        // along with this program; if not, write to the Free Software
028:        // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
029:        //
030:        //
031:        // A NOTE FROM THE AUTHOR TO THE USERS:
032:        //
033:        // Using this software in any meaning (reading, learning, copying, compiling,
034:        // running) means that you agree that the Author(s) is (are) not responsible
035:        // for cost, loss of data or any harm that may be caused directly or indirectly
036:        // by usage of this softare or this documentation. The usage of this software
037:        // is on your own risk. The installation and usage (starting/running) of this
038:        // software may allow other people or application to access your computer and
039:        // any attached devices and is highly dependent on the configuration of the
040:        // software which must be done by the user of the software; the author(s) is
041:        // (are) also not responsible for proper configuration and usage of the
042:        // software, even if provoked by documentation provided together with
043:        // the software.
044:        //
045:        // 
046:        // A NOTE FROM THE AUTHOR TO DEVELOPERS:
047:        //
048:        // Contributions and changes to the program code should be marked as such:
049:        // Please enter your own (C) notice below; they must be compatible with the GPL.
050:        // Please mark also all changes in the code; if you don't mark them then they
051:        // can't be identified; thus all unmarked code belong to the copyright holder
052:        // as mentioned above. A good documentation of code authorities will also help
053:        // to maintain the code and the project.
054:        // A re-distribution must contain the intact and unchanged copyright statement.
055:
056:        package de.anomic.kelondro;
057:
058:        public class kelondroObjectBuffer {
059:
060:            // this is a buffer for a single (only one) key/value object
061:            // without an index-backend
062:
063:            private int readHit, readMiss, writeUnique, writeDouble;
064:            private String name;
065:            private byte[] key;
066:            private Object value;
067:
068:            public kelondroObjectBuffer(String name) {
069:                this .name = name;
070:                this .readHit = 0;
071:                this .readMiss = 0;
072:                this .writeUnique = 0;
073:                this .writeDouble = 0;
074:                this .key = null;
075:                this .value = null;
076:            }
077:
078:            public String getName() {
079:                return name;
080:            }
081:
082:            public String[] status() {
083:                return new String[] { Integer.toString(readHit),
084:                        Integer.toString(readMiss),
085:                        Integer.toString(writeUnique),
086:                        Integer.toString(writeDouble) };
087:            }
088:
089:            private static String[] combinedStatus(String[] a, String[] b) {
090:                return new String[] {
091:                        Integer.toString(Integer.parseInt(a[0])
092:                                + Integer.parseInt(b[0])),
093:                        Integer.toString(Integer.parseInt(a[1])
094:                                + Integer.parseInt(b[1])),
095:                        Integer.toString(Integer.parseInt(a[2])
096:                                + Integer.parseInt(b[2])),
097:                        Integer.toString(Integer.parseInt(a[3])
098:                                + Integer.parseInt(b[3])) };
099:            }
100:
101:            public static String[] combinedStatus(String[][] a, int l) {
102:                if ((a == null) || (a.length == 0) || (l == 0))
103:                    return null;
104:                if ((a.length >= 1) && (l == 1))
105:                    return a[0];
106:                if ((a.length >= 2) && (l == 2))
107:                    return combinedStatus(a[0], a[1]);
108:                return combinedStatus(combinedStatus(a, l - 1), a[l - 1]);
109:            }
110:
111:            public void put(byte[] key, Object value) {
112:                if ((key == null) || (value == null))
113:                    return;
114:                synchronized (this ) {
115:                    if (kelondroNaturalOrder.equal(this .key, key)) {
116:                        this .writeDouble++;
117:                    } else {
118:                        this .writeUnique++;
119:                    }
120:                    this .key = key;
121:                    this .value = value;
122:                }
123:            }
124:
125:            public void put(String key, Object value) {
126:                if ((key == null) || (value == null))
127:                    return;
128:                synchronized (this ) {
129:                    if (kelondroNaturalOrder.equal(this .key, key.getBytes())) {
130:                        this .writeDouble++;
131:                    } else {
132:                        this .writeUnique++;
133:                    }
134:                    this .key = key.getBytes();
135:                    this .value = value;
136:                }
137:            }
138:
139:            public Object get(byte[] key) {
140:                if (key == null)
141:                    return null;
142:                synchronized (this ) {
143:                    if (kelondroNaturalOrder.equal(this .key, key)) {
144:                        this .readHit++;
145:                        return this .value;
146:                    } else {
147:                        this .readMiss++;
148:                        return null;
149:                    }
150:                }
151:            }
152:
153:            public Object get(String key) {
154:                if (key == null)
155:                    return null;
156:                synchronized (this ) {
157:                    if (kelondroNaturalOrder.equal(this .key, key.getBytes())) {
158:                        this .readHit++;
159:                        return this .value;
160:                    } else {
161:                        this .readMiss++;
162:                        return null;
163:                    }
164:                }
165:            }
166:
167:            public void remove(byte[] key) {
168:                if (key == null)
169:                    return;
170:                synchronized (this ) {
171:                    if (kelondroNaturalOrder.equal(this .key, key)) {
172:                        this .key = null;
173:                        this .value = null;
174:                    }
175:                }
176:            }
177:
178:            public void remove(String key) {
179:                if (key == null)
180:                    return;
181:                synchronized (this) {
182:                    if (kelondroNaturalOrder.equal(this.key, key.getBytes())) {
183:                        this.key = null;
184:                        this.value = null;
185:                    }
186:                }
187:            }
188:
189:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.