@Override public void serialize(Long value, ByteBuffer out) { BytesUtil.writeLong(value, out); }
public static void writeSignedLong(long num, byte[] bytes, int offset, int size) { writeLong(num, bytes, offset, size); }
@Override public void serialize(Object code, ByteBuffer buf) { BytesUtil.writeLong(Long.parseLong(code.toString()), buf); }
@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); }
@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); }
@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 }
@Override public void encode(String value, byte[] output, int outputOffset) { if (value == null) { Arrays.fill(output, outputOffset, outputOffset + fixedLen, NULL); return; } long code = codec.valueToCode(value); BytesUtil.writeLong(code, output, outputOffset, fixedLen); }
private String decode(long code) { BytesUtil.writeLong(code, buf, 0, buf.length); return enc.decode(buf, 0, buf.length); }
private String decode(long code) { BytesUtil.writeLong(code, buf, 0, buf.length); return enc.decode(buf, 0, buf.length); }
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; }
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; }
@Override public GTRecord next() { for (int i = 0; i < colSpecs.size(); i++) { ColSpec spec = colSpecs.get(i); if (spec.cardinality > 0) { // dimension case long v = dist[i].next(); if (v < 0) { dist[i] = new Distribution(spec, parentLevelCount(i)); v = dist[i].next(); } ByteArray bytes = rec.get(i); assert bytes.length() == spec.length; BytesUtil.writeLong(v, bytes.array(), bytes.offset(), bytes.length()); } else { // measure case int len = spec.measureRandomizer.fillRandom(rand, rec.get(i).array(), 0); rec.get(i).setLength(len); } } counter++; return rec; }
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; }
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; }
@Override public void write(LongWritable v, byte[] buf, int offset) { BytesUtil.writeLong(v == null ? 0 : v.get(), buf, offset, SIZE); } }
int encodeKey(short shard, long timestamp, int col, int colValue, byte[] buf, int offset) { int i = offset; BytesUtil.writeUnsigned(shard, buf, i, SHARD_LEN); i += SHARD_LEN; BytesUtil.writeLong(timestamp, buf, i, TIMEPART_LEN); i += TIMEPART_LEN; BytesUtil.writeUnsigned(col, buf, i, COLNO_LEN); i += COLNO_LEN; if (colValue >= 0) { int colLen = infoDigest.length(col); BytesUtil.writeUnsigned(colValue, buf, i, colLen); i += colLen; } return i - offset; }
BytesUtil.writeLong(cuboidID, newKeyBuf, bufOffset, RowConstants.ROWKEY_CUBOIDID_LEN); bufOffset += RowConstants.ROWKEY_CUBOIDID_LEN;
@Override public void write(LongWritable v, byte[] buf, int offset) { BytesUtil.writeLong(v == null ? 0 : v.get(), buf, offset, SIZE); } }
@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); }
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; }