我正在尝试构建一个包含public Blob getImage() {
Uri uri = Uri.fromFile(new
File(mCurrentPhotoPath));
File f1 = new File(mCurrentPhotoPath);
URL myURL = null;
try {
myURL = f1.toURI().toURL();
} catch (MalformedURLException e) {
e.printStackTrace();
}
Bitmap bitmap = null;
BitmapFactory.Options options = new
BitmapFactory.Options();
options.inPreferredConfig =
Bitmap.Config.ARGB_8888;
try {
if (myURL != null) {
bitmap =
BitmapFactory.decodeStream(
myURL.openConnection().getInputStream());
String wBlob =
encodeToBase64(bitmap,
Bitmap.CompressFormat.JPEG, 100);
blob = fromBase64String(wBlob);
}
} catch (java.io.IOException e) {
e.printStackTrace();
}
return blob;
}
成对比较的Hive表。例如,假设我们从表ids
开始:
A
我想创建一个表id val
a 10
b 11
c 12
:
B
我认为这需要自我加入,但我不知道该怎么做。非常感谢任何想法或引导。
我试过了:
id_A id_B val_A val_B val_diff
a b 10 11 -1
a c 10 12 -2
b c 11 12 -1
但它不起作用:
CREATE TABLE C STORED AS ORC AS
SELECT a.id AS id_A,
b.id AS id_B,
a.val AS val_A,
b.val AS val_B,
a.val - b.val AS val_diff
FROM A AS a
INNER JOIN B as b
ON a.id != b.id;
更新 问题扩展。
假设我有表FAILED: SemanticException [Error 10017]: Line 4:3 Both left and right aliases encountered in JOIN 'id'
:
A'
我如何仅在每个id val category
a 10 X
b 11 X
c 12 X
d 13 Y
e 14 Y
f 15 Y
的元素之间进行成对比较?
即。表category
:
B'
答案 0 :(得分:1)
您使用自我加入:
select a.id as id_a, b.id as id_b, a.val as val_a, b.val as val_b,
(a.val - b.val) as val_diff
from t a join
t b
on a.id < b.id;
在Hive中,您可能需要这样做:
select a.id as id_a, b.id as id_b, a.val as val_a, b.val as val_b,
(a.val - b.val) as val_diff
from t a cross join
t b
where a.id < b.id;