Used only for Segments. Not for Queries
9607
@Override
  public DateTimeFormatter getFormatter(Formatter type)
  {
    GranularityType granularityType = GranularityType.fromPeriod(period);
    switch (type) {
      case DEFAULT:
        return DateTimeFormat.forPattern(granularityType.getDefaultFormat());
      case HIVE:
        return DateTimeFormat.forPattern(granularityType.getHiveFormat());
      case LOWER_DEFAULT:
        return DateTimeFormat.forPattern(granularityType.getLowerDefaultFormat());
      default:
        throw new IAE("There is no format for type %s", type);
    }
  }
1161742
SegmentDescriptor copyTo(Buffer buffer) {
    this.buffer = buffer
      .writeLong(id)
      .writeLong(version)
      .writeLong(index)
      .writeUnsignedInt(maxSegmentSize)
      .writeInt(maxEntries)
      .writeLong(updated)
      .writeBoolean(locked)
      .skip(BYTES - buffer.position())
      .flush();
    return this;
  }
798864
@Override
  protected Double boundaryForSegment(String segmentName) throws IOException {
    if (segmentRegistration.equals(SEGMENT_SORT_ASC)
        || segmentRegistration.equals(SEGMENT_SORT_DESC)) {
      Double thisLast = segmentValueTopListLast.get(segmentName);
      if (thisLast == null) {
        return null;
      } else if (segmentRegistration.equals(SEGMENT_SORT_ASC)) {
        return thisLast * segmentNumber;
      } else {
        return thisLast / segmentNumber;
      }
    } else {
      throw new IOException("can't compute boundary for segmentRegistration "
          + segmentRegistration);
    }
  }
636641
public static void setLong(MemorySegment[] segments, int offset, long value) {
		if (inFirstSegment(segments, offset, 8)) {
			segments[0].putLong(offset, value);
		} else {
			setLongMultiSegments(segments, offset, value);
		}
	}
1220615
def _removeSegment(self, segment, preserveCurve, **kwargs):
        
        segment = self.segments[segment]
        for point in segment.points:
            self.removePoint(point, preserveCurve)
479538
@Override
  public Set<DataSegment> announceHistoricalSegments(final Set<DataSegment> segments) throws IOException
  {
    final SegmentPublishResult result = announceHistoricalSegments(segments, null, null);

    // Metadata transaction cannot fail because we are not trying to do one.
    if (!result.isSuccess()) {
      throw new ISE("WTF?! announceHistoricalSegments failed with null metadata, should not happen.");
    }

    return result.getSegments();
  }
253861
private void readSegments()
    throws IOException
  {
    for (SegmentExtent10 extent : _segmentExtents) {
      try (ReadStream is = openRead(extent.address(), extent.length())) {
        is.skip(extent.length() - BLOCK_SIZE);
        
        long sequence = BitsUtil.readLong(is);
        
        byte []tableKey = new byte[TABLE_KEY_SIZE];
        is.readAll(tableKey, 0, tableKey.length);
        
        // XXX: crc
        
        if (sequence > 0) {
          Segment10 segment = new Segment10(sequence, tableKey, extent);
          
          _segments.add(segment);
        }
      }
    }
  }
456338
public static void bitUnSet(MemorySegment[] segments, int baseOffset, int index) {
		if (segments.length == 1) {
			MemorySegment segment = segments[0];
			int offset = baseOffset + ((index & BIT_BYTE_POSITION_MASK) >>> 3);
			byte current = segment.get(offset);
			current &= ~(1 << (index & BIT_BYTE_INDEX_MASK));
			segment.put(offset, current);
		} else {
			bitUnSetMultiSegments(segments, baseOffset, index);
		}
	}
458318
@Override
    public Map<String, SegmentData> getTRSegments(String trId,
        DocumentType type, String documentId, String language)
            throws ServiceException {
        if (trId == null || trId.isEmpty()) {
            throw new IllegalArgumentException("Non-empty trId must be specified.");
        }
        if (documentId == null || documentId.isEmpty()) {
            throw new IllegalArgumentException("Non-empty documentId must be specified.");
        }
        if (language == null || language.isEmpty()) {
            throw new IllegalArgumentException("Non-empty languageId must be specified.");
        }

        GetSegmentsResponse resp = invokeApiJson(
                "GET",
                escapePathSegment(account.getInstanceId()) + "/v2/doc-trs/"
                    + escapePathSegment(trId) + "/" + type.toString().toLowerCase() + "/"
                    + escapePathSegment(documentId) + "/" + language,
                null,
                GetSegmentsResponse.class);

        if (resp.getStatus() == Status.ERROR) {
            throw new ServiceException(resp.getMessage());
        }

        Map<String, SegmentData> resultEntries = new TreeMap<String, SegmentData>();
        if (resp.segments != null && !resp.segments.isEmpty()) {
            for (Entry<String, RestSegmentData> entry : resp.segments.entrySet()) {
                resultEntries.put(entry.getKey(),
                        new SegmentDataImpl(entry.getValue()));
            }
        }
        return resultEntries;
    }
