当前位置: 首页>>代码示例>>Java>>正文


Java Element类代码示例

本文整理汇总了Java中com.tinkerpop.blueprints.Element的典型用法代码示例。如果您正苦于以下问题:Java Element类的具体用法?Java Element怎么用?Java Element使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Element类属于com.tinkerpop.blueprints包,在下文中一共展示了Element类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolve

import com.tinkerpop.blueprints.Element; //导入依赖的package包/类
@Override
public <T> Class<? extends T> resolve(final Element element, final Class<T> kind) {
	final String nodeClazz = element.getProperty(this.typeResolutionKey);
	if (nodeClazz == null) {
		return kind;
	}

	final Class<T> nodeKind = (Class<T>) this.reflectionCache.forName(nodeClazz);

	if (kind.isAssignableFrom(nodeKind) || kind.equals(VertexFrame.class) || kind.equals(EdgeFrame.class)
			|| kind.equals(AbstractVertexFrame.class) || kind.equals(AbstractEdgeFrame.class) || kind.equals(Object.class)) {
		return nodeKind;
	} else {
		return kind;
	}
}
 
开发者ID:gentics,项目名称:mesh,代码行数:17,代码来源:MeshTypeResolver.java

示例2: verifyElementOrder

import com.tinkerpop.blueprints.Element; //导入依赖的package包/类
public static void verifyElementOrder(Iterator<? extends Element> elements, String key, Order order, int expectedCount) {
    Comparable previous = null;
    int count = 0;
    while (elements.hasNext()) {
        Element element = elements.next();
        Comparable current = (Comparable)element.getProperty(key);
        if (previous != null) {
            int cmp = previous.compareTo(current);
            assertTrue(previous + " <> " + current + " @ " + count,
                    order == Order.ASC ? cmp <= 0 : cmp >= 0);
        }
        previous = current;
        count++;
    }
    assertEquals(expectedCount, count);
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:17,代码来源:TestUtil.java

示例3: setup

import com.tinkerpop.blueprints.Element; //导入依赖的package包/类
@Override
public void setup(final Mapper.Context context) throws IOException, InterruptedException {
    Configuration hc = DEFAULT_COMPAT.getContextConfiguration(context);
    ModifiableHadoopConfiguration titanConf = ModifiableHadoopConfiguration.of(hc);
    try {
        this.mapSpillOver = titanConf.get(PIPELINE_MAP_SPILL_OVER);
        final String keyClosureString = hc.get(KEY_CLOSURE, null);
        if (null == keyClosureString)
            this.keyClosure = null;
        else
            this.keyClosure = (Closure) engine.eval(keyClosureString);

        final String valueClosureString = hc.get(VALUE_CLOSURE, null);
        if (null == valueClosureString)
            this.valueClosure = null;
        else
            this.valueClosure = (Closure) engine.eval(valueClosureString);

    } catch (final ScriptException e) {
        throw new IOException(e.getMessage(), e);
    }
    this.isVertex = hc.getClass(CLASS, Element.class, Element.class).equals(Vertex.class);
    this.map = new CounterMap<Object>();
    this.outputs = new SafeMapperOutputs(context);
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:26,代码来源:GroupCountMapReduce.java

示例4: createConfiguration

import com.tinkerpop.blueprints.Element; //导入依赖的package包/类
public static Configuration createConfiguration(final Class<? extends Element> klass, final String key, final Compare compare, final Object... values) {
    final String[] valueStrings = new String[values.length];
    Class valueClass = null;
    for (int i = 0; i < values.length; i++) {
        valueStrings[i] = (null == values[i]) ? valueStrings[i] = null : values[i].toString();
        if (null != values[i])
            valueClass = values[i].getClass();
    }
    if (null == valueClass)
        valueClass = Object.class;


    final Configuration configuration = new EmptyConfiguration();
    configuration.setClass(CLASS, klass, Element.class);
    configuration.set(KEY, key);
    configuration.set(COMPARE, compare.name());
    configuration.setStrings(VALUES, valueStrings);
    configuration.setClass(VALUE_CLASS, valueClass, valueClass);
    return configuration;
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:21,代码来源:PropertyFilterMap.java

示例5: createConfiguration

import com.tinkerpop.blueprints.Element; //导入依赖的package包/类
public static Configuration createConfiguration(final Class<? extends Element> klass, final String key, final Object startValue, final Object endValue) {
    final Configuration configuration = new EmptyConfiguration();
    configuration.setClass(CLASS, klass, Element.class);
    configuration.set(KEY, key);
    if (startValue instanceof String) {
        configuration.set(VALUE_CLASS, String.class.getName());
        configuration.set(START_VALUE, (String) startValue);
        configuration.set(END_VALUE, (String) endValue);
    } else if (startValue instanceof Number) {
        configuration.set(VALUE_CLASS, Float.class.getName());
        configuration.setFloat(START_VALUE, ((Number) startValue).floatValue());
        configuration.setFloat(END_VALUE, ((Number) endValue).floatValue());
    } else if (startValue instanceof Boolean) {
        configuration.set(VALUE_CLASS, Boolean.class.getName());
        configuration.setBoolean(START_VALUE, (Boolean) startValue);
        configuration.setBoolean(END_VALUE, (Boolean) endValue);
    } else {
        throw new RuntimeException("Unknown value class: " + startValue.getClass().getName());
    }
    return configuration;
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:22,代码来源:IntervalFilterMap.java

示例6: setup

import com.tinkerpop.blueprints.Element; //导入依赖的package包/类
@Override
public void setup(final Mapper.Context context) throws IOException, InterruptedException {
    Configuration cfg = DEFAULT_COMPAT.getContextConfiguration(context);
    this.isVertex = cfg.getClass(CLASS, Element.class, Element.class).equals(Vertex.class);
    final String key = cfg.get(KEY);
    final Class valueClass = cfg.getClass(VALUE_CLASS, String.class);
    final Object startValue;
    final Object endValue;
    if (valueClass.equals(String.class)) {
        startValue = cfg.get(START_VALUE);
        endValue = cfg.get(END_VALUE);
    } else if (Number.class.isAssignableFrom((valueClass))) {
        startValue = cfg.getFloat(START_VALUE, Float.MIN_VALUE);
        endValue = cfg.getFloat(END_VALUE, Float.MAX_VALUE);
    } else {
        throw new IOException("Class " + valueClass + " is an unsupported value class");
    }

    this.startChecker = new ElementChecker(key, Compare.GREATER_THAN_EQUAL, startValue);
    this.endChecker = new ElementChecker(key, Compare.LESS_THAN, endValue);
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:22,代码来源:IntervalFilterMap.java

示例7: testMultiVertexCount

import com.tinkerpop.blueprints.Element; //导入依赖的package包/类
public void testMultiVertexCount() throws Exception {
    Configuration config = new Configuration();
    config.setClass(CountMapReduce.CLASS, Vertex.class, Element.class);
    mapReduceDriver.withConfiguration(config);

    Map<Long, FaunusVertex> graph = generateGraph(BaseTest.ExampleGraph.TINKERGRAPH, config);

    assertEquals(graph.size(), 6);
    assertEquals(graph.get(1l).incrPath(10), 10);
    assertEquals(graph.get(2l).incrPath(5), 5);
    assertEquals(graph.get(3l).incrPath(1), 1);
    assertEquals(graph.get(4l).incrPath(7), 7);
    assertEquals(graph.get(5l).pathCount(), 0);
    assertEquals(graph.get(6l).pathCount(), 0);

    List<Pair<NullWritable, LongWritable>> results = runWithGraphNoIndex(graph, mapReduceDriver);
    assertEquals(results.size(), 1);
    assertEquals(results.get(0).getSecond().get(), 23l);

    assertEquals(DEFAULT_COMPAT.getCounter(mapReduceDriver, CountMapReduce.Counters.VERTICES_COUNTED), 4L);
    assertEquals(DEFAULT_COMPAT.getCounter(mapReduceDriver, CountMapReduce.Counters.EDGES_COUNTED), 0L);
    identicalStructure(graph, ExampleGraph.TINKERGRAPH);
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:24,代码来源:CountMapReduceTest.java

示例8: startPath

import com.tinkerpop.blueprints.Element; //导入依赖的package包/类
public static Map<Long, FaunusVertex> startPath(final Map<Long, FaunusVertex> graph, final Class<? extends Element> klass, final long... ids) {
    if (ids.length == 0) {
        for (FaunusVertex vertex : graph.values()) {
            if (klass.equals(Vertex.class)) {
                vertex.startPath();
            } else if (klass.equals(Edge.class)) {
                for (Edge edge : vertex.getEdges(Direction.BOTH)) {
                    ((StandardFaunusEdge) edge).startPath();
                }
            } else {
                throw new IllegalArgumentException("It can only be either edge or vertex, not both");
            }
        }
    } else {
        if (klass.equals(Edge.class))
            throw new IllegalArgumentException("Currently no support for starting a path on a particular set of edges (only all edges)");

        for (long id : ids) {
            if (graph.get(id).hasPaths())
                graph.get(id).incrPath(1);
            else
                graph.get(id).startPath();
        }
    }
    return graph;
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:27,代码来源:BaseTest.java

示例9: getGraphIndexes

import com.tinkerpop.blueprints.Element; //导入依赖的package包/类
@Override
public Iterable<TitanGraphIndex> getGraphIndexes(final Class<? extends Element> elementType) {
    return Iterables.transform(Iterables.filter(Iterables.transform(
            transaction.getVertices(BaseKey.SchemaCategory, TitanSchemaCategory.GRAPHINDEX),
            new Function<TitanVertex, IndexType>() {
                @Nullable
                @Override
                public IndexType apply(@Nullable TitanVertex titanVertex) {
                    assert titanVertex instanceof TitanSchemaVertex;
                    return ((TitanSchemaVertex) titanVertex).asIndexType();
                }
            }), new Predicate<IndexType>() {
        @Override
        public boolean apply(@Nullable IndexType indexType) {
            return indexType.getElement().subsumedBy(elementType);
        }
    }), new Function<IndexType, TitanGraphIndex>() {
        @Nullable
        @Override
        public TitanGraphIndex apply(@Nullable IndexType indexType) {
            return new TitanGraphIndexWrapper(indexType);
        }
    });
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:25,代码来源:ManagementSystem.java

示例10: createIndexedPropertyMetadata

import com.tinkerpop.blueprints.Element; //导入依赖的package包/类
@Override
   public TitanIndexedPropertyMetadata createIndexedPropertyMetadata(
    PropertyMethod propertyMethod) {
Property property = propertyMethod
	.getAnnotationOfProperty(Property.class);
String name = property != null ? property.value() : propertyMethod
	.getName();
Class<?> declaringClass = propertyMethod.getAnnotatedElement()
	.getDeclaringClass();
Class<? extends Element> type = null;
if (declaringClass.getAnnotation(VertexDefinition.class) != null) {
    type = Vertex.class;
} else if (declaringClass.getAnnotation(EdgeDefinition.class) != null) {
    type = Edge.class;
} else {
    throw new XOException(
	    "Property '"
		    + name
		    + "' was found with index annotation, but the declaring type is neither a vertex nor an edge.");
}
Indexed indexedAnnotation = propertyMethod.getAnnotation(Indexed.class);
boolean unique = indexedAnnotation.unique();
Class<?> dataType = propertyMethod.getType();
return new TitanIndexedPropertyMetadata(name, unique, dataType, type);
   }
 
开发者ID:PureSolTechnologies,项目名称:extended-objects-titan,代码行数:26,代码来源:TitanMetadataFactory.java

示例11: checkAndInitializePropertyIndizes

import com.tinkerpop.blueprints.Element; //导入依赖的package包/类
private void checkAndInitializePropertyIndizes(
    Map<Class<?>, TypeMetadata> registeredMetadata) {
for (TypeMetadata metadata : registeredMetadata.values()) {
    IndexedPropertyMethodMetadata<?> indexedProperty = metadata
	    .getIndexedProperty();
    if (indexedProperty != null) {
	TitanIndexedPropertyMetadata datastoreMetadata = (TitanIndexedPropertyMetadata) indexedProperty
		.getDatastoreMetadata();
	String name = datastoreMetadata.getName();
	Class<?> dataType = datastoreMetadata.getDataType();
	Class<? extends Element> type = datastoreMetadata.getType();
	boolean unique = datastoreMetadata.isUnique();
	logger.info("Indexed property '" + name
		+ "' was found. Check for presence of index...");
	checkAndCreatePropertyIndex(name, dataType, type, unique);
    }
}
   }
 
开发者ID:PureSolTechnologies,项目名称:extended-objects-titan,代码行数:19,代码来源:TitanCassandraStore.java

示例12: toList

import com.tinkerpop.blueprints.Element; //导入依赖的package包/类
@Override
public List toList() {

	return Lists.transform(pipeline().toList(), new Function() {

		public Object apply(Object e) {
			if (e instanceof Edge) {
				return graph().frameElement((Element) e, TEdge.class);
			} else if (e instanceof Vertex) {
				return graph().frameElement((Element) e, TVertex.class);
			}
			return e;
		}
	});

}
 
开发者ID:BrynCooke,项目名称:totorom,代码行数:17,代码来源:TraversalBase.java

示例13: copyProperties

import com.tinkerpop.blueprints.Element; //导入依赖的package包/类
void copyProperties(PropertyContainer container, Element element) {
  for (String key : container.getPropertyKeys()) {
    Object property = container.getProperty(key);
    if (property.getClass().isArray()) {
      List<Object> propertyList = new ArrayList<>();
      for (int i = 0; i < Array.getLength(property); i++) {
        propertyList.add(Array.get(property, i));
      }
      property = propertyList;
    }
    else if (key.equals(CommonProperties.IRI) && String.class.isAssignableFrom(property.getClass())) {
      property = curieUtil.getCurie((String)property).orElse((String)property);
    }
    element.setProperty(key, property);
  }
}
 
开发者ID:SciGraph,项目名称:SciGraph,代码行数:17,代码来源:TinkerGraphUtil.java

示例14: testEdgeNoAutoIndex

import com.tinkerpop.blueprints.Element; //导入依赖的package包/类
@Test
public void testEdgeNoAutoIndex() throws Exception {
  AccumuloGraph graph = (AccumuloGraph) GraphFactory.open(AccumuloGraphTestUtils
      .generateGraphConfig("EdgeNoAutoIndexTest").getConfiguration());
  String id1 = "A";
  String id2 = "B";
  String eid = "X";
  String key = "name";
  String value = "bananaman";

  Vertex v1 = graph.addVertex(id1);
  Vertex v2 = graph.addVertex(id2);
  Edge e = graph.addEdge(eid, v1, v2, "edge");
  e.setProperty(key, value);

  Iterable<Element> elements = graph.getGlobals()
      .getEdgeKeyIndexWrapper().readElementsFromIndex(key, value);
  assertEquals(0, count(elements));
}
 
开发者ID:JHUAPL,项目名称:AccumuloGraph,代码行数:20,代码来源:AutoIndexTest.java

示例15: createIndex

import com.tinkerpop.blueprints.Element; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public <T extends Element> Index<T> createIndex(String indexName,
    Class<T> indexClass, Parameter... indexParameters) {
  if (indexClass == null) {
    throw ExceptionFactory.classForElementCannotBeNull();
  }
  else if (globals.getConfig().getIndexableGraphDisabled()) {
    throw new UnsupportedOperationException("IndexableGraph is disabled via the configuration");
  }

  for (Index<?> index : globals.getIndexMetadataWrapper().getIndices()) {
    if (index.getIndexName().equals(indexName)) {
      throw ExceptionFactory.indexAlreadyExists(indexName);
    }
  }

  return globals.getIndexMetadataWrapper().createIndex(indexName, indexClass);
}
 
开发者ID:JHUAPL,项目名称:AccumuloGraph,代码行数:20,代码来源:AccumuloGraph.java


注:本文中的com.tinkerpop.blueprints.Element类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。