मैं लिखने योग्य वर्ग को लागू करने की कोशिश कर रहा हूं, लेकिन मुझे कोई जानकारी नहीं है कि एक वर्ग के वर्ग को कैसे कार्यान्वित किया जाए, यदि मेरी कक्षा में घोंसला वाली वस्तु है, जैसे सूची, इत्यादि। क्या कोई भी शरीर मेरी मदद कर सकता है?हाडोप में लिखने योग्य वर्ग को कैसे अनुकूलित करें?
public final class Field implements Comparable<Field>, Serializable {
private String name;
private DataType dataType;
private Object value;
private FieldType fieldType;
public Field(){
}
public Field(String name, DataType dataType, FieldType fieldType){
this(name, dataType, null, fieldType);
}
public Field(String name, DataType type, Object value, FieldType fieldType){
this.name = name;
this.dataType = type;
this.value = value;
this.fieldType = fieldType;
}
}
public enum FieldType {
PRI, LOOKUP, SCD, VERSION, OTHER
}
public enum DataType {
UNDEFINED(4) {
public int getSizeInBytes(Object value) {
return STRING.getSizeInBytes(value);
}
},
STRING(4) {
public int getSizeInBytes(Object value) {
if (value == null) {
return 0;
}
return super.getSizeInBytes(value) + (value.toString().length() * 2); // length + chars
}
},
INT(4),
LONG(8),
DOUBLE(8),
DATETIME(8),
BOOLEAN(1),
BYTE(1),
FLOAT(4),
SHORT(2),
CHAR(2),
DATE(8),
TIME(8),
BLOB(0) {
public int getSizeInBytes(Object value) {
if (value == null) {
return 0;
}
return ((byte[])value).length;
}
};
private final int sizeInBytes;
private DataType(int sizeInBytes) {
this.sizeInBytes = sizeInBytes;
}
public int getSizeInBytes(Object value) {
return sizeInBytes;
}
}
प्रयास करें, यह हार्डी समझा जा सकता है .. – JMelnik