Creates a new segment.
435844
public Segment createSegment(SegmentDescriptor descriptor) {
    switch (storage.level()) {
      case MEMORY:
        return createMemorySegment(descriptor);
      case MAPPED:
        if (descriptor.version() == 1) {
          return createMappedSegment(descriptor);
        } else {
          return createDiskSegment(descriptor);
        }
      case DISK:
        return createDiskSegment(descriptor);
      default:
        throw new AssertionError();
    }
  }
1001983
def __add_segment(self, segment):
        
        segment_id = self.ns+':'+segment.attrib['id']
        self.segments.append(segment_id)
        segment_type, parent_segment_type = self.__get_segment_types(segment)
        segment_text = sanitize_string(segment.text)
        segment_label = get_segment_label(
            segment, segment_type, segment_text, self.ns, self.tokenized)

        self.add_node(
            segment_id, layers={self.ns, self.ns+':segment'},
            attr_dict={'label': segment_label,
                       self.ns+':text' : segment_text,
                       self.ns+':segment_type': segment_type})

        # store RST segment in list of EDUs
        self.edus.append(segment_id)

        if 'parent' in segment.attrib:
            self.__add_parent_relation(segment, segment_id, segment_type,
                                       parent_segment_type)
809997
def append_segment(self, apdu):
        """"""
        if _debug: SSM._debug("append_segment %r", apdu)

        # check for no context
        if not self.segmentAPDU:
            raise RuntimeError("no segmentation context established")

        # append the data
        self.segmentAPDU.put_data(apdu.pduData)
436426
JournalSegment<E> createSegment(JournalSegmentDescriptor descriptor) {
    File segmentFile = JournalSegmentFile.createSegmentFile(name, directory, descriptor.id());

    RandomAccessFile raf;
    FileChannel channel;
    try {
      raf = new RandomAccessFile(segmentFile, "rw");
      raf.setLength(descriptor.maxSegmentSize());
      channel =  raf.getChannel();
    } catch (IOException e) {
      throw new StorageException(e);
    }

    ByteBuffer buffer = ByteBuffer.allocate(JournalSegmentDescriptor.BYTES);
    descriptor.copyTo(buffer);
    buffer.flip();
    try {
      channel.write(buffer);
    } catch (IOException e) {
      throw new StorageException(e);
    } finally {
      try {
        channel.close();
        raf.close();
      } catch (IOException e) {
      }
    }
    JournalSegment<E> segment = newSegment(new JournalSegmentFile(segmentFile), descriptor);
    log.debug("Created segment: {}", segment);
    return segment;
  }
938863
def segment(self, eps, min_time):
        
        new_segments = []
        for segment in self.segments:
            segmented = segment.segment(eps, min_time)
            for seg in segmented:
                new_segments.append(Segment(seg))
        self.segments = new_segments
        return self
484306
private void open() {
    // Load existing log segments from disk.
    for (JournalSegment<E> segment : loadSegments()) {
      segments.put(segment.descriptor().index(), segment);
    }

    // If a segment doesn't already exist, create an initial segment starting at index 1.
    if (!segments.isEmpty()) {
      currentSegment = segments.lastEntry().getValue();
    } else {
      JournalSegmentDescriptor descriptor = JournalSegmentDescriptor.builder()
          .withId(1)
          .withIndex(1)
          .withMaxSegmentSize(maxSegmentSize)
          .withMaxEntries(maxEntriesPerSegment)
          .build();

      currentSegment = createSegment(descriptor);
      currentSegment.descriptor().update(System.currentTimeMillis());

      segments.put(1L, currentSegment);
    }
  }
74156
public static String createPath(String... segments) {

    int length = 0;
    for (String s : segments) {
      if (length > 0) {
        length++;
      }
      length = length + s.length();
    }
    StringBuilder buffer = new StringBuilder(length);
    appendPath(buffer, segments);
    return buffer.toString();
  }
246526
public SegmentKelp createSegment(int length,
                                   byte []tableKey,
                                   long sequence)
  {
    SegmentMeta segmentMeta = findSegmentMeta(length);
    
    SegmentKelp segment;
  
    SegmentExtent extent = segmentMeta.allocate();
    
    if (extent == null) {
      extent = allocateSegment(segmentMeta);
    }
    
    segment = new SegmentKelp(extent, sequence, tableKey, this);
    segment.writing();
    
    segmentMeta.addLoaded(segment);
  
    return segment;
  }
