小编Dav*_*ams的帖子

HBase(简单):如何在hbase shell中执行范围前缀扫描

我正在设计一个在hbase上运行的应用程序,并希望以交互方式浏览我的集群的内容.我在hbase shell中,我想要以字符"abc"开头扫描所有键.这样的键可能包括"abc4","abc92","abc20014"等......我试过扫描

hbase(main):003:0> scan 'mytable', {STARTROW => 'abc', ENDROW => 'abc'}
Run Code Online (Sandbox Code Playgroud)

但这似乎没有返回任何东西,因为从技术上讲没有rowkey"abc"只有以"abc"开头的rowkeys

我想要的是类似的东西

hbase(main):003:0> scan 'mytable', {STARTSROWPREFIX => 'abc', ENDROWPREFIX => 'abc'}
Run Code Online (Sandbox Code Playgroud)

我听说HBase能够迅速做到这一点,并且是其主要卖点之一.我如何在hbase shell中执行此操作?

hbase database-scan

30
推荐指数
3
解决办法
7万
查看次数

Clojure:[_]在函数参数列表中做了什么?

我正在研究clojure的乐趣,并想知道_语法在函数参数向量中的作用.

例:

(def available-processors
    (.availableProcessors (Runtime/getRuntime)))

(prn "available processors: " available-processors)

(def pool
    (Executors/newFixedThreadPool (+ 2 available-processors)))

