鍍金池/ 問答/ 人工智能問答
不討喜 回答

沒有css,無法確定你的問題。
應(yīng)該是這個(gè)div的外層結(jié)點(diǎn)有width限制了。

任她鬧 回答

kafka里面有單播和廣播的區(qū)別,對(duì)一條消息來說,同一個(gè)消費(fèi)組內(nèi)的消費(fèi)者有競態(tài)關(guān)系,只有一個(gè)消費(fèi)者能消費(fèi),這個(gè)是單播;同樣,對(duì)一條消息,不同消費(fèi)組的消費(fèi)者都可以同時(shí)消費(fèi),這是多播。假如你想讓兩個(gè)消費(fèi)者都能同時(shí)消費(fèi)到消息,你可以將這兩個(gè)消費(fèi)者放在不同的消費(fèi)組,這個(gè)需要消費(fèi)端的groupId屬性來設(shè)置。

小曖昧 回答

js所在頁和你接口地址,不是跨域關(guān)系吧?如果是跨域的話,jq是會(huì)發(fā)起兩次請(qǐng)求的,一次是 OPTION ,一次是 POST 。


題外話,你redis用的是string,也不是不行,就是到時(shí)候會(huì)有多少個(gè)key你自己管理起來會(huì)累死,而且也不好做關(guān)鍵詞排名,推薦哈希集或者有序集合

挽青絲 回答
  1. 把常用的查詢字段做成多字段索引
  2. 只查詢需要的列
  3. 查詢的時(shí)候把限制范圍最長的字段放在最前面
懶洋洋 回答

不一定越多越好,建議你看看這個(gè)。這個(gè)回答比較專業(yè),提到了層數(shù)和節(jié)點(diǎn)數(shù)量的關(guān)系。
神經(jīng)網(wǎng)絡(luò)如何選擇隱藏層的數(shù)量

陌上花 回答

問題解決了。直接將core-site.xml文件拷貝到classpath下,或者添加如下配置即可:

conf.set("hadoop.tmp.dir", "/home/parallels/app/hadoop-2.4.1/data/");
胭脂淚 回答

google 了一晚上,終于找到了比較滿意的方法,下面是整個(gè)的 RedisCacheConfig 文件

@Configuration
public class RedisCacheConfig {

    @Bean
    public KeyGenerator simpleKeyGenerator() {
        return (o, method, objects) -> {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append(o.getClass().getSimpleName());
            stringBuilder.append(".");
            stringBuilder.append(method.getName());
            stringBuilder.append("[");
            for (Object obj : objects) {
                stringBuilder.append(obj.toString());
            }
            stringBuilder.append("]");

            return stringBuilder.toString();
        };
    }

    @Bean
    public CacheManager cacheManager(RedisConnectionFactory redisConnectionFactory) {
        return new RedisCacheManager(
            RedisCacheWriter.nonLockingRedisCacheWriter(redisConnectionFactory),
            this.getRedisCacheConfigurationWithTtl(600), // 默認(rèn)策略,未配置的 key 會(huì)使用這個(gè)
            this.getRedisCacheConfigurationMap() // 指定 key 策略
        );
    }

    private Map<String, RedisCacheConfiguration> getRedisCacheConfigurationMap() {
        Map<String, RedisCacheConfiguration> redisCacheConfigurationMap = new HashMap<>();
        redisCacheConfigurationMap.put("UserInfoList", this.getRedisCacheConfigurationWithTtl(3000));
        redisCacheConfigurationMap.put("UserInfoListAnother", this.getRedisCacheConfigurationWithTtl(18000));

        return redisCacheConfigurationMap;
    }

    private RedisCacheConfiguration getRedisCacheConfigurationWithTtl(Integer seconds) {
        Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class);
        ObjectMapper om = new ObjectMapper();
        om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
        om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
        jackson2JsonRedisSerializer.setObjectMapper(om);

        RedisCacheConfiguration redisCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig();
        redisCacheConfiguration = redisCacheConfiguration.serializeValuesWith(
            RedisSerializationContext
                .SerializationPair
                .fromSerializer(jackson2JsonRedisSerializer)
        ).entryTtl(Duration.ofSeconds(seconds));

        return redisCacheConfiguration;
    }
}

要指定 key 的過期時(shí)間,只要在getRedisCacheConfigurationMap方法中添加就可以。
然后只需要 @Cacheable 就可以把數(shù)據(jù)存入 redis

    @Cacheable(value = "UserInfoList", keyGenerator = "simpleKeyGenerator") // 3000秒
    @Cacheable(value = "UserInfoListAnother", keyGenerator = "simpleKeyGenerator") // 18000秒
    @Cacheable(value = "DefaultKeyTest", keyGenerator = "simpleKeyGenerator") // 600秒,未指定的key,使用默認(rèn)策略
    
瘋浪 回答

Django models支持abstract=True屬性, 設(shè)置這個(gè)屬性后, 這個(gè)models不會(huì)在創(chuàng)建表, 專門用來繼承, 具體的可以看官方文檔 Models Abstract base classes部分.

Abstract base classes

Abstract base classes are useful when you want to put some common information into a number of other models. You write your base class and put abstract=True in the Meta class. This model will then not be used to create any database table. Instead, when it is used as a base class for other models, its fields will be added to those of the child class. It is an error to have fields in the abstract base class with the same name as those in the child (and Django will raise an exception).

An example:

from django.db import models

class CommonInfo(models.Model):
    name = models.CharField(max_length=100)
    age = models.PositiveIntegerField()

    class Meta:
        abstract = True

class Student(CommonInfo):
    home_group = models.CharField(max_length=5)

The Student model will have three fields: name, age and home_group. The CommonInfo model cannot be used as a normal Django model, since it is an abstract base class. It does not generate a database table or have a manager, and cannot be instantiated or saved directly.

葬愛 回答

不知道ab.exe測(cè)試時(shí)什么原理,你自己寫一個(gè)多線程調(diào)用下就知道了會(huì)產(chǎn)生負(fù)數(shù)值的。

//php不會(huì),用java寫了個(gè)test。
import redis.clients.jedis.Jedis;


public class Test {
    
    public static void main(String[] args) throws Exception {
        
        Jedis jedis = getJedis();
        jedis.set("nums", 50+"");
        close(jedis);
        
        for(int i = 0;i < 1000;i++){ //啟動(dòng)1000個(gè)線程
            new Thread(new MyTask()).start();
        }
        
    }
    
    public static  Jedis getJedis(){
        Jedis j = new Jedis("xxxxx", 6379);
        j.auth("xxxx");
        return j;
    }
    
    public static void close(Jedis jedis){
        if(null == jedis){
            return;
        }
        jedis.close();
    }
}

class MyTask implements Runnable{
    @Override
    public void run() {
        Jedis j = Test.getJedis();
         String numStr = j.get("nums");
         Integer nums = Integer.valueOf(numStr);
        
        if(nums > 1){
             j.decr("nums");
        }else{
             System.out.println(nums);
        }
        Test.close(j);
    }
}

輸出結(jié)果出現(xiàn)負(fù)值。

安淺陌 回答

大概看懂了,你的意思是如果去匹配出來,只有少于或等于兩個(gè)字符不能匹配上,就算找到了是吧,我把條件列一下

import re

if re.match(r'^.{0,6}首長四方財(cái)務(wù)有限公司$', '北京首長四方財(cái)務(wù)有限公司') or re.match(r'^首長四方財(cái)務(wù)有限公司.{0,6}$', '北京首長四方財(cái)務(wù)有限公司')
    ......

用.{0,6}判定首尾最多6個(gè)字符不匹配上,其中1個(gè)漢字占3個(gè)字符。

希望能幫助到你。

糖豆豆 回答

自問自答,結(jié)束

萢萢糖 回答

我完全復(fù)制粘貼了你的代碼。。并沒有發(fā)生你所截圖的情況。

clipboard.png

另外 你這注釋的方式。。在template里不是應(yīng)該遵循h(huán)tml的注釋方式么。你看我這圖里你的注釋都被當(dāng)成text輸出了。所以你這構(gòu)建環(huán)境具體怎么樣的和vue版本、package乃至開發(fā)工具都最好貼出來給大家參詳 避免玄學(xué)問題。。

執(zhí)念 回答

文件沒有引入進(jìn)去,

不能直接在 web.xml 直接配置(解決方案是 import 引入)

具體原因,還待研究;

病癮 回答

內(nèi)存問題可以使用valgrind定位。
“double free”或者“Segmentation fault” 要給出具體異常信息,光給個(gè)代碼片段沒什么用

熊出沒 回答

實(shí)現(xiàn)key-value咯,參見https://www.zhihu.com/question/30527705

當(dāng)然時(shí)間多的話你可以對(duì)比各種查找樹實(shí)現(xiàn)key-value存儲(chǔ)結(jié)構(gòu)的存儲(chǔ)和查詢效率,搞個(gè)benchmark,然后就可以寫一篇博客。

雨萌萌 回答
  1. 可以先通過bash命令mongoexport把mongo里的數(shù)據(jù)導(dǎo)出成文件,然后通過讀取文件內(nèi)容來處理
  2. data = list(col.find({'id': {"$in": nodes}})) 直接加載到內(nèi)存試一下?id字段加索引了吧?
寫榮 回答

PHP有兩個(gè)執(zhí)行環(huán)境,一個(gè)是在終端下,一個(gè)是在web,你配置的應(yīng)該在終端下,web端沒有配置,你看看你的PHP在/etc/php的目錄是不是還有類似cli,fpm,apache2目錄,如果是apache服務(wù),就在apache2下開啟,要是nginx,就在fpm下開啟

櫻花霓 回答

如果層數(shù)確定的話,可以這樣做:

<script>
    var ad = [
        {
            "id": 1,
            "display_name": "儀表盤",
            "children": []
        },
        {
            "id": 2,
            "display_name": "用戶權(quán)限管理",
            "children": [
                {
                    "id": 3,
                    "display_name": "用戶列表",
                    "children": [
                        {
                            "id": 5,
                            "display_name": "創(chuàng)建管理員"
                        },
                        {
                            "id": 6,
                            "display_name": "刪除用戶"
                        },
                        {
                            "id": 7,
                            "display_name": "用戶禁用/取消禁用"
                        },
                        {
                            "id": 8,
                            "display_name": "更新用戶所在角色組"
                        }
                    ]
                }
            ]
        }];

    var the_id = 5;
    var the_select_id = [];

    for(var i in ad){
        if (ad[i].id !== the_id) {
            for(var j in ad[i].children) {

                if (ad[i].children[j].id !== the_id) {
                    for(var k in ad[i].children[j].children) {

                        if (ad[i].children[j].children[k].id == the_id) {
                            the_select_id.push(ad[i].children[j].children[k].id);
                            the_select_id.push(ad[i].children[j].id);
                            the_select_id.push(ad[i].id);
                        }
                    }
                } else {
                    the_select_id.push(ad[i].children[j].id);
                    the_select_id.push(ad[i].id);
                }
            }
        } else {
            the_select_id.push(ad[i].id);
        }
    }

    console.log(the_select_id);
</script>

效果如圖:

clipboard.png

當(dāng)然,代碼還可以精簡優(yōu)化,這里只是提供個(gè)參考