Java Code Examples for org.apache.kylin.common.util.BytesUtil#writeLong()

The following examples show how to use org.apache.kylin.common.util.BytesUtil#writeLong() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IntegerDimEnc.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@Override
public void encode(String valueStr, byte[] output, int outputOffset) {
    if (valueStr == null) {
        Arrays.fill(output, outputOffset, outputOffset + fixedLen, NULL);
        return;
    }

    long integer = Long.parseLong(valueStr);
    if (integer > CAP[fixedLen] || integer < TAIL[fixedLen]) {
        if (avoidVerbose++ % 10000 == 0) {
            logger.warn("Expect at most " + fixedLen + " bytes, but got " + valueStr + ", will truncate, hit times:" + avoidVerbose);
        }
    }

    if (integer == TAIL[fixedLen]) {
        if (avoidVerbose2++ % 10000 == 0) {
            logger.warn("Value " + valueStr + " does not fit into " + fixedLen + " bytes ");
        }
    }

    BytesUtil.writeLong(integer + CAP[fixedLen], output, outputOffset, fixedLen);//apply an offset to preserve binary order, overflow is okay
}
 
Example 2
Source File: IntDimEnc.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@Override
public void encode(String valueStr, byte[] output, int outputOffset) {
    if (valueStr == null) {
        Arrays.fill(output, outputOffset, outputOffset + fixedLen, NULL);
        return;
    }

    long integer = Long.parseLong(valueStr);
    if (integer > CAP[fixedLen]) {
        if (avoidVerbose++ % 10000 == 0) {
            logger.warn("Expect at most " + fixedLen + " bytes, but got " + valueStr + ", will truncate, hit times:"
                    + avoidVerbose);
        }
    }

    BytesUtil.writeLong(integer, output, outputOffset, fixedLen);
}
 
Example 3
Source File: IntDimEnc.java    From kylin with Apache License 2.0 6 votes vote down vote up
@Override
public void encode(String valueStr, byte[] output, int outputOffset) {
    if (valueStr == null) {
        Arrays.fill(output, outputOffset, outputOffset + fixedLen, NULL);
        return;
    }

    long integer = Long.parseLong(valueStr);
    if (integer > CAP[fixedLen]) {
        if (avoidVerbose++ % 10000 == 0) {
            logger.warn("Expect at most " + fixedLen + " bytes, but got " + valueStr + ", will truncate, hit times:"
                    + avoidVerbose);
        }
    }

    BytesUtil.writeLong(integer, output, outputOffset, fixedLen);
}
 
Example 4
Source File: BooleanDimEnc.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Override
public void encode(String value, byte[] output, int outputOffset) {
    if (value == null) {
        Arrays.fill(output, outputOffset, outputOffset + fixedLen, NULL);
        return;
    }

    Integer encodeValue = map.get(value);
    if (encodeValue == null) {
        throw new IllegalArgumentException("Value '" + value + "' is not a recognized boolean value.");
    }

    BytesUtil.writeLong(encodeValue, output, outputOffset, fixedLen);
}
 
Example 5
Source File: GTScannerBenchmark2.java    From kylin with Apache License 2.0 5 votes vote down vote up
private CompareTupleFilter eq(ColumnTupleFilter col, int... values) {
    CompareTupleFilter r = new CompareTupleFilter(FilterOperatorEnum.IN);
    r.addChild(col);

    List<ByteArray> list = Lists.newArrayList();
    for (int v : values) {
        int c = col.getColumn().getColumnDesc().getZeroBasedIndex();
        int len = info.getCodeSystem().maxCodeLength(c);
        ByteArray bytes = new ByteArray(len);
        BytesUtil.writeLong(v, bytes.array(), bytes.offset(), len);
        list.add(bytes);
    }
    r.addChild(new ConstantTupleFilter(list));
    return r;
}
 
Example 6
Source File: GTScannerBenchmark2.java    From kylin with Apache License 2.0 5 votes vote down vote up
private CompareTupleFilter gt(ColumnTupleFilter col, int v) {
    CompareTupleFilter r = new CompareTupleFilter(FilterOperatorEnum.GT);
    r.addChild(col);

    int c = col.getColumn().getColumnDesc().getZeroBasedIndex();
    int len = info.getCodeSystem().maxCodeLength(c);
    ByteArray bytes = new ByteArray(len);
    BytesUtil.writeLong(v, bytes.array(), bytes.offset(), len);
    r.addChild(new ConstantTupleFilter(bytes));

    return r;
}
 
Example 7
Source File: GTScannerBenchmark.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
private CompareTupleFilter eq(ColumnTupleFilter col, int... values) {
    CompareTupleFilter r = new CompareTupleFilter(FilterOperatorEnum.IN);
    r.addChild(col);

    List<ByteArray> list = Lists.newArrayList();
    for (int v : values) {
        int c = col.getColumn().getColumnDesc().getZeroBasedIndex();
        int len = info.getCodeSystem().maxCodeLength(c);
        ByteArray bytes = new ByteArray(len);
        BytesUtil.writeLong(v, bytes.array(), bytes.offset(), len);
        list.add(bytes);
    }
    r.addChild(new ConstantTupleFilter(list));
    return r;
}
 
