org.neo4j.driver.v1.Record.keys()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中org.neo4j.driver.v1.Record.keys方法的一些代码示例,展示了Record.keys的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Record.keys方法的具体详情如下:
包路径:org.neo4j.driver.v1.Record
类名称:Record
方法名:keys

Record.keys介绍

[英]Retrieve the keys of the underlying map
[中]检索基础映射的键

代码示例

代码示例来源:origin: net.iot-solutions.graphdb/jcypher

@Override
public List<String> getColumns() {
  List<String> columns = new ArrayList<String>();
  if (this.records.size() > 0) {
    Record rec = this.records.get(0);
    columns.addAll(rec.keys());
  }
  return columns;
}

代码示例来源:origin: Wolfgang-Schuetzelhofer/jcypher

@Override
public List<String> getColumns() {
  List<String> columns = new ArrayList<String>();
  if (this.records.size() > 0) {
    Record rec = this.records.get(0);
    columns.addAll(rec.keys());
  }
  return columns;
}

代码示例来源:origin: neo4j/cypher-shell

@Override
@Nonnull
public String format(@Nonnull final BoltResult result) {
  StringBuilder sb = new StringBuilder();
  List<Record> records = result.getRecords();
  if (!records.isEmpty()) {
    sb.append(records.get(0).keys().stream().collect(Collectors.joining(COMMA_SEPARATOR)));
    sb.append("\n");
    sb.append(records.stream().map(this::formatRecord).collect(Collectors.joining("\n")));
  }
  return sb.toString();
}

代码示例来源:origin: opencypher/cypher-for-gremlin

@Override
public List<String> keys() {
  return peek().keys();
}

代码示例来源:origin: org.neo4j.driver/neo4j-java-driver

public static <V> List<Pair<String, V>> fields( final Record map, final Function<Value, V> mapFunction )
{
  int size = map.keys().size();
  switch ( size )
  {
    case 0:
      return emptyList();
    case 1:
    {
      String key = map.keys().iterator().next();
      Value value = map.get( key );
      return singletonList( InternalPair.of( key, mapFunction.apply( value ) ) );
    }
    default:
    {
      List<Pair<String, V>> list = new ArrayList<>( size );
      List<String> keys = map.keys();
      for ( int i = 0; i < size; i++ )
      {
        String key = keys.get( i );
        Value value = map.get( i );
        list.add( InternalPair.of( key, mapFunction.apply( value ) ) );
      }
      return unmodifiableList( list );
    }
  }
}

代码示例来源:origin: org.neo4j.driver/neo4j-java-driver

public static <T> Map<String, T> map( Record record, Function<Value, T> mapFunction )
{
  int size = record.size();
  switch ( size )
  {
    case 0:
      return emptyMap();
    case 1:
      return singletonMap( record.keys().get( 0 ), mapFunction.apply( record.get( 0 ) ) );
    default:
      Map<String,T> map = Iterables.newLinkedHashMapWithSize( size );
      List<String> keys = record.keys();
      for ( int i = 0; i < size; i++ )
      {
        map.put( keys.get( i ), mapFunction.apply( record.get( i ) ) );
      }
      return unmodifiableMap( map );
  }
}

代码示例来源:origin: neo4j/cypher-shell

@Override
public List<String> keys() {
  return records.stream().map(r -> r.keys().get(0)).collect(Collectors.toList());
}

代码示例来源:origin: neo4j/cypher-shell

private void checkMapForPrettyPrint(Map<String, String> map, String expectedResult) {
  // given
  BoltResult result = mock(BoltResult.class);
  Record record = mock(Record.class);
  Value value = mock(Value.class);
  when(value.type()).thenReturn(InternalTypeSystem.TYPE_SYSTEM.MAP());
  when(value.asMap((Function<Value, String>) anyObject())).thenReturn(map);
  when(record.keys()).thenReturn(asList("map"));
  when(record.values()).thenReturn(asList(value));
  when(result.getRecords()).thenReturn(asList(record));
  when(result.getSummary()).thenReturn(mock(ResultSummary.class));
  // when
  String actual = plainPrinter.format(result);
  // then
  assertThat(actual, is(expectedResult));
}

代码示例来源:origin: neo4j/cypher-shell

