当前位置: 首页>>代码示例>>Java>>正文


Java SequentialWriter.open方法代码示例

本文整理汇总了Java中org.apache.cassandra.io.util.SequentialWriter.open方法的典型用法代码示例。如果您正苦于以下问题:Java SequentialWriter.open方法的具体用法?Java SequentialWriter.open怎么用?Java SequentialWriter.open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.cassandra.io.util.SequentialWriter的用法示例。


在下文中一共展示了SequentialWriter.open方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeMetadata

import org.apache.cassandra.io.util.SequentialWriter; //导入方法依赖的package包/类
private static void writeMetadata(Descriptor desc, Map<MetadataType, MetadataComponent> components)
{
    SequentialWriter out = SequentialWriter.open(new File(desc.filenameFor(Component.STATS)));
    try
    {
        desc.getMetadataSerializer().serialize(components, out.stream);
    }
    catch (IOException e)
    {
        throw new FSWriteError(e, out.getPath());
    }
    finally
    {
        out.close();
    }
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:17,代码来源:SSTableWriter.java

示例2: SSTableWriter

import org.apache.cassandra.io.util.SequentialWriter; //导入方法依赖的package包/类
public SSTableWriter(String filename,
                     long keyCount,
                     long repairedAt,
                     CFMetaData metadata,
                     IPartitioner<?> partitioner,
                     MetadataCollector sstableMetadataCollector)
{
    super(Descriptor.fromFilename(filename),
          components(metadata),
          metadata,
          partitioner);
    this.repairedAt = repairedAt;
    iwriter = new IndexWriter(keyCount);

    if (compression)
    {
        dataFile = SequentialWriter.open(getFilename(),
                                         descriptor.filenameFor(Component.COMPRESSION_INFO),
                                         metadata.compressionParameters(),
                                         sstableMetadataCollector);
        dbuilder = SegmentedFile.getCompressedBuilder((CompressedSequentialWriter) dataFile);
    }
    else
    {
        dataFile = SequentialWriter.open(new File(getFilename()), new File(descriptor.filenameFor(Component.CRC)));
        dbuilder = SegmentedFile.getBuilder(DatabaseDescriptor.getDiskAccessMode());
    }

    this.sstableMetadataCollector = sstableMetadataCollector;
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:31,代码来源:SSTableWriter.java

示例3: IndexWriter

import org.apache.cassandra.io.util.SequentialWriter; //导入方法依赖的package包/类
IndexWriter(long keyCount)
{
    indexFile = SequentialWriter.open(new File(descriptor.filenameFor(Component.PRIMARY_INDEX)));
    builder = SegmentedFile.getBuilder(DatabaseDescriptor.getIndexAccessMode());
    summary = new IndexSummaryBuilder(keyCount, metadata.getMinIndexInterval(), Downsampling.BASE_SAMPLING_LEVEL);
    bf = FilterFactory.getFilter(keyCount, metadata.getBloomFilterFpChance(), true);
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:8,代码来源:SSTableWriter.java

示例4: testLength

import org.apache.cassandra.io.util.SequentialWriter; //导入方法依赖的package包/类
@Test
public void testLength() throws IOException {
    File tmpFile = File.createTempFile("lengthtest", "bin");
    SequentialWriter w = SequentialWriter.open(tmpFile);
    assertEquals(0, w.length());

    // write a chunk smaller then our buffer, so will not be flushed
    // to disk
    byte[] lessThenBuffer = generateByteArray(RandomAccessReader.DEFAULT_BUFFER_SIZE / 2);
    w.write(lessThenBuffer);
    assertEquals(lessThenBuffer.length, w.length());

    // sync the data and check length
    w.sync();
    assertEquals(lessThenBuffer.length, w.length());

    // write more then the buffer can hold and check length
    byte[] biggerThenBuffer = generateByteArray(RandomAccessReader.DEFAULT_BUFFER_SIZE * 2);
    w.write(biggerThenBuffer);
    assertEquals(biggerThenBuffer.length + lessThenBuffer.length, w.length());

    w.close();

    // will use cachedlength
    RandomAccessReader r = RandomAccessReader.open(new Path(tmpFile.getPath()), fs);
    assertEquals(lessThenBuffer.length + biggerThenBuffer.length, r.length());
    r.close();
}
 
开发者ID:fullcontact,项目名称:hadoop-sstable,代码行数:29,代码来源:BufferedRandomAccessFileTest.java

示例5: tempCacheFile

import org.apache.cassandra.io.util.SequentialWriter; //导入方法依赖的package包/类
private SequentialWriter tempCacheFile(Pair<String, String> pathInfo)
{
    File path = getCachePath(pathInfo.left, pathInfo.right, CURRENT_VERSION);
    File tmpFile = FileUtils.createTempFile(path.getName(), null, path.getParentFile());
    return SequentialWriter.open(tmpFile, true);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:7,代码来源:AutoSavingCache.java

示例6: testReadMethods

import org.apache.cassandra.io.util.SequentialWriter; //导入方法依赖的package包/类
@Test
public void testReadMethods() throws IOException
{
    // Make sure this array is bigger than the reader buffer size
    // so we test updating the crc across buffer boundaries
    byte[] b = new byte[RandomAccessReader.DEFAULT_BUFFER_SIZE * 2];
    for (int i = 0; i < b.length; i++)
        b[i] = (byte)i;

    ByteBuffer buffer;

    // fill a bytebuffer with some input
    try (DataOutputBuffer out = new DataOutputBuffer())
    {
        out.write(127);
        out.write(b);
        out.writeBoolean(false);
        out.writeByte(10);
        out.writeChar('t');
        out.writeDouble(3.3);
        out.writeFloat(2.2f);
        out.writeInt(42);
        out.writeLong(Long.MAX_VALUE);
        out.writeShort(Short.MIN_VALUE);
        out.writeUTF("utf");
        out.writeVInt(67L);
        out.writeUnsignedVInt(88L);
        out.writeBytes("abcdefghi");

        buffer = out.buffer();
    }

    // calculate expected CRC
    CRC32 crc = new CRC32();
    FBUtilities.updateChecksum(crc, buffer);

    // save the buffer to file to create a RAR
    File file = File.createTempFile("testReadMethods", "1");
    file.deleteOnExit();
    try (SequentialWriter writer = SequentialWriter.open(file))
    {
        writer.write(buffer);
        writer.writeInt((int) crc.getValue());
        writer.finish();
    }

    assertTrue(file.exists());
    assertEquals(buffer.remaining() + 4, file.length());

    try (ChecksummedDataInput reader = ChecksummedDataInput.open(file))
    {
        reader.limit(buffer.remaining() + 4);

        // assert that we read all the right values back
        assertEquals(127, reader.read());
        byte[] bytes = new byte[b.length];
        reader.readFully(bytes);
        assertTrue(Arrays.equals(bytes, b));
        assertEquals(false, reader.readBoolean());
        assertEquals(10, reader.readByte());
        assertEquals('t', reader.readChar());
        assertEquals(3.3, reader.readDouble());
        assertEquals(2.2f, reader.readFloat());
        assertEquals(42, reader.readInt());
        assertEquals(Long.MAX_VALUE, reader.readLong());
        assertEquals(Short.MIN_VALUE, reader.readShort());
        assertEquals("utf", reader.readUTF());
        assertEquals(67L, reader.readVInt());
        assertEquals(88L, reader.readUnsignedVInt());
        assertEquals("abcdefghi", new String(ByteBufferUtil.read(reader, 9).array(), StandardCharsets.UTF_8));

        // assert that the crc matches, and that we've read exactly as many bytes as expected
        assertTrue(reader.checkCrc());
        assertEquals(0, reader.bytesRemaining());

        reader.checkLimit(0);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:79,代码来源:ChecksummedDataInputTest.java

示例7: testResetCrc

import org.apache.cassandra.io.util.SequentialWriter; //导入方法依赖的package包/类
@Test
public void testResetCrc() throws IOException
{
    CRC32 crc = new CRC32();
    ByteBuffer buffer;

    // fill a bytebuffer with some input
    try (DataOutputBuffer out = new DataOutputBuffer())
    {
        out.write(127);
        out.writeBoolean(false);
        out.writeByte(10);
        out.writeChar('t');

        buffer = out.buffer();
        FBUtilities.updateChecksum(crc, buffer);
        out.writeInt((int) crc.getValue());

        int bufferPos = out.getLength();
        out.writeDouble(3.3);
        out.writeFloat(2.2f);
        out.writeInt(42);

        buffer = out.buffer();
        buffer.position(bufferPos);
        crc.reset();
        FBUtilities.updateChecksum(crc, buffer);

        out.writeInt((int) crc.getValue());
        buffer = out.buffer();
    }

    // save the buffer to file to create a RAR
    File file = File.createTempFile("testResetCrc", "1");
    file.deleteOnExit();
    try (SequentialWriter writer = SequentialWriter.open(file))
    {
        writer.write(buffer);
        writer.finish();
    }

    assertTrue(file.exists());
    assertEquals(buffer.remaining(), file.length());

    try (ChecksummedDataInput reader = ChecksummedDataInput.open(file))
    {
        reader.limit(buffer.remaining());

        // assert that we read all the right values back
        assertEquals(127, reader.read());
        assertEquals(false, reader.readBoolean());
        assertEquals(10, reader.readByte());
        assertEquals('t', reader.readChar());
        assertTrue(reader.checkCrc());

        reader.resetCrc();
        assertEquals(3.3, reader.readDouble());
        assertEquals(2.2f, reader.readFloat());
        assertEquals(42, reader.readInt());
        assertTrue(reader.checkCrc());
        assertEquals(0, reader.bytesRemaining());
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:64,代码来源:ChecksummedDataInputTest.java

示例8: testFailedCrc

import org.apache.cassandra.io.util.SequentialWriter; //导入方法依赖的package包/类
@Test
public void testFailedCrc() throws IOException
{
    CRC32 crc = new CRC32();
    ByteBuffer buffer;

    // fill a bytebuffer with some input
    try (DataOutputBuffer out = new DataOutputBuffer())
    {
        out.write(127);
        out.writeBoolean(false);
        out.writeByte(10);
        out.writeChar('t');

        buffer = out.buffer();
        FBUtilities.updateChecksum(crc, buffer);

        // update twice so it won't match
        FBUtilities.updateChecksum(crc, buffer);
        out.writeInt((int) crc.getValue());

        buffer = out.buffer();
    }

    // save the buffer to file to create a RAR
    File file = File.createTempFile("testFailedCrc", "1");
    file.deleteOnExit();
    try (SequentialWriter writer = SequentialWriter.open(file))
    {
        writer.write(buffer);
        writer.finish();
    }

    assertTrue(file.exists());
    assertEquals(buffer.remaining(), file.length());

    try (ChecksummedDataInput reader = ChecksummedDataInput.open(file))
    {
        reader.limit(buffer.remaining());

        // assert that we read all the right values back
        assertEquals(127, reader.read());
        assertEquals(false, reader.readBoolean());
        assertEquals(10, reader.readByte());
        assertEquals('t', reader.readChar());
        assertFalse(reader.checkCrc());
        assertEquals(0, reader.bytesRemaining());
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:50,代码来源:ChecksummedDataInputTest.java

示例9: tempCacheFile

import org.apache.cassandra.io.util.SequentialWriter; //导入方法依赖的package包/类
private SequentialWriter tempCacheFile(UUID cfId)
{
    File path = getCachePath(cfId, CURRENT_VERSION);
    File tmpFile = FileUtils.createTempFile(path.getName(), null, path.getParentFile());
    return SequentialWriter.open(tmpFile);
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:7,代码来源:AutoSavingCache.java

示例10: tempCacheFile

import org.apache.cassandra.io.util.SequentialWriter; //导入方法依赖的package包/类
private SequentialWriter tempCacheFile(CacheKey.PathInfo pathInfo)
{
    File path = getCachePath(pathInfo.keyspace, pathInfo.columnFamily, pathInfo.cfId, CURRENT_VERSION);
    File tmpFile = FileUtils.createTempFile(path.getName(), null, path.getParentFile());
    return SequentialWriter.open(tmpFile, true);
}
 
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:7,代码来源:AutoSavingCache.java

示例11: createTempFile

import org.apache.cassandra.io.util.SequentialWriter; //导入方法依赖的package包/类
private SequentialWriter createTempFile(String name) throws IOException {
    File tempFile = File.createTempFile(name, null);
    tempFile.deleteOnExit();

    return SequentialWriter.open(tempFile);
}
 
开发者ID:fullcontact,项目名称:hadoop-sstable,代码行数:7,代码来源:BufferedRandomAccessFileTest.java


注:本文中的org.apache.cassandra.io.util.SequentialWriter.open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。