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

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

Best Java code snippets using com.baidu.hugegraph.backend.id.IdGenerator (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

public synchronized Id nextId(HugeType type) {
  AtomicLong counter = this.counters.get(type);
  if (counter == null) {
    counter = new AtomicLong(0);
    AtomicLong previous = this.counters.putIfAbsent(type, counter);
    if (previous != null) {
      counter = previous;
    }
  }
  return IdGenerator.of(counter.incrementAndGet());
}
origin: hugegraph/hugegraph

private static Id readId(String id) {
  Object value = JsonUtil.fromJson(id, Object.class);
  if (value instanceof Number) {
    return IdGenerator.of(((Number) value).longValue());
  } else {
    assert value instanceof String;
    return IdGenerator.of(value.toString());
  }
}
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

private BackendEntry getEntryById(Id id,
                 Map<Id, BackendEntry> entries) {
  // TODO: improve id split
  Id entryId = IdGenerator.of(EdgeId.split(id)[0]);
  return entries.get(entryId);
}
origin: hugegraph/hugegraph

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

@Override
protected Id[] toIdArray(Object object) {
  assert object instanceof String;
  String value = (String) object;
  Number[] values = JsonUtil.fromJson(value, Number[].class);
  Id[] ids = new Id[values.length];
  int i = 0;
  for (Number number : values) {
    ids[i++] = IdGenerator.of(number.longValue());
  }
  return ids;
}
origin: hugegraph/hugegraph

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

@GET
@Timed
@Path("{id}")
@Produces(APPLICATION_JSON_WITH_CHARSET)
public Map<String, Object> get(@Context GraphManager manager,
                @PathParam("graph") String graph,
                @PathParam("id") long id) {
  LOG.debug("Graph [{}] get task: {}", graph, id);
  TaskScheduler scheduler = graph(manager, graph).taskScheduler();
  return scheduler.task(IdGenerator.of(id)).asMap();
}
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

private static Id generateId(HugeType type, Id id) {
  // NOTE: it's slower performance to use:
  // String.format("%x-%s", type.code(), name)
  return IdGenerator.of(type.string() + "-" + id.asString());
}
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

@Watched(prefix = "schema")
public Id getNextSystemId() {
  LOG.debug("SchemaTransaction get next system id");
  Id id = this.store().nextId(HugeType.SYS_SCHEMA);
  return IdGenerator.of(-id.asLong());
}
origin: hugegraph/hugegraph

@Test
public void testSize() {
  RamCache cache = new RamCache();
  Id id = IdGenerator.of("1");
  cache.update(id, "value-1");
  id = IdGenerator.of("2");
  cache.update(id, "value-2");
  Assert.assertEquals(2, cache.size());
}
com.baidu.hugegraph.backend.idIdGenerator

Most used methods

  • of

Popular in Java

  • Making http post requests using okhttp
  • addToBackStack (FragmentTransaction)
  • onCreateOptionsMenu (Activity)
  • startActivity (Activity)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • Top Sublime Text plugins
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