@Test
public void prettyPrintList() throws Exception {
  // given
  BoltResult result = mock(BoltResult.class);
  Record record1 = mock(Record.class);
  Record record2 = mock(Record.class);
  Value value1 = mock(Value.class);
  Value value2 = mock(Value.class);
  when(value1.type()).thenReturn(InternalTypeSystem.TYPE_SYSTEM.LIST());
  when(value2.type()).thenReturn(InternalTypeSystem.TYPE_SYSTEM.LIST());
  when(value1.asList(Matchers.any(Function.class))).thenReturn(asList("val1_1", "val1_2"));
  when(value2.asList(Matchers.any(Function.class))).thenReturn(asList("val2_1"));
  when(record1.keys()).thenReturn(asList("col1", "col2"));
  when(record1.values()).thenReturn(asList(value1, value2));
  when(record2.values()).thenReturn(asList(value2));
  when(result.getRecords()).thenReturn(asList(record1, record2));
  when(result.getSummary()).thenReturn(mock(ResultSummary.class));
  // when
  String actual = plainPrinter.format(result);
  // then
  assertThat(actual, is("col1, col2\n[val1_1, val1_2], [val2_1]\n[val2_1]"));
}

代码示例来源:origin: neo4j/cypher-shell

@Test
public void prettyPrintRelationships() throws Exception {
  // given
  BoltResult result = mock(BoltResult.class);
  Record record = mock(Record.class);
  Value value = mock(Value.class);
  Relationship relationship = mock(Relationship.class);
  HashMap<String, Object> propertiesAsMap = new HashMap<>();
  propertiesAsMap.put("prop1", "prop1_value");
  propertiesAsMap.put("prop2", "prop2_value");
  when(value.type()).thenReturn(InternalTypeSystem.TYPE_SYSTEM.RELATIONSHIP());
  when(value.asRelationship()).thenReturn(relationship);
  when(relationship.type()).thenReturn("RELATIONSHIP_TYPE");
  when(relationship.asMap(anyObject())).thenReturn(unmodifiableMap(propertiesAsMap));
  when(record.keys()).thenReturn(asList("rel"));
  when(record.values()).thenReturn(asList(value));
  when(result.getRecords()).thenReturn(asList(record));
  when(result.getSummary()).thenReturn(mock(ResultSummary.class));
  // when
  String actual = plainPrinter.format(result);
  // then
  assertThat(actual, is("rel\n[:RELATIONSHIP_TYPE {prop2: prop2_value, prop1: prop1_value}]"));
}

代码示例来源:origin: org.neo4j.driver/neo4j-java-driver

if ( ! keys.equals( otherRecord.keys() ) )

代码示例来源:origin: neo4j/cypher-shell

@Test
public void prettyPrintNode() throws Exception {
  // given
  BoltResult result = mock(BoltResult.class);
  Record record = mock(Record.class);
  Value value = mock(Value.class);
  Node node = mock(Node.class);
  HashMap<String, Object> propertiesAsMap = new HashMap<>();
  propertiesAsMap.put("prop1", "prop1_value");
  propertiesAsMap.put("prop2", "prop2_value");
  when(value.type()).thenReturn(InternalTypeSystem.TYPE_SYSTEM.NODE());
  when(value.asNode()).thenReturn(node);
  when(node.labels()).thenReturn(asList("label1", "label2"));
  when(node.asMap(anyObject())).thenReturn(unmodifiableMap(propertiesAsMap));
  when(record.keys()).thenReturn(asList("col1", "col2"));
  when(record.values()).thenReturn(asList(value));
  when(result.getRecords()).thenReturn(asList(record));
  when(result.getSummary()).thenReturn(mock(ResultSummary.class));
  // when
  String actual = plainPrinter.format(result);
  // then
  assertThat(actual, is("col1, col2\n" +
      "(:label1:label2 {prop2: prop2_value, prop1: prop1_value})"));
}

代码示例来源:origin: neo4j/cypher-shell

when(path.iterator()).thenReturn(asList(segment1).iterator());
when(record.keys()).thenReturn(asList("path"));
when(record.values()).thenReturn(asList(value));

代码示例来源:origin: neo4j/cypher-shell

when(record.keys()).thenReturn(asList("rel", "node"));
when(record.values()).thenReturn(asList(relVal, nodeVal));

代码示例来源:origin: neo4j/cypher-shell

when(end.asMap(anyObject())).thenReturn(unmodifiableMap(endProperties));
when(record.keys()).thenReturn(asList("path"));
when(record.values()).thenReturn(asList(value));

代码示例来源:origin: neo4j/cypher-shell

when(path.iterator()).thenReturn(asList(segment1, segment2, segment3).iterator());
when(record.keys()).thenReturn(asList("path"));
when(record.values()).thenReturn(asList(value));

代码示例来源:origin: neo4j/cypher-shell

recordMap.put("node", nodeVal);
List<String> keys = asList("rel", "node");
when(record.keys()).thenReturn(keys);
when(record.get(eq("rel"))).thenReturn(relVal);
when(record.get(eq("node"))).thenReturn(nodeVal);

相关文章