public void AddRawRecord(byte[] rawRecord) { if (_recordFileWriters == null) { _recordFileWriters = new RecordFileWriter[_recordFilesOut.Length]; for (int i = 0; i < _recordFilesOut.Length; i++) { _recordFileWriters[i] = new RecordFileWriter(_recordFilesOut[i], _recordInstance); _recordFileWriters[i].AddedRecordsInSortedOrder = _isSorted; } // we could have been set by the customHasher property otherwise... if (_hasher == null) { _hasher = new TMSNStoreHasher(); } } // if we're bucketting based on begin strings if (_bucketBoundaryBeginBytes != null) { while ((_currentBoundaryNo != _bucketBoundaryBeginBytes.Length - 1) && (TMSNStoreUtils.Utf8BytesCompare(_bucketBoundaryBeginBytes[_currentBoundaryNo+1], rawRecord) >= 0)) { _currentBoundaryNo++; } //_recordFileWriters. _recordFileWriters[_currentBoundaryNo].AddRawRecord(rawRecord); } // else if we only have one bucket else if (_recordFileWriters.Length == 1) { _recordFileWriters[0].AddRawRecord(rawRecord); } // else we have multiple buckets and we bucket based on a hash of the key else { // the default hasher respects null termination. uint bucketNo = _hasher.GetHashCode(rawRecord, rawRecord.Length) % (uint)_recordFileWriters.Length; _recordFileWriters[bucketNo].AddRawRecord(rawRecord); } }
public void Write() { if (_input == null) { throw new Exception("only for use with set input property"); } // we could have been set by the customHasher property otherwise... if (_hasher == null) { _hasher = new TMSNStoreHasher(); } // if we have a gettable then iterate through them otherwise our Add method was used while (_input.MoveNext()) { //foreach (byte[] rawRecord in _recordFilter) { byte[] rawRecord = _input.CurrentRawRecord; // increment the currentBucketNo until the key is >= the corresponding bucket // beginString or until we reach the last bucket //AddRawRecord(rawRecord); } }