你如何首先提取架构,然后从java中的avro文件中提取数据?除了java之外,与此问题相同.
我已经看到了如何从avsc文件而不是avro文件中获取模式的示例.任何方向都非常赞赏.
Schema schema = new Schema.Parser().parse(new File("/home/Hadoop/Avro/schema/emp.avsc"));
Run Code Online (Sandbox Code Playgroud) 我是节点新手,有点超出我的深度。在 Mac OS X 和 Centos 6 上都遇到此错误。我尝试过的所有 npm install xxx 命令都会发生此错误。非常感谢任何有关如何解决此错误的建议。
类似于npm install 给出了 node-gyp 错误,但我的用户名中没有空格,这解决了他的问题。
npm install canvas
> canvas@1.6.6 install /home/test1/ng2-webpack-demo/node_modules/canvas
> node-gyp rebuild
Package cairo was not found in the pkg-config search path.
Perhaps you should add the directory containing `cairo.pc'
to the PKG_CONFIG_PATH environment variable
No package 'cairo' found
gyp: Call to './util/has_lib.sh freetype' returned exit status 0 while in
binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack …Run Code Online (Sandbox Code Playgroud) 我想在我的Google App Engine java应用程序中部署一些Freemarker模板,以用作电子邮件正文模板.我正在使用freemarker-gae-2.3.23.jar.
我的问题是在war文件中我应该放置我的模板文件,以便Freemarker Configuration类可以找到它们吗?我认为WEB-INF/classes/templates可以工作,但是当我在GAE实例上运行它时,我收到以下错误.getRealPath()也没有提供任何见解.返回空字符串.任何想法或建议非常感谢.
SEVERE: Template ./templates/invitation.ftl not found.
java.lang.RuntimeException: Error in loading ftl template: Template ./templates/invitation.ftl not found.
Run Code Online (Sandbox Code Playgroud)
我的基本配置如下:
public class FreeMarkerConfig {
private static FreeMarkerConfig freeMarkerConfig = null;
private static Configuration cfg = null;
private static final Logger logger = Logger.getLogger(FreeMarkerConfig.class.getName());
private FreeMarkerConfig(ServletContext context){
cfg = new Configuration();
cfg.setServletContextForTemplateLoading(context, "/templates");
}
public static FreeMarkerConfig getInstance(ServletContext context){
if(freeMarkerConfig == null){
freeMarkerConfig = new FreeMarkerConfig(context);
return freeMarkerConfig;
}
return freeMarkerConfig;
}
public static Template getTemplateByName(String fileName){
try { …Run Code Online (Sandbox Code Playgroud) 我想将所有http流量重定向到https,只有少数例外.我希望保留在http的网址中的/ exception /中的任何内容.
尝试了以下建议通过将所有http重定向到nginx中的https,除了一个文件
但它不起作用./ exception/urls将从nginx传递到apache,以便在laravel框架中进行一些php处理,但这无关紧要.
任何改进建议都非常感谢!
server {
listen 127.0.0.1:80;
location / {
proxy_pass http://127.0.0.1:7080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Accel-Internal /internal-nginx-static-location;
access_log off;
}
location /exception/ {
# empty block do nothing
# I've also tried adding "break;" here
}
return 301 https://localhost$request_uri;
}
Run Code Online (Sandbox Code Playgroud) 我有一些看起来像这样的json数据:
{
"id": 1998983092,
"name": "Test Name 1",
"type": "search string",
"creationDate": "2017-06-06T13:49:15.091+0000",
"lastModificationDate": "2017-06-28T14:53:19.698+0000",
"lastModifiedUsername": "testuser@test.com",
"lockedQuery": false,
"lockedByUsername": null
}
Run Code Online (Sandbox Code Playgroud)
我可以将lockedQuery null值添加到GenericRecord对象而不会出现问题.
GenericRecord record = new GenericData.Record(schema);
if(json.isNull("lockedQuery")){
record.put("lockedQuery", null);
}
Run Code Online (Sandbox Code Playgroud)
但是,稍后当我尝试将该GenericRecord对象写入avro文件时,我得到一个空指针异常.
File file = new File("~/test.arvo");
DatumWriter<GenericRecord> datumWriter = new GenericDatumWriter<>(schema);
DataFileWriter<GenericRecord> dataFileWriter = new DataFileWriter<>(datumWriter);
dataFileWriter.create(schema, file);
for(GenericRecord record: masterList) {
dataFileWriter.append(record); // NULL POINTER HERE
}
Run Code Online (Sandbox Code Playgroud)
当我运行该代码时,我得到以下异常.有关如何将空值处理成Avro文件的任何提示都非常感谢.提前致谢.
java.lang.NullPointerException: null of boolean in field lockedQuery of
com.mydomain.test1.domain.MyAvroRecord
Exception in thread "main" java.lang.RuntimeException:
org.apache.avro.file.DataFileWriter$AppendWriteException:
java.lang.NullPointerException: null of …Run Code Online (Sandbox Code Playgroud) 我有三个表tblinventory,tbldisbursement,tblmissinglost.我想在扣除当天的支出和退货后计算账面总存量.
select bn.No_of_books_procured
- (count(mis.Unr_ret_donated_discareded))
- (count(case when dis.dis_disbursed_return = 1
then dis.dis_disbursed_return end ) )as Stock
from tbl_inventorylibbooks bn
right
join tbl_limgt_booksmissing_lost_adjust mis
on mis.Book_Name_missingbk = bn.Id_inventory
left
join tbllibmange_disbursement dis
on dis.dis_book_name_fk_id = bn.Id_inventory
where bn.Id_inventory = 14
Run Code Online (Sandbox Code Playgroud)
在少数条目中,我得到正确答案,而其他结果条目查询显示错误答案.你能为此提供一个解决方案吗?
tblinventory
id Name
----------
1 xyz
Run Code Online (Sandbox Code Playgroud)
考虑采购的总书数= 10
tbldisbursement
**booknameFK disbursed/returned**
----------------------------------------
Booknafk1 1
Booknafk2 0
Booknafk3 1
Run Code Online (Sandbox Code Playgroud)
其中1 =已支付,0 =已退回
tblmissinglost
**id BooknameFk missng**
----------------------------------------
1 Booknafk1 lost
2 Booknafk1 lost
----------------------------------------
Run Code Online (Sandbox Code Playgroud)
同时检查此查询
select (bn.No_of_books_procured) as procured,
count(distinct …Run Code Online (Sandbox Code Playgroud) 我是列表理解的新手,并希望将以下代码中的for循环复制到嵌套列表理解中.
master = []
inner = []
for x in range(1,8):
inner = []
for y in range(1,x+1):
inner.append(str(x*y).rjust(2))
master.append(inner)
for m in master:
print ' '.join(m)
Run Code Online (Sandbox Code Playgroud)
输出如下所示:
1
2 4
3 6 9
4 8 12 16
5 10 15 20 25
6 12 18 24 30 36
7 14 21 28 35 42 49
Run Code Online (Sandbox Code Playgroud)
我想的是:
test = [
[str(x*y).rjust(2) for x in range(1,8)]
for y in range(1,x+1)
]
for t in test:
print ' '.join(t)
Run Code Online (Sandbox Code Playgroud)
但是我收到了一个追溯错误:
Traceback (most …Run Code Online (Sandbox Code Playgroud) 在描述符中的Python 2.7版文档介绍短语绑定行为时使用。
“通常,描述符是具有“绑定行为”的对象属性,其属性访问已被描述符协议中的方法所覆盖。这些方法分别是get(),set()和delete()。方法是为一个对象定义的,它被称为描述符。”
有人可以对“约束行为”给出更清晰的解释吗?“一个”一词是指对象吗?如果是这种情况,则描述符是一个对象属性,该属性已被描述符中的方法覆盖。似乎是递归定义。绑定行为是否可以分配给对象成员?
可以提供的任何清晰度都非常感谢!
我是新的Angular和Fabric.js。我正在尝试构建一个UI,用户可以在其中将对象拖放到画布上,然后用线连接它们。
本质上,我希望从第一个链接获得Angular4拖放示例,以与第二个链接中的Fabric.js画布很好地配合使用。
拖放示例有效,但是Fabric.js画布在Chrome中呈现为方形框,仅此而已。
我已采取的步骤:
在tsconfig.json中,我设置了“ allowJs”:true
我的dnd.component.html看起来像:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/1.5.0/fabric.min.js"></script>
<script type="text/javascript" src="canvas.js"></script>
<style>
canvas {
border: 1px solid #ccc;
}
</style>
<div class="container">
<div>
<simple-dnd></simple-dnd>
<canvas id="c" width="600" height="600"></canvas>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
canvas.js看起来像这样:
setTimeout(function() {
$(document).ready(function () {
var canvas = new fabric.Canvas('c', {selection: false});
var grid = 50;
// create grid
for (var i = 0; i < (600 / grid); i++) {
canvas.add(new fabric.Line([i * grid, 0, i * grid, 600], {stroke: '#ccc', selectable: …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 SSL 连接到 Google Cloud SQL (mysql) 实例。我已经启用了两个 IP 地址和一个具有来自这些 IP 地址的远程访问权限的用户。我还从 Google 的开发者控制台生成了证书文件。
client-key.pem client-cert.pem server-ca.pem
Run Code Online (Sandbox Code Playgroud)
使用来自两个启用的 IP 地址中的每一个的此命令,我成功地建立了连接。
mysql --ssl-ca=server-ca.pem --ssl-cert=client-cert.pem --ssl-key=client-key.pem --host=xxx.xxx.xxx.xxx --user=username --password
Run Code Online (Sandbox Code Playgroud)
由于 mysql 客户端工作,我知道我的防火墙设置、用户、证书等设置正确。
现在我想从一个可执行的 jar 文件中与 java 建立类似的连接。
遵循此处概述的步骤:http : //dev.mysql.com/doc/connector-j/en/connector-j-reference-using-ssl.html
Step 1: keytool -import -alias mysqlServerCACert -file cacert.pem -keystore truststore
Run Code Online (Sandbox Code Playgroud)
注意:我用 server-ca.pem 替换了说明中使用的 cacert.pem
Step 2: openssl x509 -outform DER -in client-cert.pem -out client.cert
Step 3: keytool -import -file client.cert -keystore keystore -alias mysqlClientCertificate
Run Code Online (Sandbox Code Playgroud)
这些步骤创建了我的密钥库和信任库文件。在生成这两个文件时,我为它们中的每一个关联了不同的密码。
这是相关的Java代码:
public void testConnection() throws ClassNotFoundException, …Run Code Online (Sandbox Code Playgroud) java ×4
avro ×2
avro-tools ×2
mysql ×2
angular ×1
descriptor ×1
fabricjs ×1
freemarker ×1
nginx ×1
node-gyp ×1
node.js ×1
python ×1
python-2.7 ×1
servlets ×1
ssl ×1