private static int readVarInt(ByteBuffer buff) { return DataUtils.readVarInt(buff); }
public static ByteBuffer readOperations(ByteBuffer buff) { ByteBuffer operations; int len = DataUtils.readVarInt(buff); if (len > 0) { byte[] value = new byte[len]; buff.get(value); operations = ByteBuffer.wrap(value); } else { operations = EMPTY_BUFFER; } return operations; } }
/** * Check whether the id itself contains all the data. This operation does * not cause any reads in the map. * * @param id the id * @return if the id contains the data */ public boolean isInPlace(byte[] id) { ByteBuffer idBuffer = ByteBuffer.wrap(id); while (idBuffer.hasRemaining()) { if (idBuffer.get() != 0) { return false; } int len = DataUtils.readVarInt(idBuffer); idBuffer.position(idBuffer.position() + len); } return true; }
@Override public Object read(ByteBuffer buff, int tag) { int len = DataUtils.readVarInt(buff); byte[] data = DataUtils.newBytes(len); buff.get(data); return deserialize(data); }
@Override public Value readValue(ByteBuffer buff, int tag) { switch (tag) { case INT: return ValueInt.get(DataUtils.readVarInt(buff)); case TAG_INTEGER_NEGATIVE: return ValueInt.get(-DataUtils.readVarInt(buff)); case TAG_INTEGER_FIXED: return ValueInt.get(buff.getInt()); } return ValueInt.get(tag - TAG_INTEGER_0_15); }
@Override public Object read(ByteBuffer buff, int tag) { switch (tag) { case TAG_BIG_INTEGER_0: return BigInteger.ZERO; case TAG_BIG_INTEGER_1: return BigInteger.ONE; case TAG_BIG_INTEGER_SMALL: return BigInteger.valueOf(DataUtils.readVarLong(buff)); } int len = DataUtils.readVarInt(buff); byte[] bytes = DataUtils.newBytes(len); buff.get(bytes); return new BigInteger(bytes); }
@Override public Object readMeta(ByteBuffer buff, int columnCount) { int vertion = DataUtils.readVarInt(buff); Value[] values = new Value[columnCount]; return new VersionedValue(vertion, ValueArray.get(values)); }
@Override public Value readValue(ByteBuffer buff, int tag) { int len; if (tag == STRING) { len = DataUtils.readVarInt(buff); if (len == 0) return ValueNull.INSTANCE; } else { len = tag - TAG_STRING_0_15; } return ValueString.get(DataUtils.readString(buff, len)); } };
@Override public Object read(ByteBuffer buff) { int vertion = DataUtils.readVarInt(buff); ValueArray value = (ValueArray) valueType.read(buff); return new VersionedValue(vertion, value); }
case 0: len = DataUtils.readVarInt(idBuffer); idBuffer.position(idBuffer.position() + len); buff.append("data len=").append(len); case 1: len = DataUtils.readVarInt(idBuffer); length += len; block = DataUtils.readVarLong(idBuffer); case 2: len = DataUtils.readVarInt(idBuffer); length += DataUtils.readVarLong(idBuffer); block = DataUtils.readVarLong(idBuffer);
@Override public Value readValue(ByteBuffer buff, int tag) { switch (tag) { case TAG_BIG_DECIMAL_0: return ZERO; case TAG_BIG_DECIMAL_1: return ONE; case TAG_BIG_DECIMAL_SMALL: return ValueDecimal.get(BigDecimal.valueOf(DataUtils.readVarLong(buff))); case TAG_BIG_DECIMAL_SMALL_SCALED: int scale = DataUtils.readVarInt(buff); return ValueDecimal.get(BigDecimal.valueOf(DataUtils.readVarLong(buff), scale)); } int scale = DataUtils.readVarInt(buff); int len = DataUtils.readVarInt(buff); byte[] bytes = DataUtils.newBytes(len); buff.get(bytes); BigInteger b = new BigInteger(bytes); return ValueDecimal.get(new BigDecimal(b, scale)); } };
case 0: int len = DataUtils.readVarInt(idBuffer); idBuffer.position(idBuffer.position() + len); length += len; case 1: length += DataUtils.readVarInt(idBuffer); DataUtils.readVarLong(idBuffer); break;
ByteBuffer expandPage(ByteBuffer buff, int type, int start, int pageLength) { boolean compressed = (type & PageUtils.PAGE_COMPRESSED) != 0; if (compressed) { Compressor compressor; if ((type & PageUtils.PAGE_COMPRESSED_HIGH) == PageUtils.PAGE_COMPRESSED_HIGH) { compressor = map.getBTreeStorage().getCompressorHigh(); } else { compressor = map.getBTreeStorage().getCompressorFast(); } int lenAdd = DataUtils.readVarInt(buff); int compLen = pageLength + start - buff.position(); byte[] comp = DataUtils.newBytes(compLen); buff.get(comp); int l = compLen + lenAdd; ByteBuffer newBuff = ByteBuffer.allocate(l); compressor.expand(comp, 0, compLen, newBuff.array(), newBuff.arrayOffset(), l); return newBuff; } return buff; }
@Override public Value readValue(ByteBuffer buff, int tag) { switch (tag) { case TAG_FLOAT_0: return ValueFloat.get(0f); case TAG_FLOAT_1: return ValueFloat.get(1f); case TAG_FLOAT_FIXED: return ValueFloat.get(buff.getFloat()); } return ValueFloat.get(Float.intBitsToFloat(Integer.reverse(DataUtils.readVarInt(buff)))); } };
void readRowStorage(ByteBuffer buff, int chunkId, int offset, int maxLength, boolean disableCheck) { int start = buff.position(); int pageLength = buff.getInt(); checkPageLength(chunkId, pageLength, maxLength); buff.get(); // mode int oldLimit = buff.limit(); buff.limit(start + pageLength); readCheckValue(buff, chunkId, offset, pageLength, disableCheck); int keyLength = DataUtils.readVarInt(buff); keys = new Object[keyLength]; int type = buff.get(); ByteBuffer oldBuff = buff; buff = expandPage(buff, type, start, pageLength); map.getKeyType().read(buff, keys, keyLength); values = new Object[keyLength]; map.getValueType().read(buff, values, keyLength); totalCount = keyLength; replicationHostIds = readReplicationHostIds(buff); recalculateMemory(); oldBuff.limit(oldLimit); }
@Override public Object read(ByteBuffer buff) { int flags = DataUtils.readVarInt(buff); if (flags == -1) { long id = DataUtils.readVarLong(buff); return new SpatialKey(id); } float[] minMax = new float[dimensions * 2]; for (int i = 0; i < dimensions; i++) { float min = buff.getFloat(); float max; if ((flags & (1 << i)) != 0) { max = min; } else { max = buff.getFloat(); } minMax[i + i] = min; minMax[i + i + 1] = max; } long id = DataUtils.readVarLong(buff); return new SpatialKey(id, minMax); }
case 0: int len = DataUtils.readVarInt(idBuffer); idBuffer.position(idBuffer.position() + len); break; case 1: DataUtils.readVarInt(idBuffer); long k = DataUtils.readVarLong(idBuffer); map.remove(k);
int keyLength = DataUtils.readVarInt(buff); int columnCount = DataUtils.readVarInt(buff); keys = new Object[keyLength]; int type = buff.get();
int keyLength = DataUtils.readVarInt(buff); int columnCount = DataUtils.readVarInt(buff); columnPages = new ColumnPageReference[columnCount]; keys = new Object[keyLength];
private static Uncommitted read(long tid, StorageDataType valueType, ByteBuffer buff, StorageDataType oldValueType, boolean meta, int columnCount) { int logId = DataUtils.readVarInt(buff); boolean rowLock = buff.get() == 0; BitSet lockedColumns = null; if (!rowLock) { int len = DataUtils.readVarInt(buff); byte[] bytes = new byte[len]; for (int i = 0; i < len; i++) {