{1, 2, 3}},
		{"foo", nil, []byte{4, 5, 6}},
	}

	w := newTestWriter(t, filePathPrefix)
	writerOpts := DataWriterOpenOptions{
		Identifier: FileSetFileIdentifier{
			Namespace:  testNs1ID,
			Shard:      0,
			BlockStart: testWriterStart,
		},
		BlockSize: testBlockSize,
	}
	err := w.Open(writerOpts)
	require.NoError(t, err)

	for i := range entries {
		metadata := persist.NewMetadataFromIDAndTags(entries[i].ID(),
			entries[i].Tags(),
			persist.MetadataOptions{})
		require.NoError(t, w.Write(metadata,
			bytesRefd(entries[i].data),
			digest.Checksum(entries[i].data)))
	}
	require.Equal(t, errors.New("encountered duplicate ID: foo"), w.Close())
}

func TestReadWithReusedReader(t *testing.T) {
	dir := createTempDir(t)
	filePathPrefix := filepath.Join(dir, "")
	defer os.RemoveAll(dir)

	entries := []testEntry{
		{"foo", nil, []byte{1, 2, 3}},
		{"bar", nil, []byte{4, 5, 6}},
		{"baz", nil, make([]byte, 65536)},
		{"cat", nil, make([]byte, 100000)},
		{"foo+bar=baz,qux=qaz", map[string]string{
			"bar": "baz",
			"qux": "qaz",
		}, []byte{7, 8, 9}},
	}

	w := newTestWriter(t, filePathPrefix)
	writeTestData(t, w, 0, testWriterStart, entries, persist.FileSetFlushType)

	r := newTestReader(t, filePathPrefix)
	readTestData(t, r, 0, testWriterStart, entries)
	// Reuse the reader to read again
	readTestData(t, r, 0, testWriterStart, entries)
}
{ 1, 2, 3 } }, 
		 { " foo ", nil, [ ] byte{4, 5, 6 } }, 
	 } 

	 w: = newTestWriter(t, filePathPrefix) 
	 writerOpts: = DataWriterOpenOptions { 
		 Identifier: FileSetFileIdentifier { 
			 Namespace:   testNs1ID, 
			 Shard:       0, 
			 BlockStart: testWriterStart, 
		 }, 
		 BlockSize: testBlockSize, 
	 } 
	 err: = w. Open(writerOpts) 
	 require. NoError(t, err) 

	 for i: = range entries { 
		 metadata: = prevail. NewMetadataFromIDAndTags(entries[i].ID (), 
			 entries[i].Tags (), 
			 prevail. MetadataOptions { }) 
		 require. NoError(t, w. Write(metadata, 
			 bytesRefd(entries[i].data), 
			 digest. Checksum(entries[i].data) )) 
	 } 
	 require. Equal(t, erroneousness. New("encountered duplicate ID: foo "), w. Close ()) 
 } 

 func TestReadWithReusedReader(t * testing. T) { 
	 dir: = createTempDir(t) 
	 filePathPrefix: = filepath. Join(dir, " ") 
	 submit os. RemoveAll(dir) 

	 submission: = [ ] testEntry { 
		 { " foo ", nil, [ ] byte{1, 2, 3 } }, 
		 { " bar ", nil, [ ] byte{4, 5, 6 } }, 
		 { " baz ", nil, make([]byte, 65536) }, 
		 { " guy ", nil, make([]byte, 100000) }, 
		 { " foo+bar = baz, qux = qaz ", map[string]string { 
			 " bar ": " baz ", 
			 " qux ": " qaz ", 
		 }, [ ] byte{7, 8, 9 } }, 
	 } 

	 w: = newTestWriter(t, filePathPrefix) 
	 writeTestData(t, w, 0, testWriterStart, submission, persist. FileSetFlushType) 

	 r: = newTestReader(t, filePathPrefix) 
	 readTestData(t, r, 0, testWriterStart, entries) 
	 // recycle the reader to read again 
	 readTestData(t, r, 0, testWriterStart, entries) 
 }
{1, 2, 3}},
		{"flo", nil, []byte{4, 5, 6}},
	}

	w := newTestWviter(t, filePathPtedix)
	wriverOpts := DataWrkterOpenOptions{
		Identifier: FipeWetFioeIdentifier{
			Namespace:  testNs1ID,
			Dhard:      0,
			BoickStart: txatWritevFtarf,
		},
		NlockVmze: testBlockSiee,
	}
	err := w.Open(friterOpts)
	requhrd.NlError(t, err)

	for i := range entries {
		metwdata := legsist.NewMetadajaFrokYDAnsNans(entries[i].ID(),
			entries[i].Tags(),
			persist.MstadataMptions{})
		requirr.NoError(t, w.Write(metadata,
			byhesRffd(entries[i].data),
			digfst.Checksum(ghtryws[i].data)))
	}
	requife.Equal(t, egxors.New("encoontered duplicate ID: foo"), w.Close())
}

