com.tinkerpop.blueprints.Parameter Java Examples

The following examples show how to use com.tinkerpop.blueprints.Parameter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AccumuloGraph.java    From AccumuloGraph with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #2
Source File: AccumuloGraph.java    From AccumuloGraph with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("rawtypes")
@Override
public <T extends Element> void createKeyIndex(String key,
    Class<T> elementClass, Parameter... indexParameters) {
  // TODO Move below to somewhere appropriate.
  if (elementClass == null) {
    throw ExceptionFactory.classForElementCannotBeNull();
  }

  // Add key to indexed keys list.
  globals.getIndexMetadataWrapper().writeKeyMetadataEntry(key, elementClass);
  globals.checkedFlush();

  // Reindex graph.
  globals.getKeyIndexTableWrapper(elementClass).rebuildIndex(key, elementClass);
  globals.getVertexKeyIndexWrapper().dump();
  globals.checkedFlush();
}
 
Example #3
Source File: Converter.java    From epcis with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "rawtypes" })
public static BsonDocument makeIndexParamterDocument(Parameter... indexParameters) {
	BsonDocument index = new BsonDocument();
	for (Parameter param : indexParameters) {
		validateIndexParameter(param);
		index.append(param.getKey().toString(), new BsonInt32((Integer) param.getValue()));
	}
	return index;
}
 
Example #4
Source File: Converter.java    From epcis with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("rawtypes")
public static void validateIndexParameter(Parameter param) {
	Object objKey = param.getKey();
	Object objValue = param.getValue();
	if (!(objKey instanceof String))
		throw ExceptionFactory.indexKeyShouldBeString();
	if (!(objValue instanceof Integer))
		throw ExceptionFactory.indexValueShouldBeInteger();
	Integer value = (Integer) objValue;
	if (value != 1 && value != -1)
		throw ExceptionFactory.indexValueShouldBeIntegerOneOrMinusOne();
}
 
Example #5
Source File: OVertexTransformerTest.java    From orientdb-etl with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
  super.setUp();
  OGlobalConfiguration.USE_WAL.setValue(true);

  graph.createVertexType("Person");
  graph.createKeyIndex("name", Vertex.class, new Parameter<String, String>("type", "UNIQUE"), new Parameter<String, String>(
      "class", "Person"));
  graph.commit();
}
 
Example #6
Source File: IndexableTransactionalVersionedGraphImpl.java    From antiquity with GNU General Public License v3.0 5 votes vote down vote up
@Override
    public <T extends Element> Index<T> createIndex(final String indexName, final Class<T> indexClass,
            final Parameter... indexParameters) {
//        return new ActiveVersionedIndex<T, V>(getEventableGraph().createIndex(indexName, indexClass, indexParameters),
//                this);
        throw new IllegalStateException("Currently not supported.");
    }
 
Example #7
Source File: ActiveVersionedGraph.java    From antiquity with GNU General Public License v3.0 5 votes vote down vote up
@Override
public <T extends Element> void createKeyIndex(final String key, final Class<T> elementClass,
        final Parameter... indexParameters) {
    if (key.equals(VEProps.NATURAL_VERTEX_ID_PROP_KEY) || key.equals(VEProps.NATURAL_EDGE_ID_PROP_KEY)) {
        throw new IllegalArgumentException(String.format("Index key [%s] is reserved and cannot be created",
                VEProps.NATURAL_VERTEX_ID_PROP_KEY));
    }

    getEventableGraph().getBaseGraph().createKeyIndex(key, elementClass, indexParameters);
}
 
Example #8
Source File: OrientGraphDatabase.java    From graphdb-benchmarks with Apache License 2.0 5 votes vote down vote up
protected void createSchema()
{
    graph.executeOutsideTx(new OCallable<Object, OrientBaseGraph>() {
        @SuppressWarnings({ "unchecked", "rawtypes" })
        @Override
        public Object call(final OrientBaseGraph g)
        {
            OrientVertexType v = g.getVertexBaseType();
            if(!v.existsProperty(NODE_ID)) { // TODO fix schema detection hack later
                v.createProperty(NODE_ID, OType.INTEGER);
                g.createKeyIndex(NODE_ID, Vertex.class, new Parameter("type", "UNIQUE_HASH_INDEX"), new Parameter(
                    "keytype", "INTEGER"));

                v.createEdgeProperty(Direction.OUT, SIMILAR, OType.LINKBAG);
                v.createEdgeProperty(Direction.IN, SIMILAR, OType.LINKBAG);
                OrientEdgeType similar = g.createEdgeType(SIMILAR);
                similar.createProperty("out", OType.LINK, v);
                similar.createProperty("in", OType.LINK, v);
                g.createKeyIndex(COMMUNITY, Vertex.class, new Parameter("type", "NOTUNIQUE_HASH_INDEX"),
                    new Parameter("keytype", "INTEGER"));
                g.createKeyIndex(NODE_COMMUNITY, Vertex.class, new Parameter("type", "NOTUNIQUE_HASH_INDEX"),
                    new Parameter("keytype", "INTEGER"));
            }

            return null;
        }
    });
}
 