Example 8
Source File: GTScannerBenchmark2.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
private CompareTupleFilter gt(ColumnTupleFilter col, int v) {
    CompareTupleFilter r = new CompareTupleFilter(FilterOperatorEnum.GT);
    r.addChild(col);

    int c = col.getColumn().getColumnDesc().getZeroBasedIndex();
    int len = info.getCodeSystem().maxCodeLength(c);
    ByteArray bytes = new ByteArray(len);
    BytesUtil.writeLong(v, bytes.array(), bytes.offset(), len);
    r.addChild(new ConstantTupleFilter(bytes));

    return r;
}
 
Example 9
Source File: GTScannerBenchmark2.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
private CompareTupleFilter eq(ColumnTupleFilter col, int... values) {
    CompareTupleFilter r = new CompareTupleFilter(FilterOperatorEnum.IN);
    r.addChild(col);

    List<ByteArray> list = Lists.newArrayList();
    for (int v : values) {
        int c = col.getColumn().getColumnDesc().getZeroBasedIndex();
        int len = info.getCodeSystem().maxCodeLength(c);
        ByteArray bytes = new ByteArray(len);
        BytesUtil.writeLong(v, bytes.array(), bytes.offset(), len);
        list.add(bytes);
    }
    r.addChild(new ConstantTupleFilter(list));
    return r;
}
 
Example 10
Source File: BooleanDimEnc.java    From kylin with Apache License 2.0 5 votes vote down vote up
@Override
public void encode(String value, byte[] output, int outputOffset) {
    if (value == null) {
        Arrays.fill(output, outputOffset, outputOffset + fixedLen, NULL);
        return;
    }

    Integer encodeValue = map.get(value);
    if (encodeValue == null) {
        throw new IllegalArgumentException("Value '" + value + "' is not a recognized boolean value.");
    }

    BytesUtil.writeLong(encodeValue, output, outputOffset, fixedLen);
}
 
Example 11
Source File: GTScannerBenchmark.java    From kylin with Apache License 2.0 5 votes vote down vote up
private CompareTupleFilter gt(ColumnTupleFilter col, int v) {
    CompareTupleFilter r = new CompareTupleFilter(FilterOperatorEnum.GT);
    r.addChild(col);

    int c = col.getColumn().getColumnDesc().getZeroBasedIndex();
    int len = info.getCodeSystem().maxCodeLength(c);
    ByteArray bytes = new ByteArray(len);
    BytesUtil.writeLong(v, bytes.array(), bytes.offset(), len);
    r.addChild(new ConstantTupleFilter(bytes));

    return r;
}
 
Example 12
Source File: DateDimEncTest.java    From kylin with Apache License 2.0 4 votes vote down vote up
private String decode(long code) {
    BytesUtil.writeLong(code, buf, 0, buf.length);
    return enc.decode(buf, 0, buf.length);
}
 
Example 13
Source File: Long8Serializer.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
@Override
public void serialize(Long value, ByteBuffer out) {
    BytesUtil.writeLong(value, out);
}
 
Example 14
Source File: TimeDimEncTest.java    From kylin with Apache License 2.0 4 votes vote down vote up
private String decode(long code) {
    BytesUtil.writeLong(code, buf, 0, buf.length);
    return enc.decode(buf, 0, buf.length);
}
 
Example 15
Source File: FilterCodeSystemFactory.java    From kylin with Apache License 2.0 4 votes vote down vote up
@Override
public void serialize(Object code, ByteBuffer buf) {
    BytesUtil.writeLong(Long.parseLong(code.toString()), buf);
}
 
Example 16
Source File: Long8Serializer.java    From kylin with Apache License 2.0 4 votes vote down vote up
@Override
public void serialize(Long value, ByteBuffer out) {
    BytesUtil.writeLong(value, out);
}
 
Example 17
Source File: DateDimEncTest.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
private String decode(long code) {
    BytesUtil.writeLong(code, buf, 0, buf.length);
    return enc.decode(buf, 0, buf.length);
}
 
Example 18
Source File: TimeDimEncTest.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
private String decode(long code) {
    BytesUtil.writeLong(code, buf, 0, buf.length);
    return enc.decode(buf, 0, buf.length);
}
 
Example 19
Source File: FixedPointLongCodec.java    From Kylin with Apache License 2.0 4 votes vote down vote up
@Override
public void write(LongWritable v, byte[] buf, int offset) {
    BytesUtil.writeLong(v == null ? 0 : v.get(), buf, offset, SIZE);
}
 
Example 20
Source File: FilterCodeSystemFactory.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
@Override
public void serialize(Object code, ByteBuffer buf) {
    BytesUtil.writeLong(Long.parseLong(code.toString()), buf);
}