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

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

Introduction

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

Prototype

@Override
public byte[] getBytes() 

Source Link

Document

Returns the raw bytes; however, only data up to #getLength() is valid.

Usage

From source file:org.apache.accumulo.core.iterators.user.TransformingIterator.java

License:Apache License

/**
 * Make a new key with all parts (including delete flag) coming from {@code originalKey} but use {@code newColVis} as the column visibility.
 */// www  .j  a  v a2 s  .  c  om
protected Key replaceColumnVisibility(Key originalKey, Text newColVis) {
    byte[] row = originalKey.getRowData().toArray();
    byte[] cf = originalKey.getColumnFamilyData().toArray();
    byte[] cq = originalKey.getColumnQualifierData().toArray();
    byte[] cv = newColVis.getBytes();
    long timestamp = originalKey.getTimestamp();
    Key newKey = new Key(row, 0, row.length, cf, 0, cf.length, cq, 0, cq.length, cv, 0, newColVis.getLength(),
            timestamp);
    newKey.setDeleted(originalKey.isDeleted());
    return newKey;
}

From source file:org.apache.accumulo.core.iterators.user.TransformingIterator.java

License:Apache License

/**
 * Make a new key with a column family, column qualifier, and column visibility. Copy the rest of the parts of the key (including delete flag) from
 * {@code originalKey}./* w w w .jav  a  2s .  c o  m*/
 */
protected Key replaceKeyParts(Key originalKey, Text newColFam, Text newColQual, Text newColVis) {
    byte[] row = originalKey.getRowData().toArray();
    byte[] cf = newColFam.getBytes();
    byte[] cq = newColQual.getBytes();
    byte[] cv = newColVis.getBytes();
    long timestamp = originalKey.getTimestamp();
    Key newKey = new Key(row, 0, row.length, cf, 0, newColFam.getLength(), cq, 0, newColQual.getLength(), cv, 0,
            newColVis.getLength(), timestamp);
    newKey.setDeleted(originalKey.isDeleted());
    return newKey;
}

From source file:org.apache.accumulo.core.iterators.user.TransformingIterator.java

License:Apache License

/**
 * Make a new key with a column qualifier, and column visibility. Copy the rest of the parts of the key (including delete flag) from {@code originalKey}.
 *//*from w  w w.j  a  va  2  s  .  c  o m*/
protected Key replaceKeyParts(Key originalKey, Text newColQual, Text newColVis) {
    byte[] row = originalKey.getRowData().toArray();
    byte[] cf = originalKey.getColumnFamilyData().toArray();
    byte[] cq = newColQual.getBytes();
    byte[] cv = newColVis.getBytes();
    long timestamp = originalKey.getTimestamp();
    Key newKey = new Key(row, 0, row.length, cf, 0, cf.length, cq, 0, newColQual.getLength(), cv, 0,
            newColVis.getLength(), timestamp);
    newKey.setDeleted(originalKey.isDeleted());
    return newKey;
}

From source file:org.apache.accumulo.core.replication.ReplicationTarget.java

License:Apache License

/**
 * Deserialize a ReplicationTarget//  w  w  w  .j a  v  a2  s  .c o m
 *
 * @param t
 *          Serialized copy
 * @return the deserialized version
 */
public static ReplicationTarget from(Text t) {
    ReplicationTarget target = new ReplicationTarget();
    DataInputBuffer buffer = new DataInputBuffer();
    buffer.reset(t.getBytes(), t.getLength());

    try {
        target.readFields(buffer);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    return target;
}

From source file:org.apache.accumulo.core.replication.StatusFormatter.java

License:Apache License

protected StringBuilder appendText(StringBuilder sb, Text t) {
    return appendBytes(sb, t.getBytes(), 0, t.getLength());
}

From source file:org.apache.accumulo.core.util.format.BinaryFormatter.java

License:Apache License

public static StringBuilder appendText(StringBuilder sb, Text t) {
    return appendBytes(sb, t.getBytes(), 0, t.getLength());
}

From source file:org.apache.accumulo.core.util.format.DefaultFormatter.java

License:Apache License

static StringBuilder appendText(StringBuilder sb, Text t) {
    return appendBytes(sb, t.getBytes(), 0, t.getLength());
}

From source file:org.apache.accumulo.core.util.format.DefaultFormatter.java

License:Apache License

public static StringBuilder appendText(StringBuilder sb, Text t, int shownLength) {
    return appendBytes(sb, t.getBytes(), 0, t.getLength(), shownLength);
}

From source file:org.apache.accumulo.core.util.LocalityGroupUtil.java

License:Apache License

public static String encodeColumnFamilies(Set<Text> colFams) {
    SortedSet<String> ecfs = new TreeSet<>();

    StringBuilder sb = new StringBuilder();

    for (Text text : colFams) {
        String ecf = encodeColumnFamily(sb, text.getBytes(), text.getLength());
        ecfs.add(ecf);//from   ww w  .  jav a  2s  .co  m
    }

    return Joiner.on(",").join(ecfs);
}

From source file:org.apache.accumulo.core.util.TextUtil.java

License:Apache License

public static byte[] getBytes(Text text) {
    byte[] bytes = text.getBytes();
    if (bytes.length != text.getLength()) {
        bytes = new byte[text.getLength()];
        System.arraycopy(text.getBytes(), 0, bytes, 0, bytes.length);
    }//  w w  w  . ja  v  a  2 s  . c om
    return bytes;
}