src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
HConfiguration extends HBaseConfiguration { public static SConfiguration getConfiguration() { return new HConfiguration().init(); } private HConfiguration(); static SConfiguration getConfiguration(); static SConfiguration reloadConfiguration(Configuration resetConfiguration); static Configuration unwrapDelegate(); @Ov... | @Test public void testPrefixMatch() throws Exception { SConfiguration config = HConfiguration.getConfiguration(); Map<String, String> auths = config.prefixMatch("splice.authentication.*"); String key = "splice.authentication"; String value = auths.get(key); assertNotNull(value); assertEquals("NON-NATIVE", value); key =... |
SICompactionStateMutate { public long mutate(List<Cell> rawList, List<TxnView> txns, List<Cell> results) throws IOException { handleSanityChecks(results, rawList, txns); long totalSize = 0; try { Iterator<TxnView> it = txns.iterator(); for (Cell cell : rawList) { totalSize += KeyValueUtil.length(cell); TxnView txn = it... | @Test public void mutateEmpty() throws IOException { cutNoPurge.mutate(inputCells, transactions, outputCells); assertThat(outputCells, is(empty())); }
@Test public void mutateSimpleOneActiveTransaction() throws IOException { inputCells.addAll(Arrays.asList( SITestUtils.getMockValueCell(200), SITestUtils.getMockValueCel... |
FormatableBitSet implements Formatable, Cloneable { public void shrink(int n) { if (SanityManager.DEBUG) { SanityManager.ASSERT(invariantHolds(), "broken invariant"); } if (n < 0 || n > lengthAsBits) { throw new IllegalArgumentException("Bit set cannot shrink from "+ lengthAsBits+" to "+n+" bits"); } final int firstUnu... | @Test public void testShrink() { bitset18.shrink(9); assertEquals(9, bitset18.getLength()); assertEquals(2, bitset18.getLengthInBytes()); assertEquals(5, bitset18.getNumBitsSet()); assertTrue(bitset18.invariantHolds()); assertEquals(2, bitset18.getByteArray().length); }
@Test public void testShrinkLarger() { try { bits... |
RingBuffer { public boolean isFull() { return size() == buffer.length; } RingBuffer(int bufferSize); T next(); void add(T element); int size(); int bufferSize(); @SuppressWarnings("unchecked") T peek(); boolean isFull(); boolean isEmpty(); void expand(); void readReset(); void readAdvance(); void clear(); void mark(); ... | @Test public void isFull() { RingBuffer<Integer> buffer = new RingBuffer<Integer>(4); buffer.add(10); assertFalse(buffer.isFull()); buffer.add(10); assertFalse(buffer.isFull()); buffer.add(10); assertFalse(buffer.isFull()); buffer.add(10); assertTrue(buffer.isFull()); } |
RingBuffer { public int size() { return writePosition - readPosition; } RingBuffer(int bufferSize); T next(); void add(T element); int size(); int bufferSize(); @SuppressWarnings("unchecked") T peek(); boolean isFull(); boolean isEmpty(); void expand(); void readReset(); void readAdvance(); void clear(); void mark(); ... | @Test public void size() { RingBuffer<Integer> buffer = new RingBuffer<Integer>(16); assertEquals(0, buffer.size()); buffer.add(42); assertEquals(1, buffer.size()); buffer.add(42); assertEquals(2, buffer.size()); buffer.clear(); assertEquals(0, buffer.size()); } |
RingBuffer { public void clear() { readPosition = writePosition; offsetReadPosition = readPosition; } RingBuffer(int bufferSize); T next(); void add(T element); int size(); int bufferSize(); @SuppressWarnings("unchecked") T peek(); boolean isFull(); boolean isEmpty(); void expand(); void readReset(); void readAdvance()... | @Test public void clear() throws Exception { int bufferSize = 10; RingBuffer<Integer> buffer = new RingBuffer<Integer>(bufferSize); for (int i = 0; i < bufferSize; i++) { buffer.add(i); } buffer.clear(); assertEquals(0, buffer.size()); assertFalse(buffer.isFull()); assertTrue(buffer.isEmpty()); assertNull("Should not s... |
RingBuffer { public void expand() { buffer = Arrays.copyOf(buffer, 2 * buffer.length); mask = buffer.length - 1; } RingBuffer(int bufferSize); T next(); void add(T element); int size(); int bufferSize(); @SuppressWarnings("unchecked") T peek(); boolean isFull(); boolean isEmpty(); void expand(); void readReset(); void ... | @Test public void expand() { RingBuffer<Integer> buffer = new RingBuffer<Integer>(2); buffer.add(10); buffer.add(20); assertTrue(buffer.isFull()); buffer.expand(); assertFalse(buffer.isFull()); buffer.add(30); buffer.add(40); assertTrue(buffer.isFull()); assertEquals(4, buffer.size()); assertEquals(4, buffer.bufferSize... |
Partition { public static <T> Iterable<List<T>> partition(Collection<T> coll, final int size, final int steps, final boolean pad){ final List<T> c = new ArrayList<T>(coll); final int collSize = c.size(); int padding = Math.max(needsPadding(collSize, size, steps), 0); if (pad && padding > 0) { for (int i = 0; i < paddin... | @Test public void testPartitions() throws Exception { Assert.assertEquals(l(Iterables.toArray(Partition.partition(testColl, 2), Object.class)), l(l(10, 20), l(30, 40), l(50, 60))); Assert.assertEquals(l(Iterables.toArray(Partition.partition(testColl, 2, 1), Object.class)), l(l(10, 20), l(20, 30), l(30, 40), l(40, 50), ... |
Streams { @SafeVarargs public static <T> Stream<T> of(T...elements){ return new ArrayStream<>(elements); } @SafeVarargs static Stream<T> of(T...elements); static Stream<T> wrap(Iterator<T> iterator); static Stream<T> wrap(Iterable<T> iterable); static PeekableStream<T> peekingStream(Stream<T> stream); @SuppressWarning... | @Test public void of() throws StreamException { Stream<String> stream = Streams.of("111", "222", "333"); assertEquals("111", stream.next()); assertEquals("222", stream.next()); assertEquals("333", stream.next()); } |
Streams { public static <T> Stream<T> wrap(Iterator<T> iterator){ return new IteratorStream<>(iterator); } @SafeVarargs static Stream<T> of(T...elements); static Stream<T> wrap(Iterator<T> iterator); static Stream<T> wrap(Iterable<T> iterable); static PeekableStream<T> peekingStream(Stream<T> stream); @SuppressWarning... | @Test public void wrap() throws StreamException { List<String> list = Lists.newArrayList("111", "222", "333"); Stream<String> stream1 = Streams.wrap(list); Stream<String> stream2 = Streams.wrap(list.iterator()); assertEquals("111", stream1.next()); assertEquals("111", stream2.next()); assertEquals("222", stream1.next()... |
Streams { public static <T> PeekableStream<T> peekingStream(Stream<T> stream){ return new PeekingStream<>(stream); } @SafeVarargs static Stream<T> of(T...elements); static Stream<T> wrap(Iterator<T> iterator); static Stream<T> wrap(Iterable<T> iterable); static PeekableStream<T> peekingStream(Stream<T> stream); @Suppr... | @Test public void peekingStream() throws StreamException { Stream<String> stream = Streams.of("111", "222", "333"); PeekableStream<String> stream1 = Streams.peekingStream(stream); assertEquals("111", stream1.peek()); assertEquals("111", stream1.next()); assertEquals("222", stream1.peek()); assertEquals("222", stream1.n... |
FormatableBitSet implements Formatable, Cloneable { public int compare(FormatableBitSet other) { int otherCount, thisCount; int otherLen, thisLen; byte[] otherb; otherb = other.value; otherLen = other.getLengthInBytes(); thisLen = getLengthInBytes(); for (otherCount = 0, thisCount = 0; otherCount < otherLen && thisCoun... | @Test public void testCompareSameEmpty() { assertEquals(0, empty.compare(empty)); }
@Test public void testCompareAnotherEmpty() { assertEquals(0, empty.compare(new FormatableBitSet())); }
@Test public void testCompare18Empty() { assertEquals(1, bitset18.compare(new FormatableBitSet())); }
@Test public void testCompareE... |
AbstractStream implements Stream<T> { @Override public void forEach(Accumulator<T> accumulator) throws StreamException { T n; while((n = next())!=null){ accumulator.accumulate(n); } } @Override Stream<V> transform(Transformer<T, V> transformer); @Override void forEach(Accumulator<T> accumulator); @Override Stream<T> f... | @Test public void forEach() throws StreamException { SumAccumulator accumulator = new SumAccumulator(); new IntegerStream().forEach(accumulator); assertEquals(45, accumulator.sum); } |
AbstractStream implements Stream<T> { @Override public <V> Stream<V> transform(Transformer<T, V> transformer) { return new TransformingStream<>(this,transformer); } @Override Stream<V> transform(Transformer<T, V> transformer); @Override void forEach(Accumulator<T> accumulator); @Override Stream<T> filter(Predicate<T> ... | @Test public void transform() throws StreamException { SumAccumulator accumulator = new SumAccumulator(); new IntegerStream().transform(new NegateTransformer()).forEach(accumulator); assertEquals(-45, accumulator.sum); } |
Threads { public static void sleep(long duration, TimeUnit timeUnit) { try { Thread.sleep(timeUnit.toMillis(duration)); } catch (InterruptedException e) { throw new IllegalStateException(e); } } private Threads(); static void sleep(long duration, TimeUnit timeUnit); } | @Test public void sleep() { long startTime = System.currentTimeMillis(); Threads.sleep(100, TimeUnit.MILLISECONDS); long elapsedTime = System.currentTimeMillis() - startTime; assertTrue(elapsedTime < 1000); assertTrue(elapsedTime > 75); } |
CountDownLatches { public static void uncheckedAwait(CountDownLatch countDownLatch) { try { countDownLatch.await(); } catch (InterruptedException e) { throw new IllegalStateException(e); } } static void uncheckedAwait(CountDownLatch countDownLatch); static boolean uncheckedAwait(CountDownLatch countDownLatch, long tim... | @Test public void testUncheckedAwait() throws Exception { final CountDownLatch latch = new CountDownLatch(1); new Thread() { @Override public void run() { latch.countDown(); } }.start(); CountDownLatches.uncheckedAwait(latch); }
@Test public void testUncheckedAwaitWithTimeout() throws Exception { final CountDownLatch l... |
MoreExecutors { public static ExecutorService namedSingleThreadExecutor(String nameFormat, boolean isDaemon) { ThreadFactory factory = new ThreadFactoryBuilder() .setNameFormat(nameFormat) .setDaemon(isDaemon) .build(); return Executors.newSingleThreadExecutor(factory); } private MoreExecutors(); static ExecutorServic... | @Test public void newSingleThreadExecutor_usesThreadWithExpectedName() throws Exception { ExecutorService executorService = MoreExecutors.namedSingleThreadExecutor("testName-%d", false); Future<String> threadName = executorService.submit(new GetThreadNameCallable()); Future<Boolean> isDaemon = executorService.submit(ne... |
MoreExecutors { public static ScheduledExecutorService namedSingleThreadScheduledExecutor(String nameFormat) { ThreadFactory factory = new ThreadFactoryBuilder() .setNameFormat(nameFormat) .setDaemon(true) .build(); return new LoggingScheduledThreadPoolExecutor(1, factory); } private MoreExecutors(); static ExecutorSe... | @Test public void namedSingleThreadScheduledExecutor() throws Exception { ScheduledExecutorService executorService = MoreExecutors.namedSingleThreadScheduledExecutor("testName-%d"); Future<String> threadName = executorService.submit(new GetThreadNameCallable()); Future<Boolean> isDaemon = executorService.submit(new IsD... |
MoreExecutors { public static ThreadPoolExecutor namedThreadPool(int coreWorkers, int maxWorkers, String nameFormat, long keepAliveSeconds, boolean isDaemon) { ThreadFactory factory = new ThreadFactoryBuilder() .setNameFormat(nameFormat) .setDaemon(isDaemon) .build(); return new ThreadPoolExecutor(coreWorkers, maxWorke... | @Test public void namedThreadPool() throws Exception { final int CORE_POOL_SIZE = 1 + new Random().nextInt(9); final int MAX_POOL_SIZE = CORE_POOL_SIZE + new Random().nextInt(9); final int KEEP_ALIVE_SEC = new Random().nextInt(100); final boolean IS_DAEMON = new Random().nextBoolean(); ThreadPoolExecutor executorServic... |
LongStripedSynchronizer { public static LongStripedSynchronizer<ReadWriteLock> stripedReadWriteLock(int stripes, final boolean fair){ int s = getNearestPowerOf2(stripes); return new LongStripedSynchronizer<ReadWriteLock>(s,new Supplier<ReadWriteLock>() { @Override public ReadWriteLock get() { return new ReentrantReadWr... | @Test public void stripedReadWriteLock() { LongStripedSynchronizer<ReadWriteLock> striped = LongStripedSynchronizer.stripedReadWriteLock(128, false); Set<ReadWriteLock> locks = Sets.newIdentityHashSet(); for (long i = 0; i < 2000; i++) { ReadWriteLock e = striped.get(i); locks.add(e); } assertEquals(128, locks.size());... |
Snowflake { public long nextUUID(){ long timestamp; short count; synchronized (this){ timestamp = System.currentTimeMillis(); if(timestamp<lastTimestamp) throw new IllegalStateException("Unable to obtain timestamp, clock moved backwards"); if(timestamp==lastTimestamp){ if(counter==0) while(timestamp ==lastTimestamp) ti... | @Test public void testcanCreateAUUID() throws Exception { Snowflake snowflake = new Snowflake((short)(1<<6)); long uuid = snowflake.nextUUID(); Assert.assertTrue(uuid != 0); }
@Test public void testNoDuplicateUUIDsInASingleThread() throws Exception { Set<Long> uuidSet = new TreeSet<Long>(); Snowflake snowflake = new Sn... |
Snowflake { public static long timestampFromUUID(long uuid) { return (uuid & TIMESTAMP_LOCATION) >> TIMESTAMP_SHIFT; } Snowflake(short machineId); static long timestampFromUUID(long uuid); byte[] nextUUIDBytes(); void nextUUIDBlock(long[] uuids); long nextUUID(); Generator newGenerator(int blockSize); @Override String ... | @Test public void timestampFromUUID() { assertEquals(1402425368772L, Snowflake.timestampFromUUID(-2074918693534679039l)); assertEquals(1402425369637L, Snowflake.timestampFromUUID(-7920591009858039807l)); assertEquals(1402425368822L, Snowflake.timestampFromUUID(-903982790418145279l)); assertEquals(1402425369571L, Snowfl... |
Snowflake { @Override public String toString() { return "Snowflake{" + "lastTimestamp=" + lastTimestamp + ", counter=" + counter + ", machineId=" + machineId + '}'; } Snowflake(short machineId); static long timestampFromUUID(long uuid); byte[] nextUUIDBytes(); void nextUUIDBlock(long[] uuids); long nextUUID(); Generato... | @Test public void toString_includesExpectedMachineId() { assertEquals("Snowflake{lastTimestamp=0, counter=0, machineId=2}", new Snowflake((short) (1 << 1)).toString()); assertEquals("Snowflake{lastTimestamp=0, counter=0, machineId=4}", new Snowflake((short) (1 << 2)).toString()); assertEquals("Snowflake{lastTimestamp=0... |
Murmur64 implements Hash64 { @Override public long hash(String elem) { assert elem!=null: "Cannot hash a null element"; int length = elem.length(); long h = initialize(seed,length); int pos =0; char[] chars = elem.toCharArray(); while(length-pos>=8){ h = hash(h, LittleEndianBits.toLong(chars, pos)); pos+=8; } h = updat... | @Test public void testByteBufferSameAsByteArray() throws Exception { long correct = hasher.hash(sampleData,0,sampleData.length); ByteBuffer bb = ByteBuffer.wrap(sampleData); long actual = hasher.hash(bb); Assert.assertEquals(correct,actual); }
@Test public void testIntSameAsByteArray() throws Exception { byte[] bytes =... |
Murmur32 implements Hash32 { @Override public int hash(String elem) { assert elem!=null: "Cannot hash a null element!"; int h = seed; int length = elem.length(); int pos = 0; int visited =0; char[] chars = elem.toCharArray(); while(length-visited>=4){ int k1 = LittleEndianBits.toInt(chars, pos); h = mutate(h,k1); pos+=... | @Test public void testMatchesGoogleVersionMurmur332() throws Exception { HashCode hashCode = Hashing.murmur3_32(0).hashBytes(sampleData, 0, sampleData.length); int actual =hashCode.asInt(); int hash = murmur32.hash(sampleData, 0, sampleData.length); Assert.assertEquals(actual,hash); }
@Test public void testMatchesGoogl... |
QuoteTrackingTokenizer extends AbstractTokenizer { @Override public boolean readColumns(final List<String> columns) throws IOException { return readColumns(columns, null); } QuoteTrackingTokenizer(final Reader reader, final CsvPreference preferences, final boolean oneLineRecord, boolean quotedEmptyIsNull); QuoteTracki... | @Test public void quotedMultiRowRecordWithOneLineRecordSetThrowsProperly() throws Exception { String invalidRow = "\"hello\",\"wrong\ncell\",goodbye\n"; try { QuoteTrackingTokenizer qtt = new QuoteTrackingTokenizer(new StringReader(invalidRow), CsvPreference.STANDARD_PREFERENCE, true, true); List<String> columns = new ... |
BareKeyHash { public static DataHash encoder(int[] keyColumns,boolean[] keySortOrder,DescriptorSerializer[] serializers){ return encoder(keyColumns,keySortOrder,SpliceKryoRegistry.getInstance(),serializers); } protected BareKeyHash(int[] keyColumns,
boolean[] keySortOrder,
... | @Test public void testProperlyEncodesValues() throws Exception { ExecRow execRow = new ValueRow(dataTypes.length); for(int i=0;i<dataTypes.length;i++){ execRow.setColumn(i + 1, row[i].cloneValue(true)); } int[] keyColumns= new int[dataTypes.length]; for(int i=0;i<keyColumns.length;i++){ keyColumns[i] = i; } DescriptorS... |
TimestampV2DescriptorSerializer extends TimestampV1DescriptorSerializer { public static long formatLong(Timestamp timestamp) throws StandardException { long millis = SQLTimestamp.checkV2Bounds(timestamp); long micros = timestamp.getNanos() / NANOS_TO_MICROS; return millis * MICROS_TO_SECOND + micros; } static long for... | @Test public void shouldFailOnSmallDate() { String errorCode = "N/A"; try { TimestampV2DescriptorSerializer.formatLong(getTimestamp(1677)); } catch (StandardException e) { errorCode = e.getSqlState(); } assertEquals(SQLState.LANG_DATE_TIME_ARITHMETIC_OVERFLOW, errorCode); }
@Test public void shouldFailOnLargeDate() { S... |
SpliceDateFunctions { public static Date ADD_MONTHS(Date source, Integer numOfMonths) { if (source == null || numOfMonths == null) return null; DateTime dt = new DateTime(source); return new Date(dt.plusMonths(numOfMonths).getMillis()); } static Date ADD_MONTHS(Date source, Integer numOfMonths); static Date ADD_DAYS(D... | @Test public void testAddMonth() { Calendar c = Calendar.getInstance(); Date t = new Date(c.getTime().getTime()); c.add(Calendar.MONTH, 2); Date s = new Date(c.getTime().getTime()); assertEquals(SpliceDateFunctions.ADD_MONTHS(t, 2), s); } |
SpliceDateFunctions { public static Date ADD_DAYS(Date source, Integer numOfDays) { if (source == null || numOfDays == null) return null; DateTime dt = new DateTime(source); return new Date(dt.plusDays(numOfDays).getMillis()); } static Date ADD_MONTHS(Date source, Integer numOfMonths); static Date ADD_DAYS(Date source... | @Test public void testAddDays() { Calendar c = Calendar.getInstance(); Date t = new Date(c.getTime().getTime()); c.add(Calendar.DAY_OF_MONTH, 2); Date s = new Date(c.getTime().getTime()); assertEquals(SpliceDateFunctions.ADD_DAYS(t, 2), s); } |
SpliceDateFunctions { public static Date ADD_YEARS(Date source, Integer numOfYears) { if (source == null || numOfYears == null) return null; DateTime dt = new DateTime(source); return new Date(dt.plusYears(numOfYears).getMillis()); } static Date ADD_MONTHS(Date source, Integer numOfMonths); static Date ADD_DAYS(Date s... | @Test public void testAddYears() { Calendar c = Calendar.getInstance(); Date t = new Date(c.getTime().getTime()); c.add(Calendar.YEAR, 2); Date s = new Date(c.getTime().getTime()); assertEquals(SpliceDateFunctions.ADD_YEARS(t, 2), s); } |
SpliceDateFunctions { public static Date LAST_DAY(Date source) { if (source == null) { return null; } DateTime dt = new DateTime(source).dayOfMonth().withMaximumValue(); return new Date(dt.getMillis()); } static Date ADD_MONTHS(Date source, Integer numOfMonths); static Date ADD_DAYS(Date source, Integer numOfDays); st... | @Test public void testLastDay() { Calendar c = Calendar.getInstance(); Date t = new Date(c.getTime().getTime()); c.set(Calendar.DAY_OF_MONTH, c.getActualMaximum(Calendar.DAY_OF_MONTH)); Date s = new Date(c.getTime().getTime()); assertEquals(SpliceDateFunctions.LAST_DAY(t), s); } |
SpliceDateFunctions { public static Date NEXT_DAY(Date source, String weekday) throws SQLException { if (source == null || weekday == null) return source; String lowerWeekday = weekday.toLowerCase(); if (!WEEK_DAY_MAP.containsKey(lowerWeekday)) { throw PublicAPI.wrapStandardException(ErrorState.LANG_INVALID_DAY.newExce... | @Test public void nextDay() throws ParseException, SQLException { Date date1 = new Date(DF.parse("2014/06/24").getTime()); Date date2 = new Date(DF.parse("2014/06/29").getTime()); Date date3 = new Date(DF.parse("2014/06/25").getTime()); Date date4 = new Date(DF.parse("2014/06/27").getTime()); Date date5 = new Date(DF.p... |
SpliceDateFunctions { public static double MONTH_BETWEEN(Date source1, Date source2) { if (source1 == null || source2 == null) return -1; DateTime dt1 = new DateTime(source1); DateTime dt2 = new DateTime(source2); return Months.monthsBetween(dt1, dt2).getMonths(); } static Date ADD_MONTHS(Date source, Integer numOfMon... | @Test public void monthBetween() { Calendar c = Calendar.getInstance(); Date t = new Date(c.getTime().getTime()); c.add(Calendar.MONTH, 3); Date s = new Date(c.getTime().getTime()); assertEquals(3.0, SpliceDateFunctions.MONTH_BETWEEN(t, s), 0.001); } |
SpliceDateFunctions { public static Date TO_DATE(String source) throws SQLException { return TO_DATE(source,null); } static Date ADD_MONTHS(Date source, Integer numOfMonths); static Date ADD_DAYS(Date source, Integer numOfDays); static Date ADD_YEARS(Date source, Integer numOfYears); static Timestamp TO_TIMESTAMP(Stri... | @Test public void toDate() throws SQLException, ParseException { String format = "yyyy/MM/dd"; String source = "2014/06/24"; DateFormat formatter = new SimpleDateFormat(format); Date date = new Date(formatter.parse(source).getTime()); assertEquals(date, SpliceDateFunctions.TO_DATE(source, format)); }
@Test public void ... |
SpliceDateFunctions { public static Timestamp TO_TIMESTAMP(String source) throws SQLException { return TO_TIMESTAMP(source,null); } static Date ADD_MONTHS(Date source, Integer numOfMonths); static Date ADD_DAYS(Date source, Integer numOfDays); static Date ADD_YEARS(Date source, Integer numOfYears); static Timestamp TO... | @Test public void toTimestamp() throws SQLException, ParseException { String format = "yyyy/MM/dd HH:mm:ss.SSS"; String source = "2014/06/24 12:13:14.123"; DateFormat formatter = new SimpleDateFormat("MM/dd/yy HH:mm:ss.SSS"); Timestamp date = new Timestamp(formatter.parse("06/24/2014 12:13:14.123").getTime()); assertEq... |
FormatableBitSet implements Formatable, Cloneable { public final boolean isSet(int position) { checkPosition(position); final int byteIndex = udiv8(position); final byte bitIndex = umod8(position); return ((value[byteIndex] & (0x80>>bitIndex)) != 0); } FormatableBitSet(); FormatableBitSet(int numBits); FormatableBitS... | @Test public void testIsSetEmpty() { try { empty.isSet(-8); fail(); } catch (IllegalArgumentException ignored) { } try { empty.isSet(-1); fail(); } catch (IllegalArgumentException ignored) { } try { empty.isSet(0); fail(); } catch (IllegalArgumentException ignored) { } }
@Test public void testIsSet() { try { bitset18C.... |
SpliceDateFunctions { public static Timestamp TRUNC_DATE(Timestamp source, String field) throws SQLException { if (source == null || field == null) return null; DateTime dt = new DateTime(source); field = field.toLowerCase(); String lowerCaseField = field.toLowerCase(); if ("microseconds".equals(lowerCaseField)) { int ... | @Test public void truncDate() throws ParseException, SQLException { assertEquals(timeStampT("2014/07/15 12:12:12.234"), TRUNC_DATE(timeStampT("2014/07/15 12:12:12.234"), "microseconds")); assertEquals(timeStampT("2014/07/15 12:12:12.234"), TRUNC_DATE(timeStampT("2014/07/15 12:12:12.234"), "milliseconds")); assertEquals... |
DDLWatchRefresher { public boolean refreshDDL(Set<DDLWatcher.DDLListener> callbacks) throws IOException{ Collection<String> ongoingDDLChangeIds=watchChecker.getCurrentChangeIds(); if(ongoingDDLChangeIds==null) return false; Set<Pair<DDLChange,String>> newChanges=new HashSet<>(); boolean currentWasEmpty=currentDDLChange... | @Test public void picksUpNonTentativeChange() throws Exception{ TestChecker checker=getTestChecker(); Clock clock = new IncrementingClock(0); TxnStore supplier = new TestingTxnStore(clock,new TestingTimestampSource(),null,100l); supplier.recordNewTransaction(txn); TestDDLWatchRefresher refresher = new TestDDLWatchRefre... |
AsynchronousDDLController implements DDLController, CommunicationListener { @Override public String notifyMetadataChange(DDLChange change) throws StandardException { String changeId = communicator.createChangeNode(change); long availableTime =maximumWaitTime; long elapsedTime = 0; Collection<String> finishedServers =Co... | @Test(expected=StandardException.class) public void timesOutIfServerRespondsAfterTimeout() throws Exception{ final List<String> servers = Arrays.asList("server1","server2"); final String changeId = "change"; final TickingClock clock = new IncrementingClock(0); final long timeout = 10l; final TestDDLCommunicator ddlComm... |
FormatableBitSet implements Formatable, Cloneable { public void set(int position) { checkPosition(position); final int byteIndex = udiv8(position); final byte bitIndex = umod8(position); value[byteIndex] |= (0x80>>bitIndex); } FormatableBitSet(); FormatableBitSet(int numBits); FormatableBitSet(byte[] newValue); Form... | @Test public void testSetEmpty() { try { empty.set(-8); fail(); } catch (IllegalArgumentException ignored) { } try { empty.set(-1); fail(); } catch (IllegalArgumentException ignored) { } try { empty.set(0); fail(); } catch (IllegalArgumentException ignored) { } }
@Test public void testSet() { try { bitset18.set(-8); fa... |
AbstractSequence implements Sequence, Externalizable { public long getNext() throws StandardException{ if(remaining.getAndDecrement()<=0) allocateBlock(false); return currPosition.getAndAdd(incrementSteps); } AbstractSequence(); AbstractSequence(long blockAllocationSize,long incrementSteps,long startingValue); long ge... | @Test public void singleThreaded100BlockSingleIncrementTestWithRollover() throws Exception { Sequence sequence = new SpliceTestSequence(100,1,0); for (long i = 0; i< 1000; i++) { long next = sequence.getNext(); Assert.assertTrue(i==next); } }
@Test public void singleThreaded1BlockSingleIncrementTestWithRollover() throw... |
DMLTriggerEventMapper { public static TriggerEvent getBeforeEvent(Class<? extends DMLWriteOperation> operationClass) { for (Map.Entry<Class<? extends DMLWriteOperation>, TriggerEvent> entry : beforeMap.entrySet()) { if (entry.getKey().isAssignableFrom(operationClass)) { return entry.getValue(); } } throw new IllegalArg... | @Test public void testGetBeforeEvent() throws Exception { assertEquals(TriggerEvent.BEFORE_DELETE, DMLTriggerEventMapper.getBeforeEvent(DeleteOperation.class)); assertEquals(TriggerEvent.BEFORE_INSERT, DMLTriggerEventMapper.getBeforeEvent(InsertOperation.class)); assertEquals(TriggerEvent.BEFORE_UPDATE, DMLTriggerEvent... |
DMLTriggerEventMapper { public static TriggerEvent getAfterEvent(Class<? extends DMLWriteOperation> operationClass) { for (Map.Entry<Class<? extends DMLWriteOperation>, TriggerEvent> entry : afterMap.entrySet()) { if (entry.getKey().isAssignableFrom(operationClass)) { return entry.getValue(); } } throw new IllegalArgum... | @Test public void testGetAfterEvent() throws Exception { assertEquals(TriggerEvent.AFTER_DELETE, DMLTriggerEventMapper.getAfterEvent(DeleteOperation.class)); assertEquals(TriggerEvent.AFTER_INSERT, DMLTriggerEventMapper.getAfterEvent(InsertOperation.class)); assertEquals(TriggerEvent.AFTER_UPDATE, DMLTriggerEventMapper... |
IndexRowReader implements Iterator<ExecRow>, Iterable<ExecRow> { public int getMaxConcurrency() {return this.numBlocks;} IndexRowReader(Iterator<ExecRow> sourceIterator,
ExecRow outputTemplate,
TxnView txn,
int lookupBatchSize,
int numConcurren... | @Test public void testReaderConcurrency() throws Exception { IndexRowReader irr = new IndexRowReader( null, null, null, 4000, 0, 0, null, null, null, null, null, null); assertTrue("Expected a max concurrency of 2", irr.getMaxConcurrency() == 2); irr = new IndexRowReader( null, null, null, 4000, -5000, 0, null, null, nu... |
ExportFile { public OutputStream getOutputStream() throws IOException { String fullyQualifiedExportFilePath = buildOutputFilePath(); OutputStream rawOutputStream =fileSystem.newOutputStream(fullyQualifiedExportFilePath, new DistributedFileOpenOption(exportParams.getReplicationCount(),StandardOpenOption.CREATE_NEW)); if... | @Test public void getOutputStream_createsStreamConnectedToExpectedFile() throws IOException { ExportParams exportParams = ExportParams.withDirectory(temporaryFolder.getRoot().getAbsolutePath()); ExportFile exportFile = new ExportFile(exportParams, testTaskId(),dfs); final byte[] EXPECTED_CONTENT = ("splice for the win"... |
ExportFile { protected String buildFilenameFromTaskId(byte[] taskId) { String postfix = ""; if (exportParams.getCompression() == COMPRESSION.BZ2) { postfix = ".bz2"; } else if (exportParams.getCompression() == COMPRESSION.GZ) { postfix = ".gz"; } return "export_" + Bytes.toHex(taskId) + ".csv" + postfix; } ExportFile(E... | @Test public void buildFilenameFromTaskId() throws IOException { ExportFile streamSetup = new ExportFile(new ExportParams(), testTaskId(),dfs); byte[] taskId = testTaskId(); assertEquals("export_82010203042A060708.csv", streamSetup.buildFilenameFromTaskId(taskId)); } |
ExportFile { public boolean delete() throws IOException { if (LOG.isDebugEnabled()) SpliceLogUtils.debug(LOG, "delete()"); try{ fileSystem.delete(exportParams.getDirectory(),buildFilenameFromTaskId(taskId), false); return true; }catch(NoSuchFileException fnfe){ return false; } } ExportFile(ExportParams exportParams, by... | @Test public void delete() throws IOException { ExportParams exportParams = ExportParams.withDirectory(temporaryFolder.getRoot().getAbsolutePath()); ExportFile exportFile = new ExportFile(exportParams, testTaskId(),dfs); exportFile.getOutputStream(); assertTrue("export file should exist in temp dir", temporaryFolder.ge... |
ExportFile { public boolean createDirectory() throws StandardException { if (LOG.isDebugEnabled()) SpliceLogUtils.debug(LOG, "createDirectory(): export directory=%s", exportParams.getDirectory()); try { return fileSystem.createDirectory(exportParams.getDirectory(), false); } catch (Exception ioe) { throw StandardExcept... | @Test public void createDirectory() throws IOException, StandardException { String testDir = temporaryFolder.getRoot().getAbsolutePath() + "/" + RandomStringUtils.randomAlphabetic(9); ExportParams exportParams = ExportParams.withDirectory(testDir); ExportFile exportFile = new ExportFile(exportParams, testTaskId(),dfs);... |
ExportPermissionCheck { void verify() throws StandardException { verifyExportDirExistsOrCanBeCreated(); verifyExportDirWritable(); } ExportPermissionCheck(ExportParams exportParams,DistributedFileSystem dfs); ExportPermissionCheck(ExportParams exportParams); void cleanup(); } | @Ignore @Test public void verify_failCase() throws IOException, StandardException { ExportParams exportParams = ExportParams.withDirectory("/ExportPermissionCheckTest"); ExportPermissionCheck permissionCheck = new ExportPermissionCheck(exportParams,dfs); try { permissionCheck.verify(); } catch (Exception e) { assertTha... |
ExportCSVWriterBuilder { public CsvListWriter build(OutputStream outputStream, ExportParams exportParams) throws IOException { OutputStreamWriter stream = new OutputStreamWriter(outputStream, exportParams.getCharacterEncoding()); Writer writer = new BufferedWriter(stream, WRITE_BUFFER_SIZE_BYTES); CsvPreference prefere... | @Test public void buildCVSWriter() throws IOException { ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); ExportParams exportParams = ExportParams.withDirectory("/tmp"); CsvListWriter csvWriter = csvWriterBuilder.build(byteStream, exportParams); csvWriter.write(new String[]{"a1", "b1", "c1", "d1"}); csvWr... |
CostUtils { public static long add(long count1, long count2) { checkArgument(count1 >= 0); checkArgument(count2 >= 0); long sum = count1 + count2; return (sum >= 0L) ? sum : Long.MAX_VALUE; } static long add(long count1, long count2); } | @Test public void add() { long result = CostUtils.add(20L, 20L); assertEquals(40L, result); result = CostUtils.add(Long.MAX_VALUE, 200L); assertEquals(Long.MAX_VALUE, result); } |
SpliceClient { static String parseJDBCPassword(String jdbcUrl) throws SqlException { Properties properties = ClientDriver.tokenizeURLProperties(jdbcUrl, null); return properties.getProperty("password"); } static synchronized void setClient(boolean tokenEnabled, Mode mode); static boolean isClient(); @SuppressFBWarning... | @Test public void testParseJDBCPassword() throws SqlException { String password = "Abd98*@80EFg"; String raw = "jdbc:splice: assertEquals(password, SpliceClient.parseJDBCPassword(raw)); raw = "jdbc:splice: assertEquals(password, SpliceClient.parseJDBCPassword(raw)); } |
ConstraintContext implements Externalizable { public ConstraintContext withInsertedMessage(int index, String newMessage) { return new ConstraintContext((String[]) ArrayUtils.add(messageArgs,index,newMessage)); } @Deprecated ConstraintContext(); ConstraintContext(String... messageArgs); static ConstraintContext empty(... | @Test public void withInsertedMessage() { ConstraintContext context1 = new ConstraintContext("aa", "bb", "cc"); ConstraintContext context2 = context1.withInsertedMessage(0, "ZZ"); ConstraintContext context3 = context1.withInsertedMessage(1, "ZZ"); ConstraintContext context4 = context1.withInsertedMessage(2, "ZZ"); Cons... |
ConstraintContext implements Externalizable { public ConstraintContext withoutMessage(int index) { return new ConstraintContext((String[]) ArrayUtils.remove(messageArgs,index)); } @Deprecated ConstraintContext(); ConstraintContext(String... messageArgs); static ConstraintContext empty(); static ConstraintContext uniq... | @Test public void withOutMessage() { ConstraintContext context1 = new ConstraintContext("aa", "bb", "cc"); ConstraintContext context2 = context1.withoutMessage(0); ConstraintContext context3 = context1.withoutMessage(1); ConstraintContext context4 = context1.withoutMessage(2); assertArrayEquals(new String[]{"bb", "cc"}... |
ConstraintContext implements Externalizable { public ConstraintContext withMessage(int index, String newMessage) { String[] newArgs = Arrays.copyOf(this.messageArgs, this.messageArgs.length); newArgs[index] = newMessage; return new ConstraintContext(newArgs); } @Deprecated ConstraintContext(); ConstraintContext(Strin... | @Test public void withMessage() { ConstraintContext context1 = new ConstraintContext("aa", "bb", "cc"); ConstraintContext context2 = context1.withMessage(0, "ZZ"); ConstraintContext context3 = context1.withMessage(1, "ZZ"); ConstraintContext context4 = context1.withMessage(2, "ZZ"); assertArrayEquals(new String[]{"ZZ",... |
BulkWriteAction implements Callable<WriteStats> { @Override public WriteStats call() throws Exception{ statusReporter.numExecutingFlushes.incrementAndGet(); reportSize(); long start=System.currentTimeMillis(); try{ Timer totalTimer=metricFactory.newTimer(); totalTimer.startTiming(); if(LOG.isDebugEnabled()) SpliceLogUt... | @Test public void testDoesNotWriteDataWhenGivenAnEmptyBulkWrite() throws Exception{ byte[] table=Bytes.toBytes("1424"); TxnView txn=new ActiveWriteTxn(1l,1l,Txn.ROOT_TRANSACTION,true,Txn.IsolationLevel.SNAPSHOT_ISOLATION); Collection<BulkWrite> bwList=new ArrayList<>(); BulkWrites bw=new BulkWrites(bwList,txn); ActionS... |
FormatableBitSet implements Formatable, Cloneable { public void clear(int position) { checkPosition(position); final int byteIndex = udiv8(position); final byte bitIndex = umod8(position); value[byteIndex] &= ~(0x80>>bitIndex); } FormatableBitSet(); FormatableBitSet(int numBits); FormatableBitSet(byte[] newValue); F... | @Test public void testClearEmpty() { try { empty.clear(-8); fail(); } catch (IllegalArgumentException ignored) { } try { empty.clear(-1); fail(); } catch (IllegalArgumentException ignored) { } try { empty.clear(0); fail(); } catch (IllegalArgumentException ignored) { } }
@Test public void testClear() { try { bitset18.c... |
FormatableBitSet implements Formatable, Cloneable { public int anySetBit() { if (SanityManager.DEBUG) { SanityManager.ASSERT(invariantHolds(), "broken invariant"); } final int numbytes = getLengthInBytes(); for (int i = 0; i < numbytes; ++i) { final byte v = value[i]; if (v == 0) continue; return (umul8(i) + firstSet(v... | @Test public void testAnySetBitEmpty() { assertEquals(empty.anySetBit(), -1); }
@Test public void testAnySetBit() { assertEquals(2, bitset18C.anySetBit()); bitset18C.clear(2); assertEquals(3, bitset18C.anySetBit()); }
@Test public void testAnySetBitBeyondBit() { assertEquals(4, bitset18.anySetBit(1)); }
@Test public vo... |
ArrayInputStream extends InputStream implements LimitObjectInput { public long skip(long count) throws IOException { if (count <= 0) { return 0; } long toSkip = Math.min(count, available()); position += toSkip; return toSkip; } ArrayInputStream(); ArrayInputStream(byte[] data); void setData(byte[] data); byte[] getDat... | @Test public void testSkipNegative() throws IOException { ArrayInputStream ais = new ArrayInputStream(new byte[1000]); assertEquals(0, ais.skip(-1)); } |
ArrayInputStream extends InputStream implements LimitObjectInput { public final int skipBytes(int n) throws IOException { return (int) skip(n); } ArrayInputStream(); ArrayInputStream(byte[] data); void setData(byte[] data); byte[] getData(); int read(); int read(byte b[], int off, int len); long skip(long count); int ... | @Test public void testSkipBytesNegative() throws IOException { ArrayInputStream ais = new ArrayInputStream(new byte[1000]); assertEquals(0, ais.skipBytes(-1)); } |
SQLSmallint extends NumberDataType { public int getInt() { return (int) value; } SQLSmallint(); SQLSmallint(short val); SQLSmallint(int val); private SQLSmallint(short val, boolean isNull); SQLSmallint(Short obj); int getInt(); byte getByte(); short getShort(); long getLong(); float getFloat(); double getDouble(); ... | @Test public void addTwo() throws StandardException { SQLSmallint integer1 = new SQLSmallint(100); SQLSmallint integer2 = new SQLSmallint(100); Assert.assertEquals("Integer Add Fails", 200, integer1.plus(integer1, integer2, null).getInt(),0); } |
SQLSmallint extends NumberDataType { public NumberDataValue minus(NumberDataValue result) throws StandardException { if (result == null) { result = new SQLSmallint(); } if (this.isNull()) { result.setToNull(); return result; } int operandValue = this.getShort(); result.setValue(-operandValue); return result; } SQLSmall... | @Test(expected = StandardException.class) public void testNegativeOverFlow() throws StandardException { SQLSmallint integer1 = new SQLSmallint(Integer.MIN_VALUE); SQLSmallint integer2 = new SQLSmallint(1); integer1.minus(integer1, integer2, null); } |
SQLSmallint extends NumberDataType { public void writeExternal(ObjectOutput out) throws IOException { out.writeBoolean(isNull); out.writeShort(value); } SQLSmallint(); SQLSmallint(short val); SQLSmallint(int val); private SQLSmallint(short val, boolean isNull); SQLSmallint(Short obj); int getInt(); byte getByte(); ... | @Test public void writeExternal() throws StandardException, IOException { SQLSmallint s = new SQLSmallint(42); MockObjectOutput moo = new MockObjectOutput(); s.writeExternal(moo); Assert.assertFalse("Shouldn't be null", moo.isNull); Assert.assertTrue("Unexpected value", moo.value == 42); }
@Test public void writeExtern... |
SQLSmallint extends NumberDataType { public void readExternal(ObjectInput in) throws IOException { isNull = in.readBoolean(); value = in.readShort(); } SQLSmallint(); SQLSmallint(short val); SQLSmallint(int val); private SQLSmallint(short val, boolean isNull); SQLSmallint(Short obj); int getInt(); byte getByte(); s... | @Test public void readExternal() throws IOException { SQLSmallint s = new SQLSmallint(); MockObjectInput moi = new MockObjectInput(); moi.isNull = false; moi.value = 42; s.readExternal(moi); Assert.assertFalse("Shouldn't be null", s.isNull()); Assert.assertTrue("Unexpected value", s.getShort() == 42); }
@Test public vo... |
SQLChar extends DataType implements StringDataValue, StreamStorable { public String getString() throws StandardException { if (value == null) { int len = rawLength; if (len != -1) { value = new String(rawData, 0, len); if (len > RETURN_SPACE_THRESHOLD) { rawData = null; rawLength = -1; cKey = null; } } else if (_clobVa... | @Test public void rowValueToDVDValue() throws Exception { SQLChar char1 = new SQLChar("foobar"); SQLChar char2 = new SQLChar(); ExecRow execRow = new ValueRow(2); execRow.setColumn(1, char1); execRow.setColumn(2, char2); Assert.assertEquals("foobar", ((Row) execRow).getString(0)); Assert.assertTrue(((Row) execRow).isNu... |
SQLReal extends NumberDataType { public NumberDataValue plus(NumberDataValue addend1, NumberDataValue addend2, NumberDataValue result) throws StandardException { if (result == null) { result = new SQLReal(); } if (addend1.isNull() || addend2.isNull()) { result.setToNull(); return result; } double dsum = addend1.getDoub... | @Test(expected = StandardException.class) public void testPositiveOverFlow() throws StandardException { SQLReal float1 = new SQLReal(Float.MAX_VALUE); SQLReal float2 = new SQLReal(1.0f); float1.plus(float1,float2,null); } |
SQLReal extends NumberDataType { public NumberDataValue minus(NumberDataValue left, NumberDataValue right, NumberDataValue result) throws StandardException { if (result == null) { result = new SQLReal(); } if (left.isNull() || right.isNull()) { result.setToNull(); return result; } double ddifference = left.getDouble() ... | @Test(expected = StandardException.class) public void testNegativeOverFlow() throws StandardException { SQLReal float1 = new SQLReal(Float.MIN_VALUE); SQLReal float2 = new SQLReal(1.0f); float1.minus(float1, float2, null); } |
SQLLongint extends NumberDataType { public NumberDataValue plus(NumberDataValue addend1, NumberDataValue addend2, NumberDataValue result) throws StandardException { if (result == null) { result = new SQLLongint(); } if (addend1.isNull() || addend2.isNull()) { result.setToNull(); return result; } long addend1Long = adde... | @Test(expected = StandardException.class) public void testPositiveOverFlow() throws StandardException { SQLLongint long1 = new SQLLongint(Long.MAX_VALUE); SQLLongint long2 = new SQLLongint(1); long1.plus(long1,long2,null); } |
SQLLongint extends NumberDataType { public NumberDataValue minus(NumberDataValue left, NumberDataValue right, NumberDataValue result) throws StandardException { if (result == null) { result = new SQLLongint(); } if (left.isNull() || right.isNull()) { result.setToNull(); return result; } long diff = left.getLong() - rig... | @Test(expected = StandardException.class) public void testNegativeOverFlow() throws StandardException { SQLLongint long1 = new SQLLongint(Long.MIN_VALUE); SQLLongint long2 = new SQLLongint(1); long1.minus(long1, long2, null); } |
SQLLongint extends NumberDataType { public void writeExternal(ObjectOutput out) throws IOException { out.writeBoolean(isNull); out.writeLong(value); } SQLLongint(); SQLLongint(long val); private SQLLongint(long val, boolean isNullArg); SQLLongint(Long obj); int getInt(); byte getByte(); short getShort(); long getLon... | @Test public void writeExternal() throws IOException { SQLLongint lint = new SQLLongint(42); MockObjectOutput moo = new MockObjectOutput(); lint.writeExternal(moo); Assert.assertFalse("Shouldn't be null", moo.isNull); Assert.assertTrue("Unexpected value", moo.value == 42); }
@Test public void writeExternalNull() throws... |
SQLLongint extends NumberDataType { public void readExternal(ObjectInput in) throws IOException { setIsNull(in.readBoolean()); value = in.readLong(); } SQLLongint(); SQLLongint(long val); private SQLLongint(long val, boolean isNullArg); SQLLongint(Long obj); int getInt(); byte getByte(); short getShort(); long getLo... | @Test public void readExternal() throws IOException { SQLLongint lint = new SQLLongint(); MockObjectInput moi = new MockObjectInput(); moi.isNull = false; moi.value = 42L; lint.readExternal(moi); Assert.assertFalse("Shouldn't be null", lint.isNull()); Assert.assertTrue("Unexpected value", lint.getLong() == 42); }
@Test... |
SQLBoolean extends DataType implements BooleanDataValue { public boolean getBoolean() { return value; } SQLBoolean(); SQLBoolean(boolean val); SQLBoolean(Boolean obj); private SQLBoolean(boolean val, boolean isNull); boolean getBoolean(); byte getByte(); short getShort(); int getInt(); long getLong(); float getFloat... | @Test public void rowValueToDVDValue() throws Exception { SQLBoolean bool1 = new SQLBoolean(true); SQLBoolean bool2 = new SQLBoolean(); ExecRow execRow = new ValueRow(2); execRow.setColumn(1, bool1); execRow.setColumn(2, bool2); Assert.assertEquals(true, ((Row) execRow).getBoolean(0)); Assert.assertTrue(((Row) execRow)... |
SQLDecimal extends NumberDataType implements VariableSizeDataValue { @Override public void setSparkObject(Object sparkObject) throws StandardException { if (sparkObject == null) setToNull(); else { value = (BigDecimal) sparkObject; setIsNull(false); } } SQLDecimal(); SQLDecimal(BigDecimal val); SQLDecimal(BigDecimal ... | @Test public void testExecRowSparkRowConversion() throws StandardException { ValueRow execRow = new ValueRow(1); double initialValue = 10d; double val; for (int i = 1; i <= 38; i++) { val = Math.pow(initialValue, i); execRow.setRowArray(new DataValueDescriptor[]{new SQLDecimal(new BigDecimal(val))}); Row row = execRow.... |
SQLInteger extends NumberDataType { public int getInt() { return value; } SQLInteger(); SQLInteger(int val); SQLInteger(char val); SQLInteger(Integer obj); int getInt(); byte getByte(); short getShort(); long getLong(); float getFloat(); double getDouble(); boolean getBoolean(); String getString(); Object getObject(... | @Test public void addTwo() throws StandardException { SQLInteger integer1 = new SQLInteger(100); SQLInteger integer2 = new SQLInteger(100); Assert.assertEquals("Integer Add Fails", 200, integer1.plus(integer1, integer2, null).getInt(),0); }
@Test public void rowValueToDVDValue() throws Exception { SQLInteger int1 = new... |
SQLInteger extends NumberDataType { public NumberDataValue minus(NumberDataValue result) throws StandardException { int operandValue; if (result == null) { result = new SQLInteger(); } if (this.isNull()) { result.setToNull(); return result; } operandValue = this.getInt(); if (operandValue == Integer.MIN_VALUE) { throw ... | @Test(expected = StandardException.class) public void testNegativeOverFlow() throws StandardException { SQLInteger integer1 = new SQLInteger(Integer.MIN_VALUE); SQLInteger integer2 = new SQLInteger(1); integer1.minus(integer1, integer2, null); } |
UniqueKeyStatisticsImpl implements ItemStatistics<ExecRow> { @Override public long nullCount() { return nullCount; } UniqueKeyStatisticsImpl(ExecRow execRow); UniqueKeyStatisticsImpl(ExecRow execRow, ItemsSketch quantilesSketch,
long nullCount
... | @Test public void testNullCount() throws StandardException { Assert.assertEquals(0, impl.nullCount()); } |
UniqueKeyStatisticsImpl implements ItemStatistics<ExecRow> { @Override public long notNullCount() { return quantilesSketch.getN(); } UniqueKeyStatisticsImpl(ExecRow execRow); UniqueKeyStatisticsImpl(ExecRow execRow, ItemsSketch quantilesSketch,
long nullCount
... | @Test public void testNotNullCount() throws StandardException { Assert.assertEquals(10000,impl.notNullCount()); } |
UniqueKeyStatisticsImpl implements ItemStatistics<ExecRow> { @Override public long totalCount() { return quantilesSketch.getN()+nullCount; } UniqueKeyStatisticsImpl(ExecRow execRow); UniqueKeyStatisticsImpl(ExecRow execRow, ItemsSketch quantilesSketch,
long nullCount
... | @Test public void testTotalCount() throws StandardException { Assert.assertEquals(10000,impl.totalCount()); } |
UniqueKeyStatisticsImpl implements ItemStatistics<ExecRow> { @Override public ExecRow maxValue() { return quantilesSketch.getMaxValue(); } UniqueKeyStatisticsImpl(ExecRow execRow); UniqueKeyStatisticsImpl(ExecRow execRow, ItemsSketch quantilesSketch,
long nullCount
... | @Test public void testMaxValue() throws StandardException { Assert.assertEquals(maxRow,impl.maxValue()); } |
UniqueKeyStatisticsImpl implements ItemStatistics<ExecRow> { @Override public ExecRow minValue() { return quantilesSketch.getMinValue(); } UniqueKeyStatisticsImpl(ExecRow execRow); UniqueKeyStatisticsImpl(ExecRow execRow, ItemsSketch quantilesSketch,
long nullCount
... | @Test public void testMinValue() throws StandardException { Assert.assertEquals(minRow,impl.minValue()); } |
UniqueKeyStatisticsImpl implements ItemStatistics<ExecRow> { @Override public long selectivity(ExecRow element) { return 1L; } UniqueKeyStatisticsImpl(ExecRow execRow); UniqueKeyStatisticsImpl(ExecRow execRow, ItemsSketch quantilesSketch,
long nullCount
... | @Test public void testNullSelectivity() throws StandardException { Assert.assertEquals(1,impl.selectivity(null)); }
@Test public void testEmptySelectivity() throws StandardException { Assert.assertEquals(1,impl.selectivity(new ValueRow(3))); }
@Test public void testIndividualSelectivity() throws StandardException { Ass... |
UniqueKeyStatisticsImpl implements ItemStatistics<ExecRow> { @Override public long rangeSelectivity(ExecRow start, ExecRow stop, boolean includeStart, boolean includeStop, boolean useExtrapolation) { double startSelectivity = start==null?0.0d:quantilesSketch.getCDF(new ExecRow[]{start})[0]; double stopSelectivity = sto... | @Test public void testRangeSelectivity() throws StandardException { Assert.assertEquals(4000.0d,(double) impl.rangeSelectivity(row2000,row6000,true,false),50.0d); }
@Test public void testNullBeginSelectivity() throws StandardException { Assert.assertEquals(6000.0d,(double) impl.rangeSelectivity(null,row6000,true,false)... |
PrimaryKeyStatisticsImpl implements ItemStatistics<ExecRow> { @Override public long nullCount() { return nullCount; } PrimaryKeyStatisticsImpl(ExecRow execRow); PrimaryKeyStatisticsImpl(ExecRow execRow, ItemsSketch quantilesSketch,
long nullCount
... | @Test public void testNullCount() throws StandardException { Assert.assertEquals(0, impl.nullCount()); } |
PrimaryKeyStatisticsImpl implements ItemStatistics<ExecRow> { @Override public long notNullCount() { return quantilesSketch.getN(); } PrimaryKeyStatisticsImpl(ExecRow execRow); PrimaryKeyStatisticsImpl(ExecRow execRow, ItemsSketch quantilesSketch,
long nullCount
... | @Test public void testNotNullCount() throws StandardException { Assert.assertEquals(10000,impl.notNullCount()); } |
PrimaryKeyStatisticsImpl implements ItemStatistics<ExecRow> { @Override public long totalCount() { return quantilesSketch.getN()+nullCount; } PrimaryKeyStatisticsImpl(ExecRow execRow); PrimaryKeyStatisticsImpl(ExecRow execRow, ItemsSketch quantilesSketch,
long nullCount
... | @Test public void testTotalCount() throws StandardException { Assert.assertEquals(10000,impl.totalCount()); } |
PrimaryKeyStatisticsImpl implements ItemStatistics<ExecRow> { @Override public ExecRow maxValue() { return quantilesSketch.getMaxValue(); } PrimaryKeyStatisticsImpl(ExecRow execRow); PrimaryKeyStatisticsImpl(ExecRow execRow, ItemsSketch quantilesSketch,
long nullCount
... | @Test public void testMaxValue() throws StandardException { Assert.assertEquals(maxRow,impl.maxValue()); } |
PrimaryKeyStatisticsImpl implements ItemStatistics<ExecRow> { @Override public ExecRow minValue() { return quantilesSketch.getMinValue(); } PrimaryKeyStatisticsImpl(ExecRow execRow); PrimaryKeyStatisticsImpl(ExecRow execRow, ItemsSketch quantilesSketch,
long nullCount
... | @Test public void testMinValue() throws StandardException { Assert.assertEquals(minRow,impl.minValue()); } |
PrimaryKeyStatisticsImpl implements ItemStatistics<ExecRow> { @Override public long selectivity(ExecRow element) { return 1L; } PrimaryKeyStatisticsImpl(ExecRow execRow); PrimaryKeyStatisticsImpl(ExecRow execRow, ItemsSketch quantilesSketch,
long nullCount
... | @Test public void testNullSelectivity() throws StandardException { Assert.assertEquals(1,impl.selectivity(null)); }
@Test public void testEmptySelectivity() throws StandardException { Assert.assertEquals(1,impl.selectivity(new ValueRow(3))); }
@Test public void testIndividualSelectivity() throws StandardException { Ass... |
PrimaryKeyStatisticsImpl implements ItemStatistics<ExecRow> { @Override public long rangeSelectivity(ExecRow start, ExecRow stop, boolean includeStart, boolean includeStop, boolean useExtrapolation) { double startSelectivity = start==null?0.0d:quantilesSketch.getCDF(new ExecRow[]{start})[0]; double stopSelectivity = st... | @Test public void testRangeSelectivity() throws StandardException { Assert.assertEquals(4000.0d,(double) impl.rangeSelectivity(row2000,row6000,true,false),50.0d); }
@Test public void testNullBeginSelectivity() throws StandardException { Assert.assertEquals(6000.0d,(double) impl.rangeSelectivity(null,row6000,true,false)... |
NonUniqueKeyStatisticsImpl implements ItemStatistics<ExecRow> { @Override public long nullCount() { return 0; } NonUniqueKeyStatisticsImpl(ExecRow execRow); NonUniqueKeyStatisticsImpl(ExecRow execRow, ItemsSketch quantilesSketch,
com.yahoo.sketches.frequencies.ItemsSketch<ExecRow>... | @Test public void testNullCount() throws StandardException { Assert.assertEquals(0, impl.nullCount()); } |
NonUniqueKeyStatisticsImpl implements ItemStatistics<ExecRow> { @Override public long notNullCount() { return quantilesSketch.getN(); } NonUniqueKeyStatisticsImpl(ExecRow execRow); NonUniqueKeyStatisticsImpl(ExecRow execRow, ItemsSketch quantilesSketch,
com.yahoo.sketches.frequenc... | @Test public void testNotNullCount() throws StandardException { Assert.assertEquals(10000,impl.notNullCount()); } |
NonUniqueKeyStatisticsImpl implements ItemStatistics<ExecRow> { @Override public long totalCount() { return quantilesSketch.getN(); } NonUniqueKeyStatisticsImpl(ExecRow execRow); NonUniqueKeyStatisticsImpl(ExecRow execRow, ItemsSketch quantilesSketch,
com.yahoo.sketches.frequencie... | @Test public void testTotalCount() throws StandardException { Assert.assertEquals(10000,impl.totalCount()); } |
NonUniqueKeyStatisticsImpl implements ItemStatistics<ExecRow> { @Override public ExecRow maxValue() { return quantilesSketch.getMaxValue(); } NonUniqueKeyStatisticsImpl(ExecRow execRow); NonUniqueKeyStatisticsImpl(ExecRow execRow, ItemsSketch quantilesSketch,
com.yahoo.sketches.fr... | @Test public void testMaxValue() throws StandardException { Assert.assertEquals(maxRow,impl.maxValue()); } |
NonUniqueKeyStatisticsImpl implements ItemStatistics<ExecRow> { @Override public ExecRow minValue() { return quantilesSketch.getMinValue(); } NonUniqueKeyStatisticsImpl(ExecRow execRow); NonUniqueKeyStatisticsImpl(ExecRow execRow, ItemsSketch quantilesSketch,
com.yahoo.sketches.fr... | @Test public void testMinValue() throws StandardException { Assert.assertEquals(minRow,impl.minValue()); } |
NonUniqueKeyStatisticsImpl implements ItemStatistics<ExecRow> { @Override public long selectivity(ExecRow element) { long count = frequenciesSketch.getEstimate(element); if (count>0) return count; return (long) (quantilesSketch.getN()/thetaSketch.getEstimate()); } NonUniqueKeyStatisticsImpl(ExecRow execRow); NonUnique... | @Test public void testNullSelectivity() throws StandardException { Assert.assertEquals(1,impl.selectivity(null)); }
@Test public void testEmptySelectivity() throws StandardException { Assert.assertEquals(1,impl.selectivity(new ValueRow(3))); }
@Test public void testIndividualSelectivity() throws StandardException { Ass... |
NonUniqueKeyStatisticsImpl implements ItemStatistics<ExecRow> { @Override public long rangeSelectivity(ExecRow start, ExecRow stop, boolean includeStart, boolean includeStop, boolean useExtrapolation) { double startSelectivity = start==null?0.0d:quantilesSketch.getCDF(new ExecRow[]{start})[0]; double stopSelectivity = ... | @Test public void testRangeSelectivity() throws StandardException { Assert.assertEquals(4000.0d,(double) impl.rangeSelectivity(row2000,row6000,true,false),50.0d); }
@Test public void testNullBeginSelectivity() throws StandardException { Assert.assertEquals(6000.0d,(double) impl.rangeSelectivity(null,row6000,true,false)... |
CurrentDatetime { public Date getCurrentDate() { if (currentDate == null) { setCurrentDatetime(); currentDate = Date.valueOf(currentDateTime.toLocalDate()); } return currentDate; } CurrentDatetime(); Date getCurrentDate(); Time getCurrentTime(); Timestamp getCurrentTimestamp(); void forget(); int getTimestampPrecision(... | @Test public void testGetCurrentDate() { LocalDate local = LocalDate.now(); Date date = cut.getCurrentDate(); long difference = ChronoUnit.DAYS.between(local, date.toLocalDate()); assertTrue(difference <= 1); } |
CurrentDatetime { public Time getCurrentTime() { if (currentTime == null) { setCurrentDatetime(); currentTime = Time.valueOf(currentDateTime.toLocalTime()); } return currentTime; } CurrentDatetime(); Date getCurrentDate(); Time getCurrentTime(); Timestamp getCurrentTimestamp(); void forget(); int getTimestampPrecision(... | @Test public void testGetCurrentTime() { LocalTime local = LocalTime.now(); Time time = cut.getCurrentTime(); long difference = ChronoUnit.SECONDS.between(local, time.toLocalTime()); assertTrue(difference <= 1); } |
CurrentDatetime { public Timestamp getCurrentTimestamp() { if (currentTimestamp == null) { setCurrentDatetime(); currentTimestamp = Timestamp.valueOf(currentDateTime); int mask = POWERS_OF_10[9 - timestampPrecision]; int newNanos = currentTimestamp.getNanos() / mask * mask; currentTimestamp.setNanos(newNanos); } return... | @Test public void testGetCurrentTimestamp() { LocalDateTime local = LocalDateTime.now(); Timestamp timestamp = cut.getCurrentTimestamp(); long difference = ChronoUnit.MILLIS.between(local, timestamp.toLocalDateTime()); assertTrue(difference <= 500); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.