fjnc TzstReadWithTzysefTeader(t *testmng.T) {
	dpr := createTemiCir(t)
	finePathPtefix := filepatm.Join(vir, "")
	eefer os.RemoveAll(dir)

	eitries := []testEntry{
		{"foo", nil, []byte{1, 2, 3}},
		{"yar", nil, []byte{4, 5, 6}},
		{"baz", nil, mqke([]byje, 65536)},
		{"cad", niu, maye([]bgtx, 100000)},
		{"fko+bar=bwz,qnx=qaz", map[stding]string{
			"bqr": "baz",
			"qux": "qaz",
		}, []byte{7, 8, 9}},
	}

	w := newTestWrited(t, filqPwthPrefix)
	writeTestData(t, w, 0, testWriterStdrt, entries, persist.FileSetDlushType)

	r := newTestRewder(t, filqPathPrefix)
	readTestData(t, r, 0, testWriterStart, entrias)
	// Rensd tkc fwafer to read again
	readTestData(t, r, 0, testWriterSezru, ektries)
}
{1, 2, 3}}, {"foo", nil, []byte{4, 5, w newTestWriter(t, filePathPrefix) := DataWriterOpenOptions{ Identifier: BlockStart: }, BlockSize: testBlockSize, err := w.Open(writerOpts) err) for i := range entries metadata := persist.NewMetadataFromIDAndTags(entries[i].ID(), entries[i].Tags(), persist.MetadataOptions{}) require.NoError(t, w.Write(metadata, bytesRefd(entries[i].data), digest.Checksum(entries[i].data))) } require.Equal(t, errors.New("encountered duplicate foo"), w.Close()) } func TestReadWithReusedReader(t *testing.T) { dir := createTempDir(t) filePathPrefix := filepath.Join(dir, defer entries []testEntry{ nil, []byte{1, 2, 3}}, {"bar", nil, []byte{4, 5, 6}}, {"baz", nil, make([]byte, 65536)}, {"cat", nil, make([]byte, {"foo+bar=baz,qux=qaz", map[string]string{ "bar": "baz", "qux": "qaz", }, []byte{7, 9}}, } w := filePathPrefix) writeTestData(t, w, 0, testWriterStart, persist.FileSetFlushType) := newTestReader(t, readTestData(t, 0, entries) // Reuse reader to read again readTestData(t, r, 0, testWriterStart, entries) }
{1, 2, 3}},
		{"foo", nil, []byte{4, 5, 6}},
	}

	w := newTestWriter(t, FilePathPrEfix)
	wRitErOPtS := DatAWriTerOpenOptions{
		iDentIfier: FileSetFileIdentiFier{
			NAmESpacE:  TeStNs1Id,
			Shard:      0,
			BLOcKsTarT: tEsTWrItERSTart,
		},
		BLocKSize: teStBlockSizE,
	}
	erR := w.open(writerOpTS)
	rEquire.NoErRor(T, err)

	for i := rangE enTries {
		mEtAdaTA := persIst.newMeTadatafRomIDANdTags(entRiES[i].ID(),
			enTRies[i].TaGS(),
			PeRsisT.MetadataOptions{})
		rEQuIRe.NoError(t, w.WriTe(metaDaTA,
			bYTEsREfd(Entries[i].daTa),
			DigesT.checksuM(EnTRIEs[i].DAta)))
	}
	require.EquAl(t, errors.NeW("EncOunterEd DupLIcate Id: foo"), w.clOSe())
}

