Example usage for org.apache.hadoop.io Text readString

List of usage examples for org.apache.hadoop.io Text readString

Introduction

In this page you can find the example usage for org.apache.hadoop.io Text readString.

Prototype

public static String readString(DataInput in) throws IOException 

Source Link

Document

Read a UTF8 encoded string from in

Usage

From source file:com.cloudera.sqoop.lib.LobRef.java

License:Apache License

@Override
public void readFields(DataInput in) throws IOException {
    // The serialization format for this object is:
    // boolean isExternal
    // if true, then:
    //   a string identifying the external storage type
    //   and external-storage-specific data.
    // if false, then we use readFieldsInternal() to allow BlobRef/ClobRef
    // to serialize as it sees fit.
    ///*from   w w w.  ja  v  a  2s  . c  om*/
    // Currently the only external storage supported is LobFile, identified
    // by the string "lf". This serializes with the filename (as a string),
    // followed by a long-valued offset and a long-valued length.

    boolean isExternal = in.readBoolean();
    if (isExternal) {
        this.realData = null;

        String storageType = Text.readString(in);
        if (!storageType.equals("lf")) {
            throw new IOException("Unsupported external LOB storage code: " + storageType);
        }

        // Storage type "lf" is LobFile: filename, offset, length.
        this.fileName = Text.readString(in);
        this.offset = in.readLong();
        this.length = in.readLong();
    } else {
        readFieldsInternal(in);

        this.fileName = null;
        this.offset = 0;
        this.length = 0;
    }
}

From source file:com.cloudera.sqoop.mapreduce.MergeRecord.java

License:Apache License

@Override
/**//from  w w w  . java  2 s  .c  o  m
 * {@inheritDoc}
 */
public void readFields(DataInput in) throws IOException {
    this.isNew = in.readBoolean();
    String className = Text.readString(in);
    if (null == this.sqoopRecord) {
        // If we haven't already instantiated an inner SqoopRecord, do so here.
        try {
            Class<? extends SqoopRecord> recordClass = (Class<? extends SqoopRecord>) config
                    .getClassByName(className);
            this.sqoopRecord = recordClass.newInstance();
        } catch (Exception e) {
            throw new IOException(e);
        }
    }

    this.sqoopRecord.readFields(in);
}

From source file:com.conversantmedia.mapreduce.input.FileLineWritable.java

License:Apache License

@Override
public void readFields(DataInput in) throws IOException {
    this.offset = in.readLong();
    this.fileName = Text.readString(in);
}

From source file:com.datasalt.pangool.tuplemr.mapred.lib.input.FileSplit.java

License:Apache License

@Override
public void readFields(DataInput in) throws IOException {
    file = new Path(Text.readString(in));
    start = in.readLong();//from   w  w w . ja va2 s .c om
    length = in.readLong();
    hosts = null;
}

From source file:com.datasalt.pangool.tuplemr.mapred.lib.input.TaggedInputSplit.java

License:Apache License

@SuppressWarnings("unchecked")
public void readFields(DataInput in) throws IOException {
    inputSplitClass = (Class<? extends InputSplit>) readClass(in);
    inputFormatFile = Text.readString(in);
    inputProcessorFile = Text.readString(in);
    inputSplit = (InputSplit) ReflectionUtils.newInstance(inputSplitClass, conf);
    SerializationFactory factory = new SerializationFactory(conf);
    Deserializer deserializer = factory.getDeserializer(inputSplitClass);
    deserializer.open((DataInputStream) in);
    inputSplit = (InputSplit) deserializer.deserialize(inputSplit);
}

From source file:com.digitalpebble.behemoth.BehemothDocument.java

License:Apache License

public final void readFields(DataInput in) throws IOException {

    byte version = in.readByte(); // read version
    if (version > CUR_VERSION) // check version
        throw new VersionMismatchException(CUR_VERSION, version);

    url = Text.readString(in);
    int contentLength = in.readInt();
    content = new byte[contentLength];
    if (contentLength > 0)
        in.readFully(content);// w w w . j  av a2 s.  c o m
    contentType = Text.readString(in);
    boolean hasText = in.readBoolean();
    if (hasText)
        text = Text.readString(in);
    else
        text = null;
    boolean hasMD = in.readBoolean();
    if (hasMD) {
        metadata = new MapWritable();
        metadata.readFields(in);
    } else
        metadata = null;
    // read the number of annotation types
    int numTypes = in.readInt();
    ArrayList<String> types = null;
    if (numTypes > 0) {
        types = new ArrayList<String>(numTypes);
        for (int i = 0; i < numTypes; i++) {
            types.add(Text.readString(in));
        }
    }
    int numAnnots = in.readInt();
    this.annotations = new ArrayList<Annotation>(numAnnots);
    for (int i = 0; i < numAnnots; i++) {
        Annotation annot = new Annotation();
        readAnnotationFields(annot, in, types);
        this.annotations.add(annot);
    }
}

From source file:com.ebay.erl.mobius.core.model.ReadFieldImpl.java

License:Apache License

@Override
protected Void on_string() throws IOException {
    this.values.add(Text.readString(in));
    return null;
}

From source file:com.ebay.erl.mobius.core.model.ReadFieldImpl.java

License:Apache License

@Override
protected Void on_string_map() throws IOException {
    int map_size = in.readInt();
    CaseInsensitiveTreeMap map = new CaseInsensitiveTreeMap();
    for (int j = 0; j < map_size; j++) {
        String k = Text.readString(in);
        String v = Text.readString(in);
        map.put(k, v);/*ww w  .  j av  a  2 s . c  o m*/
    }
    this.values.add(map);
    return null;
}

From source file:com.emadbarsoum.lib.Tuple.java

License:Apache License

/**
 * {@inheritDoc}/*  www .j a v a2  s.co  m*/
 */
@SuppressWarnings("unchecked") // No static typeinfo on Tuples
public void readFields(DataInput in) throws IOException {
    int card = WritableUtils.readVInt(in);
    values = new Writable[card];
    written = WritableUtils.readVLong(in);
    Class<? extends Writable>[] cls = new Class[card];
    try {
        for (int i = 0; i < card; ++i) {
            cls[i] = Class.forName(Text.readString(in)).asSubclass(Writable.class);
        }
        for (int i = 0; i < card; ++i) {
            values[i] = cls[i].newInstance();
            if (has(i)) {
                values[i].readFields(in);
            }
        }
    } catch (ClassNotFoundException e) {
        throw (IOException) new IOException("Failed tuple init").initCause(e);
    } catch (IllegalAccessException e) {
        throw (IOException) new IOException("Failed tuple init").initCause(e);
    } catch (InstantiationException e) {
        throw (IOException) new IOException("Failed tuple init").initCause(e);
    }
}

From source file:com.flipkart.fdp.migration.distcp.config.ConnectionConfig.java

License:Apache License

@Override
public void readFields(DataInput in) throws IOException {
    userName = Text.readString(in);
    userPassword = Text.readString(in);
    keyFile = Text.readString(in);
    connectionURL = Text.readString(in);
    securityType = SecurityType.valueOf(Text.readString(in));
    freeSpaceInBytes = in.readLong();//from   w ww. j ava2s  .co m
    path = Text.readString(in);

}