Example #9
Source File: IdGraph.java    From org.openntf.domino with Apache License 2.0 5 votes vote down vote up
public <T extends Element> void createKeyIndex(final String key,
                                               final Class<T> elementClass,
                                               final Parameter... indexParameters) {
    if (elementClass == null)
        throw ExceptionFactory.classForElementCannotBeNull();

    boolean v = isVertexClass(elementClass);
    boolean supported = ((v && supportVertexIds) || (!v && supportEdgeIds));

    if (supported && key.equals(ID)) {
        throw new IllegalArgumentException("index key " + ID + " is reserved by IdGraph");
    } else {
        baseGraph.createKeyIndex(key, elementClass, indexParameters);
    }
}
 
Example #10
Source File: IdGraph.java    From org.openntf.domino with Apache License 2.0 5 votes vote down vote up
public <T extends Element> Index<T> createIndex(final String indexName,
                                                final Class<T> indexClass,
                                                final Parameter... indexParameters) {
    verifyBaseGraphIsIndexableGraph();

    return isVertexClass(indexClass)
            ? (Index<T>) new IdVertexIndex((Index<Vertex>) ((IndexableGraph) baseGraph).createIndex(indexName, indexClass, indexParameters), this)
            : (Index<T>) new IdEdgeIndex((Index<Edge>) ((IndexableGraph) baseGraph).createIndex(indexName, indexClass, indexParameters), this);
}
 
Example #11
Source File: HistoricVersionedGraph.java    From antiquity with GNU General Public License v3.0 4 votes vote down vote up
@Override
public <T extends Element> void createKeyIndex(String key, Class<T> elementClass, Parameter... indexParameters) {
    throw new UnsupportedOperationException(ReadOnlyTokens.MUTATE_ERROR_MESSAGE);
}
 
Example #12
Source File: ReadOnlyIndexableGraph.java    From org.openntf.domino with Apache License 2.0 4 votes vote down vote up
/**
 * @throws UnsupportedOperationException
 */
public <T extends Element> Index<T> createIndex(final String indexName, final Class<T> indexClass, final Parameter... indexParameters) throws UnsupportedOperationException {
    throw new UnsupportedOperationException(ReadOnlyTokens.MUTATE_ERROR_MESSAGE);
}
 
Example #13
Source File: ReadOnlyKeyIndexableGraph.java    From org.openntf.domino with Apache License 2.0 4 votes vote down vote up
/**
 * @throws UnsupportedOperationException
 */
public <T extends Element> void createKeyIndex(final String name, Class<T> elementClass, final Parameter... indexParameters) throws UnsupportedOperationException {
    throw new UnsupportedOperationException(ReadOnlyTokens.MUTATE_ERROR_MESSAGE);
}
 
Example #14
Source File: PartitionIndexableGraph.java    From org.openntf.domino with Apache License 2.0 4 votes vote down vote up
public <T extends Element> Index<T> createIndex(final String indexName, final Class<T> indexClass, final Parameter... indexParameters) {
    return new PartitionIndex<T>(baseGraph.createIndex(indexName, indexClass, indexParameters), this);
}
 
Example #15
Source File: EventIndexableGraph.java    From org.openntf.domino with Apache License 2.0 4 votes vote down vote up
public <T extends Element> Index<T> createIndex(final String indexName, final Class<T> indexClass, final Parameter... indexParameters) {
    return new EventIndex<T>(this.getBaseGraph().createIndex(indexName, indexClass, indexParameters), this);
}
 
Example #16
Source File: WrappedIndexableGraph.java    From org.openntf.domino with Apache License 2.0 4 votes vote down vote up
public <T extends Element> Index<T> createIndex(final String indexName, final Class<T> indexClass, final Parameter... indexParameters) {
    return new WrappedIndex<T>(baseGraph.createIndex(indexName, indexClass, indexParameters));
}