(defn dothreads!
    [func & {thread-count :threads exec-count :times :or {thread-count 1 exec-count 1}}]
    (dotimes [t thread-count]
        (.submit pool #(dotimes [_ exec-count] (func)))))
Run Code Online (Sandbox Code Playgroud)

表格中的下划线是做什么的:

#(dotimes [_ exec-count] (func))
Run Code Online (Sandbox Code Playgroud)

syntax arguments vector clojure

17
推荐指数
2
解决办法
4605
查看次数

Numpy,Pandas和Sklearn中的多维缩放拟合(ValueError)

我正在尝试使用sklearn,pandas和numpy进行多维缩放.使用的数据文件Im具有10个数字列且没有缺失值.我正在尝试使用这个十维数据并使用sklearn.manifold的多维缩放在2维中将其可视化,如下所示:

import numpy as np
import pandas as pd
from sklearn import manifold
from sklearn.metrics import euclidean_distances

seed = np.random.RandomState(seed=3)
data = pd.read_csv('data/big-file.csv')

#  start small dont take all the data, 
#  its about 200k records
subset = data[:10000]
similarities = euclidean_distances(subset)

mds = manifold.MDS(n_components=2, max_iter=3000, eps=1e-9, 
      random_state=seed, dissimilarity="precomputed", n_jobs=1)

pos = mds.fit(similarities).embedding_
Run Code Online (Sandbox Code Playgroud)

但我得到这个值错误:

Traceback (most recent call last):
  File "demo/mds-demo.py", line 18, in <module>
    pos = mds.fit(similarities).embedding_
  File "/Users/dwilliams/Desktop/Anaconda/lib/python2.7/site-packages/sklearn/manifold/mds.py", line 360, in fit
    self.fit_transform(X, init=init)
  File "/Users/dwilliams/Desktop/Anaconda/lib/python2.7/site-packages/sklearn/manifold/mds.py", line 395, …
Run Code Online (Sandbox Code Playgroud)

python numpy pandas scikit-learn

17
推荐指数
2
解决办法
1万
查看次数

Luaj:如何导入或需要Lua函数库

在Java LuaJ库,我想知道如何要求或通过Java中的LUA关闭另一个名为LUA脚本导入功能的LUA脚本.例如,这不起作用:

public static LuaValue runInputStreamLua(InputStream inputStream) throws Exception {
    Prototype luaScriptPrototype = LuaC.instance.compile(inputStream, "");
    Globals luaScriptStandardGlobals = JsePlatform.standardGlobals();
    luaScriptStandardGlobals.loadfile("mycoolmathfunctions.lua");
    LuaClosure luaClosure = new LuaClosure(luaScriptPrototype, luaScriptStandardGlobals);
    return luaClosure.call();
}
Run Code Online (Sandbox Code Playgroud)

这里的输入流是指另一个lua的内容:

import 'mycoolmathfunctions'
-- or maybe require mycoolmathfunctions ?

return sum({1, 2, 3})
-- or maybe mycoolmathfunctions.sum({1, 2, 3}) ?
Run Code Online (Sandbox Code Playgroud)

我该怎么做呢?

java lua luaj

17
推荐指数
1
解决办法
2727
查看次数

从X,Y,Z数据,Excel或其他工具进行3D绘图

我的数据看起来像这样:

1000    13  75.2
1000    21  79.21
1000    29  80.02
5000    29  87.9
5000    37  88.54
5000    45  88.56
10000   29  90.11
10000   37  90.79
10000   45  90.87
Run Code Online (Sandbox Code Playgroud)

我想使用第一列作为x轴标签,第二列作为y轴标签,第三列作为z值.我希望以这种方式显示表面.做这个的最好方式是什么?我试过Excel,但实际上并没有得到任何结果.有没有人对工具有什么建议呢?有谁知道如何在Excel中执行此操作?

谢谢

excel charts plot visualization data-visualization

16
推荐指数
2
解决办法
13万
查看次数

什么是"要求"中的parens和括号之间的区别?

我有点困惑的一件事是clojure require语句中的parens和括号之间的差异.我想知道是否有人可以向我解释这一点.例如,这些做同样的事情:

(ns sample.core
  (:gen-class)
  (:require clojure.set clojure.string))
Run Code Online (Sandbox Code Playgroud)

 (ns sample.core
  (:gen-class)
  (:require [clojure.set] 
            [clojure.string]))
Run Code Online (Sandbox Code Playgroud)

但是,这可以从repl开始

(require 'clojure.string 'clojure.test)
Run Code Online (Sandbox Code Playgroud)

但是在clj文件中失败了

(ns sample.core
  (:gen-class)
  (:require 'clojure.string 'clojure.test))
...
Exception in thread "main" java.lang.Exception: lib names inside prefix lists must not contain periods
    at clojure.core$load_lib.doInvoke(core.clj:5359)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    ....
Run Code Online (Sandbox Code Playgroud)

而这些apear做同样的事情:

(ns sample.core
  (:gen-class)
  (require clojure.set clojure.string))

(ns sample.core
  (:gen-class)
  (:require clojure.set clojure.string))
Run Code Online (Sandbox Code Playgroud)

一般来说,我不理解这一点.我理解使用,导入和要求.但是我不理解":"以及[]和'()等中的事物之间的差异.任何人都能以直观的方式阐明这个话题吗?

clojure

15
推荐指数
1
解决办法
1136
查看次数

Java - 初始化HashMaps的HashMap

我是java的新手,通过创建一个简单的NaiveBayes分类器来练习.我仍然是对象实例化的新手,并想知道如何初始化HashMaps的HashMap.在将新观察值插入分类器时,我可以为给定类中的未见特征名创建新的HashMap,但是我是否需要初始化?

import java.util.HashMap;

public class NaiveBayes {

    private HashMap<String, Integer> class_counts;
    private HashMap<String, HashMap<String, Integer>> class_feature_counts;

    public NaiveBayes() {
        class_counts = new HashMap<String, Integer>();
        // do I need to initialize class_feature_counts?
    }

    public void insert() {
        // todo
        // I think I can create new hashmaps on the fly here for class_feature_counts
    }

    public String classify() {
        // stub 
        return "";
    }

    // Naive Scoring:
    // p( c | f_1, ... f_n) =~ p(c) * p(f_1|c) ... * p(f_n|c)
    private …
Run Code Online (Sandbox Code Playgroud)

java oop initialization

13
推荐指数
2
解决办法
4万
查看次数

错误:无法构建gem native extension(ruby extconf.rb):Mac OSX

我正在尝试安装一个gem,我得到了这个错误,我自己和宝石作者从未见过这个错误.我该如何解决?

Davids-MacBook-Pro:web david$ sudo /usr/bin/gem install compass --pre
Password:
Building native extensions.  This could take a while...
ERROR:  Error installing compass:
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi... yes
checking for ffi_call() in -lffi... yes
checking for ffi_prep_closure()... yes
checking for ffi_raw_call()... no
checking for rb_thread_blocking_region()... yes
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_call_without_gvl()... yes
checking for ffi_prep_cif_var()... no
creating extconf.h
creating Makefile

make "DESTDIR="
compiling AbstractMemory.c
compiling ArrayType.c …
Run Code Online (Sandbox Code Playgroud)

ruby macos gem native-code

13
推荐指数
2
解决办法
5万
查看次数

Python导入类与目录同名

可以说我有以下python源文件布局:

lib/foo.py
lib/foo/bar.py
Run Code Online (Sandbox Code Playgroud)

然后在我的源代码中:

from foo import gaz
Run Code Online (Sandbox Code Playgroud)

我收到导入错误:

ImportError: No module named foo
Run Code Online (Sandbox Code Playgroud)

如何拥有.py文件和具有相同名称的目录,以便我可以执行以下操作:

 from foo import gaz
 from foo.bar import wakawaka
Run Code Online (Sandbox Code Playgroud)

提前致谢!

python import importerror

12
推荐指数
1
解决办法
1万
查看次数

Google是否拥有地理IP服务?

Google是否有API可以从IP地址到纬度经度进行地理编码?与MaxMind相似.我已经调查了他们的地方api:

https://developers.google.com/maps/documentation/business/places/
Run Code Online (Sandbox Code Playgroud)

我已经成功地使用了Maxmind,

http://www.maxmind.com/en/geolocation_landing
Run Code Online (Sandbox Code Playgroud)

但谷歌是否提供ip到lat长期服务?

google-maps geolocation

12
推荐指数
1
解决办法
3万
查看次数