code-enhancements after analysis with AppPerfect

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@307 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 20 years ago
parent cf171ca35d
commit a19541e563

@ -94,7 +94,7 @@ abstract class kelondroAbstractRA implements kelondroRA {
int ch3 = this.read();
int ch4 = this.read();
if ((ch1 | ch2 | ch3 | ch4) < 0) throw new IOException("kelondroAbstractRA.readInt: wrong values; ch1=" + ch1 + ", ch2=" + ch2 + ", ch3=" + ch3 + ", ch4=" + ch4);
return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
return ((ch1 << 24) | (ch2 << 16) | (ch3 << 8) | ch4);
}
public void writeInt(int v) throws IOException {
@ -122,7 +122,9 @@ abstract class kelondroAbstractRA implements kelondroRA {
private static final String crlf = new String(new byte[] {cr, lf});
public void writeLine(String line) throws IOException {
this.write((line + crlf).getBytes());
this.write(line.getBytes());
this.write(cr);
this.write(lf);
}
public String readLine() throws IOException {
@ -158,7 +160,9 @@ abstract class kelondroAbstractRA implements kelondroRA {
while (e.hasMoreElements()) {
key = (String) e.nextElement();
value = props.getProperty(key, "");
writeLine(key + "=" + value);
write(key.getBytes());
write((byte) '0');
writeLine(value);
}
writeLine("# EOF");
}
@ -171,7 +175,7 @@ abstract class kelondroAbstractRA implements kelondroRA {
while ((line = readLine()) != null) {
line = line.trim();
if (line.equals("# EOF")) return props;
if ((line.length() == 0) || (line.startsWith("#"))) continue;
if ((line.length() == 0) || (line.charAt(0) == '#')) continue;
pos = line.indexOf("=");
if (pos < 0) continue;
props.setProperty(line.substring(0, pos).trim(), line.substring(pos + 1).trim());
@ -200,7 +204,7 @@ abstract class kelondroAbstractRA implements kelondroRA {
while ((line = readLine()) != null) { // very slow readLine????
line = line.trim();
if (line.equals("# EOF")) return map;
if ((line.length() == 0) || (line.startsWith("#"))) continue;
if ((line.length() == 0) || (line.charAt(0) == '#')) continue;
pos = line.indexOf("=");
if (pos < 0) continue;
map.put(line.substring(0, pos), line.substring(pos + 1));

@ -145,10 +145,13 @@ public final class plasmaHTCache {
private String ageString(long date, File f) {
String s = Integer.toHexString(f.hashCode());
while (s.length() < 8) s = "0" + s;
s = Long.toHexString(date) + s;
while (s.length() < 24) s = "0" + s;
return s;
StringBuffer sb = new StringBuffer(32);
for (int i = s.length(); i < 8; i++) sb.append('0');
sb.append(s);
s = Long.toHexString(date);
for (int i = s.length(); i < 16; i++) sb.append('0');
sb.append(s);
return sb.toString();
}
public void cacheScan() {

@ -304,8 +304,11 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
File facilityDBpath = new File(getRootPath(), "DATA/SETTINGS/");
facilityDB = new kelondroTables(facilityDBpath);
facilityDB.declareMaps("backlinks", 250, 500, new String[] {"date"}, null);
log.logSystem("..opened backlinks");
facilityDB.declareMaps("zeitgeist", 40, 500);
log.logSystem("..opened zeitgeist");
facilityDB.declareTree("statistik", new int[]{11, 8, 8, 8, 8, 8, 8}, 0x400);
log.logSystem("..opened statistik");
facilityDB.update("statistik", (new serverDate()).toShortString(false).substring(0, 11), new long[]{1,2,3,4,5,6});
long[] testresult = facilityDB.selectLong("statistik", "yyyyMMddHHm");
testresult = facilityDB.selectLong("statistik", (new serverDate()).toShortString(false).substring(0, 11));

Loading…
Cancel
Save