replaced non-generic array with collection

pull/1/head
Michael Peter Christen 13 years ago
parent 4de50fe808
commit 1481037820

@ -56,7 +56,7 @@ public final class InstantBusyThread extends AbstractBusyThread implements BusyT
// freemem is the name of a method that tries to free memory and returns void
final Class<?> theClass = (env instanceof Class<?>) ? (Class<?>) env : env.getClass();
try {
this.jobExecMethod = theClass.getMethod(jobExec, new Class[0]);
this.jobExecMethod = theClass.getMethod(jobExec);
} catch (final NoSuchMethodException e) {
throw new RuntimeException("serverInstantThread, wrong declaration of jobExec: " + e.getMessage());
}
@ -64,7 +64,7 @@ public final class InstantBusyThread extends AbstractBusyThread implements BusyT
if (jobCount == null)
this.jobCountMethod = null;
else
this.jobCountMethod = theClass.getMethod(jobCount, new Class[0]);
this.jobCountMethod = theClass.getMethod(jobCount);
} catch (final NoSuchMethodException e) {
throw new RuntimeException("serverInstantThread, wrong declaration of jobCount: " + e.getMessage());
@ -73,7 +73,7 @@ public final class InstantBusyThread extends AbstractBusyThread implements BusyT
if (freemem == null)
this.freememExecMethod = null;
else
this.freememExecMethod = theClass.getMethod(freemem, new Class[0]);
this.freememExecMethod = theClass.getMethod(freemem);
} catch (final NoSuchMethodException e) {
throw new RuntimeException("serverInstantThread, wrong declaration of freemem: " + e.getMessage());
@ -87,7 +87,7 @@ public final class InstantBusyThread extends AbstractBusyThread implements BusyT
public int getJobCount() {
if (this.jobCountMethod == null) return Integer.MAX_VALUE;
try {
final Object result = this.jobCountMethod.invoke(this.environment, new Object[0]);
final Object result = this.jobCountMethod.invoke(this.environment);
if (result instanceof Integer)
return ((Integer) result).intValue();
else
@ -109,7 +109,7 @@ public final class InstantBusyThread extends AbstractBusyThread implements BusyT
synchronized(jobs) {jobs.put(this.handle, getName());}
boolean jobHasDoneSomething = false;
try {
final Object result = this.jobExecMethod.invoke(this.environment, new Object[0]);
final Object result = this.jobExecMethod.invoke(this.environment);
if (result == null) jobHasDoneSomething = true;
else if (result instanceof Boolean) jobHasDoneSomething = ((Boolean) result).booleanValue();
} catch (final IllegalAccessException e) {
@ -143,7 +143,7 @@ public final class InstantBusyThread extends AbstractBusyThread implements BusyT
public void freemem() {
if (this.freememExecMethod == null) return;
try {
this.freememExecMethod.invoke(this.environment, new Object[0]);
this.freememExecMethod.invoke(this.environment);
} catch (final IllegalAccessException e) {
Log.logSevere("BUSYTHREAD", "Internal Error in serverInstantThread.freemem: " + e.getMessage());
Log.logSevere("BUSYTHREAD", "shutting down thread '" + getName() + "'");

@ -582,7 +582,6 @@ public final class Protocol
null);
}
@SuppressWarnings("unchecked")
public static int search(
final Seed mySeed,
final String wordhashes,
@ -672,15 +671,13 @@ public final class Protocol
// create containers
final int words = wordhashes.length() / Word.commonHashLength;
assert words > 0 : "wordhashes = " + wordhashes;
final ReferenceContainer<WordReference>[] container = new ReferenceContainer[words];
final List<ReferenceContainer<WordReference>> container = new ArrayList<ReferenceContainer<WordReference>>(words);
for ( int i = 0; i < words; i++ ) {
try {
container[i] =
ReferenceContainer.emptyContainer(
container.add(ReferenceContainer.emptyContainer(
Segment.wordReferenceFactory,
ASCII.getBytes(wordhashes.substring(i * Word.commonHashLength, (i + 1)
* Word.commonHashLength)),
count);
ASCII.getBytes(wordhashes.substring(i * Word.commonHashLength, (i + 1) * Word.commonHashLength)),
count));
} catch ( final RowSpaceExceededException e ) {
Log.logException(e);
return -1;
@ -774,9 +771,9 @@ public final class Protocol
}
// add the url entry to the word indexes
for ( int m = 0; m < words; m++ ) {
for ( final ReferenceContainer<WordReference> c : container ) {
try {
container[m].add(entry);
c.add(entry);
} catch ( final RowSpaceExceededException e ) {
Log.logException(e);
break;
@ -787,7 +784,7 @@ public final class Protocol
// store remote result to local result container
// insert one container into the search result buffer
// one is enough, only the references are used, not the word
containerCache.add(container[0], false, target.getName() + "/" + target.hash, result.joincount, true, time);
containerCache.add(container.get(0), false, target.getName() + "/" + target.hash, result.joincount, true, time);
containerCache.addExpectedRemoteReferences(-count);
// insert the containers to the index
@ -802,7 +799,7 @@ public final class Protocol
Network.log.logInfo("remote search: peer "
+ target.getName()
+ " sent "
+ container[0].size()
+ container.get(0).size()
+ "/"
+ result.joincount
+ " references for "

Loading…
Cancel
Save