Example usage for org.apache.hadoop.fs XAttrCodec HEX

List of usage examples for org.apache.hadoop.fs XAttrCodec HEX

Introduction

In this page you can find the example usage for org.apache.hadoop.fs XAttrCodec HEX.

Prototype

XAttrCodec HEX

To view the source code for org.apache.hadoop.fs XAttrCodec HEX.

Click Source Link

Document

Value encoded as hexadecimal string is prefixed with 0x.

Usage

From source file:com.bigstep.datalake.DLFileSystem.java

License:Apache License

@Override
public void setXAttr(Path p, String name, byte[] value, EnumSet<XAttrSetFlag> flag) throws IOException {
    statistics.incrementWriteOps(1);// ww w  .  j a va 2  s.c o  m
    final HttpOpParam.Op op = PutOpParam.Op.SETXATTR;
    if (value != null) {
        new FsPathRunner(op, p, new XAttrNameParam(name),
                new XAttrValueParam(XAttrCodec.encodeValue(value, XAttrCodec.HEX)), new XAttrSetFlagParam(flag))
                        .run();
    } else {
        new FsPathRunner(op, p, new XAttrNameParam(name), new XAttrSetFlagParam(flag)).run();
    }
}

From source file:com.bigstep.datalake.DLFileSystem.java

License:Apache License

@Override
public byte[] getXAttr(Path p, final String name) throws IOException {
    final HttpOpParam.Op op = GetOpParam.Op.GETXATTRS;
    return new FsPathResponseRunner<byte[]>(op, p, new XAttrNameParam(name),
            new XAttrEncodingParam(XAttrCodec.HEX)) {
        @Override//ww  w  .  j  a  va 2  s . c om
        byte[] decodeResponse(Map<?, ?> json) throws IOException {
            return JsonUtil.getXAttr(json, name);
        }
    }.run();
}

From source file:com.bigstep.datalake.DLFileSystem.java

License:Apache License

@Override
public Map<String, byte[]> getXAttrs(Path p) throws IOException {
    final HttpOpParam.Op op = GetOpParam.Op.GETXATTRS;
    return new FsPathResponseRunner<Map<String, byte[]>>(op, p, new XAttrEncodingParam(XAttrCodec.HEX)) {
        @Override/*from   w ww.j  av a 2 s.  c o m*/
        Map<String, byte[]> decodeResponse(Map<?, ?> json) throws IOException {
            return JsonUtil.toXAttrs(json);
        }
    }.run();
}

From source file:com.bigstep.datalake.DLFileSystem.java

License:Apache License

@Override
public Map<String, byte[]> getXAttrs(Path p, final List<String> names) throws IOException {
    Preconditions.checkArgument(names != null && !names.isEmpty(), "XAttr names cannot be null or empty.");
    Param<?, ?>[] parameters = new Param<?, ?>[names.size() + 1];
    for (int i = 0; i < parameters.length - 1; i++) {
        parameters[i] = new XAttrNameParam(names.get(i));
    }/*from   w  w  w .ja  va  2s.c  o  m*/
    parameters[parameters.length - 1] = new XAttrEncodingParam(XAttrCodec.HEX);

    final HttpOpParam.Op op = GetOpParam.Op.GETXATTRS;
    return new FsPathResponseRunner<Map<String, byte[]>>(op, parameters, p) {
        @Override
        Map<String, byte[]> decodeResponse(Map<?, ?> json) throws IOException {
            return JsonUtil.toXAttrs(json);
        }
    }.run();
}