List of usage examples for org.apache.hadoop.io ObjectWritable writeObject
public static void writeObject(DataOutput out, Object instance, Class declaredClass, Configuration conf) throws IOException
From source file:org.apache.gora.filter.MapFieldValueFilter.java
License:Apache License
@Override public void write(DataOutput out) throws IOException { Text.writeString(out, fieldName); Text.writeString(out, mapKey.toString()); WritableUtils.writeEnum(out, filterOp); WritableUtils.writeVInt(out, operands.size()); for (int i = 0; i < operands.size(); i++) { Object operand = operands.get(i); if (operand instanceof String) { throw new IllegalStateException("Use Utf8 instead of String for operands"); }//from ww w . j a v a 2s .c o m if (operand instanceof Utf8) { operand = operand.toString(); } if (operand instanceof Boolean) { ObjectWritable.writeObject(out, operand, Boolean.TYPE, conf); } else if (operand instanceof Character) { ObjectWritable.writeObject(out, operand, Character.TYPE, conf); } else if (operand instanceof Byte) { ObjectWritable.writeObject(out, operand, Byte.TYPE, conf); } else if (operand instanceof Short) { ObjectWritable.writeObject(out, operand, Short.TYPE, conf); } else if (operand instanceof Integer) { ObjectWritable.writeObject(out, operand, Integer.TYPE, conf); } else if (operand instanceof Long) { ObjectWritable.writeObject(out, operand, Long.TYPE, conf); } else if (operand instanceof Float) { ObjectWritable.writeObject(out, operand, Float.TYPE, conf); } else if (operand instanceof Double) { ObjectWritable.writeObject(out, operand, Double.TYPE, conf); } else if (operand instanceof Void) { ObjectWritable.writeObject(out, operand, Void.TYPE, conf); } else { ObjectWritable.writeObject(out, operand, operand.getClass(), conf); } } out.writeBoolean(filterIfMissing); }
From source file:org.apache.gora.filter.SingleFieldValueFilter.java
License:Apache License
@Override public void write(DataOutput out) throws IOException { Text.writeString(out, fieldName); WritableUtils.writeEnum(out, filterOp); WritableUtils.writeVInt(out, operands.size()); for (int i = 0; i < operands.size(); i++) { Object operand = operands.get(i); if (operand instanceof String) { throw new IllegalStateException("Use Utf8 instead of String for operands"); }/*from w w w . ja v a2 s. co m*/ if (operand instanceof Utf8) { operand = operand.toString(); } if (operand instanceof Boolean) { ObjectWritable.writeObject(out, operand, Boolean.TYPE, conf); } else if (operand instanceof Character) { ObjectWritable.writeObject(out, operand, Character.TYPE, conf); } else if (operand instanceof Byte) { ObjectWritable.writeObject(out, operand, Byte.TYPE, conf); } else if (operand instanceof Short) { ObjectWritable.writeObject(out, operand, Short.TYPE, conf); } else if (operand instanceof Integer) { ObjectWritable.writeObject(out, operand, Integer.TYPE, conf); } else if (operand instanceof Long) { ObjectWritable.writeObject(out, operand, Long.TYPE, conf); } else if (operand instanceof Float) { ObjectWritable.writeObject(out, operand, Float.TYPE, conf); } else if (operand instanceof Double) { ObjectWritable.writeObject(out, operand, Double.TYPE, conf); } else if (operand instanceof Void) { ObjectWritable.writeObject(out, operand, Void.TYPE, conf); } else { ObjectWritable.writeObject(out, operand, operand.getClass(), conf); } } out.writeBoolean(filterIfMissing); }