Java Code Examples for com.google.common.collect.LinkedListMultimap#create()

The following examples show how to use com.google.common.collect.LinkedListMultimap#create() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExpandCompositeTermsTest.java    From datawave with Apache License 2.0 6 votes vote down vote up
@Test
public void test23() throws Exception {
    ShardQueryConfiguration conf = new ShardQueryConfiguration();
    
    Multimap<String,String> compositeToFieldMap = LinkedListMultimap.create();
    
    compositeToFieldMap.put("GEO_WKT", "GEO");
    compositeToFieldMap.put("GEO_WKT", "WKT");
    conf.setCompositeToFieldMap(compositeToFieldMap);
    
    Map<String,String> compositeToSeparatorMap = new HashMap<>();
    compositeToSeparatorMap.put("GEO_WKT", ",");
    conf.setCompositeFieldSeparators(compositeToSeparatorMap);
    
    Set<String> indexedFields = new HashSet<>();
    indexedFields.add("GEO");
    
    conf.getFieldToDiscreteIndexTypes().put("GEO", new GeometryType());
    
    String query = "((((GEO >= '0202' && GEO <= '020d'))) || (((GEO >= '030a' && GEO <= '0335'))) || (((GEO >= '0428' && GEO <= '0483'))) || (((GEO >= '0500aa' && GEO <= '050355'))) || (((GEO >= '1f0aaaaaaaaaaaaaaa' && GEO <= '1f36c71c71c71c71c7')))) && ((WKT >= '+AE0' && WKT < '+bE4'))";
    String expected = "(((((GEO_WKT >= '0202,+AE0' && GEO_WKT < '020d,+bE4') && ((ASTEvaluationOnly = true) && ((GEO >= '0202' && GEO <= '020d') && (WKT >= '+AE0' && WKT < '+bE4')))))) || ((((GEO_WKT >= '030a,+AE0' && GEO_WKT < '0335,+bE4') && ((ASTEvaluationOnly = true) && ((GEO >= '030a' && GEO <= '0335') && (WKT >= '+AE0' && WKT < '+bE4')))))) || ((((GEO_WKT >= '0428,+AE0' && GEO_WKT < '0483,+bE4') && ((ASTEvaluationOnly = true) && ((GEO >= '0428' && GEO <= '0483') && (WKT >= '+AE0' && WKT < '+bE4')))))) || ((((GEO_WKT >= '0500aa,+AE0' && GEO_WKT < '050355,+bE4') && ((ASTEvaluationOnly = true) && ((GEO >= '0500aa' && GEO <= '050355') && (WKT >= '+AE0' && WKT < '+bE4')))))) || ((((GEO_WKT >= '1f0aaaaaaaaaaaaaaa,+AE0' && GEO_WKT < '1f36c71c71c71c71c7,+bE4') && ((ASTEvaluationOnly = true) && ((GEO >= '1f0aaaaaaaaaaaaaaa' && GEO <= '1f36c71c71c71c71c7') && (WKT >= '+AE0' && WKT < '+bE4')))))))";
    
    runTestQuery(query, expected, indexedFields, conf);
}
 
Example 2
Source File: AcyclicDepthFirstPostOrderTraversalTest.java    From buck with Apache License 2.0 6 votes vote down vote up
/** Ensures that a cycle is detected in a trivial graph of a single node that points to itself. */
@Test
public void testTrivialCycle() {
  Multimap<Node, Node> graph = LinkedListMultimap.create();
  graph.put(Node.A, Node.A);
  TestDagDepthFirstSearch dfs = new TestDagDepthFirstSearch(graph);

  try {
    dfs.traverse(ImmutableList.of(Node.A));
  } catch (CycleException e) {
    assertThat(
        e.getMessage(),
        Matchers.containsString(
            linesToText("The following circular dependency has been found:", "A -> A")));
    assertEquals(ImmutableList.of(Node.A, Node.A), e.getCycle());
  }
}
 
