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.twitter.hraven.QualifiedJobId.java

License:Apache License

@Override
public void readFields(DataInput in) throws IOException {
    super.readFields(in);
    this.cluster = Text.readString(in);
}

From source file:com.twitter.hraven.TaskKey.java

License:Apache License

@Override
public void readFields(DataInput in) throws IOException {
    super.readFields(in);
    this.taskId = Text.readString(in);
}

From source file:com.willetinc.hadoop.mapreduce.dynamodb.AttributeValueIOUtils.java

License:Apache License

public static AttributeValue read(Types type, DataInput in) throws IOException {
    AttributeValue value = new AttributeValue();
    switch (type) {
    case STRING://from  ww w . java 2s  . co m
        value.withS(Text.readString(in));
        break;
    case NUMBER:
        value.withN(Text.readString(in));
        break;
    case BINARY:
        byte[] bytes = WritableUtils.readCompressedByteArray(in);
        ByteBuffer buf = ByteBuffer.wrap(bytes);
        value.withB(buf);
    case STRING_SET:
    case NUMBER_SET:
    case BINARY_SET: {
        // handle sets
        int size = in.readInt();
        List<AttributeValue> values = new ArrayList<AttributeValue>(size);
        for (int i = 0; i < size; i++) {
            switch (type) {
            case STRING_SET:
                values.add(read(Types.STRING, in));
                break;
            case NUMBER_SET:
                values.add(read(Types.NUMBER, in));
                break;
            case BINARY_SET:
                values.add(read(Types.BINARY, in));
                break;
            default:
                throw new IOException("Nested sets of sets are not permitted");
            }
        }
        break;
    }
    }

    return value;
}

From source file:com.xiaomi.linden.hadoop.indexing.keyvalueformat.Shard.java

License:Apache License

@Override
public void readFields(DataInput in) throws IOException {
    dir = Text.readString(in);
}

From source file:com.xiaomi.linden.hadoop.indexing.reduce.RAMDirectoryUtil.java

License:Apache License

/**
 * Read a number of files from a data input to a ram directory.
 * @param in  the data input//from  w  w w . j a v  a2  s .c o  m
 * @param dir  the ram directory
 * @throws IOException
 */
public static void readRAMFiles(DataInput in, RAMDirectory dir) throws IOException {
    int numFiles = in.readInt();

    for (int i = 0; i < numFiles; i++) {
        String name = Text.readString(in);
        long length = in.readLong();

        if (length > 0) {
            // can we avoid the extra copy?
            IndexOutput output = null;
            try {
                IOContext context = new IOContext();
                output = dir.createOutput(name, context);

                int position = 0;
                byte[] buffer = new byte[BUFFER_SIZE];

                while (position < length) {
                    int len = position + BUFFER_SIZE <= length ? BUFFER_SIZE : (int) (length - position);
                    in.readFully(buffer, 0, len);
                    output.writeBytes(buffer, 0, len);
                    position += len;
                }
            } finally {
                if (output != null) {
                    output.close();
                }
            }
        }
    }
}

From source file:com.yahoo.druid.hadoop.DruidInputSplit.java

License:Apache License

@Override
public void readFields(DataInput in) throws IOException {
    path = Text.readString(in);
}

From source file:com.yahoo.glimmer.indexing.generator.TermKey.java

License:Open Source License

public void readFields(DataInput in) throws IOException {
    value.readFields(in);
    index = in.readInt();
    term = Text.readString(in);
}

From source file:cosmos.records.impl.MapRecord.java

License:Apache License

@Override
public void readFields(DataInput in) throws IOException {
    this.docId = Text.readString(in);

    final int cvLength = WritableUtils.readVInt(in);
    final byte[] cvBytes = new byte[cvLength];
    in.readFully(cvBytes);/*from w  w w  .j a  v a 2  s .c  o  m*/

    this.docVisibility = new ColumnVisibility(cvBytes);

    final int entryCount = WritableUtils.readVInt(in);
    this.document = Maps.newHashMapWithExpectedSize(entryCount);

    for (int i = 0; i < entryCount; i++) {

        this.document.put(Column.recreate(in), RecordValue.recreate(in));
    }
}

From source file:cosmos.records.impl.MultimapRecord.java

License:Apache License

@Override
public void readFields(DataInput in) throws IOException {
    this.docId = Text.readString(in);

    final int cvLength = WritableUtils.readVInt(in);
    final byte[] cvBytes = new byte[cvLength];
    in.readFully(cvBytes);/*from   w ww. j a v  a 2  s .c o m*/

    this.docVisibility = new ColumnVisibility(cvBytes);

    final int entryCount = WritableUtils.readVInt(in);
    this.document = HashMultimap.create();

    for (int i = 0; i < entryCount; i++) {
        this.document.put(Column.recreate(in), RecordValue.recreate(in));
    }
}

From source file:cosmos.results.Column.java

License:Apache License

public void readFields(DataInput in) throws IOException {
    this.name = Text.readString(in);
}