小编Bri*_*ley的帖子

ElasticSearch一个edgeNGram用于自动完成\ typeahead,是我的search_analyzer被忽略

我有三个带有"userName"字段的文档:

  • 'briandilley'
  • 'briangumble'
  • 'briangriffen'

当我搜索'brian'时,我按照预期得到了所有三个,但是当我搜索'briandilley'时,我仍然得到了所有三个回来.analyze API告诉我它在我的搜索字符串上使用了ngram过滤器,但我不确定原因.这是我的设置:

索引设置:

{
    "analysis": {
        "analyzer": {
            "username_index": {
                "tokenizer": "keyword",
                "filter": ["lowercase", "username_ngram"]
            },
            "username_search": {
                "tokenizer": "keyword",
                "filter": ["lowercase"]
            }
        },
        "filter": {
            "username_ngram": {
                "type": "edgeNGram",
                "side" : "front",
                "min_gram": 1,
                "max_gram": 15
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

制图:

{
    "user_follow": {

        "properties": {
            "targetId": { "type": "string", "store": true },
            "followerId": { "type": "string", "store": true },
            "dateUpdated": { "type": "date", "store": true },

            "userName": {
                "type": "multi_field",
                "fields": {
                    "userName": { …
Run Code Online (Sandbox Code Playgroud)

java elasticsearch

6
推荐指数
1
解决办法
4481
查看次数

无法进行多处理以同时运行进程

下面的代码似乎并不同时运行,我不确定为什么:

def run_normalizers(config, debug, num_threads, name=None):

    def _run():
        print('Started process for normalizer')
        sqla_engine = init_sqla_from_config(config)
        image_vfs = create_s3vfs_from_config(config, config.AWS_S3_IMAGE_BUCKET)
        storage_vfs = create_s3vfs_from_config(config, config.AWS_S3_STORAGE_BUCKET)

        pp = PipedPiper(config, image_vfs, storage_vfs, debug=debug)

        if name:
            pp.run_pipeline_normalizers(name)
        else:
            pp.run_all_normalizers()
        print('Normalizer process complete')

    threads = []
    for i in range(num_threads):
        threads.append(multiprocessing.Process(target=_run))
    [t.start() for t in threads]
    [t.join() for t in threads]


run_normalizers(...)
Run Code Online (Sandbox Code Playgroud)

config变量只是的以外定义的词典_run()功能.似乎创建了所有进程 - 但它并不比使用单个进程更快地完成.基本上,run_**_normalizers()函数中发生的是从数据库中的队列表(SQLAlchemy)读取,然后发出一些HTTP请求,然后运行规范化器的"管道"来修改数据,然后将其保存回数据库.我来自JVM领域,其中线程"很重"并经常用于并行 - 我有点困惑,因为我认为多进程模块应该绕过Python的GIL的限制.

python concurrency multithreading multiprocess

6
推荐指数
1
解决办法
1104
查看次数

使用maven发布多个长寿分支

所以这里是Subversion,Jenkins,Beanstalk设置:

  • trunk/ - >开发主线
    • CI建立在签入之上
    • 成功的CI构建产生了CD构建,推动了"测试"Beanstalk环境
  • branches/qa/ - >当前发布的候选人
    • CI建立在签入之上
    • 成功的CI构建会产生推动"QA"Beanstalk环境的CD构建
  • branches/prod/ - >当前版本
    • CI建立在签入之上
    • 成功的CI构建产生了CD构建,推动了"Prod"Beanstalk环境

基本上我想要做的是:

  • 开发周期从主干开始(主干:0.1-SNAPSHOT)
  • 当开发周期完成时,分支到qa并且是qa循环.也在trunk中开始下一个开发周期(trunk 0.2-SNAPSHOT,qa:0.1-SNAPSHOT)
  • 当qa循环完成分支到prod并执行maven释放.也开始下一个qa周期(主干0.2-SNAPSHOT,qa:0.2-SNAPSHOT,prod:0.1)

这个想法是短冲刺,在每个结束时,一个开发循环结束并且qa循环开始.当qa循环完成时,它被推送到生产环境.

我想保留分支并从分支合并到\而不是删除和重新创建.这个想法是,在qa中进行的任何修复都将合并回介绍主干,并且在prod中进行的任何更改都将合并回qa(并返回到主干).

因此prod是一个"热门"分支,代表了生产环境的当前状态.

这是一个小团队的开发人员工作一周的冲刺.

问题:

  1. 这个设置听起来如何?
  2. 我可以让maven正确行动,还是我需要编写脚本?
  3. 谁是你爸爸?他做了什么?

java version-control release-management maven jenkins

5
推荐指数
1
解决办法
474
查看次数

我无法理解PhotoView的getDisplayRect()实际返回的内容(构建android照片裁剪工具)

我正在尝试使用PhotoView库为照片构建裁剪工具,但我无法理解返回的值getDisplayRect().我把照片设置在ImageView这样的:

photo.setImageDrawable(new BitmapDrawable(getResources(), image));
Run Code Online (Sandbox Code Playgroud)

imageBitmap对象在哪里.然后我设置了一些缩放值:

float minScale = ((float)image.getWidth() > (float)image.getHeight())
    ? (float)image.getWidth() / (float)image.getHeight()
    : (float)image.getHeight() / (float)image.getWidth();
attacher.setMaxScale(minScale * 5f);
attacher.setMidScale(minScale * 2.5f);
attacher.setMinScale(minScale);
attacher.setScale(minScale, (float)image.getWidth() / 2f,(float)image.getHeight() / 2f, false);
attacher.update();
Run Code Online (Sandbox Code Playgroud)

其中attacherPhotoViewAttacher对象.

当用户完成后,我使用以下内容来确定在以下位置可见的位图部分ImageView:

RectF rect      = attacher.getDisplayRect();
float scale             = attacher.getScale();
PhotoData ret   = new PhotoData(data);
ret.x       = (int)(Math.abs(rect.left) / scale);
ret.y       = (int)(Math.abs(rect.top) / scale);
ret.width   = (int)(rect.width() / scale);
ret.height  = (int)(rect.height() …
Run Code Online (Sandbox Code Playgroud)

java math android

5
推荐指数
1
解决办法
1741
查看次数

TypedArray .getColor()始终在自定义视图中返回-1

我创建了一个自定义视图,其中TextView调用了子类TextViewEx.这个视图比通过xml Drawables可用的化合物增加了更多的灵活性TextView.我想要的部分功能是能够为复合绘图提供色彩,但无论出于何种原因,返回的颜色总是如此-1.这是代码:

attrs.xml:

<resources>
    <declare-styleable name="TextViewEx">
        <attr name="drawableLeftWidth" format="dimension" />
        <attr name="drawableLeftHeight" format="dimension" />
        <attr name="drawableLeftTint" format="color" />

        <attr name="drawableTopWidth" format="dimension" />
        <attr name="drawableTopHeight" format="dimension" />
        <attr name="drawableTopTint" format="color" />

        <attr name="drawableRightWidth" format="dimension" />
        <attr name="drawableRightHeight" format="dimension" />
        <attr name="drawableRightTint" format="color" />

        <attr name="drawableBottomWidth" format="dimension" />
        <attr name="drawableBottomHeight" format="dimension" />
        <attr name="drawableBottomTint" format="color" />
    </declare-styleable>
</resources>
Run Code Online (Sandbox Code Playgroud)

TextViewEx.java:

public class TextViewEx
        extends TextView {

    public TextViewEx(Context context) {
        super(context);
        init(null, 0);
    } …
Run Code Online (Sandbox Code Playgroud)

java android android-layout

4
推荐指数
1
解决办法
2793
查看次数