added a deletion button to indexControlRWIs that deletes the complete web index

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4847 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 17 years ago
parent 01b3e9431a
commit 25192e0d36

@ -24,6 +24,16 @@
</dd> </dd>
</dl> </dl>
</fieldset> </fieldset>
</form>
<form action="IndexControlRWIs_p.html" method="post" enctype="multipart/form-data">
<fieldset><legend>Cleanup</legend>
<dl>
<dt class="TableCellDark">Index Deletion<br />(deletes all words and all urls)</dt>
<dd><input type="submit" name="deletecomplete" value="Delete index" onclick="return confirm('Confirm: You want to delete the complete index?')"/>
</dd>
</dl>
</fieldset>
</form> </form>
#(searchresult)#:: #(searchresult)#::

@ -105,6 +105,12 @@ public class IndexControlRWIs_p {
} }
} }
// delete everything
if (post.containsKey("deletecomplete")) {
sb.webIndex.clear();
post.remove("deletecomplete");
}
// delete word // delete word
if (post.containsKey("keyhashdeleteall")) { if (post.containsKey("keyhashdeleteall")) {
if (delurl || delurlref) { if (delurl || delurlref) {

@ -72,7 +72,7 @@ public class CrawlProfile {
profileTable = new kelondroMapObjects(dyn, 500); profileTable = new kelondroMapObjects(dyn, 500);
} }
public void resetDatabase() { public void clear() {
// deletes the profile database and creates a new one // deletes the profile database and creates a new one
if (profileTable != null) profileTable.close(); if (profileTable != null) profileTable.close();
if (!(profileTableFile.delete())) throw new RuntimeException("cannot delete crawl profile database"); if (!(profileTableFile.delete())) throw new RuntimeException("cannot delete crawl profile database");
@ -110,7 +110,7 @@ public class CrawlProfile {
try { try {
return handleIterator.hasNext(); return handleIterator.hasNext();
} catch (kelondroException e) { } catch (kelondroException e) {
resetDatabase(); clear();
return false; return false;
} }
} }
@ -119,7 +119,7 @@ public class CrawlProfile {
lastkey = (String) handleIterator.next(); lastkey = (String) handleIterator.next();
return getEntry(lastkey); return getEntry(lastkey);
} catch (kelondroException e) { } catch (kelondroException e) {
resetDatabase(); clear();
return null; return null;
} }
} }
@ -127,7 +127,7 @@ public class CrawlProfile {
if (lastkey != null) try { if (lastkey != null) try {
removeEntry(lastkey); removeEntry(lastkey);
} catch (kelondroException e) { } catch (kelondroException e) {
resetDatabase(); clear();
} }
} }
} }
@ -143,7 +143,7 @@ public class CrawlProfile {
try { try {
profileTable.set(ne.handle(), ne.map()); profileTable.set(ne.handle(), ne.map());
} catch (kelondroException e) { } catch (kelondroException e) {
resetDatabase(); clear();
try { try {
profileTable.set(ne.handle(), ne.map()); profileTable.set(ne.handle(), ne.map());
} catch (IOException ee) { } catch (IOException ee) {
@ -151,7 +151,7 @@ public class CrawlProfile {
System.exit(0); System.exit(0);
} }
} catch (IOException e) { } catch (IOException e) {
resetDatabase(); clear();
try { try {
profileTable.set(ne.handle(), ne.map()); profileTable.set(ne.handle(), ne.map());
} catch (IOException ee) { } catch (IOException ee) {
@ -182,7 +182,7 @@ public class CrawlProfile {
try { try {
profileTable.set(ne.handle(), ne.map()); profileTable.set(ne.handle(), ne.map());
} catch (kelondroException e) { } catch (kelondroException e) {
resetDatabase(); clear();
try { try {
profileTable.set(ne.handle(), ne.map()); profileTable.set(ne.handle(), ne.map());
} catch (IOException ee) { } catch (IOException ee) {
@ -190,7 +190,7 @@ public class CrawlProfile {
System.exit(0); System.exit(0);
} }
} catch (IOException e) { } catch (IOException e) {
resetDatabase(); clear();
try { try {
profileTable.set(ne.handle(), ne.map()); profileTable.set(ne.handle(), ne.map());
} catch (IOException ee) { } catch (IOException ee) {

@ -59,6 +59,14 @@ public class indexCollectionRI implements indexRI {
} }
} }
public void clear() {
try {
collectionIndex.clear();
} catch (IOException e) {
e.printStackTrace();
}
}
public long getUpdateTime(String wordHash) { public long getUpdateTime(String wordHash) {
indexContainer entries = getContainer(wordHash, null); indexContainer entries = getContainer(wordHash, null);
if (entries == null) return 0; if (entries == null) return 0;

@ -88,6 +88,12 @@ public final class indexContainerHeap {
this.readOnlyMode = false; this.readOnlyMode = false;
} }
public void clear() throws IOException {
if (index != null) index.clear();
if (cache != null) cache.clear();
initWriteMode();
}
/** /**
* initializes the heap in read/write mode without reading of a dump first * initializes the heap in read/write mode without reading of a dump first
* another dump reading afterwards is not possible * another dump reading afterwards is not possible

@ -80,6 +80,21 @@ public final class indexRAMRI implements indexRI, indexRIReader {
} }
} }
/**
* clear the content
* @throws IOException
*/
public void clear() {
hashScore.clear();
hashDate.clear();
initTime = System.currentTimeMillis();
try {
heap.clear();
} catch (IOException e) {
e.printStackTrace();
}
}
public int minMem() { public int minMem() {
// there is no specific large array that needs to be maintained // there is no specific large array that needs to be maintained
// this value is just a guess of the possible overhead // this value is just a guess of the possible overhead
@ -280,5 +295,8 @@ public final class indexRAMRI implements indexRI, indexRIReader {
} catch (IOException e){ } catch (IOException e){
log.logSevere("unable to dump cache: " + e.getMessage(), e); log.logSevere("unable to dump cache: " + e.getMessage(), e);
} }
heap = null;
hashScore.clear();
hashDate.clear();
} }
} }

@ -45,6 +45,7 @@ public interface indexRI {
public boolean removeEntry(String wordHash, String urlHash); public boolean removeEntry(String wordHash, String urlHash);
public int removeEntries(String wordHash, Set<String> urlHashes); public int removeEntries(String wordHash, Set<String> urlHashes);
public void addEntries(indexContainer newEntries); public void addEntries(indexContainer newEntries);
public void clear();
public void close(); public void close();
} }

@ -64,6 +64,11 @@ public final class indexRepositoryReference {
urlIndexFile = new kelondroSplitTable(this.location, "urls", indexURLReference.rowdef, false); urlIndexFile = new kelondroSplitTable(this.location, "urls", indexURLReference.rowdef, false);
} }
public void clear() throws IOException {
if (exportthread != null) exportthread.interrupt();
urlIndexFile.clear();
}
public int size() { public int size() {
return urlIndexFile.size(); return urlIndexFile.size();
} }

@ -403,7 +403,7 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {
writeOrderType(); writeOrderType();
} }
public void reset() throws IOException { public void clear() throws IOException {
kelondroRA ra = this.entryFile.getRA(); kelondroRA ra = this.entryFile.getRA();
File f = new File(ra.name()); File f = new File(ra.name());
this.entryFile.close(); this.entryFile.close();

@ -49,6 +49,10 @@ public class kelondroBytesLongMap {
return index.row(); return index.row();
} }
public void clear() throws IOException {
index.clear();
}
public synchronized long getl(byte[] key) throws IOException { public synchronized long getl(byte[] key) throws IOException {
assert (key != null); assert (key != null);
kelondroRow.Entry indexentry = index.get(key); kelondroRow.Entry indexentry = index.get(key);

@ -431,8 +431,8 @@ public class kelondroCache implements kelondroIndex {
return index.filename(); return index.filename();
} }
public void reset() throws IOException { public void clear() throws IOException {
this.index.reset(); this.index.clear();
init(); init();
} }

@ -170,6 +170,13 @@ public class kelondroCollectionIndex {
} }
} }
public void clear() throws IOException {
index.clear();
for (kelondroFixedWidthArray array: arrays.values()) {
array.clear();
}
}
private void openAllArrayFiles(boolean indexGeneration, kelondroByteOrder indexOrder) throws IOException { private void openAllArrayFiles(boolean indexGeneration, kelondroByteOrder indexOrder) throws IOException {
String[] list = this.path.list(); String[] list = this.path.list();

@ -123,9 +123,9 @@ public class kelondroDyn {
} }
} }
public void reset() throws IOException { public void clear() throws IOException {
String name = this.index.filename(); String name = this.index.filename();
this.index.reset(); this.index.clear();
this.buffer = new kelondroObjectBuffer(name); this.buffer = new kelondroObjectBuffer(name);
} }

@ -516,7 +516,7 @@ public class kelondroEcoTable implements kelondroIndex {
return lr; return lr;
} }
public void reset() throws IOException { public void clear() throws IOException {
File f = file.filename(); File f = file.filename();
file.close(); file.close();
f.delete(); f.delete();

@ -129,7 +129,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
} }
} }
public void reset() throws IOException { public void clear() throws IOException {
super.reset(); super.reset();
RAMIndex = true; RAMIndex = true;
index = new kelondroBytesIntMap(super.row().column(0).cellwidth, super.rowdef.objectOrder, 0); index = new kelondroBytesIntMap(super.row().column(0).cellwidth, super.rowdef.objectOrder, 0);

@ -73,6 +73,6 @@ public interface kelondroIndex {
public kelondroRow.Entry removeOne() throws IOException; public kelondroRow.Entry removeOne() throws IOException;
public kelondroCloneableIterator<byte[]> keys(boolean up, byte[] firstKey) throws IOException; // iterates only the key public kelondroCloneableIterator<byte[]> keys(boolean up, byte[] firstKey) throws IOException; // iterates only the key
public kelondroCloneableIterator<kelondroRow.Entry> rows(boolean up, byte[] firstKey) throws IOException; // iterates the whole row public kelondroCloneableIterator<kelondroRow.Entry> rows(boolean up, byte[] firstKey) throws IOException; // iterates the whole row
public void clear() throws IOException;
public void close(); public void close();
public void reset() throws IOException;
} }

@ -62,6 +62,13 @@ public final class kelondroMScoreCluster<E> {
encnt = 0; encnt = 0;
} }
public void clear() {
refkeyDB.clear();
keyrefDB.clear();
gcount = 0;
encnt = 0;
}
public static final String shortDateFormatString = "yyyyMMddHHmmss"; public static final String shortDateFormatString = "yyyyMMddHHmmss";
public static final SimpleDateFormat shortFormatter = new SimpleDateFormat(shortDateFormatString); public static final SimpleDateFormat shortFormatter = new SimpleDateFormat(shortDateFormatString);
public static final long minutemillis = 60000; public static final long minutemillis = 60000;