1178754
function select(segments, selection, buildLog){
	var result = [];
	segments.forEach(function(seg){
		var index =
			(seg.myFill.above ? 8 : 0) +
			(seg.myFill.below ? 4 : 0) +
			((seg.otherFill && seg.otherFill.above) ? 2 : 0) +
			((seg.otherFill && seg.otherFill.below) ? 1 : 0);
		if (selection[index] !== 0){
			// copy the segment to the results, while also calculating the fill status
			result.push({
				id: buildLog ? buildLog.segmentId() : -1,
				start: seg.start,
				end: seg.end,
				myFill: {
					above: selection[index] === 1, // 1 if filled above
					below: selection[index] === 2  // 2 if filled below
				},
				otherFill: null
			});
		}
	});

	if (buildLog)
		buildLog.selected(result);

	return result;
}
765835
void querySegmentXY(int half_edge, SegmentBuffer outBuffer) {
		outBuffer.createLine();
		Segment seg = outBuffer.get();
		Point2D pt = new Point2D();
		getHalfEdgeFromXY(half_edge, pt);
		seg.setStartXY(pt);
		getHalfEdgeToXY(half_edge, pt);
		seg.setEndXY(pt);
	}
844992
function(segment, strict) {
		if (!_.isString(segment)) {
			throw new TypeError('segment must be of type string');
		}
		return segment === module.exports.reformatSegment(segment, strict);
	}
885043
JournalSegment<E> resetSegments(long index) {
    assertOpen();

    // If the index already equals the first segment index, skip the reset.
    JournalSegment<E> firstSegment = getFirstSegment();
    if (index == firstSegment.index()) {
      return firstSegment;
    }

    for (JournalSegment<E> segment : segments.values()) {
      segment.close();
      segment.delete();
    }
    segments.clear();

    JournalSegmentDescriptor descriptor = JournalSegmentDescriptor.builder()
        .withId(1)
        .withIndex(index)
        .withMaxSegmentSize(maxSegmentSize)
        .withMaxEntries(maxEntriesPerSegment)
        .build();
    currentSegment = createSegment(descriptor);
    segments.put(index, currentSegment);
    return currentSegment;
  }
131403
function processURLSegments(parentNode, segments) {
		segments.forEach(function(segment) {
			if (segment.urlStr){
				var link = document.createElement("a"); //$NON-NLS-0$
		        link.href = segment.urlStr;
		        link.appendChild(document.createTextNode(segment.segmentStr));
		        link.dir = bidiUtils.getTextDirection(segment.segmentStr);
				parentNode.appendChild(link);
			} else {
				var plainText = document.createElement("span"); //$NON-NLS-0$
				plainText.textContent = segment.segmentStr;
				plainText.dir = bidiUtils.getTextDirection(segment.segmentStr);
				parentNode.appendChild(plainText);
			}
		});
	}
292422
function buildSegmentRows(segments) {
		var rowCnt = getRowCnt();
		var segmentRows = [];
		var segmentI;
		var segment;
		var rowI;

		// group segments by row
		for (segmentI=0; segmentI<segments.length; segmentI++) {
			segment = segments[segmentI];
			rowI = segment.row;
			if (segment.element) { // was rendered?
				if (segmentRows[rowI]) {
					// already other segments. append to array
					segmentRows[rowI].push(segment);
				}
				else {
					// first segment in row. create new array
					segmentRows[rowI] = [ segment ];
				}
			}
		}

		// sort each row
		for (rowI=0; rowI<rowCnt; rowI++) {
			segmentRows[rowI] = sortSegmentRow(
				segmentRows[rowI] || [] // guarantee an array, even if no segments
			);
		}

		return segmentRows;
	}
1013139
private void eatSplicedRange(List segments) {
        Token token = tokenizer.peekToken(0);
        if (token == null) {// ∈
            return;
        }
        switch (token.getKind()) {
            case LITERAL_STRING:
                segments.add(token.getData());
                break;
            case LSQUARE:
                tokenizer.nextToken();
                List<?> list = new ArrayList<>();
                eatRange(list);
                if (list.isEmpty()) {
                    empty = true;
                } else {
                    segments.add(list);
                }
                tokenizer.peekToken(0, TokenKind.RSQUARE);
                break;
            default:
                return;
        }
        if (tokenizer.hasMoreTokens()) {// ∈
            tokenizer.nextToken();
            eatSplicedRange(segments);
        }
    }
482818
function(index) {

            var segments = this.segments;
            var numSegments = segments.length;
            if (numSegments === 0) throw new Error('Path has no segments.');

            if (index < 0) index = numSegments + index; // convert negative indices to positive
            if (index >= numSegments || index < 0) throw new Error('Index out of range.');

            return segments[index];
        }