Opens a new segment writer with a specified sequence. Called by the GC
which has multiple segments with the same sequence number.

@param sequence the sequence id for the new segment.
328770
public OutSegment openWriterGc(long sequence)
  {
    int segmentSize = _segmentSizeGc;
    
    SegmentKelp segment = _segmentService.createSegment(segmentSize, getTableKey(), sequence);
    
    addTableSegmentLength(segmentSize);
    
    return new OutSegment(_table, _table.getTableService(), this, segment);
  }
141901
public void write(DataOutputStream stream, byte sequenceId) throws IOException {
        this.sequenceId = sequenceId;
        stream.write(PREAMBLE);
        stream.write(sequenceId);
        stream.write(action.getCode());
        stream.write(buffer.toArray());
        stream.write(Constants.EOD);
    }
29939
@Override
    public Object mapSequence(Object sequence) {
        List<?> seq = (List<?>) sequence;
        List<Object> out = new ArrayList<>();
        for (Object step : seq) {
            out.add(map(step));
        }
        return out;
    }
619500
public static void writeFasta(final OutputStream outstream,
		final List<FastaSequence> sequences, final int width)
		throws IOException {
	final OutputStreamWriter writer = new OutputStreamWriter(outstream);
	final BufferedWriter fastawriter = new BufferedWriter(writer);
	for (final FastaSequence fs : sequences) {
		fastawriter.write(fs.getFormatedSequence(width));
	}
	outstream.flush();
	fastawriter.close();
	writer.close();
	}
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);
        }
      }
    }
  }
772805
public void setCommandSequence(long sequence) {
    // For each increment of the sequence number, trigger query callbacks that are dependent on the specific sequence.
    for (long i = commandSequence + 1; i <= sequence; i++) {
      commandSequence = i;
      List<Runnable> queries = this.sequenceQueries.remove(commandSequence);
      if (queries != null) {
        for (Runnable query : queries) {
          query.run();
        }
      }
    }
  }
140479
public void addAlignedSequence(S sequence){
		if(length == null){
			length = sequence.getLength();
		}
		if(sequence.getLength() != length){
			throw new IllegalArgumentException(sequence.getAccession() + " length = " + sequence.getLength() +
					" not equal to MSA length = " + length);
		}
		sequences.add(sequence);
	}
210526
public OutSegment openWriter()
  {
    if (isGcRequired()) {
      // _gcSequence = _seqGen.get();
      _table.getGcService().gc(_seqGen.get());
      _seqSinceGcCount = 0;
    }
    
    _seqSinceGcCount++;
    long sequence = _seqGen.get();
    
    return openWriterSeq(sequence);
  }
1285026
public void fitOnSequences(Integer[][] sequences) {
        documentCount += 1;
        for (Integer[] sequence: sequences) {
            Set<Integer> sequenceSet = new HashSet<>(Arrays.asList(sequence));
            for (Integer index: sequenceSet)
                indexDocs.put(index, indexDocs.get(index) + 1);
        }
    }
567920
@Override
	public T visitAnySequence(AnySequenceContext ctx) {
//		on(ctx);
		appendAst(ctx, tok(SEQUENCE));
		return super.visitAnySequence(ctx);
	}
355662
private static StreamDescriptor copyStreamDescriptorWithSequence(StreamDescriptor streamDescriptor, int sequence)
    {
        List<StreamDescriptor> streamDescriptors = streamDescriptor.getNestedStreams().stream()
                .map(stream -> copyStreamDescriptorWithSequence(stream, sequence))
                .collect(toImmutableList());

        return new StreamDescriptor(
                streamDescriptor.getStreamName(),
                streamDescriptor.getStreamId(),
                streamDescriptor.getFieldName(),
                streamDescriptor.getStreamType(),
                streamDescriptor.getOrcDataSource(),
                streamDescriptors,
                sequence);
    }
76040
@Override
    protected void appendCharSequence(EncodingState encodingState, CharSequence csq, int start, int end) throws IOException {
        CharSequences.writeCharSequence(target, csq, start, end);
    }
1193398
public void initNewList(int maxNumberOfTerms) throws IOException {
    if (closed) {
      result = null;
      closed = false;
    }
    if (segmentRegistration != null) {
      throw new IOException("missing segment name");
    } else {
      initNewListBasic(maxNumberOfTerms);
    }
  }
751410
public List<Statement> createSequencesStatements(Iterable<Sequence> sequences) {
		List<Statement> statements = new ArrayList<Statement>();
		for ( Sequence sequence : sequences ) {
			addSequence( statements, sequence );
		}
		return statements;
	}
691820
public void sequence(FA seq) {
        int idx;
        int relocation;

        relocation = append(seq);

        if (seq.start != -1) {
            for (idx = ends.first(); idx != -1; idx = ends.next(idx)) {
                states[idx].add(relocation + seq.start, null);
            }
        }

        ends.clear();
        for (idx = seq.ends.first(); idx != -1; idx = seq.ends.next(idx)) {
            ends.add(idx + relocation);
        }
    }
1254186
public static void writeCharSequence(Writer target, CharSequence csq, int start, int end) throws IOException {
        final Class<?> csqClass = csq.getClass();
        if (csqClass == String.class) {
            target.write((String)csq, start, end - start);
        }
        else if (csqClass == StringBuffer.class) {
            char[] buf = new char[end - start];
            ((StringBuffer)csq).getChars(start, end, buf, 0);
            target.write(buf);
        }
        else if (csqClass == StringBuilder.class) {
            char[] buf = new char[end - start];
            ((StringBuilder)csq).getChars(start, end, buf, 0);
            target.write(buf);
        }
        else if (csq instanceof CharArrayAccessible) {
            char[] buf = new char[end - start];
            ((CharArrayAccessible)csq).getChars(start, end, buf, 0);
            target.write(buf);
        }
        else {
            String str = csq.subSequence(start, end).toString();
            target.write(str, 0, str.length());
        }
    }
581753
public void setSequenceNumber(long value) {
        Preconditions.checkState(this.sequenceNumber < 0, "Sequence Number has been previously set for this entry. Cannot set a new one.");
        Exceptions.checkArgument(value >= 0, "value", "Sequence Number must be a non-negative number.");

        this.sequenceNumber = value;
    }