Example 3
Source File: ExpandCompositeTermsTest.java    From datawave with Apache License 2.0 6 votes vote down vote up
@Test
public void test14() throws Exception {
    ShardQueryConfiguration conf = new ShardQueryConfiguration();
    
    Multimap<String,String> compositeToFieldMap = LinkedListMultimap.create();
    
    compositeToFieldMap.put("GEO", "GEO");
    compositeToFieldMap.put("GEO", "WKT_BYTE_LENGTH");
    conf.setCompositeToFieldMap(compositeToFieldMap);
    
    Map<String,String> compositeToSeparatorMap = new HashMap<>();
    compositeToSeparatorMap.put("GEO", ",");
    conf.setCompositeFieldSeparators(compositeToSeparatorMap);
    
    Set<String> indexedFields = new HashSet<>();
    indexedFields.add("GEO");
    
    conf.getFieldToDiscreteIndexTypes().put("GEO", new GeometryType());
    
    String query = "(GEO >= '0100' && GEO <= '0103') && WKT_BYTE_LENGTH <= '" + Normalizer.NUMBER_NORMALIZER.normalize("12345") + "'";
    String expected = "(GEO >= '0100' && GEO <= '0103,+eE1.2345') && ((ASTEvaluationOnly = true) && ((GEO >= '0100' && GEO <= '0103') && WKT_BYTE_LENGTH <= '+eE1.2345'))";
    
    runTestQuery(query, expected, indexedFields, conf);
}
 
Example 4
Source File: Serializee.java    From vraptor4 with Apache License 2.0 5 votes vote down vote up
public Multimap<String, Class<?>> getExcludes() {
	if (excludes == null) {
		excludes = LinkedListMultimap.create();
	}
	
	return excludes;
}
 
Example 5
Source File: AcyclicDepthFirstPostOrderTraversalTest.java    From buck with Apache License 2.0 5 votes vote down vote up
@Test
public void testShortCircuitTraversal() throws CycleException {
  Multimap<Node, Node> graph = LinkedListMultimap.create();
  graph.put(Node.A, Node.B);
  graph.put(Node.B, Node.C);
  graph.put(Node.C, Node.D);
  graph.put(Node.B, Node.E);

  TestDagDepthFirstSearch dfs = new TestDagDepthFirstSearch(graph, node -> !node.equals(Node.C));
  dfs.traverse(ImmutableList.of(Node.A));
  assertEquals(ImmutableList.of(Node.C, Node.E, Node.B, Node.A), dfs.exploredNodes);
}
 
Example 6
Source File: Signer.java    From galaxy-sdk-java with Apache License 2.0 5 votes vote down vote up
private static LinkedListMultimap<String, String> parseUriParameters(URI uri) {
  LinkedListMultimap<String, String> params = LinkedListMultimap.create();
  String query = uri.getQuery();
  if (query != null) {
    for (String param : query.split("&")) {
      String[] kv = param.split("=");
      if (kv.length >= 2) {
        params.put(kv[0], param.substring(kv[0].length() + 1));
      } else {
        params.put(kv[0], "");
      }
    }
  }
  return params;
}
 
Example 7
Source File: UriUtils.java    From accumulo-recipes with Apache License 2.0 5 votes vote down vote up
public static Multimap<String, String> splitQuery(String query) throws UnsupportedEncodingException {
    Multimap<String, String> query_pairs = LinkedListMultimap.create();
    String[] pairs = query.split("&");
    for (String pair : pairs) {
        int idx = pair.indexOf("=");
        query_pairs.put(URLDecoder.decode(pair.substring(0, idx), "UTF-8"), URLDecoder.decode(pair.substring(idx + 1), "UTF-8"));
    }
    return query_pairs;
}
 
Example 8
Source File: SpringValueDefinitionProcessor.java    From apollo with Apache License 2.0 5 votes vote down vote up
public static Multimap<String, SpringValueDefinition> getBeanName2SpringValueDefinitions(BeanDefinitionRegistry registry) {
  Multimap<String, SpringValueDefinition> springValueDefinitions = beanName2SpringValueDefinitions.get(registry);
  if (springValueDefinitions == null) {
    springValueDefinitions = LinkedListMultimap.create();
  }

  return springValueDefinitions;
}
 
Example 9
Source File: FDSHttpClient.java    From galaxy-fds-sdk-java with Apache License 2.0 5 votes vote down vote up
public LinkedListMultimap<String, String> headerArray2MultiValuedMap(Header[] headers) {
  LinkedListMultimap<String, String> m = LinkedListMultimap.create();
  if (headers != null) for (Header h : headers) {
    m.put(h.getName(), h.getValue());
  }
  return m;
}
 
Example 10
Source File: Vehicle.java    From anki-drive-java with MIT License 5 votes vote down vote up
public Vehicle(AnkiConnector anki, String address, String manufacturerData, String localName) {
   try {
	this.anki = new AnkiConnector(anki);
} catch (IOException e) {
	this.anki = anki;
}
   this.address = address;
   this.advertisement = new AdvertisementData(manufacturerData, localName);
   
   this.listeners = LinkedListMultimap.create();
 }
 
Example 11
Source File: TestValuesIterator.java    From tez with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor
 *
 * @param serializationClassName serialization class to be used
 * @param key                    key class name
 * @param val                    value class name
 * @param comparator             to be used
 * @param correctComparator      (real comparator to be used for correct results)
 * @param testResult             expected result
 * @throws IOException
 */
public TestValuesIterator(String serializationClassName, Class key, Class val,
    TestWithComparator comparator, TestWithComparator correctComparator, boolean testResult)
    throws IOException {
  this.keyClass = key;
  this.valClass = val;
  this.comparator = getComparator(comparator);
  this.correctComparator =
      (correctComparator == null) ? this.comparator : getComparator(correctComparator);
  this.expectedTestResult = testResult;
  originalData = LinkedListMultimap.create();
  setupConf(serializationClassName);
}
 
Example 12
Source File: ClassPathBuilder.java    From cloud-opensource-java with Apache License 2.0 5 votes vote down vote up
/**
 * Builds a classpath from the transitive dependency graph of a list of artifacts.
 * When there are multiple versions of an artifact in
 * the dependency tree, the closest to the root in breadth-first order is picked up. This "pick
 * closest" strategy follows Maven's dependency mediation.
 *
 * @param artifacts the first artifacts that appear in the classpath, in order
 */
public ClassPathResult resolve(List<Artifact> artifacts) {

  LinkedListMultimap<ClassPathEntry, DependencyPath> multimap = LinkedListMultimap.create();
  if (artifacts.isEmpty()) {
    return new ClassPathResult(multimap, ImmutableList.of());
  }
  // dependencyGraph holds multiple versions for one artifact key (groupId:artifactId)
  DependencyGraph result = dependencyGraphBuilder.buildFullDependencyGraph(artifacts);
  List<DependencyPath> dependencyPaths = result.list();

  // TODO should DependencyGraphResult have a mediate() method that returns a ClassPathResult?
  
  // To remove duplicates on (groupId:artifactId) for dependency mediation
  MavenDependencyMediation mediation = new MavenDependencyMediation();

  for (DependencyPath dependencyPath : dependencyPaths) {
    Artifact artifact = dependencyPath.getLeaf();
    mediation.put(dependencyPath);
    if (mediation.selects(artifact)) {
      // We include multiple dependency paths to the first version of an artifact we see,
      // but not paths to other versions of that artifact.
      multimap.put(new ClassPathEntry(artifact), dependencyPath);
    }
  }
  return new ClassPathResult(multimap, result.getUnresolvedArtifacts());
}
 
Example 13
Source File: GalaxyFDSClient.java    From galaxy-fds-sdk-java with Apache License 2.0 5 votes vote down vote up
private LinkedListMultimap<String, String> headerArray2MultiValuedMap(Header[] headers) {
  LinkedListMultimap<String, String> m = LinkedListMultimap.create();
  if (headers != null) for (Header h : headers) {
    m.put(h.getName(), h.getValue());
  }
  return m;
}
 
