如何在Jedis中使用SCAN命令(How to use SCAN commands in Jedis)
我使用redis和jedis的时间已经很长一段时间了,从来没有需要SCAN命令。 但是现在我需要使用SCAN命令,特别是hscan。 我明白它在redis级别上的工作原理,但是jedis的Java包装方面让我感到困惑。 有
ScanResults
和ScanParameter
类流动,我没有清楚的如何正确使用它们的概念。 此功能的文档不存在或至少很难找到。 任何人都可以指出在哪里可以找到像使用hscan和jedis进行散列迭代的体面示例?对不起,没有代码,但我迄今试过的只是没有任何意义。
I was using redis and jedis for quite some time and never needed the SCAN commands so far. Now however I need to use the SCAN commands, particularly hscan. I understand how it works on the redis level, but the jedis Java wrapper side is confusing to me. There are
ScanResults
andScanParameter
classes flowing around and I have no clear concept of how to use them properly. The documentation for this feature is non-existent or at least hard to find. Can anyone point out where to find decent examples of how to iterate over a hash using hscan with jedis?Sorry to have no code, but what I tried so far just makes no sense whatsoever.
原文:https://stackoverflow.com/questions/33842026
最满意答案
指南针是一种传感器,用于检测设备指向的方向或方向。 它以从0到359.99的度数来衡量标题。
使用compassSuccess回调函数通过CompassHeading对象返回指南针标题信息。
function onSuccess(heading) { alert('Heading: ' + heading.magneticHeading); }; function onError(error) { alert('CompassError: ' + error.code); }; navigator.compass.getCurrentHeading(onSuccess, onError);
如果您想访问手机的x,y或z轴的旋转角度,您可以简单地使用裸机HTML5。 这里有一篇关于它的伟大文章: 这最后:使用设备方向
代码示例:
window.addEventListener('deviceorientation', function(eventData) { // gamma is the left-to-right tilt in degrees, where right is positive var tiltLR = eventData.gamma; // beta is the front-to-back tilt in degrees, where front is positive var tiltFB = eventData.beta; // alpha is the compass direction the device is facing in degrees var dir = eventData.alpha // deviceorientation does not provide this data var motUD = null; // call our orientation event handler deviceOrientationHandler(tiltLR, tiltFB, dir, motUD); }, false);
The compass is a sensor that detects the direction or heading that the device is pointed. It measures the heading in degrees from 0 to 359.99.
The compass heading information is returned via a CompassHeading object using the compassSuccess callback function.
function onSuccess(heading) { alert('Heading: ' + heading.magneticHeading); }; function onError(error) { alert('CompassError: ' + error.code); }; navigator.compass.getCurrentHeading(onSuccess, onError);
If you want to access the rotation-degrees of the x,y or z axis of the Phone you can simply use bare HTML5. Here is a great article about it: THIS END UP: USING DEVICE ORIENTATION
Code example:
window.addEventListener('deviceorientation', function(eventData) { // gamma is the left-to-right tilt in degrees, where right is positive var tiltLR = eventData.gamma; // beta is the front-to-back tilt in degrees, where front is positive var tiltFB = eventData.beta; // alpha is the compass direction the device is facing in degrees var dir = eventData.alpha // deviceorientation does not provide this data var motUD = null; // call our orientation event handler deviceOrientationHandler(tiltLR, tiltFB, dir, motUD); }, false);
相关问答
更多-
PhoneGap Docs 指南针是一种传感器,用于检测设备指向的方向或方向。 它以从0到359.99的度数来衡量标题。 使用compassSuccess回调函数通过CompassHeading对象返回指南针标题信息。 function onSuccess(heading) { alert('Heading: ' + heading.magneticHeading); }; function onError(error) { alert('CompassError: ' + error.c ...
-
不幸的是,你的问题不是特别简单。 我对Android API不太熟悉,如果你环顾四周,你会发现一些试图将重力加速度与外部设备加速度隔离开来的东西(我知道有一些传感器融合算法能够取得一定程度的成功) 。 问题的核心是由于重力引起的加速度和设备上的局部加速度是难以区分的(没有重力传感器这样的东西)。 加速度计只记录作用在设备上的总加速度,即所有加速度的总和。 隔离重力矢量并非易事,但我所看到的方法主要涉及使用陀螺仪,因为磁力计太简单并且包含太多的延迟。 相反,我建议您假设设备上的局部力可忽略不计,因此您的加速度 ...
-
Android磁传感器为不同设备提供不同的值(Android magnetic sensors gives different values of different devices)[2023-01-19]
我只能确认问题。 作为稳定指南针应用的作者,我已经对不同设备的磁场传感器进行了多次测试。 我发现其中一台设备报告的mf绝对值约为其他不同设备在相同条件下报告的数量的2倍。 我在电话校准后做了很多测试,我甚至将设备置于“飞行模式”,试图最大限度地减少来自自身设备的电磁干扰。 另一个评论是,在某些设备上插入USB电缆会产生重要的磁场变化。 我在给定设备上看到的最糟糕的结果(在校准,飞行模式和USB断开之后)是这样的:在水平面上使用指南针应用设备,我读取一个读数,在水平面上旋转手机90度并采取一个新的指南针阅读。 ... -
传感器值始终相对于默认方向,因此您需要考虑远离默认方向的旋转。 为此,请使用以下内容: int rotation = activity.getWindowManager().getDefaultDisplay().getRotation(); float screen_adjustment = 0; switch(rotation) { case Surface.ROTATION_0: screen_adjustment = 0; break; case ...
-
我刚尝试过,它工作正常。 一定要在XCode中设置正确的选项,如下所示: 在你这样做之前,你建立一个像这样的清晰项目 - > cordova create OrientationChange com.example.com OrientationChange cd OrientationChange cordova platform add ios cordova plugin add org.apache.cordova.console (您不需要这个用于方向更改,但它对调试很有用)。 cordova b ...
-
如果您在将磁场X,Y,Z值从设备转换为全局参考系中时读取了我的答案您仍然无法理解它。 A1 。 将旋转矩阵与设备坐标系中磁场矢量的坐标相乘,得到世界坐标系中磁场矢量的坐标。 让我强调一下:上面说的旋转矩阵并没有反转旋转矩阵。 通过调用getRotationMatrix获得的旋转矩阵是基础矩阵从设备基础到世界基础的变化。 给出任何具有设备坐标系中坐标的矢量v,可以通过将旋转矩阵与设备系统坐标中的坐标相乘来获得相同矢量v的世界坐标系中的坐标。 反转矩阵是基础矩阵从世界基础到设备基础的变化。 因此,当您使用坐标多 ...
-
好的,我终于设法让代码工作! 首先,我注册一个Sensor.TYPE_MAGNETIC_FIELD和Sensor.TYPE_GRAVITY :(就像Hoan Nguyen说的那样!) /** * Initialize the Sensors (Gravity and magnetic field, required as a compass * sensor) */ private void initSensors() { LocationManager locationManager = ...
-
在你的评论中考虑你说它是你的指南针而不是你的代码,答案是重新校准你的指南针。 请参阅链接说明: http : //forum.xda-developers.com/showthread.php?t = 1778131 Considering in your comments you state it is your compass and not your code, the answer is to recalibrate your compass. Please see linked instructi ...
-
您不需要Magnetic sensor进行pitch和roll 。 只需低通滤波器accelerometer即可获得重力。 private static final float ALPHA = 0.8; private float[] mGravity; public void onSensorChanged(SensorEvent event) { mGravity[0] = ALPHA * mGravity[0] + (1 - ALPHA) * event.values[0]; mGr ...
-
最后,根据我自己的观察: 1)使用startDeviceMotionUpdatesUsingReferenceFrame:toQueue:withHandler: referenceFrame不等于allZeros或XArbitraryZVertical 。 2)将showsDeviceMovementDisplay设置为true 。 经过几次零值更新后,精确度CMMagneticFieldCalibrationAccuracyUncalibrated将进行标准化。 Finally, according t ...