• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

apache / iotdb / #9917

24 Aug 2023 04:16PM UTC coverage: 47.861% (+0.009%) from 47.852%
#9917

push

travis_ci

web-flow
Feature/streamlined grafana plugin profile (#10907)

80245 of 167662 relevant lines covered (47.86%)

0.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.33
/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/path/fa/FAFactory.java
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one
3
 * or more contributor license agreements.  See the NOTICE file
4
 * distributed with this work for additional information
5
 * regarding copyright ownership.  The ASF licenses this file
6
 * to you under the Apache License, Version 2.0 (the
7
 * "License"); you may not use this file except in compliance
8
 * with the License.  You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing,
13
 * software distributed under the License is distributed on an
14
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
 * KIND, either express or implied.  See the License for the
16
 * specific language governing permissions and limitations
17
 * under the License.
18
 */
19
package org.apache.iotdb.commons.path.fa;
20

21
import org.apache.iotdb.commons.path.fa.dfa.PatternDFA;
22
import org.apache.iotdb.commons.path.fa.nfa.SimpleNFA;
23
import org.apache.iotdb.commons.schema.SchemaConstant;
24

25
import com.github.benmanes.caffeine.cache.Caffeine;
26
import com.github.benmanes.caffeine.cache.LoadingCache;
27

28
public class FAFactory {
29

30
  private final LoadingCache<IPatternFA.Builder, PatternDFA> dfaCache;
31
  private static final int DFA_CACHE_SIZE = 20;
32

33
  public IPatternFA constructDFA(IPatternFA.Builder builder) {
34
    return dfaCache.get(builder);
1✔
35
  }
36

37
  public IPatternFA constructNFA(IPatternFA.Builder builder) {
38
    return new SimpleNFA(builder.getPathPattern(), builder.isPrefixMatch());
1✔
39
  }
40

41
  private FAFactory() {
1✔
42
    dfaCache =
1✔
43
        Caffeine.newBuilder()
1✔
44
            .maximumSize(DFA_CACHE_SIZE)
1✔
45
            .build(
1✔
46
                builder -> {
47
                  if (builder.getPatternTree() != null) {
1✔
48
                    if (builder.getPatternTree().equals(SchemaConstant.ALL_MATCH_PATTERN_TREE)) {
1✔
49
                      // always return the same instance for root.**
50
                      return SchemaConstant.ALL_MATCH_DFA;
×
51
                    }
52
                    return new PatternDFA(builder.getPatternTree());
1✔
53
                  } else {
54
                    return new PatternDFA(builder.getPathPattern(), builder.isPrefixMatch());
1✔
55
                  }
56
                });
57
  }
1✔
58

59
  public static FAFactory getInstance() {
60
    return FAFactoryHolder.INSTANCE;
1✔
61
  }
62

63
  /** singleton pattern. */
64
  private static class FAFactoryHolder {
65
    private static final FAFactory INSTANCE = new FAFactory();
1✔
66
  }
67
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc