我正在尝试创建一个通用散列alogrithim,它将字符串散列为64位int.
我能够正确地散列字符串:sql:
select
convert
(
varchar(64),
HASHBYTES
(
'SHA1',
'google.com'
),
2
)
Run Code Online (Sandbox Code Playgroud)
回报 BAEA954B95731C68AE6E45BD1E252EB4560CDC45
C#
System.Security.Cryptography.SHA1 c = System.Security.Cryptography.SHA1.Create();
System.Text.StringBuilder sb = new StringBuilder();
byte[] b = c.ComputeHash(Encoding.UTF8.GetBytes("google.com"));
for (int i = 0; i < b.Length;i++ )
{
byte by = b[i];
sb.Append(by.ToString("x2").ToUpper());
}
return sb.ToString();
Run Code Online (Sandbox Code Playgroud)
retruns BAEA954B95731C68AE6E45BD1E252EB4560CDC45
但是,当我转换为bigint/long时,值不匹配:sql:
select
convert
(
bigint,
HASHBYTES
(
'SHA1',
'google.com'
)
)
Run Code Online (Sandbox Code Playgroud)
回报 2172193747348806725
C#:
System.Security.Cryptography.SHA1 c = System.Security.Cryptography.SHA1.Create();
byte[] b = c.ComputeHash(Encoding.UTF8.GetBytes("google.com"));
return BitConverter.ToInt64(b, 0);
Run Code Online (Sandbox Code Playgroud)
回报 7501998164347841210
有关如何使这些数字匹配的任何想法?
我正在尝试加载间隔进程的队列.换句话说,我有一个队列,我希望队列中的每个项目都在一个单独的时间间隔上运行.
我的问题是,我似乎无法一次运行超过25个线程.我在64位机器上使用.Net 4.5,其默认最大线程数为32768.
如何使我的应用程序运行尽可能多的并发线程,因为我的机器可以处理?
这是一个示例应用程序,它复制了我的生产代码中的实际问题:
class Program
{
static void Main(string[] args)
{
System.Threading.ThreadPool.SetMaxThreads(200, 200);
test t = new test();
t.LoadUrls("http://www.google.com");
while (1 == 1)
{
System.Threading.Thread.Sleep(1000);//refresh every 5 seconds
Console.WriteLine(System.Diagnostics.Process.GetCurrentProcess().Threads.Count);
}
}
public class test
{
public void LoadUrls(string url)
{
for (int i = 0; i < 100; i++)
{
System.Threading.Timer t = new System.Threading.Timer(new System.Threading.TimerCallback(RunInterval), url, 0, 1000);
Console.WriteLine("Loaded {0} feeds.", i);
}
}
private static void RunInterval(object state)
{
string url = state as string;
string …Run Code Online (Sandbox Code Playgroud) 我试图使用其余的api将多个列/行发布到我的hbase集群.我可以一次发布1列没有问题,但似乎无法接受多列/行.
这很好用
数据:
{
"Row":{
"@key":"www.somesite.com",
"Cell":{
"@column":"ColFam:Col1",
"$":"someData"
}
}
}
Run Code Online (Sandbox Code Playgroud)
呼叫:
curl -v -X PUT -H "Content-Type: application/json" --data '{"Row": { "@key":"www.somesite.com", "Cell": { "@column":"ColFam:Col1", "$":"someData" } } }' http://somesite.com:8080/TestTable/www.somesite.com/ColFam:Col1
Run Code Online (Sandbox Code Playgroud)
根据api,我应该能够同时发布多行/列.
多列数据:
{
"Row":
{
"key":"www.somesite.com",
"Cell":[
{
"column":"ColFam:Col1",
"$":"someData"
},
{
"column":"ColFam:Col2",
"$":"moreData"
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
多行数据:
{
"Row":[
{
"key":"www.somesite.com",
"Cell":[
{
"column":"ColFam:Col1",
"$":"someData"
}
]
},
{
"key":"www.someothersite.com",
"Cell":[
{
"column":"ColFam:Col1",
"$":"moreData"
}
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用以下网址:
http://somesite.com:8080/TestTable/www.somesite.com/ColFam:Col1
http://somesite.com:8080/TestTable/www.somesite.com/ColFam
http://somesite.com:8080/TestTable/www.somesite.com
Run Code Online (Sandbox Code Playgroud)
无济于事.文档说使用false-row-key所以我也尝试过: …