本文整理汇总了Java中org.apache.cassandra.db.composites.SimpleDenseCellNameType类的典型用法代码示例。如果您正苦于以下问题:Java SimpleDenseCellNameType类的具体用法?Java SimpleDenseCellNameType怎么用?Java SimpleDenseCellNameType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SimpleDenseCellNameType类属于org.apache.cassandra.db.composites包,在下文中一共展示了SimpleDenseCellNameType类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getIndexComparator
import org.apache.cassandra.db.composites.SimpleDenseCellNameType; //导入依赖的package包/类
/**
* Returns the index comparator for index backed by CFS, or null.
*
* Note: it would be cleaner to have this be a member method. However we need this when opening indexes
* sstables, but by then the CFS won't be fully initiated, so the SecondaryIndex object won't be accessible.
*/
public static CellNameType getIndexComparator(CFMetaData baseMetadata, ColumnDefinition cdef)
{
switch (cdef.getIndexType())
{
case KEYS:
return new SimpleDenseCellNameType(keyComparator);
case COMPOSITES:
return CompositesIndex.getIndexComparator(baseMetadata, cdef);
case CUSTOM:
return null;
}
throw new AssertionError();
}
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:20,代码来源:SecondaryIndex.java
示例2: testSerializeDeserialize
import org.apache.cassandra.db.composites.SimpleDenseCellNameType; //导入依赖的package包/类
@Test
public void testSerializeDeserialize() throws IOException
{
CounterContext.ContextState state = CounterContext.ContextState.allocate(0, 2, 2);
state.writeRemote(CounterId.fromInt(1), 4L, 4L);
state.writeLocal(CounterId.fromInt(2), 4L, 4L);
state.writeRemote(CounterId.fromInt(3), 4L, 4L);
state.writeLocal(CounterId.fromInt(4), 4L, 4L);
CellNameType type = new SimpleDenseCellNameType(UTF8Type.instance);
CounterCell original = new BufferCounterCell(cellname("x"), state.context, 1L);
byte[] serialized;
try (DataOutputBuffer bufOut = new DataOutputBuffer())
{
type.columnSerializer().serialize(original, bufOut);
serialized = bufOut.getData();
}
ByteArrayInputStream bufIn = new ByteArrayInputStream(serialized, 0, serialized.length);
CounterCell deserialized = (CounterCell) type.columnSerializer().deserialize(new DataInputStream(bufIn));
Assert.assertEquals(original, deserialized);
bufIn = new ByteArrayInputStream(serialized, 0, serialized.length);
CounterCell deserializedOnRemote = (CounterCell) type.columnSerializer().deserialize(new DataInputStream(bufIn), ColumnSerializer.Flag.FROM_REMOTE);
Assert.assertEquals(deserializedOnRemote.name(), original.name());
Assert.assertEquals(deserializedOnRemote.total(), original.total());
Assert.assertEquals(deserializedOnRemote.value(), cc.clearAllLocal(original.value()));
Assert.assertEquals(deserializedOnRemote.timestamp(), deserialized.timestamp());
Assert.assertEquals(deserializedOnRemote.timestampOfLastDelete(), deserialized.timestampOfLastDelete());
}
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:32,代码来源:CounterCellTest.java
示例3: test6791
import org.apache.cassandra.db.composites.SimpleDenseCellNameType; //导入依赖的package包/类
@Test
public void test6791() throws IOException, ConfigurationException
{
File f = File.createTempFile("compressed6791_", "3");
String filename = f.getAbsolutePath();
try
{
MetadataCollector sstableMetadataCollector = new MetadataCollector(new SimpleDenseCellNameType(BytesType.instance));
CompressedSequentialWriter writer = new CompressedSequentialWriter(f, filename + ".metadata", new CompressionParameters(SnappyCompressor.instance, 32, Collections.<String, String>emptyMap()), sstableMetadataCollector);
for (int i = 0; i < 20; i++)
writer.write("x".getBytes());
FileMark mark = writer.mark();
// write enough garbage to create new chunks:
for (int i = 0; i < 40; ++i)
writer.write("y".getBytes());
writer.resetAndTruncate(mark);
for (int i = 0; i < 20; i++)
writer.write("x".getBytes());
writer.close();
CompressedRandomAccessReader reader = CompressedRandomAccessReader.open(filename, new CompressionMetadata(filename + ".metadata", f.length(), true));
String res = reader.readLine();
assertEquals(res, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
assertEquals(40, res.length());
}
finally
{
// cleanup
if (f.exists())
f.delete();
File metadata = new File(filename+ ".metadata");
if (metadata.exists())
metadata.delete();
}
}
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:41,代码来源:CompressedRandomAccessReaderTest.java
示例4: testSerializeDeserialize
import org.apache.cassandra.db.composites.SimpleDenseCellNameType; //导入依赖的package包/类
@Test
public void testSerializeDeserialize() throws IOException
{
Allocator allocator = HeapAllocator.instance;
CounterContext.ContextState state = CounterContext.ContextState.allocate(0, 2, 2, allocator);
state.writeRemote(CounterId.fromInt(1), 4L, 4L);
state.writeLocal(CounterId.fromInt(2), 4L, 4L);
state.writeRemote(CounterId.fromInt(3), 4L, 4L);
state.writeLocal(CounterId.fromInt(4), 4L, 4L);
CellNameType type = new SimpleDenseCellNameType(UTF8Type.instance);
CounterCell original = new CounterCell(cellname("x"), state.context, 1L);
byte[] serialized;
try (DataOutputBuffer bufOut = new DataOutputBuffer())
{
type.columnSerializer().serialize(original, bufOut);
serialized = bufOut.getData();
}
ByteArrayInputStream bufIn = new ByteArrayInputStream(serialized, 0, serialized.length);
CounterCell deserialized = (CounterCell) type.columnSerializer().deserialize(new DataInputStream(bufIn));
Assert.assertEquals(original, deserialized);
bufIn = new ByteArrayInputStream(serialized, 0, serialized.length);
CounterCell deserializedOnRemote = (CounterCell) type.columnSerializer().deserialize(new DataInputStream(bufIn), ColumnSerializer.Flag.FROM_REMOTE);
Assert.assertEquals(deserializedOnRemote.name(), original.name());
Assert.assertEquals(deserializedOnRemote.total(), original.total());
Assert.assertEquals(deserializedOnRemote.value(), cc.clearAllLocal(original.value()));
Assert.assertEquals(deserializedOnRemote.timestamp(), deserialized.timestamp());
Assert.assertEquals(deserializedOnRemote.timestampOfLastDelete(), deserialized.timestampOfLastDelete());
}
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:33,代码来源:CounterCellTest.java
示例5: testSerializeDeserialize
import org.apache.cassandra.db.composites.SimpleDenseCellNameType; //导入依赖的package包/类
@Test
public void testSerializeDeserialize() throws IOException
{
CounterContext.ContextState state = CounterContext.ContextState.allocate(0, 2, 2);
state.writeRemote(CounterId.fromInt(1), 4L, 4L);
state.writeLocal(CounterId.fromInt(2), 4L, 4L);
state.writeRemote(CounterId.fromInt(3), 4L, 4L);
state.writeLocal(CounterId.fromInt(4), 4L, 4L);
CellNameType type = new SimpleDenseCellNameType(UTF8Type.instance);
CounterCell original = new CounterCell(cellname("x"), state.context, 1L);
byte[] serialized;
try (DataOutputBuffer bufOut = new DataOutputBuffer())
{
type.columnSerializer().serialize(original, bufOut);
serialized = bufOut.getData();
}
ByteArrayInputStream bufIn = new ByteArrayInputStream(serialized, 0, serialized.length);
CounterCell deserialized = (CounterCell) type.columnSerializer().deserialize(new DataInputStream(bufIn));
Assert.assertEquals(original, deserialized);
bufIn = new ByteArrayInputStream(serialized, 0, serialized.length);
CounterCell deserializedOnRemote = (CounterCell) type.columnSerializer().deserialize(new DataInputStream(bufIn), ColumnSerializer.Flag.FROM_REMOTE);
Assert.assertEquals(deserializedOnRemote.name(), original.name());
Assert.assertEquals(deserializedOnRemote.total(), original.total());
Assert.assertEquals(deserializedOnRemote.value(), cc.clearAllLocal(original.value()));
Assert.assertEquals(deserializedOnRemote.timestamp(), deserialized.timestamp());
Assert.assertEquals(deserializedOnRemote.timestampOfLastDelete(), deserialized.timestampOfLastDelete());
}
开发者ID:rajath26,项目名称:cassandra-trunk,代码行数:32,代码来源:CounterCellTest.java
示例6: setUp
import org.apache.cassandra.db.composites.SimpleDenseCellNameType; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
underTest = new StudentEventMapper();
conf = new Configuration(false);
Counter mockCounter = mock(Counter.class);
when(mockedContext.getConfiguration()).thenReturn(conf);
when(mockedContext.getCounter(anyString(), anyString())).thenReturn(mockCounter);
this.simpleDenseCellType = new SimpleDenseCellNameType(BytesType.instance);
}
开发者ID:Knewton,项目名称:KassandraMRHelper,代码行数:10,代码来源:StudentEventMapperTest.java
示例7: setUp
import org.apache.cassandra.db.composites.SimpleDenseCellNameType; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
this.underTest = new DoNothingColumnMapper();
this.keyVal = "testKey";
this.columnNameVal = "testColumnName";
this.columnValue = "testColumnValue";
this.simpleDenseCellType = new SimpleDenseCellNameType(BytesType.instance);
}
开发者ID:Knewton,项目名称:KassandraMRHelper,代码行数:9,代码来源:SSTableCellMapperTest.java
示例8: setUp
import org.apache.cassandra.db.composites.SimpleDenseCellNameType; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
conf = new Configuration();
attemptId = new TaskAttemptID();
Path inputPath = new Path(TABLE_PATH_STR);
inputSplit = new FileSplit(inputPath, 0, 1, null);
Descriptor desc = new Descriptor(new File(TABLE_PATH_STR), "keyspace", "columnFamily", 1,
Type.FINAL);
doReturn(desc).when(ssTableColumnRecordReader).getDescriptor();
doNothing().when(ssTableColumnRecordReader).copyTablesToLocal(any(FileSystem.class),
any(FileSystem.class),
any(Path.class),
any(TaskAttemptContext.class));
doReturn(ssTableReader).when(ssTableColumnRecordReader)
.openSSTableReader(any(IPartitioner.class), any(CFMetaData.class));
when(ssTableReader.estimatedKeys()).thenReturn(2L);
when(ssTableReader.getScanner()).thenReturn(tableScanner);
when(tableScanner.hasNext()).thenReturn(true, true, false);
key = new BufferDecoratedKey(new StringToken("a"), ByteBuffer.wrap("b".getBytes()));
CellNameType simpleDenseCellType = new SimpleDenseCellNameType(BytesType.instance);
CellName cellName = simpleDenseCellType.cellFromByteBuffer(ByteBuffer.wrap("n".getBytes()));
ByteBuffer counterBB = CounterContext.instance()
.createGlobal(CounterId.fromInt(0), System.currentTimeMillis(), 123L);
value = BufferCounterCell.create(cellName, counterBB, System.currentTimeMillis(), 0L,
Flag.PRESERVE_SIZE);
SSTableIdentityIterator row1 = getNewRow();
SSTableIdentityIterator row2 = getNewRow();
when(tableScanner.next()).thenReturn(row1, row2);
}
开发者ID:Knewton,项目名称:KassandraMRHelper,代码行数:38,代码来源:SSTableColumnRecordReaderTest.java
示例9: testSerialization
import org.apache.cassandra.db.composites.SimpleDenseCellNameType; //导入依赖的package包/类
@Test
public void testSerialization() throws IOException
{
EstimatedHistogram rowSizes = new EstimatedHistogram(new long[] { 1L, 2L },
new long[] { 3L, 4L, 5L });
EstimatedHistogram columnCounts = new EstimatedHistogram(new long[] { 6L, 7L },
new long[] { 8L, 9L, 10L });
ReplayPosition rp = new ReplayPosition(11L, 12);
long minTimestamp = 2162517136L;
long maxTimestamp = 4162517136L;
MetadataCollector collector = new MetadataCollector(new SimpleDenseCellNameType(BytesType.instance))
.estimatedRowSize(rowSizes)
.estimatedColumnCount(columnCounts)
.replayPosition(rp);
collector.updateMinTimestamp(minTimestamp);
collector.updateMaxTimestamp(maxTimestamp);
Set<Integer> ancestors = Sets.newHashSet(1, 2, 3, 4);
for (int i : ancestors)
collector.addAncestor(i);
String partitioner = RandomPartitioner.class.getCanonicalName();
double bfFpChance = 0.1;
Map<MetadataType, MetadataComponent> originalMetadata = collector.finalizeMetadata(partitioner, bfFpChance, 0);
MetadataSerializer serializer = new MetadataSerializer();
// Serialize to tmp file
File statsFile = File.createTempFile(Component.STATS.name, null);
try (DataOutputStreamAndChannel out = new DataOutputStreamAndChannel(new FileOutputStream(statsFile)))
{
serializer.serialize(originalMetadata, out);
}
Descriptor desc = new Descriptor(Descriptor.Version.CURRENT, statsFile.getParentFile(), "", "", 0, Descriptor.Type.FINAL);
try (RandomAccessReader in = RandomAccessReader.open(statsFile))
{
Map<MetadataType, MetadataComponent> deserialized = serializer.deserialize(desc, in, EnumSet.allOf(MetadataType.class));
for (MetadataType type : MetadataType.values())
{
assertEquals(originalMetadata.get(type), deserialized.get(type));
}
}
}
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:46,代码来源:MetadataSerializerTest.java
示例10: testDataCorruptionDetection
import org.apache.cassandra.db.composites.SimpleDenseCellNameType; //导入依赖的package包/类
@Test
public void testDataCorruptionDetection() throws IOException
{
String CONTENT = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vitae.";
File file = new File("testDataCorruptionDetection");
file.deleteOnExit();
File metadata = new File(file.getPath() + ".meta");
metadata.deleteOnExit();
MetadataCollector sstableMetadataCollector = new MetadataCollector(new SimpleDenseCellNameType(BytesType.instance)).replayPosition(null);
SequentialWriter writer = new CompressedSequentialWriter(file, metadata.getPath(), new CompressionParameters(SnappyCompressor.instance), sstableMetadataCollector);
writer.write(CONTENT.getBytes());
writer.close();
// open compression metadata and get chunk information
CompressionMetadata meta = new CompressionMetadata(metadata.getPath(), file.length(), true);
CompressionMetadata.Chunk chunk = meta.chunkFor(0);
RandomAccessReader reader = CompressedRandomAccessReader.open(file.getPath(), meta);
// read and verify compressed data
assertEquals(CONTENT, reader.readLine());
// close reader
reader.close();
Random random = new Random();
RandomAccessFile checksumModifier = null;
try
{
checksumModifier = new RandomAccessFile(file, "rw");
byte[] checksum = new byte[4];
// seek to the end of the compressed chunk
checksumModifier.seek(chunk.length);
// read checksum bytes
checksumModifier.read(checksum);
// seek back to the chunk end
checksumModifier.seek(chunk.length);
// lets modify one byte of the checksum on each iteration
for (int i = 0; i < checksum.length; i++)
{
checksumModifier.write(random.nextInt());
checksumModifier.getFD().sync(); // making sure that change was synced with disk
final RandomAccessReader r = CompressedRandomAccessReader.open(file.getPath(), meta);
Throwable exception = null;
try
{
r.readLine();
}
catch (Throwable t)
{
exception = t;
}
assertNotNull(exception);
assertEquals(exception.getClass(), CorruptSSTableException.class);
assertEquals(exception.getCause().getClass(), CorruptBlockException.class);
r.close();
}
// lets write original checksum and check if we can read data
updateChecksum(checksumModifier, chunk.length, checksum);
reader = CompressedRandomAccessReader.open(file.getPath(), meta);
// read and verify compressed data
assertEquals(CONTENT, reader.readLine());
// close reader
reader.close();
}
finally
{
if (checksumModifier != null)
checksumModifier.close();
}
}
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:82,代码来源:CompressedRandomAccessReaderTest.java
示例11: testSerialization
import org.apache.cassandra.db.composites.SimpleDenseCellNameType; //导入依赖的package包/类
@Test
public void testSerialization() throws IOException
{
EstimatedHistogram rowSizes = new EstimatedHistogram(new long[] { 1L, 2L },
new long[] { 3L, 4L, 5L });
EstimatedHistogram columnCounts = new EstimatedHistogram(new long[] { 6L, 7L },
new long[] { 8L, 9L, 10L });
ReplayPosition rp = new ReplayPosition(11L, 12);
long minTimestamp = 2162517136L;
long maxTimestamp = 4162517136L;
MetadataCollector collector = new MetadataCollector(new SimpleDenseCellNameType(BytesType.instance))
.estimatedRowSize(rowSizes)
.estimatedColumnCount(columnCounts)
.replayPosition(rp);
collector.updateMinTimestamp(minTimestamp);
collector.updateMaxTimestamp(maxTimestamp);
Set<Integer> ancestors = Sets.newHashSet(1, 2, 3, 4);
for (int i : ancestors)
collector.addAncestor(i);
String partitioner = RandomPartitioner.class.getCanonicalName();
double bfFpChance = 0.1;
Map<MetadataType, MetadataComponent> originalMetadata = collector.finalizeMetadata(partitioner, bfFpChance);
MetadataSerializer serializer = new MetadataSerializer();
// Serialize to tmp file
File statsFile = File.createTempFile(Component.STATS.name, null);
try (DataOutputStream out = new DataOutputStream(new FileOutputStream(statsFile)))
{
serializer.serialize(originalMetadata, out);
}
Descriptor desc = new Descriptor(Descriptor.Version.CURRENT, statsFile.getParentFile(), "", "", 0, false);
try (RandomAccessReader in = RandomAccessReader.open(statsFile))
{
Map<MetadataType, MetadataComponent> deserialized = serializer.deserialize(desc, in, EnumSet.allOf(MetadataType.class));
for (MetadataType type : MetadataType.values())
{
assertEquals(originalMetadata.get(type), deserialized.get(type));
}
}
}
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:46,代码来源:MetadataSerializerTest.java
示例12: testSerialization
import org.apache.cassandra.db.composites.SimpleDenseCellNameType; //导入依赖的package包/类
@Test
public void testSerialization() throws IOException
{
EstimatedHistogram rowSizes = new EstimatedHistogram(new long[] { 1L, 2L },
new long[] { 3L, 4L, 5L });
EstimatedHistogram columnCounts = new EstimatedHistogram(new long[] { 6L, 7L },
new long[] { 8L, 9L, 10L });
ReplayPosition rp = new ReplayPosition(11L, 12);
long minTimestamp = 2162517136L;
long maxTimestamp = 4162517136L;
MetadataCollector collector = new MetadataCollector(new SimpleDenseCellNameType(BytesType.instance))
.estimatedRowSize(rowSizes)
.estimatedColumnCount(columnCounts)
.replayPosition(rp);
collector.updateMinTimestamp(minTimestamp);
collector.updateMaxTimestamp(maxTimestamp);
Set<Integer> ancestors = Sets.newHashSet(1, 2, 3, 4);
for (int i : ancestors)
collector.addAncestor(i);
String partitioner = RandomPartitioner.class.getCanonicalName();
double bfFpChance = 0.1;
Map<MetadataType, MetadataComponent> originalMetadata = collector.finalizeMetadata(partitioner, bfFpChance, 0);
MetadataSerializer serializer = new MetadataSerializer();
// Serialize to tmp file
File statsFile = File.createTempFile(Component.STATS.name, null);
try (DataOutputStreamAndChannel out = new DataOutputStreamAndChannel(new FileOutputStream(statsFile)))
{
serializer.serialize(originalMetadata, out);
}
Descriptor desc = new Descriptor(Descriptor.Version.CURRENT, statsFile.getParentFile(), "", "", 0, false);
try (RandomAccessReader in = RandomAccessReader.open(statsFile))
{
Map<MetadataType, MetadataComponent> deserialized = serializer.deserialize(desc, in, EnumSet.allOf(MetadataType.class));
for (MetadataType type : MetadataType.values())
{
assertEquals(originalMetadata.get(type), deserialized.get(type));
}
}
}
开发者ID:rajath26,项目名称:cassandra-trunk,代码行数:46,代码来源:MetadataSerializerTest.java
注:本文中的org.apache.cassandra.db.composites.SimpleDenseCellNameType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论