fix for problem with userDB and bookmarksDB which was caused by changes in kelondroRA in SVN 5376

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5385 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 17 years ago
parent 2c682d649b
commit e1acdb952c

@ -151,7 +151,6 @@ public class ConfigAccounts_p {
prop.put("text", "0"); prop.put("text", "0");
prop.put("error", "0"); prop.put("error", "0");
final String username=post.get("username"); final String username=post.get("username");
final String pw1=post.get("password"); final String pw1=post.get("password");
final String pw2=post.get("password2"); final String pw2=post.get("password2");
@ -191,7 +190,6 @@ public class ConfigAccounts_p {
prop.put("error", "3"); prop.put("error", "3");
} }
} else { //edit user } else { //edit user
entry = sb.userDB.getEntry(username); entry = sb.userDB.getEntry(username);
@ -223,6 +221,7 @@ public class ConfigAccounts_p {
int numUsers=0; int numUsers=0;
while(it.hasNext()){ while(it.hasNext()){
entry = it.next(); entry = it.next();
if (entry == null) continue;
prop.putHTML("users_"+numUsers+"_user", entry.getUserName()); prop.putHTML("users_"+numUsers+"_user", entry.getUserName());
numUsers++; numUsers++;
} }

@ -511,7 +511,8 @@ public class bookmarksDB {
Tag ret=null; Tag ret=null;
try { try {
map = tagsTable.get(hash); map = tagsTable.get(hash);
} catch (final IOException e) { } catch (final Exception e) {
e.printStackTrace();
return null; return null;
} }
if(map!=null){ if(map!=null){
@ -582,6 +583,7 @@ public class bookmarksDB {
try { try {
return new tagIterator(up); return new tagIterator(up);
} catch (final IOException e) { } catch (final IOException e) {
e.printStackTrace();
return new HashSet<Tag>().iterator(); return new HashSet<Tag>().iterator();
} }
} }
@ -1299,17 +1301,21 @@ public class bookmarksDB {
public boolean hasNext() { public boolean hasNext() {
try { try {
return this.tagIter.hasNext(); return this.tagIter.hasNext();
} catch (final kelondroException e) { } catch (final Exception e) {
//resetDatabase(); e.printStackTrace();
return false; return false;
} }
} }
public Tag next() { public Tag next() {
try { try {
return getTag(new String(this.tagIter.next())); byte[] b = this.tagIter.next();
} catch (final kelondroException e) { String s = new String(b);
//resetDatabase(); //System.out.println("### DEBUG tagIterator - " + s);
Tag t = getTag(s);
return t;
} catch (final Exception e) {
e.printStackTrace();
return null; return null;
} }
} }
@ -1349,7 +1355,8 @@ public class bookmarksDB {
public Bookmark next() { public Bookmark next() {
try { try {
return getBookmark(new String(this.bookmarkIter.next())); String s = new String(this.bookmarkIter.next());
return getBookmark(s);
} catch (final kelondroException e) { } catch (final kelondroException e) {
//resetDatabase(); //resetDatabase();
return null; return null;

@ -51,14 +51,14 @@ abstract class kelondroAbstractRA implements kelondroRA {
// pseudo-native methods: // pseudo-native methods:
abstract public void readFully(byte[] b, int off, int len) throws IOException; abstract public void readFully(byte[] b, int off, int len) throws IOException;
abstract public long length() throws IOException; abstract public long length() throws IOException;
abstract public long available() throws IOException; abstract public int available() throws IOException;
abstract public void write(byte[] b, int off, int len) throws IOException; abstract public void write(byte[] b, int off, int len) throws IOException;
abstract public void seek(long pos) throws IOException; abstract public void seek(long pos) throws IOException;
abstract public void close() throws IOException; abstract public void close() throws IOException;
// derived methods: // derived methods:
public byte[] readFully() throws IOException { public byte[] readFully() throws IOException {
int a = (int) this.available(); int a = this.available();
if (a <= 0) return null; if (a <= 0) return null;
final byte[] buffer = new byte[a]; final byte[] buffer = new byte[a];
this.readFully(buffer, 0, a); this.readFully(buffer, 0, a);

@ -30,6 +30,12 @@ import java.io.IOException;
public interface kelondroBLOB { public interface kelondroBLOB {
/**
* return a name of the BLOB; can be the file name
* @return
*/
public String name();
/** /**
* ask for the length of the primary key * ask for the length of the primary key
* @return the length of the key * @return the length of the key

@ -111,6 +111,10 @@ public class kelondroBLOBArray implements kelondroBLOB {
} }
} }
public String name() {
return this.heapLocation.getName();
}
public void setMaxAge(long maxAge) { public void setMaxAge(long maxAge) {
this.repositoryAgeMax = maxAge; this.repositoryAgeMax = maxAge;
this.fileAgeLimit = Math.min(oneMonth, maxAge / 10); this.fileAgeLimit = Math.min(oneMonth, maxAge / 10);

@ -83,6 +83,10 @@ public class kelondroBLOBBuffer extends Thread implements kelondroBLOB {
initQueues(compress); initQueues(compress);
} }
public String name() {
return this.backend.name();
}
public synchronized void clear() throws IOException { public synchronized void clear() throws IOException {
initQueues(this.compressedQueue != null); initQueues(this.compressedQueue != null);
this.backend.clear(); this.backend.clear();

@ -163,23 +163,28 @@ public final class kelondroBLOBHeap implements kelondroBLOB {
e.printStackTrace(); e.printStackTrace();
} }
// DEBUG
/* /*
// DEBUG
Iterator<byte[]> i = index.keys(true, null); Iterator<byte[]> i = index.keys(true, null);
byte[] b; //byte[] b;
int c = 0; int c = 0;
while (i.hasNext()) { while (i.hasNext()) {
key = i.next(); key = i.next();
System.out.println("KEY=" + new String(key)); System.out.println("*** DEBUG BLOBHeap " + this.name() + " KEY=" + new String(key));
b = get(key); //b = get(key);
System.out.println("BLOB=" + new String(b)); //System.out.println("BLOB=" + new String(b));
System.out.println(); //System.out.println();
c++; c++;
if (c >= 20) break;
} }
System.out.println("*** DEBUG - counted " + c + " BLOBs"); System.out.println("*** DEBUG - counted " + c + " BLOBs");
*/ */
} }
public String name() {
return this.heapFile.getName();
}
/** /**
* the number of BLOBs in the heap * the number of BLOBs in the heap
* @return the number of BLOBs in the heap * @return the number of BLOBs in the heap

@ -97,6 +97,31 @@ public class kelondroBLOBTree implements kelondroBLOB {
//this.segmentCount = 0; //this.segmentCount = 0;
//if (!(tree.fileExisted)) writeSegmentCount(); //if (!(tree.fileExisted)) writeSegmentCount();
buffer = new kelondroObjectBuffer(file.toString()); buffer = new kelondroObjectBuffer(file.toString());
/*
// debug
try {
kelondroCloneableIterator<byte[]> i = keys(true, false);
HashSet<String> t = new HashSet<String>();
while (i.hasNext()) {
byte[] b = i.next();
String s = new String(b);
t.add(s);
System.out.println("*** DEBUG BLOBTree " + file.getName() + " KEY=" + s);
}
Iterator<String> j = t.iterator();
while (j.hasNext()) {
String s = j.next();
byte[] r = this.get(s.getBytes());
if (r == null) System.out.println("*** DEBUG BLOBTree " + file.getName() + " KEY=" + s + " cannot be retrieved");
}
} catch (IOException e) {
e.printStackTrace();
}
*/
}
public String name() {
return this.file.getName();
} }
public static final void delete(final File file) { public static final void delete(final File file) {
@ -376,7 +401,8 @@ public class kelondroBLOBTree implements kelondroBLOB {
public class RARecord extends kelondroAbstractRA implements kelondroRA { public class RARecord extends kelondroAbstractRA implements kelondroRA {
int seekpos = 0; int seekpos = 0;
int compLength = -1;
String filekey; String filekey;
public RARecord(final String filekey) { public RARecord(final String filekey) {
@ -384,11 +410,15 @@ public class kelondroBLOBTree implements kelondroBLOB {
} }
public long length() throws IOException { public long length() throws IOException {
return Long.MAX_VALUE; if (compLength >= 0) return compLength;
int p = 0;
while (get(filekey, p, reclen) != null) p+= reclen;
compLength = p-1;
return p-1;
} }
public long available() throws IOException { public int available() throws IOException {
return Long.MAX_VALUE; return (int) (length() - seekpos);
} }
public int read() throws IOException { public int read() throws IOException {
@ -436,7 +466,7 @@ public class kelondroBLOBTree implements kelondroBLOB {
if (args.length == 1) { if (args.length == 1) {
// open a db and list keys // open a db and list keys
try { try {
final kelondroBLOB kd = new kelondroBLOBTree(new File(args[0]), true, true, 4 ,100, '_', kelondroNaturalOrder.naturalOrder, false, false, true); final kelondroBLOB kd = new kelondroBLOBTree(new File(args[0]), true, true, 4 ,100, '_', kelondroNaturalOrder.naturalOrder, true, false, false);
System.out.println(kd.size() + " elements in DB"); System.out.println(kd.size() + " elements in DB");
final Iterator<byte[]> i = kd.keys(true, false); final Iterator<byte[]> i = kd.keys(true, false);
while (i.hasNext()) while (i.hasNext())

@ -45,8 +45,8 @@ public class kelondroBufferedRA extends kelondroAbstractRA implements kelondroRA
return this.sbb; return this.sbb;
} }
public long available() throws IOException { public int available() throws IOException {
return Long.MAX_VALUE - sbb.length(); return Integer.MAX_VALUE - sbb.length();
} }
public void close() throws IOException { public void close() throws IOException {

@ -53,8 +53,8 @@ public class kelondroCachedRA extends kelondroAbstractRA implements kelondroRA {
return ra.length(); return ra.length();
} }
public synchronized long available() throws IOException { public synchronized int available() throws IOException {
return ra.length() - seekpos; return (int) (ra.length() - seekpos);
} }
private int cacheElementNumber(final long address) { private int cacheElementNumber(final long address) {

@ -45,8 +45,8 @@ public final class kelondroChannelRA extends kelondroAbstractRA implements kelon
return channel.size(); return channel.size();
} }
public long available() throws IOException { public int available() throws IOException {
return channel.size() - channel.position(); return (int) (channel.size() - channel.position());
} }
public final void readFully(final byte[] b, final int off, final int len) throws IOException { public final void readFully(final byte[] b, final int off, final int len) throws IOException {

@ -42,8 +42,8 @@ public final class kelondroFileRA extends kelondroAbstractRA implements kelondro
return RAFile.length(); return RAFile.length();
} }
public long available() throws IOException { public int available() throws IOException {
return RAFile.length() - RAFile.getFilePointer(); return (int) (RAFile.length() - RAFile.getFilePointer());
} }
// pseudo-native method read // pseudo-native method read

@ -52,6 +52,29 @@ public class kelondroMap {
this.cacheScore = new kelondroMScoreCluster<String>(); this.cacheScore = new kelondroMScoreCluster<String>();
this.startup = System.currentTimeMillis(); this.startup = System.currentTimeMillis();
this.cachesize = cachesize; this.cachesize = cachesize;
/*
// debug
try {
kelondroCloneableIterator<byte[]> i = keys(true, false);
int c = 20;
HashSet<String> t = new HashSet<String>();
while (i.hasNext()) {
c--; if (c <= 0) break;
byte[] b = i.next();
String s = new String(b);
System.out.println("*** DEBUG kelondroMap " + blob.name() + " KEY=" + s);
t.add(s);
}
Iterator<String> j = t.iterator();
while (j.hasNext()) {
String s = j.next();
if (this.get(s) == null) System.out.println("*** DEBUG kelondroMap " + blob.name() + " KEY=" + s + " cannot be found.");
}
} catch (IOException e) {
e.printStackTrace();
}
*/
} }
/** /**

@ -43,7 +43,7 @@ public interface kelondroRA {
// pseudo-native methods: // pseudo-native methods:
public long length() throws IOException; public long length() throws IOException;
public long available() throws IOException; public int available() throws IOException;
public void readFully(byte[] b, int off, int len) throws IOException; public void readFully(byte[] b, int off, int len) throws IOException;

@ -1395,8 +1395,8 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
public static void main(final String[] args) { public static void main(final String[] args) {
//cmd(args); //cmd(args);
//iterationtest(); //iterationtest();
//bigtest(Integer.parseInt(args[0])); bigtest(Integer.parseInt(args[0]));
randomtest(Integer.parseInt(args[0])); //randomtest(Integer.parseInt(args[0]));
//smalltest(); //smalltest();
} }

Loading…
Cancel
Save