removed warnings

pull/1/head
Michael Peter Christen 13 years ago
parent 8c099d2106
commit 4d29f59a27

@ -13,7 +13,6 @@ import de.anomic.data.UserDB;
import de.anomic.data.ymark.YMarkCrawlStart; import de.anomic.data.ymark.YMarkCrawlStart;
import de.anomic.data.ymark.YMarkDate; import de.anomic.data.ymark.YMarkDate;
import de.anomic.data.ymark.YMarkEntry; import de.anomic.data.ymark.YMarkEntry;
import de.anomic.data.ymark.YMarkRDF;
import de.anomic.data.ymark.YMarkTables; import de.anomic.data.ymark.YMarkTables;
import de.anomic.data.ymark.YMarkTables.TABLES; import de.anomic.data.ymark.YMarkTables.TABLES;
import de.anomic.data.ymark.YMarkUtil; import de.anomic.data.ymark.YMarkUtil;

@ -90,10 +90,7 @@ public class YMarkCrawlStart extends HashMap<String,String>{
} }
public boolean hasSchedule() { public boolean hasSchedule() {
if(!this.isEmpty() && this.date_next_exec.after(new Date())) return (!this.isEmpty() && this.date_next_exec.after(new Date()));
return true;
else
return false;
} }
public boolean isRunning(final CrawlSwitchboard crawler) { public boolean isRunning(final CrawlSwitchboard crawler) {

@ -267,7 +267,7 @@ public class dbtest {
System.out.println("*** YaCy Database Test"); System.out.println("*** YaCy Database Test");
// print out command line // print out command line
boolean assertionenabled = false; boolean assertionenabled = false;
assert assertionenabled = true; assert (assertionenabled = true) == true; // compare to true to remove warning: "Possible accidental assignement"
if (assertionenabled) System.out.println("*** Asserts are enabled"); else System.out.println("*** HINT: YOU SHOULD ENABLE ASSERTS! (include -ea in start arguments"); if (assertionenabled) System.out.println("*** Asserts are enabled"); else System.out.println("*** HINT: YOU SHOULD ENABLE ASSERTS! (include -ea in start arguments");
final long mb = MemoryControl.available() / 1024 / 1024; final long mb = MemoryControl.available() / 1024 / 1024;
System.out.println("*** RAM = " + mb + " MB"); System.out.println("*** RAM = " + mb + " MB");

@ -39,19 +39,19 @@ import de.anomic.data.ymark.YMarkUtil;
public class TablesColumnBLOBIndex extends TablesColumnIndex{ public class TablesColumnBLOBIndex extends TablesColumnIndex{
// Map<ColumnName, Map<ColumnValue, T<PrimaryKey>>> // Map<ColumnName, Map<ColumnValue, T<PrimaryKey>>>
private final BEncodedHeap index; private final BEncodedHeap index;
private final static byte SEPERATOR = (byte) ','; private final static byte SEPERATOR = (byte) ',';
public TablesColumnBLOBIndex(final BEncodedHeap bheap) { public TablesColumnBLOBIndex(final BEncodedHeap bheap) {
super(TablesColumnIndex.INDEXTYPE.BLOB); super(TablesColumnIndex.INDEXTYPE.BLOB);
this.index = bheap; this.index = bheap;
} }
public static Collection<byte[]> byteToCollection(final byte[] b) { public static Collection<byte[]> byteToCollection(final byte[] b) {
final Collection<byte[]> PKset = ByteBuffer.split(b, SEPERATOR); final Collection<byte[]> PKset = ByteBuffer.split(b, SEPERATOR);
return PKset; return PKset;
} }
public static byte[] CollectionToByte(final Collection<byte[]> bc) { public static byte[] CollectionToByte(final Collection<byte[]> bc) {
final ByteBuffer buf = new ByteBuffer(15 * bc.size()); final ByteBuffer buf = new ByteBuffer(15 * bc.size());
final Iterator<byte[]> iter = bc.iterator(); final Iterator<byte[]> iter = bc.iterator();
@ -59,9 +59,12 @@ public class TablesColumnBLOBIndex extends TablesColumnIndex{
buf.append(iter.next()); buf.append(iter.next());
buf.append(SEPERATOR); buf.append(SEPERATOR);
} }
return buf.getBytes(); byte[] b = buf.getBytes();
try {buf.close(); } catch (IOException e) {}
return b;
} }
@Override
public void deleteIndex(final String columnName) { public void deleteIndex(final String columnName) {
final byte[] column = YMarkUtil.getKeyId(columnName); final byte[] column = YMarkUtil.getKeyId(columnName);
try { try {
@ -72,16 +75,17 @@ public class TablesColumnBLOBIndex extends TablesColumnIndex{
Log.logException(e); Log.logException(e);
} }
} }
protected void insertPK(final String columnName, final String columnValue, final byte[] pk) { @Override
protected void insertPK(final String columnName, final String columnValue, final byte[] pk) {
Map<String, byte[]> valueIdxMap; Map<String, byte[]> valueIdxMap;
Collection<byte[]> PKset; Collection<byte[]> PKset;
final byte[] column = YMarkUtil.getKeyId(columnName); final byte[] column = YMarkUtil.getKeyId(columnName);
try { try {
valueIdxMap = this.index.get(column); valueIdxMap = this.index.get(column);
if(valueIdxMap != null) { if(valueIdxMap != null) {
if(valueIdxMap.containsKey(columnValue)) { if(valueIdxMap.containsKey(columnValue)) {
PKset = byteToCollection(valueIdxMap.get(columnValue)); PKset = byteToCollection(valueIdxMap.get(columnValue));
if(!ByteBuffer.contains(PKset, pk)) { if(!ByteBuffer.contains(PKset, pk)) {
PKset.add(pk); PKset.add(pk);
} }
@ -95,29 +99,30 @@ public class TablesColumnBLOBIndex extends TablesColumnIndex{
PKset.add(pk); PKset.add(pk);
valueIdxMap = new ConcurrentHashMap<String, byte[]>(); valueIdxMap = new ConcurrentHashMap<String, byte[]>();
} }
valueIdxMap.put(columnValue, CollectionToByte(PKset)); valueIdxMap.put(columnValue, CollectionToByte(PKset));
this.index.insert(column, valueIdxMap); this.index.insert(column, valueIdxMap);
return; return;
} catch (IOException e) { } catch (IOException e) {
Log.logException(e); Log.logException(e);
} catch (SpaceExceededException e) { } catch (SpaceExceededException e) {
Log.logException(e); Log.logException(e);
} }
} }
protected void removePK(final byte[] pk) { @Override
final Iterator<Map.Entry<byte[], Map<String, byte[]>>> niter = this.index.iterator(); protected void removePK(final byte[] pk) {
final Iterator<Map.Entry<byte[], Map<String, byte[]>>> niter = this.index.iterator();
while (niter.hasNext()) { while (niter.hasNext()) {
final Map.Entry<byte[], Map<String,byte[]>> entry = niter.next(); final Map.Entry<byte[], Map<String,byte[]>> entry = niter.next();
final Iterator<Map.Entry<String, byte[]>> viter = entry.getValue().entrySet().iterator(); final Iterator<Map.Entry<String, byte[]>> viter = entry.getValue().entrySet().iterator();
while(viter.hasNext()) { while(viter.hasNext()) {
final Map.Entry<String, byte[]> columnValue = viter.next(); final Map.Entry<String, byte[]> columnValue = viter.next();
final Collection<byte[]> PKset = byteToCollection(columnValue.getValue()); final Collection<byte[]> PKset = byteToCollection(columnValue.getValue());
ByteBuffer.remove(PKset, pk); ByteBuffer.remove(PKset, pk);
if(PKset.isEmpty()) { if(PKset.isEmpty()) {
viter.remove(); viter.remove();
} else { } else {
columnValue.setValue(CollectionToByte(PKset)); columnValue.setValue(CollectionToByte(PKset));
} }
} }
try { try {
@ -129,16 +134,19 @@ public class TablesColumnBLOBIndex extends TablesColumnIndex{
} }
} }
} }
public void clear() { @Override
public void clear() {
this.index.clear(); this.index.clear();
} }
public Collection<String> columns() { @Override
public Collection<String> columns() {
return this.index.columns(); return this.index.columns();
} }
public Set<String> keySet(final String columnName) { @Override
public Set<String> keySet(final String columnName) {
final byte[] column = YMarkUtil.getKeyId(columnName); final byte[] column = YMarkUtil.getKeyId(columnName);
// a TreeSet is used to get sorted set of keys (e.g. folders) // a TreeSet is used to get sorted set of keys (e.g. folders)
if(this.index.containsKey(column)) { if(this.index.containsKey(column)) {
@ -149,11 +157,12 @@ public class TablesColumnBLOBIndex extends TablesColumnIndex{
} catch (SpaceExceededException e) { } catch (SpaceExceededException e) {
Log.logException(e); Log.logException(e);
} }
} }
return new TreeSet<String>(); return new TreeSet<String>();
} }
public boolean containsKey(final String columnName, final String key) { @Override
public boolean containsKey(final String columnName, final String key) {
final byte[] column = YMarkUtil.getKeyId(columnName); final byte[] column = YMarkUtil.getKeyId(columnName);
if(this.index.containsKey(column)) { if(this.index.containsKey(column)) {
try { try {
@ -166,13 +175,15 @@ public class TablesColumnBLOBIndex extends TablesColumnIndex{
} }
return false; return false;
} }
public boolean hasIndex(final String columnName) { @Override
public boolean hasIndex(final String columnName) {
final byte[] column = YMarkUtil.getKeyId(columnName); final byte[] column = YMarkUtil.getKeyId(columnName);
return this.index.containsKey(column); return this.index.containsKey(column);
} }
public Collection<byte[]> get(final String columnName, final String key) { @Override
public Collection<byte[]> get(final String columnName, final String key) {
final byte[] column = YMarkUtil.getKeyId(columnName); final byte[] column = YMarkUtil.getKeyId(columnName);
// deserialize // deserialize
try { try {
@ -184,8 +195,9 @@ public class TablesColumnBLOBIndex extends TablesColumnIndex{
} }
return new ArrayList<byte[]>(); return new ArrayList<byte[]>();
} }
public int size(final String columnName) { @Override
public int size(final String columnName) {
final byte[] column = YMarkUtil.getKeyId(columnName); final byte[] column = YMarkUtil.getKeyId(columnName);
if(this.index.containsKey(column)) { if(this.index.containsKey(column)) {
try { try {
@ -197,9 +209,10 @@ public class TablesColumnBLOBIndex extends TablesColumnIndex{
} }
} }
return -1; return -1;
} }
public int size() { @Override
public int size() {
return this.index.size(); return this.index.size();
} }
} }

@ -131,6 +131,6 @@ public abstract class MemoryStrategy {
/** /**
* set the memory to be available for properState - StandardMemoryStrategy only * set the memory to be available for properState - StandardMemoryStrategy only
*/ */
protected void setProperMbyte(final long mbyte) { protected void setProperMbyte(@SuppressWarnings("unused") final long mbyte) {
} }
} }

@ -581,7 +581,7 @@ public final class SearchEvent {
public void run() { public void run() {
try { try {
boolean aquired; boolean aquired;
while ( aquired = this.trigger.tryAcquire(3000, TimeUnit.MILLISECONDS) ) { while ( (aquired = this.trigger.tryAcquire(3000, TimeUnit.MILLISECONDS)) == true ) { // compare to true to remove warning: "Possible accidental assignement"
if ( !aquired || MemoryControl.shortStatus()) { if ( !aquired || MemoryControl.shortStatus()) {
break; break;
} }

@ -587,7 +587,7 @@ public final class yacy {
// check assertion status // check assertion status
//ClassLoader.getSystemClassLoader().setDefaultAssertionStatus(true); //ClassLoader.getSystemClassLoader().setDefaultAssertionStatus(true);
boolean assertionenabled = false; boolean assertionenabled = false;
assert assertionenabled = true; assert (assertionenabled = true) == true; // compare to true to remove warning: "Possible accidental assignement"
if (assertionenabled) System.out.println("Asserts are enabled"); if (assertionenabled) System.out.println("Asserts are enabled");
// check memory amount // check memory amount

Loading…
Cancel
Save