Search in sources :

Example 6 with IdGeneratorFactory

use of org.neo4j.kernel.IdGeneratorFactory in project graphdb by neo4j-attic.

the class NodeStore method createStore.

/**
     * Creates a new node store contained in <CODE>fileName</CODE> If filename
     * is <CODE>null</CODE> or the file already exists an 
     * <CODE>IOException</CODE> is thrown.
     * 
     * @param fileName
     *            File name of the new node store
     * @throws IOException
     *             If unable to create node store or name null
     */
public static void createStore(String fileName, Map<?, ?> config) {
    IdGeneratorFactory idGeneratorFactory = (IdGeneratorFactory) config.get(IdGeneratorFactory.class);
    createEmptyStore(fileName, VERSION, idGeneratorFactory);
    NodeStore store = new NodeStore(fileName, config);
    NodeRecord nodeRecord = new NodeRecord(store.nextId());
    nodeRecord.setInUse(true);
    store.updateRecord(nodeRecord);
    store.close();
}
Also used : IdGeneratorFactory(org.neo4j.kernel.IdGeneratorFactory)

Example 7 with IdGeneratorFactory

use of org.neo4j.kernel.IdGeneratorFactory in project graphdb by neo4j-attic.

the class PropertyStore method createStore.

/**
     * Creates a new property store contained in <CODE>fileName</CODE> If
     * filename is <CODE>null</CODE> or the file already exists an 
     * <CODE>IOException</CODE> is thrown.
     * 
     * @param fileName
     *            File name of the new property store
     * @throws IOException
     *             If unable to create property store or name null
     */
public static void createStore(String fileName, Map<?, ?> config) {
    IdGeneratorFactory idGeneratorFactory = (IdGeneratorFactory) config.get(IdGeneratorFactory.class);
    createEmptyStore(fileName, VERSION, idGeneratorFactory);
    int stringStoreBlockSize = DEFAULT_DATA_BLOCK_SIZE;
    int arrayStoreBlockSize = DEFAULT_DATA_BLOCK_SIZE;
    try {
        String stringBlockSize = (String) config.get(STRING_BLOCK_SIZE);
        String arrayBlockSize = (String) config.get(ARRAY_BLOCK_SIZE);
        if (stringBlockSize != null) {
            int value = Integer.parseInt(stringBlockSize);
            if (value > 0) {
                stringStoreBlockSize = value;
            }
        }
        if (arrayBlockSize != null) {
            int value = Integer.parseInt(arrayBlockSize);
            if (value > 0) {
                arrayStoreBlockSize = value;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    DynamicStringStore.createStore(fileName + ".strings", stringStoreBlockSize, idGeneratorFactory, IdType.STRING_BLOCK);
    PropertyIndexStore.createStore(fileName + ".index", idGeneratorFactory);
    DynamicArrayStore.createStore(fileName + ".arrays", arrayStoreBlockSize, idGeneratorFactory);
}
Also used : IdGeneratorFactory(org.neo4j.kernel.IdGeneratorFactory) IOException(java.io.IOException)

Example 8 with IdGeneratorFactory

use of org.neo4j.kernel.IdGeneratorFactory in project neo4j-mobile-android by neo4j-contrib.

the class NeoStore method createStore.

/**
     * Creates the neo,node,relationship,property and relationship type stores.
     *
     * @param fileName
     *            The name of store
     * @param config
     *            Map of configuration parameters
     */
public static void createStore(String fileName, Map<?, ?> config) {
    IdGeneratorFactory idGeneratorFactory = (IdGeneratorFactory) config.get(IdGeneratorFactory.class);
    StoreId storeId = (StoreId) config.get(StoreId.class);
    if (storeId == null)
        storeId = new StoreId();
    createEmptyStore(fileName, buildTypeDescriptorAndVersion(TYPE_DESCRIPTOR), idGeneratorFactory);
    NodeStore.createStore(fileName + ".nodestore.db", config);
    RelationshipStore.createStore(fileName + ".relationshipstore.db", idGeneratorFactory);
    PropertyStore.createStore(fileName + ".propertystore.db", config);
    RelationshipTypeStore.createStore(fileName + ".relationshiptypestore.db", config);
    if (!config.containsKey("neo_store")) {
        // TODO Ugly
        Map<Object, Object> newConfig = new HashMap<Object, Object>(config);
        newConfig.put("neo_store", fileName);
        config = newConfig;
    }
    NeoStore neoStore = new NeoStore(config);
    // created time | random long | backup version | tx id
    neoStore.nextId();
    neoStore.nextId();
    neoStore.nextId();
    neoStore.nextId();
    neoStore.setCreationTime(storeId.getCreationTime());
    neoStore.setRandomNumber(storeId.getRandomId());
    neoStore.setVersion(0);
    neoStore.setLastCommittedTx(1);
    neoStore.close();
}
Also used : HashMap(java.util.HashMap) IdGeneratorFactory(org.neo4j.kernel.IdGeneratorFactory)

Example 9 with IdGeneratorFactory

use of org.neo4j.kernel.IdGeneratorFactory in project neo4j-mobile-android by neo4j-contrib.

the class PropertyStore method createStore.

/**
     * Creates a new property store contained in <CODE>fileName</CODE> If
     * filename is <CODE>null</CODE> or the file already exists an
     * <CODE>IOException</CODE> is thrown.
     *
     * @param fileName
     *            File name of the new property store
     * @throws IOException
     *             If unable to create property store or name null
     */
public static void createStore(String fileName, Map<?, ?> config) {
    IdGeneratorFactory idGeneratorFactory = (IdGeneratorFactory) config.get(IdGeneratorFactory.class);
    createEmptyStore(fileName, buildTypeDescriptorAndVersion(TYPE_DESCRIPTOR), idGeneratorFactory);
    int stringStoreBlockSize = DEFAULT_DATA_BLOCK_SIZE;
    int arrayStoreBlockSize = DEFAULT_DATA_BLOCK_SIZE;
    try {
        String stringBlockSize = (String) config.get(STRING_BLOCK_SIZE);
        String arrayBlockSize = (String) config.get(ARRAY_BLOCK_SIZE);
        if (stringBlockSize != null) {
            int value = Integer.parseInt(stringBlockSize);
            if (value > 0) {
                stringStoreBlockSize = value;
            }
        }
        if (arrayBlockSize != null) {
            int value = Integer.parseInt(arrayBlockSize);
            if (value > 0) {
                arrayStoreBlockSize = value;
            }
        }
    } catch (Exception e) {
        logger.log(Level.WARNING, "Exception creating store", e);
    }
    DynamicStringStore.createStore(fileName + ".strings", stringStoreBlockSize, idGeneratorFactory, IdType.STRING_BLOCK);
    PropertyIndexStore.createStore(fileName + ".index", idGeneratorFactory);
    DynamicArrayStore.createStore(fileName + ".arrays", arrayStoreBlockSize, idGeneratorFactory);
}
Also used : IdGeneratorFactory(org.neo4j.kernel.IdGeneratorFactory) IOException(java.io.IOException)

Aggregations

IdGeneratorFactory (org.neo4j.kernel.IdGeneratorFactory)9 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Test (org.junit.Test)1 IdGenerator (org.neo4j.kernel.impl.nioneo.store.IdGenerator)1