use of org.neo4j.kernel.impl.nioneo.store.PropertyIndexRecord in project neo4j-mobile-android by neo4j-contrib.
the class LegacyPropertyIndexStoreReader method readPropertyIndexStore.
public Iterable<PropertyIndexRecord> readPropertyIndexStore() throws IOException {
FileChannel fileChannel = new RandomAccessFile(fileName, "r").getChannel();
int recordLength = 9;
int endHeaderSize = UTF8.encode(FROM_VERSION).length;
long recordCount = (fileChannel.size() - endHeaderSize) / recordLength;
LinkedList<PropertyIndexRecord> records = new LinkedList<PropertyIndexRecord>();
ByteBuffer buffer = ByteBuffer.allocateDirect(recordLength);
for (int id = 0; id <= recordCount; id++) {
buffer.position(0);
fileChannel.read(buffer);
buffer.flip();
long inUseByte = buffer.get();
boolean inUse = inUseByte == Record.IN_USE.byteValue();
if (inUse) {
PropertyIndexRecord record = new PropertyIndexRecord(id);
record.setInUse(inUse);
record.setPropertyCount(buffer.getInt());
record.setKeyBlockId(buffer.getInt());
records.add(record);
}
}
fileChannel.close();
return records;
}
use of org.neo4j.kernel.impl.nioneo.store.PropertyIndexRecord in project neo4j-mobile-android by neo4j-contrib.
the class WriteTransaction method createPropertyIndex.
@Override
public void createPropertyIndex(String key, int id) {
PropertyIndexRecord record = new PropertyIndexRecord(id);
record.setInUse(true);
record.setCreated();
PropertyIndexStore propIndexStore = getPropertyStore().getIndexStore();
int keyBlockId = propIndexStore.nextKeyBlockId();
record.setKeyBlockId(keyBlockId);
Collection<DynamicRecord> keyRecords = propIndexStore.allocateKeyRecords(keyBlockId, encodeString(key));
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 loadIndex.
@Override
public String loadIndex(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 neo4j-mobile-android by neo4j-contrib.
the class WriteTransaction method doRollback.
@Override
public void doRollback() throws XAException {
if (committed) {
throw new XAException("Cannot rollback partialy commited " + "transaction[" + getIdentifier() + "]. Recover and " + "commit");
}
try {
for (RelationshipTypeRecord record : relTypeRecords.values()) {
if (record.isCreated()) {
getRelationshipTypeStore().freeId(record.getId());
for (DynamicRecord dynamicRecord : record.getTypeRecords()) {
if (dynamicRecord.isCreated()) {
getRelationshipTypeStore().freeBlockId((int) dynamicRecord.getId());
}
}
}
removeRelationshipTypeFromCache(record.getId());
}
for (NodeRecord record : nodeRecords.values()) {
if (record.isCreated()) {
getNodeStore().freeId(record.getId());
}
removeNodeFromCache(record.getId());
}
for (RelationshipRecord record : relRecords.values()) {
if (record.isCreated()) {
getRelationshipStore().freeId(record.getId());
}
removeRelationshipFromCache(record.getId());
}
for (PropertyIndexRecord record : propIndexRecords.values()) {
if (record.isCreated()) {
getPropertyStore().getIndexStore().freeId(record.getId());
for (DynamicRecord dynamicRecord : record.getKeyRecords()) {
if (dynamicRecord.isCreated()) {
getPropertyStore().getIndexStore().freeBlockId((int) dynamicRecord.getId());
}
}
}
}
for (PropertyRecord record : propertyRecords.values()) {
if (record.getNodeId() != -1) {
removeNodeFromCache(record.getNodeId());
} else if (record.getRelId() != -1) {
removeRelationshipFromCache(record.getRelId());
}
if (record.isCreated()) {
getPropertyStore().freeId(record.getId());
for (PropertyBlock block : record.getPropertyBlocks()) {
for (DynamicRecord dynamicRecord : block.getValueRecords()) {
if (dynamicRecord.isCreated()) {
if (dynamicRecord.getType() == PropertyType.STRING.intValue()) {
getPropertyStore().freeStringBlockId(dynamicRecord.getId());
} else if (dynamicRecord.getType() == PropertyType.ARRAY.intValue()) {
getPropertyStore().freeArrayBlockId(dynamicRecord.getId());
} else {
throw new InvalidRecordException("Unknown type on " + dynamicRecord);
}
}
}
}
}
}
} finally {
nodeRecords.clear();
propertyRecords.clear();
relRecords.clear();
relTypeRecords.clear();
propIndexRecords.clear();
nodeCommands.clear();
propCommands.clear();
propIndexCommands.clear();
relCommands.clear();
relTypeCommands.clear();
}
}
use of org.neo4j.kernel.impl.nioneo.store.PropertyIndexRecord in project neo4j-mobile-android by neo4j-contrib.
the class ReadTransaction method loadIndex.
@Override
public String loadIndex(int id) {
PropertyIndexStore indexStore = getPropertyStore().getIndexStore();
PropertyIndexRecord index = indexStore.getRecord(id);
if (index.isLight()) {
indexStore.makeHeavy(index);
}
return indexStore.getStringFor(index);
}
Aggregations