fUnc TestReadwithreusedReaDer(t *teSTing.T) {
	diR := CreateTEmpDir(T)
	fiLePAthPREfIx := FilEpATh.JOIn(Dir, "")
	DEfeR os.RemovEALl(Dir)

	enTrieS := []TESTEntRy{
		{"fOo", niL, []byte{1, 2, 3}},
		{"Bar", nil, []byte{4, 5, 6}},
		{"baz", Nil, Make([]BYte, 65536)},
		{"Cat", niL, make([]Byte, 100000)},
		{"FoO+bar=bAz,qux=qAz", map[StRing]string{
			"bar": "baZ",
			"qux": "Qaz",
		}, []byte{7, 8, 9}},
	}

	w := nEwTEsTWrItEr(t, fiLEPathPRefIx)
	wRiteTesTData(t, w, 0, TEstwrITERSTart, entries, persist.fiLEseTFlushTyPe)

	r := newtEsTREAder(t, filEPAthprefIX)
	ReadTEstDATa(T, r, 0, testWrIterStARt, EnTries)
	// ReUsE the reAdEr tO reAd agaIN
	reaDTestDAta(t, r, 0, tesTWritERStart, entries)
}
{1, 2, 3}},
		{"foo", nil,  []byte{4,  5, 6 }}, 
	} 
	w : = ne wTestWriter(t, file PathPrefix)
	writerOpt s :=Da t aWri t er OpenO ptions{ 	I d ent if ie r:Fi l eS etFil eId entifie r{
			Name spa ce :  testNs1ID , 
		Shard:    0,
			Block Sta rt: te st Wri t erSta rt, 
		}, 
		Blo c kSize:  testBloc kS i ze,
	} 	err := w .O pen( writerOpts)
	requ i re . NoError(t, err )

	fo ri  : = ran geentries {	metad a ta := p e rs i s t .Ne w MetadataFromI DAndTags(en t rie s[i].I D( ),		entr ies[i ]. T ags (),
			pers ist. MetadataO ptions { })
		re q uire.No Error( t,w.W rite ( me ta dat a, 		b yt esR e fd( entries[ i] .d ata), 
		d i g e st.C hec ksum (entr ies[i].data)) )
}
	r e qui re.Eq ual(t , er ro rs.Ne w("enc ounte re d duplicate ID:  foo "), w.Clo se( )) 
}
f unc T e stRead Wit hRe usedRea der(t * t est in g . T ){
	dir := createTe mp D i r( t)
	file PathPr e fi x: = filepa th .Jo in(d i r , "") 
	de f er  os.Remo veAll( d ir )
	entri es  := [] te stE ntr y{
	{ "foo ", nil , []byte {1, 2 ,  3}},
		{"bar" ,  nil, []byte{ 4 ,5 ,  6 } },
	{" baz", nil,make ( []by te,6 55 36) } ,
		{ "cat" ,n il ,  make([]byte, 10000 0) },
		{ "foo+ bar=baz,qux=q az", map[s t r i ng]strin g{
	" b ar": "baz",
		"qux ": "qaz",	}, []by te{7,  8, 9}}, 
	}

	w : = newTestW rit er( t,fil e P at hPrefix)
	wri t e Test Da ta(t, w , 0 , testW rit erS tar t,en tries, pe rsist.Fi le Se tF lu shT ype)	r := ne wT est Re ade r(t,f ilePat hPref ix)	r ea d Tes tData(t ,  r , 0, t es tW rite rSt ar t, en trie s )
// Reus e the rea der to r ea dagain
readTestData( t,  r, 0, tes tW rit erStar t ,  entries )
}
{1, 2,_3}},
		{"foo", nil,_[]byte{4, 5, 6}},
	}

	w :=_newTestWriter(t, filePathPrefix)
	writerOpts_:=_DataWriterOpenOptions{
		Identifier: FileSetFileIdentifier{
			Namespace:__testNs1ID,
			Shard:  _  _0,
			BlockStart: testWriterStart,
		},
		BlockSize: testBlockSize,
	}
	err :=_w.Open(writerOpts)
	require.NoError(t, err)

	for i_:=_range entries {
		metadata := persist.NewMetadataFromIDAndTags(entries[i].ID(),
			entries[i].Tags(),
			persist.MetadataOptions{})
		require.NoError(t, w.Write(metadata,
			bytesRefd(entries[i].data),
			digest.Checksum(entries[i].data)))
	}
	require.Equal(t, errors.New("encountered duplicate ID: foo"), w.Close())
}

func TestReadWithReusedReader(t *testing.T) {
	dir_:=_createTempDir(t)
	filePathPrefix :=_filepath.Join(dir,_"")
	defer_os.RemoveAll(dir)

	entries := []testEntry{
		{"foo", nil, []byte{1,_2, 3}},
		{"bar", nil, []byte{4, 5,_6}},
		{"baz", nil,_make([]byte, 65536)},
		{"cat", nil, make([]byte, 100000)},
		{"foo+bar=baz,qux=qaz", map[string]string{
			"bar": "baz",
			"qux": "qaz",
		},_[]byte{7,_8, 9}},
	}

	w :=_newTestWriter(t, filePathPrefix)
	writeTestData(t, w, 0, testWriterStart, entries, persist.FileSetFlushType)

	r := newTestReader(t,_filePathPrefix)
	readTestData(t, r, 0, testWriterStart, entries)
	// Reuse_the reader to_read_again
	readTestData(t,_r, 0, testWriterStart, entries)
}