use of org.neo4j.kernel.impl.nioneo.store.PropertyIndexRecord in project graphdb by neo4j-attic.
the class DumpLogicalLog method readPropertyIndexCommand.
static XaCommand readPropertyIndexCommand(ReadableByteChannel byteChannel, ByteBuffer buffer) throws IOException {
// id+in_use(byte)+count(int)+key_blockId(int)+nr_key_records(int)
buffer.clear();
buffer.limit(17);
if (byteChannel.read(buffer) != buffer.limit()) {
return null;
}
buffer.flip();
int id = buffer.getInt();
byte inUseFlag = buffer.get();
boolean inUse = false;
if ((inUseFlag & Record.IN_USE.byteValue()) == Record.IN_USE.byteValue()) {
inUse = true;
} else if (inUseFlag != Record.NOT_IN_USE.byteValue()) {
throw new IOException("Illegal in use flag: " + inUseFlag);
}
PropertyIndexRecord record = new PropertyIndexRecord(id);
record.setInUse(inUse);
record.setPropertyCount(buffer.getInt());
record.setKeyBlockId(buffer.getInt());
int nrKeyRecords = buffer.getInt();
for (int i = 0; i < nrKeyRecords; i++) {
DynamicRecord dr = readDynamicRecord(byteChannel, buffer);
if (dr == null) {
return null;
}
record.addKeyRecord(dr);
}
return new Command(record);
}
use of org.neo4j.kernel.impl.nioneo.store.PropertyIndexRecord in project graphdb by neo4j-attic.
the class WriteTransaction method getPropertyIndex.
String getPropertyIndex(int id) {
PropertyIndexStore indexStore = getPropertyStore().getIndexStore();
PropertyIndexRecord index = getPropertyIndexRecord(id);
if (index == null) {
index = indexStore.getRecord(id);
}
if (index.isLight()) {
indexStore.makeHeavy(index);
}
return indexStore.getStringFor(index);
}
use of org.neo4j.kernel.impl.nioneo.store.PropertyIndexRecord in project graphdb by neo4j-attic.
the class WriteTransaction method createPropertyIndex.
void createPropertyIndex(int id, String key) {
PropertyIndexRecord record = new PropertyIndexRecord(id);
record.setInUse(true);
record.setCreated();
PropertyIndexStore propIndexStore = getPropertyStore().getIndexStore();
int keyBlockId = propIndexStore.nextKeyBlockId();
record.setKeyBlockId(keyBlockId);
int length = key.length();
char[] chars = new char[length];
key.getChars(0, length, chars, 0);
Collection<DynamicRecord> keyRecords = propIndexStore.allocateKeyRecords(keyBlockId, chars);
for (DynamicRecord keyRecord : keyRecords) {
record.addKeyRecord(keyRecord);
}
addPropertyIndexRecord(record);
}
use of org.neo4j.kernel.impl.nioneo.store.PropertyIndexRecord in project neo4j-mobile-android by neo4j-contrib.
the class WriteTransaction method doPrepare.
@Override
protected void doPrepare() throws XAException {
if (committed) {
throw new XAException("Cannot prepare committed transaction[" + getIdentifier() + "]");
}
if (prepared) {
throw new XAException("Cannot prepare prepared transaction[" + getIdentifier() + "]");
}
// generate records then write to logical log via addCommand method
prepared = true;
for (RelationshipTypeRecord record : relTypeRecords.values()) {
Command.RelationshipTypeCommand command = new Command.RelationshipTypeCommand(neoStore.getRelationshipTypeStore(), record);
relTypeCommands.add(command);
addCommand(command);
}
for (NodeRecord record : nodeRecords.values()) {
if (!record.inUse() && record.getNextRel() != Record.NO_NEXT_RELATIONSHIP.intValue()) {
throw new InvalidRecordException("Node record " + record + " still has relationships");
}
Command.NodeCommand command = new Command.NodeCommand(neoStore.getNodeStore(), record);
nodeCommands.add(command);
if (!record.inUse()) {
removeNodeFromCache(record.getId());
}
addCommand(command);
}
for (RelationshipRecord record : relRecords.values()) {
Command.RelationshipCommand command = new Command.RelationshipCommand(neoStore.getRelationshipStore(), record);
relCommands.add(command);
if (!record.inUse()) {
removeRelationshipFromCache(record.getId());
}
addCommand(command);
}
for (PropertyIndexRecord record : propIndexRecords.values()) {
Command.PropertyIndexCommand command = new Command.PropertyIndexCommand(neoStore.getPropertyStore().getIndexStore(), record);
propIndexCommands.add(command);
addCommand(command);
}
for (PropertyRecord record : propertyRecords.values()) {
Command.PropertyCommand command = new Command.PropertyCommand(neoStore.getPropertyStore(), record);
propCommands.add(command);
addCommand(command);
}
}
use of org.neo4j.kernel.impl.nioneo.store.PropertyIndexRecord in project neo4j-mobile-android by neo4j-contrib.
the class BatchInserterImpl method createNewPropertyIndex.
private int createNewPropertyIndex(String stringKey) {
PropertyIndexStore idxStore = getPropertyIndexStore();
int keyId = (int) idxStore.nextId();
PropertyIndexRecord record = new PropertyIndexRecord(keyId);
record.setInUse(true);
record.setCreated();
int keyBlockId = idxStore.nextKeyBlockId();
record.setKeyBlockId(keyBlockId);
Collection<DynamicRecord> keyRecords = idxStore.allocateKeyRecords(keyBlockId, encodeString(stringKey));
for (DynamicRecord keyRecord : keyRecords) {
record.addKeyRecord(keyRecord);
}
idxStore.updateRecord(record);
indexHolder.addPropertyIndex(stringKey, keyId);
return keyId;
}
Aggregations