public static TimeValue Truncate(TemporalUnit unit, TemporalValue input, MapValue fields, System.Func <ZoneId> defaultZone) { OffsetTime time = input.getTimePart(defaultZone); OffsetTime truncatedOT = AssertValidUnit(() => time.truncatedTo(unit)); if (fields.Size() == 0) { return(time(truncatedOT)); } else { // Timezone needs some special handling, since the builder will shift keeping the instant instead of the local time AnyValue timezone = fields.Get("timezone"); if (timezone != NO_VALUE) { ZonedDateTime currentDT = AssertValidArgument(() => ZonedDateTime.ofInstant(Instant.now(), TimezoneOf(timezone))); ZoneOffset currentOffset = currentDT.Offset; truncatedOT = truncatedOT.withOffsetSameLocal(currentOffset); } return(UpdateFieldMapWithConflictingSubseconds(fields, unit, truncatedOT, (mapValue, offsetTime) => { if (mapValue.size() == 0) { return time(offsetTime); } else { return Build(mapValue.updatedWith("time", time(offsetTime)), defaultZone); } })); } }
internal static void AssertKeyIsMap(ResourceIterator <IDictionary <string, object> > r, string keyKey, string valueKey, MapValue expected) { IList <IDictionary <string, object> > result = r.ToList(); assertEquals("Results for should have size " + expected.Size() + " but was " + result.Count, expected.Size(), result.Count); foreach (IDictionary <string, object> row in result) { TextValue key = ( TextValue )row[keyKey]; assertTrue(expected.ContainsKey(key.StringValue())); assertThat(row, hasKey(valueKey)); object objectValue = row[valueKey]; if (objectValue is ListValue) { ListValue value = ( ListValue )objectValue; ListValue expectedValues = ( ListValue )expected.Get(key.StringValue()); assertEquals("sizes", value.Size(), expectedValues.Size()); assertThat(Arrays.asList(value.AsArray()), containsInAnyOrder(expectedValues.AsArray())); } else { string value = (( TextValue )objectValue).stringValue(); string expectedValue = (( TextValue )expected.Get(key.StringValue())).stringValue(); assertThat(value, equalTo(expectedValue)); } } }
public static LocalDateTimeValue Truncate(TemporalUnit unit, TemporalValue input, MapValue fields, System.Func <ZoneId> defaultZone) { Pair <LocalDate, LocalTime> pair = GetTruncatedDateAndTime(unit, input, "local date time"); LocalDate truncatedDate = pair.First(); LocalTime truncatedTime = pair.Other(); DateTime truncatedLDT = new DateTime(truncatedDate, truncatedTime); if (fields.Size() == 0) { return(LocalDateTime(truncatedLDT)); } else { return(UpdateFieldMapWithConflictingSubseconds(fields, unit, truncatedLDT, (mapValue, localDateTime) => { if (mapValue.size() == 0) { return LocalDateTime(LocalDateTime); } else { return Build(mapValue.updatedWith("datetime", LocalDateTime(LocalDateTime)), defaultZone); } })); } }
public override void WriteRelationship(long relId, long startNodeId, long endNodeId, TextValue type, MapValue properties) { Append(format("-[id=%d :%s", relId, type.StringValue())); if (properties.Size() > 0) { Append(" "); properties.WriteTo(this); } Append("]-"); }
private static IDictionary <string, object> ToRawMap(MapValue mapValue) { Deserializer deserializer = new Deserializer(); Dictionary <string, object> map = new Dictionary <string, object>(mapValue.Size()); mapValue.Foreach((key, value) => { value.writeTo(deserializer); map[key] = deserializer.Value(); }); return(map); }
public static DateValue Truncate(TemporalUnit unit, TemporalValue input, MapValue fields, System.Func <ZoneId> defaultZone) { LocalDate localDate = input.DatePart; DateValue truncated = Date(TruncateTo(localDate, unit)); if (fields.Size() == 0) { return(truncated); } else { MapValue updatedFields = fields.UpdatedWith("date", truncated); return(Build(updatedFields, defaultZone)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void profileStatisticConversion() public virtual void ProfileStatisticConversion() { MapValue convertedMap = ExecutionPlanConverter.Convert(new TestExecutionPlanDescription(this, "description", ProfilerStatistics, Identifiers, Arguments)); assertEquals(convertedMap.Get("operatorType"), stringValue("description")); assertEquals(convertedMap.Get("args"), ValueUtils.asMapValue(Arguments)); assertEquals(convertedMap.Get("identifiers"), ValueUtils.asListValue(Identifiers)); assertEquals(convertedMap.Get("children"), VirtualValues.EMPTY_LIST); assertEquals(convertedMap.Get("rows"), longValue(1L)); assertEquals(convertedMap.Get("dbHits"), longValue(2L)); assertEquals(convertedMap.Get("pageCacheHits"), longValue(3L)); assertEquals(convertedMap.Get("pageCacheMisses"), longValue(2L)); assertEquals((( DoubleValue )convertedMap.Get("pageCacheHitRatio")).doubleValue(), 3.0 / 5, 0.0001); assertEquals(convertedMap.Size(), 9); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldHandleMaps() internal virtual void ShouldHandleMaps() { // Given IDictionary <string, object> map = MapUtil.map("a", Arrays.asList("foo", 42)); // When AnyValue anyValue = ValueUtils.of(map); // Then assertThat(anyValue, instanceOf(typeof(MapValue))); MapValue mapValue = ( MapValue )anyValue; assertThat(mapValue.Get("a"), equalTo(VirtualValues.list(stringValue("foo"), intValue(42)))); assertThat(mapValue.Size(), equalTo(1)); }
public override void WriteNode(long nodeId, TextArray labels, MapValue properties) { Append(format("(id=%d", nodeId)); string sep = " "; for (int i = 0; i < labels.Length(); i++) { Append(sep); Append(":" + labels.StringValue(i)); sep = ""; } if (properties.Size() > 0) { Append(" "); properties.WriteTo(this); } Append(")"); }
private static void AssertMapEqualsWithDelta(MapValue a, MapValue b, double delta) { assertThat("Map should have same size", a.Size(), equalTo(b.Size())); a.Foreach((key, value) => { AnyValue aValue = value; AnyValue bValue = b.Get(key); if (aValue is MapValue) { assertThat("Value mismatch", bValue is MapValue); AssertMapEqualsWithDelta(( MapValue )aValue, ( MapValue )bValue, delta); } else if (aValue is DoubleValue) { assertThat("Value mismatch", (( DoubleValue )aValue).doubleValue(), closeTo(((DoubleValue)bValue).doubleValue(), delta)); } else { assertThat("Value mismatch", aValue, equalTo(bValue)); } }); }
public static DateTimeValue Truncate(TemporalUnit unit, TemporalValue input, MapValue fields, System.Func <ZoneId> defaultZone) { Pair <LocalDate, LocalTime> pair = GetTruncatedDateAndTime(unit, input, "date time"); LocalDate truncatedDate = pair.First(); LocalTime truncatedTime = pair.Other(); ZoneId zoneId = input.supportsTimeZone() ? input.getZoneId(defaultZone) : defaultZone(); ZonedDateTime truncatedZDT = ZonedDateTime.of(truncatedDate, truncatedTime, zoneId); if (fields.Size() == 0) { return(Datetime(truncatedZDT)); } else { // Timezone needs some special handling, since the builder will shift keeping the instant instead of the local time AnyValue timezone = fields.Get("timezone"); if (timezone != NO_VALUE) { truncatedZDT = truncatedZDT.withZoneSameLocal(TimezoneOf(timezone)); } return(UpdateFieldMapWithConflictingSubseconds(fields, unit, truncatedZDT, (mapValue, zonedDateTime) => { if (mapValue.size() == 0) { return Datetime(zonedDateTime); } else { return Build(mapValue.updatedWith("datetime", Datetime(zonedDateTime)), defaultZone); } })); } }
public static LocalTimeValue Truncate(TemporalUnit unit, TemporalValue input, MapValue fields, System.Func <ZoneId> defaultZone) { LocalTime localTime = input.LocalTimePart; LocalTime truncatedLT = AssertValidUnit(() => localTime.truncatedTo(unit)); if (fields.Size() == 0) { return(localTime(truncatedLT)); } else { return(UpdateFieldMapWithConflictingSubseconds(fields, unit, truncatedLT, (mapValue, localTime1) => { if (mapValue.size() == 0) { return localTime(localTime1); } else { return Build(mapValue.updatedWith("time", localTime(localTime1)), defaultZone); } })); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: static java.util.Map<String,Object> parseTransactionMetadata(org.neo4j.values.virtual.MapValue meta) throws org.neo4j.bolt.messaging.BoltIOException internal static IDictionary <string, object> ParseTransactionMetadata(MapValue meta) { AnyValue anyValue = meta.Get(TX_META_DATA_KEY); if (anyValue == Values.NO_VALUE) { return(null); } else if (anyValue is MapValue) { MapValue mapValue = ( MapValue )anyValue; TransactionMetadataWriter writer = new TransactionMetadataWriter(); IDictionary <string, object> txMeta = new Dictionary <string, object>(mapValue.Size()); mapValue.Foreach((key, value) => txMeta.put(key, writer.ValueAsObject(value))); return(txMeta); } else { throw new BoltIOException(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.Invalid, "Expecting transaction metadata value to be a Map value, but got: " + anyValue); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static java.util.Map<String,Object> readMetaDataMap(org.neo4j.bolt.messaging.Neo4jPack_Unpacker unpacker) throws java.io.IOException public static IDictionary <string, object> ReadMetaDataMap(Org.Neo4j.Bolt.messaging.Neo4jPack_Unpacker unpacker) { MapValue metaDataMapValue = unpacker.UnpackMap(); PrimitiveOnlyValueWriter writer = new PrimitiveOnlyValueWriter(); IDictionary <string, object> metaDataMap = new Dictionary <string, object>(metaDataMapValue.Size()); metaDataMapValue.Foreach((key, value) => { object convertedValue = AuthToken.containsSensitiveInformation(key) ? writer.SensitiveValueAsObject(value) : writer.ValueAsObject(value); metaDataMap[key] = convertedValue; }); return(metaDataMap); }