1336665
def help_center_user_segment_create(self, data, **kwargs):
        ""
        api_path = "/api/v2/help_center/user_segments.json"
        return self.call(api_path, method="POST", data=data, **kwargs)
51467
private Collection<WriterSegmentProcessor> createWriterProcessors(UpdateableSegmentMetadata segmentMetadata) {
        ImmutableList.Builder<WriterSegmentProcessor> builder = ImmutableList.builder();
        this.extensions.values().forEach(p -> builder.addAll(p.createWriterSegmentProcessors(segmentMetadata)));
        return builder.build();
    }
1054729
private void createHeader(RollingSegmentHandle handle) throws StreamSegmentException {
        Preconditions.checkArgument(handle.getHeaderHandle() == null, "handle already has a header.");

        // Create a new Header SegmentChunk.
        String headerName = StreamSegmentNameUtils.getHeaderSegmentName(handle.getSegmentName());
        this.baseStorage.create(headerName);
        val headerHandle = this.baseStorage.openWrite(headerName);

        // Create a new Handle and serialize it, after which update the original handle.
        val newHandle = new RollingSegmentHandle(headerHandle, handle.getRollingPolicy(), handle.chunks());
        serializeHandle(newHandle);
        handle.refresh(newHandle);
    }
408108
@SuppressWarnings("unchecked")
    private Segment<K,V> ensureSegment(int k) {
        final Segment<K,V>[] ss = this.segments;
        long u = (k << SSHIFT) + SBASE; // raw offset
        Segment<K,V> seg;
        if ((seg = (Segment<K,V>)UNSAFE.getObjectVolatile(ss, u)) == null) {
            Segment<K,V> proto = ss[0]; // use segment 0 as prototype
            int cap = proto.table.length;
            float lf = proto.loadFactor;
            int threshold = (int)(cap * lf);
            HashEntry<K,V>[] tab = new HashEntry[cap];
            if ((seg = (Segment<K,V>)UNSAFE.getObjectVolatile(ss, u))
                == null) { // recheck
                Segment<K,V> s = new Segment<K,V>(lf, threshold, tab);
                while ((seg = (Segment<K,V>)UNSAFE.getObjectVolatile(ss, u))
                       == null) {
                    if (UNSAFE.compareAndSwapObject(ss, u, null, seg = s)) {
                      break;
                    }
                }
            }
        }
        return seg;
    }
400387
def begin_segment(name, trace_id: nil, parent_id: nil, sampled: nil)
      seg_name = name || config.name
      raise SegmentNameMissingError if seg_name.to_s.empty?

      # sampling decision comes from outside has higher precedence.
      sample = sampled.nil? ? config.sample? : sampled
      if sample
        segment = Segment.new name: seg_name, trace_id: trace_id, parent_id: parent_id
        populate_runtime_context(segment, sample)
      else
        segment = DummySegment.new name: seg_name, trace_id: trace_id, parent_id: parent_id
      end
      context.store_entity entity: segment
      segment
    end
60909
static File createSegmentFile(String name, File directory, long id, long version) {
    return new File(directory, String.format("%s-%d-%d.log", Assert.notNull(name, "name"), id, version));
  }
253694
public Segment push(Segment segment) {
    segment.prev = this;
    segment.next = next;
    next.prev = segment;
    next = segment;
    return segment;
  }
413476
Segment writableSegment(int minimumCapacity) {
    if (minimumCapacity < 1 || minimumCapacity > Segment.SIZE) throw new IllegalArgumentException();

    if (head == null) {
      head = SegmentPool.take(); // Acquire a first segment.
      return head.next = head.prev = head;
    }

    Segment tail = head.prev;
    if (tail.limit + minimumCapacity > Segment.SIZE || !tail.owner) {
      tail = tail.push(SegmentPool.take()); // Append a new empty segment to fill up.
    }
    return tail;
  }
1265785
def createSections(self):
        """"""
        self.soma = h.Section(name='soma', cell=self)
        self.dend = h.Section(name='dend', cell=self)