index
int64 | repo_id
string | file_path
string | content
string |
|---|---|---|---|
0
|
java-sources/ai/platon/pulsar/pulsar-persist/3.0.15/ai/platon/pulsar/persist/gora
|
java-sources/ai/platon/pulsar/pulsar-persist/3.0.15/ai/platon/pulsar/persist/gora/generated/GActiveDOMStat.java
|
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package ai.platon.pulsar.persist.gora.generated;
import org.apache.gora.persistency.Persistent;
public class GActiveDOMStat extends org.apache.gora.persistency.impl.PersistentBase implements org.apache.avro.specific.SpecificRecord, org.apache.gora.persistency.Persistent {
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"GActiveDOMStat\",\"namespace\":\"ai.platon.pulsar.persist.gora.generated\",\"fields\":[{\"name\":\"ni\",\"type\":\"int\",\"default\":0},{\"name\":\"na\",\"type\":\"int\",\"default\":0},{\"name\":\"nnm\",\"type\":\"int\",\"default\":0},{\"name\":\"nst\",\"type\":\"int\",\"default\":0},{\"name\":\"w\",\"type\":\"int\",\"default\":0},{\"name\":\"h\",\"type\":\"int\",\"default\":0}]}");
private static final long serialVersionUID = -526959596255254644L;
/** Enum containing all data bean's fields. */
public static enum Field {
NI(0, "ni"),
NA(1, "na"),
NNM(2, "nnm"),
NST(3, "nst"),
W(4, "w"),
H(5, "h"),
;
/**
* Field's index.
*/
private int index;
/**
* Field's name.
*/
private String name;
/**
* Field's constructor
* @param index field's index.
* @param name field's name.
*/
Field(int index, String name) {this.index=index;this.name=name;}
/**
* Gets field's index.
* @return int field's index.
*/
public int getIndex() {return index;}
/**
* Gets field's name.
* @return String field's name.
*/
public String getName() {return name;}
/**
* Gets field's attributes to string.
* @return String field's attributes to string.
*/
public String toString() {return name;}
};
public static final String[] _ALL_FIELDS = {
"ni",
"na",
"nnm",
"nst",
"w",
"h",
};
/**
* Gets the total field count.
* @return int field count
*/
public int getFieldsCount() {
return GActiveDOMStat._ALL_FIELDS.length;
}
@Override
public Persistent clone() {
return null;
}
private int ni;
private int na;
private int nnm;
private int nst;
private int w;
private int h;
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return ni;
case 1: return na;
case 2: return nnm;
case 3: return nst;
case 4: return w;
case 5: return h;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value) {
switch (field$) {
case 0: ni = (java.lang.Integer)(value); break;
case 1: na = (java.lang.Integer)(value); break;
case 2: nnm = (java.lang.Integer)(value); break;
case 3: nst = (java.lang.Integer)(value); break;
case 4: w = (java.lang.Integer)(value); break;
case 5: h = (java.lang.Integer)(value); break;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
/**
* Gets the value of the 'ni' field.
*/
public java.lang.Integer getNi() {
return ni;
}
/**
* Sets the value of the 'ni' field.
* @param value the value to set.
*/
public void setNi(java.lang.Integer value) {
this.ni = value;
setDirty(0);
}
/**
* Checks the dirty status of the 'ni' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isNiDirty() {
return isDirty(0);
}
/**
* Gets the value of the 'na' field.
*/
public java.lang.Integer getNa() {
return na;
}
/**
* Sets the value of the 'na' field.
* @param value the value to set.
*/
public void setNa(java.lang.Integer value) {
this.na = value;
setDirty(1);
}
/**
* Checks the dirty status of the 'na' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isNaDirty() {
return isDirty(1);
}
/**
* Gets the value of the 'nnm' field.
*/
public java.lang.Integer getNnm() {
return nnm;
}
/**
* Sets the value of the 'nnm' field.
* @param value the value to set.
*/
public void setNnm(java.lang.Integer value) {
this.nnm = value;
setDirty(2);
}
/**
* Checks the dirty status of the 'nnm' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isNnmDirty() {
return isDirty(2);
}
/**
* Gets the value of the 'nst' field.
*/
public java.lang.Integer getNst() {
return nst;
}
/**
* Sets the value of the 'nst' field.
* @param value the value to set.
*/
public void setNst(java.lang.Integer value) {
this.nst = value;
setDirty(3);
}
/**
* Checks the dirty status of the 'nst' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isNstDirty() {
return isDirty(3);
}
/**
* Gets the value of the 'w' field.
*/
public java.lang.Integer getW() {
return w;
}
/**
* Sets the value of the 'w' field.
* @param value the value to set.
*/
public void setW(java.lang.Integer value) {
this.w = value;
setDirty(4);
}
/**
* Checks the dirty status of the 'w' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isWDirty() {
return isDirty(4);
}
/**
* Gets the value of the 'h' field.
*/
public java.lang.Integer getH() {
return h;
}
/**
* Sets the value of the 'h' field.
* @param value the value to set.
*/
public void setH(java.lang.Integer value) {
this.h = value;
setDirty(5);
}
/**
* Checks the dirty status of the 'h' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isHDirty() {
return isDirty(5);
}
/** Creates a new GActiveDOMStat RecordBuilder */
public static ai.platon.pulsar.persist.gora.generated.GActiveDOMStat.Builder newBuilder() {
return new ai.platon.pulsar.persist.gora.generated.GActiveDOMStat.Builder();
}
/** Creates a new GActiveDOMStat RecordBuilder by copying an existing Builder */
public static ai.platon.pulsar.persist.gora.generated.GActiveDOMStat.Builder newBuilder(ai.platon.pulsar.persist.gora.generated.GActiveDOMStat.Builder other) {
return new ai.platon.pulsar.persist.gora.generated.GActiveDOMStat.Builder(other);
}
/** Creates a new GActiveDOMStat RecordBuilder by copying an existing GActiveDOMStat instance */
public static ai.platon.pulsar.persist.gora.generated.GActiveDOMStat.Builder newBuilder(ai.platon.pulsar.persist.gora.generated.GActiveDOMStat other) {
return new ai.platon.pulsar.persist.gora.generated.GActiveDOMStat.Builder(other);
}
private static java.nio.ByteBuffer deepCopyToReadOnlyBuffer(
java.nio.ByteBuffer input) {
java.nio.ByteBuffer copy = java.nio.ByteBuffer.allocate(input.capacity());
int position = input.position();
input.reset();
int mark = input.position();
int limit = input.limit();
input.rewind();
input.limit(input.capacity());
copy.put(input);
input.rewind();
copy.rewind();
input.position(mark);
input.mark();
copy.position(mark);
copy.mark();
input.position(position);
copy.position(position);
input.limit(limit);
copy.limit(limit);
return copy.asReadOnlyBuffer();
}
/**
* RecordBuilder for GActiveDOMStat instances.
*/
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<GActiveDOMStat>
implements org.apache.avro.data.RecordBuilder<GActiveDOMStat> {
private int ni;
private int na;
private int nnm;
private int nst;
private int w;
private int h;
/** Creates a new Builder */
private Builder() {
super(ai.platon.pulsar.persist.gora.generated.GActiveDOMStat.SCHEMA$);
}
/** Creates a Builder by copying an existing Builder */
private Builder(ai.platon.pulsar.persist.gora.generated.GActiveDOMStat.Builder other) {
super(other);
}
/** Creates a Builder by copying an existing GActiveDOMStat instance */
private Builder(ai.platon.pulsar.persist.gora.generated.GActiveDOMStat other) {
super(ai.platon.pulsar.persist.gora.generated.GActiveDOMStat.SCHEMA$);
if (isValidValue(fields()[0], other.ni)) {
this.ni = (java.lang.Integer) data().deepCopy(fields()[0].schema(), other.ni);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.na)) {
this.na = (java.lang.Integer) data().deepCopy(fields()[1].schema(), other.na);
fieldSetFlags()[1] = true;
}
if (isValidValue(fields()[2], other.nnm)) {
this.nnm = (java.lang.Integer) data().deepCopy(fields()[2].schema(), other.nnm);
fieldSetFlags()[2] = true;
}
if (isValidValue(fields()[3], other.nst)) {
this.nst = (java.lang.Integer) data().deepCopy(fields()[3].schema(), other.nst);
fieldSetFlags()[3] = true;
}
if (isValidValue(fields()[4], other.w)) {
this.w = (java.lang.Integer) data().deepCopy(fields()[4].schema(), other.w);
fieldSetFlags()[4] = true;
}
if (isValidValue(fields()[5], other.h)) {
this.h = (java.lang.Integer) data().deepCopy(fields()[5].schema(), other.h);
fieldSetFlags()[5] = true;
}
}
/** Gets the value of the 'ni' field */
public java.lang.Integer getNi() {
return ni;
}
/** Sets the value of the 'ni' field */
public ai.platon.pulsar.persist.gora.generated.GActiveDOMStat.Builder setNi(int value) {
validate(fields()[0], value);
this.ni = value;
fieldSetFlags()[0] = true;
return this;
}
/** Checks whether the 'ni' field has been set */
public boolean hasNi() {
return fieldSetFlags()[0];
}
/** Clears the value of the 'ni' field */
public ai.platon.pulsar.persist.gora.generated.GActiveDOMStat.Builder clearNi() {
fieldSetFlags()[0] = false;
return this;
}
/** Gets the value of the 'na' field */
public java.lang.Integer getNa() {
return na;
}
/** Sets the value of the 'na' field */
public ai.platon.pulsar.persist.gora.generated.GActiveDOMStat.Builder setNa(int value) {
validate(fields()[1], value);
this.na = value;
fieldSetFlags()[1] = true;
return this;
}
/** Checks whether the 'na' field has been set */
public boolean hasNa() {
return fieldSetFlags()[1];
}
/** Clears the value of the 'na' field */
public ai.platon.pulsar.persist.gora.generated.GActiveDOMStat.Builder clearNa() {
fieldSetFlags()[1] = false;
return this;
}
/** Gets the value of the 'nnm' field */
public java.lang.Integer getNnm() {
return nnm;
}
/** Sets the value of the 'nnm' field */
public ai.platon.pulsar.persist.gora.generated.GActiveDOMStat.Builder setNnm(int value) {
validate(fields()[2], value);
this.nnm = value;
fieldSetFlags()[2] = true;
return this;
}
/** Checks whether the 'nnm' field has been set */
public boolean hasNnm() {
return fieldSetFlags()[2];
}
/** Clears the value of the 'nnm' field */
public ai.platon.pulsar.persist.gora.generated.GActiveDOMStat.Builder clearNnm() {
fieldSetFlags()[2] = false;
return this;
}
/** Gets the value of the 'nst' field */
public java.lang.Integer getNst() {
return nst;
}
/** Sets the value of the 'nst' field */
public ai.platon.pulsar.persist.gora.generated.GActiveDOMStat.Builder setNst(int value) {
validate(fields()[3], value);
this.nst = value;
fieldSetFlags()[3] = true;
return this;
}
/** Checks whether the 'nst' field has been set */
public boolean hasNst() {
return fieldSetFlags()[3];
}
/** Clears the value of the 'nst' field */
public ai.platon.pulsar.persist.gora.generated.GActiveDOMStat.Builder clearNst() {
fieldSetFlags()[3] = false;
return this;
}
/** Gets the value of the 'w' field */
public java.lang.Integer getW() {
return w;
}
/** Sets the value of the 'w' field */
public ai.platon.pulsar.persist.gora.generated.GActiveDOMStat.Builder setW(int value) {
validate(fields()[4], value);
this.w = value;
fieldSetFlags()[4] = true;
return this;
}
/** Checks whether the 'w' field has been set */
public boolean hasW() {
return fieldSetFlags()[4];
}
/** Clears the value of the 'w' field */
public ai.platon.pulsar.persist.gora.generated.GActiveDOMStat.Builder clearW() {
fieldSetFlags()[4] = false;
return this;
}
/** Gets the value of the 'h' field */
public java.lang.Integer getH() {
return h;
}
/** Sets the value of the 'h' field */
public ai.platon.pulsar.persist.gora.generated.GActiveDOMStat.Builder setH(int value) {
validate(fields()[5], value);
this.h = value;
fieldSetFlags()[5] = true;
return this;
}
/** Checks whether the 'h' field has been set */
public boolean hasH() {
return fieldSetFlags()[5];
}
/** Clears the value of the 'h' field */
public ai.platon.pulsar.persist.gora.generated.GActiveDOMStat.Builder clearH() {
fieldSetFlags()[5] = false;
return this;
}
@Override
public GActiveDOMStat build() {
try {
GActiveDOMStat record = new GActiveDOMStat();
record.ni = fieldSetFlags()[0] ? this.ni : (java.lang.Integer) defaultValue(fields()[0]);
record.na = fieldSetFlags()[1] ? this.na : (java.lang.Integer) defaultValue(fields()[1]);
record.nnm = fieldSetFlags()[2] ? this.nnm : (java.lang.Integer) defaultValue(fields()[2]);
record.nst = fieldSetFlags()[3] ? this.nst : (java.lang.Integer) defaultValue(fields()[3]);
record.w = fieldSetFlags()[4] ? this.w : (java.lang.Integer) defaultValue(fields()[4]);
record.h = fieldSetFlags()[5] ? this.h : (java.lang.Integer) defaultValue(fields()[5]);
return record;
} catch (Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
public GActiveDOMStat.Tombstone getTombstone(){
return TOMBSTONE;
}
public GActiveDOMStat newInstance(){
return newBuilder().build();
}
private static final Tombstone TOMBSTONE = new Tombstone();
public static final class Tombstone extends GActiveDOMStat implements org.apache.gora.persistency.Tombstone {
private Tombstone() { }
/**
* Gets the value of the 'ni' field.
*/
public java.lang.Integer getNi() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'ni' field.
* @param value the value to set.
*/
public void setNi(java.lang.Integer value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'ni' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isNiDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'na' field.
*/
public java.lang.Integer getNa() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'na' field.
* @param value the value to set.
*/
public void setNa(java.lang.Integer value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'na' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isNaDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'nnm' field.
*/
public java.lang.Integer getNnm() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'nnm' field.
* @param value the value to set.
*/
public void setNnm(java.lang.Integer value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'nnm' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isNnmDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'nst' field.
*/
public java.lang.Integer getNst() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'nst' field.
* @param value the value to set.
*/
public void setNst(java.lang.Integer value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'nst' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isNstDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'w' field.
*/
public java.lang.Integer getW() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'w' field.
* @param value the value to set.
*/
public void setW(java.lang.Integer value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'w' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isWDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'h' field.
*/
public java.lang.Integer getH() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'h' field.
* @param value the value to set.
*/
public void setH(java.lang.Integer value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'h' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isHDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
}
private static final org.apache.avro.io.DatumWriter
DATUM_WRITER$ = new org.apache.avro.specific.SpecificDatumWriter(SCHEMA$);
private static final org.apache.avro.io.DatumReader
DATUM_READER$ = new org.apache.avro.specific.SpecificDatumReader(SCHEMA$);
/**
* Writes AVRO data bean to output stream in the form of AVRO Binary encoding format. This will transform
* AVRO data bean from its Java object form to it s serializable form.
*
* @param out java.io.ObjectOutput output stream to write data bean in serializable form
*/
@Override
public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
out.write(super.getDirtyBytes().array());
DATUM_WRITER$.write(this, org.apache.avro.io.EncoderFactory.get()
.directBinaryEncoder((java.io.OutputStream) out,
null));
}
/**
* Reads AVRO data bean from input stream in it s AVRO Binary encoding format to Java object format.
* This will transform AVRO data bean from it s serializable form to deserialized Java object form.
*
* @param in java.io.ObjectOutput input stream to read data bean in serializable form
*/
@Override
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
byte[] __g__dirty = new byte[getFieldsCount()];
in.read(__g__dirty);
super.setDirtyBytes(java.nio.ByteBuffer.wrap(__g__dirty));
DATUM_READER$.read(this, org.apache.avro.io.DecoderFactory.get()
.directBinaryDecoder((java.io.InputStream) in,
null));
}
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-persist/3.0.15/ai/platon/pulsar/persist/gora
|
java-sources/ai/platon/pulsar/pulsar-persist/3.0.15/ai/platon/pulsar/persist/gora/generated/GActiveDOMStatus.java
|
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package ai.platon.pulsar.persist.gora.generated;
import org.apache.gora.persistency.Persistent;
public class GActiveDOMStatus extends org.apache.gora.persistency.impl.PersistentBase implements org.apache.avro.specific.SpecificRecord, org.apache.gora.persistency.Persistent {
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"GActiveDOMStatus\",\"namespace\":\"ai.platon.pulsar.persist.gora.generated\",\"fields\":[{\"name\":\"n\",\"type\":\"int\",\"default\":0},{\"name\":\"scroll\",\"type\":\"int\",\"default\":0},{\"name\":\"st\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"r\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"idl\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"ec\",\"type\":[\"null\",\"string\"],\"default\":null}]}");
private static final long serialVersionUID = 570553228940337791L;
/** Enum containing all data bean's fields. */
public static enum Field {
N(0, "n"),
SCROLL(1, "scroll"),
ST(2, "st"),
R(3, "r"),
IDL(4, "idl"),
EC(5, "ec"),
;
/**
* Field's index.
*/
private int index;
/**
* Field's name.
*/
private String name;
/**
* Field's constructor
* @param index field's index.
* @param name field's name.
*/
Field(int index, String name) {this.index=index;this.name=name;}
/**
* Gets field's index.
* @return int field's index.
*/
public int getIndex() {return index;}
/**
* Gets field's name.
* @return String field's name.
*/
public String getName() {return name;}
/**
* Gets field's attributes to string.
* @return String field's attributes to string.
*/
public String toString() {return name;}
};
public static final String[] _ALL_FIELDS = {
"n",
"scroll",
"st",
"r",
"idl",
"ec",
};
/**
* Gets the total field count.
* @return int field count
*/
public int getFieldsCount() {
return GActiveDOMStatus._ALL_FIELDS.length;
}
@Override
public Persistent clone() {
return null;
}
private int n;
private int scroll;
private java.lang.CharSequence st;
private java.lang.CharSequence r;
private java.lang.CharSequence idl;
private java.lang.CharSequence ec;
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return n;
case 1: return scroll;
case 2: return st;
case 3: return r;
case 4: return idl;
case 5: return ec;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value) {
switch (field$) {
case 0: n = (java.lang.Integer)(value); break;
case 1: scroll = (java.lang.Integer)(value); break;
case 2: st = (java.lang.CharSequence)(value); break;
case 3: r = (java.lang.CharSequence)(value); break;
case 4: idl = (java.lang.CharSequence)(value); break;
case 5: ec = (java.lang.CharSequence)(value); break;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
/**
* Gets the value of the 'n' field.
*/
public java.lang.Integer getN() {
return n;
}
/**
* Sets the value of the 'n' field.
* @param value the value to set.
*/
public void setN(java.lang.Integer value) {
this.n = value;
setDirty(0);
}
/**
* Checks the dirty status of the 'n' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isNDirty() {
return isDirty(0);
}
/**
* Gets the value of the 'scroll' field.
*/
public java.lang.Integer getScroll() {
return scroll;
}
/**
* Sets the value of the 'scroll' field.
* @param value the value to set.
*/
public void setScroll(java.lang.Integer value) {
this.scroll = value;
setDirty(1);
}
/**
* Checks the dirty status of the 'scroll' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isScrollDirty() {
return isDirty(1);
}
/**
* Gets the value of the 'st' field.
*/
public java.lang.CharSequence getSt() {
return st;
}
/**
* Sets the value of the 'st' field.
* @param value the value to set.
*/
public void setSt(java.lang.CharSequence value) {
this.st = value;
setDirty(2);
}
/**
* Checks the dirty status of the 'st' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isStDirty() {
return isDirty(2);
}
/**
* Gets the value of the 'r' field.
*/
public java.lang.CharSequence getR() {
return r;
}
/**
* Sets the value of the 'r' field.
* @param value the value to set.
*/
public void setR(java.lang.CharSequence value) {
this.r = value;
setDirty(3);
}
/**
* Checks the dirty status of the 'r' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isRDirty() {
return isDirty(3);
}
/**
* Gets the value of the 'idl' field.
*/
public java.lang.CharSequence getIdl() {
return idl;
}
/**
* Sets the value of the 'idl' field.
* @param value the value to set.
*/
public void setIdl(java.lang.CharSequence value) {
this.idl = value;
setDirty(4);
}
/**
* Checks the dirty status of the 'idl' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isIdlDirty() {
return isDirty(4);
}
/**
* Gets the value of the 'ec' field.
*/
public java.lang.CharSequence getEc() {
return ec;
}
/**
* Sets the value of the 'ec' field.
* @param value the value to set.
*/
public void setEc(java.lang.CharSequence value) {
this.ec = value;
setDirty(5);
}
/**
* Checks the dirty status of the 'ec' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isEcDirty() {
return isDirty(5);
}
/** Creates a new GActiveDOMStatus RecordBuilder */
public static ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus.Builder newBuilder() {
return new ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus.Builder();
}
/** Creates a new GActiveDOMStatus RecordBuilder by copying an existing Builder */
public static ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus.Builder newBuilder(ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus.Builder other) {
return new ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus.Builder(other);
}
/** Creates a new GActiveDOMStatus RecordBuilder by copying an existing GActiveDOMStatus instance */
public static ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus.Builder newBuilder(ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus other) {
return new ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus.Builder(other);
}
private static java.nio.ByteBuffer deepCopyToReadOnlyBuffer(
java.nio.ByteBuffer input) {
java.nio.ByteBuffer copy = java.nio.ByteBuffer.allocate(input.capacity());
int position = input.position();
input.reset();
int mark = input.position();
int limit = input.limit();
input.rewind();
input.limit(input.capacity());
copy.put(input);
input.rewind();
copy.rewind();
input.position(mark);
input.mark();
copy.position(mark);
copy.mark();
input.position(position);
copy.position(position);
input.limit(limit);
copy.limit(limit);
return copy.asReadOnlyBuffer();
}
/**
* RecordBuilder for GActiveDOMStatus instances.
*/
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<GActiveDOMStatus>
implements org.apache.avro.data.RecordBuilder<GActiveDOMStatus> {
private int n;
private int scroll;
private java.lang.CharSequence st;
private java.lang.CharSequence r;
private java.lang.CharSequence idl;
private java.lang.CharSequence ec;
/** Creates a new Builder */
private Builder() {
super(ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus.SCHEMA$);
}
/** Creates a Builder by copying an existing Builder */
private Builder(ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus.Builder other) {
super(other);
}
/** Creates a Builder by copying an existing GActiveDOMStatus instance */
private Builder(ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus other) {
super(ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus.SCHEMA$);
if (isValidValue(fields()[0], other.n)) {
this.n = (java.lang.Integer) data().deepCopy(fields()[0].schema(), other.n);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.scroll)) {
this.scroll = (java.lang.Integer) data().deepCopy(fields()[1].schema(), other.scroll);
fieldSetFlags()[1] = true;
}
if (isValidValue(fields()[2], other.st)) {
this.st = (java.lang.CharSequence) data().deepCopy(fields()[2].schema(), other.st);
fieldSetFlags()[2] = true;
}
if (isValidValue(fields()[3], other.r)) {
this.r = (java.lang.CharSequence) data().deepCopy(fields()[3].schema(), other.r);
fieldSetFlags()[3] = true;
}
if (isValidValue(fields()[4], other.idl)) {
this.idl = (java.lang.CharSequence) data().deepCopy(fields()[4].schema(), other.idl);
fieldSetFlags()[4] = true;
}
if (isValidValue(fields()[5], other.ec)) {
this.ec = (java.lang.CharSequence) data().deepCopy(fields()[5].schema(), other.ec);
fieldSetFlags()[5] = true;
}
}
/** Gets the value of the 'n' field */
public java.lang.Integer getN() {
return n;
}
/** Sets the value of the 'n' field */
public ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus.Builder setN(int value) {
validate(fields()[0], value);
this.n = value;
fieldSetFlags()[0] = true;
return this;
}
/** Checks whether the 'n' field has been set */
public boolean hasN() {
return fieldSetFlags()[0];
}
/** Clears the value of the 'n' field */
public ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus.Builder clearN() {
fieldSetFlags()[0] = false;
return this;
}
/** Gets the value of the 'scroll' field */
public java.lang.Integer getScroll() {
return scroll;
}
/** Sets the value of the 'scroll' field */
public ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus.Builder setScroll(int value) {
validate(fields()[1], value);
this.scroll = value;
fieldSetFlags()[1] = true;
return this;
}
/** Checks whether the 'scroll' field has been set */
public boolean hasScroll() {
return fieldSetFlags()[1];
}
/** Clears the value of the 'scroll' field */
public ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus.Builder clearScroll() {
fieldSetFlags()[1] = false;
return this;
}
/** Gets the value of the 'st' field */
public java.lang.CharSequence getSt() {
return st;
}
/** Sets the value of the 'st' field */
public ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus.Builder setSt(java.lang.CharSequence value) {
validate(fields()[2], value);
this.st = value;
fieldSetFlags()[2] = true;
return this;
}
/** Checks whether the 'st' field has been set */
public boolean hasSt() {
return fieldSetFlags()[2];
}
/** Clears the value of the 'st' field */
public ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus.Builder clearSt() {
st = null;
fieldSetFlags()[2] = false;
return this;
}
/** Gets the value of the 'r' field */
public java.lang.CharSequence getR() {
return r;
}
/** Sets the value of the 'r' field */
public ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus.Builder setR(java.lang.CharSequence value) {
validate(fields()[3], value);
this.r = value;
fieldSetFlags()[3] = true;
return this;
}
/** Checks whether the 'r' field has been set */
public boolean hasR() {
return fieldSetFlags()[3];
}
/** Clears the value of the 'r' field */
public ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus.Builder clearR() {
r = null;
fieldSetFlags()[3] = false;
return this;
}
/** Gets the value of the 'idl' field */
public java.lang.CharSequence getIdl() {
return idl;
}
/** Sets the value of the 'idl' field */
public ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus.Builder setIdl(java.lang.CharSequence value) {
validate(fields()[4], value);
this.idl = value;
fieldSetFlags()[4] = true;
return this;
}
/** Checks whether the 'idl' field has been set */
public boolean hasIdl() {
return fieldSetFlags()[4];
}
/** Clears the value of the 'idl' field */
public ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus.Builder clearIdl() {
idl = null;
fieldSetFlags()[4] = false;
return this;
}
/** Gets the value of the 'ec' field */
public java.lang.CharSequence getEc() {
return ec;
}
/** Sets the value of the 'ec' field */
public ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus.Builder setEc(java.lang.CharSequence value) {
validate(fields()[5], value);
this.ec = value;
fieldSetFlags()[5] = true;
return this;
}
/** Checks whether the 'ec' field has been set */
public boolean hasEc() {
return fieldSetFlags()[5];
}
/** Clears the value of the 'ec' field */
public ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus.Builder clearEc() {
ec = null;
fieldSetFlags()[5] = false;
return this;
}
@Override
public GActiveDOMStatus build() {
try {
GActiveDOMStatus record = new GActiveDOMStatus();
record.n = fieldSetFlags()[0] ? this.n : (java.lang.Integer) defaultValue(fields()[0]);
record.scroll = fieldSetFlags()[1] ? this.scroll : (java.lang.Integer) defaultValue(fields()[1]);
record.st = fieldSetFlags()[2] ? this.st : (java.lang.CharSequence) defaultValue(fields()[2]);
record.r = fieldSetFlags()[3] ? this.r : (java.lang.CharSequence) defaultValue(fields()[3]);
record.idl = fieldSetFlags()[4] ? this.idl : (java.lang.CharSequence) defaultValue(fields()[4]);
record.ec = fieldSetFlags()[5] ? this.ec : (java.lang.CharSequence) defaultValue(fields()[5]);
return record;
} catch (Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
public GActiveDOMStatus.Tombstone getTombstone(){
return TOMBSTONE;
}
public GActiveDOMStatus newInstance(){
return newBuilder().build();
}
private static final Tombstone TOMBSTONE = new Tombstone();
public static final class Tombstone extends GActiveDOMStatus implements org.apache.gora.persistency.Tombstone {
private Tombstone() { }
/**
* Gets the value of the 'n' field.
*/
public java.lang.Integer getN() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'n' field.
* @param value the value to set.
*/
public void setN(java.lang.Integer value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'n' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isNDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'scroll' field.
*/
public java.lang.Integer getScroll() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'scroll' field.
* @param value the value to set.
*/
public void setScroll(java.lang.Integer value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'scroll' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isScrollDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'st' field.
*/
public java.lang.CharSequence getSt() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'st' field.
* @param value the value to set.
*/
public void setSt(java.lang.CharSequence value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'st' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isStDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'r' field.
*/
public java.lang.CharSequence getR() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'r' field.
* @param value the value to set.
*/
public void setR(java.lang.CharSequence value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'r' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isRDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'idl' field.
*/
public java.lang.CharSequence getIdl() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'idl' field.
* @param value the value to set.
*/
public void setIdl(java.lang.CharSequence value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'idl' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isIdlDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'ec' field.
*/
public java.lang.CharSequence getEc() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'ec' field.
* @param value the value to set.
*/
public void setEc(java.lang.CharSequence value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'ec' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isEcDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
}
private static final org.apache.avro.io.DatumWriter
DATUM_WRITER$ = new org.apache.avro.specific.SpecificDatumWriter(SCHEMA$);
private static final org.apache.avro.io.DatumReader
DATUM_READER$ = new org.apache.avro.specific.SpecificDatumReader(SCHEMA$);
/**
* Writes AVRO data bean to output stream in the form of AVRO Binary encoding format. This will transform
* AVRO data bean from its Java object form to it s serializable form.
*
* @param out java.io.ObjectOutput output stream to write data bean in serializable form
*/
@Override
public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
out.write(super.getDirtyBytes().array());
DATUM_WRITER$.write(this, org.apache.avro.io.EncoderFactory.get()
.directBinaryEncoder((java.io.OutputStream) out,
null));
}
/**
* Reads AVRO data bean from input stream in it s AVRO Binary encoding format to Java object format.
* This will transform AVRO data bean from it s serializable form to deserialized Java object form.
*
* @param in java.io.ObjectOutput input stream to read data bean in serializable form
*/
@Override
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
byte[] __g__dirty = new byte[getFieldsCount()];
in.read(__g__dirty);
super.setDirtyBytes(java.nio.ByteBuffer.wrap(__g__dirty));
DATUM_READER$.read(this, org.apache.avro.io.DecoderFactory.get()
.directBinaryDecoder((java.io.InputStream) in,
null));
}
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-persist/3.0.15/ai/platon/pulsar/persist/gora
|
java-sources/ai/platon/pulsar/pulsar-persist/3.0.15/ai/platon/pulsar/persist/gora/generated/GFieldGroup.java
|
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package ai.platon.pulsar.persist.gora.generated;
import org.apache.gora.persistency.Persistent;
public class GFieldGroup extends org.apache.gora.persistency.impl.PersistentBase implements org.apache.avro.specific.SpecificRecord, org.apache.gora.persistency.Persistent {
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"GFieldGroup\",\"namespace\":\"ai.platon.pulsar.persist.gora.generated\",\"fields\":[{\"name\":\"id\",\"type\":\"long\",\"default\":0},{\"name\":\"parentId\",\"type\":\"long\",\"default\":0},{\"name\":\"name\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"fields\",\"type\":{\"type\":\"map\",\"values\":[\"null\",\"string\"]},\"default\":{}}]}");
private static final long serialVersionUID = -1092470099062642149L;
/** Enum containing all data bean's fields. */
public static enum Field {
ID(0, "id"),
PARENT_ID(1, "parentId"),
NAME(2, "name"),
FIELDS(3, "fields"),
;
/**
* Field's index.
*/
private int index;
/**
* Field's name.
*/
private String name;
/**
* Field's constructor
* @param index field's index.
* @param name field's name.
*/
Field(int index, String name) {this.index=index;this.name=name;}
/**
* Gets field's index.
* @return int field's index.
*/
public int getIndex() {return index;}
/**
* Gets field's name.
* @return String field's name.
*/
public String getName() {return name;}
/**
* Gets field's attributes to string.
* @return String field's attributes to string.
*/
public String toString() {return name;}
};
public static final String[] _ALL_FIELDS = {
"id",
"parentId",
"name",
"fields",
};
/**
* Gets the total field count.
* @return int field count
*/
public int getFieldsCount() {
return GFieldGroup._ALL_FIELDS.length;
}
@Override
public Persistent clone() {
return null;
}
private long id;
private long parentId;
private java.lang.CharSequence name;
private java.util.Map<java.lang.CharSequence,java.lang.CharSequence> fields;
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return id;
case 1: return parentId;
case 2: return name;
case 3: return fields;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value) {
switch (field$) {
case 0: id = (java.lang.Long)(value); break;
case 1: parentId = (java.lang.Long)(value); break;
case 2: name = (java.lang.CharSequence)(value); break;
case 3: fields = (java.util.Map<java.lang.CharSequence,java.lang.CharSequence>)((value instanceof org.apache.gora.persistency.Dirtyable) ? value : new org.apache.gora.persistency.impl.DirtyMapWrapper((java.util.Map)value)); break;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
/**
* Gets the value of the 'id' field.
*/
public java.lang.Long getId() {
return id;
}
/**
* Sets the value of the 'id' field.
* @param value the value to set.
*/
public void setId(java.lang.Long value) {
this.id = value;
setDirty(0);
}
/**
* Checks the dirty status of the 'id' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isIdDirty() {
return isDirty(0);
}
/**
* Gets the value of the 'parentId' field.
*/
public java.lang.Long getParentId() {
return parentId;
}
/**
* Sets the value of the 'parentId' field.
* @param value the value to set.
*/
public void setParentId(java.lang.Long value) {
this.parentId = value;
setDirty(1);
}
/**
* Checks the dirty status of the 'parentId' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isParentIdDirty() {
return isDirty(1);
}
/**
* Gets the value of the 'name' field.
*/
public java.lang.CharSequence getName() {
return name;
}
/**
* Sets the value of the 'name' field.
* @param value the value to set.
*/
public void setName(java.lang.CharSequence value) {
this.name = value;
setDirty(2);
}
/**
* Checks the dirty status of the 'name' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isNameDirty() {
return isDirty(2);
}
/**
* Gets the value of the 'fields' field.
*/
public java.util.Map<java.lang.CharSequence,java.lang.CharSequence> getFields() {
return fields;
}
/**
* Sets the value of the 'fields' field.
* @param value the value to set.
*/
public void setFields(java.util.Map<java.lang.CharSequence,java.lang.CharSequence> value) {
this.fields = (value instanceof org.apache.gora.persistency.Dirtyable) ? value : new org.apache.gora.persistency.impl.DirtyMapWrapper(value);
setDirty(3);
}
/**
* Checks the dirty status of the 'fields' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isFieldsDirty() {
return isDirty(3);
}
/** Creates a new GFieldGroup RecordBuilder */
public static ai.platon.pulsar.persist.gora.generated.GFieldGroup.Builder newBuilder() {
return new ai.platon.pulsar.persist.gora.generated.GFieldGroup.Builder();
}
/** Creates a new GFieldGroup RecordBuilder by copying an existing Builder */
public static ai.platon.pulsar.persist.gora.generated.GFieldGroup.Builder newBuilder(ai.platon.pulsar.persist.gora.generated.GFieldGroup.Builder other) {
return new ai.platon.pulsar.persist.gora.generated.GFieldGroup.Builder(other);
}
/** Creates a new GFieldGroup RecordBuilder by copying an existing GFieldGroup instance */
public static ai.platon.pulsar.persist.gora.generated.GFieldGroup.Builder newBuilder(ai.platon.pulsar.persist.gora.generated.GFieldGroup other) {
return new ai.platon.pulsar.persist.gora.generated.GFieldGroup.Builder(other);
}
private static java.nio.ByteBuffer deepCopyToReadOnlyBuffer(
java.nio.ByteBuffer input) {
java.nio.ByteBuffer copy = java.nio.ByteBuffer.allocate(input.capacity());
int position = input.position();
input.reset();
int mark = input.position();
int limit = input.limit();
input.rewind();
input.limit(input.capacity());
copy.put(input);
input.rewind();
copy.rewind();
input.position(mark);
input.mark();
copy.position(mark);
copy.mark();
input.position(position);
copy.position(position);
input.limit(limit);
copy.limit(limit);
return copy.asReadOnlyBuffer();
}
/**
* RecordBuilder for GFieldGroup instances.
*/
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<GFieldGroup>
implements org.apache.avro.data.RecordBuilder<GFieldGroup> {
private long id;
private long parentId;
private java.lang.CharSequence name;
private java.util.Map<java.lang.CharSequence,java.lang.CharSequence> fields;
/** Creates a new Builder */
private Builder() {
super(ai.platon.pulsar.persist.gora.generated.GFieldGroup.SCHEMA$);
}
/** Creates a Builder by copying an existing Builder */
private Builder(ai.platon.pulsar.persist.gora.generated.GFieldGroup.Builder other) {
super(other);
}
/** Creates a Builder by copying an existing GFieldGroup instance */
private Builder(ai.platon.pulsar.persist.gora.generated.GFieldGroup other) {
super(ai.platon.pulsar.persist.gora.generated.GFieldGroup.SCHEMA$);
if (isValidValue(fields()[0], other.id)) {
this.id = (java.lang.Long) data().deepCopy(fields()[0].schema(), other.id);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.parentId)) {
this.parentId = (java.lang.Long) data().deepCopy(fields()[1].schema(), other.parentId);
fieldSetFlags()[1] = true;
}
if (isValidValue(fields()[2], other.name)) {
this.name = (java.lang.CharSequence) data().deepCopy(fields()[2].schema(), other.name);
fieldSetFlags()[2] = true;
}
if (isValidValue(fields()[3], other.fields)) {
this.fields = (java.util.Map<java.lang.CharSequence,java.lang.CharSequence>) data().deepCopy(fields()[3].schema(), other.fields);
fieldSetFlags()[3] = true;
}
}
/** Gets the value of the 'id' field */
public java.lang.Long getId() {
return id;
}
/** Sets the value of the 'id' field */
public ai.platon.pulsar.persist.gora.generated.GFieldGroup.Builder setId(long value) {
validate(fields()[0], value);
this.id = value;
fieldSetFlags()[0] = true;
return this;
}
/** Checks whether the 'id' field has been set */
public boolean hasId() {
return fieldSetFlags()[0];
}
/** Clears the value of the 'id' field */
public ai.platon.pulsar.persist.gora.generated.GFieldGroup.Builder clearId() {
fieldSetFlags()[0] = false;
return this;
}
/** Gets the value of the 'parentId' field */
public java.lang.Long getParentId() {
return parentId;
}
/** Sets the value of the 'parentId' field */
public ai.platon.pulsar.persist.gora.generated.GFieldGroup.Builder setParentId(long value) {
validate(fields()[1], value);
this.parentId = value;
fieldSetFlags()[1] = true;
return this;
}
/** Checks whether the 'parentId' field has been set */
public boolean hasParentId() {
return fieldSetFlags()[1];
}
/** Clears the value of the 'parentId' field */
public ai.platon.pulsar.persist.gora.generated.GFieldGroup.Builder clearParentId() {
fieldSetFlags()[1] = false;
return this;
}
/** Gets the value of the 'name' field */
public java.lang.CharSequence getName() {
return name;
}
/** Sets the value of the 'name' field */
public ai.platon.pulsar.persist.gora.generated.GFieldGroup.Builder setName(java.lang.CharSequence value) {
validate(fields()[2], value);
this.name = value;
fieldSetFlags()[2] = true;
return this;
}
/** Checks whether the 'name' field has been set */
public boolean hasName() {
return fieldSetFlags()[2];
}
/** Clears the value of the 'name' field */
public ai.platon.pulsar.persist.gora.generated.GFieldGroup.Builder clearName() {
name = null;
fieldSetFlags()[2] = false;
return this;
}
/** Gets the value of the 'fields' field */
public java.util.Map<java.lang.CharSequence,java.lang.CharSequence> getFields() {
return fields;
}
/** Sets the value of the 'fields' field */
public ai.platon.pulsar.persist.gora.generated.GFieldGroup.Builder setFields(java.util.Map<java.lang.CharSequence,java.lang.CharSequence> value) {
validate(fields()[3], value);
this.fields = value;
fieldSetFlags()[3] = true;
return this;
}
/** Checks whether the 'fields' field has been set */
public boolean hasFields() {
return fieldSetFlags()[3];
}
/** Clears the value of the 'fields' field */
public ai.platon.pulsar.persist.gora.generated.GFieldGroup.Builder clearFields() {
fields = null;
fieldSetFlags()[3] = false;
return this;
}
@Override
public GFieldGroup build() {
try {
GFieldGroup record = new GFieldGroup();
record.id = fieldSetFlags()[0] ? this.id : (java.lang.Long) defaultValue(fields()[0]);
record.parentId = fieldSetFlags()[1] ? this.parentId : (java.lang.Long) defaultValue(fields()[1]);
record.name = fieldSetFlags()[2] ? this.name : (java.lang.CharSequence) defaultValue(fields()[2]);
record.fields = fieldSetFlags()[3] ? this.fields : (java.util.Map<java.lang.CharSequence,java.lang.CharSequence>) new org.apache.gora.persistency.impl.DirtyMapWrapper((java.util.Map)defaultValue(fields()[3]));
return record;
} catch (Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
public GFieldGroup.Tombstone getTombstone(){
return TOMBSTONE;
}
public GFieldGroup newInstance(){
return newBuilder().build();
}
private static final Tombstone TOMBSTONE = new Tombstone();
public static final class Tombstone extends GFieldGroup implements org.apache.gora.persistency.Tombstone {
private Tombstone() { }
/**
* Gets the value of the 'id' field.
*/
public java.lang.Long getId() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'id' field.
* @param value the value to set.
*/
public void setId(java.lang.Long value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'id' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isIdDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'parentId' field.
*/
public java.lang.Long getParentId() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'parentId' field.
* @param value the value to set.
*/
public void setParentId(java.lang.Long value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'parentId' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isParentIdDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'name' field.
*/
public java.lang.CharSequence getName() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'name' field.
* @param value the value to set.
*/
public void setName(java.lang.CharSequence value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'name' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isNameDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'fields' field.
*/
public java.util.Map<java.lang.CharSequence,java.lang.CharSequence> getFields() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'fields' field.
* @param value the value to set.
*/
public void setFields(java.util.Map<java.lang.CharSequence,java.lang.CharSequence> value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'fields' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isFieldsDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
}
private static final org.apache.avro.io.DatumWriter
DATUM_WRITER$ = new org.apache.avro.specific.SpecificDatumWriter(SCHEMA$);
private static final org.apache.avro.io.DatumReader
DATUM_READER$ = new org.apache.avro.specific.SpecificDatumReader(SCHEMA$);
/**
* Writes AVRO data bean to output stream in the form of AVRO Binary encoding format. This will transform
* AVRO data bean from its Java object form to it s serializable form.
*
* @param out java.io.ObjectOutput output stream to write data bean in serializable form
*/
@Override
public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
out.write(super.getDirtyBytes().array());
DATUM_WRITER$.write(this, org.apache.avro.io.EncoderFactory.get()
.directBinaryEncoder((java.io.OutputStream) out,
null));
}
/**
* Reads AVRO data bean from input stream in it s AVRO Binary encoding format to Java object format.
* This will transform AVRO data bean from it s serializable form to deserialized Java object form.
*
* @param in java.io.ObjectOutput input stream to read data bean in serializable form
*/
@Override
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
byte[] __g__dirty = new byte[getFieldsCount()];
in.read(__g__dirty);
super.setDirtyBytes(java.nio.ByteBuffer.wrap(__g__dirty));
DATUM_READER$.read(this, org.apache.avro.io.DecoderFactory.get()
.directBinaryDecoder((java.io.InputStream) in,
null));
}
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-persist/3.0.15/ai/platon/pulsar/persist/gora
|
java-sources/ai/platon/pulsar/pulsar-persist/3.0.15/ai/platon/pulsar/persist/gora/generated/GHypeLink.java
|
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package ai.platon.pulsar.persist.gora.generated;
import org.apache.gora.persistency.Persistent;
public class GHypeLink extends org.apache.gora.persistency.impl.PersistentBase implements org.apache.avro.specific.SpecificRecord, org.apache.gora.persistency.Persistent {
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"GHypeLink\",\"namespace\":\"ai.platon.pulsar.persist.gora.generated\",\"fields\":[{\"name\":\"url\",\"type\":\"string\",\"default\":\"\"},{\"name\":\"anchor\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"order\",\"type\":\"int\",\"default\":0}]}");
private static final long serialVersionUID = -7365210677982337286L;
/** Enum containing all data bean's fields. */
public static enum Field {
URL(0, "url"),
ANCHOR(1, "anchor"),
ORDER(2, "order"),
;
/**
* Field's index.
*/
private int index;
/**
* Field's name.
*/
private String name;
/**
* Field's constructor
* @param index field's index.
* @param name field's name.
*/
Field(int index, String name) {this.index=index;this.name=name;}
/**
* Gets field's index.
* @return int field's index.
*/
public int getIndex() {return index;}
/**
* Gets field's name.
* @return String field's name.
*/
public String getName() {return name;}
/**
* Gets field's attributes to string.
* @return String field's attributes to string.
*/
public String toString() {return name;}
};
public static final String[] _ALL_FIELDS = {
"url",
"anchor",
"order",
};
/**
* Gets the total field count.
* @return int field count
*/
public int getFieldsCount() {
return GHypeLink._ALL_FIELDS.length;
}
@Override
public Persistent clone() {
return null;
}
private java.lang.CharSequence url;
private java.lang.CharSequence anchor;
private int order;
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return url;
case 1: return anchor;
case 2: return order;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value) {
switch (field$) {
case 0: url = (java.lang.CharSequence)(value); break;
case 1: anchor = (java.lang.CharSequence)(value); break;
case 2: order = (java.lang.Integer)(value); break;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
/**
* Gets the value of the 'url' field.
*/
public java.lang.CharSequence getUrl() {
return url;
}
/**
* Sets the value of the 'url' field.
* @param value the value to set.
*/
public void setUrl(java.lang.CharSequence value) {
this.url = value;
setDirty(0);
}
/**
* Checks the dirty status of the 'url' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isUrlDirty() {
return isDirty(0);
}
/**
* Gets the value of the 'anchor' field.
*/
public java.lang.CharSequence getAnchor() {
return anchor;
}
/**
* Sets the value of the 'anchor' field.
* @param value the value to set.
*/
public void setAnchor(java.lang.CharSequence value) {
this.anchor = value;
setDirty(1);
}
/**
* Checks the dirty status of the 'anchor' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isAnchorDirty() {
return isDirty(1);
}
/**
* Gets the value of the 'order' field.
*/
public java.lang.Integer getOrder() {
return order;
}
/**
* Sets the value of the 'order' field.
* @param value the value to set.
*/
public void setOrder(java.lang.Integer value) {
this.order = value;
setDirty(2);
}
/**
* Checks the dirty status of the 'order' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isOrderDirty() {
return isDirty(2);
}
/** Creates a new GHypeLink RecordBuilder */
public static ai.platon.pulsar.persist.gora.generated.GHypeLink.Builder newBuilder() {
return new ai.platon.pulsar.persist.gora.generated.GHypeLink.Builder();
}
/** Creates a new GHypeLink RecordBuilder by copying an existing Builder */
public static ai.platon.pulsar.persist.gora.generated.GHypeLink.Builder newBuilder(ai.platon.pulsar.persist.gora.generated.GHypeLink.Builder other) {
return new ai.platon.pulsar.persist.gora.generated.GHypeLink.Builder(other);
}
/** Creates a new GHypeLink RecordBuilder by copying an existing GHypeLink instance */
public static ai.platon.pulsar.persist.gora.generated.GHypeLink.Builder newBuilder(ai.platon.pulsar.persist.gora.generated.GHypeLink other) {
return new ai.platon.pulsar.persist.gora.generated.GHypeLink.Builder(other);
}
private static java.nio.ByteBuffer deepCopyToReadOnlyBuffer(
java.nio.ByteBuffer input) {
java.nio.ByteBuffer copy = java.nio.ByteBuffer.allocate(input.capacity());
int position = input.position();
input.reset();
int mark = input.position();
int limit = input.limit();
input.rewind();
input.limit(input.capacity());
copy.put(input);
input.rewind();
copy.rewind();
input.position(mark);
input.mark();
copy.position(mark);
copy.mark();
input.position(position);
copy.position(position);
input.limit(limit);
copy.limit(limit);
return copy.asReadOnlyBuffer();
}
/**
* RecordBuilder for GHypeLink instances.
*/
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<GHypeLink>
implements org.apache.avro.data.RecordBuilder<GHypeLink> {
private java.lang.CharSequence url;
private java.lang.CharSequence anchor;
private int order;
/** Creates a new Builder */
private Builder() {
super(ai.platon.pulsar.persist.gora.generated.GHypeLink.SCHEMA$);
}
/** Creates a Builder by copying an existing Builder */
private Builder(ai.platon.pulsar.persist.gora.generated.GHypeLink.Builder other) {
super(other);
}
/** Creates a Builder by copying an existing GHypeLink instance */
private Builder(ai.platon.pulsar.persist.gora.generated.GHypeLink other) {
super(ai.platon.pulsar.persist.gora.generated.GHypeLink.SCHEMA$);
if (isValidValue(fields()[0], other.url)) {
this.url = (java.lang.CharSequence) data().deepCopy(fields()[0].schema(), other.url);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.anchor)) {
this.anchor = (java.lang.CharSequence) data().deepCopy(fields()[1].schema(), other.anchor);
fieldSetFlags()[1] = true;
}
if (isValidValue(fields()[2], other.order)) {
this.order = (java.lang.Integer) data().deepCopy(fields()[2].schema(), other.order);
fieldSetFlags()[2] = true;
}
}
/** Gets the value of the 'url' field */
public java.lang.CharSequence getUrl() {
return url;
}
/** Sets the value of the 'url' field */
public ai.platon.pulsar.persist.gora.generated.GHypeLink.Builder setUrl(java.lang.CharSequence value) {
validate(fields()[0], value);
this.url = value;
fieldSetFlags()[0] = true;
return this;
}
/** Checks whether the 'url' field has been set */
public boolean hasUrl() {
return fieldSetFlags()[0];
}
/** Clears the value of the 'url' field */
public ai.platon.pulsar.persist.gora.generated.GHypeLink.Builder clearUrl() {
url = null;
fieldSetFlags()[0] = false;
return this;
}
/** Gets the value of the 'anchor' field */
public java.lang.CharSequence getAnchor() {
return anchor;
}
/** Sets the value of the 'anchor' field */
public ai.platon.pulsar.persist.gora.generated.GHypeLink.Builder setAnchor(java.lang.CharSequence value) {
validate(fields()[1], value);
this.anchor = value;
fieldSetFlags()[1] = true;
return this;
}
/** Checks whether the 'anchor' field has been set */
public boolean hasAnchor() {
return fieldSetFlags()[1];
}
/** Clears the value of the 'anchor' field */
public ai.platon.pulsar.persist.gora.generated.GHypeLink.Builder clearAnchor() {
anchor = null;
fieldSetFlags()[1] = false;
return this;
}
/** Gets the value of the 'order' field */
public java.lang.Integer getOrder() {
return order;
}
/** Sets the value of the 'order' field */
public ai.platon.pulsar.persist.gora.generated.GHypeLink.Builder setOrder(int value) {
validate(fields()[2], value);
this.order = value;
fieldSetFlags()[2] = true;
return this;
}
/** Checks whether the 'order' field has been set */
public boolean hasOrder() {
return fieldSetFlags()[2];
}
/** Clears the value of the 'order' field */
public ai.platon.pulsar.persist.gora.generated.GHypeLink.Builder clearOrder() {
fieldSetFlags()[2] = false;
return this;
}
@Override
public GHypeLink build() {
try {
GHypeLink record = new GHypeLink();
record.url = fieldSetFlags()[0] ? this.url : (java.lang.CharSequence) defaultValue(fields()[0]);
record.anchor = fieldSetFlags()[1] ? this.anchor : (java.lang.CharSequence) defaultValue(fields()[1]);
record.order = fieldSetFlags()[2] ? this.order : (java.lang.Integer) defaultValue(fields()[2]);
return record;
} catch (Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
public GHypeLink.Tombstone getTombstone(){
return TOMBSTONE;
}
public GHypeLink newInstance(){
return newBuilder().build();
}
private static final Tombstone TOMBSTONE = new Tombstone();
public static final class Tombstone extends GHypeLink implements org.apache.gora.persistency.Tombstone {
private Tombstone() { }
/**
* Gets the value of the 'url' field.
*/
public java.lang.CharSequence getUrl() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'url' field.
* @param value the value to set.
*/
public void setUrl(java.lang.CharSequence value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'url' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isUrlDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'anchor' field.
*/
public java.lang.CharSequence getAnchor() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'anchor' field.
* @param value the value to set.
*/
public void setAnchor(java.lang.CharSequence value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'anchor' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isAnchorDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'order' field.
*/
public java.lang.Integer getOrder() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'order' field.
* @param value the value to set.
*/
public void setOrder(java.lang.Integer value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'order' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isOrderDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
}
private static final org.apache.avro.io.DatumWriter
DATUM_WRITER$ = new org.apache.avro.specific.SpecificDatumWriter(SCHEMA$);
private static final org.apache.avro.io.DatumReader
DATUM_READER$ = new org.apache.avro.specific.SpecificDatumReader(SCHEMA$);
/**
* Writes AVRO data bean to output stream in the form of AVRO Binary encoding format. This will transform
* AVRO data bean from its Java object form to it s serializable form.
*
* @param out java.io.ObjectOutput output stream to write data bean in serializable form
*/
@Override
public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
out.write(super.getDirtyBytes().array());
DATUM_WRITER$.write(this, org.apache.avro.io.EncoderFactory.get()
.directBinaryEncoder((java.io.OutputStream) out,
null));
}
/**
* Reads AVRO data bean from input stream in it s AVRO Binary encoding format to Java object format.
* This will transform AVRO data bean from it s serializable form to deserialized Java object form.
*
* @param in java.io.ObjectOutput input stream to read data bean in serializable form
*/
@Override
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
byte[] __g__dirty = new byte[getFieldsCount()];
in.read(__g__dirty);
super.setDirtyBytes(java.nio.ByteBuffer.wrap(__g__dirty));
DATUM_READER$.read(this, org.apache.avro.io.DecoderFactory.get()
.directBinaryDecoder((java.io.InputStream) in,
null));
}
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-persist/3.0.15/ai/platon/pulsar/persist/gora
|
java-sources/ai/platon/pulsar/pulsar-persist/3.0.15/ai/platon/pulsar/persist/gora/generated/GPageModel.java
|
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package ai.platon.pulsar.persist.gora.generated;
import org.apache.gora.persistency.Persistent;
public class GPageModel extends org.apache.gora.persistency.impl.PersistentBase implements org.apache.avro.specific.SpecificRecord, org.apache.gora.persistency.Persistent {
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"GPageModel\",\"namespace\":\"ai.platon.pulsar.persist.gora.generated\",\"fields\":[{\"name\":\"fieldGroups\",\"type\":{\"type\":\"array\",\"items\":{\"type\":\"record\",\"name\":\"GFieldGroup\",\"fields\":[{\"name\":\"id\",\"type\":\"long\",\"default\":0},{\"name\":\"parentId\",\"type\":\"long\",\"default\":0},{\"name\":\"name\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"fields\",\"type\":{\"type\":\"map\",\"values\":[\"null\",\"string\"]},\"default\":{}}]}},\"default\":[]}]}");
private static final long serialVersionUID = 1823870798188997057L;
/** Enum containing all data bean's fields. */
public static enum Field {
FIELD_GROUPS(0, "fieldGroups"),
;
/**
* Field's index.
*/
private int index;
/**
* Field's name.
*/
private String name;
/**
* Field's constructor
* @param index field's index.
* @param name field's name.
*/
Field(int index, String name) {this.index=index;this.name=name;}
/**
* Gets field's index.
* @return int field's index.
*/
public int getIndex() {return index;}
/**
* Gets field's name.
* @return String field's name.
*/
public String getName() {return name;}
/**
* Gets field's attributes to string.
* @return String field's attributes to string.
*/
public String toString() {return name;}
};
public static final String[] _ALL_FIELDS = {
"fieldGroups",
};
/**
* Gets the total field count.
* @return int field count
*/
public int getFieldsCount() {
return GPageModel._ALL_FIELDS.length;
}
@Override
public Persistent clone() {
return null;
}
private java.util.List<ai.platon.pulsar.persist.gora.generated.GFieldGroup> fieldGroups;
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return fieldGroups;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value) {
switch (field$) {
case 0: fieldGroups = (java.util.List<ai.platon.pulsar.persist.gora.generated.GFieldGroup>)((value instanceof org.apache.gora.persistency.Dirtyable) ? value : new org.apache.gora.persistency.impl.DirtyListWrapper((java.util.List)value)); break;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
/**
* Gets the value of the 'fieldGroups' field.
*/
public java.util.List<ai.platon.pulsar.persist.gora.generated.GFieldGroup> getFieldGroups() {
return fieldGroups;
}
/**
* Sets the value of the 'fieldGroups' field.
* @param value the value to set.
*/
public void setFieldGroups(java.util.List<ai.platon.pulsar.persist.gora.generated.GFieldGroup> value) {
this.fieldGroups = (value instanceof org.apache.gora.persistency.Dirtyable) ? value : new org.apache.gora.persistency.impl.DirtyListWrapper(value);
setDirty(0);
}
/**
* Checks the dirty status of the 'fieldGroups' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isFieldGroupsDirty() {
return isDirty(0);
}
/** Creates a new GPageModel RecordBuilder */
public static ai.platon.pulsar.persist.gora.generated.GPageModel.Builder newBuilder() {
return new ai.platon.pulsar.persist.gora.generated.GPageModel.Builder();
}
/** Creates a new GPageModel RecordBuilder by copying an existing Builder */
public static ai.platon.pulsar.persist.gora.generated.GPageModel.Builder newBuilder(ai.platon.pulsar.persist.gora.generated.GPageModel.Builder other) {
return new ai.platon.pulsar.persist.gora.generated.GPageModel.Builder(other);
}
/** Creates a new GPageModel RecordBuilder by copying an existing GPageModel instance */
public static ai.platon.pulsar.persist.gora.generated.GPageModel.Builder newBuilder(ai.platon.pulsar.persist.gora.generated.GPageModel other) {
return new ai.platon.pulsar.persist.gora.generated.GPageModel.Builder(other);
}
private static java.nio.ByteBuffer deepCopyToReadOnlyBuffer(
java.nio.ByteBuffer input) {
java.nio.ByteBuffer copy = java.nio.ByteBuffer.allocate(input.capacity());
int position = input.position();
input.reset();
int mark = input.position();
int limit = input.limit();
input.rewind();
input.limit(input.capacity());
copy.put(input);
input.rewind();
copy.rewind();
input.position(mark);
input.mark();
copy.position(mark);
copy.mark();
input.position(position);
copy.position(position);
input.limit(limit);
copy.limit(limit);
return copy.asReadOnlyBuffer();
}
/**
* RecordBuilder for GPageModel instances.
*/
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<GPageModel>
implements org.apache.avro.data.RecordBuilder<GPageModel> {
private java.util.List<ai.platon.pulsar.persist.gora.generated.GFieldGroup> fieldGroups;
/** Creates a new Builder */
private Builder() {
super(ai.platon.pulsar.persist.gora.generated.GPageModel.SCHEMA$);
}
/** Creates a Builder by copying an existing Builder */
private Builder(ai.platon.pulsar.persist.gora.generated.GPageModel.Builder other) {
super(other);
}
/** Creates a Builder by copying an existing GPageModel instance */
private Builder(ai.platon.pulsar.persist.gora.generated.GPageModel other) {
super(ai.platon.pulsar.persist.gora.generated.GPageModel.SCHEMA$);
if (isValidValue(fields()[0], other.fieldGroups)) {
this.fieldGroups = (java.util.List<ai.platon.pulsar.persist.gora.generated.GFieldGroup>) data().deepCopy(fields()[0].schema(), other.fieldGroups);
fieldSetFlags()[0] = true;
}
}
/** Gets the value of the 'fieldGroups' field */
public java.util.List<ai.platon.pulsar.persist.gora.generated.GFieldGroup> getFieldGroups() {
return fieldGroups;
}
/** Sets the value of the 'fieldGroups' field */
public ai.platon.pulsar.persist.gora.generated.GPageModel.Builder setFieldGroups(java.util.List<ai.platon.pulsar.persist.gora.generated.GFieldGroup> value) {
validate(fields()[0], value);
this.fieldGroups = value;
fieldSetFlags()[0] = true;
return this;
}
/** Checks whether the 'fieldGroups' field has been set */
public boolean hasFieldGroups() {
return fieldSetFlags()[0];
}
/** Clears the value of the 'fieldGroups' field */
public ai.platon.pulsar.persist.gora.generated.GPageModel.Builder clearFieldGroups() {
fieldGroups = null;
fieldSetFlags()[0] = false;
return this;
}
@Override
public GPageModel build() {
try {
GPageModel record = new GPageModel();
record.fieldGroups = fieldSetFlags()[0] ? this.fieldGroups : (java.util.List<ai.platon.pulsar.persist.gora.generated.GFieldGroup>) new org.apache.gora.persistency.impl.DirtyListWrapper((java.util.List)defaultValue(fields()[0]));
return record;
} catch (Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
public GPageModel.Tombstone getTombstone(){
return TOMBSTONE;
}
public GPageModel newInstance(){
return newBuilder().build();
}
private static final Tombstone TOMBSTONE = new Tombstone();
public static final class Tombstone extends GPageModel implements org.apache.gora.persistency.Tombstone {
private Tombstone() { }
/**
* Gets the value of the 'fieldGroups' field.
*/
public java.util.List<ai.platon.pulsar.persist.gora.generated.GFieldGroup> getFieldGroups() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'fieldGroups' field.
* @param value the value to set.
*/
public void setFieldGroups(java.util.List<ai.platon.pulsar.persist.gora.generated.GFieldGroup> value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'fieldGroups' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isFieldGroupsDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
}
private static final org.apache.avro.io.DatumWriter
DATUM_WRITER$ = new org.apache.avro.specific.SpecificDatumWriter(SCHEMA$);
private static final org.apache.avro.io.DatumReader
DATUM_READER$ = new org.apache.avro.specific.SpecificDatumReader(SCHEMA$);
/**
* Writes AVRO data bean to output stream in the form of AVRO Binary encoding format. This will transform
* AVRO data bean from its Java object form to it s serializable form.
*
* @param out java.io.ObjectOutput output stream to write data bean in serializable form
*/
@Override
public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
out.write(super.getDirtyBytes().array());
DATUM_WRITER$.write(this, org.apache.avro.io.EncoderFactory.get()
.directBinaryEncoder((java.io.OutputStream) out,
null));
}
/**
* Reads AVRO data bean from input stream in it s AVRO Binary encoding format to Java object format.
* This will transform AVRO data bean from it s serializable form to deserialized Java object form.
*
* @param in java.io.ObjectOutput input stream to read data bean in serializable form
*/
@Override
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
byte[] __g__dirty = new byte[getFieldsCount()];
in.read(__g__dirty);
super.setDirtyBytes(java.nio.ByteBuffer.wrap(__g__dirty));
DATUM_READER$.read(this, org.apache.avro.io.DecoderFactory.get()
.directBinaryDecoder((java.io.InputStream) in,
null));
}
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-persist/3.0.15/ai/platon/pulsar/persist/gora
|
java-sources/ai/platon/pulsar/pulsar-persist/3.0.15/ai/platon/pulsar/persist/gora/generated/GParseStatus.java
|
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package ai.platon.pulsar.persist.gora.generated;
import org.apache.gora.persistency.Persistent;
public class GParseStatus extends org.apache.gora.persistency.impl.PersistentBase implements org.apache.avro.specific.SpecificRecord, org.apache.gora.persistency.Persistent {
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"GParseStatus\",\"namespace\":\"ai.platon.pulsar.persist.gora.generated\",\"fields\":[{\"name\":\"majorCode\",\"type\":\"int\",\"default\":0},{\"name\":\"minorCode\",\"type\":\"int\",\"default\":0},{\"name\":\"args\",\"type\":{\"type\":\"map\",\"values\":[\"null\",\"string\"]},\"default\":{}}]}");
private static final long serialVersionUID = -2420792196436275871L;
/** Enum containing all data bean's fields. */
public static enum Field {
MAJOR_CODE(0, "majorCode"),
MINOR_CODE(1, "minorCode"),
ARGS(2, "args"),
;
/**
* Field's index.
*/
private int index;
/**
* Field's name.
*/
private String name;
/**
* Field's constructor
* @param index field's index.
* @param name field's name.
*/
Field(int index, String name) {this.index=index;this.name=name;}
/**
* Gets field's index.
* @return int field's index.
*/
public int getIndex() {return index;}
/**
* Gets field's name.
* @return String field's name.
*/
public String getName() {return name;}
/**
* Gets field's attributes to string.
* @return String field's attributes to string.
*/
public String toString() {return name;}
};
public static final String[] _ALL_FIELDS = {
"majorCode",
"minorCode",
"args",
};
/**
* Gets the total field count.
* @return int field count
*/
public int getFieldsCount() {
return GParseStatus._ALL_FIELDS.length;
}
@Override
public Persistent clone() {
return null;
}
private int majorCode;
private int minorCode;
private java.util.Map<java.lang.CharSequence,java.lang.CharSequence> args;
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return majorCode;
case 1: return minorCode;
case 2: return args;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value) {
switch (field$) {
case 0: majorCode = (java.lang.Integer)(value); break;
case 1: minorCode = (java.lang.Integer)(value); break;
case 2: args = (java.util.Map<java.lang.CharSequence,java.lang.CharSequence>)((value instanceof org.apache.gora.persistency.Dirtyable) ? value : new org.apache.gora.persistency.impl.DirtyMapWrapper((java.util.Map)value)); break;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
/**
* Gets the value of the 'majorCode' field.
*/
public java.lang.Integer getMajorCode() {
return majorCode;
}
/**
* Sets the value of the 'majorCode' field.
* @param value the value to set.
*/
public void setMajorCode(java.lang.Integer value) {
this.majorCode = value;
setDirty(0);
}
/**
* Checks the dirty status of the 'majorCode' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isMajorCodeDirty() {
return isDirty(0);
}
/**
* Gets the value of the 'minorCode' field.
*/
public java.lang.Integer getMinorCode() {
return minorCode;
}
/**
* Sets the value of the 'minorCode' field.
* @param value the value to set.
*/
public void setMinorCode(java.lang.Integer value) {
this.minorCode = value;
setDirty(1);
}
/**
* Checks the dirty status of the 'minorCode' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isMinorCodeDirty() {
return isDirty(1);
}
/**
* Gets the value of the 'args' field.
*/
public java.util.Map<java.lang.CharSequence,java.lang.CharSequence> getArgs() {
return args;
}
/**
* Sets the value of the 'args' field.
* @param value the value to set.
*/
public void setArgs(java.util.Map<java.lang.CharSequence,java.lang.CharSequence> value) {
this.args = (value instanceof org.apache.gora.persistency.Dirtyable) ? value : new org.apache.gora.persistency.impl.DirtyMapWrapper(value);
setDirty(2);
}
/**
* Checks the dirty status of the 'args' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isArgsDirty() {
return isDirty(2);
}
/** Creates a new GParseStatus RecordBuilder */
public static ai.platon.pulsar.persist.gora.generated.GParseStatus.Builder newBuilder() {
return new ai.platon.pulsar.persist.gora.generated.GParseStatus.Builder();
}
/** Creates a new GParseStatus RecordBuilder by copying an existing Builder */
public static ai.platon.pulsar.persist.gora.generated.GParseStatus.Builder newBuilder(ai.platon.pulsar.persist.gora.generated.GParseStatus.Builder other) {
return new ai.platon.pulsar.persist.gora.generated.GParseStatus.Builder(other);
}
/** Creates a new GParseStatus RecordBuilder by copying an existing GParseStatus instance */
public static ai.platon.pulsar.persist.gora.generated.GParseStatus.Builder newBuilder(ai.platon.pulsar.persist.gora.generated.GParseStatus other) {
return new ai.platon.pulsar.persist.gora.generated.GParseStatus.Builder(other);
}
private static java.nio.ByteBuffer deepCopyToReadOnlyBuffer(
java.nio.ByteBuffer input) {
java.nio.ByteBuffer copy = java.nio.ByteBuffer.allocate(input.capacity());
int position = input.position();
input.reset();
int mark = input.position();
int limit = input.limit();
input.rewind();
input.limit(input.capacity());
copy.put(input);
input.rewind();
copy.rewind();
input.position(mark);
input.mark();
copy.position(mark);
copy.mark();
input.position(position);
copy.position(position);
input.limit(limit);
copy.limit(limit);
return copy.asReadOnlyBuffer();
}
/**
* RecordBuilder for GParseStatus instances.
*/
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<GParseStatus>
implements org.apache.avro.data.RecordBuilder<GParseStatus> {
private int majorCode;
private int minorCode;
private java.util.Map<java.lang.CharSequence,java.lang.CharSequence> args;
/** Creates a new Builder */
private Builder() {
super(ai.platon.pulsar.persist.gora.generated.GParseStatus.SCHEMA$);
}
/** Creates a Builder by copying an existing Builder */
private Builder(ai.platon.pulsar.persist.gora.generated.GParseStatus.Builder other) {
super(other);
}
/** Creates a Builder by copying an existing GParseStatus instance */
private Builder(ai.platon.pulsar.persist.gora.generated.GParseStatus other) {
super(ai.platon.pulsar.persist.gora.generated.GParseStatus.SCHEMA$);
if (isValidValue(fields()[0], other.majorCode)) {
this.majorCode = (java.lang.Integer) data().deepCopy(fields()[0].schema(), other.majorCode);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.minorCode)) {
this.minorCode = (java.lang.Integer) data().deepCopy(fields()[1].schema(), other.minorCode);
fieldSetFlags()[1] = true;
}
if (isValidValue(fields()[2], other.args)) {
this.args = (java.util.Map<java.lang.CharSequence,java.lang.CharSequence>) data().deepCopy(fields()[2].schema(), other.args);
fieldSetFlags()[2] = true;
}
}
/** Gets the value of the 'majorCode' field */
public java.lang.Integer getMajorCode() {
return majorCode;
}
/** Sets the value of the 'majorCode' field */
public ai.platon.pulsar.persist.gora.generated.GParseStatus.Builder setMajorCode(int value) {
validate(fields()[0], value);
this.majorCode = value;
fieldSetFlags()[0] = true;
return this;
}
/** Checks whether the 'majorCode' field has been set */
public boolean hasMajorCode() {
return fieldSetFlags()[0];
}
/** Clears the value of the 'majorCode' field */
public ai.platon.pulsar.persist.gora.generated.GParseStatus.Builder clearMajorCode() {
fieldSetFlags()[0] = false;
return this;
}
/** Gets the value of the 'minorCode' field */
public java.lang.Integer getMinorCode() {
return minorCode;
}
/** Sets the value of the 'minorCode' field */
public ai.platon.pulsar.persist.gora.generated.GParseStatus.Builder setMinorCode(int value) {
validate(fields()[1], value);
this.minorCode = value;
fieldSetFlags()[1] = true;
return this;
}
/** Checks whether the 'minorCode' field has been set */
public boolean hasMinorCode() {
return fieldSetFlags()[1];
}
/** Clears the value of the 'minorCode' field */
public ai.platon.pulsar.persist.gora.generated.GParseStatus.Builder clearMinorCode() {
fieldSetFlags()[1] = false;
return this;
}
/** Gets the value of the 'args' field */
public java.util.Map<java.lang.CharSequence,java.lang.CharSequence> getArgs() {
return args;
}
/** Sets the value of the 'args' field */
public ai.platon.pulsar.persist.gora.generated.GParseStatus.Builder setArgs(java.util.Map<java.lang.CharSequence,java.lang.CharSequence> value) {
validate(fields()[2], value);
this.args = value;
fieldSetFlags()[2] = true;
return this;
}
/** Checks whether the 'args' field has been set */
public boolean hasArgs() {
return fieldSetFlags()[2];
}
/** Clears the value of the 'args' field */
public ai.platon.pulsar.persist.gora.generated.GParseStatus.Builder clearArgs() {
args = null;
fieldSetFlags()[2] = false;
return this;
}
@Override
public GParseStatus build() {
try {
GParseStatus record = new GParseStatus();
record.majorCode = fieldSetFlags()[0] ? this.majorCode : (java.lang.Integer) defaultValue(fields()[0]);
record.minorCode = fieldSetFlags()[1] ? this.minorCode : (java.lang.Integer) defaultValue(fields()[1]);
record.args = fieldSetFlags()[2] ? this.args : (java.util.Map<java.lang.CharSequence,java.lang.CharSequence>) new org.apache.gora.persistency.impl.DirtyMapWrapper((java.util.Map)defaultValue(fields()[2]));
return record;
} catch (Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
public GParseStatus.Tombstone getTombstone(){
return TOMBSTONE;
}
public GParseStatus newInstance(){
return newBuilder().build();
}
private static final Tombstone TOMBSTONE = new Tombstone();
public static final class Tombstone extends GParseStatus implements org.apache.gora.persistency.Tombstone {
private Tombstone() { }
/**
* Gets the value of the 'majorCode' field.
*/
public java.lang.Integer getMajorCode() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'majorCode' field.
* @param value the value to set.
*/
public void setMajorCode(java.lang.Integer value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'majorCode' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isMajorCodeDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'minorCode' field.
*/
public java.lang.Integer getMinorCode() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'minorCode' field.
* @param value the value to set.
*/
public void setMinorCode(java.lang.Integer value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'minorCode' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isMinorCodeDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'args' field.
*/
public java.util.Map<java.lang.CharSequence,java.lang.CharSequence> getArgs() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'args' field.
* @param value the value to set.
*/
public void setArgs(java.util.Map<java.lang.CharSequence,java.lang.CharSequence> value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'args' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isArgsDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
}
private static final org.apache.avro.io.DatumWriter
DATUM_WRITER$ = new org.apache.avro.specific.SpecificDatumWriter(SCHEMA$);
private static final org.apache.avro.io.DatumReader
DATUM_READER$ = new org.apache.avro.specific.SpecificDatumReader(SCHEMA$);
/**
* Writes AVRO data bean to output stream in the form of AVRO Binary encoding format. This will transform
* AVRO data bean from its Java object form to it s serializable form.
*
* @param out java.io.ObjectOutput output stream to write data bean in serializable form
*/
@Override
public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
out.write(super.getDirtyBytes().array());
DATUM_WRITER$.write(this, org.apache.avro.io.EncoderFactory.get()
.directBinaryEncoder((java.io.OutputStream) out,
null));
}
/**
* Reads AVRO data bean from input stream in it s AVRO Binary encoding format to Java object format.
* This will transform AVRO data bean from it s serializable form to deserialized Java object form.
*
* @param in java.io.ObjectOutput input stream to read data bean in serializable form
*/
@Override
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
byte[] __g__dirty = new byte[getFieldsCount()];
in.read(__g__dirty);
super.setDirtyBytes(java.nio.ByteBuffer.wrap(__g__dirty));
DATUM_READER$.read(this, org.apache.avro.io.DecoderFactory.get()
.directBinaryDecoder((java.io.InputStream) in,
null));
}
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-persist/3.0.15/ai/platon/pulsar/persist/gora
|
java-sources/ai/platon/pulsar/pulsar-persist/3.0.15/ai/platon/pulsar/persist/gora/generated/GProtocolStatus.java
|
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package ai.platon.pulsar.persist.gora.generated;
import org.apache.gora.persistency.Persistent;
public class GProtocolStatus extends org.apache.gora.persistency.impl.PersistentBase implements org.apache.avro.specific.SpecificRecord, org.apache.gora.persistency.Persistent {
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"GProtocolStatus\",\"namespace\":\"ai.platon.pulsar.persist.gora.generated\",\"fields\":[{\"name\":\"majorCode\",\"type\":\"int\",\"default\":0},{\"name\":\"minorCode\",\"type\":\"int\",\"default\":0},{\"name\":\"args\",\"type\":{\"type\":\"map\",\"values\":[\"null\",\"string\"]},\"default\":{}}]}");
private static final long serialVersionUID = -8483753504949867796L;
/** Enum containing all data bean's fields. */
public static enum Field {
MAJOR_CODE(0, "majorCode"),
MINOR_CODE(1, "minorCode"),
ARGS(2, "args"),
;
/**
* Field's index.
*/
private int index;
/**
* Field's name.
*/
private String name;
/**
* Field's constructor
* @param index field's index.
* @param name field's name.
*/
Field(int index, String name) {this.index=index;this.name=name;}
/**
* Gets field's index.
* @return int field's index.
*/
public int getIndex() {return index;}
/**
* Gets field's name.
* @return String field's name.
*/
public String getName() {return name;}
/**
* Gets field's attributes to string.
* @return String field's attributes to string.
*/
public String toString() {return name;}
};
public static final String[] _ALL_FIELDS = {
"majorCode",
"minorCode",
"args",
};
/**
* Gets the total field count.
* @return int field count
*/
public int getFieldsCount() {
return GProtocolStatus._ALL_FIELDS.length;
}
@Override
public Persistent clone() {
return null;
}
private int majorCode;
private int minorCode;
private java.util.Map<java.lang.CharSequence,java.lang.CharSequence> args;
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return majorCode;
case 1: return minorCode;
case 2: return args;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value) {
switch (field$) {
case 0: majorCode = (java.lang.Integer)(value); break;
case 1: minorCode = (java.lang.Integer)(value); break;
case 2: args = (java.util.Map<java.lang.CharSequence,java.lang.CharSequence>)((value instanceof org.apache.gora.persistency.Dirtyable) ? value : new org.apache.gora.persistency.impl.DirtyMapWrapper((java.util.Map)value)); break;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
/**
* Gets the value of the 'majorCode' field.
*/
public java.lang.Integer getMajorCode() {
return majorCode;
}
/**
* Sets the value of the 'majorCode' field.
* @param value the value to set.
*/
public void setMajorCode(java.lang.Integer value) {
this.majorCode = value;
setDirty(0);
}
/**
* Checks the dirty status of the 'majorCode' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isMajorCodeDirty() {
return isDirty(0);
}
/**
* Gets the value of the 'minorCode' field.
*/
public java.lang.Integer getMinorCode() {
return minorCode;
}
/**
* Sets the value of the 'minorCode' field.
* @param value the value to set.
*/
public void setMinorCode(java.lang.Integer value) {
this.minorCode = value;
setDirty(1);
}
/**
* Checks the dirty status of the 'minorCode' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isMinorCodeDirty() {
return isDirty(1);
}
/**
* Gets the value of the 'args' field.
*/
public java.util.Map<java.lang.CharSequence,java.lang.CharSequence> getArgs() {
return args;
}
/**
* Sets the value of the 'args' field.
* @param value the value to set.
*/
public void setArgs(java.util.Map<java.lang.CharSequence,java.lang.CharSequence> value) {
this.args = (value instanceof org.apache.gora.persistency.Dirtyable) ? value : new org.apache.gora.persistency.impl.DirtyMapWrapper(value);
setDirty(2);
}
/**
* Checks the dirty status of the 'args' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isArgsDirty() {
return isDirty(2);
}
/** Creates a new GProtocolStatus RecordBuilder */
public static ai.platon.pulsar.persist.gora.generated.GProtocolStatus.Builder newBuilder() {
return new ai.platon.pulsar.persist.gora.generated.GProtocolStatus.Builder();
}
/** Creates a new GProtocolStatus RecordBuilder by copying an existing Builder */
public static ai.platon.pulsar.persist.gora.generated.GProtocolStatus.Builder newBuilder(ai.platon.pulsar.persist.gora.generated.GProtocolStatus.Builder other) {
return new ai.platon.pulsar.persist.gora.generated.GProtocolStatus.Builder(other);
}
/** Creates a new GProtocolStatus RecordBuilder by copying an existing GProtocolStatus instance */
public static ai.platon.pulsar.persist.gora.generated.GProtocolStatus.Builder newBuilder(ai.platon.pulsar.persist.gora.generated.GProtocolStatus other) {
return new ai.platon.pulsar.persist.gora.generated.GProtocolStatus.Builder(other);
}
private static java.nio.ByteBuffer deepCopyToReadOnlyBuffer(
java.nio.ByteBuffer input) {
java.nio.ByteBuffer copy = java.nio.ByteBuffer.allocate(input.capacity());
int position = input.position();
input.reset();
int mark = input.position();
int limit = input.limit();
input.rewind();
input.limit(input.capacity());
copy.put(input);
input.rewind();
copy.rewind();
input.position(mark);
input.mark();
copy.position(mark);
copy.mark();
input.position(position);
copy.position(position);
input.limit(limit);
copy.limit(limit);
return copy.asReadOnlyBuffer();
}
/**
* RecordBuilder for GProtocolStatus instances.
*/
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<GProtocolStatus>
implements org.apache.avro.data.RecordBuilder<GProtocolStatus> {
private int majorCode;
private int minorCode;
private java.util.Map<java.lang.CharSequence,java.lang.CharSequence> args;
/** Creates a new Builder */
private Builder() {
super(ai.platon.pulsar.persist.gora.generated.GProtocolStatus.SCHEMA$);
}
/** Creates a Builder by copying an existing Builder */
private Builder(ai.platon.pulsar.persist.gora.generated.GProtocolStatus.Builder other) {
super(other);
}
/** Creates a Builder by copying an existing GProtocolStatus instance */
private Builder(ai.platon.pulsar.persist.gora.generated.GProtocolStatus other) {
super(ai.platon.pulsar.persist.gora.generated.GProtocolStatus.SCHEMA$);
if (isValidValue(fields()[0], other.majorCode)) {
this.majorCode = (java.lang.Integer) data().deepCopy(fields()[0].schema(), other.majorCode);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.minorCode)) {
this.minorCode = (java.lang.Integer) data().deepCopy(fields()[1].schema(), other.minorCode);
fieldSetFlags()[1] = true;
}
if (isValidValue(fields()[2], other.args)) {
this.args = (java.util.Map<java.lang.CharSequence,java.lang.CharSequence>) data().deepCopy(fields()[2].schema(), other.args);
fieldSetFlags()[2] = true;
}
}
/** Gets the value of the 'majorCode' field */
public java.lang.Integer getMajorCode() {
return majorCode;
}
/** Sets the value of the 'majorCode' field */
public ai.platon.pulsar.persist.gora.generated.GProtocolStatus.Builder setMajorCode(int value) {
validate(fields()[0], value);
this.majorCode = value;
fieldSetFlags()[0] = true;
return this;
}
/** Checks whether the 'majorCode' field has been set */
public boolean hasMajorCode() {
return fieldSetFlags()[0];
}
/** Clears the value of the 'majorCode' field */
public ai.platon.pulsar.persist.gora.generated.GProtocolStatus.Builder clearMajorCode() {
fieldSetFlags()[0] = false;
return this;
}
/** Gets the value of the 'minorCode' field */
public java.lang.Integer getMinorCode() {
return minorCode;
}
/** Sets the value of the 'minorCode' field */
public ai.platon.pulsar.persist.gora.generated.GProtocolStatus.Builder setMinorCode(int value) {
validate(fields()[1], value);
this.minorCode = value;
fieldSetFlags()[1] = true;
return this;
}
/** Checks whether the 'minorCode' field has been set */
public boolean hasMinorCode() {
return fieldSetFlags()[1];
}
/** Clears the value of the 'minorCode' field */
public ai.platon.pulsar.persist.gora.generated.GProtocolStatus.Builder clearMinorCode() {
fieldSetFlags()[1] = false;
return this;
}
/** Gets the value of the 'args' field */
public java.util.Map<java.lang.CharSequence,java.lang.CharSequence> getArgs() {
return args;
}
/** Sets the value of the 'args' field */
public ai.platon.pulsar.persist.gora.generated.GProtocolStatus.Builder setArgs(java.util.Map<java.lang.CharSequence,java.lang.CharSequence> value) {
validate(fields()[2], value);
this.args = value;
fieldSetFlags()[2] = true;
return this;
}
/** Checks whether the 'args' field has been set */
public boolean hasArgs() {
return fieldSetFlags()[2];
}
/** Clears the value of the 'args' field */
public ai.platon.pulsar.persist.gora.generated.GProtocolStatus.Builder clearArgs() {
args = null;
fieldSetFlags()[2] = false;
return this;
}
@Override
public GProtocolStatus build() {
try {
GProtocolStatus record = new GProtocolStatus();
record.majorCode = fieldSetFlags()[0] ? this.majorCode : (java.lang.Integer) defaultValue(fields()[0]);
record.minorCode = fieldSetFlags()[1] ? this.minorCode : (java.lang.Integer) defaultValue(fields()[1]);
record.args = fieldSetFlags()[2] ? this.args : (java.util.Map<java.lang.CharSequence,java.lang.CharSequence>) new org.apache.gora.persistency.impl.DirtyMapWrapper((java.util.Map)defaultValue(fields()[2]));
return record;
} catch (Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
public GProtocolStatus.Tombstone getTombstone(){
return TOMBSTONE;
}
public GProtocolStatus newInstance(){
return newBuilder().build();
}
private static final Tombstone TOMBSTONE = new Tombstone();
public static final class Tombstone extends GProtocolStatus implements org.apache.gora.persistency.Tombstone {
private Tombstone() { }
/**
* Gets the value of the 'majorCode' field.
*/
public java.lang.Integer getMajorCode() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'majorCode' field.
* @param value the value to set.
*/
public void setMajorCode(java.lang.Integer value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'majorCode' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isMajorCodeDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'minorCode' field.
*/
public java.lang.Integer getMinorCode() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'minorCode' field.
* @param value the value to set.
*/
public void setMinorCode(java.lang.Integer value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'minorCode' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isMinorCodeDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'args' field.
*/
public java.util.Map<java.lang.CharSequence,java.lang.CharSequence> getArgs() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'args' field.
* @param value the value to set.
*/
public void setArgs(java.util.Map<java.lang.CharSequence,java.lang.CharSequence> value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'args' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isArgsDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
}
private static final org.apache.avro.io.DatumWriter
DATUM_WRITER$ = new org.apache.avro.specific.SpecificDatumWriter(SCHEMA$);
private static final org.apache.avro.io.DatumReader
DATUM_READER$ = new org.apache.avro.specific.SpecificDatumReader(SCHEMA$);
/**
* Writes AVRO data bean to output stream in the form of AVRO Binary encoding format. This will transform
* AVRO data bean from its Java object form to it s serializable form.
*
* @param out java.io.ObjectOutput output stream to write data bean in serializable form
*/
@Override
public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
out.write(super.getDirtyBytes().array());
DATUM_WRITER$.write(this, org.apache.avro.io.EncoderFactory.get()
.directBinaryEncoder((java.io.OutputStream) out,
null));
}
/**
* Reads AVRO data bean from input stream in it s AVRO Binary encoding format to Java object format.
* This will transform AVRO data bean from it s serializable form to deserialized Java object form.
*
* @param in java.io.ObjectOutput input stream to read data bean in serializable form
*/
@Override
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
byte[] __g__dirty = new byte[getFieldsCount()];
in.read(__g__dirty);
super.setDirtyBytes(java.nio.ByteBuffer.wrap(__g__dirty));
DATUM_READER$.read(this, org.apache.avro.io.DecoderFactory.get()
.directBinaryDecoder((java.io.InputStream) in,
null));
}
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-persist/3.0.15/ai/platon/pulsar/persist/gora
|
java-sources/ai/platon/pulsar/pulsar-persist/3.0.15/ai/platon/pulsar/persist/gora/generated/GWebPage.java
|
/**
*Licensed to the Apache Software Foundation (ASF) under one
*or more contributor license agreements. See the NOTICE file
*distributed with this work for additional information
*regarding copyright ownership. The ASF licenses this file
*to you under the Apache License, Version 2.0 (the"
*License"); you may not use this file except in compliance
*with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing, software
*distributed under the License is distributed on an "AS IS" BASIS,
*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*See the License for the specific language governing permissions and
*limitations under the License.
*/
package ai.platon.pulsar.persist.gora.generated;
import org.apache.gora.persistency.Persistent;
public class GWebPage extends org.apache.gora.persistency.impl.PersistentBase implements org.apache.avro.specific.SpecificRecord, org.apache.gora.persistency.Persistent {
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"GWebPage\",\"namespace\":\"ai.platon.pulsar.persist.gora.generated\",\"fields\":[{\"name\":\"baseUrl\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"createTime\",\"type\":\"long\",\"default\":0},{\"name\":\"distance\",\"type\":\"int\",\"default\":-1},{\"name\":\"fetchCount\",\"type\":\"int\",\"default\":0},{\"name\":\"fetchPriority\",\"type\":\"int\",\"default\":0},{\"name\":\"fetchInterval\",\"type\":\"int\",\"default\":0},{\"name\":\"zoneId\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"params\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"batchId\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"resource\",\"type\":[\"null\",\"int\"],\"default\":null},{\"name\":\"crawlStatus\",\"type\":\"int\",\"default\":0},{\"name\":\"browser\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"proxy\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"prevFetchTime\",\"type\":\"long\",\"default\":0},{\"name\":\"prevCrawlTime1\",\"type\":\"long\",\"default\":0},{\"name\":\"fetchTime\",\"type\":\"long\",\"default\":0},{\"name\":\"fetchRetries\",\"type\":\"int\",\"default\":0},{\"name\":\"reprUrl\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"prevModifiedTime\",\"type\":\"long\",\"default\":0},{\"name\":\"modifiedTime\",\"type\":\"long\",\"default\":0},{\"name\":\"protocolStatus\",\"type\":[\"null\",{\"type\":\"record\",\"name\":\"GProtocolStatus\",\"fields\":[{\"name\":\"majorCode\",\"type\":\"int\",\"default\":0},{\"name\":\"minorCode\",\"type\":\"int\",\"default\":0},{\"name\":\"args\",\"type\":{\"type\":\"map\",\"values\":[\"null\",\"string\"]},\"default\":{}}]}],\"default\":null},{\"name\":\"encoding\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"contentType\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"content\",\"type\":[\"null\",\"bytes\"],\"doc\":\"The entire raw document content e.g. raw XHTML\",\"default\":null},{\"name\":\"contentLength\",\"type\":\"long\",\"default\":0},{\"name\":\"lastContentLength\",\"type\":\"long\",\"default\":0},{\"name\":\"aveContentLength\",\"type\":\"long\",\"default\":0},{\"name\":\"persistedContentLength\",\"type\":\"long\",\"default\":0},{\"name\":\"referrer\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"htmlIntegrity\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"anchor\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"anchorOrder\",\"type\":\"int\",\"default\":-1},{\"name\":\"parseStatus\",\"type\":[\"null\",{\"type\":\"record\",\"name\":\"GParseStatus\",\"fields\":[{\"name\":\"majorCode\",\"type\":\"int\",\"default\":0},{\"name\":\"minorCode\",\"type\":\"int\",\"default\":0},{\"name\":\"args\",\"type\":{\"type\":\"map\",\"values\":[\"null\",\"string\"]},\"default\":{}}]}],\"default\":null},{\"name\":\"pageTitle\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"pageText\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"contentTitle\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"contentText\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"contentTextLen\",\"type\":\"int\",\"default\":0},{\"name\":\"pageCategory\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"contentModifiedTime\",\"type\":\"long\",\"default\":0},{\"name\":\"prevContentModifiedTime\",\"type\":\"long\",\"default\":0},{\"name\":\"contentPublishTime\",\"type\":\"long\",\"default\":0},{\"name\":\"prevContentPublishTime\",\"type\":\"long\",\"default\":0},{\"name\":\"refContentPublishTime\",\"type\":\"long\",\"default\":0},{\"name\":\"prevRefContentPublishTime\",\"type\":\"long\",\"default\":0},{\"name\":\"pageModelUpdateTime\",\"type\":\"long\",\"default\":0},{\"name\":\"prevSignature\",\"type\":[\"null\",\"bytes\"],\"default\":null},{\"name\":\"signature\",\"type\":[\"null\",\"bytes\"],\"default\":null},{\"name\":\"contentScore\",\"type\":\"float\",\"default\":0},{\"name\":\"score\",\"type\":\"float\",\"default\":0},{\"name\":\"sortScore\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"pageCounters\",\"type\":{\"type\":\"map\",\"values\":[\"null\",\"int\"]},\"default\":{}},{\"name\":\"headers\",\"type\":{\"type\":\"map\",\"values\":[\"null\",\"string\"]},\"default\":{}},{\"name\":\"links\",\"type\":{\"type\":\"array\",\"items\":\"string\"},\"default\":[]},{\"name\":\"deadLinks\",\"type\":{\"type\":\"array\",\"items\":\"string\"},\"default\":[]},{\"name\":\"liveLinks\",\"type\":{\"type\":\"map\",\"values\":[\"null\",{\"type\":\"record\",\"name\":\"GHypeLink\",\"fields\":[{\"name\":\"url\",\"type\":\"string\",\"default\":\"\"},{\"name\":\"anchor\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"order\",\"type\":\"int\",\"default\":0}]}]},\"default\":[]},{\"name\":\"vividLinks\",\"type\":{\"type\":\"map\",\"values\":[\"null\",\"string\"]},\"default\":{}},{\"name\":\"inlinks\",\"type\":{\"type\":\"map\",\"values\":[\"null\",\"string\"]},\"default\":{}},{\"name\":\"markers\",\"type\":{\"type\":\"map\",\"values\":[\"null\",\"string\"]},\"default\":{}},{\"name\":\"metadata\",\"type\":{\"type\":\"map\",\"values\":[\"null\",\"bytes\"]},\"default\":{}},{\"name\":\"activeDOMStatus\",\"type\":[\"null\",{\"type\":\"record\",\"name\":\"GActiveDOMStatus\",\"fields\":[{\"name\":\"n\",\"type\":\"int\",\"default\":0},{\"name\":\"scroll\",\"type\":\"int\",\"default\":0},{\"name\":\"st\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"r\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"idl\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"ec\",\"type\":[\"null\",\"string\"],\"default\":null}]}],\"default\":null},{\"name\":\"activeDOMStatTrace\",\"type\":{\"type\":\"map\",\"values\":[\"null\",{\"type\":\"record\",\"name\":\"GActiveDOMStat\",\"fields\":[{\"name\":\"ni\",\"type\":\"int\",\"default\":0},{\"name\":\"na\",\"type\":\"int\",\"default\":0},{\"name\":\"nnm\",\"type\":\"int\",\"default\":0},{\"name\":\"nst\",\"type\":\"int\",\"default\":0},{\"name\":\"w\",\"type\":\"int\",\"default\":0},{\"name\":\"h\",\"type\":\"int\",\"default\":0}]}]},\"default\":null},{\"name\":\"pageModel\",\"type\":[\"null\",{\"type\":\"record\",\"name\":\"GPageModel\",\"fields\":[{\"name\":\"fieldGroups\",\"type\":{\"type\":\"array\",\"items\":{\"type\":\"record\",\"name\":\"GFieldGroup\",\"fields\":[{\"name\":\"id\",\"type\":\"long\",\"default\":0},{\"name\":\"parentId\",\"type\":\"long\",\"default\":0},{\"name\":\"name\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"fields\",\"type\":{\"type\":\"map\",\"values\":[\"null\",\"string\"]},\"default\":{}}]}},\"default\":[]}]}],\"default\":null}]}");
private static final long serialVersionUID = 4938242756794613472L;
/** Enum containing all data bean's fields. */
public static enum Field {
BASE_URL(0, "baseUrl"),
CREATE_TIME(1, "createTime"),
DISTANCE(2, "distance"),
FETCH_COUNT(3, "fetchCount"),
FETCH_PRIORITY(4, "fetchPriority"),
FETCH_INTERVAL(5, "fetchInterval"),
ZONE_ID(6, "zoneId"),
PARAMS(7, "params"),
BATCH_ID(8, "batchId"),
RESOURCE(9, "resource"),
CRAWL_STATUS(10, "crawlStatus"),
BROWSER(11, "browser"),
PROXY(12, "proxy"),
PREV_FETCH_TIME(13, "prevFetchTime"),
PREV_CRAWL_TIME1(14, "prevCrawlTime1"),
FETCH_TIME(15, "fetchTime"),
FETCH_RETRIES(16, "fetchRetries"),
REPR_URL(17, "reprUrl"),
PREV_MODIFIED_TIME(18, "prevModifiedTime"),
MODIFIED_TIME(19, "modifiedTime"),
PROTOCOL_STATUS(20, "protocolStatus"),
ENCODING(21, "encoding"),
CONTENT_TYPE(22, "contentType"),
CONTENT(23, "content"),
CONTENT_LENGTH(24, "contentLength"),
LAST_CONTENT_LENGTH(25, "lastContentLength"),
AVE_CONTENT_LENGTH(26, "aveContentLength"),
PERSISTED_CONTENT_LENGTH(27, "persistedContentLength"),
REFERRER(28, "referrer"),
HTML_INTEGRITY(29, "htmlIntegrity"),
ANCHOR(30, "anchor"),
ANCHOR_ORDER(31, "anchorOrder"),
PARSE_STATUS(32, "parseStatus"),
PAGE_TITLE(33, "pageTitle"),
PAGE_TEXT(34, "pageText"),
CONTENT_TITLE(35, "contentTitle"),
CONTENT_TEXT(36, "contentText"),
CONTENT_TEXT_LEN(37, "contentTextLen"),
PAGE_CATEGORY(38, "pageCategory"),
CONTENT_MODIFIED_TIME(39, "contentModifiedTime"),
PREV_CONTENT_MODIFIED_TIME(40, "prevContentModifiedTime"),
CONTENT_PUBLISH_TIME(41, "contentPublishTime"),
PREV_CONTENT_PUBLISH_TIME(42, "prevContentPublishTime"),
REF_CONTENT_PUBLISH_TIME(43, "refContentPublishTime"),
PREV_REF_CONTENT_PUBLISH_TIME(44, "prevRefContentPublishTime"),
PAGE_MODEL_UPDATE_TIME(45, "pageModelUpdateTime"),
PREV_SIGNATURE(46, "prevSignature"),
SIGNATURE(47, "signature"),
CONTENT_SCORE(48, "contentScore"),
SCORE(49, "score"),
SORT_SCORE(50, "sortScore"),
PAGE_COUNTERS(51, "pageCounters"),
HEADERS(52, "headers"),
LINKS(53, "links"),
DEAD_LINKS(54, "deadLinks"),
LIVE_LINKS(55, "liveLinks"),
VIVID_LINKS(56, "vividLinks"),
INLINKS(57, "inlinks"),
MARKERS(58, "markers"),
METADATA(59, "metadata"),
ACTIVE_DOMSTATUS(60, "activeDOMStatus"),
ACTIVE_DOMSTAT_TRACE(61, "activeDOMStatTrace"),
PAGE_MODEL(62, "pageModel"),
;
/**
* Field's index.
*/
private int index;
/**
* Field's name.
*/
private String name;
/**
* Field's constructor
* @param index field's index.
* @param name field's name.
*/
Field(int index, String name) {this.index=index;this.name=name;}
/**
* Gets field's index.
* @return int field's index.
*/
public int getIndex() {return index;}
/**
* Gets field's name.
* @return String field's name.
*/
public String getName() {return name;}
/**
* Gets field's attributes to string.
* @return String field's attributes to string.
*/
public String toString() {return name;}
};
public static final String[] _ALL_FIELDS = {
"baseUrl",
"createTime",
"distance",
"fetchCount",
"fetchPriority",
"fetchInterval",
"zoneId",
"params",
"batchId",
"resource",
"crawlStatus",
"browser",
"proxy",
"prevFetchTime",
"prevCrawlTime1",
"fetchTime",
"fetchRetries",
"reprUrl",
"prevModifiedTime",
"modifiedTime",
"protocolStatus",
"encoding",
"contentType",
"content",
"contentLength",
"lastContentLength",
"aveContentLength",
"persistedContentLength",
"referrer",
"htmlIntegrity",
"anchor",
"anchorOrder",
"parseStatus",
"pageTitle",
"pageText",
"contentTitle",
"contentText",
"contentTextLen",
"pageCategory",
"contentModifiedTime",
"prevContentModifiedTime",
"contentPublishTime",
"prevContentPublishTime",
"refContentPublishTime",
"prevRefContentPublishTime",
"pageModelUpdateTime",
"prevSignature",
"signature",
"contentScore",
"score",
"sortScore",
"pageCounters",
"headers",
"links",
"deadLinks",
"liveLinks",
"vividLinks",
"inlinks",
"markers",
"metadata",
"activeDOMStatus",
"activeDOMStatTrace",
"pageModel",
};
/**
* Gets the total field count.
* @return int field count
*/
public int getFieldsCount() {
return GWebPage._ALL_FIELDS.length;
}
@Override
public Persistent clone() {
return null;
}
private java.lang.CharSequence baseUrl;
private long createTime;
private int distance;
private int fetchCount;
private int fetchPriority;
private int fetchInterval;
private java.lang.CharSequence zoneId;
private java.lang.CharSequence params;
private java.lang.CharSequence batchId;
private java.lang.Integer resource;
private int crawlStatus;
private java.lang.CharSequence browser;
private java.lang.CharSequence proxy;
private long prevFetchTime;
private long prevCrawlTime1;
private long fetchTime;
private int fetchRetries;
private java.lang.CharSequence reprUrl;
private long prevModifiedTime;
private long modifiedTime;
private ai.platon.pulsar.persist.gora.generated.GProtocolStatus protocolStatus;
private java.lang.CharSequence encoding;
private java.lang.CharSequence contentType;
/** The entire raw document content e.g. raw XHTML */
private java.nio.ByteBuffer content;
private long contentLength;
private long lastContentLength;
private long aveContentLength;
private long persistedContentLength;
private java.lang.CharSequence referrer;
private java.lang.CharSequence htmlIntegrity;
private java.lang.CharSequence anchor;
private int anchorOrder;
private ai.platon.pulsar.persist.gora.generated.GParseStatus parseStatus;
private java.lang.CharSequence pageTitle;
private java.lang.CharSequence pageText;
private java.lang.CharSequence contentTitle;
private java.lang.CharSequence contentText;
private int contentTextLen;
private java.lang.CharSequence pageCategory;
private long contentModifiedTime;
private long prevContentModifiedTime;
private long contentPublishTime;
private long prevContentPublishTime;
private long refContentPublishTime;
private long prevRefContentPublishTime;
private long pageModelUpdateTime;
private java.nio.ByteBuffer prevSignature;
private java.nio.ByteBuffer signature;
private float contentScore;
private float score;
private java.lang.CharSequence sortScore;
private java.util.Map<java.lang.CharSequence,java.lang.Integer> pageCounters;
private java.util.Map<java.lang.CharSequence,java.lang.CharSequence> headers;
private java.util.List<java.lang.CharSequence> links;
private java.util.List<java.lang.CharSequence> deadLinks;
private java.util.Map<java.lang.CharSequence,ai.platon.pulsar.persist.gora.generated.GHypeLink> liveLinks;
private java.util.Map<java.lang.CharSequence,java.lang.CharSequence> vividLinks;
private java.util.Map<java.lang.CharSequence,java.lang.CharSequence> inlinks;
private java.util.Map<java.lang.CharSequence,java.lang.CharSequence> markers;
private java.util.Map<java.lang.CharSequence,java.nio.ByteBuffer> metadata;
private ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus activeDOMStatus;
private java.util.Map<java.lang.CharSequence,ai.platon.pulsar.persist.gora.generated.GActiveDOMStat> activeDOMStatTrace;
private ai.platon.pulsar.persist.gora.generated.GPageModel pageModel;
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return baseUrl;
case 1: return createTime;
case 2: return distance;
case 3: return fetchCount;
case 4: return fetchPriority;
case 5: return fetchInterval;
case 6: return zoneId;
case 7: return params;
case 8: return batchId;
case 9: return resource;
case 10: return crawlStatus;
case 11: return browser;
case 12: return proxy;
case 13: return prevFetchTime;
case 14: return prevCrawlTime1;
case 15: return fetchTime;
case 16: return fetchRetries;
case 17: return reprUrl;
case 18: return prevModifiedTime;
case 19: return modifiedTime;
case 20: return protocolStatus;
case 21: return encoding;
case 22: return contentType;
case 23: return content;
case 24: return contentLength;
case 25: return lastContentLength;
case 26: return aveContentLength;
case 27: return persistedContentLength;
case 28: return referrer;
case 29: return htmlIntegrity;
case 30: return anchor;
case 31: return anchorOrder;
case 32: return parseStatus;
case 33: return pageTitle;
case 34: return pageText;
case 35: return contentTitle;
case 36: return contentText;
case 37: return contentTextLen;
case 38: return pageCategory;
case 39: return contentModifiedTime;
case 40: return prevContentModifiedTime;
case 41: return contentPublishTime;
case 42: return prevContentPublishTime;
case 43: return refContentPublishTime;
case 44: return prevRefContentPublishTime;
case 45: return pageModelUpdateTime;
case 46: return prevSignature;
case 47: return signature;
case 48: return contentScore;
case 49: return score;
case 50: return sortScore;
case 51: return pageCounters;
case 52: return headers;
case 53: return links;
case 54: return deadLinks;
case 55: return liveLinks;
case 56: return vividLinks;
case 57: return inlinks;
case 58: return markers;
case 59: return metadata;
case 60: return activeDOMStatus;
case 61: return activeDOMStatTrace;
case 62: return pageModel;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value) {
switch (field$) {
case 0: baseUrl = (java.lang.CharSequence)(value); break;
case 1: createTime = (java.lang.Long)(value); break;
case 2: distance = (java.lang.Integer)(value); break;
case 3: fetchCount = (java.lang.Integer)(value); break;
case 4: fetchPriority = (java.lang.Integer)(value); break;
case 5: fetchInterval = (java.lang.Integer)(value); break;
case 6: zoneId = (java.lang.CharSequence)(value); break;
case 7: params = (java.lang.CharSequence)(value); break;
case 8: batchId = (java.lang.CharSequence)(value); break;
case 9: resource = (java.lang.Integer)(value); break;
case 10: crawlStatus = (java.lang.Integer)(value); break;
case 11: browser = (java.lang.CharSequence)(value); break;
case 12: proxy = (java.lang.CharSequence)(value); break;
case 13: prevFetchTime = (java.lang.Long)(value); break;
case 14: prevCrawlTime1 = (java.lang.Long)(value); break;
case 15: fetchTime = (java.lang.Long)(value); break;
case 16: fetchRetries = (java.lang.Integer)(value); break;
case 17: reprUrl = (java.lang.CharSequence)(value); break;
case 18: prevModifiedTime = (java.lang.Long)(value); break;
case 19: modifiedTime = (java.lang.Long)(value); break;
case 20: protocolStatus = (ai.platon.pulsar.persist.gora.generated.GProtocolStatus)(value); break;
case 21: encoding = (java.lang.CharSequence)(value); break;
case 22: contentType = (java.lang.CharSequence)(value); break;
case 23: content = (java.nio.ByteBuffer)(value); break;
case 24: contentLength = (java.lang.Long)(value); break;
case 25: lastContentLength = (java.lang.Long)(value); break;
case 26: aveContentLength = (java.lang.Long)(value); break;
case 27: persistedContentLength = (java.lang.Long)(value); break;
case 28: referrer = (java.lang.CharSequence)(value); break;
case 29: htmlIntegrity = (java.lang.CharSequence)(value); break;
case 30: anchor = (java.lang.CharSequence)(value); break;
case 31: anchorOrder = (java.lang.Integer)(value); break;
case 32: parseStatus = (ai.platon.pulsar.persist.gora.generated.GParseStatus)(value); break;
case 33: pageTitle = (java.lang.CharSequence)(value); break;
case 34: pageText = (java.lang.CharSequence)(value); break;
case 35: contentTitle = (java.lang.CharSequence)(value); break;
case 36: contentText = (java.lang.CharSequence)(value); break;
case 37: contentTextLen = (java.lang.Integer)(value); break;
case 38: pageCategory = (java.lang.CharSequence)(value); break;
case 39: contentModifiedTime = (java.lang.Long)(value); break;
case 40: prevContentModifiedTime = (java.lang.Long)(value); break;
case 41: contentPublishTime = (java.lang.Long)(value); break;
case 42: prevContentPublishTime = (java.lang.Long)(value); break;
case 43: refContentPublishTime = (java.lang.Long)(value); break;
case 44: prevRefContentPublishTime = (java.lang.Long)(value); break;
case 45: pageModelUpdateTime = (java.lang.Long)(value); break;
case 46: prevSignature = (java.nio.ByteBuffer)(value); break;
case 47: signature = (java.nio.ByteBuffer)(value); break;
case 48: contentScore = (java.lang.Float)(value); break;
case 49: score = (java.lang.Float)(value); break;
case 50: sortScore = (java.lang.CharSequence)(value); break;
case 51: pageCounters = (java.util.Map<java.lang.CharSequence,java.lang.Integer>)((value instanceof org.apache.gora.persistency.Dirtyable) ? value : new org.apache.gora.persistency.impl.DirtyMapWrapper((java.util.Map)value)); break;
case 52: headers = (java.util.Map<java.lang.CharSequence,java.lang.CharSequence>)((value instanceof org.apache.gora.persistency.Dirtyable) ? value : new org.apache.gora.persistency.impl.DirtyMapWrapper((java.util.Map)value)); break;
case 53: links = (java.util.List<java.lang.CharSequence>)((value instanceof org.apache.gora.persistency.Dirtyable) ? value : new org.apache.gora.persistency.impl.DirtyListWrapper((java.util.List)value)); break;
case 54: deadLinks = (java.util.List<java.lang.CharSequence>)((value instanceof org.apache.gora.persistency.Dirtyable) ? value : new org.apache.gora.persistency.impl.DirtyListWrapper((java.util.List)value)); break;
case 55: liveLinks = (java.util.Map<java.lang.CharSequence,ai.platon.pulsar.persist.gora.generated.GHypeLink>)((value instanceof org.apache.gora.persistency.Dirtyable) ? value : new org.apache.gora.persistency.impl.DirtyMapWrapper((java.util.Map)value)); break;
case 56: vividLinks = (java.util.Map<java.lang.CharSequence,java.lang.CharSequence>)((value instanceof org.apache.gora.persistency.Dirtyable) ? value : new org.apache.gora.persistency.impl.DirtyMapWrapper((java.util.Map)value)); break;
case 57: inlinks = (java.util.Map<java.lang.CharSequence,java.lang.CharSequence>)((value instanceof org.apache.gora.persistency.Dirtyable) ? value : new org.apache.gora.persistency.impl.DirtyMapWrapper((java.util.Map)value)); break;
case 58: markers = (java.util.Map<java.lang.CharSequence,java.lang.CharSequence>)((value instanceof org.apache.gora.persistency.Dirtyable) ? value : new org.apache.gora.persistency.impl.DirtyMapWrapper((java.util.Map)value)); break;
case 59: metadata = (java.util.Map<java.lang.CharSequence,java.nio.ByteBuffer>)((value instanceof org.apache.gora.persistency.Dirtyable) ? value : new org.apache.gora.persistency.impl.DirtyMapWrapper((java.util.Map)value)); break;
case 60: activeDOMStatus = (ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus)(value); break;
case 61: activeDOMStatTrace = (java.util.Map<java.lang.CharSequence,ai.platon.pulsar.persist.gora.generated.GActiveDOMStat>)((value instanceof org.apache.gora.persistency.Dirtyable) ? value : new org.apache.gora.persistency.impl.DirtyMapWrapper((java.util.Map)value)); break;
case 62: pageModel = (ai.platon.pulsar.persist.gora.generated.GPageModel)(value); break;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
/**
* Gets the value of the 'baseUrl' field.
*/
public java.lang.CharSequence getBaseUrl() {
return baseUrl;
}
/**
* Sets the value of the 'baseUrl' field.
* @param value the value to set.
*/
public void setBaseUrl(java.lang.CharSequence value) {
this.baseUrl = value;
setDirty(0);
}
/**
* Checks the dirty status of the 'baseUrl' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isBaseUrlDirty() {
return isDirty(0);
}
/**
* Gets the value of the 'createTime' field.
*/
public java.lang.Long getCreateTime() {
return createTime;
}
/**
* Sets the value of the 'createTime' field.
* @param value the value to set.
*/
public void setCreateTime(java.lang.Long value) {
this.createTime = value;
setDirty(1);
}
/**
* Checks the dirty status of the 'createTime' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isCreateTimeDirty() {
return isDirty(1);
}
/**
* Gets the value of the 'distance' field.
*/
public java.lang.Integer getDistance() {
return distance;
}
/**
* Sets the value of the 'distance' field.
* @param value the value to set.
*/
public void setDistance(java.lang.Integer value) {
this.distance = value;
setDirty(2);
}
/**
* Checks the dirty status of the 'distance' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isDistanceDirty() {
return isDirty(2);
}
/**
* Gets the value of the 'fetchCount' field.
*/
public java.lang.Integer getFetchCount() {
return fetchCount;
}
/**
* Sets the value of the 'fetchCount' field.
* @param value the value to set.
*/
public void setFetchCount(java.lang.Integer value) {
this.fetchCount = value;
setDirty(3);
}
/**
* Checks the dirty status of the 'fetchCount' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isFetchCountDirty() {
return isDirty(3);
}
/**
* Gets the value of the 'fetchPriority' field.
*/
public java.lang.Integer getFetchPriority() {
return fetchPriority;
}
/**
* Sets the value of the 'fetchPriority' field.
* @param value the value to set.
*/
public void setFetchPriority(java.lang.Integer value) {
this.fetchPriority = value;
setDirty(4);
}
/**
* Checks the dirty status of the 'fetchPriority' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isFetchPriorityDirty() {
return isDirty(4);
}
/**
* Gets the value of the 'fetchInterval' field.
*/
public java.lang.Integer getFetchInterval() {
return fetchInterval;
}
/**
* Sets the value of the 'fetchInterval' field.
* @param value the value to set.
*/
public void setFetchInterval(java.lang.Integer value) {
this.fetchInterval = value;
setDirty(5);
}
/**
* Checks the dirty status of the 'fetchInterval' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isFetchIntervalDirty() {
return isDirty(5);
}
/**
* Gets the value of the 'zoneId' field.
*/
public java.lang.CharSequence getZoneId() {
return zoneId;
}
/**
* Sets the value of the 'zoneId' field.
* @param value the value to set.
*/
public void setZoneId(java.lang.CharSequence value) {
this.zoneId = value;
setDirty(6);
}
/**
* Checks the dirty status of the 'zoneId' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isZoneIdDirty() {
return isDirty(6);
}
/**
* Gets the value of the 'params' field.
*/
public java.lang.CharSequence getParams() {
return params;
}
/**
* Sets the value of the 'params' field.
* @param value the value to set.
*/
public void setParams(java.lang.CharSequence value) {
this.params = value;
setDirty(7);
}
/**
* Checks the dirty status of the 'params' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isParamsDirty() {
return isDirty(7);
}
/**
* Gets the value of the 'batchId' field.
*/
public java.lang.CharSequence getBatchId() {
return batchId;
}
/**
* Sets the value of the 'batchId' field.
* @param value the value to set.
*/
public void setBatchId(java.lang.CharSequence value) {
this.batchId = value;
setDirty(8);
}
/**
* Checks the dirty status of the 'batchId' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isBatchIdDirty() {
return isDirty(8);
}
/**
* Gets the value of the 'resource' field.
*/
public java.lang.Integer getResource() {
return resource;
}
/**
* Sets the value of the 'resource' field.
* @param value the value to set.
*/
public void setResource(java.lang.Integer value) {
this.resource = value;
setDirty(9);
}
/**
* Checks the dirty status of the 'resource' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isResourceDirty() {
return isDirty(9);
}
/**
* Gets the value of the 'crawlStatus' field.
*/
public java.lang.Integer getCrawlStatus() {
return crawlStatus;
}
/**
* Sets the value of the 'crawlStatus' field.
* @param value the value to set.
*/
public void setCrawlStatus(java.lang.Integer value) {
this.crawlStatus = value;
setDirty(10);
}
/**
* Checks the dirty status of the 'crawlStatus' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isCrawlStatusDirty() {
return isDirty(10);
}
/**
* Gets the value of the 'browser' field.
*/
public java.lang.CharSequence getBrowser() {
return browser;
}
/**
* Sets the value of the 'browser' field.
* @param value the value to set.
*/
public void setBrowser(java.lang.CharSequence value) {
this.browser = value;
setDirty(11);
}
/**
* Checks the dirty status of the 'browser' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isBrowserDirty() {
return isDirty(11);
}
/**
* Gets the value of the 'proxy' field.
*/
public java.lang.CharSequence getProxy() {
return proxy;
}
/**
* Sets the value of the 'proxy' field.
* @param value the value to set.
*/
public void setProxy(java.lang.CharSequence value) {
this.proxy = value;
setDirty(12);
}
/**
* Checks the dirty status of the 'proxy' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isProxyDirty() {
return isDirty(12);
}
/**
* Gets the value of the 'prevFetchTime' field.
*/
public java.lang.Long getPrevFetchTime() {
return prevFetchTime;
}
/**
* Sets the value of the 'prevFetchTime' field.
* @param value the value to set.
*/
public void setPrevFetchTime(java.lang.Long value) {
this.prevFetchTime = value;
setDirty(13);
}
/**
* Checks the dirty status of the 'prevFetchTime' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isPrevFetchTimeDirty() {
return isDirty(13);
}
/**
* Gets the value of the 'prevCrawlTime1' field.
*/
public java.lang.Long getPrevCrawlTime1() {
return prevCrawlTime1;
}
/**
* Sets the value of the 'prevCrawlTime1' field.
* @param value the value to set.
*/
public void setPrevCrawlTime1(java.lang.Long value) {
this.prevCrawlTime1 = value;
setDirty(14);
}
/**
* Checks the dirty status of the 'prevCrawlTime1' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isPrevCrawlTime1Dirty() {
return isDirty(14);
}
/**
* Gets the value of the 'fetchTime' field.
*/
public java.lang.Long getFetchTime() {
return fetchTime;
}
/**
* Sets the value of the 'fetchTime' field.
* @param value the value to set.
*/
public void setFetchTime(java.lang.Long value) {
this.fetchTime = value;
setDirty(15);
}
/**
* Checks the dirty status of the 'fetchTime' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isFetchTimeDirty() {
return isDirty(15);
}
/**
* Gets the value of the 'fetchRetries' field.
*/
public java.lang.Integer getFetchRetries() {
return fetchRetries;
}
/**
* Sets the value of the 'fetchRetries' field.
* @param value the value to set.
*/
public void setFetchRetries(java.lang.Integer value) {
this.fetchRetries = value;
setDirty(16);
}
/**
* Checks the dirty status of the 'fetchRetries' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isFetchRetriesDirty() {
return isDirty(16);
}
/**
* Gets the value of the 'reprUrl' field.
*/
public java.lang.CharSequence getReprUrl() {
return reprUrl;
}
/**
* Sets the value of the 'reprUrl' field.
* @param value the value to set.
*/
public void setReprUrl(java.lang.CharSequence value) {
this.reprUrl = value;
setDirty(17);
}
/**
* Checks the dirty status of the 'reprUrl' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isReprUrlDirty() {
return isDirty(17);
}
/**
* Gets the value of the 'prevModifiedTime' field.
*/
public java.lang.Long getPrevModifiedTime() {
return prevModifiedTime;
}
/**
* Sets the value of the 'prevModifiedTime' field.
* @param value the value to set.
*/
public void setPrevModifiedTime(java.lang.Long value) {
this.prevModifiedTime = value;
setDirty(18);
}
/**
* Checks the dirty status of the 'prevModifiedTime' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isPrevModifiedTimeDirty() {
return isDirty(18);
}
/**
* Gets the value of the 'modifiedTime' field.
*/
public java.lang.Long getModifiedTime() {
return modifiedTime;
}
/**
* Sets the value of the 'modifiedTime' field.
* @param value the value to set.
*/
public void setModifiedTime(java.lang.Long value) {
this.modifiedTime = value;
setDirty(19);
}
/**
* Checks the dirty status of the 'modifiedTime' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isModifiedTimeDirty() {
return isDirty(19);
}
/**
* Gets the value of the 'protocolStatus' field.
*/
public ai.platon.pulsar.persist.gora.generated.GProtocolStatus getProtocolStatus() {
return protocolStatus;
}
/**
* Sets the value of the 'protocolStatus' field.
* @param value the value to set.
*/
public void setProtocolStatus(ai.platon.pulsar.persist.gora.generated.GProtocolStatus value) {
this.protocolStatus = value;
setDirty(20);
}
/**
* Checks the dirty status of the 'protocolStatus' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isProtocolStatusDirty() {
return isDirty(20);
}
/**
* Gets the value of the 'encoding' field.
*/
public java.lang.CharSequence getEncoding() {
return encoding;
}
/**
* Sets the value of the 'encoding' field.
* @param value the value to set.
*/
public void setEncoding(java.lang.CharSequence value) {
this.encoding = value;
setDirty(21);
}
/**
* Checks the dirty status of the 'encoding' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isEncodingDirty() {
return isDirty(21);
}
/**
* Gets the value of the 'contentType' field.
*/
public java.lang.CharSequence getContentType() {
return contentType;
}
/**
* Sets the value of the 'contentType' field.
* @param value the value to set.
*/
public void setContentType(java.lang.CharSequence value) {
this.contentType = value;
setDirty(22);
}
/**
* Checks the dirty status of the 'contentType' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isContentTypeDirty() {
return isDirty(22);
}
/**
* Gets the value of the 'content' field.
* The entire raw document content e.g. raw XHTML */
public java.nio.ByteBuffer getContent() {
return content;
}
/**
* Sets the value of the 'content' field.
* The entire raw document content e.g. raw XHTML * @param value the value to set.
*/
public void setContent(java.nio.ByteBuffer value) {
this.content = value;
setDirty(23);
}
/**
* Checks the dirty status of the 'content' field. A field is dirty if it represents a change that has not yet been written to the database.
* The entire raw document content e.g. raw XHTML * @param value the value to set.
*/
public boolean isContentDirty() {
return isDirty(23);
}
/**
* Gets the value of the 'contentLength' field.
*/
public java.lang.Long getContentLength() {
return contentLength;
}
/**
* Sets the value of the 'contentLength' field.
* @param value the value to set.
*/
public void setContentLength(java.lang.Long value) {
this.contentLength = value;
setDirty(24);
}
/**
* Checks the dirty status of the 'contentLength' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isContentLengthDirty() {
return isDirty(24);
}
/**
* Gets the value of the 'lastContentLength' field.
*/
public java.lang.Long getLastContentLength() {
return lastContentLength;
}
/**
* Sets the value of the 'lastContentLength' field.
* @param value the value to set.
*/
public void setLastContentLength(java.lang.Long value) {
this.lastContentLength = value;
setDirty(25);
}
/**
* Checks the dirty status of the 'lastContentLength' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isLastContentLengthDirty() {
return isDirty(25);
}
/**
* Gets the value of the 'aveContentLength' field.
*/
public java.lang.Long getAveContentLength() {
return aveContentLength;
}
/**
* Sets the value of the 'aveContentLength' field.
* @param value the value to set.
*/
public void setAveContentLength(java.lang.Long value) {
this.aveContentLength = value;
setDirty(26);
}
/**
* Checks the dirty status of the 'aveContentLength' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isAveContentLengthDirty() {
return isDirty(26);
}
/**
* Gets the value of the 'persistedContentLength' field.
*/
public java.lang.Long getPersistedContentLength() {
return persistedContentLength;
}
/**
* Sets the value of the 'persistedContentLength' field.
* @param value the value to set.
*/
public void setPersistedContentLength(java.lang.Long value) {
this.persistedContentLength = value;
setDirty(27);
}
/**
* Checks the dirty status of the 'persistedContentLength' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isPersistedContentLengthDirty() {
return isDirty(27);
}
/**
* Gets the value of the 'referrer' field.
*/
public java.lang.CharSequence getReferrer() {
return referrer;
}
/**
* Sets the value of the 'referrer' field.
* @param value the value to set.
*/
public void setReferrer(java.lang.CharSequence value) {
this.referrer = value;
setDirty(28);
}
/**
* Checks the dirty status of the 'referrer' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isReferrerDirty() {
return isDirty(28);
}
/**
* Gets the value of the 'htmlIntegrity' field.
*/
public java.lang.CharSequence getHtmlIntegrity() {
return htmlIntegrity;
}
/**
* Sets the value of the 'htmlIntegrity' field.
* @param value the value to set.
*/
public void setHtmlIntegrity(java.lang.CharSequence value) {
this.htmlIntegrity = value;
setDirty(29);
}
/**
* Checks the dirty status of the 'htmlIntegrity' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isHtmlIntegrityDirty() {
return isDirty(29);
}
/**
* Gets the value of the 'anchor' field.
*/
public java.lang.CharSequence getAnchor() {
return anchor;
}
/**
* Sets the value of the 'anchor' field.
* @param value the value to set.
*/
public void setAnchor(java.lang.CharSequence value) {
this.anchor = value;
setDirty(30);
}
/**
* Checks the dirty status of the 'anchor' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isAnchorDirty() {
return isDirty(30);
}
/**
* Gets the value of the 'anchorOrder' field.
*/
public java.lang.Integer getAnchorOrder() {
return anchorOrder;
}
/**
* Sets the value of the 'anchorOrder' field.
* @param value the value to set.
*/
public void setAnchorOrder(java.lang.Integer value) {
this.anchorOrder = value;
setDirty(31);
}
/**
* Checks the dirty status of the 'anchorOrder' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isAnchorOrderDirty() {
return isDirty(31);
}
/**
* Gets the value of the 'parseStatus' field.
*/
public ai.platon.pulsar.persist.gora.generated.GParseStatus getParseStatus() {
return parseStatus;
}
/**
* Sets the value of the 'parseStatus' field.
* @param value the value to set.
*/
public void setParseStatus(ai.platon.pulsar.persist.gora.generated.GParseStatus value) {
this.parseStatus = value;
setDirty(32);
}
/**
* Checks the dirty status of the 'parseStatus' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isParseStatusDirty() {
return isDirty(32);
}
/**
* Gets the value of the 'pageTitle' field.
*/
public java.lang.CharSequence getPageTitle() {
return pageTitle;
}
/**
* Sets the value of the 'pageTitle' field.
* @param value the value to set.
*/
public void setPageTitle(java.lang.CharSequence value) {
this.pageTitle = value;
setDirty(33);
}
/**
* Checks the dirty status of the 'pageTitle' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isPageTitleDirty() {
return isDirty(33);
}
/**
* Gets the value of the 'pageText' field.
*/
public java.lang.CharSequence getPageText() {
return pageText;
}
/**
* Sets the value of the 'pageText' field.
* @param value the value to set.
*/
public void setPageText(java.lang.CharSequence value) {
this.pageText = value;
setDirty(34);
}
/**
* Checks the dirty status of the 'pageText' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isPageTextDirty() {
return isDirty(34);
}
/**
* Gets the value of the 'contentTitle' field.
*/
public java.lang.CharSequence getContentTitle() {
return contentTitle;
}
/**
* Sets the value of the 'contentTitle' field.
* @param value the value to set.
*/
public void setContentTitle(java.lang.CharSequence value) {
this.contentTitle = value;
setDirty(35);
}
/**
* Checks the dirty status of the 'contentTitle' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isContentTitleDirty() {
return isDirty(35);
}
/**
* Gets the value of the 'contentText' field.
*/
public java.lang.CharSequence getContentText() {
return contentText;
}
/**
* Sets the value of the 'contentText' field.
* @param value the value to set.
*/
public void setContentText(java.lang.CharSequence value) {
this.contentText = value;
setDirty(36);
}
/**
* Checks the dirty status of the 'contentText' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isContentTextDirty() {
return isDirty(36);
}
/**
* Gets the value of the 'contentTextLen' field.
*/
public java.lang.Integer getContentTextLen() {
return contentTextLen;
}
/**
* Sets the value of the 'contentTextLen' field.
* @param value the value to set.
*/
public void setContentTextLen(java.lang.Integer value) {
this.contentTextLen = value;
setDirty(37);
}
/**
* Checks the dirty status of the 'contentTextLen' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isContentTextLenDirty() {
return isDirty(37);
}
/**
* Gets the value of the 'pageCategory' field.
*/
public java.lang.CharSequence getPageCategory() {
return pageCategory;
}
/**
* Sets the value of the 'pageCategory' field.
* @param value the value to set.
*/
public void setPageCategory(java.lang.CharSequence value) {
this.pageCategory = value;
setDirty(38);
}
/**
* Checks the dirty status of the 'pageCategory' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isPageCategoryDirty() {
return isDirty(38);
}
/**
* Gets the value of the 'contentModifiedTime' field.
*/
public java.lang.Long getContentModifiedTime() {
return contentModifiedTime;
}
/**
* Sets the value of the 'contentModifiedTime' field.
* @param value the value to set.
*/
public void setContentModifiedTime(java.lang.Long value) {
this.contentModifiedTime = value;
setDirty(39);
}
/**
* Checks the dirty status of the 'contentModifiedTime' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isContentModifiedTimeDirty() {
return isDirty(39);
}
/**
* Gets the value of the 'prevContentModifiedTime' field.
*/
public java.lang.Long getPrevContentModifiedTime() {
return prevContentModifiedTime;
}
/**
* Sets the value of the 'prevContentModifiedTime' field.
* @param value the value to set.
*/
public void setPrevContentModifiedTime(java.lang.Long value) {
this.prevContentModifiedTime = value;
setDirty(40);
}
/**
* Checks the dirty status of the 'prevContentModifiedTime' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isPrevContentModifiedTimeDirty() {
return isDirty(40);
}
/**
* Gets the value of the 'contentPublishTime' field.
*/
public java.lang.Long getContentPublishTime() {
return contentPublishTime;
}
/**
* Sets the value of the 'contentPublishTime' field.
* @param value the value to set.
*/
public void setContentPublishTime(java.lang.Long value) {
this.contentPublishTime = value;
setDirty(41);
}
/**
* Checks the dirty status of the 'contentPublishTime' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isContentPublishTimeDirty() {
return isDirty(41);
}
/**
* Gets the value of the 'prevContentPublishTime' field.
*/
public java.lang.Long getPrevContentPublishTime() {
return prevContentPublishTime;
}
/**
* Sets the value of the 'prevContentPublishTime' field.
* @param value the value to set.
*/
public void setPrevContentPublishTime(java.lang.Long value) {
this.prevContentPublishTime = value;
setDirty(42);
}
/**
* Checks the dirty status of the 'prevContentPublishTime' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isPrevContentPublishTimeDirty() {
return isDirty(42);
}
/**
* Gets the value of the 'refContentPublishTime' field.
*/
public java.lang.Long getRefContentPublishTime() {
return refContentPublishTime;
}
/**
* Sets the value of the 'refContentPublishTime' field.
* @param value the value to set.
*/
public void setRefContentPublishTime(java.lang.Long value) {
this.refContentPublishTime = value;
setDirty(43);
}
/**
* Checks the dirty status of the 'refContentPublishTime' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isRefContentPublishTimeDirty() {
return isDirty(43);
}
/**
* Gets the value of the 'prevRefContentPublishTime' field.
*/
public java.lang.Long getPrevRefContentPublishTime() {
return prevRefContentPublishTime;
}
/**
* Sets the value of the 'prevRefContentPublishTime' field.
* @param value the value to set.
*/
public void setPrevRefContentPublishTime(java.lang.Long value) {
this.prevRefContentPublishTime = value;
setDirty(44);
}
/**
* Checks the dirty status of the 'prevRefContentPublishTime' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isPrevRefContentPublishTimeDirty() {
return isDirty(44);
}
/**
* Gets the value of the 'pageModelUpdateTime' field.
*/
public java.lang.Long getPageModelUpdateTime() {
return pageModelUpdateTime;
}
/**
* Sets the value of the 'pageModelUpdateTime' field.
* @param value the value to set.
*/
public void setPageModelUpdateTime(java.lang.Long value) {
this.pageModelUpdateTime = value;
setDirty(45);
}
/**
* Checks the dirty status of the 'pageModelUpdateTime' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isPageModelUpdateTimeDirty() {
return isDirty(45);
}
/**
* Gets the value of the 'prevSignature' field.
*/
public java.nio.ByteBuffer getPrevSignature() {
return prevSignature;
}
/**
* Sets the value of the 'prevSignature' field.
* @param value the value to set.
*/
public void setPrevSignature(java.nio.ByteBuffer value) {
this.prevSignature = value;
setDirty(46);
}
/**
* Checks the dirty status of the 'prevSignature' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isPrevSignatureDirty() {
return isDirty(46);
}
/**
* Gets the value of the 'signature' field.
*/
public java.nio.ByteBuffer getSignature() {
return signature;
}
/**
* Sets the value of the 'signature' field.
* @param value the value to set.
*/
public void setSignature(java.nio.ByteBuffer value) {
this.signature = value;
setDirty(47);
}
/**
* Checks the dirty status of the 'signature' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isSignatureDirty() {
return isDirty(47);
}
/**
* Gets the value of the 'contentScore' field.
*/
public java.lang.Float getContentScore() {
return contentScore;
}
/**
* Sets the value of the 'contentScore' field.
* @param value the value to set.
*/
public void setContentScore(java.lang.Float value) {
this.contentScore = value;
setDirty(48);
}
/**
* Checks the dirty status of the 'contentScore' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isContentScoreDirty() {
return isDirty(48);
}
/**
* Gets the value of the 'score' field.
*/
public java.lang.Float getScore() {
return score;
}
/**
* Sets the value of the 'score' field.
* @param value the value to set.
*/
public void setScore(java.lang.Float value) {
this.score = value;
setDirty(49);
}
/**
* Checks the dirty status of the 'score' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isScoreDirty() {
return isDirty(49);
}
/**
* Gets the value of the 'sortScore' field.
*/
public java.lang.CharSequence getSortScore() {
return sortScore;
}
/**
* Sets the value of the 'sortScore' field.
* @param value the value to set.
*/
public void setSortScore(java.lang.CharSequence value) {
this.sortScore = value;
setDirty(50);
}
/**
* Checks the dirty status of the 'sortScore' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isSortScoreDirty() {
return isDirty(50);
}
/**
* Gets the value of the 'pageCounters' field.
*/
public java.util.Map<java.lang.CharSequence,java.lang.Integer> getPageCounters() {
return pageCounters;
}
/**
* Sets the value of the 'pageCounters' field.
* @param value the value to set.
*/
public void setPageCounters(java.util.Map<java.lang.CharSequence,java.lang.Integer> value) {
this.pageCounters = (value instanceof org.apache.gora.persistency.Dirtyable) ? value : new org.apache.gora.persistency.impl.DirtyMapWrapper(value);
setDirty(51);
}
/**
* Checks the dirty status of the 'pageCounters' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isPageCountersDirty() {
return isDirty(51);
}
/**
* Gets the value of the 'headers' field.
*/
public java.util.Map<java.lang.CharSequence,java.lang.CharSequence> getHeaders() {
return headers;
}
/**
* Sets the value of the 'headers' field.
* @param value the value to set.
*/
public void setHeaders(java.util.Map<java.lang.CharSequence,java.lang.CharSequence> value) {
this.headers = (value instanceof org.apache.gora.persistency.Dirtyable) ? value : new org.apache.gora.persistency.impl.DirtyMapWrapper(value);
setDirty(52);
}
/**
* Checks the dirty status of the 'headers' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isHeadersDirty() {
return isDirty(52);
}
/**
* Gets the value of the 'links' field.
*/
public java.util.List<java.lang.CharSequence> getLinks() {
return links;
}
/**
* Sets the value of the 'links' field.
* @param value the value to set.
*/
public void setLinks(java.util.List<java.lang.CharSequence> value) {
this.links = (value instanceof org.apache.gora.persistency.Dirtyable) ? value : new org.apache.gora.persistency.impl.DirtyListWrapper(value);
setDirty(53);
}
/**
* Checks the dirty status of the 'links' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isLinksDirty() {
return isDirty(53);
}
/**
* Gets the value of the 'deadLinks' field.
*/
public java.util.List<java.lang.CharSequence> getDeadLinks() {
return deadLinks;
}
/**
* Sets the value of the 'deadLinks' field.
* @param value the value to set.
*/
public void setDeadLinks(java.util.List<java.lang.CharSequence> value) {
this.deadLinks = (value instanceof org.apache.gora.persistency.Dirtyable) ? value : new org.apache.gora.persistency.impl.DirtyListWrapper(value);
setDirty(54);
}
/**
* Checks the dirty status of the 'deadLinks' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isDeadLinksDirty() {
return isDirty(54);
}
/**
* Gets the value of the 'liveLinks' field.
*/
public java.util.Map<java.lang.CharSequence,ai.platon.pulsar.persist.gora.generated.GHypeLink> getLiveLinks() {
return liveLinks;
}
/**
* Sets the value of the 'liveLinks' field.
* @param value the value to set.
*/
public void setLiveLinks(java.util.Map<java.lang.CharSequence,ai.platon.pulsar.persist.gora.generated.GHypeLink> value) {
this.liveLinks = (value instanceof org.apache.gora.persistency.Dirtyable) ? value : new org.apache.gora.persistency.impl.DirtyMapWrapper(value);
setDirty(55);
}
/**
* Checks the dirty status of the 'liveLinks' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isLiveLinksDirty() {
return isDirty(55);
}
/**
* Gets the value of the 'vividLinks' field.
*/
public java.util.Map<java.lang.CharSequence,java.lang.CharSequence> getVividLinks() {
return vividLinks;
}
/**
* Sets the value of the 'vividLinks' field.
* @param value the value to set.
*/
public void setVividLinks(java.util.Map<java.lang.CharSequence,java.lang.CharSequence> value) {
this.vividLinks = (value instanceof org.apache.gora.persistency.Dirtyable) ? value : new org.apache.gora.persistency.impl.DirtyMapWrapper(value);
setDirty(56);
}
/**
* Checks the dirty status of the 'vividLinks' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isVividLinksDirty() {
return isDirty(56);
}
/**
* Gets the value of the 'inlinks' field.
*/
public java.util.Map<java.lang.CharSequence,java.lang.CharSequence> getInlinks() {
return inlinks;
}
/**
* Sets the value of the 'inlinks' field.
* @param value the value to set.
*/
public void setInlinks(java.util.Map<java.lang.CharSequence,java.lang.CharSequence> value) {
this.inlinks = (value instanceof org.apache.gora.persistency.Dirtyable) ? value : new org.apache.gora.persistency.impl.DirtyMapWrapper(value);
setDirty(57);
}
/**
* Checks the dirty status of the 'inlinks' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isInlinksDirty() {
return isDirty(57);
}
/**
* Gets the value of the 'markers' field.
*/
public java.util.Map<java.lang.CharSequence,java.lang.CharSequence> getMarkers() {
return markers;
}
/**
* Sets the value of the 'markers' field.
* @param value the value to set.
*/
public void setMarkers(java.util.Map<java.lang.CharSequence,java.lang.CharSequence> value) {
this.markers = (value instanceof org.apache.gora.persistency.Dirtyable) ? value : new org.apache.gora.persistency.impl.DirtyMapWrapper(value);
setDirty(58);
}
/**
* Checks the dirty status of the 'markers' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isMarkersDirty() {
return isDirty(58);
}
/**
* Gets the value of the 'metadata' field.
*/
public java.util.Map<java.lang.CharSequence,java.nio.ByteBuffer> getMetadata() {
return metadata;
}
/**
* Sets the value of the 'metadata' field.
* @param value the value to set.
*/
public void setMetadata(java.util.Map<java.lang.CharSequence,java.nio.ByteBuffer> value) {
this.metadata = (value instanceof org.apache.gora.persistency.Dirtyable) ? value : new org.apache.gora.persistency.impl.DirtyMapWrapper(value);
setDirty(59);
}
/**
* Checks the dirty status of the 'metadata' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isMetadataDirty() {
return isDirty(59);
}
/**
* Gets the value of the 'activeDOMStatus' field.
*/
public ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus getActiveDOMStatus() {
return activeDOMStatus;
}
/**
* Sets the value of the 'activeDOMStatus' field.
* @param value the value to set.
*/
public void setActiveDOMStatus(ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus value) {
this.activeDOMStatus = value;
setDirty(60);
}
/**
* Checks the dirty status of the 'activeDOMStatus' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isActiveDOMStatusDirty() {
return isDirty(60);
}
/**
* Gets the value of the 'activeDOMStatTrace' field.
*/
public java.util.Map<java.lang.CharSequence,ai.platon.pulsar.persist.gora.generated.GActiveDOMStat> getActiveDOMStatTrace() {
return activeDOMStatTrace;
}
/**
* Sets the value of the 'activeDOMStatTrace' field.
* @param value the value to set.
*/
public void setActiveDOMStatTrace(java.util.Map<java.lang.CharSequence,ai.platon.pulsar.persist.gora.generated.GActiveDOMStat> value) {
this.activeDOMStatTrace = (value instanceof org.apache.gora.persistency.Dirtyable) ? value : new org.apache.gora.persistency.impl.DirtyMapWrapper(value);
setDirty(61);
}
/**
* Checks the dirty status of the 'activeDOMStatTrace' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isActiveDOMStatTraceDirty() {
return isDirty(61);
}
/**
* Gets the value of the 'pageModel' field.
*/
public ai.platon.pulsar.persist.gora.generated.GPageModel getPageModel() {
return pageModel;
}
/**
* Sets the value of the 'pageModel' field.
* @param value the value to set.
*/
public void setPageModel(ai.platon.pulsar.persist.gora.generated.GPageModel value) {
this.pageModel = value;
setDirty(62);
}
/**
* Checks the dirty status of the 'pageModel' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isPageModelDirty() {
return isDirty(62);
}
/** Creates a new GWebPage RecordBuilder */
public static ai.platon.pulsar.persist.gora.generated.GWebPage.Builder newBuilder() {
return new ai.platon.pulsar.persist.gora.generated.GWebPage.Builder();
}
/** Creates a new GWebPage RecordBuilder by copying an existing Builder */
public static ai.platon.pulsar.persist.gora.generated.GWebPage.Builder newBuilder(ai.platon.pulsar.persist.gora.generated.GWebPage.Builder other) {
return new ai.platon.pulsar.persist.gora.generated.GWebPage.Builder(other);
}
/** Creates a new GWebPage RecordBuilder by copying an existing GWebPage instance */
public static ai.platon.pulsar.persist.gora.generated.GWebPage.Builder newBuilder(ai.platon.pulsar.persist.gora.generated.GWebPage other) {
return new ai.platon.pulsar.persist.gora.generated.GWebPage.Builder(other);
}
private static java.nio.ByteBuffer deepCopyToReadOnlyBuffer(
java.nio.ByteBuffer input) {
java.nio.ByteBuffer copy = java.nio.ByteBuffer.allocate(input.capacity());
int position = input.position();
input.reset();
int mark = input.position();
int limit = input.limit();
input.rewind();
input.limit(input.capacity());
copy.put(input);
input.rewind();
copy.rewind();
input.position(mark);
input.mark();
copy.position(mark);
copy.mark();
input.position(position);
copy.position(position);
input.limit(limit);
copy.limit(limit);
return copy.asReadOnlyBuffer();
}
/**
* RecordBuilder for GWebPage instances.
*/
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<GWebPage>
implements org.apache.avro.data.RecordBuilder<GWebPage> {
private java.lang.CharSequence baseUrl;
private long createTime;
private int distance;
private int fetchCount;
private int fetchPriority;
private int fetchInterval;
private java.lang.CharSequence zoneId;
private java.lang.CharSequence params;
private java.lang.CharSequence batchId;
private java.lang.Integer resource;
private int crawlStatus;
private java.lang.CharSequence browser;
private java.lang.CharSequence proxy;
private long prevFetchTime;
private long prevCrawlTime1;
private long fetchTime;
private int fetchRetries;
private java.lang.CharSequence reprUrl;
private long prevModifiedTime;
private long modifiedTime;
private ai.platon.pulsar.persist.gora.generated.GProtocolStatus protocolStatus;
private java.lang.CharSequence encoding;
private java.lang.CharSequence contentType;
private java.nio.ByteBuffer content;
private long contentLength;
private long lastContentLength;
private long aveContentLength;
private long persistedContentLength;
private java.lang.CharSequence referrer;
private java.lang.CharSequence htmlIntegrity;
private java.lang.CharSequence anchor;
private int anchorOrder;
private ai.platon.pulsar.persist.gora.generated.GParseStatus parseStatus;
private java.lang.CharSequence pageTitle;
private java.lang.CharSequence pageText;
private java.lang.CharSequence contentTitle;
private java.lang.CharSequence contentText;
private int contentTextLen;
private java.lang.CharSequence pageCategory;
private long contentModifiedTime;
private long prevContentModifiedTime;
private long contentPublishTime;
private long prevContentPublishTime;
private long refContentPublishTime;
private long prevRefContentPublishTime;
private long pageModelUpdateTime;
private java.nio.ByteBuffer prevSignature;
private java.nio.ByteBuffer signature;
private float contentScore;
private float score;
private java.lang.CharSequence sortScore;
private java.util.Map<java.lang.CharSequence,java.lang.Integer> pageCounters;
private java.util.Map<java.lang.CharSequence,java.lang.CharSequence> headers;
private java.util.List<java.lang.CharSequence> links;
private java.util.List<java.lang.CharSequence> deadLinks;
private java.util.Map<java.lang.CharSequence,ai.platon.pulsar.persist.gora.generated.GHypeLink> liveLinks;
private java.util.Map<java.lang.CharSequence,java.lang.CharSequence> vividLinks;
private java.util.Map<java.lang.CharSequence,java.lang.CharSequence> inlinks;
private java.util.Map<java.lang.CharSequence,java.lang.CharSequence> markers;
private java.util.Map<java.lang.CharSequence,java.nio.ByteBuffer> metadata;
private ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus activeDOMStatus;
private java.util.Map<java.lang.CharSequence,ai.platon.pulsar.persist.gora.generated.GActiveDOMStat> activeDOMStatTrace;
private ai.platon.pulsar.persist.gora.generated.GPageModel pageModel;
/** Creates a new Builder */
private Builder() {
super(ai.platon.pulsar.persist.gora.generated.GWebPage.SCHEMA$);
}
/** Creates a Builder by copying an existing Builder */
private Builder(ai.platon.pulsar.persist.gora.generated.GWebPage.Builder other) {
super(other);
}
/** Creates a Builder by copying an existing GWebPage instance */
private Builder(ai.platon.pulsar.persist.gora.generated.GWebPage other) {
super(ai.platon.pulsar.persist.gora.generated.GWebPage.SCHEMA$);
if (isValidValue(fields()[0], other.baseUrl)) {
this.baseUrl = (java.lang.CharSequence) data().deepCopy(fields()[0].schema(), other.baseUrl);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.createTime)) {
this.createTime = (java.lang.Long) data().deepCopy(fields()[1].schema(), other.createTime);
fieldSetFlags()[1] = true;
}
if (isValidValue(fields()[2], other.distance)) {
this.distance = (java.lang.Integer) data().deepCopy(fields()[2].schema(), other.distance);
fieldSetFlags()[2] = true;
}
if (isValidValue(fields()[3], other.fetchCount)) {
this.fetchCount = (java.lang.Integer) data().deepCopy(fields()[3].schema(), other.fetchCount);
fieldSetFlags()[3] = true;
}
if (isValidValue(fields()[4], other.fetchPriority)) {
this.fetchPriority = (java.lang.Integer) data().deepCopy(fields()[4].schema(), other.fetchPriority);
fieldSetFlags()[4] = true;
}
if (isValidValue(fields()[5], other.fetchInterval)) {
this.fetchInterval = (java.lang.Integer) data().deepCopy(fields()[5].schema(), other.fetchInterval);
fieldSetFlags()[5] = true;
}
if (isValidValue(fields()[6], other.zoneId)) {
this.zoneId = (java.lang.CharSequence) data().deepCopy(fields()[6].schema(), other.zoneId);
fieldSetFlags()[6] = true;
}
if (isValidValue(fields()[7], other.params)) {
this.params = (java.lang.CharSequence) data().deepCopy(fields()[7].schema(), other.params);
fieldSetFlags()[7] = true;
}
if (isValidValue(fields()[8], other.batchId)) {
this.batchId = (java.lang.CharSequence) data().deepCopy(fields()[8].schema(), other.batchId);
fieldSetFlags()[8] = true;
}
if (isValidValue(fields()[9], other.resource)) {
this.resource = (java.lang.Integer) data().deepCopy(fields()[9].schema(), other.resource);
fieldSetFlags()[9] = true;
}
if (isValidValue(fields()[10], other.crawlStatus)) {
this.crawlStatus = (java.lang.Integer) data().deepCopy(fields()[10].schema(), other.crawlStatus);
fieldSetFlags()[10] = true;
}
if (isValidValue(fields()[11], other.browser)) {
this.browser = (java.lang.CharSequence) data().deepCopy(fields()[11].schema(), other.browser);
fieldSetFlags()[11] = true;
}
if (isValidValue(fields()[12], other.proxy)) {
this.proxy = (java.lang.CharSequence) data().deepCopy(fields()[12].schema(), other.proxy);
fieldSetFlags()[12] = true;
}
if (isValidValue(fields()[13], other.prevFetchTime)) {
this.prevFetchTime = (java.lang.Long) data().deepCopy(fields()[13].schema(), other.prevFetchTime);
fieldSetFlags()[13] = true;
}
if (isValidValue(fields()[14], other.prevCrawlTime1)) {
this.prevCrawlTime1 = (java.lang.Long) data().deepCopy(fields()[14].schema(), other.prevCrawlTime1);
fieldSetFlags()[14] = true;
}
if (isValidValue(fields()[15], other.fetchTime)) {
this.fetchTime = (java.lang.Long) data().deepCopy(fields()[15].schema(), other.fetchTime);
fieldSetFlags()[15] = true;
}
if (isValidValue(fields()[16], other.fetchRetries)) {
this.fetchRetries = (java.lang.Integer) data().deepCopy(fields()[16].schema(), other.fetchRetries);
fieldSetFlags()[16] = true;
}
if (isValidValue(fields()[17], other.reprUrl)) {
this.reprUrl = (java.lang.CharSequence) data().deepCopy(fields()[17].schema(), other.reprUrl);
fieldSetFlags()[17] = true;
}
if (isValidValue(fields()[18], other.prevModifiedTime)) {
this.prevModifiedTime = (java.lang.Long) data().deepCopy(fields()[18].schema(), other.prevModifiedTime);
fieldSetFlags()[18] = true;
}
if (isValidValue(fields()[19], other.modifiedTime)) {
this.modifiedTime = (java.lang.Long) data().deepCopy(fields()[19].schema(), other.modifiedTime);
fieldSetFlags()[19] = true;
}
if (isValidValue(fields()[20], other.protocolStatus)) {
this.protocolStatus = (ai.platon.pulsar.persist.gora.generated.GProtocolStatus) data().deepCopy(fields()[20].schema(), other.protocolStatus);
fieldSetFlags()[20] = true;
}
if (isValidValue(fields()[21], other.encoding)) {
this.encoding = (java.lang.CharSequence) data().deepCopy(fields()[21].schema(), other.encoding);
fieldSetFlags()[21] = true;
}
if (isValidValue(fields()[22], other.contentType)) {
this.contentType = (java.lang.CharSequence) data().deepCopy(fields()[22].schema(), other.contentType);
fieldSetFlags()[22] = true;
}
if (isValidValue(fields()[23], other.content)) {
this.content = (java.nio.ByteBuffer) data().deepCopy(fields()[23].schema(), other.content);
fieldSetFlags()[23] = true;
}
if (isValidValue(fields()[24], other.contentLength)) {
this.contentLength = (java.lang.Long) data().deepCopy(fields()[24].schema(), other.contentLength);
fieldSetFlags()[24] = true;
}
if (isValidValue(fields()[25], other.lastContentLength)) {
this.lastContentLength = (java.lang.Long) data().deepCopy(fields()[25].schema(), other.lastContentLength);
fieldSetFlags()[25] = true;
}
if (isValidValue(fields()[26], other.aveContentLength)) {
this.aveContentLength = (java.lang.Long) data().deepCopy(fields()[26].schema(), other.aveContentLength);
fieldSetFlags()[26] = true;
}
if (isValidValue(fields()[27], other.persistedContentLength)) {
this.persistedContentLength = (java.lang.Long) data().deepCopy(fields()[27].schema(), other.persistedContentLength);
fieldSetFlags()[27] = true;
}
if (isValidValue(fields()[28], other.referrer)) {
this.referrer = (java.lang.CharSequence) data().deepCopy(fields()[28].schema(), other.referrer);
fieldSetFlags()[28] = true;
}
if (isValidValue(fields()[29], other.htmlIntegrity)) {
this.htmlIntegrity = (java.lang.CharSequence) data().deepCopy(fields()[29].schema(), other.htmlIntegrity);
fieldSetFlags()[29] = true;
}
if (isValidValue(fields()[30], other.anchor)) {
this.anchor = (java.lang.CharSequence) data().deepCopy(fields()[30].schema(), other.anchor);
fieldSetFlags()[30] = true;
}
if (isValidValue(fields()[31], other.anchorOrder)) {
this.anchorOrder = (java.lang.Integer) data().deepCopy(fields()[31].schema(), other.anchorOrder);
fieldSetFlags()[31] = true;
}
if (isValidValue(fields()[32], other.parseStatus)) {
this.parseStatus = (ai.platon.pulsar.persist.gora.generated.GParseStatus) data().deepCopy(fields()[32].schema(), other.parseStatus);
fieldSetFlags()[32] = true;
}
if (isValidValue(fields()[33], other.pageTitle)) {
this.pageTitle = (java.lang.CharSequence) data().deepCopy(fields()[33].schema(), other.pageTitle);
fieldSetFlags()[33] = true;
}
if (isValidValue(fields()[34], other.pageText)) {
this.pageText = (java.lang.CharSequence) data().deepCopy(fields()[34].schema(), other.pageText);
fieldSetFlags()[34] = true;
}
if (isValidValue(fields()[35], other.contentTitle)) {
this.contentTitle = (java.lang.CharSequence) data().deepCopy(fields()[35].schema(), other.contentTitle);
fieldSetFlags()[35] = true;
}
if (isValidValue(fields()[36], other.contentText)) {
this.contentText = (java.lang.CharSequence) data().deepCopy(fields()[36].schema(), other.contentText);
fieldSetFlags()[36] = true;
}
if (isValidValue(fields()[37], other.contentTextLen)) {
this.contentTextLen = (java.lang.Integer) data().deepCopy(fields()[37].schema(), other.contentTextLen);
fieldSetFlags()[37] = true;
}
if (isValidValue(fields()[38], other.pageCategory)) {
this.pageCategory = (java.lang.CharSequence) data().deepCopy(fields()[38].schema(), other.pageCategory);
fieldSetFlags()[38] = true;
}
if (isValidValue(fields()[39], other.contentModifiedTime)) {
this.contentModifiedTime = (java.lang.Long) data().deepCopy(fields()[39].schema(), other.contentModifiedTime);
fieldSetFlags()[39] = true;
}
if (isValidValue(fields()[40], other.prevContentModifiedTime)) {
this.prevContentModifiedTime = (java.lang.Long) data().deepCopy(fields()[40].schema(), other.prevContentModifiedTime);
fieldSetFlags()[40] = true;
}
if (isValidValue(fields()[41], other.contentPublishTime)) {
this.contentPublishTime = (java.lang.Long) data().deepCopy(fields()[41].schema(), other.contentPublishTime);
fieldSetFlags()[41] = true;
}
if (isValidValue(fields()[42], other.prevContentPublishTime)) {
this.prevContentPublishTime = (java.lang.Long) data().deepCopy(fields()[42].schema(), other.prevContentPublishTime);
fieldSetFlags()[42] = true;
}
if (isValidValue(fields()[43], other.refContentPublishTime)) {
this.refContentPublishTime = (java.lang.Long) data().deepCopy(fields()[43].schema(), other.refContentPublishTime);
fieldSetFlags()[43] = true;
}
if (isValidValue(fields()[44], other.prevRefContentPublishTime)) {
this.prevRefContentPublishTime = (java.lang.Long) data().deepCopy(fields()[44].schema(), other.prevRefContentPublishTime);
fieldSetFlags()[44] = true;
}
if (isValidValue(fields()[45], other.pageModelUpdateTime)) {
this.pageModelUpdateTime = (java.lang.Long) data().deepCopy(fields()[45].schema(), other.pageModelUpdateTime);
fieldSetFlags()[45] = true;
}
if (isValidValue(fields()[46], other.prevSignature)) {
this.prevSignature = (java.nio.ByteBuffer) data().deepCopy(fields()[46].schema(), other.prevSignature);
fieldSetFlags()[46] = true;
}
if (isValidValue(fields()[47], other.signature)) {
this.signature = (java.nio.ByteBuffer) data().deepCopy(fields()[47].schema(), other.signature);
fieldSetFlags()[47] = true;
}
if (isValidValue(fields()[48], other.contentScore)) {
this.contentScore = (java.lang.Float) data().deepCopy(fields()[48].schema(), other.contentScore);
fieldSetFlags()[48] = true;
}
if (isValidValue(fields()[49], other.score)) {
this.score = (java.lang.Float) data().deepCopy(fields()[49].schema(), other.score);
fieldSetFlags()[49] = true;
}
if (isValidValue(fields()[50], other.sortScore)) {
this.sortScore = (java.lang.CharSequence) data().deepCopy(fields()[50].schema(), other.sortScore);
fieldSetFlags()[50] = true;
}
if (isValidValue(fields()[51], other.pageCounters)) {
this.pageCounters = (java.util.Map<java.lang.CharSequence,java.lang.Integer>) data().deepCopy(fields()[51].schema(), other.pageCounters);
fieldSetFlags()[51] = true;
}
if (isValidValue(fields()[52], other.headers)) {
this.headers = (java.util.Map<java.lang.CharSequence,java.lang.CharSequence>) data().deepCopy(fields()[52].schema(), other.headers);
fieldSetFlags()[52] = true;
}
if (isValidValue(fields()[53], other.links)) {
this.links = (java.util.List<java.lang.CharSequence>) data().deepCopy(fields()[53].schema(), other.links);
fieldSetFlags()[53] = true;
}
if (isValidValue(fields()[54], other.deadLinks)) {
this.deadLinks = (java.util.List<java.lang.CharSequence>) data().deepCopy(fields()[54].schema(), other.deadLinks);
fieldSetFlags()[54] = true;
}
if (isValidValue(fields()[55], other.liveLinks)) {
this.liveLinks = (java.util.Map<java.lang.CharSequence,ai.platon.pulsar.persist.gora.generated.GHypeLink>) data().deepCopy(fields()[55].schema(), other.liveLinks);
fieldSetFlags()[55] = true;
}
if (isValidValue(fields()[56], other.vividLinks)) {
this.vividLinks = (java.util.Map<java.lang.CharSequence,java.lang.CharSequence>) data().deepCopy(fields()[56].schema(), other.vividLinks);
fieldSetFlags()[56] = true;
}
if (isValidValue(fields()[57], other.inlinks)) {
this.inlinks = (java.util.Map<java.lang.CharSequence,java.lang.CharSequence>) data().deepCopy(fields()[57].schema(), other.inlinks);
fieldSetFlags()[57] = true;
}
if (isValidValue(fields()[58], other.markers)) {
this.markers = (java.util.Map<java.lang.CharSequence,java.lang.CharSequence>) data().deepCopy(fields()[58].schema(), other.markers);
fieldSetFlags()[58] = true;
}
if (isValidValue(fields()[59], other.metadata)) {
this.metadata = (java.util.Map<java.lang.CharSequence,java.nio.ByteBuffer>) data().deepCopy(fields()[59].schema(), other.metadata);
fieldSetFlags()[59] = true;
}
if (isValidValue(fields()[60], other.activeDOMStatus)) {
this.activeDOMStatus = (ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus) data().deepCopy(fields()[60].schema(), other.activeDOMStatus);
fieldSetFlags()[60] = true;
}
if (isValidValue(fields()[61], other.activeDOMStatTrace)) {
this.activeDOMStatTrace = (java.util.Map<java.lang.CharSequence,ai.platon.pulsar.persist.gora.generated.GActiveDOMStat>) data().deepCopy(fields()[61].schema(), other.activeDOMStatTrace);
fieldSetFlags()[61] = true;
}
if (isValidValue(fields()[62], other.pageModel)) {
this.pageModel = (ai.platon.pulsar.persist.gora.generated.GPageModel) data().deepCopy(fields()[62].schema(), other.pageModel);
fieldSetFlags()[62] = true;
}
}
/** Gets the value of the 'baseUrl' field */
public java.lang.CharSequence getBaseUrl() {
return baseUrl;
}
/** Sets the value of the 'baseUrl' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setBaseUrl(java.lang.CharSequence value) {
validate(fields()[0], value);
this.baseUrl = value;
fieldSetFlags()[0] = true;
return this;
}
/** Checks whether the 'baseUrl' field has been set */
public boolean hasBaseUrl() {
return fieldSetFlags()[0];
}
/** Clears the value of the 'baseUrl' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearBaseUrl() {
baseUrl = null;
fieldSetFlags()[0] = false;
return this;
}
/** Gets the value of the 'createTime' field */
public java.lang.Long getCreateTime() {
return createTime;
}
/** Sets the value of the 'createTime' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setCreateTime(long value) {
validate(fields()[1], value);
this.createTime = value;
fieldSetFlags()[1] = true;
return this;
}
/** Checks whether the 'createTime' field has been set */
public boolean hasCreateTime() {
return fieldSetFlags()[1];
}
/** Clears the value of the 'createTime' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearCreateTime() {
fieldSetFlags()[1] = false;
return this;
}
/** Gets the value of the 'distance' field */
public java.lang.Integer getDistance() {
return distance;
}
/** Sets the value of the 'distance' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setDistance(int value) {
validate(fields()[2], value);
this.distance = value;
fieldSetFlags()[2] = true;
return this;
}
/** Checks whether the 'distance' field has been set */
public boolean hasDistance() {
return fieldSetFlags()[2];
}
/** Clears the value of the 'distance' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearDistance() {
fieldSetFlags()[2] = false;
return this;
}
/** Gets the value of the 'fetchCount' field */
public java.lang.Integer getFetchCount() {
return fetchCount;
}
/** Sets the value of the 'fetchCount' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setFetchCount(int value) {
validate(fields()[3], value);
this.fetchCount = value;
fieldSetFlags()[3] = true;
return this;
}
/** Checks whether the 'fetchCount' field has been set */
public boolean hasFetchCount() {
return fieldSetFlags()[3];
}
/** Clears the value of the 'fetchCount' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearFetchCount() {
fieldSetFlags()[3] = false;
return this;
}
/** Gets the value of the 'fetchPriority' field */
public java.lang.Integer getFetchPriority() {
return fetchPriority;
}
/** Sets the value of the 'fetchPriority' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setFetchPriority(int value) {
validate(fields()[4], value);
this.fetchPriority = value;
fieldSetFlags()[4] = true;
return this;
}
/** Checks whether the 'fetchPriority' field has been set */
public boolean hasFetchPriority() {
return fieldSetFlags()[4];
}
/** Clears the value of the 'fetchPriority' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearFetchPriority() {
fieldSetFlags()[4] = false;
return this;
}
/** Gets the value of the 'fetchInterval' field */
public java.lang.Integer getFetchInterval() {
return fetchInterval;
}
/** Sets the value of the 'fetchInterval' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setFetchInterval(int value) {
validate(fields()[5], value);
this.fetchInterval = value;
fieldSetFlags()[5] = true;
return this;
}
/** Checks whether the 'fetchInterval' field has been set */
public boolean hasFetchInterval() {
return fieldSetFlags()[5];
}
/** Clears the value of the 'fetchInterval' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearFetchInterval() {
fieldSetFlags()[5] = false;
return this;
}
/** Gets the value of the 'zoneId' field */
public java.lang.CharSequence getZoneId() {
return zoneId;
}
/** Sets the value of the 'zoneId' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setZoneId(java.lang.CharSequence value) {
validate(fields()[6], value);
this.zoneId = value;
fieldSetFlags()[6] = true;
return this;
}
/** Checks whether the 'zoneId' field has been set */
public boolean hasZoneId() {
return fieldSetFlags()[6];
}
/** Clears the value of the 'zoneId' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearZoneId() {
zoneId = null;
fieldSetFlags()[6] = false;
return this;
}
/** Gets the value of the 'params' field */
public java.lang.CharSequence getParams() {
return params;
}
/** Sets the value of the 'params' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setParams(java.lang.CharSequence value) {
validate(fields()[7], value);
this.params = value;
fieldSetFlags()[7] = true;
return this;
}
/** Checks whether the 'params' field has been set */
public boolean hasParams() {
return fieldSetFlags()[7];
}
/** Clears the value of the 'params' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearParams() {
params = null;
fieldSetFlags()[7] = false;
return this;
}
/** Gets the value of the 'batchId' field */
public java.lang.CharSequence getBatchId() {
return batchId;
}
/** Sets the value of the 'batchId' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setBatchId(java.lang.CharSequence value) {
validate(fields()[8], value);
this.batchId = value;
fieldSetFlags()[8] = true;
return this;
}
/** Checks whether the 'batchId' field has been set */
public boolean hasBatchId() {
return fieldSetFlags()[8];
}
/** Clears the value of the 'batchId' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearBatchId() {
batchId = null;
fieldSetFlags()[8] = false;
return this;
}
/** Gets the value of the 'resource' field */
public java.lang.Integer getResource() {
return resource;
}
/** Sets the value of the 'resource' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setResource(java.lang.Integer value) {
validate(fields()[9], value);
this.resource = value;
fieldSetFlags()[9] = true;
return this;
}
/** Checks whether the 'resource' field has been set */
public boolean hasResource() {
return fieldSetFlags()[9];
}
/** Clears the value of the 'resource' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearResource() {
resource = null;
fieldSetFlags()[9] = false;
return this;
}
/** Gets the value of the 'crawlStatus' field */
public java.lang.Integer getCrawlStatus() {
return crawlStatus;
}
/** Sets the value of the 'crawlStatus' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setCrawlStatus(int value) {
validate(fields()[10], value);
this.crawlStatus = value;
fieldSetFlags()[10] = true;
return this;
}
/** Checks whether the 'crawlStatus' field has been set */
public boolean hasCrawlStatus() {
return fieldSetFlags()[10];
}
/** Clears the value of the 'crawlStatus' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearCrawlStatus() {
fieldSetFlags()[10] = false;
return this;
}
/** Gets the value of the 'browser' field */
public java.lang.CharSequence getBrowser() {
return browser;
}
/** Sets the value of the 'browser' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setBrowser(java.lang.CharSequence value) {
validate(fields()[11], value);
this.browser = value;
fieldSetFlags()[11] = true;
return this;
}
/** Checks whether the 'browser' field has been set */
public boolean hasBrowser() {
return fieldSetFlags()[11];
}
/** Clears the value of the 'browser' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearBrowser() {
browser = null;
fieldSetFlags()[11] = false;
return this;
}
/** Gets the value of the 'proxy' field */
public java.lang.CharSequence getProxy() {
return proxy;
}
/** Sets the value of the 'proxy' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setProxy(java.lang.CharSequence value) {
validate(fields()[12], value);
this.proxy = value;
fieldSetFlags()[12] = true;
return this;
}
/** Checks whether the 'proxy' field has been set */
public boolean hasProxy() {
return fieldSetFlags()[12];
}
/** Clears the value of the 'proxy' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearProxy() {
proxy = null;
fieldSetFlags()[12] = false;
return this;
}
/** Gets the value of the 'prevFetchTime' field */
public java.lang.Long getPrevFetchTime() {
return prevFetchTime;
}
/** Sets the value of the 'prevFetchTime' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setPrevFetchTime(long value) {
validate(fields()[13], value);
this.prevFetchTime = value;
fieldSetFlags()[13] = true;
return this;
}
/** Checks whether the 'prevFetchTime' field has been set */
public boolean hasPrevFetchTime() {
return fieldSetFlags()[13];
}
/** Clears the value of the 'prevFetchTime' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearPrevFetchTime() {
fieldSetFlags()[13] = false;
return this;
}
/** Gets the value of the 'prevCrawlTime1' field */
public java.lang.Long getPrevCrawlTime1() {
return prevCrawlTime1;
}
/** Sets the value of the 'prevCrawlTime1' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setPrevCrawlTime1(long value) {
validate(fields()[14], value);
this.prevCrawlTime1 = value;
fieldSetFlags()[14] = true;
return this;
}
/** Checks whether the 'prevCrawlTime1' field has been set */
public boolean hasPrevCrawlTime1() {
return fieldSetFlags()[14];
}
/** Clears the value of the 'prevCrawlTime1' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearPrevCrawlTime1() {
fieldSetFlags()[14] = false;
return this;
}
/** Gets the value of the 'fetchTime' field */
public java.lang.Long getFetchTime() {
return fetchTime;
}
/** Sets the value of the 'fetchTime' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setFetchTime(long value) {
validate(fields()[15], value);
this.fetchTime = value;
fieldSetFlags()[15] = true;
return this;
}
/** Checks whether the 'fetchTime' field has been set */
public boolean hasFetchTime() {
return fieldSetFlags()[15];
}
/** Clears the value of the 'fetchTime' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearFetchTime() {
fieldSetFlags()[15] = false;
return this;
}
/** Gets the value of the 'fetchRetries' field */
public java.lang.Integer getFetchRetries() {
return fetchRetries;
}
/** Sets the value of the 'fetchRetries' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setFetchRetries(int value) {
validate(fields()[16], value);
this.fetchRetries = value;
fieldSetFlags()[16] = true;
return this;
}
/** Checks whether the 'fetchRetries' field has been set */
public boolean hasFetchRetries() {
return fieldSetFlags()[16];
}
/** Clears the value of the 'fetchRetries' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearFetchRetries() {
fieldSetFlags()[16] = false;
return this;
}
/** Gets the value of the 'reprUrl' field */
public java.lang.CharSequence getReprUrl() {
return reprUrl;
}
/** Sets the value of the 'reprUrl' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setReprUrl(java.lang.CharSequence value) {
validate(fields()[17], value);
this.reprUrl = value;
fieldSetFlags()[17] = true;
return this;
}
/** Checks whether the 'reprUrl' field has been set */
public boolean hasReprUrl() {
return fieldSetFlags()[17];
}
/** Clears the value of the 'reprUrl' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearReprUrl() {
reprUrl = null;
fieldSetFlags()[17] = false;
return this;
}
/** Gets the value of the 'prevModifiedTime' field */
public java.lang.Long getPrevModifiedTime() {
return prevModifiedTime;
}
/** Sets the value of the 'prevModifiedTime' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setPrevModifiedTime(long value) {
validate(fields()[18], value);
this.prevModifiedTime = value;
fieldSetFlags()[18] = true;
return this;
}
/** Checks whether the 'prevModifiedTime' field has been set */
public boolean hasPrevModifiedTime() {
return fieldSetFlags()[18];
}
/** Clears the value of the 'prevModifiedTime' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearPrevModifiedTime() {
fieldSetFlags()[18] = false;
return this;
}
/** Gets the value of the 'modifiedTime' field */
public java.lang.Long getModifiedTime() {
return modifiedTime;
}
/** Sets the value of the 'modifiedTime' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setModifiedTime(long value) {
validate(fields()[19], value);
this.modifiedTime = value;
fieldSetFlags()[19] = true;
return this;
}
/** Checks whether the 'modifiedTime' field has been set */
public boolean hasModifiedTime() {
return fieldSetFlags()[19];
}
/** Clears the value of the 'modifiedTime' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearModifiedTime() {
fieldSetFlags()[19] = false;
return this;
}
/** Gets the value of the 'protocolStatus' field */
public ai.platon.pulsar.persist.gora.generated.GProtocolStatus getProtocolStatus() {
return protocolStatus;
}
/** Sets the value of the 'protocolStatus' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setProtocolStatus(ai.platon.pulsar.persist.gora.generated.GProtocolStatus value) {
validate(fields()[20], value);
this.protocolStatus = value;
fieldSetFlags()[20] = true;
return this;
}
/** Checks whether the 'protocolStatus' field has been set */
public boolean hasProtocolStatus() {
return fieldSetFlags()[20];
}
/** Clears the value of the 'protocolStatus' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearProtocolStatus() {
protocolStatus = null;
fieldSetFlags()[20] = false;
return this;
}
/** Gets the value of the 'encoding' field */
public java.lang.CharSequence getEncoding() {
return encoding;
}
/** Sets the value of the 'encoding' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setEncoding(java.lang.CharSequence value) {
validate(fields()[21], value);
this.encoding = value;
fieldSetFlags()[21] = true;
return this;
}
/** Checks whether the 'encoding' field has been set */
public boolean hasEncoding() {
return fieldSetFlags()[21];
}
/** Clears the value of the 'encoding' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearEncoding() {
encoding = null;
fieldSetFlags()[21] = false;
return this;
}
/** Gets the value of the 'contentType' field */
public java.lang.CharSequence getContentType() {
return contentType;
}
/** Sets the value of the 'contentType' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setContentType(java.lang.CharSequence value) {
validate(fields()[22], value);
this.contentType = value;
fieldSetFlags()[22] = true;
return this;
}
/** Checks whether the 'contentType' field has been set */
public boolean hasContentType() {
return fieldSetFlags()[22];
}
/** Clears the value of the 'contentType' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearContentType() {
contentType = null;
fieldSetFlags()[22] = false;
return this;
}
/** Gets the value of the 'content' field */
public java.nio.ByteBuffer getContent() {
return content;
}
/** Sets the value of the 'content' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setContent(java.nio.ByteBuffer value) {
validate(fields()[23], value);
this.content = value;
fieldSetFlags()[23] = true;
return this;
}
/** Checks whether the 'content' field has been set */
public boolean hasContent() {
return fieldSetFlags()[23];
}
/** Clears the value of the 'content' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearContent() {
content = null;
fieldSetFlags()[23] = false;
return this;
}
/** Gets the value of the 'contentLength' field */
public java.lang.Long getContentLength() {
return contentLength;
}
/** Sets the value of the 'contentLength' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setContentLength(long value) {
validate(fields()[24], value);
this.contentLength = value;
fieldSetFlags()[24] = true;
return this;
}
/** Checks whether the 'contentLength' field has been set */
public boolean hasContentLength() {
return fieldSetFlags()[24];
}
/** Clears the value of the 'contentLength' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearContentLength() {
fieldSetFlags()[24] = false;
return this;
}
/** Gets the value of the 'lastContentLength' field */
public java.lang.Long getLastContentLength() {
return lastContentLength;
}
/** Sets the value of the 'lastContentLength' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setLastContentLength(long value) {
validate(fields()[25], value);
this.lastContentLength = value;
fieldSetFlags()[25] = true;
return this;
}
/** Checks whether the 'lastContentLength' field has been set */
public boolean hasLastContentLength() {
return fieldSetFlags()[25];
}
/** Clears the value of the 'lastContentLength' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearLastContentLength() {
fieldSetFlags()[25] = false;
return this;
}
/** Gets the value of the 'aveContentLength' field */
public java.lang.Long getAveContentLength() {
return aveContentLength;
}
/** Sets the value of the 'aveContentLength' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setAveContentLength(long value) {
validate(fields()[26], value);
this.aveContentLength = value;
fieldSetFlags()[26] = true;
return this;
}
/** Checks whether the 'aveContentLength' field has been set */
public boolean hasAveContentLength() {
return fieldSetFlags()[26];
}
/** Clears the value of the 'aveContentLength' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearAveContentLength() {
fieldSetFlags()[26] = false;
return this;
}
/** Gets the value of the 'persistedContentLength' field */
public java.lang.Long getPersistedContentLength() {
return persistedContentLength;
}
/** Sets the value of the 'persistedContentLength' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setPersistedContentLength(long value) {
validate(fields()[27], value);
this.persistedContentLength = value;
fieldSetFlags()[27] = true;
return this;
}
/** Checks whether the 'persistedContentLength' field has been set */
public boolean hasPersistedContentLength() {
return fieldSetFlags()[27];
}
/** Clears the value of the 'persistedContentLength' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearPersistedContentLength() {
fieldSetFlags()[27] = false;
return this;
}
/** Gets the value of the 'referrer' field */
public java.lang.CharSequence getReferrer() {
return referrer;
}
/** Sets the value of the 'referrer' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setReferrer(java.lang.CharSequence value) {
validate(fields()[28], value);
this.referrer = value;
fieldSetFlags()[28] = true;
return this;
}
/** Checks whether the 'referrer' field has been set */
public boolean hasReferrer() {
return fieldSetFlags()[28];
}
/** Clears the value of the 'referrer' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearReferrer() {
referrer = null;
fieldSetFlags()[28] = false;
return this;
}
/** Gets the value of the 'htmlIntegrity' field */
public java.lang.CharSequence getHtmlIntegrity() {
return htmlIntegrity;
}
/** Sets the value of the 'htmlIntegrity' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setHtmlIntegrity(java.lang.CharSequence value) {
validate(fields()[29], value);
this.htmlIntegrity = value;
fieldSetFlags()[29] = true;
return this;
}
/** Checks whether the 'htmlIntegrity' field has been set */
public boolean hasHtmlIntegrity() {
return fieldSetFlags()[29];
}
/** Clears the value of the 'htmlIntegrity' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearHtmlIntegrity() {
htmlIntegrity = null;
fieldSetFlags()[29] = false;
return this;
}
/** Gets the value of the 'anchor' field */
public java.lang.CharSequence getAnchor() {
return anchor;
}
/** Sets the value of the 'anchor' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setAnchor(java.lang.CharSequence value) {
validate(fields()[30], value);
this.anchor = value;
fieldSetFlags()[30] = true;
return this;
}
/** Checks whether the 'anchor' field has been set */
public boolean hasAnchor() {
return fieldSetFlags()[30];
}
/** Clears the value of the 'anchor' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearAnchor() {
anchor = null;
fieldSetFlags()[30] = false;
return this;
}
/** Gets the value of the 'anchorOrder' field */
public java.lang.Integer getAnchorOrder() {
return anchorOrder;
}
/** Sets the value of the 'anchorOrder' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setAnchorOrder(int value) {
validate(fields()[31], value);
this.anchorOrder = value;
fieldSetFlags()[31] = true;
return this;
}
/** Checks whether the 'anchorOrder' field has been set */
public boolean hasAnchorOrder() {
return fieldSetFlags()[31];
}
/** Clears the value of the 'anchorOrder' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearAnchorOrder() {
fieldSetFlags()[31] = false;
return this;
}
/** Gets the value of the 'parseStatus' field */
public ai.platon.pulsar.persist.gora.generated.GParseStatus getParseStatus() {
return parseStatus;
}
/** Sets the value of the 'parseStatus' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setParseStatus(ai.platon.pulsar.persist.gora.generated.GParseStatus value) {
validate(fields()[32], value);
this.parseStatus = value;
fieldSetFlags()[32] = true;
return this;
}
/** Checks whether the 'parseStatus' field has been set */
public boolean hasParseStatus() {
return fieldSetFlags()[32];
}
/** Clears the value of the 'parseStatus' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearParseStatus() {
parseStatus = null;
fieldSetFlags()[32] = false;
return this;
}
/** Gets the value of the 'pageTitle' field */
public java.lang.CharSequence getPageTitle() {
return pageTitle;
}
/** Sets the value of the 'pageTitle' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setPageTitle(java.lang.CharSequence value) {
validate(fields()[33], value);
this.pageTitle = value;
fieldSetFlags()[33] = true;
return this;
}
/** Checks whether the 'pageTitle' field has been set */
public boolean hasPageTitle() {
return fieldSetFlags()[33];
}
/** Clears the value of the 'pageTitle' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearPageTitle() {
pageTitle = null;
fieldSetFlags()[33] = false;
return this;
}
/** Gets the value of the 'pageText' field */
public java.lang.CharSequence getPageText() {
return pageText;
}
/** Sets the value of the 'pageText' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setPageText(java.lang.CharSequence value) {
validate(fields()[34], value);
this.pageText = value;
fieldSetFlags()[34] = true;
return this;
}
/** Checks whether the 'pageText' field has been set */
public boolean hasPageText() {
return fieldSetFlags()[34];
}
/** Clears the value of the 'pageText' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearPageText() {
pageText = null;
fieldSetFlags()[34] = false;
return this;
}
/** Gets the value of the 'contentTitle' field */
public java.lang.CharSequence getContentTitle() {
return contentTitle;
}
/** Sets the value of the 'contentTitle' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setContentTitle(java.lang.CharSequence value) {
validate(fields()[35], value);
this.contentTitle = value;
fieldSetFlags()[35] = true;
return this;
}
/** Checks whether the 'contentTitle' field has been set */
public boolean hasContentTitle() {
return fieldSetFlags()[35];
}
/** Clears the value of the 'contentTitle' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearContentTitle() {
contentTitle = null;
fieldSetFlags()[35] = false;
return this;
}
/** Gets the value of the 'contentText' field */
public java.lang.CharSequence getContentText() {
return contentText;
}
/** Sets the value of the 'contentText' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setContentText(java.lang.CharSequence value) {
validate(fields()[36], value);
this.contentText = value;
fieldSetFlags()[36] = true;
return this;
}
/** Checks whether the 'contentText' field has been set */
public boolean hasContentText() {
return fieldSetFlags()[36];
}
/** Clears the value of the 'contentText' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearContentText() {
contentText = null;
fieldSetFlags()[36] = false;
return this;
}
/** Gets the value of the 'contentTextLen' field */
public java.lang.Integer getContentTextLen() {
return contentTextLen;
}
/** Sets the value of the 'contentTextLen' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setContentTextLen(int value) {
validate(fields()[37], value);
this.contentTextLen = value;
fieldSetFlags()[37] = true;
return this;
}
/** Checks whether the 'contentTextLen' field has been set */
public boolean hasContentTextLen() {
return fieldSetFlags()[37];
}
/** Clears the value of the 'contentTextLen' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearContentTextLen() {
fieldSetFlags()[37] = false;
return this;
}
/** Gets the value of the 'pageCategory' field */
public java.lang.CharSequence getPageCategory() {
return pageCategory;
}
/** Sets the value of the 'pageCategory' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setPageCategory(java.lang.CharSequence value) {
validate(fields()[38], value);
this.pageCategory = value;
fieldSetFlags()[38] = true;
return this;
}
/** Checks whether the 'pageCategory' field has been set */
public boolean hasPageCategory() {
return fieldSetFlags()[38];
}
/** Clears the value of the 'pageCategory' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearPageCategory() {
pageCategory = null;
fieldSetFlags()[38] = false;
return this;
}
/** Gets the value of the 'contentModifiedTime' field */
public java.lang.Long getContentModifiedTime() {
return contentModifiedTime;
}
/** Sets the value of the 'contentModifiedTime' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setContentModifiedTime(long value) {
validate(fields()[39], value);
this.contentModifiedTime = value;
fieldSetFlags()[39] = true;
return this;
}
/** Checks whether the 'contentModifiedTime' field has been set */
public boolean hasContentModifiedTime() {
return fieldSetFlags()[39];
}
/** Clears the value of the 'contentModifiedTime' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearContentModifiedTime() {
fieldSetFlags()[39] = false;
return this;
}
/** Gets the value of the 'prevContentModifiedTime' field */
public java.lang.Long getPrevContentModifiedTime() {
return prevContentModifiedTime;
}
/** Sets the value of the 'prevContentModifiedTime' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setPrevContentModifiedTime(long value) {
validate(fields()[40], value);
this.prevContentModifiedTime = value;
fieldSetFlags()[40] = true;
return this;
}
/** Checks whether the 'prevContentModifiedTime' field has been set */
public boolean hasPrevContentModifiedTime() {
return fieldSetFlags()[40];
}
/** Clears the value of the 'prevContentModifiedTime' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearPrevContentModifiedTime() {
fieldSetFlags()[40] = false;
return this;
}
/** Gets the value of the 'contentPublishTime' field */
public java.lang.Long getContentPublishTime() {
return contentPublishTime;
}
/** Sets the value of the 'contentPublishTime' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setContentPublishTime(long value) {
validate(fields()[41], value);
this.contentPublishTime = value;
fieldSetFlags()[41] = true;
return this;
}
/** Checks whether the 'contentPublishTime' field has been set */
public boolean hasContentPublishTime() {
return fieldSetFlags()[41];
}
/** Clears the value of the 'contentPublishTime' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearContentPublishTime() {
fieldSetFlags()[41] = false;
return this;
}
/** Gets the value of the 'prevContentPublishTime' field */
public java.lang.Long getPrevContentPublishTime() {
return prevContentPublishTime;
}
/** Sets the value of the 'prevContentPublishTime' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setPrevContentPublishTime(long value) {
validate(fields()[42], value);
this.prevContentPublishTime = value;
fieldSetFlags()[42] = true;
return this;
}
/** Checks whether the 'prevContentPublishTime' field has been set */
public boolean hasPrevContentPublishTime() {
return fieldSetFlags()[42];
}
/** Clears the value of the 'prevContentPublishTime' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearPrevContentPublishTime() {
fieldSetFlags()[42] = false;
return this;
}
/** Gets the value of the 'refContentPublishTime' field */
public java.lang.Long getRefContentPublishTime() {
return refContentPublishTime;
}
/** Sets the value of the 'refContentPublishTime' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setRefContentPublishTime(long value) {
validate(fields()[43], value);
this.refContentPublishTime = value;
fieldSetFlags()[43] = true;
return this;
}
/** Checks whether the 'refContentPublishTime' field has been set */
public boolean hasRefContentPublishTime() {
return fieldSetFlags()[43];
}
/** Clears the value of the 'refContentPublishTime' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearRefContentPublishTime() {
fieldSetFlags()[43] = false;
return this;
}
/** Gets the value of the 'prevRefContentPublishTime' field */
public java.lang.Long getPrevRefContentPublishTime() {
return prevRefContentPublishTime;
}
/** Sets the value of the 'prevRefContentPublishTime' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setPrevRefContentPublishTime(long value) {
validate(fields()[44], value);
this.prevRefContentPublishTime = value;
fieldSetFlags()[44] = true;
return this;
}
/** Checks whether the 'prevRefContentPublishTime' field has been set */
public boolean hasPrevRefContentPublishTime() {
return fieldSetFlags()[44];
}
/** Clears the value of the 'prevRefContentPublishTime' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearPrevRefContentPublishTime() {
fieldSetFlags()[44] = false;
return this;
}
/** Gets the value of the 'pageModelUpdateTime' field */
public java.lang.Long getPageModelUpdateTime() {
return pageModelUpdateTime;
}
/** Sets the value of the 'pageModelUpdateTime' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setPageModelUpdateTime(long value) {
validate(fields()[45], value);
this.pageModelUpdateTime = value;
fieldSetFlags()[45] = true;
return this;
}
/** Checks whether the 'pageModelUpdateTime' field has been set */
public boolean hasPageModelUpdateTime() {
return fieldSetFlags()[45];
}
/** Clears the value of the 'pageModelUpdateTime' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearPageModelUpdateTime() {
fieldSetFlags()[45] = false;
return this;
}
/** Gets the value of the 'prevSignature' field */
public java.nio.ByteBuffer getPrevSignature() {
return prevSignature;
}
/** Sets the value of the 'prevSignature' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setPrevSignature(java.nio.ByteBuffer value) {
validate(fields()[46], value);
this.prevSignature = value;
fieldSetFlags()[46] = true;
return this;
}
/** Checks whether the 'prevSignature' field has been set */
public boolean hasPrevSignature() {
return fieldSetFlags()[46];
}
/** Clears the value of the 'prevSignature' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearPrevSignature() {
prevSignature = null;
fieldSetFlags()[46] = false;
return this;
}
/** Gets the value of the 'signature' field */
public java.nio.ByteBuffer getSignature() {
return signature;
}
/** Sets the value of the 'signature' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setSignature(java.nio.ByteBuffer value) {
validate(fields()[47], value);
this.signature = value;
fieldSetFlags()[47] = true;
return this;
}
/** Checks whether the 'signature' field has been set */
public boolean hasSignature() {
return fieldSetFlags()[47];
}
/** Clears the value of the 'signature' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearSignature() {
signature = null;
fieldSetFlags()[47] = false;
return this;
}
/** Gets the value of the 'contentScore' field */
public java.lang.Float getContentScore() {
return contentScore;
}
/** Sets the value of the 'contentScore' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setContentScore(float value) {
validate(fields()[48], value);
this.contentScore = value;
fieldSetFlags()[48] = true;
return this;
}
/** Checks whether the 'contentScore' field has been set */
public boolean hasContentScore() {
return fieldSetFlags()[48];
}
/** Clears the value of the 'contentScore' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearContentScore() {
fieldSetFlags()[48] = false;
return this;
}
/** Gets the value of the 'score' field */
public java.lang.Float getScore() {
return score;
}
/** Sets the value of the 'score' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setScore(float value) {
validate(fields()[49], value);
this.score = value;
fieldSetFlags()[49] = true;
return this;
}
/** Checks whether the 'score' field has been set */
public boolean hasScore() {
return fieldSetFlags()[49];
}
/** Clears the value of the 'score' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearScore() {
fieldSetFlags()[49] = false;
return this;
}
/** Gets the value of the 'sortScore' field */
public java.lang.CharSequence getSortScore() {
return sortScore;
}
/** Sets the value of the 'sortScore' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setSortScore(java.lang.CharSequence value) {
validate(fields()[50], value);
this.sortScore = value;
fieldSetFlags()[50] = true;
return this;
}
/** Checks whether the 'sortScore' field has been set */
public boolean hasSortScore() {
return fieldSetFlags()[50];
}
/** Clears the value of the 'sortScore' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearSortScore() {
sortScore = null;
fieldSetFlags()[50] = false;
return this;
}
/** Gets the value of the 'pageCounters' field */
public java.util.Map<java.lang.CharSequence,java.lang.Integer> getPageCounters() {
return pageCounters;
}
/** Sets the value of the 'pageCounters' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setPageCounters(java.util.Map<java.lang.CharSequence,java.lang.Integer> value) {
validate(fields()[51], value);
this.pageCounters = value;
fieldSetFlags()[51] = true;
return this;
}
/** Checks whether the 'pageCounters' field has been set */
public boolean hasPageCounters() {
return fieldSetFlags()[51];
}
/** Clears the value of the 'pageCounters' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearPageCounters() {
pageCounters = null;
fieldSetFlags()[51] = false;
return this;
}
/** Gets the value of the 'headers' field */
public java.util.Map<java.lang.CharSequence,java.lang.CharSequence> getHeaders() {
return headers;
}
/** Sets the value of the 'headers' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setHeaders(java.util.Map<java.lang.CharSequence,java.lang.CharSequence> value) {
validate(fields()[52], value);
this.headers = value;
fieldSetFlags()[52] = true;
return this;
}
/** Checks whether the 'headers' field has been set */
public boolean hasHeaders() {
return fieldSetFlags()[52];
}
/** Clears the value of the 'headers' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearHeaders() {
headers = null;
fieldSetFlags()[52] = false;
return this;
}
/** Gets the value of the 'links' field */
public java.util.List<java.lang.CharSequence> getLinks() {
return links;
}
/** Sets the value of the 'links' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setLinks(java.util.List<java.lang.CharSequence> value) {
validate(fields()[53], value);
this.links = value;
fieldSetFlags()[53] = true;
return this;
}
/** Checks whether the 'links' field has been set */
public boolean hasLinks() {
return fieldSetFlags()[53];
}
/** Clears the value of the 'links' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearLinks() {
links = null;
fieldSetFlags()[53] = false;
return this;
}
/** Gets the value of the 'deadLinks' field */
public java.util.List<java.lang.CharSequence> getDeadLinks() {
return deadLinks;
}
/** Sets the value of the 'deadLinks' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setDeadLinks(java.util.List<java.lang.CharSequence> value) {
validate(fields()[54], value);
this.deadLinks = value;
fieldSetFlags()[54] = true;
return this;
}
/** Checks whether the 'deadLinks' field has been set */
public boolean hasDeadLinks() {
return fieldSetFlags()[54];
}
/** Clears the value of the 'deadLinks' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearDeadLinks() {
deadLinks = null;
fieldSetFlags()[54] = false;
return this;
}
/** Gets the value of the 'liveLinks' field */
public java.util.Map<java.lang.CharSequence,ai.platon.pulsar.persist.gora.generated.GHypeLink> getLiveLinks() {
return liveLinks;
}
/** Sets the value of the 'liveLinks' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setLiveLinks(java.util.Map<java.lang.CharSequence,ai.platon.pulsar.persist.gora.generated.GHypeLink> value) {
validate(fields()[55], value);
this.liveLinks = value;
fieldSetFlags()[55] = true;
return this;
}
/** Checks whether the 'liveLinks' field has been set */
public boolean hasLiveLinks() {
return fieldSetFlags()[55];
}
/** Clears the value of the 'liveLinks' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearLiveLinks() {
liveLinks = null;
fieldSetFlags()[55] = false;
return this;
}
/** Gets the value of the 'vividLinks' field */
public java.util.Map<java.lang.CharSequence,java.lang.CharSequence> getVividLinks() {
return vividLinks;
}
/** Sets the value of the 'vividLinks' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setVividLinks(java.util.Map<java.lang.CharSequence,java.lang.CharSequence> value) {
validate(fields()[56], value);
this.vividLinks = value;
fieldSetFlags()[56] = true;
return this;
}
/** Checks whether the 'vividLinks' field has been set */
public boolean hasVividLinks() {
return fieldSetFlags()[56];
}
/** Clears the value of the 'vividLinks' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearVividLinks() {
vividLinks = null;
fieldSetFlags()[56] = false;
return this;
}
/** Gets the value of the 'inlinks' field */
public java.util.Map<java.lang.CharSequence,java.lang.CharSequence> getInlinks() {
return inlinks;
}
/** Sets the value of the 'inlinks' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setInlinks(java.util.Map<java.lang.CharSequence,java.lang.CharSequence> value) {
validate(fields()[57], value);
this.inlinks = value;
fieldSetFlags()[57] = true;
return this;
}
/** Checks whether the 'inlinks' field has been set */
public boolean hasInlinks() {
return fieldSetFlags()[57];
}
/** Clears the value of the 'inlinks' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearInlinks() {
inlinks = null;
fieldSetFlags()[57] = false;
return this;
}
/** Gets the value of the 'markers' field */
public java.util.Map<java.lang.CharSequence,java.lang.CharSequence> getMarkers() {
return markers;
}
/** Sets the value of the 'markers' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setMarkers(java.util.Map<java.lang.CharSequence,java.lang.CharSequence> value) {
validate(fields()[58], value);
this.markers = value;
fieldSetFlags()[58] = true;
return this;
}
/** Checks whether the 'markers' field has been set */
public boolean hasMarkers() {
return fieldSetFlags()[58];
}
/** Clears the value of the 'markers' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearMarkers() {
markers = null;
fieldSetFlags()[58] = false;
return this;
}
/** Gets the value of the 'metadata' field */
public java.util.Map<java.lang.CharSequence,java.nio.ByteBuffer> getMetadata() {
return metadata;
}
/** Sets the value of the 'metadata' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setMetadata(java.util.Map<java.lang.CharSequence,java.nio.ByteBuffer> value) {
validate(fields()[59], value);
this.metadata = value;
fieldSetFlags()[59] = true;
return this;
}
/** Checks whether the 'metadata' field has been set */
public boolean hasMetadata() {
return fieldSetFlags()[59];
}
/** Clears the value of the 'metadata' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearMetadata() {
metadata = null;
fieldSetFlags()[59] = false;
return this;
}
/** Gets the value of the 'activeDOMStatus' field */
public ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus getActiveDOMStatus() {
return activeDOMStatus;
}
/** Sets the value of the 'activeDOMStatus' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setActiveDOMStatus(ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus value) {
validate(fields()[60], value);
this.activeDOMStatus = value;
fieldSetFlags()[60] = true;
return this;
}
/** Checks whether the 'activeDOMStatus' field has been set */
public boolean hasActiveDOMStatus() {
return fieldSetFlags()[60];
}
/** Clears the value of the 'activeDOMStatus' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearActiveDOMStatus() {
activeDOMStatus = null;
fieldSetFlags()[60] = false;
return this;
}
/** Gets the value of the 'activeDOMStatTrace' field */
public java.util.Map<java.lang.CharSequence,ai.platon.pulsar.persist.gora.generated.GActiveDOMStat> getActiveDOMStatTrace() {
return activeDOMStatTrace;
}
/** Sets the value of the 'activeDOMStatTrace' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setActiveDOMStatTrace(java.util.Map<java.lang.CharSequence,ai.platon.pulsar.persist.gora.generated.GActiveDOMStat> value) {
validate(fields()[61], value);
this.activeDOMStatTrace = value;
fieldSetFlags()[61] = true;
return this;
}
/** Checks whether the 'activeDOMStatTrace' field has been set */
public boolean hasActiveDOMStatTrace() {
return fieldSetFlags()[61];
}
/** Clears the value of the 'activeDOMStatTrace' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearActiveDOMStatTrace() {
activeDOMStatTrace = null;
fieldSetFlags()[61] = false;
return this;
}
/** Gets the value of the 'pageModel' field */
public ai.platon.pulsar.persist.gora.generated.GPageModel getPageModel() {
return pageModel;
}
/** Sets the value of the 'pageModel' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder setPageModel(ai.platon.pulsar.persist.gora.generated.GPageModel value) {
validate(fields()[62], value);
this.pageModel = value;
fieldSetFlags()[62] = true;
return this;
}
/** Checks whether the 'pageModel' field has been set */
public boolean hasPageModel() {
return fieldSetFlags()[62];
}
/** Clears the value of the 'pageModel' field */
public ai.platon.pulsar.persist.gora.generated.GWebPage.Builder clearPageModel() {
pageModel = null;
fieldSetFlags()[62] = false;
return this;
}
@Override
public GWebPage build() {
try {
GWebPage record = new GWebPage();
record.baseUrl = fieldSetFlags()[0] ? this.baseUrl : (java.lang.CharSequence) defaultValue(fields()[0]);
record.createTime = fieldSetFlags()[1] ? this.createTime : (java.lang.Long) defaultValue(fields()[1]);
record.distance = fieldSetFlags()[2] ? this.distance : (java.lang.Integer) defaultValue(fields()[2]);
record.fetchCount = fieldSetFlags()[3] ? this.fetchCount : (java.lang.Integer) defaultValue(fields()[3]);
record.fetchPriority = fieldSetFlags()[4] ? this.fetchPriority : (java.lang.Integer) defaultValue(fields()[4]);
record.fetchInterval = fieldSetFlags()[5] ? this.fetchInterval : (java.lang.Integer) defaultValue(fields()[5]);
record.zoneId = fieldSetFlags()[6] ? this.zoneId : (java.lang.CharSequence) defaultValue(fields()[6]);
record.params = fieldSetFlags()[7] ? this.params : (java.lang.CharSequence) defaultValue(fields()[7]);
record.batchId = fieldSetFlags()[8] ? this.batchId : (java.lang.CharSequence) defaultValue(fields()[8]);
record.resource = fieldSetFlags()[9] ? this.resource : (java.lang.Integer) defaultValue(fields()[9]);
record.crawlStatus = fieldSetFlags()[10] ? this.crawlStatus : (java.lang.Integer) defaultValue(fields()[10]);
record.browser = fieldSetFlags()[11] ? this.browser : (java.lang.CharSequence) defaultValue(fields()[11]);
record.proxy = fieldSetFlags()[12] ? this.proxy : (java.lang.CharSequence) defaultValue(fields()[12]);
record.prevFetchTime = fieldSetFlags()[13] ? this.prevFetchTime : (java.lang.Long) defaultValue(fields()[13]);
record.prevCrawlTime1 = fieldSetFlags()[14] ? this.prevCrawlTime1 : (java.lang.Long) defaultValue(fields()[14]);
record.fetchTime = fieldSetFlags()[15] ? this.fetchTime : (java.lang.Long) defaultValue(fields()[15]);
record.fetchRetries = fieldSetFlags()[16] ? this.fetchRetries : (java.lang.Integer) defaultValue(fields()[16]);
record.reprUrl = fieldSetFlags()[17] ? this.reprUrl : (java.lang.CharSequence) defaultValue(fields()[17]);
record.prevModifiedTime = fieldSetFlags()[18] ? this.prevModifiedTime : (java.lang.Long) defaultValue(fields()[18]);
record.modifiedTime = fieldSetFlags()[19] ? this.modifiedTime : (java.lang.Long) defaultValue(fields()[19]);
record.protocolStatus = fieldSetFlags()[20] ? this.protocolStatus : (ai.platon.pulsar.persist.gora.generated.GProtocolStatus) defaultValue(fields()[20]);
record.encoding = fieldSetFlags()[21] ? this.encoding : (java.lang.CharSequence) defaultValue(fields()[21]);
record.contentType = fieldSetFlags()[22] ? this.contentType : (java.lang.CharSequence) defaultValue(fields()[22]);
record.content = fieldSetFlags()[23] ? this.content : (java.nio.ByteBuffer) defaultValue(fields()[23]);
record.contentLength = fieldSetFlags()[24] ? this.contentLength : (java.lang.Long) defaultValue(fields()[24]);
record.lastContentLength = fieldSetFlags()[25] ? this.lastContentLength : (java.lang.Long) defaultValue(fields()[25]);
record.aveContentLength = fieldSetFlags()[26] ? this.aveContentLength : (java.lang.Long) defaultValue(fields()[26]);
record.persistedContentLength = fieldSetFlags()[27] ? this.persistedContentLength : (java.lang.Long) defaultValue(fields()[27]);
record.referrer = fieldSetFlags()[28] ? this.referrer : (java.lang.CharSequence) defaultValue(fields()[28]);
record.htmlIntegrity = fieldSetFlags()[29] ? this.htmlIntegrity : (java.lang.CharSequence) defaultValue(fields()[29]);
record.anchor = fieldSetFlags()[30] ? this.anchor : (java.lang.CharSequence) defaultValue(fields()[30]);
record.anchorOrder = fieldSetFlags()[31] ? this.anchorOrder : (java.lang.Integer) defaultValue(fields()[31]);
record.parseStatus = fieldSetFlags()[32] ? this.parseStatus : (ai.platon.pulsar.persist.gora.generated.GParseStatus) defaultValue(fields()[32]);
record.pageTitle = fieldSetFlags()[33] ? this.pageTitle : (java.lang.CharSequence) defaultValue(fields()[33]);
record.pageText = fieldSetFlags()[34] ? this.pageText : (java.lang.CharSequence) defaultValue(fields()[34]);
record.contentTitle = fieldSetFlags()[35] ? this.contentTitle : (java.lang.CharSequence) defaultValue(fields()[35]);
record.contentText = fieldSetFlags()[36] ? this.contentText : (java.lang.CharSequence) defaultValue(fields()[36]);
record.contentTextLen = fieldSetFlags()[37] ? this.contentTextLen : (java.lang.Integer) defaultValue(fields()[37]);
record.pageCategory = fieldSetFlags()[38] ? this.pageCategory : (java.lang.CharSequence) defaultValue(fields()[38]);
record.contentModifiedTime = fieldSetFlags()[39] ? this.contentModifiedTime : (java.lang.Long) defaultValue(fields()[39]);
record.prevContentModifiedTime = fieldSetFlags()[40] ? this.prevContentModifiedTime : (java.lang.Long) defaultValue(fields()[40]);
record.contentPublishTime = fieldSetFlags()[41] ? this.contentPublishTime : (java.lang.Long) defaultValue(fields()[41]);
record.prevContentPublishTime = fieldSetFlags()[42] ? this.prevContentPublishTime : (java.lang.Long) defaultValue(fields()[42]);
record.refContentPublishTime = fieldSetFlags()[43] ? this.refContentPublishTime : (java.lang.Long) defaultValue(fields()[43]);
record.prevRefContentPublishTime = fieldSetFlags()[44] ? this.prevRefContentPublishTime : (java.lang.Long) defaultValue(fields()[44]);
record.pageModelUpdateTime = fieldSetFlags()[45] ? this.pageModelUpdateTime : (java.lang.Long) defaultValue(fields()[45]);
record.prevSignature = fieldSetFlags()[46] ? this.prevSignature : (java.nio.ByteBuffer) defaultValue(fields()[46]);
record.signature = fieldSetFlags()[47] ? this.signature : (java.nio.ByteBuffer) defaultValue(fields()[47]);
record.contentScore = fieldSetFlags()[48] ? this.contentScore : (java.lang.Float) defaultValue(fields()[48]);
record.score = fieldSetFlags()[49] ? this.score : (java.lang.Float) defaultValue(fields()[49]);
record.sortScore = fieldSetFlags()[50] ? this.sortScore : (java.lang.CharSequence) defaultValue(fields()[50]);
record.pageCounters = fieldSetFlags()[51] ? this.pageCounters : (java.util.Map<java.lang.CharSequence,java.lang.Integer>) new org.apache.gora.persistency.impl.DirtyMapWrapper((java.util.Map)defaultValue(fields()[51]));
record.headers = fieldSetFlags()[52] ? this.headers : (java.util.Map<java.lang.CharSequence,java.lang.CharSequence>) new org.apache.gora.persistency.impl.DirtyMapWrapper((java.util.Map)defaultValue(fields()[52]));
record.links = fieldSetFlags()[53] ? this.links : (java.util.List<java.lang.CharSequence>) new org.apache.gora.persistency.impl.DirtyListWrapper((java.util.List)defaultValue(fields()[53]));
record.deadLinks = fieldSetFlags()[54] ? this.deadLinks : (java.util.List<java.lang.CharSequence>) new org.apache.gora.persistency.impl.DirtyListWrapper((java.util.List)defaultValue(fields()[54]));
record.liveLinks = fieldSetFlags()[55] ? this.liveLinks : (java.util.Map<java.lang.CharSequence,ai.platon.pulsar.persist.gora.generated.GHypeLink>) new org.apache.gora.persistency.impl.DirtyMapWrapper((java.util.Map)defaultValue(fields()[55]));
record.vividLinks = fieldSetFlags()[56] ? this.vividLinks : (java.util.Map<java.lang.CharSequence,java.lang.CharSequence>) new org.apache.gora.persistency.impl.DirtyMapWrapper((java.util.Map)defaultValue(fields()[56]));
record.inlinks = fieldSetFlags()[57] ? this.inlinks : (java.util.Map<java.lang.CharSequence,java.lang.CharSequence>) new org.apache.gora.persistency.impl.DirtyMapWrapper((java.util.Map)defaultValue(fields()[57]));
record.markers = fieldSetFlags()[58] ? this.markers : (java.util.Map<java.lang.CharSequence,java.lang.CharSequence>) new org.apache.gora.persistency.impl.DirtyMapWrapper((java.util.Map)defaultValue(fields()[58]));
record.metadata = fieldSetFlags()[59] ? this.metadata : (java.util.Map<java.lang.CharSequence,java.nio.ByteBuffer>) new org.apache.gora.persistency.impl.DirtyMapWrapper((java.util.Map)defaultValue(fields()[59]));
record.activeDOMStatus = fieldSetFlags()[60] ? this.activeDOMStatus : (ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus) defaultValue(fields()[60]);
record.activeDOMStatTrace = fieldSetFlags()[61] ? this.activeDOMStatTrace : (java.util.Map<java.lang.CharSequence,ai.platon.pulsar.persist.gora.generated.GActiveDOMStat>) new org.apache.gora.persistency.impl.DirtyMapWrapper((java.util.Map)defaultValue(fields()[61]));
record.pageModel = fieldSetFlags()[62] ? this.pageModel : (ai.platon.pulsar.persist.gora.generated.GPageModel) defaultValue(fields()[62]);
return record;
} catch (Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
public GWebPage.Tombstone getTombstone(){
return TOMBSTONE;
}
public GWebPage newInstance(){
return newBuilder().build();
}
private static final Tombstone TOMBSTONE = new Tombstone();
public static final class Tombstone extends GWebPage implements org.apache.gora.persistency.Tombstone {
private Tombstone() { }
/**
* Gets the value of the 'baseUrl' field.
*/
public java.lang.CharSequence getBaseUrl() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'baseUrl' field.
* @param value the value to set.
*/
public void setBaseUrl(java.lang.CharSequence value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'baseUrl' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isBaseUrlDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'createTime' field.
*/
public java.lang.Long getCreateTime() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'createTime' field.
* @param value the value to set.
*/
public void setCreateTime(java.lang.Long value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'createTime' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isCreateTimeDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'distance' field.
*/
public java.lang.Integer getDistance() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'distance' field.
* @param value the value to set.
*/
public void setDistance(java.lang.Integer value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'distance' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isDistanceDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'fetchCount' field.
*/
public java.lang.Integer getFetchCount() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'fetchCount' field.
* @param value the value to set.
*/
public void setFetchCount(java.lang.Integer value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'fetchCount' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isFetchCountDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'fetchPriority' field.
*/
public java.lang.Integer getFetchPriority() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'fetchPriority' field.
* @param value the value to set.
*/
public void setFetchPriority(java.lang.Integer value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'fetchPriority' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isFetchPriorityDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'fetchInterval' field.
*/
public java.lang.Integer getFetchInterval() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'fetchInterval' field.
* @param value the value to set.
*/
public void setFetchInterval(java.lang.Integer value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'fetchInterval' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isFetchIntervalDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'zoneId' field.
*/
public java.lang.CharSequence getZoneId() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'zoneId' field.
* @param value the value to set.
*/
public void setZoneId(java.lang.CharSequence value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'zoneId' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isZoneIdDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'params' field.
*/
public java.lang.CharSequence getParams() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'params' field.
* @param value the value to set.
*/
public void setParams(java.lang.CharSequence value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'params' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isParamsDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'batchId' field.
*/
public java.lang.CharSequence getBatchId() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'batchId' field.
* @param value the value to set.
*/
public void setBatchId(java.lang.CharSequence value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'batchId' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isBatchIdDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'resource' field.
*/
public java.lang.Integer getResource() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'resource' field.
* @param value the value to set.
*/
public void setResource(java.lang.Integer value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'resource' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isResourceDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'crawlStatus' field.
*/
public java.lang.Integer getCrawlStatus() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'crawlStatus' field.
* @param value the value to set.
*/
public void setCrawlStatus(java.lang.Integer value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'crawlStatus' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isCrawlStatusDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'browser' field.
*/
public java.lang.CharSequence getBrowser() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'browser' field.
* @param value the value to set.
*/
public void setBrowser(java.lang.CharSequence value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'browser' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isBrowserDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'proxy' field.
*/
public java.lang.CharSequence getProxy() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'proxy' field.
* @param value the value to set.
*/
public void setProxy(java.lang.CharSequence value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'proxy' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isProxyDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'prevFetchTime' field.
*/
public java.lang.Long getPrevFetchTime() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'prevFetchTime' field.
* @param value the value to set.
*/
public void setPrevFetchTime(java.lang.Long value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'prevFetchTime' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isPrevFetchTimeDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'prevCrawlTime1' field.
*/
public java.lang.Long getPrevCrawlTime1() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'prevCrawlTime1' field.
* @param value the value to set.
*/
public void setPrevCrawlTime1(java.lang.Long value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'prevCrawlTime1' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isPrevCrawlTime1Dirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'fetchTime' field.
*/
public java.lang.Long getFetchTime() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'fetchTime' field.
* @param value the value to set.
*/
public void setFetchTime(java.lang.Long value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'fetchTime' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isFetchTimeDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'fetchRetries' field.
*/
public java.lang.Integer getFetchRetries() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'fetchRetries' field.
* @param value the value to set.
*/
public void setFetchRetries(java.lang.Integer value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'fetchRetries' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isFetchRetriesDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'reprUrl' field.
*/
public java.lang.CharSequence getReprUrl() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'reprUrl' field.
* @param value the value to set.
*/
public void setReprUrl(java.lang.CharSequence value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'reprUrl' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isReprUrlDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'prevModifiedTime' field.
*/
public java.lang.Long getPrevModifiedTime() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'prevModifiedTime' field.
* @param value the value to set.
*/
public void setPrevModifiedTime(java.lang.Long value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'prevModifiedTime' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isPrevModifiedTimeDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'modifiedTime' field.
*/
public java.lang.Long getModifiedTime() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'modifiedTime' field.
* @param value the value to set.
*/
public void setModifiedTime(java.lang.Long value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'modifiedTime' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isModifiedTimeDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'protocolStatus' field.
*/
public ai.platon.pulsar.persist.gora.generated.GProtocolStatus getProtocolStatus() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'protocolStatus' field.
* @param value the value to set.
*/
public void setProtocolStatus(ai.platon.pulsar.persist.gora.generated.GProtocolStatus value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'protocolStatus' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isProtocolStatusDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'encoding' field.
*/
public java.lang.CharSequence getEncoding() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'encoding' field.
* @param value the value to set.
*/
public void setEncoding(java.lang.CharSequence value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'encoding' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isEncodingDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'contentType' field.
*/
public java.lang.CharSequence getContentType() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'contentType' field.
* @param value the value to set.
*/
public void setContentType(java.lang.CharSequence value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'contentType' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isContentTypeDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'content' field.
* The entire raw document content e.g. raw XHTML */
public java.nio.ByteBuffer getContent() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'content' field.
* The entire raw document content e.g. raw XHTML * @param value the value to set.
*/
public void setContent(java.nio.ByteBuffer value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'content' field. A field is dirty if it represents a change that has not yet been written to the database.
* The entire raw document content e.g. raw XHTML * @param value the value to set.
*/
public boolean isContentDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'contentLength' field.
*/
public java.lang.Long getContentLength() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'contentLength' field.
* @param value the value to set.
*/
public void setContentLength(java.lang.Long value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'contentLength' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isContentLengthDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'lastContentLength' field.
*/
public java.lang.Long getLastContentLength() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'lastContentLength' field.
* @param value the value to set.
*/
public void setLastContentLength(java.lang.Long value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'lastContentLength' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isLastContentLengthDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'aveContentLength' field.
*/
public java.lang.Long getAveContentLength() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'aveContentLength' field.
* @param value the value to set.
*/
public void setAveContentLength(java.lang.Long value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'aveContentLength' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isAveContentLengthDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'persistedContentLength' field.
*/
public java.lang.Long getPersistedContentLength() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'persistedContentLength' field.
* @param value the value to set.
*/
public void setPersistedContentLength(java.lang.Long value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'persistedContentLength' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isPersistedContentLengthDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'referrer' field.
*/
public java.lang.CharSequence getReferrer() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'referrer' field.
* @param value the value to set.
*/
public void setReferrer(java.lang.CharSequence value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'referrer' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isReferrerDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'htmlIntegrity' field.
*/
public java.lang.CharSequence getHtmlIntegrity() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'htmlIntegrity' field.
* @param value the value to set.
*/
public void setHtmlIntegrity(java.lang.CharSequence value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'htmlIntegrity' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isHtmlIntegrityDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'anchor' field.
*/
public java.lang.CharSequence getAnchor() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'anchor' field.
* @param value the value to set.
*/
public void setAnchor(java.lang.CharSequence value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'anchor' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isAnchorDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'anchorOrder' field.
*/
public java.lang.Integer getAnchorOrder() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'anchorOrder' field.
* @param value the value to set.
*/
public void setAnchorOrder(java.lang.Integer value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'anchorOrder' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isAnchorOrderDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'parseStatus' field.
*/
public ai.platon.pulsar.persist.gora.generated.GParseStatus getParseStatus() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'parseStatus' field.
* @param value the value to set.
*/
public void setParseStatus(ai.platon.pulsar.persist.gora.generated.GParseStatus value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'parseStatus' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isParseStatusDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'pageTitle' field.
*/
public java.lang.CharSequence getPageTitle() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'pageTitle' field.
* @param value the value to set.
*/
public void setPageTitle(java.lang.CharSequence value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'pageTitle' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isPageTitleDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'pageText' field.
*/
public java.lang.CharSequence getPageText() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'pageText' field.
* @param value the value to set.
*/
public void setPageText(java.lang.CharSequence value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'pageText' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isPageTextDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'contentTitle' field.
*/
public java.lang.CharSequence getContentTitle() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'contentTitle' field.
* @param value the value to set.
*/
public void setContentTitle(java.lang.CharSequence value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'contentTitle' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isContentTitleDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'contentText' field.
*/
public java.lang.CharSequence getContentText() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'contentText' field.
* @param value the value to set.
*/
public void setContentText(java.lang.CharSequence value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'contentText' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isContentTextDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'contentTextLen' field.
*/
public java.lang.Integer getContentTextLen() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'contentTextLen' field.
* @param value the value to set.
*/
public void setContentTextLen(java.lang.Integer value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'contentTextLen' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isContentTextLenDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'pageCategory' field.
*/
public java.lang.CharSequence getPageCategory() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'pageCategory' field.
* @param value the value to set.
*/
public void setPageCategory(java.lang.CharSequence value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'pageCategory' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isPageCategoryDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'contentModifiedTime' field.
*/
public java.lang.Long getContentModifiedTime() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'contentModifiedTime' field.
* @param value the value to set.
*/
public void setContentModifiedTime(java.lang.Long value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'contentModifiedTime' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isContentModifiedTimeDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'prevContentModifiedTime' field.
*/
public java.lang.Long getPrevContentModifiedTime() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'prevContentModifiedTime' field.
* @param value the value to set.
*/
public void setPrevContentModifiedTime(java.lang.Long value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'prevContentModifiedTime' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isPrevContentModifiedTimeDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'contentPublishTime' field.
*/
public java.lang.Long getContentPublishTime() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'contentPublishTime' field.
* @param value the value to set.
*/
public void setContentPublishTime(java.lang.Long value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'contentPublishTime' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isContentPublishTimeDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'prevContentPublishTime' field.
*/
public java.lang.Long getPrevContentPublishTime() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'prevContentPublishTime' field.
* @param value the value to set.
*/
public void setPrevContentPublishTime(java.lang.Long value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'prevContentPublishTime' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isPrevContentPublishTimeDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'refContentPublishTime' field.
*/
public java.lang.Long getRefContentPublishTime() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'refContentPublishTime' field.
* @param value the value to set.
*/
public void setRefContentPublishTime(java.lang.Long value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'refContentPublishTime' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isRefContentPublishTimeDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'prevRefContentPublishTime' field.
*/
public java.lang.Long getPrevRefContentPublishTime() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'prevRefContentPublishTime' field.
* @param value the value to set.
*/
public void setPrevRefContentPublishTime(java.lang.Long value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'prevRefContentPublishTime' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isPrevRefContentPublishTimeDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'pageModelUpdateTime' field.
*/
public java.lang.Long getPageModelUpdateTime() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'pageModelUpdateTime' field.
* @param value the value to set.
*/
public void setPageModelUpdateTime(java.lang.Long value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'pageModelUpdateTime' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isPageModelUpdateTimeDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'prevSignature' field.
*/
public java.nio.ByteBuffer getPrevSignature() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'prevSignature' field.
* @param value the value to set.
*/
public void setPrevSignature(java.nio.ByteBuffer value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'prevSignature' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isPrevSignatureDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'signature' field.
*/
public java.nio.ByteBuffer getSignature() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'signature' field.
* @param value the value to set.
*/
public void setSignature(java.nio.ByteBuffer value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'signature' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isSignatureDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'contentScore' field.
*/
public java.lang.Float getContentScore() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'contentScore' field.
* @param value the value to set.
*/
public void setContentScore(java.lang.Float value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'contentScore' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isContentScoreDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'score' field.
*/
public java.lang.Float getScore() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'score' field.
* @param value the value to set.
*/
public void setScore(java.lang.Float value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'score' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isScoreDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'sortScore' field.
*/
public java.lang.CharSequence getSortScore() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'sortScore' field.
* @param value the value to set.
*/
public void setSortScore(java.lang.CharSequence value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'sortScore' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isSortScoreDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'pageCounters' field.
*/
public java.util.Map<java.lang.CharSequence,java.lang.Integer> getPageCounters() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'pageCounters' field.
* @param value the value to set.
*/
public void setPageCounters(java.util.Map<java.lang.CharSequence,java.lang.Integer> value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'pageCounters' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isPageCountersDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'headers' field.
*/
public java.util.Map<java.lang.CharSequence,java.lang.CharSequence> getHeaders() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'headers' field.
* @param value the value to set.
*/
public void setHeaders(java.util.Map<java.lang.CharSequence,java.lang.CharSequence> value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'headers' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isHeadersDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'links' field.
*/
public java.util.List<java.lang.CharSequence> getLinks() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'links' field.
* @param value the value to set.
*/
public void setLinks(java.util.List<java.lang.CharSequence> value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'links' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isLinksDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'deadLinks' field.
*/
public java.util.List<java.lang.CharSequence> getDeadLinks() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'deadLinks' field.
* @param value the value to set.
*/
public void setDeadLinks(java.util.List<java.lang.CharSequence> value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'deadLinks' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isDeadLinksDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'liveLinks' field.
*/
public java.util.Map<java.lang.CharSequence,ai.platon.pulsar.persist.gora.generated.GHypeLink> getLiveLinks() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'liveLinks' field.
* @param value the value to set.
*/
public void setLiveLinks(java.util.Map<java.lang.CharSequence,ai.platon.pulsar.persist.gora.generated.GHypeLink> value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'liveLinks' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isLiveLinksDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'vividLinks' field.
*/
public java.util.Map<java.lang.CharSequence,java.lang.CharSequence> getVividLinks() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'vividLinks' field.
* @param value the value to set.
*/
public void setVividLinks(java.util.Map<java.lang.CharSequence,java.lang.CharSequence> value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'vividLinks' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isVividLinksDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'inlinks' field.
*/
public java.util.Map<java.lang.CharSequence,java.lang.CharSequence> getInlinks() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'inlinks' field.
* @param value the value to set.
*/
public void setInlinks(java.util.Map<java.lang.CharSequence,java.lang.CharSequence> value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'inlinks' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isInlinksDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'markers' field.
*/
public java.util.Map<java.lang.CharSequence,java.lang.CharSequence> getMarkers() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'markers' field.
* @param value the value to set.
*/
public void setMarkers(java.util.Map<java.lang.CharSequence,java.lang.CharSequence> value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'markers' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isMarkersDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'metadata' field.
*/
public java.util.Map<java.lang.CharSequence,java.nio.ByteBuffer> getMetadata() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'metadata' field.
* @param value the value to set.
*/
public void setMetadata(java.util.Map<java.lang.CharSequence,java.nio.ByteBuffer> value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'metadata' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isMetadataDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'activeDOMStatus' field.
*/
public ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus getActiveDOMStatus() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'activeDOMStatus' field.
* @param value the value to set.
*/
public void setActiveDOMStatus(ai.platon.pulsar.persist.gora.generated.GActiveDOMStatus value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'activeDOMStatus' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isActiveDOMStatusDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'activeDOMStatTrace' field.
*/
public java.util.Map<java.lang.CharSequence,ai.platon.pulsar.persist.gora.generated.GActiveDOMStat> getActiveDOMStatTrace() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'activeDOMStatTrace' field.
* @param value the value to set.
*/
public void setActiveDOMStatTrace(java.util.Map<java.lang.CharSequence,ai.platon.pulsar.persist.gora.generated.GActiveDOMStat> value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'activeDOMStatTrace' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isActiveDOMStatTraceDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
/**
* Gets the value of the 'pageModel' field.
*/
public ai.platon.pulsar.persist.gora.generated.GPageModel getPageModel() {
throw new java.lang.UnsupportedOperationException("Get is not supported on tombstones");
}
/**
* Sets the value of the 'pageModel' field.
* @param value the value to set.
*/
public void setPageModel(ai.platon.pulsar.persist.gora.generated.GPageModel value) {
throw new java.lang.UnsupportedOperationException("Set is not supported on tombstones");
}
/**
* Checks the dirty status of the 'pageModel' field. A field is dirty if it represents a change that has not yet been written to the database.
* @param value the value to set.
*/
public boolean isPageModelDirty() {
throw new java.lang.UnsupportedOperationException("IsDirty is not supported on tombstones");
}
}
private static final org.apache.avro.io.DatumWriter
DATUM_WRITER$ = new org.apache.avro.specific.SpecificDatumWriter(SCHEMA$);
private static final org.apache.avro.io.DatumReader
DATUM_READER$ = new org.apache.avro.specific.SpecificDatumReader(SCHEMA$);
/**
* Writes AVRO data bean to output stream in the form of AVRO Binary encoding format. This will transform
* AVRO data bean from its Java object form to it s serializable form.
*
* @param out java.io.ObjectOutput output stream to write data bean in serializable form
*/
@Override
public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
out.write(super.getDirtyBytes().array());
DATUM_WRITER$.write(this, org.apache.avro.io.EncoderFactory.get()
.directBinaryEncoder((java.io.OutputStream) out,
null));
}
/**
* Reads AVRO data bean from input stream in it s AVRO Binary encoding format to Java object format.
* This will transform AVRO data bean from it s serializable form to deserialized Java object form.
*
* @param in java.io.ObjectOutput input stream to read data bean in serializable form
*/
@Override
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
byte[] __g__dirty = new byte[getFieldsCount()];
in.read(__g__dirty);
super.setDirtyBytes(java.nio.ByteBuffer.wrap(__g__dirty));
DATUM_READER$.read(this, org.apache.avro.io.DecoderFactory.get()
.directBinaryDecoder((java.io.InputStream) in,
null));
}
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-persist/3.0.15/ai/platon/pulsar/persist
|
java-sources/ai/platon/pulsar/pulsar-persist/3.0.15/ai/platon/pulsar/persist/metadata/FetchMode.java
|
package ai.platon.pulsar.persist.metadata;
import org.jetbrains.annotations.NotNull;
/**
* @author vincent
*/
public enum FetchMode {
UNKNOWN,
/**
* Fetch every page using a real browser
* */
BROWSER;
/**
* <p>fromString.</p>
*
* @param s a {@link java.lang.String} object.
* @return a {@link ai.platon.pulsar.persist.metadata.FetchMode} object.
*/
@NotNull
public static FetchMode fromString(String s) {
if (s == null || s.isEmpty()) {
return UNKNOWN;
}
try {
return FetchMode.valueOf(s.toUpperCase());
} catch (Throwable e) {
return UNKNOWN;
}
}
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-persist/3.0.15/ai/platon/pulsar/persist
|
java-sources/ai/platon/pulsar/pulsar-persist/3.0.15/ai/platon/pulsar/persist/metadata/MultiMetadata.java
|
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.platon.pulsar.persist.metadata;
import ai.platon.pulsar.common.DateTimes;
import ai.platon.pulsar.common.DublinCore;
import ai.platon.pulsar.common.HttpHeaders;
import ai.platon.pulsar.common.config.AppConstants;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import java.time.Instant;
import java.util.*;
import java.util.stream.Collectors;
/**
* A multi-valued data container.
*
* @author Chris Mattmann
* @author Jérôme Charron
* @version $Id: $Id
*/
public class MultiMetadata implements DublinCore, HttpHeaders, AppConstants {
public static final String META_TMP = "TMP_";
/**
* A map of all data attributes.
*/
private final Multimap<String, String> data = ArrayListMultimap.create();
/**
* Constructs a new, empty data.
*/
public MultiMetadata() {
}
public MultiMetadata(Map<String, String> kvs) {
kvs.forEach(this::put);
}
/**
* Constructs a new, empty data.
*
* @param kvs a {@link java.lang.String} object.
*/
public MultiMetadata(String... kvs) {
int length = kvs.length;
if (length % 2 == 0) {
for (int i = 0; i < length; i += 2) {
put(kvs[i], kvs[1 + i]);
}
} else {
throw new IllegalArgumentException("Length of the variable argument 'kvs' must be an even number");
}
}
/**
* Returns true if named value is multivalued.
*
* @param name name of data
* @return true is named value is multivalued, false if single value or null
*/
public boolean isMultiValued(String name) {
return data.get(name) != null && data.get(name).size() > 1;
}
/**
* Returns a set of the names contained in the data.
*
* @return Metadata names
*/
public Set<String> names() {
return data.keySet();
}
/**
* <p>asMultimap.</p>
*
* @return a {@link com.google.common.collect.Multimap} object.
*/
public Multimap<String, String> asMultimap() {
return data;
}
/**
* Get the value associated to a data name. If many values are assiociated
* to the specified name, then the first one is returned.
*
* @param name of the data.
* @return the value associated to the specified data name.
*/
public String get(String name) {
Collection<String> values = data.get(name);
if (values.isEmpty()) {
return null;
} else {
return values.iterator().next();
}
}
/**
* <p>get.</p>
*
* @param name a {@link ai.platon.pulsar.persist.metadata.Name} object.
* @return a {@link java.lang.String} object.
*/
public String get(Name name) {
return get(name.text());
}
/**
* Get the values associated to a data name.
*
* @param name of the data.
* @return the values associated to a data name.
*/
public Collection<String> getValues(String name) {
return CollectionUtils.emptyIfNull(data.get(name));
}
/**
* <p>getNonNullValues.</p>
*
* @param name a {@link java.lang.String} object.
* @return a {@link java.util.Collection} object.
*/
public Collection<String> getNonNullValues(String name) {
return getValues(name).stream().filter(Objects::nonNull).collect(Collectors.toList());
}
/**
* Add a data name/value mapping. Add the specified value to the list of
* values associated to the specified data name.
*
* @param name the data name.
* @param value the data value.
*/
public void put(String name, String value) {
data.put(name, value);
}
/**
* <p>put.</p>
*
* @param name a {@link ai.platon.pulsar.persist.metadata.Name} object.
* @param value a {@link java.lang.String} object.
*/
public void put(Name name, String value) {
put(name.text(), value);
}
/**
* <p>put.</p>
*
* @param name a {@link ai.platon.pulsar.persist.metadata.Name} object.
* @param value a int.
*/
public void put(Name name, int value) {
put(name, String.valueOf(value));
}
/**
* <p>put.</p>
*
* @param name a {@link ai.platon.pulsar.persist.metadata.Name} object.
* @param value a long.
*/
public void put(Name name, long value) {
put(name, String.valueOf(value));
}
/**
* <p>put.</p>
*
* @param name a {@link ai.platon.pulsar.persist.metadata.Name} object.
* @param value a {@link java.time.Instant} object.
*/
public void put(Name name, Instant value) {
put(name, DateTimes.isoInstantFormat(value));
}
/**
* <p>set.</p>
*
* @param name a {@link java.lang.String} object.
* @param value a {@link java.lang.String} object.
*/
public void set(String name, String value) {
data.removeAll(name);
data.put(name, value);
}
/**
* <p>getInt.</p>
*
* @param name a {@link java.lang.String} object.
* @param defaultValue a int.
* @return a int.
*/
public int getInt(String name, int defaultValue) {
String s = get(name);
return NumberUtils.toInt(s, defaultValue);
}
/**
* <p>getLong.</p>
*
* @param name a {@link java.lang.String} object.
* @param defaultValue a long.
* @return a long.
*/
public long getLong(String name, long defaultValue) {
String s = get(name);
return NumberUtils.toLong(s, defaultValue);
}
/**
* <p>getBoolean.</p>
*
* @param name a {@link java.lang.String} object.
* @param defaultValue a {@link java.lang.Boolean} object.
* @return a boolean.
*/
public boolean getBoolean(String name, Boolean defaultValue) {
String s = get(name);
if (s == null) {
return defaultValue;
}
return Boolean.parseBoolean(s);
}
/**
* <p>getInstant.</p>
*
* @param name a {@link java.lang.String} object.
* @param defaultValue a {@link java.time.Instant} object.
* @return a {@link java.time.Instant} object.
*/
public Instant getInstant(String name, Instant defaultValue) {
return DateTimes.parseInstant(get(name), defaultValue);
}
/**
* Copy All key-value pairs from properties.
*
* @param properties properties to copy from
*/
public void putAll(Properties properties) {
Enumeration<?> names = properties.propertyNames();
while (names.hasMoreElements()) {
String name = (String) names.nextElement();
data.put(name, properties.getProperty(name));
}
}
/**
* <p>putAll.</p>
*
* @param metadata a {@link java.util.Map} object.
*/
public void putAll(Map<String, String> metadata) {
metadata.forEach((key, value) -> data.put(key, value));
}
/**
* Remove a data and all its associated values.
*
* @param name data name to remove
*/
public void removeAll(String name) {
data.removeAll(name);
}
/**
* Remove all mappings from data.
*/
public void clear() {
data.clear();
}
/** {@inheritDoc} */
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof MultiMetadata)) {
return false;
}
MultiMetadata other;
try {
other = (MultiMetadata) o;
} catch (ClassCastException e) {
return false;
}
return data.equals(other.data);
}
/** {@inheritDoc} */
@Override
public String toString() {
StringBuilder buf = new StringBuilder();
for (String name : data.keySet()) {
List<String> values = Lists.newArrayList(data.get(name));
buf.append(name).append("=").append(StringUtils.join(values, ",")).append(StringUtils.SPACE);
}
return buf.toString();
}
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-persist/3.0.15/ai/platon/pulsar/persist
|
java-sources/ai/platon/pulsar/pulsar-persist/3.0.15/ai/platon/pulsar/persist/metadata/Name.java
|
package ai.platon.pulsar.persist.metadata;
/**
* Created by vincent on 17-3-19.
* Copyright @ 2013-2023 Platon AI. All rights reserved
* <p>
* All valid Metadata names are listed here.
* A metadata field can be moved to be a WebPage field if it's stable
*
* @author vincent
* @version $Id: $Id
*/
public enum Name {
UNKNOWN(""),
/**
* fetch
*/
HREF("F_HREF"),
LOCATION("F_LOCATION"),
FETCH_MODE("F_MD"),
FETCH_TIME_HISTORY("F_FTH"),
FETCH_MAX_RETRY("F_MR"),
RESPONSE_TIME("F_RT"),
FORCE_FOLLOW("PFF"),
REPARSE_LINKS("PRL"),
PARSE_NO_LINK_FILTER("PNF"),
PARSE_LINK_FILTER_DEBUG_LEVEL("PLFDL"),
TOTAL_OUT_LINKS("PTOL"),
ORIGINAL_CONTENT_LENGTH("POCL"),
/**
* export
*/
ORIGINAL_EXPORT_PATH("S_OEP");
private final String text;
Name(String name) {
this.text = name;
}
/**
* <p>text.</p>
*
* @return a {@link java.lang.String} object.
*/
public String text() {
return this.text;
}
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-persist/3.0.15/ai/platon/pulsar/persist
|
java-sources/ai/platon/pulsar/pulsar-persist/3.0.15/ai/platon/pulsar/persist/metadata/PageCategory.java
|
package ai.platon.pulsar.persist.metadata;
import org.apache.commons.lang3.StringUtils;
/**
* Predefined page category enumeration
*/
public enum PageCategory {
INDEX, DETAIL, OFFER_LIST, SELLER, REVIEW, PROFILE, SEARCH, MEDIA, BBS, TIEBA, BLOG, UNKNOWN;
public boolean is(PageCategory pageCategory) {
return pageCategory == this;
}
public boolean isIndex() {
return this == INDEX;
}
public boolean isDetail() {
return this == DETAIL;
}
public boolean isOfferList() {
return this == OFFER_LIST;
}
public boolean isSeller() {
return this == SELLER;
}
public boolean isReview() {
return this == REVIEW;
}
public boolean isProfile() {
return this == PROFILE;
}
public boolean isSearch() {
return this == SEARCH;
}
public boolean isMedia() {
return this == MEDIA;
}
public boolean isBBS() {
return this == BBS;
}
public boolean isTieBa() {
return this == TIEBA;
}
public boolean isBlog() {
return this == BLOG;
}
public boolean isUnknown() {
return this == UNKNOWN;
}
public String symbol() {
String n = "U";
if (this == INDEX) return "I";
else if (this == DETAIL) return "D";
else if (this == REVIEW) return "R";
else if (this == SELLER) return "SL";
else if (this == PROFILE) return "P";
else if (this == SEARCH) return "S";
else if (this == MEDIA) return "M";
else if (this == BBS) return "B";
else if (this == TIEBA) return "T";
else if (this == BLOG) return "G";
else if (this == UNKNOWN) return "U";
return n;
}
public String format() {
return name() + " " + symbol();
}
@Override
public String toString() {
return name();
}
/**
* Parse a string to a PageCategory object, format() and this method are symmetric.
* */
public static PageCategory parse(String category) {
try {
return PageCategory.valueOf(StringUtils.substringBefore(category.toUpperCase(), " "));
} catch (Throwable e) {
return PageCategory.UNKNOWN;
}
}
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-persist/3.0.15/ai/platon/pulsar/persist
|
java-sources/ai/platon/pulsar/pulsar-persist/3.0.15/ai/platon/pulsar/persist/metadata/ParseStatusCodes.java
|
package ai.platon.pulsar.persist.metadata;
public interface ParseStatusCodes {
// Primary status codes:
/**
* Parsing was not performed.
*/
short NOTPARSED = 0;
/**
* Parsing succeeded.
*/
short SUCCESS = 1;
/**
* General failure. There may be a more specific error message in arguments.
*/
short FAILED = 2;
// Use different type for primary codes and secondary codes to make less errors
// Secondary success codes:
int SC_OK = 0;
int SUCCESS_IGNORE = 1;
int SUCCESS_EXT = 2;
/**
* Parsed content contains a directive to redirect to another URL. The target
* URL can be retrieved from the arguments.
*/
int SUCCESS_REDIRECT = 100;
/**
* Parsing success. The page is not allowed to index
*/
int SUCCESS_NO_INDEX = 101;
// Secondary failure codes go here:
/**
* Parsing failed. An Exception occured (which may be retrieved from the
* arguments).
*/
int FAILED_EXCEPTION = 200;
/**
* Parsing failed. The reason is unknown or not specified.
*/
int FAILED_NOT_SPECIFIED = 201;
/**
* Parsing failed. Content was truncated, but the parser cannot handle
* incomplete content.
*/
int FAILED_TRUNCATED = 202;
/**
* Parsing failed. Invalid format - the content may be corrupted or of wrong
* type.
*/
int FAILED_INVALID_FORMAT = 203;
/**
* Parsing failed. Other related parts of the content are needed to halt
* parsing. The list of URLs to missing parts may be provided in arguments.
*/
int FAILED_MISSING_PARTS = 204;
/**
* Parsing failed. There was no content to be parsed - probably caused by
* errors at protocol stage.
*/
int FAILED_MISSING_CONTENT = 205;
/**
* Parsing failed. No responsible parser found
*/
int FAILED_NO_PARSER = 206;
/**
* Parsing failed. No responsible parser found
*/
int FAILED_MALFORMED_URL = 207;
/**
* Parsing failed. No responsible parser found
*/
int FAILED_UNKNOWN_ENCODING = 208;
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-ql-common/3.0.15/ai/platon/pulsar/ql
|
java-sources/ai/platon/pulsar/pulsar-ql-common/3.0.15/ai/platon/pulsar/ql/common/H2Config.java
|
package ai.platon.pulsar.ql.common;
import org.h2.engine.SysProperties;
import org.h2.util.JdbcUtils;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* Custom H2 config, must be called on both server and client side
* */
public class H2Config {
private static final AtomicBoolean configured = new AtomicBoolean();
public static void config() {
if (configured.getAndSet(true)) {
return;
}
// From java doc:
// "On the client side, this setting is required to be disabled"
SysProperties.serializeJavaObject = false;
JdbcUtils.serializer = new PulsarObjectSerializer();
String dataTypeHandler = System.getProperty("h2.customDataTypesHandler");
if (dataTypeHandler == null) {
JdbcUtils.customDataTypesHandler = new PulsarDataTypesHandler();
}
}
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-ql-common/3.0.15/ai/platon/pulsar/ql
|
java-sources/ai/platon/pulsar/pulsar-ql-common/3.0.15/ai/platon/pulsar/ql/common/PulsarDataTypesHandler.java
|
package ai.platon.pulsar.ql.common;
import ai.platon.pulsar.ql.common.types.ValueDom;
import ai.platon.pulsar.ql.common.types.ValueStringJSON;
import ai.platon.pulsar.ql.common.types.ValueURI;
import org.h2.api.CustomDataTypesHandler;
import org.h2.api.ErrorCode;
import org.h2.message.DbException;
import org.h2.store.DataHandler;
import org.h2.value.*;
import org.jsoup.nodes.Element;
import java.sql.Types;
import java.util.ArrayList;
import java.util.HashMap;
public class PulsarDataTypesHandler implements CustomDataTypesHandler {
public final static String DOM_DATA_TYPE_NAME = "DOM";
public final static int DOM_DATA_TYPE_ID = 1010;
public final static int DOM_DATA_TYPE_ORDER = 100_010;
public final static String URI_DATA_TYPE_NAME = "URI";
public final static int URI_DATA_TYPE_ID = 1011;
public final static int URI_DATA_TYPE_ORDER = 100_011;
public final static String STRING_JSON_DATA_TYPE_NAME = "STRING_JSON";
public final static int STRING_JSON_DATA_TYPE_ID = 1021;
public final static int STRING_JSON_DATA_TYPE_ORDER = 100_021;
/**
* The list of types. An ArrayList so that Tomcat doesn't set it to null
* when clearing references.
*/
private static final ArrayList<DataType> TYPES = new ArrayList<>();
private static final HashMap<String, DataType> TYPES_BY_NAME = new HashMap<>();
private static final HashMap<Integer, DataType> TYPES_BY_VALUE_TYPE = new HashMap<>();
/** */
public PulsarDataTypesHandler() {
createDomDataType();
createURIDataType();
createStringJSONDataType();
}
/** Constructs data type instance for complex number type */
private static void createDomDataType() {
DataType dt = new DataType();
dt.type = DOM_DATA_TYPE_ID;
dt.name = DOM_DATA_TYPE_NAME;
dt.sqlType = Types.JAVA_OBJECT;
register(dt);
}
/** Constructs data type instance for complex number type */
private static void createURIDataType() {
DataType dt = new DataType();
dt.type = URI_DATA_TYPE_ID;
dt.name = URI_DATA_TYPE_NAME;
dt.sqlType = Types.JAVA_OBJECT;
register(dt);
}
/** Constructs data type instance for complex number type */
private static void createStringJSONDataType() {
DataType dt = new DataType();
dt.type = STRING_JSON_DATA_TYPE_ID;
dt.name = STRING_JSON_DATA_TYPE_NAME;
dt.sqlType = Types.JAVA_OBJECT;
register(dt);
}
private static void register(DataType dt) {
TYPES.add(dt);
TYPES_BY_NAME.put(dt.name, dt);
TYPES_BY_VALUE_TYPE.put(dt.type, dt);
}
@Override
public DataType getDataTypeByName(String name) {
return TYPES_BY_NAME.get(name);
}
@Override
public DataType getDataTypeById(int type) {
return TYPES_BY_VALUE_TYPE.get(type);
}
@Override
public String getDataTypeClassName(int type) {
if (type == DOM_DATA_TYPE_ID) {
return ValueDom.class.getName();
} else if (type == URI_DATA_TYPE_ID) {
return ValueURI.class.getName();
} else if (type == STRING_JSON_DATA_TYPE_ID) {
return ValueStringJSON.class.getName();
}
throw DbException.throwInternalError("type="+type);
}
@Override
public int getTypeIdFromClass(Class<?> x) {
if (ValueDom.class.isAssignableFrom(x)) {
return DOM_DATA_TYPE_ID;
} else if (ValueURI.class.isAssignableFrom(x)) {
return URI_DATA_TYPE_ID;
} else if (ValueStringJSON.class.isAssignableFrom(x)) {
return STRING_JSON_DATA_TYPE_ID;
}
return Value.JAVA_OBJECT;
}
@Override
public Value convert(Value source, final int targetType) {
if (source.getType() == targetType) {
return source;
}
if (targetType == DOM_DATA_TYPE_ID) {
return switch (source.getType()) {
case Value.JAVA_OBJECT -> {
assert source instanceof ValueJavaObject;
yield ValueDom.get(new String(source.getBytesNoCopy()));
}
case Value.STRING -> {
assert source instanceof ValueString;
yield ValueDom.get(source.getString());
}
case Value.BYTES -> {
assert source instanceof ValueBytes;
yield ValueDom.get(new String(source.getBytesNoCopy()));
}
default -> throw DbException.get(ErrorCode.DATA_CONVERSION_ERROR_1, source.getString());
};
} else if (targetType == URI_DATA_TYPE_ID) {
return switch (source.getType()) {
case Value.JAVA_OBJECT -> {
assert source instanceof ValueJavaObject;
yield ValueURI.get(new String(source.getBytesNoCopy()));
}
case Value.STRING -> {
assert source instanceof ValueString;
yield ValueURI.get(source.getString());
}
case Value.BYTES -> {
assert source instanceof ValueBytes;
yield ValueURI.get(new String(source.getBytesNoCopy()));
}
default -> throw DbException.get(ErrorCode.DATA_CONVERSION_ERROR_1, source.getString());
};
} else if (targetType == STRING_JSON_DATA_TYPE_ID) {
return switch (source.getType()) {
case Value.JAVA_OBJECT -> {
assert source instanceof ValueJavaObject;
yield ValueStringJSON.get(new String(source.getBytesNoCopy()));
}
case Value.STRING -> {
assert source instanceof ValueString;
yield ValueStringJSON.get(source.getString());
}
case Value.BYTES -> {
assert source instanceof ValueBytes;
yield ValueStringJSON.get(new String(source.getBytesNoCopy()));
}
default -> throw DbException.get(ErrorCode.DATA_CONVERSION_ERROR_1, source.getString());
};
} else {
return source.convertTo(targetType);
}
}
@Override
public int getDataTypeOrder(int type) {
if (type == DOM_DATA_TYPE_ID) {
return DOM_DATA_TYPE_ORDER;
} else if (type == URI_DATA_TYPE_ID) {
return URI_DATA_TYPE_ORDER;
} else if (type == STRING_JSON_DATA_TYPE_ID) {
return STRING_JSON_DATA_TYPE_ORDER;
}
throw DbException.get(ErrorCode.UNKNOWN_DATA_TYPE_1, "type:" + type);
}
@Override
public Value getValue(int type, Object data, DataHandler dataHandler) {
if (type == DOM_DATA_TYPE_ID) {
assert data instanceof Element;
return ValueDom.get((Element) data);
} else if (type == URI_DATA_TYPE_ID) {
assert data instanceof String;
return ValueURI.get((String) data);
} else if (type == STRING_JSON_DATA_TYPE_ID) {
assert data instanceof String;
return ValueStringJSON.get((String) data);
}
return ValueJavaObject.getNoCopy(data, null, dataHandler);
}
@Override
public Object getObject(Value value, Class<?> cls) {
if (cls.equals(ValueDom.class)) {
if (value.getType() == DOM_DATA_TYPE_ID) {
return value.getObject();
}
return convert(value, DOM_DATA_TYPE_ID).getObject();
} else if (cls.equals(ValueURI.class)) {
if (value.getType() == URI_DATA_TYPE_ID) {
return value.getObject();
}
return convert(value, URI_DATA_TYPE_ID).getObject();
} else if (cls.equals(ValueStringJSON.class)) {
if (value.getType() == STRING_JSON_DATA_TYPE_ID) {
return value.getObject();
}
return convert(value, STRING_JSON_DATA_TYPE_ID).getObject();
}
throw DbException.get(ErrorCode.UNKNOWN_DATA_TYPE_1, "type:" + value.getType());
}
@Override
public boolean supportsAdd(int type) {
if (type == DOM_DATA_TYPE_ID) {
return false;
} else if (type == Value.UNKNOWN) {
return false;
}
return false;
}
@Override
public int getAddProofType(int type) {
if (type == DOM_DATA_TYPE_ID) {
return type;
}
throw DbException.get(ErrorCode.UNKNOWN_DATA_TYPE_1, "type:" + type);
}
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-ql-common/3.0.15/ai/platon/pulsar/ql
|
java-sources/ai/platon/pulsar/pulsar-ql-common/3.0.15/ai/platon/pulsar/ql/common/PulsarObjectSerializer.java
|
package ai.platon.pulsar.ql.common;
import ai.platon.pulsar.ql.common.io.ValueDomWritable;
import ai.platon.pulsar.ql.common.types.ValueDom;
import ai.platon.pulsar.ql.common.types.ValueStringJSON;
import org.apache.hadoop.io.DataInputBuffer;
import org.apache.hadoop.io.DataOutputBuffer;
import org.h2.api.ErrorCode;
import org.h2.api.JavaObjectSerializer;
import org.h2.message.DbException;
public class PulsarObjectSerializer implements JavaObjectSerializer {
@Override
public byte[] serialize(Object obj) throws Exception {
if (obj instanceof org.jsoup.nodes.Element ele) {
obj = ValueDom.get(ele);
}
if (obj instanceof ValueDom dom) {
try(DataOutputBuffer buffer = new DataOutputBuffer(1024)) {
buffer.writeInt(ValueDom.type);
new ValueDomWritable(dom).write(buffer);
return buffer.getData();
}
} if (obj instanceof ValueStringJSON json) {
try(DataOutputBuffer buffer = new DataOutputBuffer(1024)) {
buffer.writeInt(ValueStringJSON.type);
buffer.writeUTF(json.getString());
buffer.writeUTF(json.getTargetClassName());
return buffer.getData();
}
} else {
throw DbException.get(ErrorCode.SERIALIZATION_FAILED_1);
}
}
@Override
public Object deserialize(byte[] bytes) throws Exception {
DataInputBuffer in = new DataInputBuffer();
in.reset(bytes, bytes.length);
int type = in.readInt();
if (type == ValueDom.type) {
ValueDomWritable writable = new ValueDomWritable();
writable.readFields(in);
return writable.get();
} if (type == ValueStringJSON.type) {
String jsonText = in.readUTF();
String className = in.readUTF();
return ValueStringJSON.get(jsonText, className);
} else {
throw DbException.get(ErrorCode.DESERIALIZATION_FAILED_1, "Unknown custom type #" + type);
}
}
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-ql-common/3.0.15/ai/platon/pulsar/ql
|
java-sources/ai/platon/pulsar/pulsar-ql-common/3.0.15/ai/platon/pulsar/ql/common/ResultSets.java
|
package ai.platon.pulsar.ql.common;
import org.h2.tools.SimpleResultSet;
import org.h2.value.DataType;
import org.h2.value.Value;
import java.sql.ResultSet;
public class ResultSets {
public static void addColumn(SimpleResultSet rs, String name) {
rs.addColumn(name, DataType.convertTypeToSQLType(Value.STRING), 0, 0);
}
public static void addColumns(SimpleResultSet rs, String... names) {
for (String name : names) {
rs.addColumn(name, DataType.convertTypeToSQLType(Value.STRING), 0, 0);
}
}
public static void addColumns(SimpleResultSet rs, Iterable<String> names) {
for (String name : names) {
rs.addColumn(name, DataType.convertTypeToSQLType(Value.STRING), 0, 0);
}
}
public static ResultSet newResultSet() {
SimpleResultSet rs = new SimpleResultSet();
rs.setAutoClose(false);
return rs;
}
public static SimpleResultSet newSimpleResultSet() {
SimpleResultSet rs = new SimpleResultSet();
rs.setAutoClose(false);
return rs;
}
public static SimpleResultSet newSimpleResultSet(Iterable<String> names) {
SimpleResultSet rs = newSimpleResultSet();
rs.setAutoClose(false);
addColumns(rs, names);
return rs;
}
public static SimpleResultSet newSimpleResultSet(String... names) {
SimpleResultSet rs = newSimpleResultSet();
rs.setAutoClose(false);
addColumns(rs, names);
return rs;
}
public static SimpleResultSet newSimpleResultSet(int columnCount) {
SimpleResultSet rs = newSimpleResultSet();
rs.setAutoClose(false);
for (int i = 0; i < columnCount; i++) {
addColumns(rs, "C" + (i + 1));
}
return rs;
}
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-ql-common/3.0.15/ai/platon/pulsar/ql/common
|
java-sources/ai/platon/pulsar/pulsar-ql-common/3.0.15/ai/platon/pulsar/ql/common/annotation/H2Context.java
|
package ai.platon.pulsar.ql.common.annotation;
import javax.annotation.meta.TypeQualifier;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Documented
@TypeQualifier
@Retention(RetentionPolicy.RUNTIME)
public @interface H2Context {
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-ql-common/3.0.15/ai/platon/pulsar/ql/common
|
java-sources/ai/platon/pulsar/pulsar-ql-common/3.0.15/ai/platon/pulsar/ql/common/annotation/UDAggregation.java
|
package ai.platon.pulsar.ql.common.annotation;
import javax.annotation.meta.TypeQualifier;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Documented
@TypeQualifier
@Retention(RetentionPolicy.RUNTIME)
public @interface UDAggregation {
String name();
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-ql-common/3.0.15/ai/platon/pulsar/ql/common
|
java-sources/ai/platon/pulsar/pulsar-ql-common/3.0.15/ai/platon/pulsar/ql/common/annotation/UDFContext.java
|
package ai.platon.pulsar.ql.common.annotation;
import javax.annotation.meta.TypeQualifier;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Documented
@TypeQualifier
@Retention(RetentionPolicy.RUNTIME)
public @interface UDFContext {
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-ql-common/3.0.15/ai/platon/pulsar/ql/common
|
java-sources/ai/platon/pulsar/pulsar-ql-common/3.0.15/ai/platon/pulsar/ql/common/annotation/UDFGroup.java
|
package ai.platon.pulsar.ql.common.annotation;
import javax.annotation.meta.TypeQualifier;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Documented
@TypeQualifier
@Retention(RetentionPolicy.RUNTIME)
public @interface UDFGroup {
String namespace() default "";
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-ql-common/3.0.15/ai/platon/pulsar/ql/common
|
java-sources/ai/platon/pulsar/pulsar-ql-common/3.0.15/ai/platon/pulsar/ql/common/annotation/UDFunction.java
|
package ai.platon.pulsar.ql.common.annotation;
import javax.annotation.meta.TypeQualifier;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Documented
@TypeQualifier
@Retention(RetentionPolicy.RUNTIME)
public @interface UDFunction {
boolean nobuffer() default true;
boolean deterministic() default false;
/**
* If a function has a shortcut, the namespace can be avoid
* */
boolean hasShortcut() default false;
String description() default "";
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-ql-common/3.0.15/ai/platon/pulsar/ql/common
|
java-sources/ai/platon/pulsar/pulsar-ql-common/3.0.15/ai/platon/pulsar/ql/common/io/ValueDomWritable.java
|
package ai.platon.pulsar.ql.common.io;
import ai.platon.pulsar.common.concurrent.ConcurrentLRUCache;
import ai.platon.pulsar.common.io.Writable;
import ai.platon.pulsar.dom.Documents;
import ai.platon.pulsar.dom.FeaturedDocument;
import ai.platon.pulsar.ql.common.types.ValueDom;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.time.Duration;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class ValueDomWritable implements Writable {
public static int CACHE_SIZE = 200;
private static FeaturedDocument NIL_DOC = FeaturedDocument.Companion.getNIL();
private static String NIL_DOC_HTML = FeaturedDocument.Companion.getNIL_DOC_HTML();
private static int NIL_DOC_LENGTH = FeaturedDocument.Companion.getNIL_DOC_LENGTH();
private static Duration CACHE_EXPIRES = Duration.ofMinutes(10);
private static String CACHED_HINT = "(cached)";
// server side
// TODO: check if this is client side or server side, ensure items in client side lives longer than that in server side
private static ConcurrentLRUCache<String, String> pageCache = new ConcurrentLRUCache<>(CACHE_EXPIRES, CACHE_SIZE);
// client side
private static Map<String, FeaturedDocument> documentCache = new ConcurrentHashMap<>();
private ValueDom dom;
public ValueDomWritable() {
}
public ValueDomWritable(ValueDom dom) {
this.dom = dom;
}
public ValueDom get() {
return dom;
}
@Override
public void write(DataOutput out) throws IOException {
Element ele = dom.getElement();
Document doc = ele.ownerDocument();
String baseUri = doc.baseUri();
out.writeBytes(doc.baseUri());
out.write('\n'); // make a line
out.writeBytes(ele.cssSelector());
out.write('\n'); // make a line
String html = pageCache.get(baseUri);
if (html != null && !html.isEmpty()) {
// tell the client it's cached
html = CACHED_HINT;
} else {
// not cached, cache it
html = doc.outerHtml();
pageCache.put(baseUri, html);
}
out.writeInt(html.length());
out.write(html.getBytes());
}
/**
* TODO: The local cache might not sync with the server side which lead to no data in client side, we need a better solution
*/
@Override
public void readFields(DataInput in) throws IOException {
String baseUri = in.readLine();
String selector = in.readLine();
int htmlLen = in.readInt();
String html;
FeaturedDocument doc;
if (htmlLen == CACHED_HINT.length()) {
// cached
doc = documentCache.get(baseUri);
in.skipBytes(htmlLen);
} else {
// not cached
byte[] bytes = new byte[htmlLen];
in.readFully(bytes);
html = new String(bytes);
doc = Documents.INSTANCE.parse(html, baseUri);
documentCache.put(baseUri, doc);
}
if (doc == null) {
doc = NIL_DOC;
}
Element ele;
if (selector.equals("#root")) {
ele = doc.unbox();
} else {
ele = doc.selectFirst(selector);
}
dom = ValueDom.get(ele);
}
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-ql-common/3.0.15/ai/platon/pulsar/ql/common
|
java-sources/ai/platon/pulsar/pulsar-ql-common/3.0.15/ai/platon/pulsar/ql/common/types/ValueDom.java
|
/*
* Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package ai.platon.pulsar.ql.common.types;
import ai.platon.pulsar.dom.FeaturedDocument;
import ai.platon.pulsar.dom.nodes.node.ext.NodeExtKt;
import ai.platon.pulsar.ql.common.PulsarDataTypesHandler;
import org.h2.api.ErrorCode;
import org.h2.message.DbException;
import org.h2.util.JdbcUtils;
import org.h2.util.StringUtils;
import org.h2.value.*;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Types;
import java.util.Objects;
/**
* Implementation of the DOM data type.
*/
public class ValueDom extends Value implements Comparable<ValueDom> {
public static final Document NIL_DOC = FeaturedDocument.Companion.getNIL().getDocument();
public static final ValueDom NIL = new ValueDom(NIL_DOC);
public static int type = PulsarDataTypesHandler.DOM_DATA_TYPE_ID;
private final Document document;
private final Element element;
private String outerHtml = null;
private ValueDom(Element element) {
Objects.requireNonNull(element);
this.document = element.ownerDocument();
this.element = element;
}
public Document getDocument() {
return document;
}
public Element getElement() {
return element;
}
public String globalId() {
return NodeExtKt.getGlobalId(element);
}
public boolean isNil() {
return this == NIL;
}
public boolean isNotNil() {
return this != NIL;
}
public boolean isDocument() {
return element == document;
}
/**
* TODO: might use lot of memory so memory should be managed
* */
public String getOuterHtml() {
// TODO: document scope cache
if (outerHtml == null) outerHtml = element.outerHtml();
return outerHtml;
}
/**
* Create a result set value for the given result set.
* The result set will be wrapped.
*
* @param element the Element
* @return the value
*/
public static ValueDom get(Element element) {
Objects.requireNonNull(element);
if (element instanceof Document) {
Document doc = (Document) element;
String baseUri = doc.baseUri();
if (!baseUri.isEmpty()) {
doc.body().attr("baseUri", baseUri);
} else {
baseUri = doc.body().attr("baseUri");
doc.setBaseUri(baseUri);
}
}
return new ValueDom(element);
}
public static ValueDom get(FeaturedDocument doc) {
return get(doc.unbox());
}
public static ValueDom getOrNil(Element element) {
return element == null ? NIL : get(element);
}
public static ValueDom get(String html) {
Objects.requireNonNull(html);
return get(Jsoup.parse(html));
}
@Override
public Value convertTo(int targetType) {
if (getType() == targetType) {
return this;
}
if (targetType == Value.STRING) {
return ValueString.get(getString());
} else if (targetType == Value.BYTES) {
return ValueBytes.get(getBytesNoCopy());
} else if (targetType == Value.JAVA_OBJECT) {
System.err.println("Convert ValueDom to ValueJavaObject");
return ValueJavaObject.getNoCopy(null, getBytesNoCopy(), getDataHandler());
}
throw DbException.get(ErrorCode.DATA_CONVERSION_ERROR_1, getString());
}
@Override
public int getType() {
return type;
}
@Override
public long getPrecision() {
return 128;
}
@Override
public int getDisplaySize() {
return 128;
}
@Override
public int getMemory() {
return getDisplaySize() * 2 + 48;
}
@Override
public String getString() {
return toString();
}
/**
* TODO: performance
* When to use compareSecure?
* */
@Override
protected int compareSecure(Value o, CompareMode mode) {
ValueDom v = (ValueDom) o;
return mode.compareString(getOuterHtml(), v.getOuterHtml(), false);
}
/**
* TODO: We might have a better Element.equals implementation
* */
@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}
if (!(other instanceof ValueDom)) {
return false;
}
ValueDom dom = (ValueDom) other;
return globalId().equals(dom.globalId());
}
@Override
public Object getObject() {
return element;
}
@Override
public void set(PreparedStatement prep, int parameterIndex) throws SQLException {
Object obj = JdbcUtils.deserialize(getBytesNoCopy(), getDataHandler());
prep.setObject(parameterIndex, obj, Types.JAVA_OBJECT);
}
@Override
public String getSQL() {
return "X'" + StringUtils.convertBytesToHex(getBytesNoCopy()) + "'::Dom";
}
@Override
public byte[] getBytes() {
return getOuterHtml().getBytes();
}
/**
* Used by ValueDataType.writeValue for serialization
* */
@Override
public byte[] getBytesNoCopy() {
return getOuterHtml().getBytes();
}
@Override
public int hashCode() {
return globalId().hashCode();
}
@Override
public String toString() {
if (element != null) {
if (isNotNil()) {
return NodeExtKt.getName(element);
} else {
return "(nil)";
}
}
return "(dom)";
}
@Override
public int compareTo(ValueDom o) {
return globalId().compareTo(o.globalId());
}
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-ql-common/3.0.15/ai/platon/pulsar/ql/common
|
java-sources/ai/platon/pulsar/pulsar-ql-common/3.0.15/ai/platon/pulsar/ql/common/types/ValueStringJSON.java
|
/*
* Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package ai.platon.pulsar.ql.common.types;
import ai.platon.pulsar.ql.common.PulsarDataTypesHandler;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.h2.api.ErrorCode;
import org.h2.message.DbException;
import org.h2.util.JdbcUtils;
import org.h2.util.StringUtils;
import org.h2.value.*;
import org.jetbrains.annotations.NotNull;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Types;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public class ValueStringJSON extends Value implements Comparable<ValueStringJSON> {
public static int type = PulsarDataTypesHandler.STRING_JSON_DATA_TYPE_ID;
public static ValueStringJSON get(String jsonText) {
Objects.requireNonNull(jsonText);
return new ValueStringJSON(jsonText);
}
public static ValueStringJSON get(String jsonText, String className) {
Objects.requireNonNull(jsonText);
Objects.requireNonNull(className);
return new ValueStringJSON(jsonText, className);
}
public static ValueStringJSON get(byte[] jsonText) {
Objects.requireNonNull(jsonText);
return new ValueStringJSON(new String(jsonText));
}
private String value;
private String className = Object.class.getName();
public ValueStringJSON(String value) {
this.value = value;
}
public ValueStringJSON(String value, String className) {
this.value = value;
this.className = className;
}
public String getTargetClassName() {
return className;
}
@Override
public Value convertTo(int targetType) {
if (getType() == targetType) {
return this;
}
if (targetType == Value.STRING) {
return ValueString.get(getString());
} else if (targetType == Value.BYTES) {
return ValueBytes.get(getBytesNoCopy());
} else if (targetType == Value.JAVA_OBJECT) {
if (Objects.equals(className, Map.class.getName())) {
try {
ObjectMapper mapper = new ObjectMapper();
Map<?, ?> obj = mapper.readValue(value, Map.class);
return ValueJavaObject.getNoCopy(obj, getBytesNoCopy(), getDataHandler());
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
return ValueJavaObject.getNoCopy(null, getBytesNoCopy(), getDataHandler());
}
throw DbException.get(ErrorCode.DATA_CONVERSION_ERROR_1, getString());
}
@Override
public int getType() {
return type;
}
@Override
public long getPrecision() {
return 0;
}
@Override
public int getDisplaySize() {
return value.length();
}
@Override
public String getString() {
return value;
}
@Override
public Object getObject() {
ObjectMapper mapper = new ObjectMapper();
try {
if (Objects.equals(className, Map.class.getName())) {
return mapper.readValue(value, Map.class);
}
else if (Objects.equals(className, "kotlin.collections.Map")) {
return mapper.readValue(value, Map.class);
}
else if (Objects.equals(className, List.class.getName())) {
return mapper.readValue(value, List.class);
}
else if (Objects.equals(className, "kotlin.collections.List")) {
return mapper.readValue(value, List.class);
}
else {
return mapper.readTree(value);
}
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
@Override
public void set(PreparedStatement prep, int parameterIndex) throws SQLException {
Object obj = JdbcUtils.deserialize(getBytesNoCopy(), getDataHandler());
prep.setObject(parameterIndex, obj, Types.JAVA_OBJECT);
}
@Override
protected int compareSecure(Value value, CompareMode compareMode) {
return this == value ? 0 : super.toString().compareTo(value.toString());
}
@Override
public int hashCode() {
return value.hashCode();
}
@Override
public boolean equals(Object o) {
return o instanceof ValueStringJSON && value.equals(o.toString());
}
@Override
public String getSQL() {
return "X'" + StringUtils.convertBytesToHex(getBytesNoCopy()) + "'::JSON";
}
@Override
public int compareTo(@NotNull ValueStringJSON o) {
return getString().compareTo(o.getString());
}
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-ql-common/3.0.15/ai/platon/pulsar/ql/common
|
java-sources/ai/platon/pulsar/pulsar-ql-common/3.0.15/ai/platon/pulsar/ql/common/types/ValueURI.java
|
/*
* Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package ai.platon.pulsar.ql.common.types;
import ai.platon.pulsar.ql.common.PulsarDataTypesHandler;
import org.h2.util.StringUtils;
import org.h2.value.CompareMode;
import org.h2.value.Value;
import java.net.URI;
import java.sql.PreparedStatement;
/**
* Implementation of the URI data type.
*/
public class ValueURI extends Value {
public static int type = PulsarDataTypesHandler.URI_DATA_TYPE_ID;
private final URI uri;
private ValueURI(URI uri) {
this.uri = uri;
}
public URI getURI() {
return uri;
}
/**
* Create a result set value for the given result set.
* The result set will be wrapped.
*
* @param uri the URI
* @return the value
*/
public static ValueURI get(URI uri) {
ValueURI val = new ValueURI(uri);
return val;
}
public static ValueURI get(String s) {
return ValueURI.get(URI.create(s));
}
public static ValueURI get(byte[] s) {
return ValueURI.get(URI.create(new String(s)));
}
@Override
public int getType() {
return type;
}
@Override
public long getPrecision() {
return 0;
}
@Override
public int getDisplaySize() {
// it doesn't make sense to calculate it
return uri.toString().length();
}
@Override
public String getString() {
return uri.toString();
}
@Override
protected int compareSecure(Value v, CompareMode mode) {
return this == v ? 0 : super.toString().compareTo(v.toString());
}
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
return other instanceof ValueURI && ((ValueURI) other).uri.equals(this.uri);
}
@Override
public int hashCode() {
return uri.hashCode();
}
@Override
public Object getObject() {
return uri;
}
@Override
public void set(PreparedStatement prep, int parameterIndex) {
throw throwUnsupportedExceptionForType("ValueURI.set");
}
@Override
public String getSQL() {
return "X'" + StringUtils.convertBytesToHex(getBytesNoCopy()) + "'::URI";
}
@Override
public byte[] getBytes() {
return uri.toString().getBytes();
}
/**
* Used by ValueDataType.writeValue for serialization
* */
@Override
public byte[] getBytesNoCopy() {
return uri.toString().getBytes();
}
@Override
public String toString() {
return uri.toString();
}
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-schedule/3.0.15/ai/platon/pulsar
|
java-sources/ai/platon/pulsar/pulsar-schedule/3.0.15/ai/platon/pulsar/schedule/package-info.java
|
package ai.platon.pulsar.schedule;
/*
* The pulsar-schedule plugin
* */
|
0
|
java-sources/ai/platon/pulsar/pulsar-scoring/3.0.15/ai/platon/pulsar
|
java-sources/ai/platon/pulsar/pulsar-scoring/3.0.15/ai/platon/pulsar/scoring/package-info.java
|
package ai.platon.pulsar.scoring;
/*
* The pulsar-scoring plugin
* */
|
0
|
java-sources/ai/platon/pulsar/pulsar-skeleton/3.0.15/ai/platon/pulsar/skeleton
|
java-sources/ai/platon/pulsar/pulsar-skeleton/3.0.15/ai/platon/pulsar/skeleton/common/EncodingDetector.java
|
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.platon.pulsar.skeleton.common;
import ai.platon.pulsar.common.HttpHeaders;
import ai.platon.pulsar.common.config.ImmutableConfig;
import ai.platon.pulsar.persist.WebPage;
import com.ibm.icu.text.CharsetDetector;
import com.ibm.icu.text.CharsetMatch;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.ByteArrayInputStream;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* A simple class for detecting character encodings.
* <p>
* <p>
* Broadly this encompasses two functions, which are distinctly separate:
* <p>
* <ol>
* <li>Auto detecting a set of "clues" from input text.</li>
* <li>Taking a set of clues and making a "best guess" as to the "real"
* encoding.</li>
* </ol>
* </p>
* <p>
* <p>
* A caller will often have some extra information about what the encoding might
* be (e.g. from the HTTP header or HTML meta-tags, often wrong but still
* potentially useful clues). The types of clues may differ from caller to
* caller. Thus a typical calling sequence is:
* <ul>
* <li>Run step (1) to generate a set of auto-detected clues;</li>
* <li>Combine these clues with the caller-dependent "extra clues" available;</li>
* <li>Run step (2) to guess what the most probable answer is.</li>
* </p>
* <p>
* TODO: Use Tika's EncodingDetector
*/
public class EncodingDetector {
public static final Logger LOG = LoggerFactory.getLogger(EncodingDetector.class);
public static final int NO_THRESHOLD = -1;
public static final String MIN_CONFIDENCE_KEY = "encodingdetector.charset.min.confidence";
// I used 1000 bytes at first, but found that some documents have
// meta tag well past the first 1000 bytes.
// (e.g. http://cn.promo.yahoo.com/customcare/music.html)
private static final int CHUNK_SIZE = 2000;
private static final HashMap<String, String> ALIASES = new HashMap<>();
private static final HashSet<String> DETECTABLES = new HashSet<>();
// CharsetDetector will die without a minimum amount of data.
private static final int MIN_LENGTH = 4;
// PULSAR-1006 Meta equiv with single quotes not accepted
private static Pattern metaPattern = Pattern.compile(
"<meta\\s+([^>]*http-equiv=(\"|')?content-type(\"|')?[^>]*)>",
Pattern.CASE_INSENSITIVE);
private static Pattern charsetPattern = Pattern.compile(
"charset=\\s*([a-z][_\\-0-9a-z]*)", Pattern.CASE_INSENSITIVE);
private static Pattern charsetPatternHTML5 = Pattern.compile(
"<meta\\s+charset\\s*=\\s*[\"']?([a-z][_\\-0-9a-z]*)[^>]*>",
Pattern.CASE_INSENSITIVE);
static {
DETECTABLES.add("text/html");
DETECTABLES.add("text/plain");
DETECTABLES.add("text/richtext");
DETECTABLES.add("text/rtf");
DETECTABLES.add("text/sgml");
DETECTABLES.add("text/tab-separated-values");
DETECTABLES.add("text/xml");
DETECTABLES.add("application/rss+xml");
DETECTABLES.add("application/xhtml+xml");
/*
* the following map is not an alias mapping table, but maps character
* encodings which are often used in mislabelled documents to their correct
* encodings. For instance, there are a lot of documents labelled
* 'ISO-8859-1' which contain characters not covered by ISO-8859-1 but
* covered by windows-1252. Because windows-1252 is a superset of ISO-8859-1
* (sharing code points for the common part), it's better to treat
* ISO-8859-1 as synonymous with windows-1252 than to reject, as invalid,
* documents labelled as ISO-8859-1 that have characters outside ISO-8859-1.
*/
ALIASES.put("ISO-8859-1", "windows-1252");
ALIASES.put("EUC-KR", "x-windows-949");
ALIASES.put("x-EUC-CN", "GB18030");
/**
* GB18030有两个版本:GB18030-2000和GB18030-2005,
* GB18030-2000是GBK的取代版本,它的主要特点是在GBK基础上增加了CJK统一汉字扩充A的汉字。
* GB18030-2005的主要特点是在GB18030-2000基础上增加了CJK统一汉字扩充B的汉字。
* @see http://www.fmddlmyy.cn/text24.html
* */
// ALIASES.put("GBK", "GB18030");
// ALIASES.put("Big5", "Big5HKSCS");
// ALIASES.put("TIS620", "Cp874");
// ALIASES.put("ISO-8859-11", "Cp874");
}
private final CharsetDetector detector = new CharsetDetector();
private final List<EncodingClue> clues = new ArrayList<>();
private int minConfidence = -1;
private String defaultCharEncoding = "utf-8";
public EncodingDetector() {
}
public EncodingDetector(ImmutableConfig conf) {
this.minConfidence = conf.getInt(MIN_CONFIDENCE_KEY, -1);
this.defaultCharEncoding = conf.get("parser.character.encoding.default", "utf-8");
}
public static String resolveEncodingAlias(String encoding) {
try {
if (encoding == null || !Charset.isSupported(encoding)) {
return null;
}
String canonicalName = Charset.forName(encoding).name();
String encodingAlias = ALIASES.getOrDefault(canonicalName, canonicalName);
return encodingAlias.toLowerCase();
} catch (Exception e) {
LOG.warn("Invalid encoding " + encoding + " detected, using default.");
return null;
}
}
/**
* ParseResult the character encoding from the specified content type header. If the
* content type is null, or there is no explicit character encoding,
* <code>null</code> is returned.
* This method was copied from org.apache.catalina.util.RequestUtil, which is
* licensed under the Apache License, Version 2.0 (the "License").
*
* @param contentTypeUtf8 utf8 encoded content
*/
public static String parseCharacterEncoding(CharSequence contentTypeUtf8) {
if (contentTypeUtf8 == null) {
return null;
}
String contentType = contentTypeUtf8.toString();
int start = contentType.indexOf("charset=");
if (start < 0) {
return null;
}
String encoding = contentType.substring(start + 8);
int end = encoding.indexOf(';');
if (end >= 0) {
encoding = encoding.substring(0, end);
}
encoding = encoding.trim();
if ((encoding.length() > 2) && (encoding.startsWith("\"")) && (encoding.endsWith("\""))) {
encoding = encoding.substring(1, encoding.length() - 1);
}
return encoding.trim();
}
public String getDefaultCharEncoding() {
return this.defaultCharEncoding;
}
public void setDefaultCharEncoding(String defaultCharEncoding) {
this.defaultCharEncoding = defaultCharEncoding;
}
public int getMinConfidence() {
return minConfidence;
}
public void setMinConfidence(int minConfidence) {
this.minConfidence = minConfidence;
}
public String sniffEncoding(WebPage page) {
String trustedEncoding = page.getHeaders().get(HttpHeaders.Q_TRUSTED_CONTENT_ENCODING);
if (trustedEncoding != null) {
return trustedEncoding;
}
clearClues();
autoDetectClues(page, true);
addClue(sniffCharacterEncoding(page.getContentAsBytes()), "sniffed");
return guessEncoding(page, defaultCharEncoding);
}
public List<EncodingClue> getClues() {
return clues;
}
public String getCluesAsString() {
return StringUtils.join(getClues(), ", ");
}
public void autoDetectClues(WebPage page, boolean filter) {
String contentType = page.getHeaders().get(HttpHeaders.CONTENT_TYPE);
autoDetectClues(page.getContent(), page.getContentType(),
parseCharacterEncoding(contentType), filter);
}
/**
* Given a <code>byte[]</code> representing an html file of an
* <em>unknown</em> encoding, read out 'charset' parameter in the meta tag
* from the first <code>CHUNK_SIZE</code> bytes. If there's no meta tag for
* Content-Type or no charset is specified, the content is checked for a
* Unicode Byte Order Mark (BOM). This will also cover non-byte oriented
* character encodings (UTF-16 only). If no character set can be determined,
* <code>null</code> is returned.
* See also
* http://www.w3.org/International/questions/qa-html-encoding-declarations,
* http://www.w3.org/TR/2011/WD-html5-diff-20110405/#character-encoding, and
* http://www.w3.org/TR/REC-xml/#sec-guessing
*
* @param content <code>byte[]</code> representation of an html file
*/
public String sniffCharacterEncoding(byte[] content) {
int length = content.length < CHUNK_SIZE ? content.length : CHUNK_SIZE;
// We don't care about non-ASCII parts so that it's sufficient
// to just inflate each byte to a 16-bit value by padding.
// For instance, the sequence {0x41, 0x82, 0xb7} will be turned into
// {U+0041, U+0082, U+00B7}.
String str = new String(content, 0, length, StandardCharsets.US_ASCII);
Matcher metaMatcher = metaPattern.matcher(str);
String encoding = null;
if (metaMatcher.find()) {
Matcher charsetMatcher = charsetPattern.matcher(metaMatcher.group(1));
if (charsetMatcher.find()) {
encoding = charsetMatcher.group(1);
if (LOG.isTraceEnabled()) {
LOG.trace("metaPattern: " + encoding);
}
}
}
if (encoding == null) {
// check for HTML5 meta charset
metaMatcher = charsetPatternHTML5.matcher(str);
if (metaMatcher.find()) {
encoding = metaMatcher.group(1);
if (LOG.isTraceEnabled()) {
LOG.trace("charsetPatternHTML5: " + encoding);
}
}
}
if (encoding == null) {
// check for BOM
if (content.length >= 3 && content[0] == (byte) 0xEF
&& content[1] == (byte) 0xBB && content[2] == (byte) 0xBF) {
encoding = "UTF-8";
} else if (content.length >= 2) {
if (content[0] == (byte) 0xFF && content[1] == (byte) 0xFE) {
encoding = "UTF-16LE";
} else if (content[0] == (byte) 0xFE && content[1] == (byte) 0xFF) {
encoding = "UTF-16BE";
}
}
if (LOG.isTraceEnabled()) {
LOG.trace("BOM: " + encoding);
}
}
return encoding;
}
protected void autoDetectClues(ByteBuffer dataBuffer, String contentType, String encoding, boolean filter) {
if (dataBuffer == null) {
return;
}
int length = dataBuffer.remaining();
if (minConfidence >= 0 && DETECTABLES.contains(contentType) && length > MIN_LENGTH) {
CharsetMatch[] matches = null;
// do all these in a try/catch; setText and detect/detectAll
// will sometimes throw exceptions
try {
detector.enableInputFilter(filter);
detector.setText(new ByteArrayInputStream(dataBuffer.array(),
dataBuffer.arrayOffset() + dataBuffer.position(), length));
matches = detector.detectAll();
} catch (Exception e) {
LOG.debug("Exception from ICU4J (ignoring): ", e);
}
if (matches != null) {
for (CharsetMatch match : matches) {
addClue(match.getName(), "detect", match.getConfidence());
}
}
}
// add character encoding coming from HTTP response header
addClue(encoding, "header");
}
protected void addClue(String value, String source, int confidence) {
if (value == null || value.isEmpty()) {
return;
}
value = resolveEncodingAlias(value);
if (value != null) {
clues.add(new EncodingClue(value, source, confidence));
// log.trace("addClue " + value + ", " + source + ", " + confidence);
}
}
public void addClue(String value, String source) {
addClue(value, source, NO_THRESHOLD);
}
/**
* Guess the encoding with the previously specified list of clues.
*
* @param page URL's row
* @param defaultValue Default encoding to return if no encoding can be detected with
* enough confidence. Note that this will <b>not</b> be normalized
* with {@link EncodingDetector#resolveEncodingAlias}
* @return Guessed encoding or defaultValue
*/
public String guessEncoding(WebPage page, String defaultValue) {
return guessEncoding(page.getLocation(), defaultValue);
}
/**
* Guess the encoding with the previously specified list of clues.
*
* @param baseUrl Base URL
* @param defaultValue Default encoding to return if no encoding can be detected with
* enough confidence. Note that this will <b>not</b> be normalized
* with {@link EncodingDetector#resolveEncodingAlias}
* @return Guessed encoding or defaultValue
*/
private String guessEncoding(String baseUrl, String defaultValue) {
/*
* This algorithm could be replaced by something more sophisticated; ideally
* we would gather a bunch of data on where various clues (autodetect, HTTP
* headers, HTML meta tags, etc.) disagree, tag each with the correct
* answer, and use machine learning/some statistical method to generate a
* better heuristic.
*/
if (LOG.isTraceEnabled()) {
findDisagreements(baseUrl, clues);
}
/*
* Go down the list of encoding "clues". Use a clue if:
* 1. Has a confidence value which meets our confidence threshold, OR
* 2. Doesn't meet the threshold, but is the best try, since nothing else is available.
*/
EncodingClue defaultClue = new EncodingClue(defaultValue, "default");
EncodingClue bestClue = defaultClue;
int i = 0;
for (EncodingClue clue : clues) {
if (LOG.isTraceEnabled()) {
LOG.trace(++i + ".\tcharset " + clue);
}
String charset = clue.value;
if (minConfidence >= 0 && clue.confidence >= minConfidence) {
if (LOG.isTraceEnabled()) {
LOG.trace("Choosing encoding: " + charset + " with confidence " + clue.confidence);
}
return resolveEncodingAlias(charset);
} else if (clue.confidence == NO_THRESHOLD && bestClue == defaultClue) {
if (LOG.isTraceEnabled()) {
// Always be the first one if confidence is -1
LOG.trace("Choose as best clue " + clue);
}
bestClue = clue;
} else {
}
}
if (LOG.isTraceEnabled()) {
LOG.trace("Best clue: " + bestClue);
}
return bestClue.value.toLowerCase();
}
/**
* Clears all clues.
*/
public void clearClues() {
clues.clear();
}
/*
* Strictly for analysis, look for "disagreements." The top guess from each
* source is examined; if these meet the threshold and disagree, then we log
* the information -- useful for testing or generating training data for a
* better heuristic.
*/
private void findDisagreements(String url, List<EncodingClue> newClues) {
HashSet<String> valsSeen = new HashSet<>();
HashSet<String> sourcesSeen = new HashSet<>();
boolean disagreement = false;
for (EncodingClue clue : newClues) {
if (!clue.isEmpty() && !sourcesSeen.contains(clue.source)) {
if (valsSeen.size() > 0 && !valsSeen.contains(clue.value) && clue.meetsThreshold()) {
disagreement = true;
}
if (clue.meetsThreshold()) {
valsSeen.add(clue.value);
}
sourcesSeen.add(clue.source);
}
}
if (disagreement) {
// dump all values in case of disagreement
StringBuilder sb = new StringBuilder();
sb.append("Disagreement: ").append(url).append("; ");
for (int i = 0; i < newClues.size(); i++) {
if (i > 0) {
sb.append(", ");
}
sb.append(newClues.get(i));
}
LOG.trace(sb.toString());
}
}
public class EncodingClue {
private final String value;
private final String source;
private final int confidence;
// Constructor for clues with no confidence values (ignore thresholds)
public EncodingClue(String value, String source) {
this(value, source, NO_THRESHOLD);
}
public EncodingClue(String value, String source, int confidence) {
this.value = value.toLowerCase();
this.source = source;
this.confidence = confidence;
}
public String getSource() {
return source;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return value + " (" + source
+ ((confidence >= 0) ? ", " + confidence + "% confidence" : "") + ")";
}
public boolean isEmpty() {
return (value == null || "".equals(value));
}
public boolean meetsThreshold() {
return (confidence < 0 || (minConfidence >= 0 && confidence >= minConfidence));
}
}
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-skeleton/3.0.15/ai/platon/pulsar/skeleton
|
java-sources/ai/platon/pulsar/pulsar-skeleton/3.0.15/ai/platon/pulsar/skeleton/common/MimeTypeResolver.java
|
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.platon.pulsar.skeleton.common;
import ai.platon.pulsar.common.ObjectCache;
import ai.platon.pulsar.common.config.ImmutableConfig;
import org.apache.tika.Tika;
import org.apache.tika.config.TikaConfig;
import org.apache.tika.io.TikaInputStream;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.mime.MimeType;
import org.apache.tika.mime.MimeTypeException;
import org.apache.tika.mime.MimeTypes;
import org.apache.tika.mime.MimeTypesFactory;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
public final class MimeTypeResolver {
private static final String SEPARATOR = ";";
/* our log stream */
private static final Logger logger = LoggerFactory.getLogger(MimeTypeResolver.class.getName());
/* our Tika mime type registry */
private MimeTypes mimeTypes;
private TikaConfig tikaConfig;
/* the tika detectors */
private final Tika tika = new Tika();
/* whether magic should be employed or not */
private boolean mimeMagic;
public MimeTypeResolver(ImmutableConfig conf) {
ObjectCache objectCache = ObjectCache.get(conf);
MimeTypes mimeTypes = objectCache.getBean(MimeTypes.class);
if (mimeTypes == null) {
try {
String customMimeTypeFile = conf.get("mime.types.file");
if (customMimeTypeFile != null && !customMimeTypeFile.isEmpty()) {
try {
mimeTypes = MimeTypesFactory.create(conf.getConfResourceAsInputStream(customMimeTypeFile));
} catch (Exception e) {
logger.error("Can't load mime.types.file : " + customMimeTypeFile + " using Tika's default");
}
}
if (mimeTypes == null) {
mimeTypes = MimeTypes.getDefaultMimeTypes();
}
} catch (Exception e) {
logger.error("Exception in MimeUtil " + e.getMessage());
throw new RuntimeException(e);
}
objectCache.putBean(mimeTypes);
}
this.mimeTypes = mimeTypes;
this.mimeMagic = conf.getBoolean("mime.type.magic", true);
}
/**
* Cleans a {@link MimeType} name by removing out the actual {@link MimeType},
* from a string of the form:
* @param origType
* The original mime type string to be cleaned.
* @return The primary type, and subtype, concatenated, e.g., the actual mime
* type.
*/
public static String cleanMimeType(String origType) {
if (origType == null) {
return null;
}
// take the origType and split it on ';'
String[] tokenizedMimeType = origType.split(SEPARATOR);
if (tokenizedMimeType.length > 1) {
// there was a ';' in there, take the first value
return tokenizedMimeType[0];
} else {
// there wasn't a ';', so just return the orig type
return origType;
}
}
public void reload(ImmutableConfig conf) {
}
/**
* A facade interface to trying all the possible mime type resolution
* strategies available within Tika. First, the mime type provided in
* <code>typeName</code> is cleaned, with {@link #cleanMimeType(String)}. Then
* the cleaned mime type is looked up in the underlying Tika {@link MimeTypes}
* registry, by its cleaned name. If the {@link MimeType} is found, then that
* mime type is used, otherwise URL resolution is used to try and determine
* the mime type. However, if <code>mime.type.magic</code> is enabled in
* {@link ImmutableConfig}, then mime type magic resolution is used to try
* and obtain a better-than-the-default approximation of the {@link MimeType}.
*
* @param typeName The original mime type, returned from a ProtocolOutput.
* @param url The given @see url, that AppConstants was trying to text.
* @param data The byte data, returned from the text, if any.
* @return The correctly, automatically guessed {@link MimeType} name.
*/
public String autoResolveContentType(String typeName, @NotNull String url, @Nullable byte[] data) {
String retType = null;
MimeType type = null;
String cleanedMimeType = MimeTypeResolver.cleanMimeType(typeName);
// first try to get the type from the cleaned type name
if (cleanedMimeType != null) {
try {
type = mimeTypes.forName(cleanedMimeType);
cleanedMimeType = type.getName();
} catch (MimeTypeException mte) {
// Seems to be a malformed mime type name...
cleanedMimeType = null;
}
}
// if returned null, or if it's the default type then try url resolution
if (type == null || type.getName().equals(MimeTypes.OCTET_STREAM)) {
// If no mime-type header, or cannot find a corresponding registered
// mime-type, then guess a mime-type from the url pattern
try {
retType = tika.detect(url);
} catch (Exception e) {
String message = "Problem loading default Tika configuration";
logger.error(message, e);
throw new RuntimeException(e);
}
} else {
retType = type.getName();
}
// if magic is enabled use mime magic to guess if the mime type returned
// from the magic guess is different than the one that's already set so far
// if it is, and it's not the default mime type, then go with the mime type
// returned by the magic
if (this.mimeMagic && data != null) {
String magicType = null;
// pass URL (file name) and (cleansed) content type from protocol to Tika
Metadata tikaMeta = new Metadata();
// tikaMeta.add(Metadata.RESOURCE_NAME_KEY, url);
tikaMeta.add(Metadata.CONTENT_TYPE, (cleanedMimeType != null ? cleanedMimeType : typeName));
try (InputStream stream = TikaInputStream.get(data)) {
magicType = tika.detect(stream, tikaMeta);
} catch (IOException ignored) {
}
if (magicType != null && !magicType.equals(MimeTypes.OCTET_STREAM)
&& !magicType.equals(MimeTypes.PLAIN_TEXT) && retType != null
&& !retType.equals(magicType)) {
// If magic enabled and the current mime type differs from that of the
// one returned from the magic, take the magic mimeType
retType = magicType;
}
// if type is STILL null after all the resolution strategies, go for the
// default type
if (retType == null) {
try {
retType = MimeTypes.OCTET_STREAM;
} catch (Exception ignored) {
}
}
}
return retType;
}
/**
* Facade interface to Tika's underlying {@link MimeTypes#getMimeType(String)}
* method.
*
* @param url
* A string representation of the document to sense the
* {@link MimeType} for.
* @return An appropriate {@link MimeType}, identified from the given Document
* url in string form.
*/
public String getMimeType(String url) {
return tika.detect(url);
}
/**
* A facade interface to Tika's underlying {@link MimeTypes#forName(String)}
* method.
*
* @param name
* The name of a valid {@link MimeType} in the Tika mime registry.
* @return The object representation of the {@link MimeType}, if it exists, or
* null otherwise.
*/
public String forName(String name) {
try {
return this.mimeTypes.forName(name).toString();
} catch (MimeTypeException e) {
logger.error("Exception getting mime type by name: [" + name + "]: Message: " + e.getMessage());
return null;
}
}
/**
* Facade interface to Tika's underlying {@link MimeTypes#getMimeType(File)}
* method.
*
* @param path The {@link Path} to sense the {@link MimeType} for.
* @return The {@link MimeType} of the given {@link File}, or null if it cannot be determined.
*/
public String detect(Path path) {
return detect(path.toFile());
}
/**
* Facade interface to Tika's underlying {@link MimeTypes#getMimeType(File)}
* method.
*
* @param file The {@link File} to sense the {@link MimeType} for.
* @return The {@link MimeType} of the given {@link File}, or null if it cannot be determined.
*/
public String detect(File file) {
try {
return tika.detect(file);
} catch (Exception e) {
logger.error("Exception getting mime type for file: [" + file.getPath() + "]: Message: " + e.getMessage());
return null;
}
}
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-skeleton/3.0.15/ai/platon/pulsar/skeleton/common
|
java-sources/ai/platon/pulsar/pulsar-skeleton/3.0.15/ai/platon/pulsar/skeleton/common/domain/DomainSuffix.java
|
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.platon.pulsar.skeleton.common.domain;
/**
* This class represents the last part of the host name, which is operated by
* authoritives, not individuals. This information is needed to find the domain
* name of a host. The domain name of a host is defined to be the last part
* before the domain suffix, w/o subdomain names. As an example the domain name
* of <br>
* <code> http://lucene.apache.org/
* </code><br>
* is <code> apache.org</code> <br>
* This class holds three fields, <strong>domain</strong> field represents the
* suffix (such as "co.uk") <strong>boost</strong> is a float for boosting score
* of url's with this suffix <strong>status</strong> field represents domain's
* status
*
* @author Enis Soztutar <enis.soz.pulsar@gmail.com>
* @see TopLevelDomain
* @see domain-suffixes.xml
*/
public class DomainSuffix {
public static final float DEFAULT_BOOST = 1.0f;
public static final Status DEFAULT_STATUS = Status.IN_USE;
private String domain;
private Status status;
private float boost;
public DomainSuffix(String domain, Status status, float boost) {
this.domain = domain;
this.status = status;
this.boost = boost;
}
public DomainSuffix(String domain) {
this(domain, DEFAULT_STATUS, DEFAULT_BOOST);
}
public String getDomain() {
return domain;
}
public Status getStatus() {
return status;
}
public float getBoost() {
return boost;
}
@Override
public String toString() {
return domain;
}
/**
* Enumeration of the status of the tld. Please see domain-suffixes.xml.
*/
public enum Status {
INFRASTRUCTURE, SPONSORED, UNSPONSORED, STARTUP, PROPOSED, DELETED, PSEUDO_DOMAIN, DEPRECATED, IN_USE, NOT_IN_USE, REJECTED
}
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-skeleton/3.0.15/ai/platon/pulsar/skeleton/common
|
java-sources/ai/platon/pulsar/pulsar-skeleton/3.0.15/ai/platon/pulsar/skeleton/common/domain/DomainSuffixes.java
|
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.platon.pulsar.skeleton.common.domain;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.InputStream;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* A Top-Level Domain is the suffix tied to a website, such as com, net, or org.
* <p />
* A top-level domain (TLD) is the suffix or extension tied to a website.
* Around half of all websites use the top-level domain com, commonly called “dot” com.
* <p />
* There is no algorithmic way of knowing whether a suffix is a public domain suffix, or not.
*/
public class DomainSuffixes {
private static final Logger LOG = LoggerFactory.getLogger(DomainSuffixes.class);
public static String DOMAIN_SUFFIXES_FILE = "domain-suffixes.xml";
private static DomainSuffixes instance;
private Map<String, DomainSuffix> domains = new ConcurrentHashMap<>();
private DomainSuffixes() {
}
/**
* Singleton instance, lazy instantination
*
* @return DomainSuffixes
*/
public static DomainSuffixes getInstance() {
if (instance == null) {
synchronized (DomainSuffixes.class) {
if (instance == null) {
instance = load(DOMAIN_SUFFIXES_FILE);
}
}
}
return instance;
}
private static DomainSuffixes load(String resource) {
DomainSuffixes suffixes = null;
LOG.info("Loading domain suffixes from resource " + resource);
try (InputStream input = DomainSuffixes.class.getClassLoader().getResourceAsStream(resource)) {
if (input == null) {
LOG.error("Failed to load resource " + resource);
} else {
suffixes = new DomainSuffixesReader().read(new DomainSuffixes(), input);
LOG.info("Total {} known domains", suffixes.domains.size());
}
} catch (Exception e) {
LOG.warn(e.getMessage());
}
return suffixes;
}
void addDomainSuffix(DomainSuffix tld) {
domains.put(tld.getDomain(), tld);
}
/**
* return whether the extension is a registered domain entry
*/
public boolean isDomainSuffix(String extension) {
return domains.containsKey(extension);
}
/**
* Return the {@link DomainSuffix} object for the extension, if extension is a
* top level domain returned object will be an instance of
* {@link TopLevelDomain}
*
* @param extension of the domain
*/
public DomainSuffix get(String extension) {
return domains.get(extension);
}
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-skeleton/3.0.15/ai/platon/pulsar/skeleton/common
|
java-sources/ai/platon/pulsar/pulsar-skeleton/3.0.15/ai/platon/pulsar/skeleton/common/domain/DomainSuffixesReader.java
|
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.platon.pulsar.skeleton.common.domain;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.io.InputStream;
/**
* For parsing xml files containing domain suffix definitions. Parsed xml files
* should validate against <code>domain-suffixes.xsd</code>
*
* @author Enis Soztutar <enis.soz.pulsar@gmail.com>
*/
class DomainSuffixesReader {
private static final Logger LOG = LoggerFactory.getLogger(DomainSuffixesReader.class);
DomainSuffixes read(DomainSuffixes tldEntries, InputStream input) throws IOException {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setIgnoringComments(true);
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(new InputSource(input));
Element root = document.getDocumentElement();
if (root != null && root.getTagName().equals("domains")) {
Element tlds = (Element) root.getElementsByTagName("tlds").item(0);
Element suffixes = (Element) root.getElementsByTagName("suffixes").item(0);
// read tlds
readITLDs(tldEntries, (Element) tlds.getElementsByTagName("itlds").item(0));
readGTLDs(tldEntries, (Element) tlds.getElementsByTagName("gtlds").item(0));
readCCTLDs(tldEntries, (Element) tlds.getElementsByTagName("cctlds").item(0));
readSuffixes(tldEntries, suffixes);
} else {
throw new IOException("xml file is not valid");
}
} catch (ParserConfigurationException | SAXException ex) {
LOG.warn(ex.getMessage());
throw new IOException(ex);
}
return tldEntries;
}
void readITLDs(DomainSuffixes tldEntries, Element el) {
NodeList children = el.getElementsByTagName("tld");
for (int i = 0; i < children.getLength(); i++) {
tldEntries.addDomainSuffix(readGTLD((Element) children.item(i),
TopLevelDomain.Type.INFRASTRUCTURE));
}
}
void readGTLDs(DomainSuffixes tldEntries, Element el) {
NodeList children = el.getElementsByTagName("tld");
for (int i = 0; i < children.getLength(); i++) {
tldEntries.addDomainSuffix(readGTLD((Element) children.item(i), TopLevelDomain.Type.GENERIC));
}
}
void readCCTLDs(DomainSuffixes tldEntries, Element el) throws IOException {
NodeList children = el.getElementsByTagName("tld");
for (int i = 0; i < children.getLength(); i++) {
tldEntries.addDomainSuffix(readCCTLD((Element) children.item(i)));
}
}
TopLevelDomain readGTLD(Element el, TopLevelDomain.Type type) {
String domain = el.getAttribute("domain");
DomainSuffix.Status status = readStatus(el);
float boost = readBoost(el);
return new TopLevelDomain(domain, type, status, boost);
}
TopLevelDomain readCCTLD(Element el) throws IOException {
String domain = el.getAttribute("domain");
DomainSuffix.Status status = readStatus(el);
float boost = readBoost(el);
String countryName = readCountryName(el);
return new TopLevelDomain(domain, status, boost, countryName);
}
/** read optional field status */
DomainSuffix.Status readStatus(Element el) {
NodeList list = el.getElementsByTagName("status");
if (list == null || list.getLength() == 0)
return DomainSuffix.DEFAULT_STATUS;
return DomainSuffix.Status.valueOf(list.item(0).getFirstChild().getNodeValue());
}
/** read optional field boost */
float readBoost(Element el) {
NodeList list = el.getElementsByTagName("boost");
if (list == null || list.getLength() == 0)
return DomainSuffix.DEFAULT_BOOST;
return Float.parseFloat(list.item(0).getFirstChild().getNodeValue());
}
/**
* read field countryname
*/
String readCountryName(Element el) throws IOException {
NodeList list = el.getElementsByTagName("country");
if (list == null || list.getLength() == 0)
throw new IOException("Country name should be given");
return list.item(0).getNodeValue();
}
void readSuffixes(DomainSuffixes tldEntries, Element el) {
NodeList children = el.getElementsByTagName("suffix");
for (int i = 0; i < children.getLength(); i++) {
tldEntries.addDomainSuffix(readSuffix((Element) children.item(i)));
}
}
DomainSuffix readSuffix(Element el) {
String domain = el.getAttribute("domain");
DomainSuffix.Status status = readStatus(el);
float boost = readBoost(el);
return new DomainSuffix(domain, status, boost);
}
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-skeleton/3.0.15/ai/platon/pulsar/skeleton/common
|
java-sources/ai/platon/pulsar/pulsar-skeleton/3.0.15/ai/platon/pulsar/skeleton/common/domain/TopLevelDomain.java
|
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.platon.pulsar.skeleton.common.domain;
/**
* (From wikipedia) A top-level domain (TLD) is the last part of an Internet
* domain name; that is, the letters which follow the final dot of any domain
* name. For example, in the domain name <code>www.website.com</code>, the
* top-level domain is <code>com</code>.
*
* @author Enis Soztutar <enis.soz.pulsar@gmail.com>
* @see {http://www.iana.org/}
* @see {http://en.wikipedia.org/wiki/Top-level_domain}
*/
public class TopLevelDomain extends DomainSuffix {
private Type type;
private String countryName = null;
public TopLevelDomain(String domain, Type type, Status status, float boost) {
super(domain, status, boost);
this.type = type;
}
public TopLevelDomain(String domain, Status status, float boost,
String countryName) {
super(domain, status, boost);
this.type = Type.COUNTRY;
this.countryName = countryName;
}
public Type getType() {
return type;
}
/**
* Returns the country name if TLD is Country Code TLD
*
* @return country name or null
*/
public String getCountryName() {
return countryName;
}
public enum Type {
INFRASTRUCTURE, GENERIC, COUNTRY
}
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-skeleton/3.0.15/ai/platon/pulsar/skeleton/crawl
|
java-sources/ai/platon/pulsar/pulsar-skeleton/3.0.15/ai/platon/pulsar/skeleton/crawl/filter/package-info.java
|
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Index writer plugin for <a href="http://lucene.apache.org/solr/">Apache Solr</a>.
*/
package ai.platon.pulsar.skeleton.crawl.filter;
|
0
|
java-sources/ai/platon/pulsar/pulsar-skeleton/3.0.15/ai/platon/pulsar/skeleton/crawl
|
java-sources/ai/platon/pulsar/pulsar-skeleton/3.0.15/ai/platon/pulsar/skeleton/crawl/parse/package-info.java
|
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* The {@link ai.platon.pulsar.parse.Parse Parse} interface and related classes.
*/
package ai.platon.pulsar.skeleton.crawl.parse;
|
0
|
java-sources/ai/platon/pulsar/pulsar-skeleton/3.0.15/ai/platon/pulsar/skeleton/crawl
|
java-sources/ai/platon/pulsar/pulsar-skeleton/3.0.15/ai/platon/pulsar/skeleton/crawl/protocol/package-info.java
|
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Classes related to the {@link ai.platon.pulsar.skeleton.crawl.protocol.Protocol Protocol} interface,
* see also {@link ai.platon.pulsar.skeleton.crawl.net.protocols}.
*/
package ai.platon.pulsar.skeleton.crawl.protocol;
|
0
|
java-sources/ai/platon/pulsar/pulsar-skeleton/3.0.15/ai/platon/pulsar/skeleton/crawl
|
java-sources/ai/platon/pulsar/pulsar-skeleton/3.0.15/ai/platon/pulsar/skeleton/crawl/schedule/package-info.java
|
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.platon.pulsar.skeleton.crawl.schedule;
|
0
|
java-sources/ai/platon/pulsar/pulsar-skeleton/3.0.15/ai/platon/pulsar/skeleton
|
java-sources/ai/platon/pulsar/pulsar-skeleton/3.0.15/ai/platon/pulsar/skeleton/signature/MD5Signature.java
|
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.platon.pulsar.skeleton.signature;
import ai.platon.pulsar.persist.WebPage;
import org.apache.avro.util.Utf8;
import java.nio.ByteBuffer;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
* Default implementation of a page signature. It calculates an MD5 hash of the
* raw binary content of a page. In case there is no content, it calculates a
* hash from the page's URL.
*
* @author Andrzej Bialecki <ab@getopt.org>
*/
public class MD5Signature extends Signature {
private static final ThreadLocal<MessageDigest> DIGESTER_FACTORY = ThreadLocal.withInitial(() -> {
try {
return MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
});
public static MessageDigest getDigester() {
MessageDigest digester = (MessageDigest)DIGESTER_FACTORY.get();
digester.reset();
return digester;
}
public static byte[] digest(byte[] data, int start, int len) {
MessageDigest digester = getDigester();
digester.update(data, start, len);
byte[] digest = digester.digest();
if (digest.length != 16) {
throw new IllegalArgumentException("Wrong length: " + digest.length);
}
return digest;
}
@Override
public byte[] calculate(WebPage page) {
ByteBuffer buf = page.getContent();
byte[] data;
int of;
int cb;
if (buf == null) {
Utf8 baseUrl = new Utf8(page.getLocation());
data = baseUrl.getBytes();
of = 0;
cb = baseUrl.length();
} else {
data = buf.array();
of = buf.arrayOffset() + buf.position();
cb = buf.remaining();
}
return digest(data, of, cb);
}
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-skeleton/3.0.15/ai/platon/pulsar/skeleton
|
java-sources/ai/platon/pulsar/pulsar-skeleton/3.0.15/ai/platon/pulsar/skeleton/signature/Signature.java
|
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.platon.pulsar.skeleton.signature;
import ai.platon.pulsar.persist.WebPage;
public abstract class Signature {
public abstract byte[] calculate(WebPage page);
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-skeleton/3.0.15/ai/platon/pulsar/skeleton
|
java-sources/ai/platon/pulsar/pulsar-skeleton/3.0.15/ai/platon/pulsar/skeleton/signature/SignatureComparator.java
|
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.platon.pulsar.skeleton.signature;
import java.nio.ByteBuffer;
import java.util.Comparator;
public class SignatureComparator implements Comparator<SignatureComparator> {
public static int compare(byte[] data1, byte[] data2) {
if (data1 == null && data2 == null)
return 0;
if (data1 == null)
return -1;
if (data2 == null)
return 1;
return _compare(data1, 0, data1.length, data2, 0, data2.length);
}
public static int compare(ByteBuffer buf1, ByteBuffer buf2) {
if (buf1 == null && buf2 == null)
return 0;
if (buf1 == null)
return -1;
if (buf2 == null)
return 1;
return _compare(buf1.array(), buf1.arrayOffset() + buf1.position(),
buf1.remaining(), buf2.array(), buf2.arrayOffset() + buf2.position(),
buf2.remaining());
}
public static int _compare(Object o1, Object o2) {
if (o1 == null && o2 == null)
return 0;
if (o1 == null)
return -1;
if (o2 == null)
return 1;
if (!(o1 instanceof byte[]))
return -1;
if (!(o2 instanceof byte[]))
return 1;
byte[] data1 = (byte[]) o1;
byte[] data2 = (byte[]) o2;
return _compare(data1, 0, data1.length, data2, 0, data2.length);
}
public static int _compare(byte[] data1, int s1, int l1, byte[] data2,
int s2, int l2) {
if (l2 > l1)
return -1;
if (l2 < l1)
return 1;
int res = 0;
for (int i = 0; i < l1; i++) {
res = (data1[s1 + i] - data2[s2 + i]);
if (res != 0)
return res;
}
return 0;
}
public int compare(SignatureComparator o1, SignatureComparator o2) {
return _compare(o1, o2);
}
}
|
0
|
java-sources/ai/platon/pulsar/pulsar-skeleton/3.0.15/ai/platon/pulsar/skeleton
|
java-sources/ai/platon/pulsar/pulsar-skeleton/3.0.15/ai/platon/pulsar/skeleton/signature/TextMD5Signature.java
|
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.platon.pulsar.skeleton.signature;
import ai.platon.pulsar.persist.WebPage;
import org.apache.hadoop.io.MD5Hash;
/**
* Default implementation of a page signature. It calculates an MD5 hash of the
* textual content of a page. In case there is no signature, it calculates a hash
* from the page's fetched content.
*/
public class TextMD5Signature extends Signature {
public static int GOOD_CONTENT_TEXT_LENGTH = 2000;
private Signature fallback = new MD5Signature();
/**
* We need calculate signature using a more clean signature content, eg, extracted by signature-persist
* */
@Override
public byte[] calculate(WebPage page) {
String text = page.getContentText();
if (text.isEmpty() || text.length() < GOOD_CONTENT_TEXT_LENGTH) {
text = page.getPageText();
}
if (text.isEmpty()) {
return fallback.calculate(page);
}
return MD5Hash.digest(text).getDigest();
}
}
|
0
|
java-sources/ai/polus/utils/filepattern
|
java-sources/ai/polus/utils/filepattern/2.0.7/FilePattern.java
|
package filepattern.java;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Arrays;
import java.nio.file.*;
import java.io.*;
/**
* This class provides use of the filepattern package.
* filepattern is used to store files that follow a pattern, where the pattern is
* analogous to a simplified regular expression. This class allows a user to specify
* a filepattern, and then iterate over the FilePattern object to obtain files matching
* the given filepattern
*
* For example, consider the follwoing files in a directory:
*
* data/
* img_r01_c01.tif
* img_r01_c02.tif
* img_r02_c01.tif
* img_r02_c02.tif
*
* A filepattern to capture these file would be "img_r{r:dd}_c{c:dd}.tif",
* where "dd" captures two digits and assigns the value to a variable named "r" another "c".
*
* For more information on how to use this class, please see the ReadtheDocs or the Github for filepattern.
*
* Github: https://github.com/PolusAI/filepattern
* rtd: https://filepattern.readthedocs.io/en/latest/?badge=latest
*
*/
public class FilePattern implements Iterable{
private FilePatternBindings.FilePattern fp;
private FilePatternBuilder builder;
private boolean external;
private ArrayList<String> groups = new ArrayList<>();
/**
* Builder class for FilePattern to provide optional variables when constructing
* a FilePattern.
*/
public static class FilePatternBuilder {
private String path;
private String filePattern = "";
private boolean recursive = false;
private boolean suppressWarnings = false;
private String blockSize = "";
public FilePatternBuilder(String path) {
this.path = path;
}
public FilePatternBuilder filePattern(String filePattern) {
this.filePattern = filePattern;
return this;
}
public FilePatternBuilder recursive(boolean recursive) {
this.recursive = recursive;
return this;
}
public FilePatternBuilder suppressWarnings(boolean suppressWarnings) {
this.suppressWarnings = suppressWarnings;
return this;
}
public FilePatternBuilder blockSize(String blockSize) {
this.blockSize = blockSize;
return this;
}
public FilePattern build() throws IOException {
FilePattern fp = new FilePattern(this);
return fp;
}
}
/**
* Construct a FilePattern object from a Builder
* @param builder Builder containing the FilePattern parameters
* @throws IOException Throws IOException when supplied directory path is not found.
*/
private FilePattern(FilePatternBuilder builder) throws IOException {
this.builder = builder;
this.fp = new FilePatternBindings.FilePattern(builder.path, builder.filePattern, builder.blockSize, builder.recursive, builder.suppressWarnings); // need to add builder to FPOjbect
}
/**
* Get the filepattern that is currently being used.
*
* @return The filepattern.
*/
public String getPattern() {
return this.fp.getPattern();
}
/**
* This method will return a list containing all files where the variable matches the supplied. For example,
* if the HashMap `{"x", 1}` is passed to get matching, all files where x is 1 will be returned. A list of values
* can also be passed, such as `{"x", {1,2,3}}`. Furthermore, an arbitrary number of variables and values can be passed,
* such as {{x, 1}, {y, 2}, {z, 3}}`.
*
* @param keywordArgs HashMap mapping variable names to the values to be matched.
* @return An ArrayList of files matching the variable values requested.
* @throws IllegalArgumentException An exception will be thrown if invalid variables are used as keys in the HashMap.
*/
public ArrayList<Pair<HashMap<String, Object>, ArrayList<Path>>> getMatching(HashMap<String, Object> keywordArgs) throws IllegalArgumentException {
this.checkKeywordArgs(keywordArgs);
return FilePatternBindings.FilePatternVector.cast(fp.getMatchingByMap(FilePatternBindings.StringVariantMap.cast(keywordArgs)));
}
/**
* Takes in a variable as the key and a list of values as the value and returns the a HashMap
* mapping the variable to a HashMap of the values mapped to the number of occurrences of the variable
* value.
* For example, if the filepattern is `img_r{r:ddd}_c{r:ddd}.tif` and r=1 occurs 20 times in the path,
* then the passing `{"r", 1}` will return `{"r", {1: 20}}`.
* @param keywordArgs
* @return
* @throws IllegalArgumentException
*/
public HashMap<String, HashMap<Object, Integer>> getOccurrences(HashMap<String, Object> keywordArgs) throws IllegalArgumentException {
this.checkKeywordArgs(keywordArgs);
return FilePatternBindings.StringMapMap.cast(this.fp.getOccurrencesByMap(FilePatternBindings.StringVariantMap.cast(keywordArgs)));
}
/**
* Given variable names from the filepattern as arguments, this method returns a HashMap
* of mapping the variable names to a set of the unique values for each variable. If no variables are
* provided, all variables will be returned.
*
* For example if the filepattern is `img_r{r:ddd}_c{r:ddd}.tif` and `r` ranges from 1 to 3 and c ranges from 1 to 2,
* then fp_object.getUniqueValues("r", "c") will return `{"r", {1,2,3}, "c", {1,2}}`.
*
* @param variables Name of variables that exist in the filepattern.
* @return The unique values for the supplied variables.
* @throws IllegalArgumentException
*/
public HashMap<String, HashSet<Object>> getUniqueValues(String ... variables) throws IllegalArgumentException {
return FilePatternBindings.StringSetMap.cast(this.fp.getUniqueValues(new FilePatternBindings.StringVector(variables)));
}
/**
* Returns a single filename that captures variables from a list of files.
*
* Given a list of files, this method will return a single filename that captures the variables from each
* file in the list. If a variable is constant through the list, the variable value will be in the returned
* name. If a variable is not constant, the minimum and maximum values will appear in the returned name in
* the form "(min-max)".
* @param files List of FilePattern file mapping to get the output name of.
* @return The outputname for the ArrayList of files.
*/
public String outputName(ArrayList<Pair<HashMap<String, Object>, ArrayList<Path>>> files) {
return this.fp.outputName(FilePatternBindings.TupleVector.cast(files));
}
/**
* Returns a list of variables that are contained in the filepattern
* For example, if the filepattern is `img_x{x:d}_y{y:d}_c{c:c+}.tif`, get_variables will return
* the list `{x, y, c}`.
*
* @return ArrayList of variables contained in the filepattern.
*/
public ArrayList<String> getVariables() {
return FilePatternBindings.StringVector.cast(new FilePatternBindings.StringVector(this.fp.getVariables()));
}
/**
* Replace the first version of filepattern naming style with the updated version. This method
* will update the filepattern being used in the FilePattern object.
*
* @param pattern A String containing the old style of filepattern.
* @param suppressWarnings True to suppress warnings for using deprecated style
*/
public void getNewNaming(String pattern, boolean suppressWarnings) {
this.fp.getNewNaming(pattern, suppressWarnings);
}
/**
* Get the path supplied to the FilePattern object
*
* @return The path the FilePattern object is using.
*/
public String getPath() {
return this.fp.getPath();
}
/**
* Get the nested structure of file variable values and path. This returns what the iterator
* would return but in a single ArrayList.
*
* @return ArrayList of variable values and paths for all files found by the filepattern.
*/
public ArrayList<Pair<HashMap<String, Object>, ArrayList<Path>>> getFiles() {
return FilePatternBindings.TupleVector.cast(this.fp.getFiles());
}
/**
* Get the iterator for iterating over the files found by the filepattern.
*/
public Iterator<?> iterator() {
if (this.groups.size() == 0) {
return new FilePatternIterator(this);
} else {
return new FilePatternGroupedIterator(this);
}
}
/**
* Get the iterator for iterating over grouped files found by the filepattern.
*
* For example, if groups="r", then the files will be returned in groups for each value of "r".
*
* @param groups Names of variables contained in the filepattern to group by.
* @return An iterator for the grouped files.
*/
public Iterator<?> iterator(String ... groups) {
this.setGroup(groups);
return new FilePatternGroupedIterator(this);
}
/**
* Get iterator for files matching specific values.
*
* This will return lists containing all files where the variable matches the supplied. For example,
* if the argument `{"x", 1}` is passed, all files where x is 1 will be returned.
*
* @param keywordArgs A hashmap containg variables in the filepattern mapped to values to get the matching files for.
* @return The files matching the values specified in the arguments.
*/
public Iterator<?> iterator(HashMap<String, Object> keywordArgs) {
return this.getMatching(keywordArgs).iterator();
}
/**
* Randomly access files found by the filepattern by index.
*
* @param index Index of the file to be accessed.
* @return The file stored at `index`.
*/
public Pair<HashMap<String, Object>, ArrayList<Path>> getAt(int index) {
return FilePatternBindings.TupleVector.cast(this.fp.getSliceByIdx(index)).get(0);
}
/**
* Randomly access of grouped files found by the filepattern by index.
*
* @param index Index of the file to be accessed.
* @return The grouped files stored at `index`.
*/
public Pair<ArrayList<Pair<String, Object>>, ArrayList<Pair<HashMap<String, Object>, ArrayList<Path>>>> getAtGrouped(int index) {
return FilePatternBindings.PairTupleVector.cast(this.fp.getGroupedSliceByIdx(index));
}
/**
* Check if the arguments passed contain valid data.
*
* @param keywordArgs HashMap mapping variable names to values.
* @throws IllegalArgumentException
*/
private void checkKeywordArgs(HashMap<String, Object> keywordArgs) throws IllegalArgumentException {
for (Map.Entry<String, Object> mapElement : keywordArgs.entrySet()) {
Object value = mapElement.getValue();
if(!(value instanceof Integer || value instanceof Double || value instanceof String)) {
throw new IllegalArgumentException("Value of keywordArgs must be Integer or String.");
}
}
}
/**
* Get the number of files found by the filepattern.
*
* @return The number of files found by the filepattern.
*/
public int getSize() {
return this.fp.getSize();
}
/**
* Get the number of groups found by the filepattern.
*
* @return The number of groups found by the filepattern.
*/
public int getGroupedSize() {
return this.fp.getGroupedSize();
}
/**
* Set the variables to group the found files by.
*
* @param groups Name of variables in the filepattern to group the files by.
*/
public void setGroup(String ... groups) {
this.groups = new ArrayList<String>(Arrays.asList(groups));
this.fp.setGroup(new FilePatternBindings.StringVector(groups));
this.fp.group(new FilePatternBindings.StringVector(groups));
}
/**
* Iterator for the files found by the filepattern.
*/
private class FilePatternIterator implements Iterator<Pair<HashMap<String, Object>, ArrayList<Path>>> {
private int current;
private FilePattern fp;
public FilePatternIterator(FilePattern obj) {
fp = obj;
current = 0;
}
public boolean hasNext() {
return (current + 1) <= this.fp.getSize();
}
public Pair<HashMap<String, Object>, ArrayList<Path>> next() {
return this.fp.getAt(current++);
}
}
/**
* Iterator for groups found by the file pattern and grouped by the groups specified in setGroups().
*/
private class FilePatternGroupedIterator implements Iterator<Pair<ArrayList<Pair<String, Object>>, ArrayList<Pair<HashMap<String, Object>, ArrayList<Path>>>>> {
private int current;
private FilePattern fp;
public FilePatternGroupedIterator(FilePattern obj) {
fp = obj;
current = 0;
}
public boolean hasNext() {
return (current + 1) <= this.fp.getGroupedSize();
}
public Pair<ArrayList<Pair<String, Object>>, ArrayList<Pair<HashMap<String, Object>, ArrayList<Path>>>> next() {
return this.fp.getAtGrouped(current++);
}
}
}
|
0
|
java-sources/ai/polus/utils/filepattern
|
java-sources/ai/polus/utils/filepattern/2.0.7/FilePatternBindings.java
|
package filepattern.java;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.ArrayList;
import java.util.Iterator;
import java.nio.file.*;
import java.io.*;
import org.bytedeco.javacpp.*;
import org.bytedeco.javacpp.annotation.*;
import org.bytedeco.javacpp.BytePointer;
import org.bytedeco.javacpp.ClassProperties;
import org.bytedeco.javacpp.FunctionPointer;
import org.bytedeco.javacpp.LoadEnabled;
import org.bytedeco.javacpp.Loader;
import org.bytedeco.javacpp.Pointer;
import org.bytedeco.javacpp.PointerPointer;
import org.bytedeco.javacpp.presets.javacpp;
import org.bytedeco.javacpp.tools.BuildEnabled;
import org.bytedeco.javacpp.tools.Info;
import org.bytedeco.javacpp.tools.InfoMap;
import org.bytedeco.javacpp.tools.InfoMapper;
import org.bytedeco.javacpp.tools.Logger;
@Platform(compiler="cpp17",
include={ "<vector>",
"<map>",
"<tuple>",
"<variant>",
"<string>",
"<filesystem>",
"java.h",
"../cpp/pattern.cpp",
"../cpp/pattern.hpp",
"../cpp/internal/filepattern.cpp",
"../cpp/internal/filepattern.hpp",
"../cpp/internal/stringpattern.cpp",
"../cpp/internal/stringpattern.hpp",
"../cpp/internal/vectorpattern.cpp",
"../cpp/internal/vectorpattern.hpp",
"../cpp/internal/internal_pattern.hpp",
"../cpp/internal/internal_pattern.cpp",
"../cpp/internal/internal_pattern.cpp",
"../cpp/internal/internal_pattern.hpp",
"../cpp/external/external_pattern.cpp",
"../cpp/external/external_pattern.hpp",
"../cpp/external/external_filepattern.cpp",
"../cpp/external/external_filepattern.hpp",
"../cpp/external/external_stringpattern.cpp",
"../cpp/external/external_stringpattern.hpp",
"../cpp/external/external_vectorpattern.cpp",
"../cpp/external/external_vectorpattern.hpp",
"../cpp/include/filepattern.h",
"../cpp/interface/filepattern.cpp",
"../cpp/pattern_object.hpp",
"../cpp/util/util.hpp"}
)
public class FilePatternBindings implements InfoMapper {
public void map(InfoMap infoMap) {
infoMap.put(new Info("std::vector<std::tuple<std::map<std::string, std::variant<int, std::string, double>>, std::vector<std::string>>>").pointerTypes("FilePatternVector").define());
infoMap.put(new Info("std::tuple<std::map<std::string, std::variant<int, std::string, double>>, std::vector<std::string>>").pointerTypes("Tuple").define());
infoMap.put(new Info("std::map<std::string, std::variant<int, std::string, double>>").pointerTypes("Map").define());
infoMap.put(new Info("std::vector<std::string>").pointerTypes("FileVector").define());
infoMap.put(new Info("std::variant<int, std::string, double>>").pointerTypes("Variant").define());
infoMap.put(new Info("std::vector<std::string>").pointerTypes("StringVector").define());
infoMap.put(new Info("std::map<std::string, std::variant<int, std::string, double>>").pointerTypes("StringVariantMap").define());
infoMap.put(new Info("std::string").pointerTypes("Path").define());
}
@Name("std::map<Types, int>")
public static class TypesIntMap extends Pointer {
static { Loader.load(); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public TypesIntMap(Pointer p) { super(p); }
public TypesIntMap() { allocate(); }
private native void allocate();
public native long size();
public native @ByVal Iterator begin();
public native @ByVal Iterator end();
@NoOffset @Name("iterator") public static class Iterator extends Pointer {
public Iterator(Pointer p) { super(p); }
public Iterator() { }
public native @Name("operator++") @ByRef Iterator increment();
public native @Name("operator==") boolean equals(@ByRef Iterator it);
public native @Name("operator*().first") @MemberGetter @ByVal Variant first();
public native @Name("operator*().second") @MemberGetter @ByVal int second();
}
public static HashMap<Object, Integer> cast(TypesIntMap map) {
Iterator mapIter = map.begin();
Iterator mapEnd = map.end();
HashMap<Object, Integer> casted = new HashMap<Object, Integer>();
while(mapIter.increment() != mapEnd) {
casted.put(mapIter.first(), new Integer(mapIter.second()));
}
return casted;
}
}
@Name("std::set<Types>")
public static class TypesSet extends Pointer {
static { Loader.load(); }
public TypesSet(Pointer p) { super(p); }
public TypesSet() { allocate(); }
private native void allocate();
public boolean empty() { return size() == 0; }
public native long size();
public native @ByVal Iterator begin();
public native @ByVal Iterator end();
@NoOffset @Name("iterator") public static class Iterator extends Pointer {
public Iterator(Pointer p) { super(p); }
public Iterator() { }
public native @Name("operator ++") @ByRef Iterator increment();
public native @Name("operator ==") boolean equals(@ByRef Iterator it);
public native @Name("operator *") @ByVal Variant get();
}
public static HashSet<Object> cast(TypesSet set) {
Iterator setIter = set.begin();
Iterator setEnd = set.end();
HashSet<Object> casted = new HashSet<Object>();
while(setIter.increment() != setEnd) {
casted.add(Variant.cast(setIter.get()));
}
return casted;
}
}
@Name("std::map<std::string, std::set<Types>>")
public static class StringSetMap extends Pointer {
static { Loader.load(); }
public StringSetMap(Pointer p) { super(p); }
public StringSetMap() { allocate(); }
private native void allocate();
public native long size();
@Index public native @ByRef TypesSet get(@StdString String i);
public native @ByVal Iterator begin();
public native @ByVal Iterator end();
@NoOffset @Name("iterator") public static class Iterator extends Pointer {
public Iterator(Pointer p) { super(p); }
public Iterator() { }
public native @Name("operator++") @ByRef Iterator increment();
public native @Name("operator==") boolean equals(@ByRef Iterator it);
public native @Name("operator*().first") @MemberGetter @ByVal @StdString String first();
public native @Name("operator*().second") @MemberGetter @ByVal TypesSet second();
}
public static HashMap<String, HashSet<Object>> cast(StringSetMap map) {
Iterator mapIter = map.begin();
Iterator mapEnd = map.end();
HashMap<String, HashSet<Object>> casted = new HashMap<String, HashSet<Object>>();
while(mapIter.increment() != mapEnd) {
casted.put(mapIter.first(), TypesSet.cast(mapIter.second()));
}
return casted;
}
}
@Name("std::map<std::string, std::map<Types, int>>")
public static class StringMapMap extends Pointer {
static { Loader.load(); }
public StringMapMap(Pointer p) { super(p); }
public StringMapMap() { allocate(); }
private native void allocate();
public native long size();
@Index public native @ByRef TypesIntMap get(@StdString String i);
public native @ByVal Iterator begin();
public native @ByVal Iterator end();
@NoOffset @Name("iterator") public static class Iterator extends Pointer {
public Iterator(Pointer p) { super(p); }
public Iterator() { }
public native @Name("operator++") @ByRef Iterator increment();
public native @Name("operator==") boolean equals(@ByRef Iterator it);
public native @Name("operator*().first") @MemberGetter @ByVal @StdString String first();
public native @Name("operator*().second") @MemberGetter @ByVal TypesIntMap second();
}
public static HashMap<String, HashMap<Object, Integer>> cast(StringMapMap map) {
Iterator mapIter = map.begin();
Iterator mapEnd = map.end();
HashMap<String, HashMap<Object, Integer>> casted = new HashMap<String, HashMap<Object, Integer>>();
while(mapIter.increment() != mapEnd) {
casted.put(mapIter.first(), TypesIntMap.cast(mapIter.second()));
}
return casted;
}
}
@Name("std::variant<int, std::string, double>")
public static class Variant extends Pointer {
static { Loader.load(); }
public Variant(Pointer p) { super(p); }
public Variant() { allocate(); }
private native void allocate();
@Name("operator=")
public native @ByVal Variant put(@ByRef int value);
@Name("operator=")
public native @ByVal Variant put(@ByRef @StdString String value);
@Name("operator=")
public native @ByVal Variant put(@ByRef double value);
@Namespace @Name("std::get<int>")
public static native @ByRef int getInt(@ByRef Variant container);
@Namespace @Name("std::get<double>")
public static native @ByRef double getDouble(@ByRef Variant container);
@Namespace @Name("std::get<std::string>")
public static native @ByRef String getString(@ByRef Variant container);
public static Object cast(Variant variant) {
Object value;
try {
value = Integer.valueOf(Variant.getInt(variant));
} catch (Exception e) {
try {
value = Double.valueOf(Variant.getDouble(variant));
} catch (Exception e2) {
try {
value = Double.valueOf(Variant.getDouble(variant));
} catch (Exception e3) {
value = Variant.getString(variant);
}
}
}
return value;
}
}
@Name("std::map<std::string, std::variant<int, std::string, double>>")
public static class StringVariantMap extends Pointer {
static { Loader.load(); }
public StringVariantMap(Pointer p) { super(p); }
public StringVariantMap() { allocate(); }
private native void allocate();
public native long size();
@Index public native @ByRef Variant get(@StdString String i);
public native StringVariantMap put(@StdString String i, Variant value);
public native @ByVal Iterator begin();
public native @ByVal Iterator end();
@NoOffset @Name("iterator") public static class Iterator extends Pointer {
public Iterator(Pointer p) { super(p); }
public Iterator() { }
public native @Name("operator++") @ByRef Iterator increment();
public native @Name("operator==") boolean equals(@ByRef Iterator it);
public native @Name("operator*().first") @MemberGetter @ByRef @StdString String first();
public native @Name("operator*().second") @MemberGetter @ByRef Variant second();
}
public static HashMap<String, Object> cast(StringVariantMap map) {
Iterator mapIter = map.begin();
Iterator mapEnd = map.end();
HashMap<String, Object> casted = new HashMap<String, Object>();
while(true) {
if (mapIter.equals(mapEnd)) {
break;
}
// Get the value from the Variant
Object value = Variant.cast(mapIter.second());
casted.put(mapIter.first(), value);
mapIter.increment();
}
return casted;
}
public static StringVariantMap cast(HashMap<String, Object> map) {
StringVariantMap casted = new StringVariantMap();
for (Map.Entry<String, Object> entry : map.entrySet()) {
Variant var = new Variant();
if (entry.getValue() instanceof Integer) {
casted.put(entry.getKey(), var.put((int) entry.getValue()));
} else if (entry.getValue() instanceof String) {
casted.put(entry.getKey(), var.put(String.valueOf(entry.getValue())));
} else if (entry.getValue() instanceof Double) {
casted.put(entry.getKey(), var.put((double) entry.getValue()));
} else {
throw new IllegalArgumentException("Value must be Integer or String.");
}
}
return casted;
}
}
@Name("std::vector<std::string>")
public static class FileVector extends Pointer {
static { Loader.load(); }
public FileVector() { allocate(); }
public FileVector(long n) { allocate(n); }
private native void allocate();
private native void allocate(long n);
@Name("operator[]")
public native @ByRef String get(long n);
public native @ByRef String at(long n);
@ValueSetter @Index(function = "at") public native FileVector put(@Cast("size_t") long i, @StdString String value);
public native long size();
public native @Cast("bool") boolean empty();
public static ArrayList<Path> cast(FileVector vec) {
ArrayList<Path> casted = new ArrayList<Path>();
for(int i = 0; i < vec.size(); ++i) {
casted.add(Paths.get(vec.get(i)));
}
return casted;
}
public static FileVector cast(ArrayList<Path> input) {
FileVector casted = new FileVector();
for(long i = 0; i < input.size(); ++i) {
casted.put(i, input.get((int) i).toString());
}
return casted;
}
}
@NoOffset
@Name("std::tuple<std::map<std::string, std::variant<int, std::string, double>>, std::vector<std::string>>")
public static class Tuple extends Pointer {
static { Loader.load(); }
public Tuple() { super(); }
public Tuple(Pointer p) { super(p); }
public @ByRef StringVariantMap get0() {return get0(this);}
@Namespace @Name("std::get<0>")
public static native @ByRef StringVariantMap get0(@ByRef Tuple container);
public @ByRef FileVector get1() {return get1(this);}
@Namespace @Name("std::get<1>")
public static native @ByRef FileVector get1(@ByRef Tuple container);
@Namespace @Name("std::make_tuple")
public static native @ByVal Tuple put(@ByRef StringVariantMap i, @ByRef FileVector j);
public static Pair<HashMap<String, Object>, ArrayList<Path>> cast(Tuple tuple) {
Pair<HashMap<String, Object>, ArrayList<Path>> casted = new Pair<HashMap<String, Object>, ArrayList<Path>>();
casted.first = StringVariantMap.cast(tuple.get0());
casted.second = FileVector.cast(tuple.get1());
return casted;
}
public static Tuple cast(Pair<HashMap<String, Object>, ArrayList<Path>> input) {
StringVariantMap casted1 = new StringVariantMap();
FileVector casted2 = new FileVector();
casted1 = StringVariantMap.cast(input.first);
for(long i = 0; i < input.second.size(); ++i) {
casted2.put(i, input.second.get((int)i).toString());
}
Tuple tuple = new Tuple();
return Tuple.put(casted1, casted2);
}
}
@Name("std::vector<std::tuple<std::map<std::string, std::variant<int, std::string, double>>, std::vector<std::string>>>")
public static class TupleVector extends Pointer {
static { Loader.load(); }
public TupleVector() { allocate(); }
public TupleVector(long n) { allocate(n); }
private native void allocate();
private native void allocate(long n);
@Name("operator[]")
public native @ByRef Tuple get(long n);
public native @ByRef Tuple at(long n);
public native long size();
public native @Cast("bool") boolean empty();
@ValueSetter @Index(function = "at") public native TupleVector put(@Cast("size_t") long i, @ByRef Tuple value);
public native void resize(@Cast("size_t") long n);
public static TupleVector cast(ArrayList<Pair<HashMap<String, Object>, ArrayList<Path>>> input) {
TupleVector casted = new TupleVector();
Pair<HashMap<String, Object>, ArrayList<Path>> pair = new Pair<HashMap<String, Object>, ArrayList<Path>>();
Tuple tuple = new Tuple();
for(long i = 0; i < input.size(); ++i) {
pair = input.get((int) i);
tuple.put(StringVariantMap.cast(pair.first), FileVector.cast(pair.second));
casted.put(i, tuple);
}
return casted;
}
public static ArrayList<Pair<HashMap<String, Object>, ArrayList<Path>>> cast(TupleVector input) {
ArrayList<Pair<HashMap<String, Object>, ArrayList<Path>>> casted = new ArrayList<Pair<HashMap<String, Object>, ArrayList<Path>>>();
for(int i = 0; i < input.size(); ++i) {
casted.add(i, Tuple.cast(input.get(i)));
}
return casted;
}
}
@Name("std::pair<std::string, std::variant<int, std::string, double>>")
public static class StringVariantTuple extends Pointer {
static { Loader.load(); }
public StringVariantTuple() { super(); }
public StringVariantTuple(Pointer p) { super(p); }
public @ByRef @StdString String get0() {return get0(this);}
@Namespace @Name("std::get<0>")
public static native @ByRef @StdString String get0(@ByRef StringVariantTuple container);
public @ByRef Variant get1() {return get1(this);}
@Namespace @Name("std::get<1>")
public static native @ByRef Variant get1(@ByRef StringVariantTuple container);
;
@Namespace @Name("std::make_pair")
public static native @ByVal StringVariantTuple put(@ByRef String i, @ByRef Variant j);
public static Pair<String, Object> cast(StringVariantTuple tuple) {
Pair<String, Object> pair = new Pair<String, Object>();
pair.first = StringVariantTuple.get0(tuple);
pair.second = Variant.cast(StringVariantTuple.get1(tuple));
return pair;
}
}
@Name("std::vector<std::pair<std::string, std::variant<int, std::string, double>>>")
public static class PairVector extends Pointer {
static { Loader.load(); }
public PairVector() { allocate(); }
public PairVector(long n) { allocate(n); }
private native void allocate();
private native void allocate(long n);
@Name("operator[]")
public native @ByRef StringVariantTuple get(long n);
public native @ByRef StringVariantTuple at(long n);
public native long size();
public native @Cast("bool") boolean empty();
@ValueSetter @Index(function = "at") public native PairVector put(@Cast("size_t") long i, @ByRef StringVariantTuple value);
public native void resize(@Cast("size_t") long n);
public static ArrayList<Pair<String, Object>> cast(PairVector input) {
ArrayList<Pair<String, Object>> casted = new ArrayList<Pair<String, Object>>();
for (int i = 0; i < input.size(); ++i) {
casted.add(StringVariantTuple.cast(input.get(i)));
}
return casted;
}
}
@Name("std::pair<std::vector<std::pair<std::string, std::variant<int, std::string, double>>> , std::vector<std::tuple<std::map<std::string, std::variant<int, std::string, double>>, std::vector<std::string>>>>")
public static class PairTupleVector extends Pointer {
static { Loader.load(); }
public PairTupleVector() { allocate(); }
private native void allocate();
public @ByRef PairVector get0() {return get0(this);}
@Namespace @Name("std::get<0>")
public static native @ByRef PairVector get0(@ByRef PairTupleVector container);
public @ByRef FilePatternVector get1() {return get1(this);}
@Namespace @Name("std::get<1>")
public static native @ByRef FilePatternVector get1(@ByRef PairTupleVector container);
@Namespace @Name("std::make_pair")
public static native @ByVal PairTupleVector put(@ByRef PairVector i, @ByRef FilePatternVector j);
public static Pair<ArrayList<Pair<String, Object>>, ArrayList<Pair<HashMap<String, Object>, ArrayList<Path>>>> cast(PairTupleVector input) {
ArrayList<Pair<String, Object>> first = new ArrayList<Pair<String, Object>>();
first = PairVector.cast(input.get0());
ArrayList<Pair<HashMap<String, Object>, ArrayList<Path>>> second = new ArrayList<Pair<HashMap<String, Object>, ArrayList<Path>>>();
second = FilePatternVector.cast(input.get1());
Pair<ArrayList<Pair<String, Object>>, ArrayList<Pair<HashMap<String, Object>, ArrayList<Path>>>> pair = new Pair<ArrayList<Pair<String, Object>>, ArrayList<Pair<HashMap<String, Object>, ArrayList<Path>>>>();
pair.first = first;
pair.second = second;
return pair;
}
}
@Name("std::vector<std::tuple<std::map<std::string, std::variant<int, std::string, double>>, std::vector<std::string>>>")
public static class FilePatternVector extends Pointer {
static { Loader.load(); }
public FilePatternVector() { allocate(); }
public FilePatternVector(long n) { allocate(n); }
private native void allocate();
private native void allocate(long n);
@Name("operator=")
public native @ByRef FilePatternVector put(@ByRef FilePatternVector x);
@Name("operator[]")
public native @ByRef Tuple get(long n);
public native @ByRef Tuple at(long n);
public native long size();
public native @Cast("bool") boolean empty();
public static ArrayList<Pair<HashMap<String, Object>, ArrayList<Path>>> cast(FilePatternVector vec) {
ArrayList<Pair<HashMap<String, Object>, ArrayList<Path>>> casted = new ArrayList<Pair<HashMap<String, Object>, ArrayList<Path>>>();
for(int i = 0; i < vec.size(); ++i) {
casted.add(Tuple.cast(vec.get(i)));
}
return casted;
}
}
@Name("std::vector<std::string>")
public static class StringVector extends Pointer {
static { Loader.load(); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public StringVector(Pointer p) { super(p); }
public StringVector(BytePointer value) { this(1); put(0, value); }
public StringVector(BytePointer ... array) { this(array.length); put(array); }
public StringVector(@StdString String value) { this(1); put(0, value); }
public StringVector(@StdString String ... array) { this(array.length); put(array); }
public StringVector() { allocate(); }
public StringVector(long n) { allocate(n); }
private native void allocate();
private native void allocate(@Cast("size_t") long n);
public native @Name("operator =") @ByRef StringVector put(@ByRef StringVector x);
public boolean empty() { return size() == 0; }
public native long size();
public void clear() { resize(0); }
public native void resize(@Cast("size_t") long n);
@Index(function = "at") public native @StdString BytePointer get(@Cast("size_t") long i);
public native StringVector put(@Cast("size_t") long i, BytePointer value);
@ValueSetter @Index(function = "at") public native StringVector put(@Cast("size_t") long i, @StdString String value);
public native @ByVal Iterator insert(@ByVal Iterator pos, @StdString BytePointer value);
public native @ByVal Iterator erase(@ByVal Iterator pos);
public native @ByVal Iterator begin();
public native @ByVal Iterator end();
@NoOffset @Name("iterator") public static class Iterator extends Pointer {
public Iterator(Pointer p) { super(p); }
public Iterator() { }
public native @Name("operator ++") @ByRef Iterator increment();
public native @Name("operator ==") boolean equals(@ByRef Iterator it);
public native @Name("operator *") @StdString BytePointer get();
}
public BytePointer[] get() {
BytePointer[] array = new BytePointer[size() < Integer.MAX_VALUE ? (int)size() : Integer.MAX_VALUE];
for (int i = 0; i < array.length; i++) {
array[i] = get(i);
}
return array;
}
@Override public String toString() {
return java.util.Arrays.toString(get());
}
public BytePointer pop_back() {
long size = size();
BytePointer value = get(size - 1);
resize(size - 1);
return value;
}
public StringVector push_back(BytePointer value) {
long size = size();
resize(size + 1);
return put(size, value);
}
public StringVector put(BytePointer value) {
if (size() != 1) { resize(1); }
return put(0, value);
}
public StringVector put(BytePointer ... array) {
if (size() != array.length) { resize(array.length); }
for (int i = 0; i < array.length; i++) {
put(i, array[i]);
}
return this;
}
public StringVector push_back(String value) {
long size = size();
resize(size + 1);
return put(size, value);
}
public StringVector put(String value) {
if (size() != 1) { resize(1); }
return put(0, value);
}
public StringVector put(String ... array) {
if (size() != array.length) { resize(array.length); }
for (int i = 0; i < array.length; i++) {
put(i, array[i]);
}
return this;
}
public static ArrayList<String> cast(StringVector vec) {
ArrayList<String> arrayList = new ArrayList<String>();
for (int i = 0; i < vec.size(); ++i) {
arrayList.add(vec.get(i).getString());
}
return arrayList;
}
}
@Name("std::vector<std::tuple<std::string, std::vector<Types>>>")
public static class TypesTupleVector extends Pointer {
static { Loader.load(); }
public TypesTupleVector() { allocate(); }
public TypesTupleVector(long n) { allocate(n); }
private native void allocate();
private native void allocate(long n);
@Name("operator=")
public native @ByRef TypesTupleVector put(@ByRef TypesTupleVector x);
@Name("operator[]")
public native @ByRef TypesTuple get(long n);
public native @ByRef TypesTuple at(long n);
public native long size();
public native @Cast("bool") boolean empty();
}
@Name("std::tuple<std::string, std::vector<Types>>")
public static class TypesTuple extends Pointer {
static { Loader.load(); }
public TypesTuple(Pointer p) { super(p); }
public @ByRef @StdString String get0() {return get0(this);}
@Namespace @Name("std::get<0>")
public static native @ByRef @StdString String get0(@ByRef TypesTuple container);
public @ByRef VariantVector get1() {return get1(this);}
@Namespace @Name("std::get<1>")
public static native @ByRef VariantVector get1(@ByRef TypesTuple container);
}
@Name("std::vector<Types>")
public static class VariantVector extends Pointer {
static { Loader.load(); }
public VariantVector() { allocate(); }
public VariantVector(long n) { allocate(n); }
private native void allocate();
private native void allocate(long n);
@Name("operator=")
public native @ByRef VariantVector put(@ByRef VariantVector x);
@Name("operator[]")
public native @ByRef Variant get(long n);
public native @ByRef Variant at(long n);
public native long size();
public native @Cast("bool") boolean empty();
}
public static class FilePattern extends Pointer{
static { Loader.load(); }
public FilePattern(String path, String filePattern, String blockSize, boolean recursive, boolean suppress_warnings) {
allocate(path, filePattern, blockSize, recursive, suppress_warnings);
}
private native void allocate(String path, String filePattern, String blockSize, boolean recursive, boolean suppress_warnings);
public native @StdString String getPattern();
public native @StdString String getPath();
public native void setPattern(@StdString String pattern);
public native @ByVal StringVector getVariables();
public native void setGroup(@ByRef StringVector groups);
public native @ByVal TupleVector getFiles();
public native @ByVal FilePatternVector getMatchingByMap(@ByRef StringVariantMap variables);
public native void group(@ByRef StringVector groups);
public native @ByVal StringMapMap getOccurrencesByMap(@ByRef StringVariantMap mapping);
public native @ByVal StringSetMap getUniqueValues(@ByRef StringVector vec);
public native @ByVal @StdString String outputName(@ByRef TupleVector vec);
public native @ByVal int getSize();
public native @ByVal int getGroupedSize();
public native @ByVal TupleVector getSliceByIdx(int index);
public native void getNewNaming(@StdString String pattern, boolean suppressWarnings);
public native @ByVal PairTupleVector getGroupedSliceByIdx(int index);
}
}
|
0
|
java-sources/ai/polus/utils/filepattern
|
java-sources/ai/polus/utils/filepattern/2.0.7/Pair.java
|
package filepattern.java;
public class Pair<T, S> {
public T first;
public S second;
public T get0() {
return this.first;
}
public S get1() {
return this.second;
}
public void set0(T value) {
this.first = value;
}
public void set1(S value) {
this.second = value;
}
@Override
public String toString() {
return "[" + this.first.toString() + ", " + this.second.toString() + "]";
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof Pair)) {
return false;
}
// typecast o to Complex so that we can compare data members
Pair pair = (Pair) obj;
if ((pair.first.equals(this.first) && pair.second.equals(this.second)) || (pair.first == this.first && pair.second == this.second)) {
return true;
} else {
return false;
}
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/algorithm/Algorithm.java
|
package ai.preferred.cerebro.core.algorithm;
import ai.preferred.cerebro.core.entity.AbstractVector;
import ai.preferred.cerebro.core.entity.Parameter;
import ai.preferred.cerebro.core.util.StringUtils;
/**
* This class provides several utility for recommendation algorithms
* @author ddle.2015
*
*/
public abstract class Algorithm {
private Parameter params = new Parameter();
public abstract double score(AbstractVector userVector, AbstractVector itemVector);
public abstract void update(AbstractVector userVector, AbstractVector v, double multiplier);
public abstract String getType();
/**
* Load the learning setting
*
* @param settingStr Setting for recommendation algorithms
*/
public void loadSettings(String settingStr){
String[] attrs = StringUtils.explode(settingStr, ',');
for(String attr: attrs){
String[] parts = StringUtils.explode(attr, "[:]");
params.add(parts[0], parts[1]);
}
}
public Parameter getParams() { return params; }
public void setParams(Parameter params) { this.params = params; }
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/algorithm/AlgorithmManager.java
|
package ai.preferred.cerebro.core.algorithm;
import ai.preferred.cerebro.core.algorithm.impl.IBPR;
import ai.preferred.cerebro.core.algorithm.impl.PMF;
public class AlgorithmManager {
private Algorithm[] algorithms;
public AlgorithmManager() {
this(new Algorithm[] {
new PMF(),
new IBPR()
});
}
public AlgorithmManager(Algorithm ... algorithms) { this.algorithms = algorithms; }
public Algorithm getAlgorithm(String modelCode, String settingStr){
for(Algorithm alg:algorithms) {
if(modelCode.contains(alg.getType())) {
alg.loadSettings(settingStr);
return alg;
}
}
return null;
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/algorithm
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/algorithm/impl/IBPR.java
|
package ai.preferred.cerebro.core.algorithm.impl;
import ai.preferred.cerebro.core.algorithm.Algorithm;
import ai.preferred.cerebro.core.entity.AbstractVector;
/**
* This class implements the IBPR algorithms
* @author ddle.2015
*
*/
public class IBPR extends Algorithm{
@Override
public double score(AbstractVector userVector, AbstractVector itemVector) {
// TODO Auto-generated method stub
double unorm = Math.sqrt(userVector.innerProduct(userVector));
double inorm = Math.sqrt(itemVector.innerProduct(itemVector));
return Math.acos(userVector.innerProduct(itemVector)/(unorm * inorm));
}
@Override
public void update(AbstractVector userVector, AbstractVector v, double multiplier) {
// TODO Auto-generated method stub
int nbFactors = getParams().getValueAsInt("nbFactors");
double learnRate = getParams().getValueAsDouble("learnRate");
double userReg = getParams().getValueAsDouble("userReg");
double unorm = Math.sqrt(userVector.innerProduct(userVector));
double vnorm = Math.sqrt(v.innerProduct(v));
double cos_uv = Math.cos(score(userVector, v));
for (int f = 0; f < nbFactors; f++) {
double uf = userVector.getElement(f);
double vf = v.getElement(f);
userVector.setElement(f, uf + learnRate * (1/unorm * (- (- vf/vnorm + cos_uv * uf/unorm)/Math.sqrt(1 - cos_uv * cos_uv)) - userReg * uf));
}
}
@Override
public String getType() {
return "bpr";
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/algorithm
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/algorithm/impl/PMF.java
|
package ai.preferred.cerebro.core.algorithm.impl;
import ai.preferred.cerebro.core.algorithm.Algorithm;
import ai.preferred.cerebro.core.entity.AbstractVector;
/**
* This class implements the PMF algorithm
* @author ddle.2015
*
*/
public class PMF extends Algorithm{
@Override
public double score(AbstractVector userVector, AbstractVector itemVector) {
double globalBias = getParams().getValueAsDouble("globalBias");
return userVector.innerProduct(itemVector) + globalBias;
}
@Override
public void update(AbstractVector userVector, AbstractVector v, double multiplier) {
int nbFactors = getParams().getValueAsInt("nbFactors");
double learnRate = getParams().getValueAsDouble("learnRate");
double userReg = getParams().getValueAsDouble("userReg");
for(int f = 0; f < nbFactors; f++){
double u_f = userVector.getElement(f);
double i_f = v.getElement(f);
double delta_u = -multiplier*i_f - userReg*u_f;
double newVal = u_f - learnRate*delta_u;
userVector.setElement(f, newVal);
}
}
@Override
public String getType() {
return "pmf";
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/entity/AbstractVector.java
|
package ai.preferred.cerebro.core.entity;
import java.io.Serializable;
/**
* This class defines a vector (dense or sparse)
* @author ddle.2015
*
*/
public abstract class AbstractVector implements Serializable {
private static final long serialVersionUID = 1L;
public abstract void add(AbstractVector v);
public abstract void divide(double c);
public abstract double innerProduct(AbstractVector v);
public abstract void setElement(int index, double value);
public abstract double getElement(int index);
public abstract int length();
public abstract String toString();
public abstract void validateInput(AbstractVector v);
public abstract AbstractVector clone();
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/entity/DenseVector.java
|
package ai.preferred.cerebro.core.entity;
import ai.preferred.cerebro.core.util.NumberUtils;
/**
* Dense vector
* @author ddle.2015
*
*/
public class DenseVector extends AbstractVector {
private static final long serialVersionUID = 3321081266694588388L;
private double[] elements;
public DenseVector(int nbFactors) {
elements = new double[nbFactors];
}
@Override
public void add(AbstractVector v) {
// Validate v
validateInput(v);
DenseVector v_cast = (DenseVector) v;
for(int i = 0; i < elements.length; i++)
elements[i] -= v_cast.getElements()[i];
}
@Override
public void divide(double c) {
if(c < 0)
throw new UnsupportedOperationException("The value should be possitive");
for(int i = 0; i < elements.length; i++)
elements[i] /= c;
}
@Override
public double innerProduct(AbstractVector v) {
// Validate v
validateInput(v);
DenseVector v_cast = (DenseVector) v;
double sum = 0.0;
for(int i = 0; i < elements.length; i++)
sum += elements[i] * v_cast.getElements()[i];
return sum;
}
@Override
public int length() {
// TODO Auto-generated method stub
return elements.length;
}
@Override
public void validateInput(AbstractVector v){
if(!(v instanceof DenseVector))
throw new ClassCastException("The two vectors have different type");
if(length() != v.length())
throw new UnsupportedOperationException("The two vectors have different lengths!");
}
@Override
public AbstractVector clone() {
DenseVector v = new DenseVector(elements.length);
v.setElements(elements);
return v;
}
@Override
public String toString(){
StringBuffer buffer = new StringBuffer();
for(int i = 0; i < elements.length; i++){
buffer.append(i).append(":").append(elements[i]);
if(i < elements.length - 1) buffer.append(",");
}
return buffer.toString();
}
public static AbstractVector convertFromString(String s) {
String[] els = s.split(",");
DenseVector v = new DenseVector(els.length);
double[] vals = new double[els.length];
for(String el: els){
String[] parts = el.split(":");
int index = NumberUtils.parseInt(parts[0]);
double val = NumberUtils.parseDouble(parts[1]);
vals[index] = val;
}
v.setElements(vals);
return v;
}
public double[] getElements() { return elements; }
public void setElements(double[] elements) { this.elements = elements; }
@Override
public void setElement(int index, double value) {
if(index >= elements.length)
throw new IndexOutOfBoundsException();
elements[index] = value;
}
@Override
public double getElement(int index) {
if(index >= elements.length)
throw new IndexOutOfBoundsException();
return elements[index];
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/entity/Parameter.java
|
package ai.preferred.cerebro.core.entity;
import java.util.Map;
import java.util.TreeMap;
import ai.preferred.cerebro.core.util.NumberUtils;
import ai.preferred.cerebro.core.util.StringUtils;
/**
* Parameter
* @author ddle.2015
*
*/
public class Parameter {
private Map<String, Object> params = new TreeMap<String, Object>();
public Map<String, Object> getParams() { return params; }
public void setParams(Map<String, Object> params) { this.params = params; }
public Parameter add(String key, Object value){
params.put(key, value);
return this;
}
public String getValueAsString(String key){
return StringUtils.parseString(params.get(key));
}
public String getValueAsString(String key, String defaultValue){
return StringUtils.parseString(params.get(key), defaultValue);
}
public int getValueAsInt(String key){
return NumberUtils.parseInt(params.get(key));
}
public int getValueAsInt(String key, int defaultValue){
return NumberUtils.parseInt(params.get(key), defaultValue);
}
public double getValueAsDouble(String key){
return NumberUtils.parseDouble(params.get(key));
}
public double getValueAsDouble(String key, double defaultValue){
return NumberUtils.parseDouble(params.get(key), defaultValue);
}
public long getValueAsLong(String key){
return NumberUtils.parseLong(params.get(key));
}
public long getValueAsLong(String key, long defaultValue){
return NumberUtils.parseLong(params.get(key), defaultValue);
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/entity/SparseVector.java
|
package ai.preferred.cerebro.core.entity;
import java.util.TreeMap;
import ai.preferred.cerebro.core.util.NumberUtils;
import ai.preferred.cerebro.core.util.StringUtils;
/**
* Sparse vector
* @author ddle.2015
*
*/
public class SparseVector extends AbstractVector {
private static final long serialVersionUID = 163539530080124298L;
private TreeMap<String, Double> elements = new TreeMap<String, Double>();
public SparseVector() {}
@Override
public void add(AbstractVector v) {
// Validate v
validateInput(v);
SparseVector v_cast = (SparseVector) v;
for(String v_key: v_cast.getElements().keySet()){
double val = 0;
if(elements.containsKey(v_key))
val = elements.get(v_key) + v_cast.getElements().get(v_key);
else val = v_cast.getElements().get(v_key);
elements.put(v_key, val);
}
}
@Override
public void divide(double c) {
if(c < 0)
throw new UnsupportedOperationException("The value should be possitive");
for(String key: elements.keySet()){
double val = elements.get(key);
elements.put(key, val/c);
}
}
@Override
public double innerProduct(AbstractVector v) {
// Validate v
validateInput(v);
SparseVector v_cast = (SparseVector) v;
double sum = 0.0;
for(String v_key: v_cast.getElements().keySet()){
if(elements.containsKey(v_key))
sum += elements.get(v_key) * v_cast.getElements().get(v_key);
}
return sum;
}
@Override
public int length() {
return elements.size();
}
@Override
public String toString(){
StringBuffer buffer = new StringBuffer();
int count = 0;
for(String key: elements.keySet()){
buffer.append(key).append(":").append(elements.get(key));
if(count < elements.size() - 1) buffer.append(",");
count++;
}
return buffer.toString();
}
@Override
public void validateInput(AbstractVector v){
if(!(v instanceof SparseVector))
throw new ClassCastException("The two vectors have different type");
}
@Override
public AbstractVector clone() {
SparseVector v = new SparseVector();
v.setElements(elements);
return v;
}
public static SparseVector convertFromString(String s) {
String[] els = s.split(",");
SparseVector v = new SparseVector();
TreeMap<String, Double> vals = new TreeMap<String, Double>();
for(String el: els){
String[] parts = el.split(":");
double val = NumberUtils.parseDouble(parts[1]);
vals.put(parts[0], val);
}
v.setElements(vals);
return v;
}
public TreeMap<String, Double> getElements() { return elements; }
public void setElements(TreeMap<String, Double> elements) { this.elements = elements;}
@Override
public void setElement(int index, double value) {
if(index >= elements.size())
throw new IndexOutOfBoundsException();
elements.put(StringUtils.parseString(index), value);
}
@Override
public double getElement(int index) {
if(index >= elements.size())
throw new IndexOutOfBoundsException();
return elements.get(StringUtils.parseString(index));
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/entity/TopKItem.java
|
package ai.preferred.cerebro.core.entity;
import java.io.Serializable;
/**
* Definition of a top-k item
* @author ddle.2015
*
*/
public class TopKItem implements Serializable{
private static final long serialVersionUID = 7606047916434415063L;
private String itemId;
private double score;
public TopKItem() {}
public TopKItem(String itemId, double score) {
super();
this.itemId = itemId;
this.score = score;
}
public String getItemId() { return itemId; }
public void setItemId(String itemId) { this.itemId = itemId; }
public double getScore() { return score; }
public void setScore(double score) { this.score = score; }
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa/entity/Feedback.java
|
package ai.preferred.cerebro.core.jpa.entity;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import ai.preferred.cerebro.core.entity.Parameter;
import ai.preferred.cerebro.core.util.StringUtils;
@NamedQueries({
@NamedQuery(name = Feedback.GET_FEEDBACK_BY_ID, query = "SELECT f FROM Feedback f "
+ "WHERE f.id = :id"),
@NamedQuery(name = Feedback.GET_ALL_FEEDBACK_BY_TYPE, query = "SELECT f FROM Feedback f "
+ "WHERE f.type = :type"),
@NamedQuery(name = Feedback.GET_ALL_FEEDBACK_BY_SESSION_ID_AND_TYPE, query = "SELECT f FROM Feedback f "
+ "WHERE f.sessionId = :sessionId "
+ "AND f.type = :type"),
@NamedQuery(name = Feedback.GET_ALL_FEEDBACK_BY_SESSION_ID, query = "SELECT f FROM Feedback f "
+ "WHERE f.sessionId = :sessionId"),
@NamedQuery(name = Feedback.GET_ALL_FEEDBACK_BY_SESSION_ID_AND_STATUS, query = "SELECT f FROM Feedback f "
+ "WHERE f.sessionId = :sessionId "
+ "AND f.status = :status"),
@NamedQuery(name = Feedback.UPDATE_FEEDBACK_STATUS_BY_ID, query = "UPDATE Feedback f "
+ "SET f.status = :status "
+ "WHERE f.id = :id")
})
@Entity
@Table(name = "tbl_feedback")
public class Feedback implements Serializable{
private static final long serialVersionUID = 4315689097886225189L;
public static final String GET_FEEDBACK_BY_ID = "GetFeedbackById";
public static final String GET_ALL_FEEDBACK_BY_TYPE = "GetAllFeedbackByType";
public static final String GET_ALL_FEEDBACK_BY_SESSION_ID_AND_TYPE = "GetAllFeedbackBySessionIdAndType";
public static final String GET_ALL_FEEDBACK_BY_SESSION_ID = "GetAllFeedbackBySessionId";
public static final String GET_ALL_FEEDBACK_BY_SESSION_ID_AND_STATUS = "GetAllFeedbackBySessionIdAndStatus";
public static final String UPDATE_FEEDBACK_STATUS_BY_ID = "UpdateFeedbackStatusById";
public static final int TYPE_CLICK = 0;
public static final int TYPE_FAVORITE = 1;
public static final int TYPE_RATE = 2;
public static final int TYPE_SEARCH = 3;
public static final int TYPE_ADD_TO_CART = 4;
public static final int TYPE_PURCHASE = 5;
public static final int TYPE_SELECT_BRAND=6;
public static final int TYPE_SELECT_PRODUCT=7;
public static final int TYPE_VIEW_HOMEPAGE=8;
public static final int STATUS_CHECKED = 0;
public static final int STATUS_UNCHECKED = 1;
@Id
@Column(name = "FeedbackId", nullable = false, length = 128)
private String id;
@Column(name = "SessionId", nullable = false, length = 128)
private String sessionId;
@Column(name = "Type", nullable = false, length = 11)
private int type;
@Column(name = "Object", nullable = false)
private String object;
@Column(name = "Metadata", nullable=true)
private String metadata;
@Column(name = "CreatedTime", nullable = true)
@Temporal(value = TemporalType.TIMESTAMP)
private Date createdTime;
@Column(name = "Status", nullable = false, length = 11)
private int status;
public Feedback(){}
public Feedback(String id, String sessionId, int type, String object, String metadata) {
this(id, sessionId, type, object, metadata, new Date(), STATUS_UNCHECKED);
}
public Feedback(String id, String sessionId, int type, String object, String metadata, Date createdTime, int status) {
super();
this.id = id;
this.sessionId = sessionId;
this.type = type;
this.object = object;
this.metadata = metadata;
this.createdTime = createdTime;
this.status = status;
}
public String getId() { return id; }
public void setId(String id) { this.id = id; }
public String getSessionId() { return sessionId; }
public void setSessionId(String sessionId) { this.sessionId = sessionId; }
public int getType() { return type; }
public void setType(int type) { this.type = type; }
public String getObject() { return object;}
public void setObject(String object) { this.object = object; }
public String getMetadata() { return metadata; }
public void setMetadata(String metadata) { this.metadata = metadata; }
public Date getCreatedTime() { return createdTime; }
public void setCreatedTime(Date createdTime) { this.createdTime = createdTime;}
public int getStatus() { return status; }
public void setStatus(int status) { this.status = status; }
public Parameter getMetadataAsParams(){
Parameter params = new Parameter();
String[] attrs = StringUtils.explode(this.metadata, ',');
for(String attr: attrs){
String[] parts = StringUtils.explode(attr, "[:]");
params.add(parts[0], parts[1]);
}
return params;
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa/entity/IndexMetadata.java
|
package ai.preferred.cerebro.core.jpa.entity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
@NamedQueries({
@NamedQuery(name = IndexMetadata.GET_INDEX_METADATA_BY_ID, query = "SELECT im FROM IndexMetadata im "
+ "WHERE im.id = :id"),
@NamedQuery(name = IndexMetadata.GET_LIST_INDEX_METADATA_BY_MODEL_CODE, query = "SELECT im FROM IndexMetadata im "
+ "WHERE im.model.modelCode = :modelCode"),
@NamedQuery(name = IndexMetadata.GET_LIST_INDEX_METADATA_BY_TYPE_ID, query = "SELECT im FROM IndexMetadata im "
+ "WHERE im.type.id = :typeId")})
@Entity
@Table(name = "tbl_index")
public class IndexMetadata implements Serializable {
private static final long serialVersionUID = 4446729250740301382L;
public static final String GET_INDEX_METADATA_BY_ID = "GetIndexMetadataById";
public static final String GET_LIST_INDEX_METADATA_BY_MODEL_CODE = "GetListIndexMetadataByModelCode";
public static final String GET_LIST_INDEX_METADATA_BY_TYPE_ID = "GetListIndexMetadataByTypeId";
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "Id", nullable = false, length = 11)
private int id;
@Column(name = "Name", nullable = false, length = 32)
private String name;
@ManyToOne(targetEntity = Model.class)
@JoinColumn(name = "ModelId", referencedColumnName = "ModelId", nullable = false)
private Model model;
@ManyToOne(targetEntity = IndexType.class)
@JoinColumn(name = "IndexTypeId", referencedColumnName = "Id", nullable = false)
private IndexType type;
@Column(name = "Settings", nullable = false, length = 255)
private String settings;
@Column(name = "IndexPath", nullable = false, length = 255)
private String indexPath;
@Column(name = "SupporterPath", length = 255)
private String supporterPath;
@Column(name = "Status", nullable = false, length = 11)
private int status;
public IndexMetadata(){}
public IndexMetadata(Model model, IndexType type, String settings, String indexPath, String supporterPath, int status) {
this("NA", model, type, settings, indexPath, supporterPath, status);
}
public IndexMetadata(String name, Model model, IndexType type, String settings, String indexPath, String supporterPath, int status) {
super();
this.name = name;
this.model = model;
this.type = type;
this.settings = settings;
this.indexPath = indexPath;
this.supporterPath = supporterPath;
this.status = status;
}
public int getId() { return id; }
public void setId(int id) { this.id = id; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public Model getModel() { return model; }
public void setModel(Model model) { this.model = model; }
public IndexType getType() { return type; }
public void setType(IndexType type) { this.type = type; }
public String getSettings() { return settings; }
public void setSettings(String settings) { this.settings = settings; }
public String getIndexPath() { return indexPath;}
public void setIndexPath(String indexPath) { this.indexPath = indexPath;}
public String getSupporterPath() { return supporterPath; }
public void setSupporterPath(String supporterPath) { this.supporterPath = supporterPath; }
public int getStatus() { return status; }
public void setStatus(int status) { this.status = status; }
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa/entity/IndexType.java
|
package ai.preferred.cerebro.core.jpa.entity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
@NamedQueries({
@NamedQuery(name = IndexType.GET_ALL_INDEX_TYPE, query = "SELECT it FROM IndexType it"),
@NamedQuery(name = IndexType.GET_INDEX_TYPE_BY_ID, query = "SELECT it FROM IndexType it "
+ "WHERE it.id = :typeId")})
@Entity
@Table(name = "tbl_indextype")
public class IndexType implements Serializable {
private static final long serialVersionUID = 8912126496605092997L;
public static final String GET_ALL_INDEX_TYPE = "GetAllIndexType";
public static final String GET_INDEX_TYPE_BY_ID = "GetIndexTypeById";
public static final int TYPE_EXHAUSTIVE = 0;
public static final int TYPE_LSH = 1;
public static final int TYPE_INVERTED = 2;
@Id
@Column(name = "Id", nullable = false, length = 11)
private int id;
@Column(name = "Type", nullable = false, length = 256)
private String type;
@Column(name = "Status", nullable = false, length = 11)
private int status;
public IndexType(){}
public IndexType(String type) {
super();
this.type = type;
}
public int getId() { return id; }
public void setId(int id) { this.id = id; }
public String getType() { return type; }
public void setType(String type) { this.type = type; }
public int getStatus() { return status; }
public void setStatus(int status) { this.status = status; }
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa/entity/ItemModel.java
|
package ai.preferred.cerebro.core.jpa.entity;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@NamedQueries({
@NamedQuery(name = ItemModel.GET_ALL_ITEM_MODEL_BY_MODEL_ID, query = "SELECT im FROM ItemModel im "
+ "WHERE im.model.modelId = :modelId"),
@NamedQuery(name = ItemModel.GET_ITEM_MODEL_BY_ITEM_ID_AND_MODEL_ID, query = "SELECT im FROM ItemModel im "
+ "WHERE im.itemId = :itemId "
+ "AND im.model.modelId = :modelId")})
@Entity
@Table(name = "tbl_itemmodel")
@IdClass(ItemModelId.class)
public class ItemModel implements Serializable {
private static final long serialVersionUID = -2031908364586239883L;
public static final String GET_ALL_ITEM_MODEL_BY_MODEL_ID = "GetAllItemModelByModeId";
public static final String GET_ITEM_MODEL_BY_ITEM_ID_AND_MODEL_ID = "GetItemModelByItemIdAndModeId";
@Id
@Column(name = "ItemId", nullable = false, length = 128)
private String itemId;
@Id
@ManyToOne(targetEntity = Model.class)
@JoinColumn(name = "ModelId", referencedColumnName = "ModelId", nullable = false)
private Model model;
@Column(name = "Representation", nullable = false)
private String representation;
@Column(name = "UpdatedTime", nullable = true)
@Temporal(value = TemporalType.TIMESTAMP)
private Date updatedTime;
@Column(name = "Status", nullable = false, length = 11)
private int status;
public ItemModel(){}
public ItemModel(Model model, String itemId, String representation, Date updatedTime, int status) {
super();
this.model = model;
this.itemId = itemId;
this.representation = representation;
this.updatedTime = updatedTime;
this.status = status;
}
public String getItemId() { return itemId; }
public void setItemId(String itemId) { this.itemId = itemId; }
public Model getModel() { return model; }
public void setModel(Model model) { this.model = model; }
public String getRepresentation() { return representation; }
public void setRepresentation(String representation) { this.representation = representation; }
public Date getUpdatedTime() { return updatedTime; }
public void setUpdatedTime(Date updatedTime) { this.updatedTime = updatedTime; }
public int getStatus() { return status; }
public void setStatus(int status) { this.status = status; }
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa/entity/ItemModelId.java
|
package ai.preferred.cerebro.core.jpa.entity;
import java.io.Serializable;
import ai.preferred.cerebro.core.util.StringUtils;
public class ItemModelId implements Serializable{
private static final long serialVersionUID = 1565499982993981436L;
private String itemId;
private int model;
public ItemModelId() {}
public ItemModelId(String itemId, int modelId) {
super();
this.itemId = itemId;
this.model = modelId;
}
public String getItemId() { return itemId; }
public void setItemId(String itemId) { this.itemId = itemId; }
public int getModel() { return model; }
public void setModel(int model) { this.model = model; }
@Override
public boolean equals(Object obj) {
if(obj instanceof ItemModelId) {
ItemModelId id = (ItemModelId) obj;
return StringUtils.areEqual(itemId, id.getItemId()) && model == id.getModel();
}
return false;
}
@Override
public int hashCode() {
return itemId.hashCode() + model;
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa/entity/Model.java
|
package ai.preferred.cerebro.core.jpa.entity;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import ai.preferred.cerebro.core.entity.Parameter;
import ai.preferred.cerebro.core.util.StringUtils;
@NamedQueries({
@NamedQuery(name = Model.GET_MODEL_BY_CODE, query = "SELECT m FROM Model m "
+ "WHERE m.modelCode = :modelCode"),
@NamedQuery(name = Model.GET_MODEL_BY_ID, query = "SELECT m FROM Model m "
+ "WHERE m.modelId = :modelId")
})
@Entity
@Table(name = "tbl_model")
public class Model implements Serializable {
private static final long serialVersionUID = 6783646528264205835L;
public static final String GET_MODEL_BY_ID = "GetModelById";
public static final String GET_MODEL_BY_CODE = "GetModelByCode";
public static final String MODEL_CODE_PMF = "pmf";
public static final String MODEL_CODE_IPBR = "ibpr";
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ModelId", nullable = false)
private int modelId;
@Column(name = "ModelCode", nullable = false, length = 32)
private String modelCode;
@Column(name = "Description", nullable = true, length = 128)
private String description;
@Column(name = "UseDenseVector", nullable = false, columnDefinition = "TINYINT(1)")
private boolean useDenseVector;
@Column(name = "Setting", nullable = false)
private String setting;
@Column(name = "CreatedTime", nullable = true)
@Temporal(value = TemporalType.TIMESTAMP)
private Date createdTime;
@Column(name = "Status", nullable = false, length = 11)
private int status;
public Model(){}
public Model(String modelCode, String description, boolean useDenseVector,
String setting, Date createdTime, int status) {
super();
this.modelCode = modelCode;
this.description = description;
this.useDenseVector = useDenseVector;
this.setting = setting;
this.createdTime = createdTime;
this.status = status;
}
public int getModelId() { return modelId; }
public void setModelId(int modelId) { this.modelId = modelId; }
public String getModelCode() { return modelCode; }
public void setModelCode(String modelCode) { this.modelCode = modelCode; }
public String getDescription() { return description; }
public void setDescription(String description) { this.description = description; }
public boolean useDenseVector() { return useDenseVector; }
public void setUseDenseVector(boolean useDenseVector) { this.useDenseVector = useDenseVector;}
public String getSetting() { return setting; }
public void setSetting(String setting) { this.setting = setting; }
public Date getCreatedTime() { return createdTime; }
public void setCreatedTime(Date createdTime) { this.createdTime = createdTime; }
public int getStatus() { return status; }
public void setStatus(int status) { this.status = status; }
public Parameter getSettingAsParams(){
Parameter params = new Parameter();
String[] attrs = StringUtils.explode(setting, ',');
for(String attr: attrs){
String[] parts = StringUtils.explode(attr, "[:]");
params.add(parts[0], parts[1]);
}
return params;
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa/entity/Session.java
|
package ai.preferred.cerebro.core.jpa.entity;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;
@NamedQueries({
@NamedQuery(name = Session.GET_SESSION_BY_SESSION_ID, query = "SELECT s FROM Session s "
+ "WHERE s.sessionId = :sessionId"),
@NamedQuery(name = Session.GET_ALL_TIMEOUT_SESSION_BY_USER_ID, query = "SELECT s FROM Session s "
+ "WHERE s.userId = :userId "
+ "AND s.status = 1"),
@NamedQuery(name = Session.QUERY_UPDATE_SESSION, query = "UPDATE Session s "
+ "SET s.lastActivityTime = :lastActivityTime "
+ "WHERE s.sessionId = :sessionId"),
@NamedQuery(name = Session.QUERY_CLEAN_SESSION, query = "UPDATE Session s "
+ "SET s.status=" + Session.STATUS_TIMEOUT + " "
+ "WHERE s.lastActivityTime < :expireTime") })
@Entity
@Table(name = "tbl_session")
public class Session implements Serializable {
private static final long serialVersionUID = -4845224462796531712L;
public static final String GET_SESSION_BY_SESSION_ID = "GetSessionBySessionId";
public static final String GET_ALL_TIMEOUT_SESSION_BY_USER_ID = "GetAllTimeOutSessionByUserId";
public static final String QUERY_UPDATE_SESSION = "updateSession";
public static final String QUERY_CLEAN_SESSION = "cleanSession";
public static final int STATUS_NORMAL = 0;
public static final int STATUS_TIMEOUT = 1;
@Id
@Column(name = "SessionId", nullable = false, length = 100)
private String sessionId;
@Column(name = "UserId", nullable = false)
private String userId;
@Column(name = "ClientId", nullable = true, length = 255)
private String clientId;
@Column(name = "Ip", nullable = true, length = 255)
private String ip;
@Column(name = "Location", nullable = true, length = 255)
private String location;
@Column(name = "Device", nullable = true, length = 255)
private String device;
@Version
@Column(name = "Version", nullable = false, length = 11)
private int version;
@Column(name = "LastActivityTime", nullable = true)
@Temporal(value = TemporalType.TIMESTAMP)
private java.util.Date lastActivityTime;
@Column(name = "Status", nullable = false, length = 11)
private int status;
public Session(){}
public Session(String sessionId, String userId, String clientId, String ip, String location, String device,
Date lastActivityTime, int status) {
super();
this.sessionId = sessionId;
this.userId = userId;
this.clientId = clientId;
this.ip = ip;
this.location = location;
this.device = device;
this.lastActivityTime = lastActivityTime;
this.version = 1;
this.status = status;
}
public void setSessionId(String value) { this.sessionId = value; }
public String getSessionId() { return sessionId; }
public void setUserId(String value) { this.userId = value; }
public String getUserId() { return userId; }
public void setClientId(String value) { this.clientId = value; }
public String getClientId() { return clientId; }
public void setIp(String value) { this.ip = value; }
public String getIp() { return ip; }
public void setLocation(String value) { this.location = value; }
public String getLocation() { return location; }
public void setDevice(String value) { this.device = value; }
public String getDevice() { return device; }
public void setLastActivityTime(Date value) { this.lastActivityTime = value; }
public Date getLastActivityTime() { return lastActivityTime; }
public int getVersion() { return version; }
public void setVersion(int version) { this.version = version; }
public void setStatus(int value) { this.status = value; }
public int getStatus() { return status; }
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa/entity/UserModel.java
|
package ai.preferred.cerebro.core.jpa.entity;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@NamedQueries({
@NamedQuery(name = UserModel.GET_ALL_USER_MODEL_BY_MODEL_ID, query = "SELECT um FROM UserModel um "
+ "WHERE um.model.modelId = :modelId"),
@NamedQuery(name = UserModel.GET_USER_MODEL_BY_USER_ID, query = "SELECT um FROM UserModel um "
+ "WHERE um.userId = :userId"),
@NamedQuery(name = UserModel.GET_USER_MODEL_BY_USER_ID_AND_MODEL_ID, query = "SELECT um FROM UserModel um "
+ "WHERE um.userId = :userId "
+ "AND um.model.modelId = :modelId"),
@NamedQuery(name = UserModel.GET_RANDOM_USERID, query = "SELECT um.userId FROM UserModel um "
+ "ORDER BY function('RAND')")})
@Entity
@Table(name = "tbl_usermodel")
@IdClass(UserModelId.class)
public class UserModel implements Serializable {
private static final long serialVersionUID = -2031908364586239883L;
public static final String GET_ALL_USER_MODEL_BY_MODEL_ID = "GetAllUserModelByModelId";
public static final String GET_USER_MODEL_BY_USER_ID = "GetUserModelByUserId";
public static final String GET_USER_MODEL_BY_USER_ID_AND_MODEL_ID = "GetUserModelByUserIdAndModelId";
public static final String GET_RANDOM_USERID = "GetRandomUserId";
@Id
@Column(name = "UserId", nullable = false)
private String userId;
@Id
@ManyToOne(targetEntity = Model.class)
@JoinColumn(name = "ModelId", referencedColumnName = "ModelId", nullable = false)
private Model model;
@Column(name = "Representation", nullable = false)
private String representation;
@Column(name = "UpdatedTime", nullable = true)
@Temporal(value = TemporalType.TIMESTAMP)
private Date updatedTime;
@Column(name = "Status", nullable = false, length = 11)
private int status;
public UserModel(){}
public UserModel(Model model, String userId, String representation, Date updatedTime, int status) {
super();
this.model = model;
this.userId = userId;
this.representation = representation;
this.updatedTime = updatedTime;
this.status = status;
}
public String getUserId() { return userId; }
public void setUserId(String userId) { this.userId = userId; }
public Model getModel() { return model; }
public void setModel(Model model) { this.model = model; }
public String getRepresentation() { return representation; }
public void setRepresentation(String representation) { this.representation = representation; }
public Date getUpdatedTime() { return updatedTime; }
public void setUpdatedTime(Date updatedTime) { this.updatedTime = updatedTime; }
public int getStatus() { return status; }
public void setStatus(int status) { this.status = status; }
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa/entity/UserModelId.java
|
package ai.preferred.cerebro.core.jpa.entity;
import java.io.Serializable;
import ai.preferred.cerebro.core.util.StringUtils;
public class UserModelId implements Serializable {
private static final long serialVersionUID = 8694739860356797551L;
private String userId;
private int model;
public UserModelId() {}
public UserModelId(String itemId, int modelId) {
super();
this.userId = itemId;
this.model = modelId;
}
public String getUserId() { return userId; }
public void setUserId(String userId) { this.userId = userId; }
public int getModel() { return model; }
public void setModel(int model) { this.model = model; }
@Override
public boolean equals(Object obj) {
if(obj instanceof UserModelId) {
UserModelId id = (UserModelId) obj;
return StringUtils.areEqual(userId, id.getUserId()) && model == id.getModel();
}
return false;
}
@Override
public int hashCode() {
return userId.hashCode() + model;
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa/entity/UserProfile.java
|
package ai.preferred.cerebro.core.jpa.entity;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@NamedQueries({
@NamedQuery(name = UserProfile.QUERY_GET_ALL_USER_PROFILES, query = "SELECT u FROM UserProfile u" + " WHERE u.status=0"),
@NamedQuery(name = UserProfile.QUERY_GET_USER_PROFILE_BY_USERNAME, query = "SELECT u" + " FROM UserProfile u" + " WHERE u.username=:username"),
@NamedQuery(name = UserProfile.QUERY_GET_USER_PROFILE_BY_USER_ID, query = "SELECT u" + " FROM UserProfile u" + " WHERE u.userId=:userId"),
@NamedQuery(name = UserProfile.QUERY_GET_USER_PROFILE_BY_EMAIL, query = "SELECT u" + " FROM UserProfile u" + " WHERE u.email=:email"),
@NamedQuery(name = UserProfile.QUERY_GET_USER_PROFILE_BY_PHONE, query = "SELECT u" + " FROM UserProfile u" + " WHERE u.phone=:phone")
})
@Entity
@Table(name = "tbl_userprofile")
public class UserProfile implements Serializable {
private static final long serialVersionUID = -9154967562173683888L;
public static final String QUERY_GET_ALL_USER_PROFILES = "GetAllUserProfiles";
public static final String QUERY_GET_USER_PROFILE_BY_USERNAME = "GetUserProfileByUsername";
public static final String QUERY_GET_USER_PROFILE_BY_USER_ID = "GetUserProfileByProfileId";
public static final String QUERY_GET_USER_PROFILE_BY_EMAIL = "GetUserProfileByEmail";
public static final String QUERY_GET_USER_PROFILE_BY_PHONE = "GetUserProfileByPhone";
public static final int USER_NOT_ACTIVATED = 0;
public static final int USER_ACTIVATED = 1;
public static final int USER_STATUS_NORMAL = 0;
public static final int USER_STATUS_NEED_UPDATE = 1;
public static final int USER_TYPE_ADMINISTATOR = 1;
public static final int USER_TYPE_NORMAL = 0;
public static final int USER_GENDER_FEMALE = 0;
public static final int USER_GENDER_MALE = 1;
@Id
@Column(name = "UserId", nullable = false, length = 255)
private String userId;
@Column(name = "Username", nullable = false, length = 128)
private String username;
@Column(name = "Password", nullable = false, length = 255)
private String password;
@Column(name = "Name", nullable = true, length = 255)
private String name;
@Column(name = "Gender", nullable = true, length = 11)
private int gender;
@Column(name = "Email", nullable = true, length = 255)
private String email;
@Column(name = "Phone", nullable = true, length = 32)
private String phone;
@Column(name = "Photo")
private String photo;
@Column(name = "Language", nullable = true, length = 32)
private String language;
@Column(name = "UserType", nullable = false, length = 11)
private int userType;
@Column(name = "Activation", nullable = false, length = 11)
private int activation;
@Column(name = "LastActiveTime", nullable = true)
@Temporal(value = TemporalType.TIMESTAMP)
private Date lastActiveTime;
@Column(name = "Status", nullable = false, length = 11)
private int status;
public UserProfile() {}
public UserProfile(String userId, String username, String password, String name, int gender, String email, String phone, String photo,
String language, int userType, int activation, Date lastActiveTime, int status) {
super();
this.userId = userId;
this.username = username;
this.password = password;
this.name = name;
this.gender = gender;
this.email = email;
this.phone = phone;
this.photo = photo;
this.language = language;
this.userType = userType;
this.activation = activation;
this.lastActiveTime = lastActiveTime;
this.status = status;
}
public String getUserId() { return userId; }
public void setUserId(String userId) { this.userId = userId; }
public String getUsername() { return username; }
public void setUsername(String username) { this.username = username; }
public String getPassword() { return password; }
public void setPassword(String password) { this.password = password; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public int getUserType() { return userType; }
public void setUserType(int userType) { this.userType = userType; }
public int getGender() { return gender; }
public void setGender(int gender) { this.gender = gender; }
public String getEmail() { return email; }
public void setEmail(String email) { this.email = email; }
public String getPhone() { return phone; }
public void setPhone(String phone) { this.phone = phone; }
public String getPhoto() { return photo; }
public void setPhoto(String photo) { this.photo = photo; }
public String getLanguage() { return language; }
public void setLanguage(String language) { this.language = language; }
public int getActivation() { return activation; }
public void setActivation(int activation) { this.activation = activation; }
public Date getLastActiveTime() { return lastActiveTime; }
public void setLastActiveTime(Date lastActiveTime) { this.lastActiveTime = lastActiveTime; }
public int getStatus() { return status; }
public void setStatus(int status) { this.status = status; }
public String toString() {
return String.valueOf(getUserId());
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa/entitymanager/AbstractManager.java
|
package ai.preferred.cerebro.core.jpa.entitymanager;
import javax.persistence.EntityManager;
import javax.persistence.Query;
public abstract class AbstractManager<E> {
protected EntityManager entityManager;
public AbstractManager(EntityManager entityManager) {
this.entityManager = entityManager;
}
public void persist(E e) {
if(!entityManager.getTransaction().isActive())
entityManager.getTransaction().begin();
entityManager.persist(e);
entityManager.flush();
entityManager.getTransaction().commit();
}
@SuppressWarnings("unchecked")
public void persist(E... objects) {
if(!entityManager.getTransaction().isActive())
entityManager.getTransaction().begin();
for (Object object : objects) {
entityManager.persist(object);
}
entityManager.flush();
entityManager.getTransaction().commit();
}
public void merge(E e) {
if(!entityManager.getTransaction().isActive())
entityManager.getTransaction().begin();
// entityManager.lock(e, LockModeType.OPTIMISTIC);
entityManager.merge(e);
entityManager.flush();
// entityManager.lock(e, LockModeType.NONE);
entityManager.getTransaction().commit();
}
public void refresh(E e) {
entityManager.refresh(e);
}
public void remove(E e) {
if(!entityManager.getTransaction().isActive())
entityManager.getTransaction().begin();
entityManager.remove(e);
entityManager.flush();
entityManager.getTransaction().commit();
}
public void detach(E e) {
entityManager.detach(e);
}
public void executeQuery(Query query) {
if(!entityManager.getTransaction().isActive())
entityManager.getTransaction().begin();
query.executeUpdate();
entityManager.flush();
entityManager.getTransaction().commit();
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa/entitymanager/FeedbackManager.java
|
package ai.preferred.cerebro.core.jpa.entitymanager;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import ai.preferred.cerebro.core.jpa.entity.Feedback;
import ai.preferred.cerebro.core.jpa.util.QueryUtils;
public class FeedbackManager extends AbstractManager<Feedback> {
public FeedbackManager(EntityManager entityManager) {
super(entityManager);
}
public Feedback getFeedbacklById(String id){
Query query = entityManager .createNamedQuery(Feedback.GET_FEEDBACK_BY_ID);
query.setParameter("id", id);
return QueryUtils.getSingleResult(query);
}
public List<Feedback> getAllFeedbackByType(int type){
Query query = entityManager .createNamedQuery(Feedback.GET_ALL_FEEDBACK_BY_TYPE);
query.setParameter("type", type);
return QueryUtils.getResultList(query);
}
public List<Feedback> getAllFeedbackBySessionIdAndType(String sessionId, int type){
Query query = entityManager .createNamedQuery(Feedback.GET_ALL_FEEDBACK_BY_SESSION_ID_AND_TYPE);
query.setParameter("sessionId", sessionId);
query.setParameter("type", type);
return QueryUtils.getResultList(query);
}
public List<Feedback> getAllFeedbackBySessionId(String sessionId){
Query query = entityManager .createNamedQuery(Feedback.GET_ALL_FEEDBACK_BY_SESSION_ID);
query.setParameter("sessionId", sessionId);
return QueryUtils.getResultList(query);
}
public List<Feedback> getAllFeedbackBySessionIdAndStatus(String sessionId, int status){
Query query = entityManager .createNamedQuery(Feedback.GET_ALL_FEEDBACK_BY_SESSION_ID_AND_STATUS);
query.setParameter("sessionId", sessionId);
query.setParameter("status", status);
return QueryUtils.getResultList(query);
}
public void updateFeedbackStatusById(String id, int status) {
Query query = entityManager .createNamedQuery(Feedback.UPDATE_FEEDBACK_STATUS_BY_ID);
query.setParameter("id", id);
query.setParameter("status", status);
executeQuery(query);
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa/entitymanager/IndexMetadataManager.java
|
package ai.preferred.cerebro.core.jpa.entitymanager;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import ai.preferred.cerebro.core.jpa.entity.IndexMetadata;
import ai.preferred.cerebro.core.jpa.util.QueryUtils;
public class IndexMetadataManager extends AbstractManager<IndexMetadata> {
public IndexMetadataManager(EntityManager entityManager) {
super(entityManager);
}
public IndexMetadata getIndexMetadataById(int id){
Query query = entityManager
.createNamedQuery(IndexMetadata.GET_INDEX_METADATA_BY_ID);
query.setParameter("id", id);
return QueryUtils.getSingleResult(query);
}
public List<IndexMetadata> getListIndexMetadataByModelCode(String modelCode){
Query query = entityManager
.createNamedQuery(IndexMetadata.GET_LIST_INDEX_METADATA_BY_MODEL_CODE);
query.setParameter("modelCode", modelCode);
return QueryUtils.getResultList(query);
}
public List<IndexMetadata> getListIndexMetadataByIndexType(int typeId){
Query query = entityManager
.createNamedQuery(IndexMetadata.GET_LIST_INDEX_METADATA_BY_TYPE_ID);
query.setParameter("typeId", typeId);
return QueryUtils.getResultList(query);
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa/entitymanager/IndexTypeManager.java
|
package ai.preferred.cerebro.core.jpa.entitymanager;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import ai.preferred.cerebro.core.jpa.entity.IndexType;
import ai.preferred.cerebro.core.jpa.util.QueryUtils;
public class IndexTypeManager extends AbstractManager<IndexType> {
public IndexTypeManager(EntityManager entityManager) {
super(entityManager);
}
public List<IndexType> getAllIndexType(){
Query query = entityManager
.createNamedQuery(IndexType.GET_ALL_INDEX_TYPE);
return QueryUtils.getResultList(query);
}
public IndexType getIndexTypeById(String typeId){
Query query = entityManager
.createNamedQuery(IndexType.GET_INDEX_TYPE_BY_ID);
query.setParameter("typeId", typeId);
return QueryUtils.getSingleResult(query);
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa/entitymanager/ItemModelManager.java
|
package ai.preferred.cerebro.core.jpa.entitymanager;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import ai.preferred.cerebro.core.jpa.entity.ItemModel;
import ai.preferred.cerebro.core.jpa.util.QueryUtils;
public class ItemModelManager extends AbstractManager<ItemModel> {
public ItemModelManager(EntityManager entityManager) {
super(entityManager);
}
public List<ItemModel> getAllItemModelByModelId(int modelId){
Query query = entityManager
.createNamedQuery(ItemModel.GET_ALL_ITEM_MODEL_BY_MODEL_ID);
query.setParameter("modelId", modelId);
return QueryUtils.getResultList(query);
}
public ItemModel getItemModelByItemIdAndModelId(String itemId, int modelId){
Query query = entityManager
.createNamedQuery(ItemModel.GET_ITEM_MODEL_BY_ITEM_ID_AND_MODEL_ID);
query.setParameter("itemId", itemId);
query.setParameter("modelId", modelId);
return QueryUtils.getSingleResult(query);
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa/entitymanager/ModelManager.java
|
package ai.preferred.cerebro.core.jpa.entitymanager;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import ai.preferred.cerebro.core.jpa.entity.Model;
import ai.preferred.cerebro.core.jpa.util.QueryUtils;
public class ModelManager extends AbstractManager<Model> {
public ModelManager(EntityManager entityManager) {
super(entityManager);
}
public Model getModelById(int modelId){
Query query = entityManager
.createNamedQuery(Model.GET_MODEL_BY_ID);
query.setParameter("modelId", modelId);
return QueryUtils.getSingleResult(query);
}
public Model getModelByCode(String modelCode){
Query query = entityManager
.createNamedQuery(Model.GET_MODEL_BY_CODE);
query.setParameter("modelCode", modelCode);
return QueryUtils.getSingleResult(query);
}
public boolean useDenseVector(int modelId){
return getModelById(modelId).useDenseVector();
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa/entitymanager/SessionManager.java
|
package ai.preferred.cerebro.core.jpa.entitymanager;
import java.util.Date;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.persistence.TemporalType;
import ai.preferred.cerebro.core.jpa.entity.Session;
import ai.preferred.cerebro.core.jpa.util.QueryUtils;
import ai.preferred.cerebro.core.jpa.util.UUIDUtils;
import ai.preferred.cerebro.core.util.DateUtils;
public class SessionManager extends AbstractManager<Session> {
public SessionManager(EntityManager entityManager) {
super(entityManager);
}
public Session getSession(String sessionId) {
Query query = entityManager
.createNamedQuery(Session.GET_SESSION_BY_SESSION_ID);
query.setParameter("sessionId", sessionId);
return QueryUtils.getSingleResult(query);
}
public List<Session> getAllTimeOutSessionByUserId(String userId){
Query query = entityManager
.createNamedQuery(Session.GET_ALL_TIMEOUT_SESSION_BY_USER_ID);
query.setParameter("userId", userId);
return QueryUtils.getResultList(query);
}
public Session createSession(String userId, String device, String ip, String location) {
Session session = new Session();
session.setSessionId(UUIDUtils.newPlainUUIDString());
session.setUserId(userId);
session.setDevice(device);
session.setIp(ip);
session.setLocation(location);
session.setLastActivityTime(new Date());
session.setStatus(Session.STATUS_NORMAL);
return session;
}
public Session validateSession(String sessionId, int timeoutMinutes, String lastRequestAction) {
Session session = getSession(sessionId);
if (session == null)
return null;
if (session.getLastActivityTime().before(DateUtils.addSeconds(new Date(), 0 - timeoutMinutes*60))) {
remove(session);
return null;
}
session.setLastActivityTime(new Date());
// try {
// merge(session);
// } catch (Exception ex) {ex.printStackTrace();}
//
return session;
}
public void cleanSession(Date expireTime) {
Query query = entityManager
.createNamedQuery(Session.QUERY_CLEAN_SESSION);
query.setParameter("expireTime", expireTime, TemporalType.TIMESTAMP);
executeQuery(query);
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa/entitymanager/UserModelManager.java
|
package ai.preferred.cerebro.core.jpa.entitymanager;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import ai.preferred.cerebro.core.jpa.entity.UserModel;
import ai.preferred.cerebro.core.jpa.util.QueryUtils;
public class UserModelManager extends AbstractManager<UserModel> {
public UserModelManager(EntityManager entityManager) {
super(entityManager);
}
public List<UserModel> getAllUserModelByModelId(int modelId){
Query query = entityManager
.createNamedQuery(UserModel.GET_ALL_USER_MODEL_BY_MODEL_ID);
query.setParameter("modelId", modelId);
return QueryUtils.getResultList(query);
}
public List<UserModel> getUserModelByUserId(String userId){
Query query = entityManager
.createNamedQuery(UserModel.GET_USER_MODEL_BY_USER_ID_AND_MODEL_ID);
query.setParameter("userId", userId);
return QueryUtils.getResultList(query);
}
public UserModel getUserModelByUserIdAndModelId(String userId, int modelId){
Query query = entityManager
.createNamedQuery(UserModel.GET_USER_MODEL_BY_USER_ID_AND_MODEL_ID);
query.setParameter("userId", userId);
query.setParameter("modelId", modelId);
return QueryUtils.getSingleResult(query);
}
public boolean exist(String userId) {
return !getUserModelByUserId(userId).isEmpty();
}
public String getRandomUserId() {
Query query = entityManager
.createNamedQuery(UserModel.GET_RANDOM_USERID);
query.setMaxResults(1);
return QueryUtils.getSingleResult(query);
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa/entitymanager/UserProfileManager.java
|
package ai.preferred.cerebro.core.jpa.entitymanager;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import ai.preferred.cerebro.core.jpa.entity.UserProfile;
import ai.preferred.cerebro.core.jpa.util.QueryUtils;
public class UserProfileManager extends AbstractManager<UserProfile> {
public UserProfileManager(EntityManager entityManager) {
super(entityManager);
}
public List<UserProfile> getAllUserProfiles(){
Query query = entityManager.createNamedQuery(UserProfile.QUERY_GET_ALL_USER_PROFILES);
return QueryUtils.getResultList(query);
}
public UserProfile getUserProfileById(String userId){
Query query = entityManager
.createNamedQuery(UserProfile.QUERY_GET_USER_PROFILE_BY_USER_ID);
query.setParameter("userId", userId);
return QueryUtils.getSingleResult(query);
}
public UserProfile getUserProfileByUserName(String userName){
Query query = entityManager
.createNamedQuery(UserProfile.QUERY_GET_USER_PROFILE_BY_USERNAME);
query.setParameter("username", userName);
return QueryUtils.getSingleResult(query);
}
public UserProfile getUserProfileByEmail(String email){
Query query = entityManager
.createNamedQuery(UserProfile.QUERY_GET_USER_PROFILE_BY_EMAIL);
query.setParameter("email", email);
return QueryUtils.getSingleResult(query);
}
public UserProfile getUserProfileByPhone(String phone){
Query query = entityManager
.createNamedQuery(UserProfile.QUERY_GET_USER_PROFILE_BY_PHONE);
query.setParameter("phone", phone);
return QueryUtils.getSingleResult(query);
}
public boolean isExisted(String userId){
return (getUserProfileById(userId) != null);
}
public boolean isActivated(String userId) {
UserProfile u = getUserProfileById(userId);
if(u == null) return false;
return u.getActivation() == UserProfile.USER_ACTIVATED;
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa/util/LatentVectorUtils.java
|
package ai.preferred.cerebro.core.jpa.util;
import ai.preferred.cerebro.core.entity.AbstractVector;
import ai.preferred.cerebro.core.entity.DenseVector;
import ai.preferred.cerebro.core.entity.SparseVector;
import ai.preferred.cerebro.core.jpa.entity.ItemModel;
import ai.preferred.cerebro.core.jpa.entitymanager.ItemModelManager;
import ai.preferred.cerebro.core.jpa.entitymanager.ModelManager;
public class LatentVectorUtils {
public static AbstractVector getItemLatentVector(String itemId, int modelId) {
ModelManager modelManager = new ModelManager(PersistenceUtils.getEntityManager());
boolean useDenseVector = modelManager.useDenseVector(modelId);
ItemModelManager itemModelManager = new ItemModelManager(PersistenceUtils.getEntityManager());
ItemModel im = itemModelManager.getItemModelByItemIdAndModelId(itemId, modelId);
return convertToLatentVector(useDenseVector, im.getRepresentation());
}
public static AbstractVector convertToLatentVector(boolean isDenseVector, String s) {
if(isDenseVector) return DenseVector.convertFromString(s);
return SparseVector.convertFromString(s);
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa/util/PersistenceUtils.java
|
package ai.preferred.cerebro.core.jpa.util;
import java.util.HashMap;
import java.util.Map;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import ai.preferred.cerebro.core.util.ConfigUtils;
public class PersistenceUtils {
private static final Logger LOGGER = LogManager.getLogger(PersistenceUtils.class);
private static EntityManager entityManager = null;
public static synchronized EntityManager getEntityManager() {
if(entityManager == null) {
String host = ConfigUtils.getInstance().getStringProperty("preferred.ai.cerebro.cerebrojpa.jdbc.host", "localhost");
int port = ConfigUtils.getInstance().getIntProperty("preferred.ai.cerebro.jpa.jdbc.port", 3306);
String dbname = ConfigUtils.getInstance().getStringProperty("preferred.ai.cerebro.jpa.jdbc.db");
String username = ConfigUtils.getInstance().getStringProperty("preferred.ai.cerebro.jpa.jdbc.user");
String password = ConfigUtils.getInstance().getStringProperty("preferred.ai.cerebro.jpa.jdbc.password");
entityManager = PersistenceUtils.createEntityManager("cerebrojpa", host, port, dbname, username, password, false);
}
return entityManager;
}
private static EntityManager createEntityManager(String name, String host, int port, String dbname, String username, String password, boolean useSSL) {
try {
Map<String, String> persistenceMap = new HashMap<String, String>();
String url = "jdbc:mysql://" + host +":" + port + "/" + dbname
+ "?autoReconnect=true&useUnicode=yes&characterEncoding=UTF-8"
+ "&serverTimezone=Asia/Singapore&verifyServerCertificate=false&useSSL=" + useSSL;
persistenceMap.put("javax.persistence.jdbc.url", url);
persistenceMap.put("javax.persistence.jdbc.user", username);
persistenceMap.put("javax.persistence.jdbc.password", password);
persistenceMap.put("javax.persistence.jdbc.driver", "com.mysql.cj.jdbc.Driver");
EntityManagerFactory emf = Persistence.createEntityManagerFactory(name, persistenceMap);
if (emf != null)
return emf.createEntityManager();
} catch (Exception ex) {
LOGGER.error(ex.getMessage());
}
return null;
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa/util/QueryUtils.java
|
package ai.preferred.cerebro.core.jpa.util;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Query;
public class QueryUtils {
@SuppressWarnings({ "rawtypes", "unchecked" })
public static <E> E getSingleResult(Query query) {
E entity = null;
try {
List results = query.getResultList();
if (results != null && !results.isEmpty())
entity = (E) results.get(0);
} catch (Exception ex) {
}
return entity;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public static <E> List<E> getResultList(Query query, int limit) {
ArrayList<E> entities = new ArrayList<E>();
try {
if (limit > 0) {
query.setMaxResults(limit);
}
List results = query.getResultList();
if (results != null && !results.isEmpty()) {
for (int i = 0; i < results.size(); i++) {
try {
entities.add((E) results.get(i));
} catch (Exception ex2) {
}
}
}
} catch (Exception ex) {
}
return entities;
}
public static <E> List<E> getResultList(Query query) {
return getResultList(query, 0);
}
@SuppressWarnings({ "unchecked" })
public static <E> E[] getResults(Query query, int limit) {
ArrayList<E> entities = (ArrayList<E>) getResultList(query, limit);
return entities.toArray((E[]) new Object[0]);
}
public static <E> E[] getResults(Query query) {
return getResults(query, 0);
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/jpa/util/UUIDUtils.java
|
package ai.preferred.cerebro.core.jpa.util;
import java.util.UUID;
public class UUIDUtils {
private static final String DEFAULT_UUID_STRING = "00000000-0000-0000-0000-000000000000";
private static final UUID DEFAULT_UUID = UUID
.fromString("00000000-0000-0000-0000-000000000000");
public static String getDefaultUUIDString() {
return DEFAULT_UUID_STRING;
}
public static UUID getDefaultUUID() {
return DEFAULT_UUID;
}
public static UUID newUUID() {
return UUID.randomUUID();
}
public static String newUUIDString() {
return String.valueOf(newUUID().toString());
}
public static String newPlainUUIDString() {
return newUUIDString().replace("-", "");
}
public static byte[] newUUIDByteArray() {
return toBytes(newUUID());
}
public static UUID parseUUID(Object value) {
return parseUUID(value, DEFAULT_UUID);
}
public static UUID parseUUID(Object value, UUID defaultValue) {
if (value == null)
return defaultValue;
if (value instanceof UUID)
return (UUID) value;
try {
return UUID.fromString(value.toString());
} catch (Exception ex) {
return defaultValue;
}
}
public static byte[] toBytes(UUID uuid) {
long msb = uuid.getMostSignificantBits();
long lsb = uuid.getLeastSignificantBits();
return toBytes(msb, lsb);
}
private static byte[] toBytes(long msb, long lsb) {
byte[] buffer = new byte[16];
for (int i = 0; i < 8; i++) {
buffer[i] = (byte) (msb >>> 8 * (7 - i));
}
for (int i = 8; i < 16; i++) {
buffer[i] = (byte) (lsb >>> 8 * (7 - i));
}
return buffer;
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/util/BooleanUtils.java
|
package ai.preferred.cerebro.core.util;
/**
* BooleanUtils
* @author ddle.2015
*
*/
public class BooleanUtils {
private static final boolean DEFAULT_BOOLEAN = false;
public static boolean getDefaultBoolean() {
return DEFAULT_BOOLEAN;
}
public static Boolean getObject(boolean value) {
return new Boolean(value);
}
public static boolean parseBoolean(Object value) {
return parseBoolean(value, DEFAULT_BOOLEAN);
}
public static boolean parseBoolean(Object value, boolean defaultValue) {
if (value == null)
return defaultValue;
if (value instanceof Boolean)
return ((Boolean) value).booleanValue();
try {
return new Boolean(value.toString()).booleanValue();
} catch (Exception ex) {
return defaultValue;
}
}
public static boolean areEqual(Boolean value1, Boolean value2) {
return parseBoolean(value1) == parseBoolean(value2);
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/util/CommandOptions.java
|
package ai.preferred.cerebro.core.util;
import java.util.HashMap;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import ai.preferred.cerebro.core.util.BooleanUtils;
import ai.preferred.cerebro.core.util.NumberUtils;
import ai.preferred.cerebro.core.util.ObjectUtils;
import ai.preferred.cerebro.core.util.StringUtils;
/**
* Command Options
* @author ddle.2015
*
*/
public class CommandOptions {
private Map<String, Option> options = new HashMap<String, Option>();
private static final Logger LOGGER = LogManager.getLogger(CommandOptions.class.getName());
public CommandOptions(){}
public void parse(String[] args){
if(args == null || args.length == 0){
printHelp();
return;
}
for(int i = 0; i < args.length;){
String currentToken = args[i];
if(currentToken.startsWith("-"))
currentToken = currentToken.substring(1, currentToken.length());
else if(!currentToken.startsWith("-") || StringUtils.isNullOrEmpty(currentToken)){
LOGGER.error("Invalid argument " + currentToken);
printHelp();
System.exit(0);
}
Option opt = options.get(currentToken);
if(ObjectUtils.isNull(opt)){
LOGGER.error("No such key " + currentToken);
printHelp();
System.exit(0);
}
if(i < args.length - 1){
String nextToken = args[i+1];
if(!nextToken.startsWith("-")){
opt.setValue(nextToken);
i += 2;
} else {
opt.setValue(true);
i++;
}
} else {
opt.setValue(true);
i++;
}
options.put(currentToken, opt);
}
}
public void addOption(String key, String description, Object defaultValue){
options.put(key, new Option(description, defaultValue));
}
public Boolean getBooleanOption(String key) throws Exception{
Option opt = options.get(key);
if(ObjectUtils.isNull(opt))
throw new Exception("No such key " + key + " found");
Object obj = opt.getValue();
if(ObjectUtils.isNull(obj))
return BooleanUtils.parseBoolean(opt.getDefaultValue());
return BooleanUtils.parseBoolean(obj);
}
public String getStringOption(String key) throws Exception{
Option opt = options.get(key);
if(ObjectUtils.isNull(opt))
throw new Exception("No such key " + key + " found");
Object obj = opt.getValue();
if(ObjectUtils.isNull(obj))
return StringUtils.parseString(opt.getDefaultValue());
return StringUtils.parseString(obj);
}
public Integer getIntegerOption(String key) throws Exception{
Option opt = options.get(key);
if(ObjectUtils.isNull(opt))
throw new Exception("No such key " + key + " found");
Object obj = opt.getValue();
if(ObjectUtils.isNull(obj))
return NumberUtils.parseInt(opt.getDefaultValue());
return NumberUtils.parseInt(obj);
}
public Double getDoubleOption(String key) throws Exception{
Option opt = options.get(key);
if(ObjectUtils.isNull(opt))
throw new Exception("No such key " + key + " found");
Object obj = opt.getValue();
if(ObjectUtils.isNull(obj))
return NumberUtils.parseDouble(opt.getDefaultValue());
return NumberUtils.parseDouble(obj);
}
public Long getLongOption(String key) throws Exception{
Option opt = options.get(key);
if(ObjectUtils.isNull(opt))
throw new Exception("No such key " + key + " found");
Object obj = opt.getValue();
if(ObjectUtils.isNull(obj))
return NumberUtils.parseLong(opt.getDefaultValue());
return NumberUtils.parseLong(obj);
}
public void printHelp(){
StringBuffer buffer = new StringBuffer();
buffer.append("\nPlease use the following arguments: ").append("\n");
for(String key: options.keySet()){
buffer.append(" ").append("-" + key).append(": ")
.append(options.get(key).toString()).append("\n");
}
LOGGER.info(buffer.toString());
}
class Option {
private Object value;
private String description;
private Object defaultValue;
public Option(){}
public Option(String description, Object defaultValue) {
super();
this.description = description;
this.defaultValue = defaultValue;
}
public Object getValue() {
return value;
}
public void setValue(Object value) {
this.value = value;
}
public Object getDefaultValue() {
return defaultValue;
}
public void setDefaultValue(Object defaultValue) {
this.defaultValue = defaultValue;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String toString(){
return description + ". Default value " + defaultValue;
}
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/util/ConfigUtils.java
|
package ai.preferred.cerebro.core.util;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
* ConfigUtils
* @author ddle.2015
*
*/
public class ConfigUtils {
static public final String PROPERTIES_FILE = "app.cfg";
private static ConfigUtils instance = null;
private Properties properties;
private static final Logger LOGGER = LogManager.getLogger(ConfigUtils.class.getName());
public ConfigUtils(){
loadProperties(PROPERTIES_FILE);
}
public static ConfigUtils getInstance(){
if(instance == null) instance = new ConfigUtils();
return instance;
}
/**
*
* @param fName File name
*/
public void loadProperties(String fName) {
try {
FileInputStream propsFile = new FileInputStream(fName);
properties = new Properties();
properties.load(propsFile);
propsFile.close();
} catch (IOException e) {
LOGGER.error(e.getMessage());
}
}
/**
*
* @param prefix
* @return all keys with prefix
*/
public List<String> getAllKeyWithPrefix(String prefix) {
List<String> holder = new ArrayList<String>();
for(Object objKey: properties.keySet()) {
String key = StringUtils.parseString(objKey);
if(!key.startsWith(prefix)) continue;
holder.add(key);
}
return holder;
}
/**
*
* @param propName
* @return
*/
public String getStringProperty(String propName) {
return properties.getProperty(propName);
}
/**
*
* @param propName
* @param defaultValue
* @return
*/
public String getStringProperty(String propName, String defaultValue) {
return properties.getProperty(propName, defaultValue);
}
/**
* Gets a property and converts it into byte.
*/
public byte getByteProperty(String propName, byte defaultValue) {
return Byte.parseByte(properties.getProperty(propName, Byte.toString(defaultValue)));
}
/**
* Gets a property and converts it into integer.
*/
public int getIntProperty(String propName, int defaultValue) {
return Integer.parseInt(properties.getProperty(propName, Integer.toString(defaultValue)));
}
/**
* Gets a property and converts it into double.
*/
public double getDoubleProperty(String propName, double defaultValue) {
return Double.parseDouble(properties.getProperty(propName, Double.toString(defaultValue)));
}
public void debug(){
LOGGER.info("------------------- CONFIGURATIONS -----------------");
for(Object key: properties.keySet()){
LOGGER.info(" " + key + " " + properties.getProperty(key.toString()));
}
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/util/DateUtils.java
|
package ai.preferred.cerebro.core.util;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
/**
* DateUtils
*
*/
public class DateUtils {
private static final Date DEFAULT_DATE = new Date(0);
private static final String DEFAULT_DATE_MASK = "EEE HH:mm:ss dd MMM yyyy";
private static final String SIMPLE_DATE_MASK = "yyyyMMdd";
private static final String COMPACT_DATE_MASK = "yyyyMMddHHmmss";
public static Date getDefaultDate() {
return DEFAULT_DATE;
}
public static String getGMTString(Date value) {
SimpleDateFormat formatter = new SimpleDateFormat(DEFAULT_DATE_MASK);
formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
return formatter.format(value);
}
public static String getString(Date value) {
SimpleDateFormat formatter = new SimpleDateFormat(DEFAULT_DATE_MASK);
return formatter.format(value);
}
public static String getString(Date value, String mask) {
SimpleDateFormat formatter = new SimpleDateFormat(mask);
return formatter.format(value);
}
public static String getString(Date value, String mask, TimeZone tz) {
SimpleDateFormat formatter = new SimpleDateFormat(mask);
formatter.setTimeZone(tz);
return formatter.format(value);
}
public static String getSimpleString(Date value) {
SimpleDateFormat formatter = new SimpleDateFormat(SIMPLE_DATE_MASK);
return formatter.format(value);
}
public static String getCompactString(Date value) {
SimpleDateFormat formatter = new SimpleDateFormat(COMPACT_DATE_MASK);
return formatter.format(value);
}
public static Date parseDate(Object value) {
return parseDate(value, DEFAULT_DATE);
}
public static Date parseDate(Object value, Date defaultValue) {
return parseDate(value, DEFAULT_DATE_MASK, defaultValue);
}
public static Date parseDate(Object value, String mask) {
return parseDate(value, mask, DEFAULT_DATE);
}
public static Date parseDate(Object value, String mask, Date defaultValue) {
if (value == null)
return defaultValue;
if (value instanceof Date)
return (Date) value;
try {
SimpleDateFormat formatter = new SimpleDateFormat(mask);
return (Date) formatter.parse(StringUtils.parseString(value));
} catch (Exception ex) {
return defaultValue;
}
}
public static Date parseDate(Object value, String mask, TimeZone tz) {
return parseDate(value, mask, DEFAULT_DATE);
}
public static Date parseDate(Object value, String mask, TimeZone tz, Date defaultValue) {
if (value == null)
return defaultValue;
if (value instanceof Date)
return (Date) value;
try {
SimpleDateFormat formatter = new SimpleDateFormat(mask);
formatter.setTimeZone(tz);
return (Date) formatter.parse(StringUtils.parseString(value));
} catch (Exception ex) {
return defaultValue;
}
}
public static Date addSeconds(Date date, int seconds) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.SECOND, seconds);
return calendar.getTime();
}
public static double diffDays(Date d1, Date d2){
double diff = d2.getTime() - d1.getTime();
return NumberUtils.roundDouble(diff / (24 * 60 * 60 * 1000),0);
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/util/FileUtils.java
|
package ai.preferred.cerebro.core.util;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Scanner;
import java.util.Stack;
import java.util.regex.Pattern;
/**
* FileUtils
* @author ddle.2015
*
*/
public class FileUtils {
public static final char EXTENSION_SEPARATOR = '.';
public static final String EXTENSION_SEPARATOR_STR = Character
.toString(EXTENSION_SEPARATOR);
private static final char UNIX_SEPARATOR = '/';
private static final char WINDOWS_SEPARATOR = '\\';
private static final char SYSTEM_SEPARATOR = File.separatorChar;
private static final char OTHER_SEPARATOR;
static {
if (isSystemWindows()) {
OTHER_SEPARATOR = UNIX_SEPARATOR;
} else {
OTHER_SEPARATOR = WINDOWS_SEPARATOR;
}
}
public static int emptyFolder(File folder, boolean ignoreCannotDel)
throws IOException {
int counter = 0;
if (folder.exists() && folder.isDirectory()) {
File[] child = folder.listFiles();
for (int i = 0; i < child.length; i++) {
File file = child[i];
if (file.isDirectory())
counter += emptyFolder(file, ignoreCannotDel);
boolean result = file.delete();
if (!result && !ignoreCannotDel) {
throw new IOException("Cannot delete "
+ file.getAbsolutePath());
} else {
counter++;
}
}
}
return counter;
}
public static int remove(File file, boolean ignoreCannotDelete)
throws Exception {
int counter = 0;
if (file.exists()) {
if (file.isDirectory()) {
counter += emptyFolder(file, ignoreCannotDelete);
}
boolean result = file.delete();
if (!result && !ignoreCannotDelete) {
throw new Exception("Cannot delete " + file.getAbsolutePath());
} else {
counter++;
}
}
return counter;
}
public static void removeIfExist(String path) throws Exception {
File file = new File(path);
if (file.exists())
remove(file, true);
}
public static boolean exist(String path) throws Exception {
File file = new File(path);
return file.exists();
}
public static void mkdirs(String path) throws IOException {
File file = new File(path);
if (!file.exists()) {
if (!file.mkdirs()) {
throw new IOException("Cannot create directory " + path);
}
}
}
public static int cp(String src, String dest) throws Exception {
int counter = 0;
File srcFolder = new java.io.File(src);
if (!srcFolder.exists())
throw new Exception(src + " does not exist");
if (srcFolder.isFile()) {
File destFolder = new java.io.File(dest);
if (destFolder.isFile()) {
dest = destFolder.getParent();
}
if (destFolder.exists()) {
dest = dest + "/" + srcFolder.getName();
}
InputStream input = new java.io.FileInputStream(srcFolder);
OutputStream output = new java.io.FileOutputStream(dest);
byte[] buff = new byte[8192];
int len = 0;
while ((len = input.read(buff)) > 0) {
output.write(buff, 0, len);
}
input.close();
output.close();
counter++;
} else {
File destFolder = new File(dest);
if (!destFolder.exists()) {
destFolder.mkdirs();
}
File[] child = srcFolder.listFiles();
for (int i = 0; i < child.length; i++) {
File file = child[i];
if (file.isFile()) {
counter += cp(file.getAbsolutePath(),
destFolder.getAbsolutePath() + "/" + file.getName());
} else {
counter += cp(file.getAbsolutePath(),
destFolder.getAbsolutePath() + "/" + file.getName());
}
}
}
return counter;
}
public static void copyTo(InputStream src, String dest) throws IOException {
File destFolder = new java.io.File(dest);
if (destFolder.isFile()) {
dest = destFolder.getParent();
}
OutputStream output = new java.io.FileOutputStream(dest);
byte[] buff = new byte[8192];
int len = 0;
while ((len = src.read(buff)) > 0) {
output.write(buff, 0, len);
}
src.close();
output.close();
}
public static void writeToFile(String fname, byte[] data, boolean append)
throws IOException {
FileOutputStream os = new FileOutputStream(fname, append);
os.write(data);
os.close();
}
public static void writeToFile(String fname, String data, boolean append)
throws IOException {
writeToFile(fname, StringUtils.parseString(data).getBytes(), append);
}
public static File[] listFile(String dir) {
List<File> holder = new ArrayList<File>();
File file = new File(dir);
if (file.isFile())
holder.add(file);
else if (file.isDirectory()) {
for (File child : file.listFiles())
holder.add(child);
}
return holder.toArray(new File[holder.size()]);
}
public static String[] listName(String dir) {
return listName(dir, false);
}
public static String[] listName(String dir, boolean directoryOnly) {
List<String> holder = new ArrayList<String>();
File file = new File(dir);
if(!directoryOnly){
if (file.isFile())
holder.add(file.getAbsolutePath());
else if (file.isDirectory()) {
for (File child : file.listFiles())
holder.add(child.getAbsolutePath());
}
} else {
if (file.isDirectory()) {
for (File child : file.listFiles())
if(child.isDirectory())
holder.add(child.getAbsolutePath());
}
}
return holder.toArray(new String[holder.size()]);
}
public static String[] findFiles(String dir, final String exp)
throws IOException {
List<String> holder = new ArrayList<String>();
final Pattern fpattern = Pattern.compile(exp);
FileFilter filter = new FileFilter() {
public boolean accept(File pathname) {
return fpattern.matcher(pathname.getName()).matches();
}
};
findFiles(holder, new File(dir), filter);
return holder.toArray(new String[holder.size()]);
}
public static <T extends FileFilter> List<String> findFiles(File dir,
T filter) throws IOException {
List<String> holder = new ArrayList<String>();
findFiles(holder, dir, filter);
return holder;
}
public static <T extends FileFilter> void findFiles(List<String> holder,
File file, T filter) throws IOException {
if (file.isFile() && filter.accept(file)) {
holder.add(file.getCanonicalPath());
return;
} else if (file.isDirectory()) {
for (File child : file.listFiles()) {
findFiles(holder, child, filter);
}
}
}
public static File getParentFolder(String fpath) {
return new File(fpath).getParentFile();
}
public static String getParent(String fpath) {
return getParentFolder(fpath).getPath();
}
public static String[] readLines(String fileName) {
try {
List<String> lines = readLines(new FileInputStream(fileName));
return lines.toArray(new String[lines.size()]);
} catch (FileNotFoundException e) {
return new String[0];
}
}
public static String readLinesAsString(String fileName) {
try {
List<String> lines = readLines(new FileInputStream(fileName));
StringBuffer buffer = new StringBuffer();
for(String line: lines) buffer.append(line).append("\n");
return buffer.toString();
} catch (FileNotFoundException e) {
return new String("");
}
}
public static List<String> readLinesAsList(String fileName) {
try {
return readLines(new FileInputStream(fileName));
} catch (FileNotFoundException e) {
return new ArrayList<String>();
}
}
public static String[] readLines(URL url) {
try {
List<String> lines = readLines(new FileInputStream(url.getFile()));
return lines.toArray(new String[lines.size()]);
} catch (FileNotFoundException e) {
return new String[0];
}
}
public static List<String> readLines(InputStream in) {
List<String> lines = new ArrayList<String>();
Scanner scanner = new Scanner(in);
while (scanner.hasNext()) {
lines.add(scanner.nextLine());
}
scanner.close();
return lines;
}
// -----------------------------------------------------------------------
/**
* Determines if Windows file system is in use.
*
* @return true if the system is Windows
*/
static boolean isSystemWindows() {
return SYSTEM_SEPARATOR == WINDOWS_SEPARATOR;
}
// -----------------------------------------------------------------------
/**
* Checks if the character is a separator.
*
* @param ch
* the character to check
* @return true if it is a separator character
*/
private static boolean isSeparator(final char ch) {
return ch == UNIX_SEPARATOR || ch == WINDOWS_SEPARATOR;
}
// -----------------------------------------------------------------------
/**
* Normalizes a path, removing double and single dot path steps.
* <p>
* This method normalizes a path to a standard format. The input may contain
* separators in either Unix or Windows format. The output will contain
* separators in the format of the system.
* <p>
* A trailing slash will be retained. A double slash will be merged to a
* single slash (but UNC names are handled). A single dot path segment will
* be removed. A double dot will cause that path segment and the one before
* to be removed. If the double dot has no parent path segment to work with,
* {@code null} is returned.
* <p>
* The output will be the same on both Unix and Windows except for the
* separator character.
*
* <pre>
* /foo// --> /foo/
* /foo/./ --> /foo/
* /foo/../bar --> /bar
* /foo/../bar/ --> /bar/
* /foo/../bar/../baz --> /baz
* //foo//./bar --> /foo/bar
* /../ --> null
* ../foo --> null
* foo/bar/.. --> foo/
* foo/../../bar --> null
* foo/../bar --> bar
* //server/foo/../bar --> //server/bar
* //server/../bar --> null
* C:\foo\..\bar --> C:\bar
* C:\..\bar --> null
* ~/foo/../bar/ --> ~/bar/
* ~/../bar --> null
* </pre>
*
* (Note the file separator returned will be correct for Windows/Unix)
*
* @param filename
* the filename to normalize, null returns null
* @return the normalized filename, or null if invalid
*/
public static String normalize(final String filename) {
return doNormalize(filename, SYSTEM_SEPARATOR, true);
}
/**
* Normalizes a path, removing double and single dot path steps.
* <p>
* This method normalizes a path to a standard format. The input may contain
* separators in either Unix or Windows format. The output will contain
* separators in the format specified.
* <p>
* A trailing slash will be retained. A double slash will be merged to a
* single slash (but UNC names are handled). A single dot path segment will
* be removed. A double dot will cause that path segment and the one before
* to be removed. If the double dot has no parent path segment to work with,
* {@code null} is returned.
* <p>
* The output will be the same on both Unix and Windows except for the
* separator character.
*
* <pre>
* /foo// --> /foo/
* /foo/./ --> /foo/
* /foo/../bar --> /bar
* /foo/../bar/ --> /bar/
* /foo/../bar/../baz --> /baz
* //foo//./bar --> /foo/bar
* /../ --> null
* ../foo --> null
* foo/bar/.. --> foo/
* foo/../../bar --> null
* foo/../bar --> bar
* //server/foo/../bar --> //server/bar
* //server/../bar --> null
* C:\foo\..\bar --> C:\bar
* C:\..\bar --> null
* ~/foo/../bar/ --> ~/bar/
* ~/../bar --> null
* </pre>
*
* The output will be the same on both Unix and Windows including the
* separator character.
*
* @param filename
* the filename to normalize, null returns null
* @param unixSeparator
* {@code true} if a unix separator should be used or
* {@code false} if a windows separator should be used.
* @return the normalized filename, or null if invalid
* @since 2.0
*/
public static String normalize(final String filename,
final boolean unixSeparator) {
final char separator = unixSeparator ? UNIX_SEPARATOR
: WINDOWS_SEPARATOR;
return doNormalize(filename, separator, true);
}
// -----------------------------------------------------------------------
/**
* Normalizes a path, removing double and single dot path steps, and
* removing any final directory separator.
* <p>
* This method normalizes a path to a standard format. The input may contain
* separators in either Unix or Windows format. The output will contain
* separators in the format of the system.
* <p>
* A trailing slash will be removed. A double slash will be merged to a
* single slash (but UNC names are handled). A single dot path segment will
* be removed. A double dot will cause that path segment and the one before
* to be removed. If the double dot has no parent path segment to work with,
* {@code null} is returned.
* <p>
* The output will be the same on both Unix and Windows except for the
* separator character.
*
* <pre>
* /foo// --> /foo
* /foo/./ --> /foo
* /foo/../bar --> /bar
* /foo/../bar/ --> /bar
* /foo/../bar/../baz --> /baz
* //foo//./bar --> /foo/bar
* /../ --> null
* ../foo --> null
* foo/bar/.. --> foo
* foo/../../bar --> null
* foo/../bar --> bar
* //server/foo/../bar --> //server/bar
* //server/../bar --> null
* C:\foo\..\bar --> C:\bar
* C:\..\bar --> null
* ~/foo/../bar/ --> ~/bar
* ~/../bar --> null
* </pre>
*
* (Note the file separator returned will be correct for Windows/Unix)
*
* @param filename
* the filename to normalize, null returns null
* @return the normalized filename, or null if invalid
*/
public static String normalizeNoEndSeparator(final String filename) {
return doNormalize(filename, SYSTEM_SEPARATOR, false);
}
/**
* Normalizes a path, removing double and single dot path steps, and
* removing any final directory separator.
* <p>
* This method normalizes a path to a standard format. The input may contain
* separators in either Unix or Windows format. The output will contain
* separators in the format specified.
* <p>
* A trailing slash will be removed. A double slash will be merged to a
* single slash (but UNC names are handled). A single dot path segment will
* be removed. A double dot will cause that path segment and the one before
* to be removed. If the double dot has no parent path segment to work with,
* {@code null} is returned.
* <p>
* The output will be the same on both Unix and Windows including the
* separator character.
*
* <pre>
* /foo// --> /foo
* /foo/./ --> /foo
* /foo/../bar --> /bar
* /foo/../bar/ --> /bar
* /foo/../bar/../baz --> /baz
* //foo//./bar --> /foo/bar
* /../ --> null
* ../foo --> null
* foo/bar/.. --> foo
* foo/../../bar --> null
* foo/../bar --> bar
* //server/foo/../bar --> //server/bar
* //server/../bar --> null
* C:\foo\..\bar --> C:\bar
* C:\..\bar --> null
* ~/foo/../bar/ --> ~/bar
* ~/../bar --> null
* </pre>
*
* @param filename
* the filename to normalize, null returns null
* @param unixSeparator
* {@code true} if a unix separator should be used or
* {@code false} if a windows separtor should be used.
* @return the normalized filename, or null if invalid
* @since 2.0
*/
public static String normalizeNoEndSeparator(final String filename,
final boolean unixSeparator) {
final char separator = unixSeparator ? UNIX_SEPARATOR
: WINDOWS_SEPARATOR;
return doNormalize(filename, separator, false);
}
/**
* Internal method to perform the normalization.
*
* @param filename
* the filename
* @param separator
* The separator character to use
* @param keepSeparator
* true to keep the final separator
* @return the normalized filename
*/
private static String doNormalize(final String filename,
final char separator, final boolean keepSeparator) {
if (filename == null) {
return null;
}
int size = filename.length();
if (size == 0) {
return filename;
}
final int prefix = getPrefixLength(filename);
if (prefix < 0) {
return null;
}
final char[] array = new char[size + 2]; // +1 for possible extra slash,
// +2 for arraycopy
filename.getChars(0, filename.length(), array, 0);
// fix separators throughout
final char otherSeparator = separator == SYSTEM_SEPARATOR ? OTHER_SEPARATOR
: SYSTEM_SEPARATOR;
for (int i = 0; i < array.length; i++) {
if (array[i] == otherSeparator) {
array[i] = separator;
}
}
// add extra separator on the end to simplify code below
boolean lastIsDirectory = true;
if (array[size - 1] != separator) {
array[size++] = separator;
lastIsDirectory = false;
}
// adjoining slashes
for (int i = prefix + 1; i < size; i++) {
if (array[i] == separator && array[i - 1] == separator) {
System.arraycopy(array, i, array, i - 1, size - i);
size--;
i--;
}
}
// dot slash
for (int i = prefix + 1; i < size; i++) {
if (array[i] == separator && array[i - 1] == '.'
&& (i == prefix + 1 || array[i - 2] == separator)) {
if (i == size - 1) {
lastIsDirectory = true;
}
System.arraycopy(array, i + 1, array, i - 1, size - i);
size -= 2;
i--;
}
}
// double dot slash
outer: for (int i = prefix + 2; i < size; i++) {
if (array[i] == separator && array[i - 1] == '.'
&& array[i - 2] == '.'
&& (i == prefix + 2 || array[i - 3] == separator)) {
if (i == prefix + 2) {
return null;
}
if (i == size - 1) {
lastIsDirectory = true;
}
int j;
for (j = i - 4; j >= prefix; j--) {
if (array[j] == separator) {
// remove b/../ from a/b/../c
System.arraycopy(array, i + 1, array, j + 1, size - i);
size -= i - j;
i = j + 1;
continue outer;
}
}
// remove a/../ from a/../c
System.arraycopy(array, i + 1, array, prefix, size - i);
size -= i + 1 - prefix;
i = prefix + 1;
}
}
if (size <= 0) { // should never be less than 0
return "";
}
if (size <= prefix) { // should never be less than prefix
return new String(array, 0, size);
}
if (lastIsDirectory && keepSeparator) {
return new String(array, 0, size); // keep trailing separator
}
return new String(array, 0, size - 1); // lose trailing separator
}
// -----------------------------------------------------------------------
/**
* Concatenates a filename to a base path using normal command line style
* rules.
* <p>
* The effect is equivalent to resultant directory after changing directory
* to the first argument, followed by changing directory to the second
* argument.
* <p>
* The first argument is the base path, the second is the path to
* concatenate. The returned path is always normalized via
* {@link #normalize(String)}, thus <code>..</code> is handled.
* <p>
* If <code>pathToAdd</code> is absolute (has an absolute prefix), then it
* will be normalized and returned. Otherwise, the paths will be joined,
* normalized and returned.
* <p>
* The output will be the same on both Unix and Windows except for the
* separator character.
*
* <pre>
* /foo/ + bar --> /foo/bar
* /foo + bar --> /foo/bar
* /foo + /bar --> /bar
* /foo + C:/bar --> C:/bar
* /foo + C:bar --> C:bar (*)
* /foo/a/ + ../bar --> foo/bar
* /foo/ + ../../bar --> null
* /foo/ + /bar --> /bar
* /foo/.. + /bar --> /bar
* /foo + bar/c.txt --> /foo/bar/c.txt
* /foo/c.txt + bar --> /foo/c.txt/bar (!)
* </pre>
*
* (*) Note that the Windows relative drive prefix is unreliable when used
* with this method. (!) Note that the first parameter must be a path. If it
* ends with a name, then the name will be built into the concatenated path.
* If this might be a problem, use {@link #getFullPath(String)} on the base
* path argument.
*
* @param basePath
* the base path to attach to, always treated as a path
* @param fullFilenameToAdd
* the filename (or path) to attach to the base
* @return the concatenated path, or null if invalid
*/
public static String concat(final String basePath,
final String fullFilenameToAdd) {
final int prefix = getPrefixLength(fullFilenameToAdd);
if (prefix < 0) {
return null;
}
if (prefix > 0) {
return normalize(fullFilenameToAdd);
}
if (basePath == null) {
return null;
}
final int len = basePath.length();
if (len == 0) {
return normalize(fullFilenameToAdd);
}
final char ch = basePath.charAt(len - 1);
if (isSeparator(ch)) {
return normalize(basePath + fullFilenameToAdd);
} else {
return normalize(basePath + '/' + fullFilenameToAdd);
}
}
// -----------------------------------------------------------------------
/**
* Converts all separators to the Unix separator of forward slash.
*
* @param path
* the path to be changed, null ignored
* @return the updated path
*/
public static String separatorsToUnix(final String path) {
if (path == null || path.indexOf(WINDOWS_SEPARATOR) == -1) {
return path;
}
return path.replace(WINDOWS_SEPARATOR, UNIX_SEPARATOR);
}
/**
* Converts all separators to the Windows separator of backslash.
*
* @param path
* the path to be changed, null ignored
* @return the updated path
*/
public static String separatorsToWindows(final String path) {
if (path == null || path.indexOf(UNIX_SEPARATOR) == -1) {
return path;
}
return path.replace(UNIX_SEPARATOR, WINDOWS_SEPARATOR);
}
/**
* Converts all separators to the system separator.
*
* @param path
* the path to be changed, null ignored
* @return the updated path
*/
public static String separatorsToSystem(final String path) {
if (path == null) {
return null;
}
if (isSystemWindows()) {
return separatorsToWindows(path);
} else {
return separatorsToUnix(path);
}
}
// -----------------------------------------------------------------------
/**
* Returns the length of the filename prefix, such as <code>C:/</code> or
* <code>~/</code>.
* <p>
* This method will handle a file in either Unix or Windows format.
* <p>
* The prefix length includes the first slash in the full filename if
* applicable. Thus, it is possible that the length returned is greater than
* the length of the input string.
*
* <pre>
* Windows:
* a\b\c.txt --> "" --> relative
* \a\b\c.txt --> "\" --> current drive absolute
* C:a\b\c.txt --> "C:" --> drive relative
* C:\a\b\c.txt --> "C:\" --> absolute
* \\server\a\b\c.txt --> "\\server\" --> UNC
*
* Unix:
* a/b/c.txt --> "" --> relative
* /a/b/c.txt --> "/" --> absolute
* ~/a/b/c.txt --> "~/" --> current user
* ~ --> "~/" --> current user (slash added)
* ~user/a/b/c.txt --> "~user/" --> named user
* ~user --> "~user/" --> named user (slash added)
* </pre>
* <p>
* The output will be the same irrespective of the machine that the code is
* running on. ie. both Unix and Windows prefixes are matched regardless.
*
* @param filename
* the filename to find the prefix in, null returns -1
* @return the length of the prefix, -1 if invalid or null
*/
public static int getPrefixLength(final String filename) {
if (filename == null) {
return -1;
}
final int len = filename.length();
if (len == 0) {
return 0;
}
char ch0 = filename.charAt(0);
if (ch0 == ':') {
return -1;
}
if (len == 1) {
if (ch0 == '~') {
return 2; // return a length greater than the input
}
return isSeparator(ch0) ? 1 : 0;
} else {
if (ch0 == '~') {
int posUnix = filename.indexOf(UNIX_SEPARATOR, 1);
int posWin = filename.indexOf(WINDOWS_SEPARATOR, 1);
if (posUnix == -1 && posWin == -1) {
return len + 1; // return a length greater than the input
}
posUnix = posUnix == -1 ? posWin : posUnix;
posWin = posWin == -1 ? posUnix : posWin;
return Math.min(posUnix, posWin) + 1;
}
final char ch1 = filename.charAt(1);
if (ch1 == ':') {
ch0 = Character.toUpperCase(ch0);
if (ch0 >= 'A' && ch0 <= 'Z') {
if (len == 2 || isSeparator(filename.charAt(2)) == false) {
return 2;
}
return 3;
}
return -1;
} else if (isSeparator(ch0) && isSeparator(ch1)) {
int posUnix = filename.indexOf(UNIX_SEPARATOR, 2);
int posWin = filename.indexOf(WINDOWS_SEPARATOR, 2);
if (posUnix == -1 && posWin == -1 || posUnix == 2
|| posWin == 2) {
return -1;
}
posUnix = posUnix == -1 ? posWin : posUnix;
posWin = posWin == -1 ? posUnix : posWin;
return Math.min(posUnix, posWin) + 1;
} else {
return isSeparator(ch0) ? 1 : 0;
}
}
}
/**
* Returns the index of the last directory separator character.
* <p>
* This method will handle a file in either Unix or Windows format. The
* position of the last forward or backslash is returned.
* <p>
* The output will be the same irrespective of the machine that the code is
* running on.
*
* @param filename
* the filename to find the last path separator in, null returns
* -1
* @return the index of the last separator character, or -1 if there is no
* such character
*/
public static int indexOfLastSeparator(final String filename) {
if (filename == null) {
return -1;
}
final int lastUnixPos = filename.lastIndexOf(UNIX_SEPARATOR);
final int lastWindowsPos = filename.lastIndexOf(WINDOWS_SEPARATOR);
return Math.max(lastUnixPos, lastWindowsPos);
}
/**
* Returns the index of the last extension separator character, which is a
* dot.
* <p>
* This method also checks that there is no directory separator after the
* last dot. To do this it uses {@link #indexOfLastSeparator(String)} which
* will handle a file in either Unix or Windows format.
* <p>
* The output will be the same irrespective of the machine that the code is
* running on.
*
* @param filename
* the filename to find the last path separator in, null returns
* -1
* @return the index of the last separator character, or -1 if there is no
* such character
*/
public static int indexOfExtension(final String filename) {
if (filename == null) {
return -1;
}
final int extensionPos = filename.lastIndexOf(EXTENSION_SEPARATOR);
final int lastSeparator = indexOfLastSeparator(filename);
return lastSeparator > extensionPos ? -1 : extensionPos;
}
// -----------------------------------------------------------------------
/**
* Gets the prefix from a full filename, such as <code>C:/</code> or
* <code>~/</code>.
* <p>
* This method will handle a file in either Unix or Windows format. The
* prefix includes the first slash in the full filename where applicable.
*
* <pre>
* Windows:
* a\b\c.txt --> "" --> relative
* \a\b\c.txt --> "\" --> current drive absolute
* C:a\b\c.txt --> "C:" --> drive relative
* C:\a\b\c.txt --> "C:\" --> absolute
* \\server\a\b\c.txt --> "\\server\" --> UNC
*
* Unix:
* a/b/c.txt --> "" --> relative
* /a/b/c.txt --> "/" --> absolute
* ~/a/b/c.txt --> "~/" --> current user
* ~ --> "~/" --> current user (slash added)
* ~user/a/b/c.txt --> "~user/" --> named user
* ~user --> "~user/" --> named user (slash added)
* </pre>
* <p>
* The output will be the same irrespective of the machine that the code is
* running on. ie. both Unix and Windows prefixes are matched regardless.
*
* @param filename
* the filename to query, null returns null
* @return the prefix of the file, null if invalid
*/
public static String getPrefix(final String filename) {
if (filename == null) {
return null;
}
final int len = getPrefixLength(filename);
if (len < 0) {
return null;
}
if (len > filename.length()) {
return filename + UNIX_SEPARATOR; // we know this only happens for
// unix
}
return filename.substring(0, len);
}
/**
* Gets the path from a full filename, which excludes the prefix.
* <p>
* This method will handle a file in either Unix or Windows format. The
* method is entirely text based, and returns the text before and including
* the last forward or backslash.
*
* <pre>
* C:\a\b\c.txt --> a\b\
* ~/a/b/c.txt --> a/b/
* a.txt --> ""
* a/b/c --> a/b/
* a/b/c/ --> a/b/c/
* </pre>
* <p>
* The output will be the same irrespective of the machine that the code is
* running on.
* <p>
* This method drops the prefix from the result. See
* {@link #getFullPath(String)} for the method that retains the prefix.
*
* @param filename
* the filename to query, null returns null
* @return the path of the file, an empty string if none exists, null if
* invalid
*/
public static String getPath(final String filename) {
return doGetPath(filename, 1);
}
/**
* Gets the path from a full filename, which excludes the prefix, and also
* excluding the final directory separator.
* <p>
* This method will handle a file in either Unix or Windows format. The
* method is entirely text based, and returns the text before the last
* forward or backslash.
*
* <pre>
* C:\a\b\c.txt --> a\b
* ~/a/b/c.txt --> a/b
* a.txt --> ""
* a/b/c --> a/b
* a/b/c/ --> a/b/c
* </pre>
* <p>
* The output will be the same irrespective of the machine that the code is
* running on.
* <p>
* This method drops the prefix from the result. See
* {@link #getFullPathNoEndSeparator(String)} for the method that retains
* the prefix.
*
* @param filename
* the filename to query, null returns null
* @return the path of the file, an empty string if none exists, null if
* invalid
*/
public static String getPathNoEndSeparator(final String filename) {
return doGetPath(filename, 0);
}
/**
* Does the work of getting the path.
*
* @param filename
* the filename
* @param separatorAdd
* 0 to omit the end separator, 1 to return it
* @return the path
*/
private static String doGetPath(final String filename,
final int separatorAdd) {
if (filename == null) {
return null;
}
final int prefix = getPrefixLength(filename);
if (prefix < 0) {
return null;
}
final int index = indexOfLastSeparator(filename);
final int endIndex = index + separatorAdd;
if (prefix >= filename.length() || index < 0 || prefix >= endIndex) {
return "";
}
return filename.substring(prefix, endIndex);
}
/**
* Gets the full path from a full filename, which is the prefix + path.
* <p>
* This method will handle a file in either Unix or Windows format. The
* method is entirely text based, and returns the text before and including
* the last forward or backslash.
*
* <pre>
* C:\a\b\c.txt --> C:\a\b\
* ~/a/b/c.txt --> ~/a/b/
* a.txt --> ""
* a/b/c --> a/b/
* a/b/c/ --> a/b/c/
* C: --> C:
* C:\ --> C:\
* ~ --> ~/
* ~/ --> ~/
* ~user --> ~user/
* ~user/ --> ~user/
* </pre>
* <p>
* The output will be the same irrespective of the machine that the code is
* running on.
*
* @param filename
* the filename to query, null returns null
* @return the path of the file, an empty string if none exists, null if
* invalid
*/
public static String getFullPath(final String filename) {
return doGetFullPath(filename, true);
}
/**
* Gets the full path from a full filename, which is the prefix + path, and
* also excluding the final directory separator.
* <p>
* This method will handle a file in either Unix or Windows format. The
* method is entirely text based, and returns the text before the last
* forward or backslash.
*
* <pre>
* C:\a\b\c.txt --> C:\a\b
* ~/a/b/c.txt --> ~/a/b
* a.txt --> ""
* a/b/c --> a/b
* a/b/c/ --> a/b/c
* C: --> C:
* C:\ --> C:\
* ~ --> ~
* ~/ --> ~
* ~user --> ~user
* ~user/ --> ~user
* </pre>
* <p>
* The output will be the same irrespective of the machine that the code is
* running on.
*
* @param filename
* the filename to query, null returns null
* @return the path of the file, an empty string if none exists, null if
* invalid
*/
public static String getFullPathNoEndSeparator(final String filename) {
return doGetFullPath(filename, false);
}
/**
* Does the work of getting the path.
*
* @param filename
* the filename
* @param includeSeparator
* true to include the end separator
* @return the path
*/
private static String doGetFullPath(final String filename,
final boolean includeSeparator) {
if (filename == null) {
return null;
}
final int prefix = getPrefixLength(filename);
if (prefix < 0) {
return null;
}
if (prefix >= filename.length()) {
if (includeSeparator) {
return getPrefix(filename); // add end slash if necessary
} else {
return filename;
}
}
final int index = indexOfLastSeparator(filename);
if (index < 0) {
return filename.substring(0, prefix);
}
int end = index + (includeSeparator ? 1 : 0);
if (end == 0) {
end++;
}
return filename.substring(0, end);
}
/**
* Gets the name minus the path from a full filename.
* <p>
* This method will handle a file in either Unix or Windows format. The text
* after the last forward or backslash is returned.
*
* <pre>
* a/b/c.txt --> c.txt
* a.txt --> a.txt
* a/b/c --> c
* a/b/c/ --> ""
* </pre>
* <p>
* The output will be the same irrespective of the machine that the code is
* running on.
*
* @param filename
* the filename to query, null returns null
* @return the name of the file without the path, or an empty string if none
* exists
*/
public static String getName(final String filename) {
if (filename == null) {
return null;
}
final int index = indexOfLastSeparator(filename);
return filename.substring(index + 1);
}
/**
* Gets the base name, minus the full path and extension, from a full
* filename.
* <p>
* This method will handle a file in either Unix or Windows format. The text
* after the last forward or backslash and before the last dot is returned.
*
* <pre>
* a/b/c.txt --> c
* a.txt --> a
* a/b/c --> c
* a/b/c/ --> ""
* </pre>
* <p>
* The output will be the same irrespective of the machine that the code is
* running on.
*
* @param filename
* the filename to query, null returns null
* @return the name of the file without the path, or an empty string if none
* exists
*/
public static String getBaseName(final String filename) {
return removeExtension(getName(filename));
}
/**
* Gets the extension of a filename.
* <p>
* This method returns the textual part of the filename after the last dot.
* There must be no directory separator after the dot.
*
* <pre>
* foo.txt --> "txt"
* a/b/c.jpg --> "jpg"
* a/b.txt/c --> ""
* a/b/c --> ""
* </pre>
* <p>
* The output will be the same irrespective of the machine that the code is
* running on.
*
* @param filename
* the filename to retrieve the extension of.
* @return the extension of the file or an empty string if none exists or
* {@code null} if the filename is {@code null}.
*/
public static String getExtension(final String filename) {
if (filename == null) {
return null;
}
final int index = indexOfExtension(filename);
if (index == -1) {
return "";
} else {
return filename.substring(index + 1);
}
}
// -----------------------------------------------------------------------
/**
* Removes the extension from a filename.
* <p>
* This method returns the textual part of the filename before the last dot.
* There must be no directory separator after the dot.
*
* <pre>
* foo.txt --> foo
* a\b\c.jpg --> a\b\c
* a\b\c --> a\b\c
* a.b\c --> a.b\c
* </pre>
* <p>
* The output will be the same irrespective of the machine that the code is
* running on.
*
* @param filename
* the filename to query, null returns null
* @return the filename minus the extension
*/
public static String removeExtension(final String filename) {
if (filename == null) {
return null;
}
final int index = indexOfExtension(filename);
if (index == -1) {
return filename;
} else {
return filename.substring(0, index);
}
}
// -----------------------------------------------------------------------
/**
* Checks whether the extension of the filename is that specified.
* <p>
* This method obtains the extension as the textual part of the filename
* after the last dot. There must be no directory separator after the dot.
* The extension check is case-sensitive on all platforms.
*
* @param filename
* the filename to query, null returns false
* @param extension
* the extension to check for, null or empty checks for no
* extension
* @return true if the filename has the specified extension
*/
public static boolean isExtension(final String filename,
final String extension) {
if (filename == null) {
return false;
}
if (extension == null || extension.length() == 0) {
return indexOfExtension(filename) == -1;
}
final String fileExt = getExtension(filename);
return fileExt.equals(extension);
}
/**
* Checks whether the extension of the filename is one of those specified.
* <p>
* This method obtains the extension as the textual part of the filename
* after the last dot. There must be no directory separator after the dot.
* The extension check is case-sensitive on all platforms.
*
* @param filename
* the filename to query, null returns false
* @param extensions
* the extensions to check for, null checks for no extension
* @return true if the filename is one of the extensions
*/
public static boolean isExtension(final String filename,
final String[] extensions) {
if (filename == null) {
return false;
}
if (extensions == null || extensions.length == 0) {
return indexOfExtension(filename) == -1;
}
final String fileExt = getExtension(filename);
for (final String extension : extensions) {
if (fileExt.equals(extension)) {
return true;
}
}
return false;
}
/**
* Checks whether the extension of the filename is one of those specified.
* <p>
* This method obtains the extension as the textual part of the filename
* after the last dot. There must be no directory separator after the dot.
* The extension check is case-sensitive on all platforms.
*
* @param filename
* the filename to query, null returns false
* @param extensions
* the extensions to check for, null checks for no extension
* @return true if the filename is one of the extensions
*/
public static boolean isExtension(final String filename,
final Collection<String> extensions) {
if (filename == null) {
return false;
}
if (extensions == null || extensions.isEmpty()) {
return indexOfExtension(filename) == -1;
}
final String fileExt = getExtension(filename);
for (final String extension : extensions) {
if (fileExt.equals(extension)) {
return true;
}
}
return false;
}
// -----------------------------------------------------------------------
/**
* Checks a filename to see if it matches the specified wildcard matcher,
* always testing case-sensitive.
* <p>
* The wildcard matcher uses the characters '?' and '*' to represent a
* single or multiple (zero or more) wildcard characters. This is the same
* as often found on Dos/Unix command lines. The check is case-sensitive
* always.
*
* <pre>
* wildcardMatch("c.txt", "*.txt") --> true
* wildcardMatch("c.txt", "*.jpg") --> false
* wildcardMatch("a/b/c.txt", "a/b/*") --> true
* wildcardMatch("c.txt", "*.???") --> true
* wildcardMatch("c.txt", "*.????") --> false
* </pre>
*
* N.B. the sequence "*?" does not work properly at present in match
* strings.
*
* @param filename
* the filename to match on
* @param wildcardMatcher
* the wildcard string to match against
* @return true if the filename matches the wilcard string
* @see IOCase#SENSITIVE
*/
public static boolean wildcardMatch(final String filename,
final String wildcardMatcher) {
return wildcardMatch(filename, wildcardMatcher, true);
}
/**
* Checks a filename to see if it matches the specified wildcard matcher
* using the ignore case rule.
* <p>
* The wildcard matcher uses the characters '?' and '*' to represent a
* single or multiple (zero or more) wildcard characters. This is the same
* as often found on Dos/Unix command lines. The check is case-sensitive on
* Unix and case-insensitive on Windows.
*
* <pre>
* wildcardMatch("c.txt", "*.txt") --> true
* wildcardMatch("c.txt", "*.jpg") --> false
* wildcardMatch("a/b/c.txt", "a/b/*") --> true
* wildcardMatch("c.txt", "*.???") --> true
* wildcardMatch("c.txt", "*.????") --> false
* </pre>
*
* N.B. the sequence "*?" does not work properly at present in match
* strings.
*
* @param filename
* the filename to match on
* @param wildcardMatcher
* the wildcard string to match against
* @return true if the filename matches the wilcard string
* @see IOCase#SYSTEM
*/
public static boolean wildcardMatchIgnoreCase(final String filename,
final String wildcardMatcher) {
return wildcardMatch(filename, wildcardMatcher, false);
}
/**
* Checks a filename to see if it matches the specified wildcard matcher
* allowing control over case-sensitivity.
* <p>
* The wildcard matcher uses the characters '?' and '*' to represent a
* single or multiple (zero or more) wildcard characters. N.B. the sequence
* "*?" does not work properly at present in match strings.
*
* @param filename
* the filename to match on
* @param wildcardMatcher
* the wildcard string to match against
* @param caseSensitivity
* what case sensitivity rule to use, null means case-sensitive
* @return true if the filename matches the wilcard string
* @since 1.3
*/
public static boolean wildcardMatch(final String filename,
final String wildcardMatcher, boolean caseSensitivity) {
if (filename == null && wildcardMatcher == null) {
return true;
}
if (filename == null || wildcardMatcher == null) {
return false;
}
final String[] wcs = splitOnTokens(wildcardMatcher);
boolean anyChars = false;
int textIdx = 0;
int wcsIdx = 0;
final Stack<int[]> backtrack = new Stack<int[]>();
// loop around a backtrack stack, to handle complex * matching
do {
if (backtrack.size() > 0) {
final int[] array = backtrack.pop();
wcsIdx = array[0];
textIdx = array[1];
anyChars = true;
}
// loop whilst tokens and text left to process
while (wcsIdx < wcs.length) {
if (wcs[wcsIdx].equals("?")) {
// ? so move to next text char
textIdx++;
if (textIdx > filename.length()) {
break;
}
anyChars = false;
} else if (wcs[wcsIdx].equals("*")) {
// set any chars status
anyChars = true;
if (wcsIdx == wcs.length - 1) {
textIdx = filename.length();
}
} else {
// matching text token
if (anyChars) {
// any chars then try to locate text token
textIdx = StringUtils.indexOf(filename, textIdx,
wcs[wcsIdx], caseSensitivity);
if (textIdx == -1) {
// token not found
break;
}
final int repeat = StringUtils.indexOf(filename,
textIdx + 1, wcs[wcsIdx], caseSensitivity);
if (repeat >= 0) {
backtrack.push(new int[] { wcsIdx, repeat });
}
} else {
// matching from current position
if (!StringUtils.regionMatches(filename, textIdx,
wcs[wcsIdx], caseSensitivity)) {
// couldnt match token
break;
}
}
// matched text token, move text index to end of matched
// token
textIdx += wcs[wcsIdx].length();
anyChars = false;
}
wcsIdx++;
}
// full match
if (wcsIdx == wcs.length && textIdx == filename.length()) {
return true;
}
} while (backtrack.size() > 0);
return false;
}
/**
* Splits a string into a number of tokens. The text is split by '?' and
* '*'. Where multiple '*' occur consecutively they are collapsed into a
* single '*'.
*
* @param text
* the text to split
* @return the array of tokens, never null
*/
static String[] splitOnTokens(final String text) {
// used by wildcardMatch
// package level so a unit test may run on this
if (text.indexOf('?') == -1 && text.indexOf('*') == -1) {
return new String[] { text };
}
final char[] array = text.toCharArray();
final ArrayList<String> list = new ArrayList<String>();
final StringBuilder buffer = new StringBuilder();
for (int i = 0; i < array.length; i++) {
if (array[i] == '?' || array[i] == '*') {
if (buffer.length() != 0) {
list.add(buffer.toString());
buffer.setLength(0);
}
if (array[i] == '?') {
list.add("?");
} else if (list.isEmpty() || i > 0
&& list.get(list.size() - 1).equals("*") == false) {
list.add("*");
}
} else {
buffer.append(array[i]);
}
}
if (buffer.length() != 0) {
list.add(buffer.toString());
}
return list.toArray(new String[list.size()]);
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/util/MapUtils.java
|
package ai.preferred.cerebro.core.util;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/**
* MapUtils
* @author ddle.2015
*
*/
public class MapUtils {
public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> unsortMap) {
List<Map.Entry<K, V>> list =
new LinkedList<Map.Entry<K, V>>(unsortMap.entrySet());
Collections.sort(list, new Comparator<Map.Entry<K, V>>() {
public int compare(Map.Entry<K, V> o1, Map.Entry<K, V> o2) {
return (o2.getValue()).compareTo(o1.getValue());
}
});
Map<K, V> result = new LinkedHashMap<K, V>();
for (Map.Entry<K, V> entry : list) {
result.put(entry.getKey(), entry.getValue());
}
return result;
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/util/NumberUtils.java
|
package ai.preferred.cerebro.core.util;
import java.text.DecimalFormat;
import java.text.NumberFormat;
/**
* NumberUtils
* @author ddle.2015
*
*/
public class NumberUtils {
private static final int DEFAULT_INT = 0;
private static final long DEFAULT_LONG = 0L;
private static final float DEFAULT_FLOAT = 0F;
private static final double DEFAULT_DOUBLE = 0D;
public static boolean isZero(double value) {
return Math.round(value) == 0;
}
public static boolean isZero(double value, int d) {
return d != 0 ? Math.round(value * Math.pow(10, d)) == 0
: isZero(value);
}
public static int getDefaultInt() {
return DEFAULT_INT;
}
public static long getDefaultLong() {
return DEFAULT_LONG;
}
public static float getDefaultFloat() {
return DEFAULT_FLOAT;
}
public static double getDefaultDouble() {
return DEFAULT_DOUBLE;
}
public static Integer getObject(int value) {
return new Integer(value);
}
public static Long getObject(long value) {
return new Long(value);
}
public static Float getObject(float value) {
return new Float(value);
}
public static Double getObject(double value) {
return new Double(value);
}
public static Boolean getObject(boolean value) {
return new Boolean(value);
}
public static String formatNumber(String pattern, double value) {
return new DecimalFormat(pattern).format(value);
}
public static String formatNumber(String pattern, long value) {
return new DecimalFormat(pattern).format(value);
}
public static String formatNumber(String pattern, Object value) {
return new DecimalFormat(pattern).format(value);
}
public static int parseInt(Object value) {
return parseInt(value, DEFAULT_INT);
}
public static int parseInt(Object value, int defaultValue) {
if (value == null)
return defaultValue;
if (value instanceof Integer)
return ((Integer) value).intValue();
try {
return NumberFormat.getIntegerInstance().parse(value.toString())
.intValue();
} catch (Exception ex) {
return defaultValue;
}
}
public static long parseLong(Object value) {
return parseLong(value, DEFAULT_LONG);
}
public static long parseLong(Object value, long defaultValue) {
if (value == null)
return defaultValue;
if (value instanceof Long)
return ((Long) value).longValue();
try {
return NumberFormat.getNumberInstance().parse(value.toString())
.longValue();
} catch (Exception ex) {
return defaultValue;
}
}
public static float parseFloat(Object value) {
return parseFloat(value, DEFAULT_FLOAT);
}
public static float parseFloat(Object value, float defaultValue) {
if (value == null)
return defaultValue;
if (value instanceof Float)
return ((Float) value).floatValue();
try {
return Float.parseFloat(value.toString());
} catch (Exception ex) {
return defaultValue;
}
}
public static double parseDouble(Object value) {
return parseDouble(value, DEFAULT_DOUBLE);
}
public static double parseDouble(Object value, double defaultValue) {
if (value == null)
return defaultValue;
if (value instanceof Double)
return ((Double) value).doubleValue();
try {
return Double.parseDouble(value.toString());
} catch (Exception ex) {
return defaultValue;
}
}
public static boolean areEqual(Integer value1, Integer value2) {
return parseInt(value1) == parseInt(value2);
}
public static int[] parseAsIntArray(Object[] objArray){
int[] intArray = new int[objArray.length];
for(int i = 0; i < intArray.length; i++){
intArray[i] = parseInt(objArray[i]);
}
return intArray;
}
public static double[] parseAsDoubleArray(Object[] objArray){
double[] doubleArray = new double[objArray.length];
for(int i = 0; i < objArray.length; i++){
doubleArray[i] = parseDouble(objArray[i]);
}
return doubleArray;
}
public static long[] parseAsLongArray(Object[] objArray){
long[] longArray = new long[objArray.length];
for(int i = 0; i < objArray.length; i++){
longArray[i] = parseLong(objArray[i]);
}
return longArray;
}
public static double roundDouble(Double value, int numDecimal){
if(value == null) return 0;
if(numDecimal == -1) return value;
double de = Math.pow(10, numDecimal);
return (double)Math.round(value*de)/de;
}
public static double logb(double a, double b) {
return Math.log(a) / Math.log(b);
}
public static double log2(double value){
return logb(value, 2);
}
public static boolean isNumber(String s){
for(int i = 0; i < s.length(); i++){
char c = s.charAt(i);
if((int) c < 48 || (int) c > 57 ) return false;
}
return true;
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/util/ObjectUtils.java
|
package ai.preferred.cerebro.core.util;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.Serializable;
/**
* ObjectUtils
* @author ddle.2015
*
*/
public class ObjectUtils {
public static Object coalesce(Object... objArray) {
for (Object obj : objArray)
if (!isNull(obj))
return obj;
return null;
}
public static boolean isAnyNull(Object... objArray) {
for (Object obj : objArray)
if (isNull(obj))
return true;
return false;
}
public static boolean isAllNull(Object... objArray) {
for (Object obj : objArray)
if (!isNull(obj))
return false;
return true;
}
public static boolean isNull(Object value) {
return (value == null);
}
public static boolean isNullOrEmpty(Object value) {
if (value == null)
return true;
if (value instanceof String)
return "".equals(value);
return "".equals(value.toString());
}
public static boolean isNullOrWhiteSpace(Object value) {
if (value == null)
return true;
if (value instanceof String)
return "".equals(((String) value).trim());
return value.toString() == null || "".equals(value.toString().trim());
}
public static Object getObject(int value) {
return new Integer(value);
}
public static Object getObject(long value) {
return new Long(value);
}
public static Object getObject(float value) {
return new Float(value);
}
public static Object getObject(double value) {
return new Double(value);
}
public static Object getObject(boolean value) {
return new Boolean(value);
}
public static Object getObject(Object object) {
return object;
}
public static Object getObject(Object object, Object defaultObject) {
return object != null ? object : defaultObject;
}
@SuppressWarnings("rawtypes")
public static String normalizeClassName(Class type) {
if (!type.isArray())
return type.getName();
StringBuffer className = new StringBuffer();
try {
className.append(getArrayBaseType(type).getName() + " ");
for (int i = 0; i < getArrayDimensions(type); i++)
className.append("[]");
} catch (Exception e) { /* shouldn't happen */
}
return className.toString();
}
@SuppressWarnings("rawtypes")
public static int getArrayDimensions(Class arrayClass) {
if (!arrayClass.isArray())
return 0;
return arrayClass.getName().lastIndexOf('[') + 1;
}
@SuppressWarnings("rawtypes")
public static Class getArrayBaseType(Class arrayClass) throws Exception {
if (!arrayClass.isArray())
throw new Exception("The class is not an array.");
return arrayClass.getComponentType();
}
public static void save(Object obj, String fileName) throws IOException {
if (!(obj instanceof Serializable)) {
throw new IllegalArgumentException("Type " + obj.getClass()
+ " is not serializable");
}
OutputStream out = null;
ObjectOutputStream oout = null;
try {
out = new FileOutputStream(fileName);
oout = new ObjectOutputStream(out);
oout.writeObject(obj);
} finally {
oout.close();
}
}
public static Object load(String fileName) throws IOException,
ClassNotFoundException {
Object obj = null;
FileInputStream in = null;
try {
in = new FileInputStream(fileName);
obj = deserialize(in);
} finally {
in.close();
}
return obj;
}
public static byte[] serialize(Object obj) throws IOException {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bytes);
out.writeObject(obj);
out.close();
byte[] ret = bytes.toByteArray();
return ret;
}
public static Object deserialize(InputStream in) throws IOException,
ClassNotFoundException {
Object obj = null;
ObjectInputStream oin = null;
try {
oin = new ObjectInputStream(in);
obj = oin.readObject();
} finally {
oin.close();
}
return obj;
}
public static Object deserialize(byte[] bytes) throws Exception {
if (bytes == null || bytes.length <= 0)
return null;
ByteArrayInputStream is = new ByteArrayInputStream(bytes);
Object obj = deserialize(is);
is.close();
return obj;
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/util/StatisticMap.java
|
package ai.preferred.cerebro.core.util;
import java.io.PrintStream;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* StaticMap
* @author ddle.2015
*
*/
public class StatisticMap {
private Map<String, Map<String, Integer>> maps = new HashMap<String, Map<String, Integer>>();
/**
*
* @param cat
* @param subCat
* @param freq
*/
public void incr(String cat, String subCat, int freq){
Map<String, Integer> subMap = maps.get(cat);
if(ObjectUtils.isNull(subMap)){
subMap = new HashMap<String, Integer>();
subMap.put(subCat, freq);
} else {
doIncr(subMap, subCat, freq);
}
doIncr(subMap, "all", freq);
maps.put(cat, subMap);
}
/**
*
* @param withPercentage
*/
public void report(boolean withPercentage){
report(System.out, withPercentage, true);
}
/**
*
* @param out
* @param withPercentage
*/
public void report(PrintStream out, boolean withPercentage){
report(out, withPercentage, true);
}
/**
*
* @param out
* @param withPercentage
* @param sortSubset
*/
public void report(PrintStream out, boolean withPercentage, boolean sortSubset){
for(String key: maps.keySet()){
out.println("----------------------------------------------------------------------------------------");
out.println("Category: " + key);
out.println("----------------------------------------------------------------------------------------");
Map<String, Integer> subMap = maps.get(key);
if(sortSubset) subMap = sortByComparator(subMap, true);
int allFreq = subMap.get("all");
for(String subKey: subMap.keySet()){
if(StringUtils.isNullOrEmpty(subKey)) continue;
if(subKey.equals("all")) out.println("all" + StringUtils.indent("all", 60) + allFreq);
else {
int subFreq = subMap.get(subKey);
double percentage = NumberUtils.roundDouble((double)subFreq*100/allFreq, 2);
out.print(subKey + StringUtils.indent(subKey, 60) + subFreq);
if(withPercentage) out.print(" ( " + percentage + "% )");
out.println();
}
}
}
}
public Set<String> getAllCategories(){
return maps.keySet();
}
/**
*
* @param cat
* @return
*/
public Map<String, Integer> getSubmap(String cat){
Map<String, Integer> subMap = maps.get(cat);
if(ObjectUtils.isNull(subMap)) return null;
return subMap;
}
/**
*
* @param cat
* @param subCat
* @return
*/
public int getValue(String cat, String subCat){
Map<String, Integer> subMap = maps.get(cat);
if(ObjectUtils.isNull(subMap)) return 0;
Integer subFreq = subMap.get(subCat);
return (!ObjectUtils.isNull(subFreq)) ? subFreq : 0;
}
/**
*
* @param cat
* @return
*/
public String getMostFrequentSubcat(String cat){
Map<String, Integer> subMap = maps.get(cat);
if(ObjectUtils.isNull(subMap)) return "";
subMap = sortByComparator(subMap, true);
for(String subKey: subMap.keySet())
if(!"all".equalsIgnoreCase(subKey))
return subKey;
return "";
}
/**
*
* @param cat
* @param topN
* @return
*/
public Map<String, Integer> getTopSubCat(String cat, int topN){
Map<String, Integer> holder = new HashMap<String, Integer>();
Map<String, Integer> subMap = maps.get(cat);
if(ObjectUtils.isNull(subMap)) return holder;
subMap = sortByComparator(subMap, true);
int prevVal = 0;
int topCount = 1;
for(String subKey: subMap.keySet()){
if("all".equalsIgnoreCase(subKey)) continue;
int val = subMap.get(subKey);
if(holder.size() != 0){
if(val != prevVal)
topCount++;
if(topCount > topN) break;
}
holder.put(subKey, topCount);
prevVal = val;
}
return holder;
}
/**
*
* @param cat
* @param freqThreshold
*/
public void compactByFrequency(String cat, int freqThreshold){
Map<String, Integer> subMap = maps.get(cat);
if(ObjectUtils.isNull(subMap)) return;
Set<String> subKeys = subMap.keySet();
Set<String> removingSubKeys = new HashSet<String>();
int smallValue = 0;
for(String subKey: subKeys){
int subFreq = subMap.get(subKey);
if(subFreq < freqThreshold) {
smallValue += subFreq;
removingSubKeys.add(subKey);
}
}
subMap.put("lowerGroup", smallValue);
for(String subKey: removingSubKeys)
remove(cat, subKey);
}
/**
*
* @param cat
* @param freqThreshold
*/
public void eliminateByFrequency(String cat, int freqThreshold){
Map<String, Integer> subMap = maps.get(cat);
if(ObjectUtils.isNull(subMap)) return;
Set<String> subKeys = subMap.keySet();
Set<String> removingSubKeys = new HashSet<String>();
for(String subKey: subKeys){
int subFreq = subMap.get(subKey);
if(subFreq < freqThreshold)
removingSubKeys.add(subKey);
}
for(String subKey: removingSubKeys)
remove(cat, subKey);
}
/**
*
* @param cat
* @param subKey
*/
public void remove(String cat, String subKey){
Map<String, Integer> subMap = maps.get(cat);
if(ObjectUtils.isNull(subMap)) return;
subMap.remove(subKey);
}
public void clearAll(){
maps.clear();
}
/**
*
* @param subMap
* @param subCat
* @param freq
*/
private void doIncr(Map<String, Integer> subMap, String subCat, int freq){
Integer curFreq = subMap.get(subCat);
if(ObjectUtils.isNull(curFreq)) subMap.put(subCat, freq);
else subMap.put(subCat, curFreq + freq);
}
/**
*
* @param unsortMap
* @param desc
* @return
*/
public static Map<String, Integer> sortByComparator(Map<String, Integer> unsortMap, final boolean desc) {
// Convert Map to List
List<Map.Entry<String, Integer>> list =
new LinkedList<Map.Entry<String, Integer>>(unsortMap.entrySet());
// Sort list with comparator, to compare the Map values
Collections.sort(list, new Comparator<Map.Entry<String, Integer>>() {
public int compare(Map.Entry<String, Integer> o1,
Map.Entry<String, Integer> o2) {
if(!desc)
return (o1.getValue()).compareTo(o2.getValue());
else
return (-1)*(o1.getValue()).compareTo(o2.getValue());
}
});
// Convert sorted map back to a Map
Map<String, Integer> sortedMap = new LinkedHashMap<String, Integer>();
for (Iterator<Map.Entry<String, Integer>> it = list.iterator(); it.hasNext();) {
Map.Entry<String, Integer> entry = it.next();
sortedMap.put(entry.getKey(), entry.getValue());
}
return sortedMap;
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/core/util/StringUtils.java
|
package ai.preferred.cerebro.core.util;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.List;
/**
* StringUtils
* @author ddle.2015
*
*/
public class StringUtils {
private static final String DEFAULT_STRING = "";
private static final int STRING_BUFFER_SIZE = 1024;
// Null or Empty -Coalescing
public static Object coalesce(Object... objArray) {
for (Object obj : objArray)
if (!isNullOrEmpty(obj))
return obj;
return DEFAULT_STRING;
}
public static int indexOf(Object container, Object token) {
return parseString(container).indexOf(parseString(token));
}
public static boolean contains(Object container, Object token) {
return indexOf(container, token) >= 0;
}
public static String concat(Object... values) {
StringBuilder builder = new StringBuilder();
for (Object val : values)
builder.append(parseString(val));
return builder.toString();
}
public static boolean in(Object obj, Object[] values) {
String str = parseString(obj);
for (Object val : values)
if (str.equals(parseString(val)))
return true;
return false;
}
public static boolean inIgnoreCase(Object obj, Object[] values) {
String str = parseString(obj);
for (Object val : values)
if (str.equalsIgnoreCase(parseString(val)))
return true;
return false;
}
public static boolean areEqual(Object... vals) {
if (vals.length < 2)
return true;
String reference = parseString(vals[0]);
for (Object val : vals)
if (!parseString(val).equals(reference))
return false;
return true;
}
public static boolean areEqualIgnoreCase(Object... vals) {
if (vals.length < 2)
return true;
String reference = parseString(vals[0]);
for (Object val : vals)
if (!parseString(val).equalsIgnoreCase(reference))
return false;
return true;
}
public static int indexOf(String str, int strStartIndex, String search,
boolean caseSensitivity) {
final int endIndex = str.length() - search.length();
if (endIndex >= strStartIndex) {
for (int i = strStartIndex; i <= endIndex; i++) {
if (regionMatches(str, i, search, caseSensitivity)) {
return i;
}
}
}
return -1;
}
public static boolean regionMatches(String str, int strStartIndex,
String search, boolean caseSensitivity) {
return str.regionMatches(!caseSensitivity, strStartIndex, search, 0,
search.length());
}
public static boolean isNull(Object value) {
return (value == null);
}
public static boolean isNullOrEmpty(Object value) {
if (value == null)
return true;
if (value instanceof String)
return "".equals(value);
return "".equals(value.toString());
}
public static boolean isNullOrWhiteSpace(Object value) {
if (value == null)
return true;
if (value instanceof String)
return "".equals(((String) value).trim());
return value.toString() == null || "".equals(value.toString().trim());
}
public static String getDefaultString() {
return DEFAULT_STRING;
}
public static String parseString(Object value) {
return parseString(value, DEFAULT_STRING);
}
public static String parseString(Object value, String defaultValue) {
if (value == null)
return defaultValue;
if (value instanceof String)
return (String) value;
try {
return value.toString();
} catch (Exception ex) {
return defaultValue;
}
}
public static String trim(Object value) {
return parseString(value).trim();
}
public static String trimToSize(String s, int length) {
return s != null && s.length() > length ? s.substring(0, length) : s;
}
public static String quote(String s) {
int i = s.indexOf("\\E");
if (i == -1)
return (new StringBuffer()).append("\\Q").append(s).append("\\E")
.toString();
StringBuffer stringbuilder = new StringBuffer(s.length() * 2);
stringbuilder.append("\\Q");
i = 0;
int j = 0;
while ((i = s.indexOf("\\E", j)) != -1) {
stringbuilder.append(s.substring(j, i));
j = i + 2;
stringbuilder.append("\\E\\\\E\\Q");
}
stringbuilder.append(s.substring(j, s.length()));
stringbuilder.append("\\E");
return stringbuilder.toString();
}
public static String implode(Object[] elements, String delimiter) {
if (elements.length <= 0)
return "";
StringBuffer buffer = new StringBuffer("");
for (int i = 0; i < elements.length - 1; i++) {
buffer.append(parseString(elements[i]) + delimiter);
}
buffer.append(parseString(elements[elements.length - 1]));
return buffer.toString();
}
public static String implode(Object[] elements) {
return implode(elements, ", ");
}
public static String capitalize(String str) {
return capitalize(str, null);
}
public static String capitalize(String str, char[] delimiters) {
int delimLen = (delimiters == null ? -1 : delimiters.length);
if (str == null || str.length() == 0 || delimLen == 0) {
return str;
}
int strLen = str.length();
StringBuffer buffer = new StringBuffer(strLen);
boolean capitalizeNext = true;
for (int i = 0; i < strLen; i++) {
char ch = str.charAt(i);
if (isDelimiter(ch, delimiters)) {
buffer.append(ch);
capitalizeNext = true;
} else if (capitalizeNext) {
buffer.append(Character.toTitleCase(ch));
capitalizeNext = false;
} else {
buffer.append(ch);
}
}
return buffer.toString();
}
public static String capitalizeFully(String str) {
return capitalizeFully(str, null);
}
public static String capitalizeFully(String str, char[] delimiters) {
int delimLen = (delimiters == null ? -1 : delimiters.length);
if (str == null || str.length() == 0 || delimLen == 0) {
return str;
}
str = str.toLowerCase();
return capitalize(str, delimiters);
}
public static String uncapitalize(String str) {
return uncapitalize(str, null);
}
public static String uncapitalize(String str, char[] delimiters) {
int delimLen = (delimiters == null ? -1 : delimiters.length);
if (str == null || str.length() == 0 || delimLen == 0) {
return str;
}
int strLen = str.length();
StringBuffer buffer = new StringBuffer(strLen);
boolean uncapitalizeNext = true;
for (int i = 0; i < strLen; i++) {
char ch = str.charAt(i);
if (isDelimiter(ch, delimiters)) {
buffer.append(ch);
uncapitalizeNext = true;
} else if (uncapitalizeNext) {
buffer.append(Character.toLowerCase(ch));
uncapitalizeNext = false;
} else {
buffer.append(ch);
}
}
return buffer.toString();
}
private static boolean isDelimiter(char ch, char[] delimiters) {
if (delimiters == null) {
return Character.isWhitespace(ch);
}
for (int i = 0, isize = delimiters.length; i < isize; i++) {
if (ch == delimiters[i]) {
return true;
}
}
return false;
}
public static String[] explode(String str, String regex){
if (str == null || str.length() == 0) {
return null;
}
ArrayList<String> strings = new ArrayList<String>();
String[] els = str.split(regex);
for(String el: els){
el = el.trim();
if(!isNullOrWhiteSpace(el))
strings.add(el);
}
return strings.toArray(new String[strings.size()]);
}
public static String[] explode(String str, int ch) {
return explode(str, ch, false);
}
public static String[] explode(String str, int ch, boolean respectEmpty) {
if (str == null || str.length() == 0) {
return new String[0];
}
ArrayList<String> strings = new ArrayList<String>();
int pos;
int lastpos = 0;
// add snipples
while ((pos = str.indexOf(ch, lastpos)) >= 0) {
if (pos - lastpos > 0 || respectEmpty) {
strings.add(str.substring(lastpos, pos));
}
lastpos = pos + 1;
}
// add rest
if (lastpos < str.length()) {
strings.add(str.substring(lastpos));
} else if (respectEmpty && lastpos == str.length()) {
strings.add("");
}
// return string array
return strings.toArray(new String[strings.size()]);
}
public static String[] tokenize(String str) {
if (str == null)
return new String[0];
String[] tokens = str.split("[ \\t{}():;._,\\-! \"?\n]");
ArrayList<String> list = new ArrayList<String>();
for (String token : tokens) {
if (!isNullOrWhiteSpace(token) && !"rrb".equalsIgnoreCase(token))
list.add(token);
}
return list.toArray(new String[0]);
}
public static String subTokens(String[] tokens, int beginIndex, int endIndex) {
return subTokens(tokens, beginIndex, endIndex, " ");
}
public static String subTokens(String[] tokens, int beginIndex,
int endIndex, String separator) {
if (tokens == null || beginIndex < 0 || endIndex < 0)
return "";
StringBuilder builder = new StringBuilder();
for (int i = beginIndex; i < tokens.length && i < endIndex; i++) {
builder.append(tokens[i]);
if (i != tokens.length - 1 && i != endIndex - 1) {
builder.append(separator);
}
}
return builder.toString().trim();
}
public static void save(Object obj, String fileName) throws IOException {
OutputStream out = null;
OutputStreamWriter owriter = null;
String str = parseString(obj);
try {
out = new FileOutputStream(fileName);
owriter = new OutputStreamWriter(out, "UTF8");
owriter.write(str, 0, str.length());
} finally {
owriter.close();
}
}
public static String load(String fileName) throws IOException {
char[] buffer = new char[STRING_BUFFER_SIZE];
InputStream in = null;
InputStreamReader ireader = null;
StringBuilder str = new StringBuilder();
int len = 0;
try {
in = new FileInputStream(fileName);
ireader = new InputStreamReader(in, "UTF8");
while ((len = ireader.read(buffer, 0, STRING_BUFFER_SIZE)) != -1) {
str.append(buffer, 0, len);
}
} finally {
ireader.close();
}
return str.toString();
}
public static List<String> toList(String str, String separator){
String[] strs = str.split(separator);
return toList(strs);
}
public static List<String> toList(String ...strs){
if(strs == null || strs.length == 0) return null;
List<String> holder = new ArrayList<String>();
for(String sel: strs) holder.add(sel);
return holder;
}
public static String indent(String prefix, int maxNumSpace){
StringBuffer buffer = new StringBuffer();
for(int i = 0; i < maxNumSpace - prefix.length(); i++)
buffer.append(" ");
return buffer.toString();
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/index
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/index/builder/ExtFilter.java
|
package ai.preferred.cerebro.index.builder;
import java.io.File;
import java.io.FileFilter;
/**
* This class acts as a filter to rule out all the file
* extension that should not be read for indexing.
*/
public class ExtFilter implements FileFilter {
final String [] extensions;
/**
* @param extensions contain the file extensions to be accepted for reading.
*/
public ExtFilter(String... extensions) {
this.extensions = extensions;
}
@Override
public boolean accept(File pathname) {
String name = pathname.getName().toLowerCase();
for(String ext : extensions){
if (name.endsWith(ext))
return true;
}
return false;
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/index
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/index/builder/LocalitySensitiveHash.java
|
package ai.preferred.cerebro.index.builder;
import org.apache.lucene.util.BytesRef;
import ai.preferred.cerebro.index.utils.IndexUtils;
import java.util.BitSet;
/**
* This class calculate the hashcode of a vector
* given which set of hashing vectors it was
* created with.
*/
public class LocalitySensitiveHash {
protected final int numHashBit;
protected final int dimension;
protected final double [][] splitVecs;
/**
*
* @param splitVecs the set of hashing vectors.
*/
public LocalitySensitiveHash(double [][] splitVecs){
assert splitVecs.length > 0;
this.splitVecs =splitVecs;
this.numHashBit = splitVecs.length;
this.dimension = splitVecs[0].length;
}
/**
*
* @param features the vector to compute hashcode.
* @return the hashcode of the vector.
*/
public BytesRef getHashBit(double [] features){
assert features.length == dimension;
BitSet hashbits = new BitSet(numHashBit);
for(int i=0; i < numHashBit; i++){
hashbits.set(i, IndexUtils.dotProduct(features, splitVecs[i]) > 0);
}
return new BytesRef(hashbits.toByteArray());
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/index
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/index/builder/LuIndexWriter.java
|
package ai.preferred.cerebro.index.builder;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.Term;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.util.BytesRef;
import ai.preferred.cerebro.core.jpa.entity.IndexMetadata;
import ai.preferred.cerebro.core.jpa.entity.Model;
import ai.preferred.cerebro.index.exception.DocNotClearedException;
import ai.preferred.cerebro.index.exception.UnsupportedDataType;
import ai.preferred.cerebro.index.utils.IndexConst;
import ai.preferred.cerebro.index.utils.IndexUtils;
import ai.preferred.cerebro.index.utils.JPAUtils;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.nio.file.Paths;
/**
* Wrapper class containing an instance of Lucene's {@link IndexWriter}
* that facilitates the indexing of both text objects and latent feature
* vectors.
*
* Note that Right now LuIndexWriter is not thread-safe due to the way it
* uses PersonalizedDocFactory. This will be fixed in a near future version.
*/
public abstract class LuIndexWriter implements VersatileIndexing{
protected IndexWriter writer;
protected PersonalizedDocFactory docFactory = null;
/**
* @param indexDirectoryPath directory to the folder containing the index files.
* @param splitVecPath path to the object file containing the LSH vectors.
* @throws IOException this is triggered when a path or file does not exist.
*
* Constructor using an existing LSHash Vector object. This will try to allocate
* as much memory as possible for the writing buffer.
*
* In case a path LSH vectors object is not specify the indexwriter will still load,
* but any operation involving latent item vector will throw a {@link NullPointerException}.
*/
public LuIndexWriter(String indexDirectoryPath, String splitVecPath) throws IOException {
//Get the maximum amount of memory for indexWriter
long maxHeapSize = Runtime.getRuntime().maxMemory();
long size = maxHeapSize / IndexConst.mb;
if(size > 8192)
size = 8192;
Directory indexDirectory = FSDirectory.open(Paths.get(indexDirectoryPath));
IndexWriterConfig iwc = new IndexWriterConfig(new StandardAnalyzer());
iwc.setRAMBufferSizeMB(size);
writer = new IndexWriter(indexDirectory, iwc);
if(splitVecPath != null){
double[][] splitVecs = IndexUtils.readVectors(splitVecPath);
docFactory = new PersonalizedDocFactory(splitVecs);
}
else {
docFactory = new PersonalizedDocFactory();
}
}
/**
*
* @param indexDirectoryPath directory to the folder containing the index files.
* @param model model ID to decide which configuration to get from the database.
* @param numHash number hashing vector to randomize.
* @throws IOException this is triggered when a path or file does not exist.
*
* Constructor randomizing a new hashtable, then save it to the same folder
* containing the index file and save metadata to database.
*
* Note that this is intented to worked with other unreleased components of
* Cerebro. As such it is not recommended to instantiate {@link LuIndexWriter}
* this way.
*/
public LuIndexWriter(String indexDirectoryPath, int model, int numHash) throws IOException {
this(indexDirectoryPath, null);
Model m = JPAUtils.retrieveModelByModelId(model);
int nbFactor = m.getSettingAsParams().getValueAsInt("nbFactors");
double[][] splitVecs = IndexUtils.randomizeFeatureVectors(numHash, nbFactor, true, false);
docFactory = new PersonalizedDocFactory(splitVecs);
//save the actual hashing vectors to disk
IndexUtils.saveVectors(splitVecs, indexDirectoryPath + "\\splitVec.o");
//save metadata to database
String settings = "numberOfHashes:" + numHash + ",numberOfHashTables:" + 1;
IndexMetadata indexMetadata = new IndexMetadata(m, null, settings, indexDirectoryPath + "\\splitVec.o", null, 0);
JPAUtils.insertIndexMetadataToDB(indexMetadata);
}
/**
* Closes all open resources and releases the write lock.
* <p>
* Note that this may be a costly operation, so, try to re-use
* a single writer instead of closing and opening a new one.
*
* <p><b>NOTE</b>: You must ensure no other threads are still making
* changes at the same time that this method is invoked.</p>
*/
final public void close() throws IOException {
writer.close();
}
/**
* Determines the minimal number of documents required before the buffered
* in-memory documents are flushed as a new Segment. Large values generally
* give faster indexing.
*
* <p>
* When this is set, the writer will flush every maxBufferedDocs added
* documents. Pass in {@link IndexWriterConfig#DISABLE_AUTO_FLUSH} to prevent
* triggering a flush due to number of buffered documents. Note that if
* flushing by RAM usage is also enabled, then the flush will be triggered by
* whichever comes first.
*
* <p>
* Disabled by default (writer flushes by RAM usage).
*
* <p>
* Takes effect immediately, but only the next time a document is added,
* updated or deleted.
*
* @see #setMaxBufferRAMSize(double)
* @throws IllegalArgumentException
* if maxBufferedDocs is enabled but smaller than 2, or it disables
* maxBufferedDocs when ramBufferSize is already disabled.
*/
final public void setMaxBufferDocNum(int num){
writer.getConfig().setMaxBufferedDocs(num);
}
/**
* Determines the amount of RAM that may be used for buffering added documents
* and deletions before they are flushed to the Directory. Generally for
* faster indexing performance it's best to flush by RAM usage instead of
* document count and use as large a RAM buffer as you can.
* <p>
* When this is set, the writer will flush whenever buffered documents and
* deletions use this much RAM. Pass in
* {@link IndexWriterConfig#DISABLE_AUTO_FLUSH} to prevent triggering a flush
* due to RAM usage. Note that if flushing by document count is also enabled,
* then the flush will be triggered by whichever comes first.
* <p>
* The maximum RAM limit is inherently determined by the JVMs available
* memory. Yet, an {@link IndexWriter} session can consume a significantly
* larger amount of memory than the given RAM limit since this limit is just
* an indicator when to flush memory resident documents to the Directory.
* Flushes are likely happen concurrently while other threads adding documents
* to the writer. For application stability the available memory in the JVM
* should be significantly larger than the RAM buffer used for indexing.
* <p>
* <b>NOTE</b>: the account of RAM usage for pending deletions is only
* approximate. Specifically, if you delete by Query, Lucene currently has no
* way to measure the RAM usage of individual Queries so the accounting will
* under-estimate and you should compensate by either calling commit() or refresh()
* periodically yourself.
* <p>
* <b>NOTE</b>: It's not guaranteed that all memory resident documents are
* flushed once this limit is exceeded.
* <p>
*
* The default value is {@link IndexWriterConfig#DEFAULT_RAM_BUFFER_SIZE_MB}.
*
* <p>
* Takes effect immediately, but only the next time a document is added,
* updated or deleted.
*
* @see IndexWriterConfig#setRAMPerThreadHardLimitMB(int)
*
* @throws IllegalArgumentException
* if ramBufferSize is enabled but non-positive, or it disables
* ramBufferSize when maxBufferedDocs is already disabled
*/
final public void setMaxBufferRAMSize(double mb){
writer.getConfig().setRAMBufferSizeMB(mb);
}
/**
*
* @param ID ID of the document to delete
* @throws IOException
* @throws UnsupportedDataType
* Delete a document by its unique ID. Note that
* you should let Cerebro handle the ID field
* automatically, only passing in the ID value
* either as an integer or a string.
*/
public void deleteByID(Object ID) throws IOException, UnsupportedDataType {
Term term = null;
if(ID instanceof String)
term = new Term(IndexConst.IDFieldName, (String)ID);
else if(ID instanceof Integer)
term = new Term(IndexConst.IDFieldName, new BytesRef(IndexUtils.intToByte(((Integer) ID).intValue())));
else
throw new UnsupportedDataType();
writer.deleteDocuments(term);
writer.close();
}
/**
*
* @throws IOException
* With multithreading trying to get all of the index
* in one segment has no advantage. You should let Lucene
* decide when to carry out the index optimization.
*/
public void optimize() throws IOException {
writer.getConfig().setUseCompoundFile(true);
writer.getConfig().getMergePolicy().setNoCFSRatio(1.0);
writer.forceMerge(1);
writer.close();
}
/**
*
* @param dataDirPath directory to the folder containing the data
* @param filter an object to filter out all the type of file we
* don't want to read.
* @throws IOException
*
* This method lists all the acceptable files in the given directory
* and pass them individually to {@link #indexFile(File)} to index
* the file content.
*/
final public void createIndexFromDir(String dataDirPath, FileFilter filter)
throws IOException {
//get all files in the data directory
File[] files = new File(dataDirPath).listFiles();
for (File file : files) {
if(!file.isDirectory()
&& !file.isHidden()
&& file.exists()
&& file.canRead()
&& filter.accept(file)
){
indexFile(file);
}
}
writer.close();
}
/**
* Self-implement this function to parse information from your file to be indexed.
* If you are utilizing personalized search function, plz use docFactory to create your Documents.
* Do not try to create Lucene document directly if you want to use personalized search.
* See the deprecated function {@link #createIndexFromVecData(double[][])} as an example
* of how to work with docFactory.
*/
abstract public void indexFile(File file) throws IOException;
/**
* @param itemVecs the set of item latent vector to be indexes.
* @throws IOException
* @throws DocNotClearedException this exception is triggered when
* a call to {@link PersonalizedDocFactory#create(Object, double[])}
* is not paired with a call to {@link PersonalizedDocFactory#getDoc()}.
*
* This method indexes the given set of vectors, using the
* order number of a document as ID, this
* may vary from use-case to use-case.
*/
public void createIndexFromVecData(double[][] itemVecs) throws Exception {
for(int i = 0; i < itemVecs.length; i++){
docFactory.create(writer.numDocs(), itemVecs[i]);
writer.addDocument(docFactory.getDoc());
}
writer.close();
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/index
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/index/builder/PersonalizedDocFactory.java
|
package ai.preferred.cerebro.index.builder;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.StringField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.util.BytesRef;
import ai.preferred.cerebro.index.exception.DocNotClearedException;
import ai.preferred.cerebro.index.exception.SameNameException;
import ai.preferred.cerebro.index.store.DoubleStoredField;
import ai.preferred.cerebro.index.store.VectorField;
import ai.preferred.cerebro.index.utils.IndexConst;
import ai.preferred.cerebro.index.utils.IndexUtils;
import java.util.Iterator;
/**
* This class handles the creation of Document object
* to ensure that there is no conflict in field name
* and that all the hashcoding behaves as intended.
*/
public class PersonalizedDocFactory {
private LocalitySensitiveHash hashFunc = null;
private Document doc;
PersonalizedDocFactory(double [][] splitVecs){
hashFunc = new LocalitySensitiveHash(splitVecs);
}
PersonalizedDocFactory(){}
/**
* @param ID unique ID of the document.
* @param features the latent feature vector to index.
* @throws DocNotClearedException this exception is triggered when
* a call to {@link #create(Object, double[])} is not paired with a
* call to {@link #getDoc()}.
*
* Only use this function to construct a Document containing latent vector.
* To add additional fields to the Document, use {@link #addField(IndexableField...)}.
* Call {@link #getDoc()} to pass the Document to IndexWriter or before creating a new Document.
*/
public void create(Object ID, double[] features) throws Exception {
if(this.doc != null)
throw new DocNotClearedException();
if(this.hashFunc == null)
throw new Exception("Hashing Vecs not provided");
this.doc = new Document();
StringField idField = null;
if(ID instanceof String)
idField = new StringField(IndexConst.IDFieldName, (String)ID, Field.Store.YES);
else if(ID instanceof Integer)
idField = new StringField(IndexConst.IDFieldName,
new BytesRef(IndexUtils.intToByte(((Integer) ID).intValue())), Field.Store.YES);
doc.add(idField);
/* Storing double vector */
VectorField vecField = new VectorField(features);
doc.add(vecField);
/* adding hashcode */
BytesRef hashcode = hashFunc.getHashBit(features);
doc.add(new StringField(IndexConst.HashFieldName, hashcode, Field.Store.YES));
}
/**
*
* @param ID unique ID of the document
* @param fields the custom fields
* @throws SameNameException this is triggered when one of your custom field has name
* identical to Cerebro reserved word. See more detail at {@link IndexConst}.
* @throws DocNotClearedException this exception is triggered when
* a call to {@link #create(Object, double[])} is not paired with a
* call to {@link #getDoc()}.
*
* Call this function to construct a generic text-only Document.
* Should you need to add latent vector later call getDoc
* and start anew with the other create method.
*/
public void create(Object ID, IndexableField... fields) throws SameNameException, DocNotClearedException {
if(this.doc != null){
throw new DocNotClearedException();
}
this.doc = new Document();
StringField idField = null;
if(ID instanceof String)
idField = new StringField(IndexConst.IDFieldName, (String)ID, Field.Store.YES);
else if(ID instanceof Integer)
idField = new StringField(IndexConst.IDFieldName,
new BytesRef(IndexUtils.intToByte(((Integer) ID).intValue())), Field.Store.YES);
doc.add(idField);
for(IndexableField field : fields){
if(checkReservedFieldName(field.name()))
throw new SameNameException("Same name exception");
this.doc.add(field);
}
}
/**
*
* @param fields
* @throws SameNameException this is triggered when one of your custom field has name
* identical to Cerebro reserved word. See more detail at {@link IndexConst}.
*
* After calling {@link #create(Object, double[])} to create a document with latent vector
* if you still want add more custom fields to a Document then use this function.
*/
public void addField(IndexableField... fields) throws SameNameException {
for(IndexableField f : fields){
/* Name of any other fields must not coincide with the name of any reserved field */
if(checkReservedFieldName(f.name()))
throw new SameNameException("Same name exception");
this.doc.add(f);
}
}
/**
*
* @return the Document object being built since the last {@link #create(Object, double[])}
* or {@link #create(Object, IndexableField...)} call.
*
* After calling this function the pointer doc become null again.
*/
public Document getDoc(){
Document t = this.doc;
this.doc = null;
return t;
}
/**
* @param fieldname
* @return true if the fieldname is the similar to one of the reserved words.
*/
public boolean checkReservedFieldName(String fieldname){
boolean a = fieldname.equals(IndexConst.IDFieldName);
boolean b = fieldname.equals(IndexConst.VecFieldName);
boolean c = fieldname.equals(IndexConst.HashFieldName);
//boolean d = fieldname.equals(IndexConst.VecLenFieldName);
return a || b || c ;//|| d;
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/index
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/index/builder/TextFileFilter.java
|
package ai.preferred.cerebro.index.builder;
import java.io.File;
import java.io.FileFilter;
/**
* A Filter class that only accept .txt files.
* Example on how to apply {@link FileFilter}
* to read only files that you want.
*/
public class TextFileFilter implements FileFilter {
@Override
public boolean accept(File pathname){
return pathname.getName()
.toLowerCase()
.endsWith(".txt");
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/index
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/index/builder/VersatileIndexing.java
|
package ai.preferred.cerebro.index.builder;
/**
* An interface to enforce the functionality of Cerebro's IndexWriter.
*/
public interface VersatileIndexing {
void indexLatentVectors(Object... params) throws Exception;
void indexKeyWords(Object... params) throws Exception;
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/index
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/index/exception/ClosedException.java
|
package ai.preferred.cerebro.index.exception;
/**
* Thrown when you are trying to use a closed {@link ai.preferred.cerebro.index.builder.LuIndexWriter}.
*/
public class ClosedException extends Exception {
public ClosedException(){
super("Object is closed, instantiate a new instance with the same parameter to continue");
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/index
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/index/exception/DocNotClearedException.java
|
package ai.preferred.cerebro.index.exception;
import ai.preferred.cerebro.index.builder.PersonalizedDocFactory;
/**
* Thrown when you call {@link ai.preferred.cerebro.index.builder.PersonalizedDocFactory}'s create functions
* but forget to pair a {@link PersonalizedDocFactory#getDoc()} with a previous create call.
*/
public class DocNotClearedException extends Exception{
public DocNotClearedException(){
super("Doc not returned before being cleared for creating another doc");
}
public DocNotClearedException(String message){
super(message);
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/index
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/index/exception/SameNameException.java
|
package ai.preferred.cerebro.index.exception;
import ai.preferred.cerebro.index.utils.IndexConst;
/**
* Thrown when one of your custom fields has name similar
* to one of Cerebro's reserved keyword. For more information,
* see {@link IndexConst}.
*/
public class SameNameException extends Exception{
public SameNameException(){
super("Field's name matches with preserved keyword exception");
}
public SameNameException(String message){
super(message);
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/index
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/index/exception/UnsupportedDataType.java
|
package ai.preferred.cerebro.index.exception;
/**
* Thrown whenever there is a mismatch in the datatype
* of objects.
*/
public class UnsupportedDataType extends Exception {
public UnsupportedDataType() {
super("There is problem with data type");
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/index
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/index/request/LoadSearcherRequest.java
|
package ai.preferred.cerebro.index.request;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.store.RAMDirectory;
import ai.preferred.cerebro.index.search.structure.LuIndexSearcher;
import ai.preferred.cerebro.index.search.structure.VersatileSearcher;
import java.io.IOException;
import java.nio.file.Paths;
/**
* A class to streamline the creation of a {@link VersatileSearcher}.
*/
public class LoadSearcherRequest {
String indexDir;
String lshVecDir;
boolean loadToRAM;
/**
*
* @param indexDir
* @param lshVecDir
* @param loadToRAM
*
* Note that setting loadToRAM = true is only necessary as a warm-up step
* to speed up searcher. Usually after running a few queries with an in-RAM
* searcher we should close and then use a non-RAM searcher on the same index.
* The new searcher will always outperform the in-RAM one due to caching mechanism
* while also consumes less memory.
*
* You can also use a non-RAM searcher from the start and let the operation system
* eventually caches your index file but this usually takes a longer time than using
* a in-RAM searcher first. Plus doing so means that the first dozens (or hundreds)
* queries will be very slow.
*/
public LoadSearcherRequest(String indexDir, String lshVecDir, boolean loadToRAM) {
this.indexDir = indexDir;
this.lshVecDir = lshVecDir;
this.loadToRAM = loadToRAM;
}
public VersatileSearcher getSearcher() throws IOException {
Directory indexDirectory;
if(loadToRAM){
indexDirectory = new RAMDirectory(FSDirectory.open(Paths.get(indexDir)), null);
return new LuIndexSearcher(DirectoryReader.open(indexDirectory), lshVecDir);
}
else {
indexDirectory = FSDirectory.open(Paths.get(indexDir));
return new LuIndexSearcher(DirectoryReader.open(indexDirectory), lshVecDir);
}
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/index
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/index/request/QueryRequest.java
|
package ai.preferred.cerebro.index.request;
/**
* This class is a search request to be passed into
* {@link ai.preferred.cerebro.index.search.processor.QueryProcessor}
* and get the result. The extra steps are to handle communication
* between the index and other unreleased Cerebro components. Create your
* queries and pass them directly via your searcher if you want to.
*/
public class QueryRequest {
//private int modelId;
private Object queryData;
private int topK;
public QueryType getType() {
return type;
}
private QueryType type;
/**
* Decide how {@link QueryRequest#queryData} will be processed
* and the kind of functionality to support.
*/
public enum QueryType{
KEYWORD,
VECTOR
}
public QueryRequest(/*int modelId,*/ Object queryData, QueryType type ,int topK) {
//check type compatibility
assert checkType(queryData, type);
//this.modelId = modelId;
this.queryData = queryData;
this.topK = topK;
this.type = type;
}
public Object getQueryData() {
return queryData;
}
public void setQueryData(Object queryData) {
//check type compatibility
assert checkType(queryData, type);
this.queryData = queryData;
}
/*public int getModelId() { return modelId; }
public void setModelId(int modelId) { this.modelId = modelId; }*/
public int getTopK() { return topK; }
private static boolean checkType(Object queryData, QueryType type){
switch (type){
case VECTOR:
return queryData instanceof double[];
case KEYWORD:
return queryData instanceof String || queryData instanceof String[];
default:
return false;
}
}
}
|
0
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/index
|
java-sources/ai/preferred/cerebro/1.0/ai/preferred/cerebro/index/response/QueryResponse.java
|
package ai.preferred.cerebro.index.response;
import org.apache.lucene.search.ScoreDoc;
import ai.preferred.cerebro.core.entity.TopKItem;
import java.util.ArrayList;
import java.util.List;
/**
* A class to wrap up the result of any query pass to a
* {@link ai.preferred.cerebro.index.search.processor.QueryProcessor}.
* This is to handle communication between the index and other unreleased
* Cerebro components. You can Get the result of your queries directly from
* your searcher if you want to.
*/
public class QueryResponse<T> {
public QueryResponse(T[] rankedItemList){
this.rankedItemList = rankedItemList;
}
public T[] getRankedItemList() {
return rankedItemList;
}
private T[] rankedItemList;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.