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:cn.edu.hfut.dmic.webcollectorcluster.model.Content.java

@Override
public void readFields(DataInput di) throws IOException {
    contentType = Text.readString(di);
    int length = di.readInt();
    content = new byte[length];
    di.readFully(content);/*from w w  w  . j ava2s.  c  o  m*/

}

From source file:cn.edu.hfut.dmic.webcollectorcluster.model.CrawlDatum.java

License:Open Source License

@Override
public void readFields(DataInput di) throws IOException {
    url = Text.readString(di);
    status = di.readInt();
    fetchTime = di.readLong();
}

From source file:cn.edu.hfut.dmic.webcollectorcluster.model.Link.java

License:Open Source License

@Override
public void readFields(DataInput di) throws IOException {
    anchor = Text.readString(di);
    url = Text.readString(di);
}

From source file:cn.edu.hfut.dmic.webcollectorcluster.parser.ParseData.java

License:Open Source License

@Override
public void readFields(DataInput di) throws IOException {
    url = Text.readString(di);
    int size = di.readInt();
    links = new ArrayList<Link>();
    for (int i = 0; i < size; i++) {
        Link link = new Link();
        link.readFields(di);/*w w w . ja  va  2  s .  c  o m*/
        links.add(link);
    }
}

From source file:cn.edu.jnu.ie.backend.NutchDocument.java

License:Apache License

public void readFields(DataInput in) throws IOException {
    fields.clear();/*w w  w  . jav  a  2s  .c om*/
    byte version = in.readByte();
    if (version != VERSION) {
        throw new VersionMismatchException(VERSION, version);
    }
    int size = WritableUtils.readVInt(in);
    for (int i = 0; i < size; i++) {
        String name = Text.readString(in);
        NutchField field = new NutchField();
        field.readFields(in);
        fields.put(name, field);
    }
    weight = in.readFloat();
}

From source file:cn.edu.jnu.ie.backend.NutchField.java

License:Apache License

public void readFields(DataInput in) throws IOException {
    weight = in.readFloat();/*from  w  w  w .  j  a va  2s.c o  m*/
    int count = in.readInt();
    values = new ArrayList<Object>();
    for (int i = 0; i < count; i++) {
        String type = Text.readString(in);

        if (type.equals("java.lang.String")) {
            values.add(Text.readString(in));
        } else if (type.equals("java.lang.Boolean")) {
            values.add(in.readBoolean());
        } else if (type.equals("java.lang.Integer")) {
            values.add(in.readInt());
        } else if (type.equals("java.lang.Float")) {
            values.add(in.readFloat());
        } else if (type.equals("java.lang.Long")) {
            values.add(in.readLong());
        } else if (type.equals("java.util.Date")) {
            values.add(new Date(in.readLong()));
        }
    }
}

From source file:co.cask.cdap.etl.batch.mapreduce.TaggedWritable.java

License:Apache License

@Override
public void readFields(DataInput in) throws IOException {
    this.stageName = Text.readString(in);
    this.recordWritable.readFields(in);
    this.record = (RECORD) recordWritable.get();
}

From source file:co.cask.cdap.internal.app.runtime.batch.dataset.DataSetInputSplit.java

License:Apache License

@SuppressWarnings("unchecked")
@Override/*from   ww  w  . j  a v  a 2 s . com*/
public void readFields(final DataInput in) throws IOException {
    try {
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        if (classLoader == null) {
            classLoader = getClass().getClassLoader();
        }
        Class<? extends Split> splitClass = (Class<Split>) classLoader.loadClass(Text.readString(in));
        split = new Gson().fromJson(Text.readString(in), splitClass);
    } catch (ClassNotFoundException e) {
        throw Throwables.propagate(e);
    }
}

From source file:co.cask.cdap.internal.app.runtime.batch.dataset.input.MultiInputTaggedSplit.java

License:Apache License

@SuppressWarnings("unchecked")
@Override/*from  w  ww . j a va2s. c  o  m*/
protected void readAdditionalFields(DataInput in) throws IOException {
    name = Text.readString(in);
    mapperClassName = Text.readString(in);
    inputConfigs = GSON.fromJson(Text.readString(in), STRING_STRING_MAP_TYPE);
    inputFormatClass = (Class<? extends InputFormat<?, ?>>) readClass(in);
}

From source file:co.cask.cdap.internal.app.runtime.batch.dataset.input.TaggedInputSplit.java

License:Apache License

@SuppressWarnings("unchecked")
@Override//w  w  w  . ja v a2 s.com
public void readFields(DataInput in) throws IOException {
    name = Text.readString(in);
    inputSplitClass = (Class<? extends InputSplit>) readClass(in);
    inputFormatClass = (Class<? extends InputFormat<?, ?>>) readClass(in);
    mapperClassName = Text.readString(in);
    inputConfigs = GSON.fromJson(Text.readString(in), STRING_STRING_MAP_TYPE);
    inputSplit = ReflectionUtils.newInstance(inputSplitClass, conf);
    SerializationFactory factory = new SerializationFactory(conf);
    Deserializer deserializer = factory.getDeserializer(inputSplitClass);
    deserializer.open((DataInputStream) in);
    inputSplit = (InputSplit) deserializer.deserialize(inputSplit);
}