private object UnpackBlob(int count) { int type = buffer[offset++]; count--; object val; switch (type) { case ParticleType.STRING: val = ByteUtil.Utf8ToString(buffer, offset, count); break; case ParticleType.CSHARP_BLOB: val = ByteUtil.BytesToObject(buffer, offset, count); break; default: byte[] dest = new byte[count]; Array.Copy(buffer, offset, dest, 0, count); if (lua) { val = new LuaBytes(dest); } else { val = dest; } break; } offset += count; return(val); }
public static object BytesToLua(int type, byte[] buf, int offset, int len) { if (len <= 0) { return(null); } switch (type) { case ParticleType.STRING: return(ByteUtil.Utf8ToString(buf, offset, len)); case ParticleType.INTEGER: return(ByteUtil.BytesToNumber(buf, offset, len)); case ParticleType.DOUBLE: return(ByteUtil.BytesToDouble(buf, offset)); case ParticleType.BLOB: byte[] dest = new byte[len]; Array.Copy(buf, offset, dest, 0, len); return(new LuaBytes(dest)); case ParticleType.CSHARP_BLOB: return(ByteUtil.BytesToObject(buf, offset, len)); case ParticleType.LIST: { Unpacker unpacker = new Unpacker(buf, offset, len, true); return(unpacker.UnpackList()); } case ParticleType.MAP: { Unpacker unpacker = new Unpacker(buf, offset, len, true); return(unpacker.UnpackMap()); } case ParticleType.GEOJSON: { // skip the flags int ncells = ByteUtil.BytesToShort(buf, offset + 1); int hdrsz = 1 + 2 + (ncells * 8); return(new LuaGeoJSON(ByteUtil.Utf8ToString(buf, offset + hdrsz, len - hdrsz))); } default: return(null); } }
private object UnpackBlob(int count) { int type = buffer[offset++]; count--; object val; switch (type) { case ParticleType.STRING: val = ByteUtil.Utf8ToString(buffer, offset, count); break; case ParticleType.CSHARP_BLOB: val = ByteUtil.BytesToObject(buffer, offset, count); break; case ParticleType.GEOJSON: val = new Value.GeoJSONValue(ByteUtil.Utf8ToString(buffer, offset, count)); break; default: byte[] dest = new byte[count]; Array.Copy(buffer, offset, dest, 0, count); if (lua) { #if NETFRAMEWORK val = new LuaBytes(dest); #else throw new AerospikeException("Lua not supported in .NET core"); #endif } else { val = dest; } break; } offset += count; return(val); }
public static object BytesToLua(int type, byte[] buf, int offset, int len) { if (len <= 0) { return(null); } switch (type) { case ParticleType.STRING: return(ByteUtil.Utf8ToString(buf, offset, len)); case ParticleType.INTEGER: return(ByteUtil.BytesToNumber(buf, offset, len)); case ParticleType.DOUBLE: return(ByteUtil.BytesToDouble(buf, offset)); case ParticleType.BLOB: byte[] dest = new byte[len]; Array.Copy(buf, offset, dest, 0, len); return(new LuaBytes(dest)); case ParticleType.CSHARP_BLOB: return(ByteUtil.BytesToObject(buf, offset, len)); case ParticleType.LIST: { Unpacker unpacker = new Unpacker(buf, offset, len, true); return(unpacker.UnpackList()); } case ParticleType.MAP: { Unpacker unpacker = new Unpacker(buf, offset, len, true); return(unpacker.UnpackMap()); } default: return(null); } }