脚本
假设您在3个区域中有多个数据库.区A,B和C.每个区域位于不同的地理位置.同时,您有一个应用程序将根据用户的地理位置路由用户名和密码.例如,用户A将被重定向到Zone中的数据库A.用户B区B等.
现在,假设用户A移动到某个区域B.应用程序查询区域B,将找不到任何内容.由于区域很远,查询区域A和区域C可能需要一些时间,并且必须查询所有区域中的所有数据库.
我的问题
如何验证多个集合中是否存在字符串/数字?
要么
如何在发送查询之前验证数据库中是否存在行?
我的算法
这不是完美的,但会让你知道我想要做什么
如果我们拥有包含以下3个用户的数据库
我们获取所有3个用户的哈希值,如果哈希值不是素数,则查找下一个素数.
sum = hash(foo).nextPrime() * hash(bar).nextPrime() * hash(foobar).nextPrime()
Run Code Online (Sandbox Code Playgroud)
所有区域之间共享该金额.如果我想检查foo,我可以只取foo的哈希值,然后查找下一个素数,然后选择gcd(foo,sum).如果它不等于一个.这意味着foo存在于某些数据库中.如果它等于1,则表示foo根本不存在.如果我想添加新用户名.我可以干脆做sum = sum * hash(newUserName).nextPrime().
总和将增长到可以更快地查询所有数据库的点.
你知道一个类似的算法来解决这个问题吗?
我正在尝试在 Ubuntu 20.04 上构建一个应用程序,其中 python3 指向 Python3.8,并且我正在构建 aganist Python3.6
我在 WORKSPACE 的同一目录中有以下运行时。
$ cat BUILD.bazel
py_runtime(
name = "python3.6",
interpreter_path = "/usr/bin/python3.6",
)
Run Code Online (Sandbox Code Playgroud)
我尝试通过运行以下命令来构建应用程序,bazel 仍然指向 python3,即 python3.8
bazelisk build company/app_api:app --python_top=//:python3.6
Run Code Online (Sandbox Code Playgroud)
我还尝试了已弃用的选项,但也不起作用。
bazelisk build company/app_api:app --python_path=/usr/bin/python3.6
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
...
subprocess.CalledProcessError: Command '['/usr/bin/python3', '-m', 'pip', '--isolated', 'wheel', '-r', '/source_code/src/python/third_party/requirements.txt']' returned non-zero exit status 1.
...
Run Code Online (Sandbox Code Playgroud)
pip 正在尝试安装一个仅适用于 python3.6 的包,这就是它返回非零存在代码的原因。
如何强制 bazel 使用自定义 python 解释器?
我从 nativescript 开始。我正在尝试构建一个 hello world 应用程序来测试它。但是,当我运行它时,我得到一个退出状态 127 for command not found。
这是我尝试构建的方法:
[ahmed@localhost hello]$ tns build android
Executing before-shouldPrepare hook from /home/ahmed/PycharmProjects/hello/hooks/before-shouldPrepare/nativescript-dev-webpack.js
Skipping prepare.
Building project...
Gradle build...
spawn ./gradlew ENOENT
[ahmed@localhost hello]$ echo $?
127
[ahmed@localhost hello]$
Run Code Online (Sandbox Code Playgroud)
如果我跑tns doctor,一切似乎都好
[ahmed@localhost hello]$ tns doctor
? Getting environment information
No issues were detected.
? Your ANDROID_HOME environment variable is set and points to correct directory.
? Your adb from the Android SDK is correctly installed.
? The Android SDK …Run Code Online (Sandbox Code Playgroud) algorithm ×1
bazel ×1
bazel-python ×1
database ×1
math ×1
nativescript ×1
python ×1
sharding ×1