1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.directory.server.core.factory;
20
21
22 import java.io.File;
23 import java.util.Set;
24
25 import org.apache.directory.api.ldap.model.name.Dn;
26 import org.apache.directory.api.ldap.model.schema.SchemaManager;
27 import org.apache.directory.server.core.api.DnFactory;
28 import org.apache.directory.server.core.api.partition.Partition;
29 import org.apache.directory.server.core.partition.impl.avl.AvlPartition;
30 import org.apache.directory.server.xdbm.Index;
31 import org.apache.directory.server.xdbm.impl.avl.AvlIndex;
32
33
34
35
36
37
38
39 public class AvlPartitionFactory implements PartitionFactory
40 {
41
42
43
44
45 public AvlPartition createPartition( SchemaManager schemaManager, DnFactory dnFactory, String id, String suffix,
46 int cacheSize,
47 File workingDirectory )
48 throws Exception
49 {
50 AvlPartitione/partition/impl/avl/AvlPartition.html#AvlPartition">AvlPartition partition = new AvlPartition( schemaManager, dnFactory );
51 partition.setId( id );
52 partition.setSuffixDn( new Dn( suffix ) );
53 partition.setCacheSize( 500 );
54 partition.setPartitionPath( workingDirectory.toURI() );
55
56 return partition;
57 }
58
59
60
61
62
63 public void addIndex( Partition partition, String attributeId, int cacheSize ) throws Exception
64 {
65 if ( !( partition instanceof AvlPartition ) )
66 {
67 throw new IllegalArgumentException( "Partition must be a AvlPartition" );
68 }
69
70 AvlPartition./../org/apache/directory/server/core/partition/impl/avl/AvlPartition.html#AvlPartition">AvlPartition avlPartition = ( AvlPartition ) partition;
71 Set<Index<?, String>> indexedAttributes = avlPartition.getIndexedAttributes();
72
73 AvlIndex<Object> index = new AvlIndex<>( attributeId, false );
74
75 indexedAttributes.add( index );
76 avlPartition.setIndexedAttributes( indexedAttributes );
77 }
78
79 }