public override int ApplyAsInt(Value[] values) { _stringRecordIds.reset(); _arrayRecordIds.reset(); int propertyRecordsUsed = 0; int freeBlocksInCurrentRecord = 0; foreach (Value value in values) { PropertyBlock block = new PropertyBlock(); PropertyStore.EncodeValue(block, 0, value, _stringRecordCounter, _arrayRecordCounter, true); if (block.ValueBlocks.Length > freeBlocksInCurrentRecord) { propertyRecordsUsed++; freeBlocksInCurrentRecord = PropertyType.PayloadSizeLongs; } freeBlocksInCurrentRecord -= block.ValueBlocks.Length; } int size = propertyRecordsUsed * _propertyRecordSize; size += toIntExact(_stringRecordIds.peek()) * _stringRecordSize; size += toIntExact(_arrayRecordIds.peek()) * _arrayRecordSize; return(size); }
private static void AddBlock(PropertyRecord record, int key, int value) { PropertyBlock block = new PropertyBlock(); PropertyStore.EncodeValue(block, key, Values.of(value), null, null, true); foreach (long valueBlock in block.ValueBlocks) { record.AddLoadedBlock(valueBlock); } }
public Loaders(RecordStore <NodeRecord> nodeStore, PropertyStore propertyStore, RecordStore <RelationshipRecord> relationshipStore, RecordStore <RelationshipGroupRecord> relationshipGroupStore, RecordStore <PropertyKeyTokenRecord> propertyKeyTokenStore, RecordStore <RelationshipTypeTokenRecord> relationshipTypeTokenStore, RecordStore <LabelTokenRecord> labelTokenStore, SchemaStore schemaStore) { _nodeLoader = _nodeLoader(nodeStore); _propertyLoader = _propertyLoader(propertyStore); _relationshipLoader = _relationshipLoader(relationshipStore); _relationshipGroupLoader = _relationshipGroupLoader(relationshipGroupStore); _schemaRuleLoader = _schemaRuleLoader(schemaStore); _propertyKeyTokenLoader = _propertyKeyTokenLoader(propertyKeyTokenStore); _labelTokenLoader = _labelTokenLoader(labelTokenStore); _relationshipTypeTokenLoader = _relationshipTypeTokenLoader(relationshipTypeTokenStore); }
public static Value GetRightArray(Pair <sbyte[], sbyte[]> data) { sbyte[] header = data.First(); sbyte[] bArray = data.Other(); sbyte typeId = header[0]; if (typeId == PropertyType.String.intValue()) { ByteBuffer headerBuffer = ByteBuffer.wrap(header, 1, header.Length - 1); int arrayLength = headerBuffer.Int; string[] result = new string[arrayLength]; ByteBuffer dataBuffer = ByteBuffer.wrap(bArray); for (int i = 0; i < arrayLength; i++) { int byteLength = dataBuffer.Int; sbyte[] stringByteArray = new sbyte[byteLength]; dataBuffer.get(stringByteArray); result[i] = PropertyStore.DecodeString(stringByteArray); } return(Values.stringArray(result)); } else if (typeId == PropertyType.Geometry.intValue()) { GeometryType.GeometryHeader geometryHeader = GeometryType.GeometryHeader.fromArrayHeaderBytes(header); return(GeometryType.decodeGeometryArray(geometryHeader, bArray)); } else if (typeId == PropertyType.Temporal.intValue()) { TemporalType.TemporalHeader temporalHeader = TemporalType.TemporalHeader.fromArrayHeaderBytes(header); return(TemporalType.decodeTemporalArray(temporalHeader, bArray)); } else { ShortArray type = ShortArray.typeOf(typeId); int bitsUsedInLastByte = header[1]; int requiredBits = header[2]; if (requiredBits == 0) { return(type.createEmptyArray()); } if (type == ShortArray.Byte && requiredBits == (sizeof(sbyte) * 8)) { // Optimization for byte arrays (probably large ones) return(Values.byteArray(bArray)); } else { // Fallback to the generic approach, which is a slower Bits bits = Bits.bitsFromBytes(bArray); int length = (bArray.Length * 8 - (8 - bitsUsedInLastByte)) / requiredBits; return(type.createArray(length, bits, requiredBits)); } } }
public DirectRecordAccessSet(RecordStore <NodeRecord> nodeStore, PropertyStore propertyStore, RecordStore <RelationshipRecord> relationshipStore, RecordStore <RelationshipGroupRecord> relationshipGroupStore, RecordStore <PropertyKeyTokenRecord> propertyKeyTokenStore, RecordStore <RelationshipTypeTokenRecord> relationshipTypeTokenStore, RecordStore <LabelTokenRecord> labelTokenStore, SchemaStore schemaStore) { Loaders loaders = new Loaders(nodeStore, propertyStore, relationshipStore, relationshipGroupStore, propertyKeyTokenStore, relationshipTypeTokenStore, labelTokenStore, schemaStore); _nodeRecords = new DirectRecordAccess <NodeRecord, Void>(nodeStore, loaders.NodeLoader()); _propertyRecords = new DirectRecordAccess <PropertyRecord, PrimitiveRecord>(propertyStore, loaders.PropertyLoader()); _relationshipRecords = new DirectRecordAccess <RelationshipRecord, Void>(relationshipStore, loaders.RelationshipLoader()); _relationshipGroupRecords = new DirectRecordAccess <RelationshipGroupRecord, int>(relationshipGroupStore, loaders.RelationshipGroupLoader()); _propertyKeyTokenRecords = new DirectRecordAccess <PropertyKeyTokenRecord, Void>(propertyKeyTokenStore, loaders.PropertyKeyTokenLoader()); _relationshipTypeTokenRecords = new DirectRecordAccess <RelationshipTypeTokenRecord, Void>(relationshipTypeTokenStore, loaders.RelationshipTypeTokenLoader()); _labelTokenRecords = new DirectRecordAccess <LabelTokenRecord, Void>(labelTokenStore, loaders.LabelTokenLoader()); _all = new DirectRecordAccess[] { _nodeRecords, _propertyRecords, _relationshipRecords, _relationshipGroupRecords, _propertyKeyTokenRecords, _relationshipTypeTokenRecords, _labelTokenRecords }; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldWriteOutTheDynamicChainBeforeUpdatingThePropertyRecord() public virtual void ShouldWriteOutTheDynamicChainBeforeUpdatingThePropertyRecord() { // given PageCache pageCache = PageCacheRule.getPageCache(_fileSystemAbstraction); Config config = Config.defaults(GraphDatabaseSettings.rebuild_idgenerators_fast, "true"); DynamicStringStore stringPropertyStore = mock(typeof(DynamicStringStore)); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final PropertyStore store = new PropertyStore(storeFile, idFile, config, new org.neo4j.kernel.impl.core.JumpingIdGeneratorFactory(1), pageCache, org.neo4j.logging.NullLogProvider.getInstance(), stringPropertyStore, mock(PropertyKeyTokenStore.class), mock(DynamicArrayStore.class), org.neo4j.kernel.impl.store.format.RecordFormatSelector.defaultFormat()); PropertyStore store = new PropertyStore(_storeFile, _idFile, config, new JumpingIdGeneratorFactory(1), pageCache, NullLogProvider.Instance, stringPropertyStore, mock(typeof(PropertyKeyTokenStore)), mock(typeof(DynamicArrayStore)), RecordFormatSelector.defaultFormat()); store.Initialise(true); try { store.MakeStoreOk(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long propertyRecordId = store.nextId(); long propertyRecordId = store.NextId(); PropertyRecord record = new PropertyRecord(propertyRecordId); record.InUse = true; DynamicRecord dynamicRecord = dynamicRecord(); PropertyBlock propertyBlock = PropertyBlockWith(dynamicRecord); record.PropertyBlock = propertyBlock; doAnswer(invocation => { PropertyRecord recordBeforeWrite = store.GetRecord(propertyRecordId, store.NewRecord(), FORCE); assertFalse(recordBeforeWrite.inUse()); return(null); }).when(stringPropertyStore).updateRecord(dynamicRecord); // when store.UpdateRecord(record); // then verify that our mocked method above, with the assert, was actually called verify(stringPropertyStore).updateRecord(dynamicRecord); } finally { store.Close(); } }
private static void AllocateFromString(ICollection <DynamicRecord> target, string[] array, DynamicRecordAllocator recordAllocator) { sbyte[][] stringsAsBytes = new sbyte[array.Length][]; int totalBytesRequired = STRING_HEADER_SIZE; // 1b type + 4b array length for (int i = 0; i < array.Length; i++) { string @string = array[i]; sbyte[] bytes = PropertyStore.EncodeString(@string); stringsAsBytes[i] = bytes; totalBytesRequired += 4 + bytes.Length; } ByteBuffer buf = ByteBuffer.allocate(totalBytesRequired); buf.put(PropertyType.String.byteValue()); buf.putInt(array.Length); foreach (sbyte[] stringAsBytes in stringsAsBytes) { buf.putInt(stringAsBytes.Length); buf.put(stringAsBytes); } AllocateRecordsFromBytes(target, buf.array(), recordAllocator); }
public PropertyValueRecordSizeCalculator(PropertyStore propertyStore) : this(propertyStore.RecordSize, propertyStore.StringStore.RecordSize, propertyStore.StringStore.RecordDataSize, propertyStore.ArrayStore.RecordSize, propertyStore.ArrayStore.RecordDataSize) { }
public RecordAccess_LoaderAnonymousInnerClass2(PropertyStore store) { this._store = store; }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: //ORIGINAL LINE: public static org.neo4j.kernel.impl.transaction.state.RecordAccess_Loader<org.neo4j.kernel.impl.store.record.PropertyRecord,org.neo4j.kernel.impl.store.record.PrimitiveRecord> propertyLoader(final org.neo4j.kernel.impl.store.PropertyStore store) public static RecordAccess_Loader <PropertyRecord, PrimitiveRecord> PropertyLoader(PropertyStore store) { return(new RecordAccess_LoaderAnonymousInnerClass2(store)); }
public abstract Org.Neo4j.Values.Storable.Value value(Org.Neo4j.Kernel.impl.store.record.PropertyBlock block, PropertyStore store);
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setupStore() public virtual void SetupStore() { _neoStores = (new StoreFactory(Storage.directory().databaseLayout(), Config.defaults(), new DefaultIdGeneratorFactory(Storage.fileSystem()), Storage.pageCache(), Storage.fileSystem(), NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY)).openNeoStores(true, StoreType.Property, StoreType.PropertyArray, StoreType.PropertyString); _propertyStore = _neoStores.PropertyStore; }