我正在尝试预先拆分 hbase 表。HbaseAdmin java api 是创建一个 hbase 表,它是 startkey、endkey 和区域数量的函数。这是我从 HbaseAdmin 使用的 java apivoid createTable(HTableDescriptor desc, byte[] startKey, byte[] endKey, int numRegions)
关于根据数据集选择 startkey 和 endkey 有什么建议吗?
我的方法是假设我们在数据集中有 100 条记录。我希望数据大约分为 10 个区域,因此每个区域将有大约 10 条记录。所以为了找到startkey,我会说scan '/mytable', {LIMIT => 10}并选择最后一个rowkey作为我的startkey,然后scan '/mytable', {LIMIT => 90}选择最后一个rowkey作为我的endkey。
这种查找 startkey 和 rowkey 的方法看起来不错还是有更好的做法?
编辑 我尝试了以下方法来预拆分空表。所有三个都不像我使用的那样工作。我想我需要加盐才能获得平等分配。
PS> 我只显示一些地区信息
1)
byte[][] splits = new RegionSplitter.HexStringSplit().split(10);
hBaseAdmin.createTable(tabledescriptor, splits);
Run Code Online (Sandbox Code Playgroud)
这给出了具有以下边界的区域:
{
"startkey":"-INFINITY",
"endkey":"11111111",
"numberofrows":3628951,
},
{
"startkey":"11111111",
"endkey":"22222222",
},
{
"startkey":"22222222",
"endkey":"33333333",
},
{
"startkey":"33333333", …Run Code Online (Sandbox Code Playgroud) 当我尝试从某个日期范围进行搜索时出现此错误。
这是我的模型:
def self.search(search)
if search
@policies = Policy.find_by_sql("acct_ent_date IN ?", start_date..end_date)
else
limit(10)
end
end
Run Code Online (Sandbox Code Playgroud) 我有两个整数数组,例如
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
b = [7, 8, 9]
Run Code Online (Sandbox Code Playgroud)
我想反复复制值,'b'以获得完全匹配的数组长度,如下所示:
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
b = [7, 8, 9, 7, 8, 9, 7, 8, 9, 7]
Run Code Online (Sandbox Code Playgroud)
我们可以假设 a.length > b.length
我真的被困在这部分:
如果我禁用# rubocop:disable Metrics/AbcSize,那么我会收到此错误:
ruby -v : ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin14]
rubocop -V
0.52.1 (using Parser 2.4.0.2, running on ruby 2.4.2 x86_64-darwin14)
$ rubocop .
Inspecting 7 files
.....W.
Offenses:
recipes/default.rb:13:1: W: Lint/MissingCopEnableDirective: Re-enable Metrics/AbcSize cop with # rubocop:enable after disabling it.
# rubocop:disable Metrics/AbcSize
^
7 files inspected, 1 offense detected
Run Code Online (Sandbox Code Playgroud)
如果我rubocop在脚本中启用然后得到:
rubocop .
Inspecting 7 files
.....C.
Offenses:
recipes/default.rb:31:1: C: Metrics/AbcSize: Assignment Branch Condition size for check_tropo_versions is too high. [33.02/20]
def …Run Code Online (Sandbox Code Playgroud) 我有三个模型User,Individual和Business.我还为每个创建了三个表.我的个人和用户表是相同的所以我从user.rb继承我的问题是当我来到business.rb时,我能够访问User的所有父属性(例如:first_name)但我无法访问该模型business表中的特定属性(例如:company_name).
class User < ApplicationRecord
# This is the user model
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:confirmable, :lockable, :timeoutable
enum status: {unverified: 0, verified: 1}
end
# This is the business model
class Business < User
end
individual.rb
# # This is the individual model
class Individual < User
end
schema.rb
# This is the schema for all the models
ActiveRecord::Schema.define(version: 2018_06_09_091056) do
create_table "businesses", force: :cascade do |t|
t.string "company_address"
t.string "company_name"
t.string "company_phone_number"
t.text "documents"
end …Run Code Online (Sandbox Code Playgroud) 我试图解析这样一个简单的 JSON:
JSON.parse({"pong": "ok"})
Run Code Online (Sandbox Code Playgroud)
它失败了
2.4.0 :014 > JSON.parse({"pong": "ok"})
TypeError: no implicit conversion of Hash into String
from (irb):14
Run Code Online (Sandbox Code Playgroud)
这里有什么问题?为什么要转换为 String ?
另一个尝试,这次使用OpenStruct:
2.4.0 :001 > pong = OpenStruct.new(pong: 'OK')
=> #<OpenStruct pong="OK">
2.4.0 :002 > JSON.parse(pong)
TypeError: no implicit conversion of OpenStruct into String
from (irb):2
Run Code Online (Sandbox Code Playgroud)
相同 ?谢谢
在下面,有什么原因#home而不是/home?所有其他人都是/help,/about.
Rails.application.routes.draw do
root 'static_pages#home'
get 'static_pages/help'
get 'static_pages/about'
end
Run Code Online (Sandbox Code Playgroud) 我是新来的,所以请温柔地对待我,我仍然只是编程新手,特别是红宝石语言.
这是一个组合框,我想知道它在更改它或它调用的函数之后的位置.你能告诉我它的去向或作用吗?谢谢
<p><%= f.select :done_ratio, ((0..100).step(1).to_a.collect {|r| ["#{r} %", r] }), :required => @issue.required_attribute?('done_ratio') %></p>
Run Code Online (Sandbox Code Playgroud) ruby ×5
activerecord ×1
chef-infra ×1
hadoop ×1
hashmap ×1
hbase ×1
java ×1
json ×1
openstruct ×1
rubocop ×1
sql ×1
url-routing ×1