Example 14
Source File: ThirdEyeRequest.java    From incubator-pinot with Apache License 2.0 4 votes vote down vote up
public ThirdEyeRequestBuilder() {
  this.filterSet = LinkedListMultimap.create();
  this.groupBy = new ArrayList<String>();
  metricFunctions = new ArrayList<>();
}
 
Example 15
Source File: HttpRequest.java    From timbuctoo with GNU General Public License v3.0 4 votes vote down vote up
public HttpRequest(String method, String url) {
  this(method, url, LinkedListMultimap.create(), null, null, LinkedListMultimap.create());
}
 
Example 16
Source File: HttpRequest.java    From timbuctoo with GNU General Public License v3.0 4 votes vote down vote up
public HttpRequest(String method, String url, String body) {
  this(method, url, LinkedListMultimap.create(), body, null, LinkedListMultimap.create());
}
 
Example 17
Source File: BaseTypeImpl.java    From schemaorg-java with Apache License 2.0 4 votes vote down vote up
BuilderImpl() {
  properties = LinkedListMultimap.create();
}
 
Example 18
Source File: ListMultimapJsonDeserializer.java    From gwt-jackson with Apache License 2.0 4 votes vote down vote up
@Override
protected ListMultimap<K, V> newMultimap() {
    return LinkedListMultimap.create();
}
 
Example 19
Source File: AndOrHasContainer.java    From sqlg with MIT License 4 votes vote down vote up
private void toSql(SqlgGraph sqlgGraph, SchemaTableTree schemaTableTree, StringBuilder result, int depth) {
    if (!this.hasContainers.isEmpty()) {
        boolean first = true;
        for (HasContainer h : this.hasContainers) {
            if (!SqlgUtil.isBulkWithin(sqlgGraph, h)) {
                if (first) {
                    first = false;
                    result.append("(");
                } else {
                	result.append(" AND ");
                }
                String k=h.getKey();
                WhereClause whereClause = WhereClause.from(h.getPredicate());
                
                // check if property exists
                String bool=null;
                if (!k.equals(T.id.getAccessor())){
                	Map<String,PropertyType> pts=sqlgGraph.getTopology().getTableFor(schemaTableTree.getSchemaTable());
                    if (pts!=null && !pts.containsKey(k)){
                    	// verify if we have a value
                    	Multimap<String, Object> keyValueMap=LinkedListMultimap.create();
                    	whereClause.putKeyValueMap(h, keyValueMap, schemaTableTree);
                    	// we do
                    	if (keyValueMap.size()>0){
                    		bool="? is null";
                    	} else {
                    		 if (Existence.NULL.equals(h.getBiPredicate())) {
                    			 bool="1=1";
                    		 } else {
                    			 bool="1=0";
                    		 }
                    	}
                    }
                }
                if (bool!=null){
                	result.append(bool);
                } else {
                	
                	result.append(whereClause.toSql(sqlgGraph, schemaTableTree, h));
                }
            }
        }
        if (!first) {
            result.append(")");
        }
    }
    int count = 1;
    if (!this.andOrHasContainers.isEmpty()) {
        result.append("\n");
        for (int i = 0; i < depth; i++) {
            result.append("\t");
        }
        result.append("(");
    }
    for (AndOrHasContainer andOrHasContainer : this.andOrHasContainers) {
        andOrHasContainer.toSql(sqlgGraph, schemaTableTree, result, depth + 1);
        if (count++ < this.andOrHasContainers.size()) {
            switch (this.type) {
                case AND:
                    result.append(" AND ");
                    break;
                case OR:
                    result.append(" OR ");
                    break;
                case NONE:
                    break;
            }
        }
    }
    if (!this.andOrHasContainers.isEmpty()) {
        result.append("\n");
        for (int i = 0; i < depth - 1; i++) {
            result.append("\t");
        }
        result.append(")");
    }
}
 
Example 20
Source File: LinkedListMultimapJsonDeserializer.java    From gwt-jackson with Apache License 2.0 4 votes vote down vote up
@Override
protected LinkedListMultimap<K, V> newMultimap() {
    return LinkedListMultimap.create();
}