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 16 years ago
parent 2c682d649b
commit e1acdb952c

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

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

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

@ -30,6 +30,12 @@ import java.io.IOException;
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
* @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) {
this.repositoryAgeMax = maxAge;
this.fileAgeLimit = Math.min(oneMonth, maxAge / 10);

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

@ -163,23 +163,28 @@ public final class kelondroBLOBHeap implements kelondroBLOB {
e.printStackTrace();
}
// DEBUG
/*
// DEBUG
Iterator<byte[]> i = index.keys(true, null);
byte[] b;
//byte[] b;
int c = 0;
while (i.hasNext()) {
key = i.next();
System.out.println("KEY=" + new String(key));
b = get(key);
System.out.println("BLOB=" + new String(b));
System.out.println();
System.out.println("*** DEBUG BLOBHeap " + this.name() + " KEY=" + new String(key));
//b = get(key);
//System.out.println("BLOB=" + new String(b));
//System.out.println();
c++;
if (c >= 20) break;
}
System.out.println("*** DEBUG - counted " + c + " BLOBs");
*/
}
public String name() {
return this.heapFile.getName();
}
/**
* 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;
//if (!(tree.fileExisted)) writeSegmentCount();
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) {
@ -376,7 +401,8 @@ public class kelondroBLOBTree implements kelondroBLOB {
public class RARecord extends kelondroAbstractRA implements kelondroRA {
int seekpos = 0;
int compLength = -1;
String filekey;
public RARecord(final String filekey) {
@ -384,11 +410,15 @@ public class kelondroBLOBTree implements kelondroBLOB {
}
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 {
return Long.MAX_VALUE;
public int available() throws IOException {
return (int) (length() - seekpos);
}
public int read() throws IOException {
@ -436,7 +466,7 @@ public class kelondroBLOBTree implements kelondroBLOB {
if (args.length == 1) {
// open a db and list keys
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");
final Iterator<byte[]> i = kd.keys(true, false);
while (i.hasNext())

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

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

@ -45,8 +45,8 @@ public final class kelondroChannelRA extends kelondroAbstractRA implements kelon
return channel.size();
}
public long available() throws IOException {
return channel.size() - channel.position();
public int available() throws IOException {
return (int) (channel.size() - channel.position());
}
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();
}
public long available() throws IOException {
return RAFile.length() - RAFile.getFilePointer();
public int available() throws IOException {
return (int) (RAFile.length() - RAFile.getFilePointer());
}
// pseudo-native method read

@ -52,6 +52,29 @@ public class kelondroMap {
this.cacheScore = new kelondroMScoreCluster<String>();
this.startup = System.currentTimeMillis();
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:
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;

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

Loading…
Cancel
Save