use of org.neo4j.kernel.impl.store.record.AbstractBaseRecord in project neo4j by neo4j.
the class RsdrMain method readStore.
private static void readStore(FileSystemAbstraction fileSystem, RecordStore store, long fromId, long toId, Pattern pattern) throws IOException {
toId = Math.min(toId, store.getHighId());
try (StoreChannel channel = fileSystem.open(store.getStorageFileName(), "r")) {
int recordSize = store.getRecordSize();
ByteBuffer buf = ByteBuffer.allocate(recordSize);
for (long i = fromId; i <= toId; i++) {
buf.clear();
long offset = recordSize * i;
int count = channel.read(buf, offset);
if (count == -1) {
break;
}
byte[] bytes = new byte[count];
buf.clear();
buf.get(bytes);
String hex = DatatypeConverter.printHexBinary(bytes);
int paddingNeeded = (recordSize * 2 - Math.max(count * 2, 0)) + 1;
String format = "%s %6s 0x%08X %s%" + paddingNeeded + "s%s%n";
String str;
String use;
try {
AbstractBaseRecord record = RecordStore.getRecord(store, i, CHECK);
use = record.inUse() ? "+" : "-";
str = record.toString();
} catch (InvalidRecordException e) {
str = new String(bytes, 0, count, "ASCII");
use = "?";
}
if (pattern == null || pattern.matcher(str).find()) {
console.printf(format, use, i, offset, hex, " ", str);
}
}
}
}
use of org.neo4j.kernel.impl.store.record.AbstractBaseRecord in project neo4j by neo4j.
the class DumpStoreTest method dumpStoreShouldPrintBufferWithContent.
@Test
public void dumpStoreShouldPrintBufferWithContent() throws Exception {
// Given
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
PrintStream out = new PrintStream(outStream);
DumpStore dumpStore = new DumpStore(out);
ByteBuffer buffer = ByteBuffer.allocate(1024);
for (byte i = 0; i < 10; i++) {
buffer.put(i);
}
buffer.flip();
AbstractBaseRecord record = Mockito.mock(AbstractBaseRecord.class);
// When
//when( record.inUse() ).thenReturn( true );
dumpStore.dumpHex(record, buffer, 2, 4);
// Then
Assert.assertEquals(String.format("@ 0x00000008: 00 01 02 03 04 05 06 07 08 09%n"), outStream.toString());
}
use of org.neo4j.kernel.impl.store.record.AbstractBaseRecord in project neo4j by neo4j.
the class DumpStoreTest method dumpStoreShouldPrintShorterMessageForAllZeroBuffer.
@Test
public void dumpStoreShouldPrintShorterMessageForAllZeroBuffer() throws Exception {
// Given
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
PrintStream out = new PrintStream(outStream);
DumpStore dumpStore = new DumpStore(out);
ByteBuffer buffer = ByteBuffer.allocate(1024);
AbstractBaseRecord record = Mockito.mock(AbstractBaseRecord.class);
// When
//when( record.inUse() ).thenReturn( true );
dumpStore.dumpHex(record, buffer, 2, 4);
// Then
Assert.assertEquals(String.format(": all zeros @ 0x8 - 0xc%n"), outStream.toString());
}
use of org.neo4j.kernel.impl.store.record.AbstractBaseRecord in project neo4j by neo4j.
the class IdGeneratorTest method makeSureIdCapacityCannotBeExceeded.
@Test
public void makeSureIdCapacityCannotBeExceeded() throws Exception {
RecordFormats formats = Standard.LATEST_RECORD_FORMATS;
List<RecordFormat<? extends AbstractBaseRecord>> recordFormats = Arrays.asList(formats.node(), formats.dynamic(), formats.labelToken(), formats.property(), formats.propertyKeyToken(), formats.relationship(), formats.relationshipGroup(), formats.relationshipTypeToken());
for (RecordFormat format : recordFormats) {
makeSureIdCapacityCannotBeExceeded(format);
}
}
use of org.neo4j.kernel.impl.store.record.AbstractBaseRecord in project neo4j by neo4j.
the class RecordStorageEngine method listStorageFiles.
@Override
public Collection<StoreFileMetadata> listStorageFiles() {
List<StoreFileMetadata> files = new ArrayList<>();
for (StoreType type : StoreType.values()) {
if (type.equals(StoreType.COUNTS)) {
addCountStoreFiles(files);
} else {
final RecordStore<AbstractBaseRecord> recordStore = neoStores.getRecordStore(type);
StoreFileMetadata metadata = new StoreFileMetadata(recordStore.getStorageFileName(), Optional.of(type), recordStore.getRecordSize());
files.add(metadata);
}
}
return files;
}
Aggregations