Tabnine Logo
IdGenerator.of
Code IndexAdd Tabnine to your IDE (free)

How to use
of
method
in
com.baidu.hugegraph.backend.id.IdGenerator

Best Java code snippets using com.baidu.hugegraph.backend.id.IdGenerator.of (Showing top 20 results out of 315)

origin: hugegraph/hugegraph

  private Id genTaskId() {
    if (ephemeralTaskId >= 0) {
      ephemeralTaskId = -1;
    }
    return IdGenerator.of(ephemeralTaskId--);
  }
}
origin: hugegraph/hugegraph

/**
 * Generate a string id
 * @param id original string id value
 * @return   wrapped id object
 */
public Id generate(String id) {
  return of(id);
}
origin: hugegraph/hugegraph

/**
 * Generate a long id
 * @param id original long id value
 * @return   wrapped id object
 */
public Id generate(long id) {
  return of(id);
}
origin: hugegraph/hugegraph

@Override
public EdgeLabelBuilder id(long id) {
  E.checkArgument(id != 0L, "Not allowed to assign 0 as edge label id");
  this.id = IdGenerator.of(id);
  return this;
}
origin: hugegraph/hugegraph

/**
 * Concat multiple parts into a single id with ID_SPLITOR
 * @param parts the string id values to be spliced
 * @return      spliced id object
 */
public static Id splicing(String... parts) {
  String escaped = StringUtil.escape(ID_SPLITOR, ESCAPE, parts);
  return IdGenerator.of(escaped);
}
origin: hugegraph/hugegraph

@Override
public IndexLabelBuilder id(long id) {
  E.checkArgument(id != 0L,
          "Not allowed to assign 0 as index label id");
  this.id = IdGenerator.of(id);
  return this;
}
origin: hugegraph/hugegraph

protected Id schemaId() {
  String name = this.task().name();
  String[] parts = name.split(SPLITOR, 3);
  E.checkState(parts.length == 3 && parts[1] != null,
         "Task name should be formatted to String " +
         "'TYPE:ID:NAME', but got '%s'", name);
  return IdGenerator.of(Long.valueOf(parts[1]));
}
origin: hugegraph/hugegraph

@Override
protected Id writeQueryId(HugeType type, Id id) {
  if (type.isEdge()) {
    id = IdGenerator.of(writeEdgeId(id, true));
  } else if (type.isGraph()) {
    id = IdGenerator.of(writeEntryId(id));
  } else {
    assert type.isSchema();
    id = IdGenerator.of(writeId(id));
  }
  return id;
}
origin: hugegraph/hugegraph

@DELETE
@Timed
@Path("{id}")
public void delete(@Context GraphManager manager,
          @PathParam("graph") String graph,
          @PathParam("id") long id) {
  LOG.debug("Graph [{}] delete task: {}", graph, id);
  TaskScheduler scheduler = graph(manager, graph).taskScheduler();
  HugeTask<?> task = scheduler.deleteTask(IdGenerator.of(id));
  E.checkArgument(task != null, "There is no task with id '%s'", id);
}
origin: hugegraph/hugegraph

  @Override
  public Id read(Kryo kryo, Input input, Class<Id> clazz) {
    boolean number = input.readBoolean();
    int length = input.read();
    byte[] idBytes = input.readBytes(length);
    return IdGenerator.of(idBytes, number);
  }
}
origin: hugegraph/hugegraph

@Test
public void testMutiThreadsUpdateWithGtCapacity() {
  RamCache cache = new RamCache(10);
  runWithThreads(THREADS_NUM, () -> {
    for (int i = 0; i < 10000 * 100; i++) {
      Id id = IdGenerator.of(
          Thread.currentThread().getName() + "-" + i);
      cache.update(id, "value-" + i);
    }
  });
  Assert.assertEquals(10, cache.size());
}
origin: hugegraph/hugegraph

@Test
public void testUpdateGet() {
  RamCache cache = new RamCache();
  Id id = IdGenerator.of("1");
  cache.update(id, "value-1");
  Assert.assertEquals("value-1", cache.get(id));
}
origin: hugegraph/hugegraph

@Test
public void testUpdateIfAbsent() {
  RamCache cache = new RamCache();
  Id id = IdGenerator.of("1");
  cache.updateIfAbsent(id, "value-1");
  Assert.assertEquals("value-1", cache.get(id));
}
origin: hugegraph/hugegraph