@ -145,8 +145,8 @@ public class kelondroMapObjects extends kelondroObjects {
if (doubleaccfields != null) for (int i = 0; i < doubleaccfields.length; i++) accMap.put(doubleaccfields[i], doubleaccumulator[i]); if (doubleaccfields != null) for (int i = 0; i < doubleaccfields.length; i++) accMap.put(doubleaccfields[i], doubleaccumulator[i]);
} }
public void reset() throws IOException { public void clear() throws IOException {
super.reset(); super.clear();
if (sortfields == null) sortClusterMap = null; else { if (sortfields == null) sortClusterMap = null; else {
sortClusterMap = new HashMap<String, kelondroMScoreCluster<String>>(); sortClusterMap = new HashMap<String, kelondroMScoreCluster<String>>();
for (int i = 0; i < sortfields.length; i++) { for (int i = 0; i < sortfields.length; i++) {

@ -48,8 +48,8 @@ public class kelondroObjects {
this.cachesize = cachesize; this.cachesize = cachesize;
} }
public void reset() throws IOException { public void clear() throws IOException {
this.dyn.reset(); this.dyn.clear();
this.cache = new HashMap<String, kelondroObjectsEntry>(); this.cache = new HashMap<String, kelondroObjectsEntry>();
this.cacheScore = new kelondroMScoreCluster<String>(); this.cacheScore = new kelondroMScoreCluster<String>();
} }

@ -43,7 +43,7 @@ public class kelondroRAMIndex implements kelondroIndex {
reset(initialspace); reset(initialspace);
} }
public void reset() { public void clear() {
reset(0); reset(0);
} }

@ -297,7 +297,7 @@ public class kelondroSQLTable implements kelondroIndex {
return new int[]{0,0,0,0,0,0,0,0,0,0}; return new int[]{0,0,0,0,0,0,0,0,0,0};
} }
public void reset() { public void clear() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }

@ -143,7 +143,7 @@ public class kelondroSplitTable implements kelondroIndex {
} }
} }
public void reset() throws IOException { public void clear() throws IOException {
this.close(); this.close();
String[] l = path.list(); String[] l = path.list();
for (int i = 0; i < l.length; i++) { for (int i = 0; i < l.length; i++) {

@ -159,8 +159,8 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
super.setLogger(log); super.setLogger(log);
} }
public void reset() throws IOException { public void clear() throws IOException {
super.reset(); super.clear();
setHandle(root, null); setHandle(root, null);
} }

@ -54,6 +54,8 @@ import java.util.Vector;
*/ */
public class LanguageStatisticsHolder extends Vector<LanguageStatistics> { public class LanguageStatisticsHolder extends Vector<LanguageStatistics> {
private static final long serialVersionUID = -887517724227204705L;
private String languageDir = "langstats"; // directory that contains language files private String languageDir = "langstats"; // directory that contains language files
private static LanguageStatisticsHolder instance; private static LanguageStatisticsHolder instance;

@ -190,6 +190,17 @@ public final class plasmaWordIndex implements indexRI {
newsPool = new yacyNewsPool(networkRoot); newsPool = new yacyNewsPool(networkRoot);
} }
public void clear() {
dhtInCache.clear();
dhtOutCache.clear();
collections.clear();
try {
referenceURL.clear();
} catch (IOException e) {
e.printStackTrace();
}
queuePreStack.clear();
}
private void initActiveCrawlProfiles() { private void initActiveCrawlProfiles() {
this.defaultProxyProfile = null; this.defaultProxyProfile = null;
@ -213,7 +224,7 @@ public final class plasmaWordIndex implements indexRI {
if (name.equals(CRAWL_PROFILE_SNIPPET_GLOBAL_MEDIA)) this.defaultMediaSnippetGlobalProfile = profile; if (name.equals(CRAWL_PROFILE_SNIPPET_GLOBAL_MEDIA)) this.defaultMediaSnippetGlobalProfile = profile;
} }
} catch (Exception e) { } catch (Exception e) {
this.profilesActiveCrawls.resetDatabase(); this.profilesActiveCrawls.clear();
this.defaultProxyProfile = null; this.defaultProxyProfile = null;
this.defaultRemoteProfile = null; this.defaultRemoteProfile = null;
this.defaultTextSnippetLocalProfile = null; this.defaultTextSnippetLocalProfile = null;

@ -1031,7 +1031,7 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {
// eergency reset // eergency reset
yacyCore.log.logSevere("seed-db emergency reset", e); yacyCore.log.logSevere("seed-db emergency reset", e);
try { try {
database.reset(); database.clear();
nextSeed = null; nextSeed = null;
return null; return null;
} catch (IOException e1) { } catch (IOException e1) {

Loading…
Cancel
Save