Jedis HMSET地图插入顺序(Jedis HMSET map insertion order)
Jedis有一个hmset方法,允许您在特定键上设置字段及其值的映射。
我用这种方法:
Map<String, String> map = new LinkedHashMap<String, String>(); // General player data map.put("name", player.getName()); map.put("ip", player.getAddress().getAddress().getHostAddress()); map.put("rank", "none"); map.put("tokens", "0"); map.put("coins", "0"); // Arsenal player statistics map.put("ar_score", "0"); map.put("ar_gameswon", "0"); map.put("ar_gameslost", "0"); map.put("ar_kills", "0"); map.put("ar_deaths", "0"); pipeline.hmset("uuid:" + uuid, map); pipeline.sync(); core.redis.getJedisPool().returnResourceObject(jedis);
我决定使用LinkedHashMap来保留插入顺序 - 但是,在查看数据库时,它仍然会弄乱订单。
有没有人知道如何将其插入数据库而不会搞乱订单?
谢谢。
Jedis has a hmset method which allows you to set a map of fields and their values at a specific key.
I use the method this way:
Map<String, String> map = new LinkedHashMap<String, String>(); // General player data map.put("name", player.getName()); map.put("ip", player.getAddress().getAddress().getHostAddress()); map.put("rank", "none"); map.put("tokens", "0"); map.put("coins", "0"); // Arsenal player statistics map.put("ar_score", "0"); map.put("ar_gameswon", "0"); map.put("ar_gameslost", "0"); map.put("ar_kills", "0"); map.put("ar_deaths", "0"); pipeline.hmset("uuid:" + uuid, map); pipeline.sync(); core.redis.getJedisPool().returnResourceObject(jedis);
I decided to use a LinkedHashMap to retain the insertion order — however, when looking at the database, it still messes up the order.
Does anyone know how to insert it into the database without messing up the order?
Thank you.
原文:https://stackoverflow.com/questions/31767537
最满意答案
用方向指出你的意思并不完全清楚。 正如安东指出的那样,积分没有方向。 澄清你的问题将(希望)将其变成一个直接回答的问题。
一些建议:
您以度为单位随机生成纬度和经度,然后转换为弧度。 只需生成0到2PI之间的随机数即可。
跟踪您自己的Modelview矩阵。 那三个
glRotatef
调用可能不会做你想要的。 这需要一些线性代数专有技术,但完全值得。 您将拥有3D变换的直觉,它将使您的生活变得比处理OpenGL的“便利”方法容易得多。了解最新的OpenGL。 您使用的代码库已经被弃用了大约6年,并且已经被着色器编程取代了更长时间。
It's not entirely clear what you mean by points with direction. As Andon pointed out, points don't have direction. Clarifying your question will (hopefully) turn this into a directly answerable question.
Some suggestions:
You generate latitude and longitude randomly in degrees and then convert to radians. Just generate a random number between 0 and 2PI to begin with.
Keep track of your own Modelview matrix. Those three
glRotatef
calls are probably not going to do what you want. This requires some linear algebra know-how but is totally worth it. You will have an intuition for 3D transformations and it will make your life far easier than having to deal with OpenGL's "convenience" methods.Learn up to date OpenGL. The codebase you're using has been deprecated for ~6 years and has been replaced by shader programming for even longer.
相关问答
更多-
这是图书馆不能将Raymenu改为垂直方向。 如果你想要垂直方向,你应该尝试这个库 。 Thats library cant change Raymenu into vertical direction. You should try this library if you want vertical direction.
-
基本上,您希望将世界y轴与(单位长度)方向对齐。 为了用glRotatef组成旋转矩阵,你需要一个轴a = [a_x, a_y, a_z]和一个角度omega 。 将y取入d的旋转轴垂直于y和d ,因此可以通过矢量叉积来计算: a = cross(y, d); 旋转角度omega只是矢量y和d之间的角度,因此可以从点积计算: omega = acos(dot(y, d)); 现在您可以使用以下方法构建旋转矩阵: glRotatef(omega, a_x, a_y, a_z); 小心omega需要以度数 ...
-
记住一个方向,移动到一个点,然后改变方向。(Remembering a direction, moving to a point, then changing direction. XNA)[2021-08-22]
一种解决方案是添加一个int counter = 0; 您在游戏循环中更新(使用counter++; )每帧/时间步。 每次进行有效输入时设置为0并保存该输入。 概述代码: public class GameClassWhereUpdateIsDone { private enum Directions { None, Up, Down, Left, Right }; private int counter = 0; private Directions currentDirect ... -
通过在用户触摸开始时将速度设为0然后通过在触摸方向上施加脉冲来使其工作。 无论如何,谢谢你兄弟的帮助。 Made to to work by making velocity to 0 when user touches began and then by applying an impulse in the direction of touch. Anyways thank you bro for your help.
-
如何改变活塞方向?(How to change a piston direction?)[2023-07-13]
您可以使用方法设置它: block.setTypeIdAndData(33, (byte)direction, false); 如果您想放置粘性活塞,请使用29作为第一个参数。 方向值如下: 0:向下 1:向上 2:北 3:南 4:西 5:东 对于最后一个参数, false表示禁用由块放置引起的不必要的块更新。 You can set it using method: block.setTypeIdAndData(33, (byte)direction, false); If you would lik ... -
openGL / maths如何设置一个点的方向,并改变那个方向(openGL/maths how to set direction for a point, and change that direction)[2022-10-08]
用方向指出你的意思并不完全清楚。 正如安东指出的那样,积分没有方向。 澄清你的问题将(希望)将其变成一个直接回答的问题。 一些建议: 您以度为单位随机生成纬度和经度,然后转换为弧度。 只需生成0到2PI之间的随机数即可。 跟踪您自己的Modelview矩阵。 那三个glRotatef调用可能不会做你想要的。 这需要一些线性代数专有技术,但完全值得。 您将拥有3D变换的直觉,它将使您的生活变得比处理OpenGL的“便利”方法容易得多。 了解最新的OpenGL。 您使用的代码库已经被弃用了大约6年,并且已经被着 ... -
Android OpenGL ES 1.0照明位置,方向和截止(Android OpenGL ES 1.0 lighting position, direction and cutoff)[2022-03-18]
注意,在固定管道中,在调用glLightf(GL_POSITION)时,光的位置由矩阵堆栈的顶部变换。 因此,如果要在世界坐标中定义灯光的位置,则必须已将ViewProjection矩阵放在堆栈顶部。 这是一个常见的错误,许多人在设置相机/投影矩阵之前定义了灯在世界坐标中的位置,因此它实际上是在屏幕空间坐标中定义的。 the problem was that gles10 only does per-vertex-lighting. a per-pixel-lighting has to be implem ... -
好的我管理了一些东西 我占据了我的位置,固定位置和第三个位置,具有完全相同的经度和纬度90.我有两个向量一个指向北方,一个在直线上与我们的位置和固定位置。 我计算这些矢量之间的角度,并将此角度添加到旋转动画中。 我不认为我的解决方案是那么好,但因为我在论坛上没有找到任何其他内容我发布了答案^^。 Ok I managed something. I took my position, the fixed location and a third location with the exact same sam ...
-
你不必为此使用glRotate。 你已经发现了一些你知道的东西,目标方向。 但目标方向并非全部,您仍然可以围绕目标轴旋转对象,因此您还需要向上向量。 这是对象的本地Z轴(或者您可能指定为“向前”的任何其他矩阵)。 您可以对此向量进行标准化,并将其放入对象变换矩阵的Z列中。 向上矢量必须垂直于目标轴。 要么你有一个,要么你从假设中推导出一个对象的向上向量应该至少向上,即有一个Y分量。 通过将矢量的标量积与目标轴相乘并从目标轴中减去目标轴矢量(由标量乘积缩放),然后进行归一化,可以得到向上并垂直于目标轴的矢量。 ...
-
这一切都与你的渐变矢量有关。 这里: (0, 0, Color.RED, 1000, 1000, Color.BLUE)你的矢量是一个对角线矢量,起源于[0,0],然后结束或指向[ (0, 0, Color.RED, 1000, 1000, Color.BLUE) ]或在45度角。 将其改为直降:[0,0]到[0,1000]应该可以正常工作。 例如, new GradientPaint(0, 0, Color.RED, 0, 1000, Color.BLUE) It all has to do with ...