@Test
public void testExpireWithZeroSecond() {
  RamCache cache = new RamCache();
  cache.update(IdGenerator.of("1"), "value-1");
  cache.update(IdGenerator.of("2"), "value-2");
  Assert.assertEquals(2, cache.size());
  cache.expire(0);
  waitTillNext(1);
  cache.tick();
  Assert.assertEquals(2, cache.size());
}
origin: hugegraph/hugegraph

@Test
public void testExpire() {
  RamCache cache = new RamCache();
  cache.update(IdGenerator.of("1"), "value-1");
  cache.update(IdGenerator.of("2"), "value-2");
  Assert.assertEquals(2, cache.size());
  cache.expire(2); // 2 seconds
  waitTillNext(2);
  cache.tick();
  Assert.assertEquals(0, cache.size());
}
origin: hugegraph/hugegraph

@Override
public BackendEntry writeVertexProperty(HugeVertexProperty<?> prop) {
  BinaryBackendEntry entry = newBackendEntry(prop.element());
  entry.column(this.formatProperty(prop));
  entry.subId(IdGenerator.of(prop.key()));
  return entry;
}
origin: hugegraph/hugegraph

@Test
public void testUpdateIfAbsentWithExistKey() {
  RamCache cache = new RamCache();
  Id id = IdGenerator.of("1");
  cache.update(id, "value-1");
  cache.updateIfAbsent(id, "value-2");
  Assert.assertEquals("value-1", cache.get(id));
}
origin: hugegraph/hugegraph

private CassandraBackendEntry wrapByVertex(CassandraBackendEntry edge) {
  assert edge.type().isEdge();
  String ownerVertex = edge.column(HugeKeys.OWNER_VERTEX);
  E.checkState(ownerVertex != null, "Invalid backend entry");
  Id vertexId = IdGenerator.of(ownerVertex);
  CassandraBackendEntry vertex = new CassandraBackendEntry(
                    HugeType.VERTEX, vertexId);
  vertex.column(HugeKeys.ID, ownerVertex);
  vertex.column(HugeKeys.PROPERTIES, ImmutableMap.of());
  vertex.subRow(edge.row());
  return vertex;
}
origin: hugegraph/hugegraph

@Override
public BackendEntry writeEdge(HugeEdge edge) {
  Id id = IdGenerator.of(edge.idWithDirection().asString());
  TextBackendEntry entry = newBackendEntry(edge.type(), id);
  entry.column(this.formatEdgeName(edge), this.formatEdgeValue(edge));
  return entry;
}
origin: hugegraph/hugegraph

private MysqlBackendEntry wrapByVertex(MysqlBackendEntry edge) {
  assert edge.type().isEdge();
  String ownerVertex = edge.column(HugeKeys.OWNER_VERTEX);
  E.checkState(ownerVertex != null, "Invalid backend entry");
  Id vertexId = IdGenerator.of(ownerVertex);
  MysqlBackendEntry vertex = new MysqlBackendEntry(HugeType.VERTEX,
                           vertexId);
  vertex.column(HugeKeys.ID, ownerVertex);
  vertex.column(HugeKeys.PROPERTIES, "");
  vertex.subRow(edge.row());
  return vertex;
}
com.baidu.hugegraph.backend.idIdGeneratorof

Popular methods of IdGenerator

    Popular in Java

    • Making http requests using okhttp
    • putExtra (Intent)
    • getSharedPreferences (Context)
    • getApplicationContext (Context)
    • FileReader (java.io)
      A specialized Reader that reads from a file in the file system. All read requests made by calling me
    • System (java.lang)
      Provides access to system-related information and resources including standard input and output. Ena
    • Permission (java.security)
      Legacy security code; do not use.
    • PriorityQueue (java.util)
      A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
    • TimeZone (java.util)
      TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
    • Loader (org.hibernate.loader)
      Abstract superclass of object loading (and querying) strategies. This class implements useful common
    • CodeWhisperer alternatives
    Tabnine Logo
    • Products

      Search for Java codeSearch for JavaScript code
    • IDE Plugins

      IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
    • Company

      About UsContact UsCareers
    • Resources

      FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
    Get Tabnine for your IDE now