Refine search
private static Map<String, String> parseConfigOverrides( Args arguments ) { Collection<Pair<String, String>> options = arguments.interpretOptions( "c", Converters.optional(), s -> { if ( s.contains( "=" ) ) { String[] keyVal = s.split( "=", 2 ); return pair( keyVal[0], keyVal[1] ); } // Shortcut to specify boolean flags ("-c dbms.enableTheFeature") return pair( s, "true" ); } ); Map<String,String> ret = stringMap(); options.forEach( pair -> ret.put( pair.first(), pair.other() ) ); return ret; }
assertEquals( asList( of( 1, "Person" ), of( 2, "City" ) ), Iterators.asList( lookup.labels() ) ); assertEquals( asList( of( 1, "name" ), of( 2, "income" ), of( 3, "lastName" ), of( 4, "tax" ), of( 5, "area" ) ), Iterators.asList( lookup.properties() ) ); assertEquals( asList( of( 1, "LIVES_IN" ), of( 2, "FRIEND" ) ), Iterators.asList( lookup.relationshipTypes() ) ); assertArrayEquals( new String[] { "Person" }, lookup.knownUniqueIndices().next().first() ); assertArrayEquals( new String[]{"name", "lastName"}, lookup.knownUniqueIndices().next().other() ); assertEquals( asList( "City" ), Iterators.asList( Iterators.map( Pair::first, lookup.knownUniqueConstraints() ) ) ); assertArrayEquals( new String[]{"name", "area"}, lookup.knownUniqueConstraints().next().other() ); assertEquals( new String[] { "City" }, lookup.knownIndices().next().first() ); assertArrayEquals( new String[]{"income", "tax"}, lookup.knownIndices().next().other() );
@Override public Key[] keys() { Key[] keys = new Key[stats.size()]; int i = 0; for ( Pair<Key,Stat> stat : stats ) { keys[i++] = stat.first(); } return keys; }
public String maybeReadInfo( FileSystemAbstraction fs, File stateFile, String currentInfo ) { if ( currentInfo != null ) { return currentInfo; } Pair<String,String> data = readFromFile( fs, stateFile, this ); return data == null ? null : data.other(); }
private Iterator<Pair<String,String[]>> idsToNames( Iterable<? extends LabelSchemaSupplier> nodeConstraints ) { return Iterators.map( nodeConstraint -> { String label = labels.byIdOrFail( nodeConstraint.schema().getLabelId() ); String[] propertyKeyNames = propertyKeys .byIdOrFail( nodeConstraint.schema().getPropertyIds() ); return Pair.of( label, propertyKeyNames ); }, nodeConstraints.iterator() ); } };
@Test public void shouldReplaceExistingDynamicLabelsWithInlined() { // GIVEN BatchInserter inserter = globalInserter; long node = inserter.createNode( map(), manyLabels( 150 ).first() ); // WHEN inserter.setNodeLabels( node, Labels.FIRST ); // THEN Iterable<String> labelNames = asNames( inserter.getNodeLabels( node ) ); assertEquals( asSet( Labels.FIRST.name() ), Iterables.asSet( labelNames ) ); }
@Test public void shouldIndexConcurrentUpdatesWhilePopulating() throws Exception { // GIVEN Object value1 = "Mattias"; Object value2 = "Jacob"; Object value3 = "Stefan"; Object changedValue = "changed"; long node1 = createNode( map( name, value1 ), FIRST ); long node2 = createNode( map( name, value2 ), FIRST ); long node3 = createNode( map( name, value3 ), FIRST ); @SuppressWarnings( "UnnecessaryLocalVariable" ) long changeNode = node1; int propertyKeyId = getPropertyKeyForName( name ); NodeChangingWriter populator = new NodeChangingWriter( changeNode, propertyKeyId, value1, changedValue, labelId ); IndexPopulationJob job = newIndexPopulationJob( populator, new FlippableIndexProxy(), EntityType.NODE, indexDescriptor( FIRST, name, false ) ); populator.setJob( job ); // WHEN job.run(); // THEN Set<Pair<Long, Object>> expected = asSet( Pair.of( node1, value1 ), Pair.of( node2, value2 ), Pair.of( node3, value3 ), Pair.of( node1, changedValue ) ); assertEquals( expected, populator.added ); }
/** * Alias of {@link #pair(Object, Object)}. * @param first the first object in the pair. * @param other the other object in the pair. * @param <T1> the type of the first object in the pair * @param <T2> the type of the second object in the pair * @return a new pair of the two parameters. */ public static <T1, T2> Pair<T1, T2> of( final T1 first, final T2 other ) { return pair( first, other ); }
assertEquals( asList( of( 1, "Person" ), of( 2, "City" ) ), Iterators.asList( lookup.labels() ) ); assertEquals( asList( of( 1, "name" ), of( 2, "income" ) ), Iterators.asList( lookup.properties() ) ); assertEquals( asList( of( 1, "LIVES_IN" ), of( 2, "FRIEND" ) ), Iterators.asList( lookup.relationshipTypes() ) ); assertArrayEquals( new String[] { "Person" }, lookup.knownUniqueIndices().next().first() ); assertArrayEquals( new String[]{"name"}, lookup.knownUniqueIndices().next().other() ); Iterators.asList( Iterators.map( Pair::first, lookup.knownNodeKeyConstraints() ) ) ); assertArrayEquals( new String[]{"name"}, lookup.knownNodeKeyConstraints().next().other() ); Iterators.asList( Iterators.map( Pair::first, lookup.knownUniqueConstraints() ) ) ); assertArrayEquals( new String[]{"name"}, lookup.knownUniqueConstraints().next().other() ); assertEquals( new String[] { "City" }, lookup.knownIndices().next().first() ); assertArrayEquals( new String[]{"income"}, lookup.knownIndices().next().other() );
@Override public long nodeReference() { return current.first(); }
@Override public int numberOfProperties() { return current.other().length; }
@Override public Iterator<Pair<String,String[]>> knownRelationshipPropertyExistenceConstraints() { return Iterators.map( relConstraint -> { String label = labels.byIdOrFail( relConstraint.schema().getRelTypeId() ); String[] propertyKeyNames = propertyKeys .byIdOrFail( relConstraint.schema().getPropertyIds() ); return Pair.of( label, propertyKeyNames ); }, relPropertyExistenceConstraints.iterator() ); }
private Map<String,Object> toNeo4jValue( Map<?,?> attributeValue ) { // Build a new map with the same keys, but each value passed // through `toNeo4jValue` return attributeValue.entrySet().stream() .map( e -> pair( e.getKey().toString(), toNeo4jValue( e.getValue() ) ) ) .collect( CollectorsUtil.pairsToMap() ); }