mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-19 00:01:41 +02:00
small speed enhancement using a column factory
This commit is contained in:
parent
d10627d591
commit
6f8a2fef1f
|
@ -31,7 +31,7 @@ import java.io.Serializable;
|
||||||
|
|
||||||
import net.yacy.kelondro.util.kelondroException;
|
import net.yacy.kelondro.util.kelondroException;
|
||||||
|
|
||||||
public final class Column implements Serializable {
|
public final class Column implements Cloneable, Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID=6558500565023465301L;
|
private static final long serialVersionUID=6558500565023465301L;
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ public final class Column implements Serializable {
|
||||||
this.nickname = nickname;
|
this.nickname = nickname;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Column(String celldef) {
|
public Column(String celldef) {
|
||||||
// define column with column syntax
|
// define column with column syntax
|
||||||
// example: <UDate-3>
|
// example: <UDate-3>
|
||||||
|
@ -196,6 +196,24 @@ public final class Column implements Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* th clone method is useful to produce a similiar column with a different cell width
|
||||||
|
* @return the cloned Column
|
||||||
|
*/
|
||||||
|
public Object clone() {
|
||||||
|
return new Column(this.nickname, this.celltype, this.encoder, this.cellwidth, this.description);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* a column width may change when the object was not yet used.
|
||||||
|
* this applies to clones of Column objects which are used as Column producers
|
||||||
|
* @param cellwidth
|
||||||
|
*/
|
||||||
|
public void setCellwidth(int cellwidth) {
|
||||||
|
assert this.celltype == celltype_string || this.celltype == celltype_binary;
|
||||||
|
this.cellwidth = cellwidth;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
final StringBuilder s = new StringBuilder(20);
|
final StringBuilder s = new StringBuilder(20);
|
||||||
|
|
|
@ -169,10 +169,10 @@ public class RowCollection implements Sortable<Row.Entry>, Iterable<Row.Entry>,
|
||||||
return (int) (time / day) - 10957;
|
return (int) (time / day) - 10957;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Column exportColumn0, exportColumn1, exportColumn2, exportColumn3, exportColumn4;
|
private static Column exportColumn0, exportColumn1, exportColumn2, exportColumn3, exportColumn4, collectionColumnProducer;
|
||||||
|
|
||||||
protected static final long exportOverheadSize = 14;
|
protected static final long exportOverheadSize = 14;
|
||||||
|
|
||||||
private static Row exportRow(final int chunkcachelength) {
|
private static Row exportRow(final int chunkcachelength) {
|
||||||
/*
|
/*
|
||||||
return new Row(
|
return new Row(
|
||||||
|
@ -191,15 +191,17 @@ public class RowCollection implements Sortable<Row.Entry>, Iterable<Row.Entry>,
|
||||||
if (exportColumn2 == null) exportColumn2 = new Column("short lastwrote-2 {b256}");
|
if (exportColumn2 == null) exportColumn2 = new Column("short lastwrote-2 {b256}");
|
||||||
if (exportColumn3 == null) exportColumn3 = new Column("byte[] orderkey-2");
|
if (exportColumn3 == null) exportColumn3 = new Column("byte[] orderkey-2");
|
||||||
if (exportColumn4 == null) exportColumn4 = new Column("int orderbound-4 {b256}");
|
if (exportColumn4 == null) exportColumn4 = new Column("int orderbound-4 {b256}");
|
||||||
|
if (collectionColumnProducer == null) collectionColumnProducer = new Column("byte[] collection-1");
|
||||||
/*
|
/*
|
||||||
* because of a strange bug these objects cannot be initialized as normal
|
* because of a strange bug these objects cannot be initialized as normal
|
||||||
* static final. If I try that, they are not initialized and are assigned null. why?
|
* static final. If I try that, they are not initialized and are assigned null. why?
|
||||||
*/
|
*/
|
||||||
final StringBuilder colName = new StringBuilder(30);
|
|
||||||
colName.append("byte[] collection-").append(Integer.toString(chunkcachelength));
|
Column collectionColumn = (Column) collectionColumnProducer.clone();
|
||||||
|
collectionColumn.setCellwidth(chunkcachelength);
|
||||||
final Row er = new Row(new Column[]{
|
final Row er = new Row(new Column[]{
|
||||||
exportColumn0, exportColumn1, exportColumn2, exportColumn3, exportColumn4,
|
exportColumn0, exportColumn1, exportColumn2, exportColumn3, exportColumn4,
|
||||||
new Column(colName.toString())
|
collectionColumn
|
||||||
},
|
},
|
||||||
NaturalOrder.naturalOrder
|
NaturalOrder.naturalOrder
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user