如何phrase以及term在不同的Structured查询?
我的CloudSearch域中有这些数据:
{
"guid": 9,
"operating_systems": [
"12345", "123"
],
"manufacturer": "sealand",
"model": "gaming tree whale plum",
"identifier": "gaming tree whale plum",
"type": "computer",
"created_at": "1982-10-14T14:43:54Z"
}
Run Code Online (Sandbox Code Playgroud)
"model"是类型text,"identifier"是类型literal,"created_at"是类型date.
我们来一些问题:
(phrase field=model 'tree whale') match
(phrase field= identifier 'tree whale') no match
(phrase 'tree whale') match
(phrase field=created_at '1982-10-14T14:43:54Z') match (this shouldn't match according to docs)
(term field=model 'tree whale') match
(term field= identifier …Run Code Online (Sandbox Code Playgroud) 我想处理ThreadPoolExecutor#afterExecute()方法中工作线程抛出的exeptions .目前我有这个代码:
public class MyExecutor extends ThreadPoolExecutor {
public static void main(String[] args) {
MyExecutor threadPool = new MyExecutor();
Task<Object> task = new Task<>();
threadPool.submit(task);
}
public MyExecutor() {
super(4, 20, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<>(4000));
}
@Override
protected void afterExecute(Runnable r, Throwable t) {
super.afterExecute(r, t);
System.out.println("in afterExecute()");
if (t != null) {
System.out.println("exception thrown: " + t.getMessage());
} else {
System.out.println("t == null");
}
}
private static class Task<V> implements Callable<V> {
@Override
public V call() throws …Run Code Online (Sandbox Code Playgroud) java multithreading futuretask threadpool threadpoolexecutor
在阅读Javascript的原型时,我遇到了这种行为,我无法解释.我在chrome的控制台(V8)中测试它.
var fruit = {taste:'good'};
var banana = Object.create(fruit);
console.log(banana.taste); //"good"
console.log(banana.__proto__); //Object {taste: "good"}
console.log(Object.getPrototypeOf(banana)); //Object {taste: "good"}
Run Code Online (Sandbox Code Playgroud)
到目前为止,一切都如预期.但是,如果我这样做:
var drink = Object.create(null);
Object.defineProperty(drink, 'taste', {value:"nice"});
var coke = Object.create(drink);
console.log(coke.taste); //"nice"
console.log(coke.__proto__); //undefined
console.log(Object.getPrototypeOf(coke)); //Object {taste: "nice"}
Run Code Online (Sandbox Code Playgroud)
然后coke.__proto__ === undefined.为什么是undefined第二种情况?
我需要在Android中使用Retrofit尽可能快地发出50个http GET请求.我正在使用OkHttp进行Retrofit.目前改造正在做的不好VS普通的Java ThreadPoolExecutor和HttpUrlConnection:约50秒的改造和30秒为纯HttpUrlConnection对所有50个请求,如果我设置了池大小20 ThreadPoolExecutor和用于改造/ OkHttp我设置okHttpClient.dispatcher().setMaxRequests(20);.
如果我查看logcat,我可以看到Retrofit最多会执行5个并发请求,无论我设置什么,setMaxRequests()而且ThreadPoolExecutor有可用工作线程的并发请求数量.
有什么办法可以让Retrofit变得更快吗?我不想切换到,HttpUrlConnection因为Retrofit非常优雅且易于使用.
我尝试向ThreadPoolExecutorOkHttp 提供自定义,但没有时间改进:
OkHttpClient.Builder builder = new OkHttpClient.Builder();
ExecutorService exec = new ThreadPoolExecutor(20, 20, 1, TimeUnit.HOURS, new LinkedBlockingQueue<>());
Dispatcher d = new Dispatcher(exec);
builder.dispatcher(d);
OkHttpClient okHttpClient = builder.build();
okHttpClient.dispatcher().setMaxRequests(20);
Run Code Online (Sandbox Code Playgroud)
如果这很重要,我会向同一个端点发出所有请求
如果一个线程中断另一个线程,中断状态是否会立即可见(即它是否有可见性问题)?
最重要的是,我想知道你有没有使用过中断?挥发性布尔标志似乎更可靠
我想创建一个缓存的线程池,但它作为一个固定的线程池.目前我有这个代码:
public class BackgroundProcesses {
public static void main(String[] args) throws InterruptedException, ExecutionException {
//ExecutorService threadPool2 = Executors.newCachedThreadPool();
ExecutorService threadPool = new ThreadPoolExecutor(2, 10, 180, TimeUnit.SECONDS, new LinkedBlockingQueue<>());
for (int i = 0; i < 800; i++) {
Callable<String> task = new Task();
threadPool.submit(task);
}
}
}
class Task implements Callable<String> {
@Override
public String call() throws Exception {
Thread.sleep(100);
System.out.println(Thread.currentThread().getName() + " is ready");
return "";
}
}
Run Code Online (Sandbox Code Playgroud)
如果我运行代码,我得到输出:
pool-1-thread-1 is ready
pool-1-thread-2 is ready
pool-1-thread-1 is ready
pool-1-thread-2 …Run Code Online (Sandbox Code Playgroud) 我是AngularJS noob.我试图实现一个表单,它需要填写所有输入字段,包括文件上传输入.
完全像第一个例子:https://angular-file-upload.appspot.com/
所以我创建了一个简单的表单来测试它:
<form name="myForm">
<input id="userUpload" ng-model="filename" name="userUpload" required type="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />
<input id="userName" ng-model="username" name="name" required type="text" />
<button ng-disabled="myForm.$invalid" class="btn btn-primary">Ok</button>
</form>
Run Code Online (Sandbox Code Playgroud)
但这不起作用.确定按钮将永远保持禁用状态.我发现如果我将属性添加ngf-select=""到文件输入字段:
<input id="userUpload" ng-model="filename" name="userUpload" required ngf-select="" type="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />
Run Code Online (Sandbox Code Playgroud)
然后表单按预期工作.填充两个userName和userUpload输入字段时,确定按钮变为启用状态.我试过谷歌搜索ngf-select但找不到满意的答案.它是做什么的,为什么表格必须按预期运作?
我有带有 MongoDB 的 Spring Web 应用程序。目前我总是从数据库中永久删除数据。
@Repository
public class SessionRepository extends CrudRepository implements SessionService {
...
@Override
public void insert(Session session) {
saveRoom(session);
getTemplate().insert(session);
}
@Override
public void delete(Session session) {
getTemplate().remove(session);
}
...
}
Run Code Online (Sandbox Code Playgroud)
将其更改为软删除的好方法是什么?
----------------- 编辑 1 -------------------
我现在明白我应该做什么的逻辑了,感谢 Sarath Nair。但我不确定如何在 Spring 中实现这一点。我有一个 Session 对象:
@Document(collection = "session")
public class Session {
@Id
private String id;
private Date startDate;
private Date endDate;
//I just put this here
private boolean deleted = false;
public boolean isDeleted() {
return deleted; …Run Code Online (Sandbox Code Playgroud) 我有一个返回类型为 void 的函数(包括整个函数):
CREATE OR REPLACE FUNCTION insert_avg_prices(p_county character varying, p_municipality character varying, p_district character varying, p_neighbourhood character varying, p_street character varying, p_number character varying, p_avg_rent decimal, p_avg_sale decimal)
RETURNS VOID AS
$BODY$
DECLARE
_precint_id integer;
_city_id integer;
_parish_id integer;
_county_id integer;
_address_id integer;
BEGIN
SELECT place_precint.precint_id INTO _precint_id FROM place_precint WHERE place_precint.name = p_neighbourhood;
SELECT place_city.city_id INTO _city_id FROM place_city WHERE place_city.name = p_district;
SELECT place_parish.parish_id INTO _parish_id FROM place_parish WHERE place_parish.name = p_municipality;
SELECT place_county.county_id INTO _county_id FROM …Run Code Online (Sandbox Code Playgroud) 对我来说,Javascript 中的变量很容易理解:如果一个变量不在局部范围内,那么它就是全局对象中的一个字段。
但是 Javascript 命令呢?如果我只是在文件中编写 Javascript 命令(在任何函数之外),那么 Javascript 引擎将如何解释它?
----- file.js -----
console.log('hai:DDD');
--- end of file ---
Run Code Online (Sandbox Code Playgroud)
它会function用命令创建某种“全局”或“主要”类型的对象然后执行它吗?如果有多个带有代码的文件怎么办?
我猜这个问题只适用于 node.js 因为在浏览器中所有 Javascript 代码都是事件处理程序
我一直在谷歌搜索这几个小时但到目前为止没有运气.
我想获取触摸/点击地图的位置的地址.
据我所知,为了获得地址,我需要反转地理编码坐标.但是我如何首先从地图中获取坐标?
java ×5
javascript ×3
android ×2
threadpool ×2
angularjs ×1
concurrency ×1
forms ×1
futuretask ×1
geocoding ×1
google-maps ×1
html ×1
http ×1
interrupt ×1
mongodb ×1
node.js ×1
okhttp3 ×1
postgresql ×1
prototype ×1
retrofit ×1
spring ×1
sql ×1
v8 ×1
volatile ×1