diff --git a/README.md b/README.md index 24a629e8a..98c9ae26e 100644 --- a/README.md +++ b/README.md @@ -77,9 +77,9 @@ The GemFireXD layout is divided into separate logical modules namely: GemFireXD now builds completely using gradle. Due to the repository layout changes, the older ant builds no longer work (unless someone takes the effort to change them). The new scripts are much simpler, cleaner and way faster than old ant scripts but are still missing a bunch of old targets. Plan is to add them progressively as required. * Switch to "snappy/master" branch if not on that already. Update the branch to the latest version. Then test the build with: ./gradlew cleanAll && ./gradlew buildAll - * Run a GemFireXD junit test: ./gradlew :gemfirexd-tools:junit -Djunit.single='\*\*/BugsTest.class' - * Run a GemFireXD dunit test: ./gradlew :gemfirexd-tools:dunit -Ddunit.single='\*\*/BugsDUnit.class' - * Run a GemFireXD wan test: ./gradlew :gemfirexd-tools:wan -Dwan.single='\*\*/GfxdSerialWanDUnit.class' + * Run a GemFireXD junit test: ./gradlew :snappy-store:snappydata-store-tools:junit -Djunit.single='\*\*/BugsTest.class' + * Run a GemFireXD dunit test: ./gradlew :snappy-store:snappydata-store-tools:dunitTest -Ddunit.single='**/BugsDUnit.class' + * Run a GemFireXD wan test: ./gradlew :snappy-store:snappydata-store-tools:wan -Dwan.single='**/GfxdSerialWanDUnit.class' Useful build and test targets: ``` diff --git a/build.gradle b/build.gradle index 8cc898962..b9c0ae1a4 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2017-2019 TIBCO Software Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -17,6 +17,17 @@ apply plugin: 'wrapper' +buildscript { + repositories { + maven { url 'https://plugins.gradle.org/m2' } + } + dependencies { + classpath 'gradle.plugin.ca.coglinc2:javacc-gradle-plugin:3.0.0' + classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.3' + classpath 'de.undercouch:gradle-download-task:3.4.3' + } +} + allprojects { // We want to see all test results. This is equivalent to setting --continue // on the command line. @@ -29,47 +40,85 @@ allprojects { maven { url 'https://app.camunda.com/nexus/content/repositories/public' } } - gradle.taskGraph.whenReady( { graph -> - tasks.withType(Tar).each { tar -> - tar.compression = Compression.GZIP - tar.extension = 'tar.gz' - } - }) - ext { scalaBinaryVersion = '2.11' sparkVersion = '2.1.1' - springVersion = '3.2.17.RELEASE' + springVersion = '3.2.18.RELEASE' + springShellVersion = '1.0.0.RELEASE' log4jVersion = '1.2.17' slf4jVersion = '1.7.25' junitVersion = '4.12' - antVersion = '1.9.7' + hamcrestVersion = '1.3' + jmockVersion = '2.9.0' + multiThreadedTCVersion = '1.01' + cglibVersion = '3.2.10' + bcelVersion = '6.2' + memcachedVersion = '2.12.3' + antVersion = '1.9.13' + antlr2Version = '2.7.7' pxfVersion = '2.5.1.0' osgiVersion = '6.0.0' - jettyVersion = '9.2.22.v20170606' - hadoopVersion = '2.7.3' + jettyVersion = '9.2.26.v20180806' + hadoopVersion = '2.7.7' protobufVersion = '2.6.1' - kryoVersion = '4.0.1' + kryoVersion = '4.0.2' thriftVersion = '0.9.3' - jnaVersion = '4.5.0' - jerseyVersion = '2.26' + jnaVersion = '4.5.2' + jerseyVersion = '2.27' jsr305Version = '3.0.2' servletAPIVersion = '3.1.0' - derbyVersion = '10.12.1.1' - // hbaseVersion = '0.98.17-hadoop2' + derbyVersion = '10.14.2.0' + hibernateVersion = '4.3.11.Final' + hibernateJpaVersion = '1.0.2.Final' + commonsBeanutilsVersion = '1.9.3' + commonsCliVersion = '1.4' + commonsCodecVersion = '1.11' + commonsConfigVersion = '1.10' + commonsCollectionsVersion = '3.2.2' + commonsDbcpVersion = '1.4' + commonsIoVersion = '2.6' + commonsLangVersion = '2.6' + commonsLoggingVersion = '1.2' + commonsModelerVersion = '2.0.1' + commonsPoolVersion = '1.6' + commonsPool2Version = '2.6.0' + javaxResourceVersion = '1.7.1' + javaxTransactionVersion = '1.3' + mx4jVersion = '3.0.2' + mx4jToolsVersion = '3.0.1' + xalanVersion = '2.7.2' + oroVersion = '2.0.8' + dom4jVersion = '1.6.1' + apacheDsVersion = '1.5.7' hbaseVersion = '0.98.24-hadoop2' hadoopJettyVersion = '6.1.26' sunJerseyVersion = '1.19.4' guavaVersion = '14.0.1' - nettyAllVersion = '4.0.51.Final' - jlineVersion = '2.14.5' + nettyAllVersion = '4.0.56.Final' + jlineVersion = '2.14.6' + jlineSfVersion = '1.0.S2-B' jackson1Version = '1.9.13' - kolobokeVersion = '1.0.0' - kolobokeCompileVersion = '0.5.1' + eclipseCollectionsVersion = '9.2.0' + snappyJavaVersion = '1.1.7.2' + rsApiVersion = '2.1.1' + htraceVersion = '3.2.0-incubating' + clouderaHtraceVersion = '2.05' + xmlApisVersion = '1.4.01' + xomVersion = '1.2.10' + jschVersion = '0.1.55' + objenesisVersion = '3.0.1' + tomcatJdbcVersion = '8.5.37' + vijavaVersion = '5.1' + jdomVersion = '1.1.3' + ojdbc6Version = '11.2.0.1.0' + bshVersion = '2.0b5' + jsonSimpleVersion = '1.1.1' + ejbVersion = '3.2.2' + c3p0Version = '0.9.5.2' snappyDunitVersion = '1.0.3.6' // product and release properties - PRODUCT_NAME = 'SnappyData RowStore' + PRODUCT_NAME = 'TIBCO ComputeDB RowStore' GEMFIRE_PRODUCT = 'Pivotal GemFire' GEMFIRE_VERSION = '7.5.Beta' @@ -81,13 +130,13 @@ allprojects { PRODUCT_MAJOR = '1' PRODUCT_MINOR = '6' - PRODUCT_MAINT = '2' + PRODUCT_MAINT = '3' PRODUCT_CLASSIFIER = '' PRODUCT_RELEASE_STAGE = '' PRODUCT_VERSION = "${PRODUCT_MAJOR}.${PRODUCT_MINOR}.${PRODUCT_MAINT}${PRODUCT_CLASSIFIER}" - vendorName = 'SnappyData, Inc.' + vendorName = 'TIBCO Software Inc.' PRODUCT_VENDOR = vendorName - COPYRIGHT = "Copyright 2017, ${PRODUCT_VENDOR} All rights reserved." + COPYRIGHT = "Copyright (c) 2017-2019, ${PRODUCT_VENDOR} All rights reserved." if (rootProject.name == 'snappy-store') { subprojectBase = ':' @@ -149,10 +198,19 @@ allprojects { } } + // force same output directory for IDEA and gradle + idea { + module { + outputDir file(project.sourceSets.main.java.outputDir) + testOutputDir file(project.sourceSets.test.java.outputDir) + } + } + group = 'io.snappydata' version = PRODUCT_VERSION apply plugin: 'java' + apply plugin: 'com.github.johnrengelman.shadow' apply plugin: 'maven' apply plugin: 'idea' } @@ -317,13 +375,13 @@ subprojects { compile "org.slf4j:slf4j-log4j12:${slf4jVersion}" testCompile "junit:junit:${junitVersion}" - testCompile 'org.hamcrest:hamcrest-core:1.3' - testCompile 'org.hamcrest:hamcrest-library:1.3' - testCompile 'org.jmock:jmock:2.5.1' - testCompile 'org.jmock:jmock-legacy:2.5.1' - testCompile 'edu.umd.cs.mtc:multithreadedtc:1.01' - testRuntime 'cglib:cglib-nodep:2.1_3' - testRuntime 'org.objenesis:objenesis:2.6' + testCompile "org.hamcrest:hamcrest-core:${hamcrestVersion}" + testCompile "org.hamcrest:hamcrest-library:${hamcrestVersion}" + testCompile "org.jmock:jmock:${jmockVersion}" + testCompile "org.jmock:jmock-legacy:${jmockVersion}" + testCompile "edu.umd.cs.mtc:multithreadedtc:${multiThreadedTCVersion}" + testRuntime "cglib:cglib-nodep:${cglibVersion}" + testRuntime "org.objenesis:objenesis:${objenesisVersion}" } test { @@ -362,50 +420,12 @@ subprojects { reports.junitXml.destination = file(workingDir) } - task dunitTest(type:Test, overwrite: true) { + tasks.getByName("dunitTest") { it.configure { dependsOn "${subprojectBase}storeProduct" maxParallelForks = Math.max((int)Math.sqrt(Runtime.getRuntime().availableProcessors() + 1) + 1, 2) minHeapSize = '2g' maxHeapSize = '2g' - includes.clear() - - def single = System.getProperty('dunit.single') - if (single == null || single.length() == 0) { - single = rootProject.hasProperty('dunit.single') ? - rootProject.property('dunit.single') : null - } - if (single == null || single.length() == 0) { - def dunitTests = fileTree(dir: testClassesDir, - includes: ['**/*DUnit.class'], - excludes: ['**/NCJ*DUnit.class', '**/BackwardCompatabilityPart*DUnit.class', - '**/*Perf*DUnit.class', '**/ListAggDUnit.class', '**/SingleHop*TransactionDUnit.class', - '**/*Parallel*AsyncEvent*DUnit.class', '**/pivotal/gemfirexd/wan/**/*DUnit.class']) - FileTree includeTestFiles = dunitTests - int dunitFrom = rootProject.hasProperty('dunit.from') ? - getLast(includeTestFiles, rootProject.property('dunit.from')) : 0 - int dunitTo = rootProject.hasProperty('dunit.to') ? - getLast(includeTestFiles, rootProject.property('dunit.to')) : includeTestFiles.size() - - int begin = dunitFrom != -1 ? dunitFrom : 0 - int end = dunitTo != -1 ? dunitTo : includeTestFiles.size() - def filteredSet = includeTestFiles.drop(begin).take(end-begin+1).collect {f -> "**/" + f.name} - if (begin != 0 || end != includeTestFiles.size()) { - println("Picking tests :") - filteredSet.each { a -> println(a) } - } - include filteredSet - } else { - include single - } - exclude '**/*NCJ*DUnit.class' - exclude '**/BackwardCompatabilityPart*DUnit.class' - exclude '**/*Perf*DUnit.class' - exclude '**/ListAggDUnit.class' - exclude '**/SingleHop*TransactionDUnit.class' - exclude '**/*Parallel*AsyncEvent*DUnit.class' - exclude '**/pivotal/gemfirexd/wan/**/*DUnit.class' - workingDir = "${testResultsBase}/dunit" binResultsDir = file("${workingDir}/binary/${project.name}") @@ -414,7 +434,7 @@ subprojects { // try to avoid long "tail" in parallel runs where some workers finish early forkEvery 10 - } + } } task wanTest(type:Test) { dependsOn "${subprojectBase}storeProduct" @@ -459,7 +479,7 @@ subprojects { includeCategories 'com.gemstone.junit.IntegrationTest' excludeCategories 'com.gemstone.junit.UnitTest' excludeCategories 'com.gemstone.junit.DistributedTest' - } + } workingDir = "${testResultsBase}/integration" @@ -468,107 +488,6 @@ subprojects { reports.junitXml.destination = file(workingDir) } - // apply common test configuration - gradle.taskGraph.whenReady({ graph -> - tasks.withType(Test).each { test -> - test.configure { - - jvmArgs = ['-XX:+HeapDumpOnOutOfMemoryError', - '-XX:+UseParNewGC', '-XX:+UseConcMarkSweepGC', - '-XX:CMSInitiatingOccupancyFraction=50', - '-XX:+CMSClassUnloadingEnabled', '-ea'] - - testLogging.exceptionFormat = 'full' - - systemProperties 'gemfire.DEFAULT_MAX_OPLOG_SIZE' : '10', - 'gemfire.disallowMcastDefaults' : 'true', - 'java.net.preferIPv4Stack' : 'true', - 'jline.terminal' : 'scala.tools.jline.UnsupportedTerminal', - 'store.test.resourceDir' : "${projectDir}/src/test/resources", - 'GEMFIREXD' : productDir.getAbsolutePath() - - def logLevel = System.getProperty('logLevel') - if (logLevel != null && logLevel.length() > 0) { - systemProperties 'gemfire.log-level' : logLevel, - 'logLevel' : logLevel - } - logLevel = System.getProperty('securityLogLevel') - if (logLevel != null && logLevel.length() > 0) { - systemProperties 'gemfire.security-log-level' : logLevel, - 'securityLogLevel' : logLevel - } - - environment 'GEMFIREXD' : productDir.getAbsolutePath(), - 'JUNIT_JAR' : sourceSets.test.output.classesDir - - int numTestClasses = 0 - def testCount = new java.util.concurrent.atomic.AtomicInteger(0) - - doFirst { - numTestClasses = test.getCandidateClassFiles().getFiles().size() - } - beforeSuite { desc -> - if (desc.className != null) { - def count = testCount.incrementAndGet() - println "${now()} Start ${desc.className} ($count/$numTestClasses)" - } - } - afterSuite { desc, result -> - if (desc.className != null) { - println "${now()} END ${desc.className}" - } - } - - if (rootProject.name == 'snappy-store') { - def failureCount = new java.util.concurrent.atomic.AtomicInteger(0) - def progress = new File(workingDir, 'progress.txt') - def output = new File(workingDir, 'output.txt') - - def eol = System.getProperty('line.separator') - beforeTest { desc -> - String now = now() - progress << "${now} Starting test ${desc.className} ${desc.name}${eol}" - output << "${now} STARTING TEST ${desc.className} ${desc.name}${eol}${eol}" - } - onOutput { desc, event -> - def msg = event.message - if (event.destination.toString() == 'StdErr') { - msg = msg.replace(eol, "${eol}[error] ") - } - output << msg - } - afterTest { desc, result -> - String now = now() - progress << "${now} Completed test ${desc.className} ${desc.name} with result: ${result.resultType}${eol}" - output << "${eol}${now} COMPLETED TEST ${desc.className} ${desc.name} with result: ${result.resultType}${eol}${eol}" - def exceptions = result.exceptions - if (exceptions.size() > 0) { - exceptions.each { t -> - progress << " EXCEPTION: ${getStackTrace(t)}${eol}" - output << "${getStackTrace(t)}${eol}" - } - failureCount.incrementAndGet() - } - } - doLast { - def report = "${test.reports.html.destination}/index.html" - if (failureCount.get() > 0) { - println() - def failureMsg = "FAILED: There were ${failureCount.get()} failures.${eol}" - failureMsg += " See the progress report in: file://$progress${eol}" - failureMsg += " HTML report in: file://$report" - throw new GradleException(failureMsg) - } else { - println() - println("SUCCESS: See the progress report in: file://$progress") - println(" HTML report in: file://$report") - println() - } - } - } - } - } - }) test.dependsOn subprojectBase + 'cleanTestOutput' dunitTest.dependsOn subprojectBase + 'cleanDUnitOutput' @@ -592,7 +511,7 @@ subprojects { } task packageTests(type: Jar, dependsOn: testClasses) { description 'Assembles a jar archive of test classes.' - from sourceSets.test.output.classesDir + from sourceSets.test.output.classesDirs classifier = 'tests' } artifacts { @@ -620,7 +539,7 @@ subprojects { name PRODUCT_NAME packaging 'jar' // optionally artifactId can be defined here - description 'SnappyData store based off Pivotal GemFireXD' + description 'TIBCO ComputeDB store based off Pivotal GemFireXD' url 'http://www.snappydata.io' scm { @@ -640,7 +559,7 @@ subprojects { developer { id 'smenon' name 'Sudhir Menon' - email 'smenon@snappydata.io' + email 'sumenon@tibco.com' } } } @@ -656,6 +575,115 @@ int getLast(includeTestFiles, pattern) { } } +// apply common test and misc configuration +gradle.taskGraph.whenReady { graph -> + def allTasks = subprojects.collect { it.tasks }.flatten() + allTasks.each { task -> + if (task instanceof Tar) { + def tar = (Tar)task + tar.compression = Compression.GZIP + tar.extension = 'tar.gz' + } else if (task instanceof Test) { + def test = (Test)task + test.configure { + + jvmArgs = ['-XX:+UseParNewGC', '-XX:+UseConcMarkSweepGC', + '-XX:CMSInitiatingOccupancyFraction=50', + '-XX:+CMSClassUnloadingEnabled', '-ea'] + + testLogging.exceptionFormat = 'full' + + systemProperties 'gemfire.DEFAULT_MAX_OPLOG_SIZE' : '10', + 'gemfire.disallowMcastDefaults' : 'true', + 'java.net.preferIPv4Stack' : 'true', + 'jline.terminal' : 'scala.tools.jline.UnsupportedTerminal', + 'store.test.resourceDir' : "${project.projectDir}/src/test/resources", + 'GEMFIREXD' : productDir.getAbsolutePath() + + def logLevel = System.getProperty('logLevel') + if (logLevel != null && logLevel.length() > 0) { + systemProperties 'gemfire.log-level' : logLevel, + 'logLevel' : logLevel + } + logLevel = System.getProperty('securityLogLevel') + if (logLevel != null && logLevel.length() > 0) { + systemProperties 'gemfire.security-log-level' : logLevel, + 'securityLogLevel' : logLevel + } + + environment 'GEMFIREXD' : productDir.getAbsolutePath(), + 'JUNIT_JAR' : project.sourceSets.test.java.outputDir + + if (rootProject.name == 'snappy-store') { + def failureCount = new java.util.concurrent.atomic.AtomicInteger(0) + def progress = new File(workingDir, 'progress.txt') + def output = new File(workingDir, 'output.txt') + + def eol = System.getProperty('line.separator') + + int numTestClasses = 0 + def testCount = new java.util.concurrent.atomic.AtomicInteger(0) + doFirst { + numTestClasses = test.getCandidateClassFiles().getFiles().size() + } + beforeSuite { desc -> + if (desc.className != null) { + def count = testCount.incrementAndGet() + println "${now()} Start ${desc.className} ($count/$numTestClasses)" + } + } + afterSuite { desc, result -> + if (desc.className != null) { + println "${now()} END ${desc.className}" + } + } + + beforeTest { desc -> + String now = now() + progress << "${now} Starting test ${desc.className} ${desc.name}${eol}" + output << "${now} STARTING TEST ${desc.className} ${desc.name}${eol}${eol}" + } + onOutput { desc, event -> + def msg = event.message + if (event.destination.toString() == 'StdErr') { + msg = msg.replace(eol, "${eol}[error] ") + } + output << msg + } + afterTest { desc, result -> + String now = now() + progress << "${now} Completed test ${desc.className} ${desc.name} with result: ${result.resultType}${eol}" + output << "${eol}${now} COMPLETED TEST ${desc.className} ${desc.name} with result: ${result.resultType}${eol}${eol}" + def exceptions = result.exceptions + if (exceptions.size() > 0) { + exceptions.each { t -> + progress << " EXCEPTION: ${getStackTrace(t)}${eol}" + output << "${getStackTrace(t)}${eol}" + } + failureCount.incrementAndGet() + } + } + doLast { + def report = "${test.reports.html.destination}/index.html" + if (failureCount.get() > 0) { + println() + def failureMsg = "FAILED: There were ${failureCount.get()} failures.${eol}" + failureMsg += " See the progress report in: file://$progress${eol}" + failureMsg += " HTML report in: file://$report" + throw new GradleException(failureMsg) + } else { + println() + println("SUCCESS: See the progress report in: file://$progress") + println(" HTML report in: file://$report") + println() + } + } + } + } + } + } +} + task junit { dependsOn subprojects.test } @@ -676,9 +704,9 @@ task combineReports(type: TestReport) { mustRunAfter test, junit, dunit, wan, integrationTest } -gradle.taskGraph.whenReady({ graph -> +gradle.taskGraph.whenReady { graph -> tasks.getByName('combineReports').reportOn rootProject.subprojects.collect{ it.tasks.withType(Test) }.flatten() -}) +} check.dependsOn.clear() check.dependsOn junit, dunit @@ -693,7 +721,6 @@ if (!rootProject.hasProperty('store')) { task generateSources { dependsOn subprojectBase + 'gemfire-jgroups:jgMagic' dependsOn subprojectBase + 'gemfire-core:createVersionPropertiesFile' - dependsOn subprojectBase + 'snappydata-util:compileJava' dependsOn subprojectBase + 'snappydata-store-core:compileJavacc' dependsOn subprojectBase + 'snappydata-store-core:generatePropertiesFiles' dependsOn subprojectBase + 'gemfire-core:createVersionPropertiesFile' @@ -846,7 +873,7 @@ task storeProduct(dependsOn: [ subprojectBase + 'snappydata-store-client:shadowJ } copy { - from (project(subprojectBase + 'gemfire-tests').projectDir.getAbsolutePath() + '/src/main/java') { + from (project(subprojectBase + 'gemfire-tests').sourceSets.main.java.srcDirs) { include '**/*.bt' include '**/*.conf' include '**/*.inc' @@ -862,7 +889,7 @@ task storeProduct(dependsOn: [ subprojectBase + 'snappydata-store-client:shadowJ include 'hydratest/hydracheck/*.sh' include 'bin/scaleperf/*' } - from (project(subprojectBase + 'snappydata-store-tests').projectDir.getAbsolutePath() + '/src/main/java') { + from (project(subprojectBase + 'snappydata-store-tests').sourceSets.main.java.srcDirs) { include '**/*.bt' include '**/*.conf' include '**/*.inc' @@ -875,7 +902,7 @@ task storeProduct(dependsOn: [ subprojectBase + 'snappydata-store-client:shadowJ include '**/*.ts' include '**/*.pl' } - into (project(subprojectBase + 'snappydata-store-tests').buildDir.getAbsolutePath() + '/classes/main') + into (project(subprojectBase + 'snappydata-store-tests').sourceSets.main.java.outputDir) } } } if (rootProject.hasProperty('docs')) { diff --git a/gemfire-core/build.gradle b/gemfire-core/build.gradle index 733848d60..185e2b14b 100644 --- a/gemfire-core/build.gradle +++ b/gemfire-core/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -29,23 +29,22 @@ configurations { dependencies { compileOnly files("${System.getProperty('java.home')}/../lib/tools.jar") - compileOnly 'antlr:antlr:2.7.7' + compileOnly "antlr:antlr:${antlr2Version}" compile "net.java.dev.jna:jna:${jnaVersion}" - compile 'commons-collections:commons-collections:3.2.2' - compile 'commons-io:commons-io:2.5' - compile 'commons-logging:commons-logging:1.2' - compile 'commons-lang:commons-lang:2.6' - compile('commons-modeler:commons-modeler:2.0.1') { + compile "commons-collections:commons-collections:${commonsCollectionsVersion}" + compile "commons-io:commons-io:${commonsIoVersion}" + compile "commons-logging:commons-logging:${commonsLoggingVersion}" + compile "commons-lang:commons-lang:${commonsLangVersion}" + compile("commons-modeler:commons-modeler:${commonsModelerVersion}") { exclude(group: 'xml-apis', module: 'xml-apis') } - compile 'commons-cli:commons-cli:1.4' - compile 'javax.mail:javax.mail-api:1.6.0' - compile 'javax.resource:javax.resource-api:1.7' - compile 'javax.transaction:javax.transaction-api:1.2' - compile 'mx4j:mx4j:3.0.2' - compile 'mx4j:mx4j-remote:3.0.2' - compile 'mx4j:mx4j-tools:3.0.1' - compileOnly 'net.sourceforge.jline:jline:1.0.S2-B' + compile "commons-cli:commons-cli:${commonsCliVersion}" + compile "javax.resource:javax.resource-api:${javaxResourceVersion}" + compile "javax.transaction:javax.transaction-api:${javaxTransactionVersion}" + compile "mx4j:mx4j:${mx4jVersion}" + compile "mx4j:mx4j-remote:${mx4jVersion}" + compile "mx4j:mx4j-tools:${mx4jToolsVersion}" + compileOnly "net.sourceforge.jline:jline:${jlineSfVersion}" compileOnly "org.eclipse.jetty:jetty-http:${jettyVersion}" compileOnly "org.eclipse.jetty:jetty-io:${jettyVersion}" compileOnly "org.eclipse.jetty:jetty-security:${jettyVersion}" @@ -63,12 +62,12 @@ dependencies { compileOnly "org.springframework:spring-web:${springVersion}" compileOnly "org.springframework:spring-webmvc:${springVersion}" compileOnly "org.springframework:spring-tx:${springVersion}" - compileOnly 'org.springframework.shell:spring-shell:1.0.0.RELEASE' - compile 'org.xerial.snappy:snappy-java:1.1.4' + compileOnly "org.springframework.shell:spring-shell:${springShellVersion}" + compile "org.xerial.snappy:snappy-java:${snappyJavaVersion}" compileOnly "org.apache.hadoop:hadoop-annotations:${hadoopVersion}" - compileOnly "org.apache.hadoop:hadoop-auth:${hadoopVersion}" - compileOnly "org.apache.hadoop:hadoop-common:${hadoopVersion}" + compileOnly("org.apache.hadoop:hadoop-auth:${hadoopVersion}") + compileOnly("org.apache.hadoop:hadoop-common:${hadoopVersion}") compileOnly "org.apache.hadoop:hadoop-hdfs:${hadoopVersion}" compileOnly "org.apache.hadoop:hadoop-mapreduce-client-core:${hadoopVersion}" compileOnly "com.google.protobuf:protobuf-java:${protobufVersion}" @@ -80,15 +79,17 @@ dependencies { compileOnly "com.esotericsoftware:kryo-shaded:${kryoVersion}" compile "io.netty:netty-all:${nettyAllVersion}" - compile 'javax.ws.rs:javax.ws.rs-api:2.0.1' - compile 'org.apache.htrace:htrace-core:3.2.0-incubating' + compile "javax.ws.rs:javax.ws.rs-api:${rsApiVersion}" + compile "org.apache.htrace:htrace-core:${htraceVersion}" compile "org.codehaus.jackson:jackson-core-asl:${jackson1Version}" compile "org.codehaus.jackson:jackson-mapper-asl:${jackson1Version}" - compile 'org.apache.commons:commons-pool2:2.4.2' + compile "org.eclipse.collections:eclipse-collections-api:${eclipseCollectionsVersion}" + compile "org.eclipse.collections:eclipse-collections:${eclipseCollectionsVersion}" + compile "org.apache.commons:commons-pool2:${commonsPool2Version}" compile "com.google.guava:guava:${guavaVersion}" - compile 'xml-apis:xml-apis:1.4.01' - compile('com.io7m.xom:xom:1.2.10') { + compile "xml-apis:xml-apis:${xmlApisVersion}" + compile("com.io7m.xom:xom:${xomVersion}") { exclude(group: 'xalan', module: 'xalan') exclude(group: 'xerces', module: 'xercesImpl') exclude(group: 'xml-apis', module: 'xml-apis') @@ -120,23 +121,22 @@ dependencies { exclude(group: 'com.sun.jersey', module: 'jersey-json') exclude(group: 'commons-io', module: 'commons-io') } - compileOnly 'com.jcraft:jsch:0.1.53' + compileOnly "com.jcraft:jsch:${jschVersion}" compileOnly "org.apache.ant:ant:${antVersion}" compile project(subprojectBase + 'gemfire-jgroups') compile project(subprojectBase + 'gemfire-util') compile project(subprojectBase + 'gemfire-shared') compile project(subprojectBase + 'gemfire-trove') - compile project(subprojectBase + 'snappydata-util') jcaCompile sourceSets.main.output } // Creates the version properties file and writes it to the classes dir task createVersionPropertiesFile(dependsOn: 'processResources') { - def propertiesDir = file("${buildDir}/resources/main/com/gemstone/gemfire/internal") + def propertiesDir = file("${sourceSets.main.java.outputDir}/com/pivotal/gemfirexd/internal") outputs.file "${propertiesDir}/GemFireVersion.properties" - inputs.dir compileJava.destinationDir + inputs.file "${rootProject.projectDir}/build.gradle" doLast { def props = [ @@ -172,18 +172,11 @@ jar { } copy { from "${projectDir}/lib" - into sourceSets.main.output.classesDir + into sourceSets.main.java.outputDir } } } -task webJar (type: Jar, dependsOn: classes) { - description 'Assembles the jar archive containing the gemfire management web classes.' - from sourceSets.main.output - baseName 'gemfire-web' - include 'com/gemstone/gemfire/management/internal/web/**' -} - task raJar (type: Jar, dependsOn: classes) { description 'Assembles the jar archive that contains the JCA classes' from sourceSets.jca.output diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/AdminDistributedSystemJmxImpl.java b/gemfire-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/AdminDistributedSystemJmxImpl.java index 77b3b7224..da06c74ce 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/AdminDistributedSystemJmxImpl.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/AdminDistributedSystemJmxImpl.java @@ -173,7 +173,8 @@ public AdminDistributedSystemJmxImpl(AgentConfig config) this.objectName = MBeanUtil.createMBean(this); isEmailNotificationEnabled = config.isEmailNotificationEnabled(); if (isEmailNotificationEnabled) { - initMailProps(config); + throw new UnsupportedOperationException("email notifications not supported"); + // initMailProps(config); } // Init file name for StatAlertDefns initStateSaveFile(config); @@ -182,6 +183,7 @@ public AdminDistributedSystemJmxImpl(AgentConfig config) cacheRegionListener = new CacheAndRegionListenerImpl(this); } + /* private void initMailProps(AgentConfig config) { mailProps = new Properties(); mailProps.put(MailManager.PROPERTY_MAIL_FROM, @@ -191,6 +193,7 @@ private void initMailProps(AgentConfig config) { mailProps.put(MailManager.PROPERTY_MAIL_TO_LIST, config.getEmailNotificationToList()); } + */ private void initStateSaveFile(AgentConfig agentConfig) { // Init file name for StatAlertDefns @@ -429,6 +432,7 @@ public void nodeJoined(GfManagerAgent source, GemFireVM joined) { // String mess = "Gemfire AlertNotification: System Member Joined, System member Id: " + joined.getId().toString(); // sendEmail("Gemfire AlertNotification: Member Joined, ID: " + joined.getId().toString(), mess); + /* if (isEmailNotificationEnabled) { String mess = LocalizedStrings.AdminDistributedSystemJmxImpl_MEMBER_JOINED_THE_DISTRIBUTED_SYSTEM_MEMBER_ID_0.toLocalizedString(new Object[] {joined.getId().toString()} ); sendEmail( @@ -436,6 +440,7 @@ public void nodeJoined(GfManagerAgent source, GemFireVM joined) { + LocalizedStrings.AdminDistributedSystemJmxImpl_MEMBER_JOINED.toLocalizedString() +">", mess); } + */ } catch (javax.management.MBeanException e) { logger.warning(e); } @@ -487,6 +492,7 @@ public void nodeLeft(GfManagerAgent source, GemFireVM left) { // String mess = "Gemfire AlertNotification: System Member Left the system, System member Id: " + left.getId().toString(); // sendEmail("Gemfire AlertNotification: Member Left, ID: " + left.getId().toString(), mess); + /* if (isEmailNotificationEnabled) { String mess = LocalizedStrings.AdminDistributedSystemJmxImpl_MEMBER_LEFT_THE_DISTRIBUTED_SYSTEM_MEMBER_ID_0.toLocalizedString(new Object[] {left.getId().toString()} ); sendEmail( @@ -494,6 +500,7 @@ public void nodeLeft(GfManagerAgent source, GemFireVM left) { + LocalizedStrings.AdminDistributedSystemJmxImpl_MEMBER_LEFT.toLocalizedString() +">", mess); } + */ } catch (javax.management.MBeanException e) { logger.warning(e); } @@ -552,6 +559,7 @@ public void nodeCrashed(GfManagerAgent source, GemFireVM crashed) { // String mess = "Gemfire AlertNotification: System Member Crashed, System member Id: " + crashed.getId().toString(); // sendEmail("Gemfire AlertNotification: Member Crashed, ID: " + crashed.getId().toString(), mess); + /* if (isEmailNotificationEnabled) { String mess = LocalizedStrings.AdminDistributedSystemJmxImpl_MEMBER_CRASHED_IN_THE_DISTRIBUTED_SYSTEM_MEMBER_ID_0.toLocalizedString(new Object[] {crashed.getId().toString()} ); sendEmail( @@ -559,6 +567,7 @@ public void nodeCrashed(GfManagerAgent source, GemFireVM crashed) { + LocalizedStrings.AdminDistributedSystemJmxImpl_MEMBER_CRASHED.toLocalizedString() +">", mess); } + */ } catch (javax.management.MBeanException e) { logger.warning(e); } @@ -613,10 +622,12 @@ public void alert(Alert alert) { // String mess = "Gemfire AlertNotification: System Alert :" + alert.toString(); // sendEmail("Gemfire AlertNotification: System Alert", mess); + /* if (isEmailNotificationEnabled) { String mess = LocalizedStrings.AdminDistributedSystemJmxImpl_SYSTEM_ALERT_FROM_DISTRIBUTED_SYSTEM_0.toLocalizedString(strAlert); sendEmail( EML_SUBJ_PRFX_GFE_ALERT + EML_SUBJ_ITEM_GFE_DS + getName() + " ", mess); } + */ } catch (javax.management.MBeanException e) { logger.warning(e); } @@ -1491,7 +1502,7 @@ public void revokePersistentMember(String uuid) throws AdminException, UnknownHo //TODO: yet to set the timer task // private SystemTimer systemwideAlertNotificationScheduler = new SystemTimer(); - private MailManager mailManager = null; + // private MailManager mailManager = null; private final boolean isEmailNotificationEnabled; /** @@ -2198,6 +2209,7 @@ private void sendNotifications(ArrayList notificationObjects, buf.append(not.toString(getAlertDefinition(not.getDefinitionId()))); } // sendEmail("Gemfire AlertNotification on Member:" + objName, buf.toString()); + /* if (isEmailNotificationEnabled) { String mess = LocalizedStrings.AdminDistributedSystemJmxImpl_STATISTICS_ALERT_FROM_DISTRIBUTED_SYSTEM_MEMBER_0_STATISTICS_1.toLocalizedString(new Object[] {objName.getCanonicalName(), buf.toString()} ); sendEmail( @@ -2205,6 +2217,7 @@ private void sendNotifications(ArrayList notificationObjects, + " <"+LocalizedStrings.AdminDistributedSystemJmxImpl_STATISTICS_ALERT_FOR_MEMBER.toLocalizedString()+">", mess); } + */ } catch (javax.management.MBeanException e) { logger.error(e); } catch (RuntimeException e) { @@ -2227,7 +2240,8 @@ private void sendNotifications(ArrayList notificationObjects, throw e; } } - + + /* /** * Sends an email to the configured recipients using configured email server. * The given message will be the email body. NOTE: the check whether email @@ -2238,13 +2252,14 @@ private void sendNotifications(ArrayList notificationObjects, * subject of the email * @param message * message body of the email - */ + * private void sendEmail(String subject, String message) { if (mailManager == null) { mailManager = new MailManager(mailProps); } this.mailManager.sendEmail(subject, message); } + */ public void processSystemwideNotifications() { } diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/MailManager.java b/gemfire-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/MailManager.java deleted file mode 100644 index 70bc09ffb..000000000 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/MailManager.java +++ /dev/null @@ -1,350 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you - * may not use this file except in compliance with the License. You - * may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. See accompanying - * LICENSE file. - */ -package com.gemstone.gemfire.admin.jmx.internal; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.HashSet; -import java.util.Properties; - -import javax.mail.Message; -import javax.mail.Session; -import javax.mail.Transport; -import javax.mail.internet.InternetAddress; -import javax.mail.internet.MimeMessage; - -import com.gemstone.gemfire.SystemFailure; -import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; -import com.gemstone.gemfire.i18n.LogWriterI18n; -import com.gemstone.gemfire.internal.i18n.LocalizedStrings; - -/** - * Provides the ways to send emails to all the registered email id It also - * provides the way to add/remove email ids. Can be used to send email in case - * of any alerts raised / warning / failure in gemfire. - * - * @author Harsh Khanna - * @since 5.1 - */ -public class MailManager { - - public MailManager() { - init(); - } - - public MailManager(Properties mailProperties) { - setMailProperties(mailProperties); - init(); - } - - public MailManager(File mailPropertiesFile) throws IOException { - Properties prop = new Properties(); - FileInputStream fio = new FileInputStream(mailPropertiesFile); - try { - prop.load(fio); - } - finally { - fio.close(); - } - setMailProperties(prop); - init(); - } - - public MailManager(String mailHost, String mailFrom) { - this.mailHost = mailHost; - this.mailFrom = mailFrom; - init(); - } - - /** - * Send email to all the registered email id with given subject and message - */ - public void sendEmail(String subject, String message) { - processEmail(new EmailData(subject, message)); - } - - /** - * Send Emails to all the registered email id - * - * @param emailData - * Instance of EmailData - */ - // Why a separate method & class EmailData needed??? - private void processEmail(EmailData emailData) { - boolean finerEnabled = logger.finerEnabled(); - if (finerEnabled) { - logger.finer("Entered MailManager:processEmail"); - } - - if (mailHost == null || mailHost.length() == 0 - || emailData == null || mailToAddresses.length == 0) { - if (logger.errorEnabled()) { - logger.error(LocalizedStrings.MailManager_REQUIRED_MAILSERVER_CONFIGURATION_NOT_SPECIFIED); - } - if (logger.fineEnabled()) { - logger.fine("Exited MailManager:processEmail: Not sending email as conditions not met"); - } - return; - } - - Session session = Session.getDefaultInstance(getMailHostConfiguration()); - MimeMessage mimeMessage = new MimeMessage(session); - String subject = emailData.subject; - String message = emailData.message; - String mailToList = getMailToAddressesAsString(); - - try { - for (int i = 0; i < mailToAddresses.length; i++) { - mimeMessage.addRecipient(Message.RecipientType.TO, new InternetAddress( - mailToAddresses[i])); - } - - if (subject == null) { - subject = LocalizedStrings.MailManager_ALERT_MAIL_SUBJECT.toLocalizedString(); - } - mimeMessage.setSubject(subject); - - if (message == null) { - message = ""; - } - mimeMessage.setText(message); - - Transport.send(mimeMessage); - if (logger.infoEnabled()) { - logger.info( - LocalizedStrings.MailManager_EMAIL_ALERT_HAS_BEEN_SENT_0_1_2, - new Object[] { mailToList, subject, message }); - } - } catch (Throwable ex) { - Error err; - if (ex instanceof Error && SystemFailure.isJVMFailureError( - err = (Error)ex)) { - SystemFailure.initiateFailure(err); - // If this ever returns, rethrow the error. We're poisoned - // now, so don't let this thread continue. - throw err; - } - // Whenever you catch Error or Throwable, you must also - // check for fatal JVM error (see above). However, there is - // _still_ a possibility that you are dealing with a cascading - // error condition, so you also need to check to see if the JVM - // is still usable: - SystemFailure.checkFailure(); - StringBuilder buf = new StringBuilder(); - buf.append(LocalizedStrings.MailManager_AN_EXCEPTION_OCCURRED_WHILE_SENDING_EMAIL.toLocalizedString()); - buf.append(LocalizedStrings.MailManager_UNABLE_TO_SEND_EMAIL_PLEASE_CHECK_YOUR_EMAIL_SETTINGS_AND_LOG_FILE.toLocalizedString()); - buf.append("\n\n").append(LocalizedStrings.MailManager_EXCEPTION_MESSAGE_0.toLocalizedString(ex.getMessage())); - buf.append("\n\n").append(LocalizedStrings.MailManager_FOLLOWING_EMAIL_WAS_NOT_DELIVERED.toLocalizedString()); - buf.append("\n\t").append(LocalizedStrings.MailManager_MAIL_HOST_0.toLocalizedString(mailHost)); - buf.append("\n\t").append(LocalizedStrings.MailManager_FROM_0.toLocalizedString(mailFrom)); - buf.append("\n\t").append(LocalizedStrings.MailManager_TO_0.toLocalizedString(mailToList)); - buf.append("\n\t").append(LocalizedStrings.MailManager_SUBJECT_0.toLocalizedString(subject)); - buf.append("\n\t").append(LocalizedStrings.MailManager_CONTENT_0.toLocalizedString(message)); - - logger.error(LocalizedStrings.ONE_ARG, buf.toString(), ex); - } - if (finerEnabled) { - logger.finer("Exited MailManager:processEmail"); - } - } - - /** - * Initializing the log writer - */ - private void init() { - logger = InternalDistributedSystem.getAnyInstance().getLogWriterI18n(); - } - - /** - * Not yet implemented - */ - public void close() { - } - - /** - * @return All the registered email id as string - */ - private String getMailToAddressesAsString() { - StringBuffer mailToList = new StringBuffer(); - for (int i = 0; i < mailToAddresses.length; i++) { - mailToList.append(mailToAddresses[i]); - mailToList.append(", "); - } - return mailToList.toString(); - } - - /** - * - * @return Properties consisting mailHost and mailFrom property - */ - private Properties getMailHostConfiguration() { - Properties result = new Properties(); - if (mailHost == null) { - mailHost = ""; - } - if (mailFrom == null) { - mailFrom = ""; - } - result.setProperty("mail.host", mailHost); - result.put("mail.from", mailFrom); - return result; - } - - /** - * - * @param host - * mail host server name - */ - public void setMailHost(String host) { - this.mailHost = host; - } - - /** - * - * @return mail host server name - */ - public String getMailHost() { - return this.mailHost; - } - - /** - * - * @param fromAddress - * mailFrom email id - */ - public void setMailFromAddress(String fromAddress) { - mailFrom = fromAddress; - } - - /** - * - * @return mailFrom email id - */ - public String getMailFromAddress() { - return mailFrom; - } - - /** - * add new mail id to ToList - */ - public void addMailToAddress(String toAddress) { - mailToSet.add(toAddress); - mailToAddresses = getAllToAddresses(); - } - - /** - * remove given mail id from ToList - */ - public void removeMailToAddress(String toAddress) { - mailToSet.remove(toAddress); - mailToAddresses = getAllToAddresses(); - } - - /** - * @return list all the registered email id - */ - public String[] getAllToAddresses() { - return (String[])mailToSet.toArray(new String[0]); - } - - /** - * remove all the registered email ids from ToList - */ - public void removeAllMailToAddresses() { - mailToSet.clear(); - mailToAddresses = new String[0]; - } - - /** - * Set the mail properties, e.g mail host, mailFrom, MailTo etc - */ - public void setMailProperties(Properties mailProperties) { - mailHost = mailProperties.getProperty(PROPERTY_MAIL_HOST); - mailFrom = mailProperties.getProperty(PROPERTY_MAIL_FROM); - String mailList = mailProperties.getProperty(PROPERTY_MAIL_TO_LIST, ""); - String split[] = mailList.split(","); - removeAllMailToAddresses(); - for (int i = 0; i < split.length; i++) { - addMailToAddress(split[i].trim()); - } - } - - @Override - public String toString() { - StringBuffer buffer = new StringBuffer(200); - buffer.append("[Mail Host: "); - buffer.append(getMailHost()); - buffer.append("]"); - buffer.append(" [Mail From: "); - buffer.append(getMailFromAddress()); - buffer.append("]"); - buffer.append(" [Mail To: "); - if (mailToAddresses.length > 0) { - - for (int i = 0; i < mailToAddresses.length; i++) { - buffer.append(mailToAddresses[i]); - buffer.append(", "); - } - buffer.replace(buffer.length() - 2, buffer.length(), ""); - } - else { - buffer.append(" Undefined"); - } - buffer.append("]"); - return buffer.toString(); - } - - private final HashSet mailToSet = new HashSet(); - - private String mailToAddresses[] = new String[0]; - - protected String mailHost; - - protected String mailFrom; - - private LogWriterI18n logger; - - public final static String PROPERTY_MAIL_HOST = "mail.host"; - - public final static String PROPERTY_MAIL_FROM = "mail.from"; - - public final static String PROPERTY_MAIL_TO_LIST = "mail.toList"; - - /** - * Incorporating subject and message of email - * - * @author Harsh Khanna - * - */ - static private class EmailData { - String subject; - - String message; - - EmailData(String subject, String message) { - this.subject = subject; - this.message = message; - } - } - - public static void main(String args[]) { - MailManager mailManager = new MailManager("mailsrv1.gemstone.com", - "hkhanna@gemstone.com"); - mailManager.sendEmail("Alert!", "Test"); - } -} diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/CommitConflictException.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/CommitConflictException.java deleted file mode 100644 index 22117a932..000000000 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/CommitConflictException.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you - * may not use this file except in compliance with the License. You - * may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. See accompanying - * LICENSE file. - */ - -package com.gemstone.gemfire.cache; - -/** - * Thrown when a commit fails due to a write conflict. - * - * @author Darrel Schneider - * - * @see CacheTransactionManager#commit - * @since 4.0 - * - * @deprecated as of 7.0, this exception is no longer thrown (see - * {@link ConflictException} that is now thrown) - */ -@Deprecated -public class CommitConflictException extends ConflictException { - - private static final long serialVersionUID = -1491184174802596675L; - - /** - * Constructs an instance of CommitConflictException with the - * specified detail message. - * - * @param msg - * the detail message - */ - @Deprecated - public CommitConflictException(String msg) { - super(msg); - } - - /** - * Constructs an instance of CommitConflictException with the - * specified detail message and cause. - * - * @param msg - * the detail message - * @param cause - * the causal Throwable - */ - @Deprecated - public CommitConflictException(String msg, Throwable cause) { - super(msg, cause); - } - - /** - * Constructs an instance of CommitConflictException with the - * specified cause. - * - * @param cause - * the causal Throwable - * @since 6.5 - */ - @Deprecated - public CommitConflictException(Throwable cause) { - super(cause); - } - - /** - * Returns true to indicate that this exception causes the transaction to be - * aborted since the transaction state can no longer be guaranteed to be - * consistent. - */ - @Override - public boolean isTransactionSeverity() { - return true; - } - - @Override - public void setTransactionSeverity() { - } -} diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/CommitDistributionException.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/CommitDistributionException.java deleted file mode 100644 index b94e6c796..000000000 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/CommitDistributionException.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you - * may not use this file except in compliance with the License. You - * may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. See accompanying - * LICENSE file. - */ -package com.gemstone.gemfire.cache; - -import java.util.*; - -/** - * Indicates that an attempt to notify required participants of a transaction - * involving one or more regions that are configured with {@link - * MembershipAttributes} may have failed. The commit itself was completed but - * one or more regions affected by the transaction have one or more required - * roles that were not successfully notified. Failure may be caused by - * departure of one or more required roles while sending the operation to - * them. This exception will contain one {@link RegionDistributionException} - * for every region that had a reliability failure. Details of the failed - * {@link MembershipAttributes#getRequiredRoles required roles} are provided - * in each RegionDistributionException. - * - * @author Kirk Lund - * @since 5.0 - * - * @deprecated as of 7.0, this exception is no longer thrown - */ -@Deprecated -public class CommitDistributionException extends TransactionException { - private static final long serialVersionUID = -3517820638706581823L; - /** - * The RegionDistributionExceptions for every region that had a reliability - * failure during distribution of the operation. - */ - private Set regionDistributionExceptions = Collections.EMPTY_SET; - - /** - * Constructs a CommitDistributionException with a message. - * - * @param s the String message - */ - @Deprecated - public CommitDistributionException(String s) { - super(s); - } - - /** - * Constructs a CommitDistributionException with a message and - * a cause. - * - * @param s the String message - * @param regionDistributionExceptions set of RegionDistributionExceptions - * for each region that had a reliability failure - */ - @Deprecated - public CommitDistributionException(String s, Set regionDistributionExceptions) { - super(s); - this.regionDistributionExceptions = regionDistributionExceptions; - if (this.regionDistributionExceptions == null) { - this.regionDistributionExceptions = Collections.EMPTY_SET; - } - } - - /** - * Returns set of RegionDistributionExceptions for each region that had a - * reliability failure during distribution of the operation. - * - * @return set of RegionDistributionExceptions for each region that had a - * reliability failure during distribution of the operation - */ - @Deprecated - public Set getRegionDistributionExceptions() { - return this.regionDistributionExceptions; - } - -} - diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/CommitIncompleteException.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/CommitIncompleteException.java deleted file mode 100644 index 404fd9f21..000000000 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/CommitIncompleteException.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you - * may not use this file except in compliance with the License. You - * may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. See accompanying - * LICENSE file. - */ -package com.gemstone.gemfire.cache; - -/** - * Thrown when a commit fails to complete due to errors - * - * @author Mitch Thomas - * @since 5.7 - * - * @deprecated as of 7.0, this exception is no longer thrown - * - * @see ConflictException - * @see TransactionInDoubtException - */ -@Deprecated -public class CommitIncompleteException extends TransactionException { - private static final long serialVersionUID = 1017741483744420800L; - - @Deprecated - public CommitIncompleteException(String message) { - super(message); - } -} diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/EntryNotFoundInRegion.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/EntryNotFoundInRegion.java deleted file mode 100644 index 0ded919a1..000000000 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/EntryNotFoundInRegion.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you - * may not use this file except in compliance with the License. You - * may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. See accompanying - * LICENSE file. - */ -package com.gemstone.gemfire.cache; - -import com.gemstone.gemfire.GemFireException; -import com.gemstone.gemfire.internal.i18n.LocalizedStrings; -import com.gemstone.gemfire.InternalGemFireError; - -/** - * @deprecated this class is no longer in use - */ -@Deprecated -public class EntryNotFoundInRegion extends GemFireException { - private static final long serialVersionUID = 5572550909947420405L; - - /** - * Generates an {@link InternalGemFireError} - * @param msg the detail message - * @deprecated Do not create instances of this class. - */ - @Deprecated - public EntryNotFoundInRegion(String msg) { - throw new InternalGemFireError(LocalizedStrings.EntryNotFoundInRegion_THIS_CLASS_IS_DEPRECATED.toLocalizedString()); - } - - /** - * Generates an {@link InternalGemFireError} - * @param msg the detail message - * @param cause the causal Throwable - * @deprecated do not create instances of this class. - */ - @Deprecated - public EntryNotFoundInRegion(String msg, Throwable cause) { - throw new InternalGemFireError(LocalizedStrings.EntryNotFoundInRegion_THIS_CLASS_IS_DEPRECATED.toLocalizedString()); - } -} diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/LowMemoryException.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/LowMemoryException.java index c541b37cf..09cadfd4b 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/LowMemoryException.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/LowMemoryException.java @@ -58,6 +58,16 @@ public LowMemoryException(String msg, final Set criticalMembe CallbackFactoryProvider.getStoreCallbacks().logMemoryStats(); } + /** + * Constructs an instance of LowMemoryException with the specified cause. + * @param cause + */ + public LowMemoryException(Throwable cause) { + super(cause); + this.critMems = Collections.emptySet(); + CallbackFactoryProvider.getStoreCallbacks().logMemoryStats(); + } + /** * Get a read-only set of members in a critical state at the time this * exception was constructed. diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RemoteTransactionException.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RemoteTransactionException.java deleted file mode 100644 index 91f60c66d..000000000 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RemoteTransactionException.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you - * may not use this file except in compliance with the License. You - * may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. See accompanying - * LICENSE file. - */ -package com.gemstone.gemfire.cache; - -/** - * Indicates that an unexpected runtime exception occurred - * during a cache operation on the transactional data host. - * - *

This exception only occurs when a transaction - * is hosted on a member that is not - * the initiator of the transaction. - * - * @author gregp - * @since 6.5 - * @deprecated as of 6.6 exceptions from a remote node are no longer wrapped in this exception. Instead of this, {@link TransactionDataNodeHasDepartedException} is thrown. - */ -public class RemoteTransactionException extends TransactionException { - - private static final long serialVersionUID = -2217135580436381984L; - - public RemoteTransactionException(String s) { - super(s); - } - - public RemoteTransactionException(Exception e) { - super(e); - } -} diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/client/internal/TXSynchronizationOp.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/client/internal/TXSynchronizationOp.java index 1b387680d..637a7a52b 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/client/internal/TXSynchronizationOp.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/client/internal/TXSynchronizationOp.java @@ -18,7 +18,7 @@ package com.gemstone.gemfire.cache.client.internal; import com.gemstone.gemfire.GemFireException; -import com.gemstone.gemfire.cache.CommitConflictException; +import com.gemstone.gemfire.cache.ConflictException; import com.gemstone.gemfire.cache.SynchronizationCommitConflictException; import com.gemstone.gemfire.cache.client.ServerOperationException; import com.gemstone.gemfire.i18n.LogWriterI18n; @@ -94,7 +94,7 @@ protected void processAck(Message msg, String opName) Part part = msg.getPart(0); if (msgType == MessageType.EXCEPTION) { Throwable t = (Throwable) part.getObject(); - if (t instanceof CommitConflictException || + if (t instanceof ConflictException || t instanceof SynchronizationCommitConflictException) { throw (GemFireException)t; } diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionAdvisor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionAdvisor.java index b546a2d1a..8a81924bb 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionAdvisor.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionAdvisor.java @@ -46,9 +46,9 @@ import com.gemstone.gemfire.internal.cache.persistence.PersistentMemberID; import com.gemstone.gemfire.internal.cache.versions.VersionSource; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; -import io.snappydata.collection.OpenHashSet; import com.gemstone.gemfire.internal.shared.Version; import com.gemstone.gemfire.internal.util.ArrayUtils; +import org.eclipse.collections.impl.set.mutable.UnifiedSet; /** * Provides advice on sending distribution messages. For a given operation, @@ -1395,7 +1395,7 @@ protected Set adviseFilter(Filter f) { getLogWriter().fine("Intelligent Messaging Disabled"); return getDefaultDistributionMembers(); } - OpenHashSet recipients = new OpenHashSet<>(4); + UnifiedSet recipients = new UnifiedSet<>(4); Profile[] locProfiles = this.profiles; // grab current profiles // getLogWriter().fine("adviseFilter: " + locProfiles.length + " to consider, f=" + f); for (int i = 0; i < locProfiles.length; i++) { diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfig.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfig.java index 0245ca13d..ab5c51c45 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfig.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfig.java @@ -2328,7 +2328,7 @@ public interface DistributionConfig extends Config, ManagerLogWriter.LogConfig { public static final String DISABLE_AUTO_RECONNECT_NAME = "disable-auto-reconnect"; /** The default value of the corresponding property */ - public static final boolean DEFAULT_DISABLE_AUTO_RECONNECT = false; + public static final boolean DEFAULT_DISABLE_AUTO_RECONNECT = true; /** * Gets the value of "disable-auto-reconnect" diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java index 779704513..d7693c495 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalDistributedSystem.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalDistributedSystem.java index 3e9289b87..7e9e7278e 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalDistributedSystem.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalDistributedSystem.java @@ -1472,7 +1472,7 @@ protected void disconnect(boolean preparingForReconnect, String reason, boolean LocalizedStrings.InternalDistributedSystem_EXCEPTION_TRYING_TO_CLOSE_CACHE, e); } finally { - disconnectListenerThread.set(Boolean.FALSE); + disconnectListenerThread.remove(); } } if (!preparingForReconnect) { diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/locks/DLockGrantor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/locks/DLockGrantor.java index 69ade095c..a4699d9f3 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/locks/DLockGrantor.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/locks/DLockGrantor.java @@ -543,7 +543,7 @@ void handleLockBatch(DLockRequestMessage request) throws InterruptedException { // request.respondWithTryLockFailed(name); // } } - catch (CommitConflictException ex) { + catch (ConflictException ex) { request.respondWithTryLockFailed(ex.getMessage()); } finally { diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/locks/DLockService.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/locks/DLockService.java index 9f4ac807e..8827e5a90 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/locks/DLockService.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/locks/DLockService.java @@ -1728,7 +1728,7 @@ else if (processor.repliedNotHolder()) { if (!gotLock && interruptible && Thread.interrupted()) { throw new InterruptedException(); } - blockedOn.set(null); + blockedOn.remove(); } if (getLogWriter().fineEnabled()) { diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/locks/DistributedMemberLock.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/locks/DistributedMemberLock.java index d1c80a1dd..6feb20dbe 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/locks/DistributedMemberLock.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/locks/DistributedMemberLock.java @@ -260,7 +260,11 @@ private boolean doExecuteOperation(Operation lockOp, boolean interruptible) } finally { this.threadState.interruptible = false; - this.dls.getThreadRequestState().set(oldThreadState); + if (oldThreadState == null) { + this.dls.getThreadRequestState().remove(); + } else { + this.dls.getThreadRequestState().set(oldThreadState); + } } } diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/jgroup/JGroupMembershipManager.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/jgroup/JGroupMembershipManager.java index c5ba88f61..3f7eb4e1d 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/jgroup/JGroupMembershipManager.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/jgroup/JGroupMembershipManager.java @@ -30,32 +30,14 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import com.gemstone.gemfire.CancelException; -import com.gemstone.gemfire.DataSerializer; -import com.gemstone.gemfire.ForcedDisconnectException; -import com.gemstone.gemfire.GemFireConfigException; -import com.gemstone.gemfire.InternalGemFireError; -import com.gemstone.gemfire.SystemConnectException; -import com.gemstone.gemfire.SystemFailure; -import com.gemstone.gemfire.ToDataException; +import com.gemstone.gemfire.*; import com.gemstone.gemfire.cache.Cache; import com.gemstone.gemfire.cache.util.BoundedLinkedHashMap; import com.gemstone.gemfire.distributed.DistributedMember; import com.gemstone.gemfire.distributed.DistributedSystem; import com.gemstone.gemfire.distributed.DistributedSystemDisconnectedException; import com.gemstone.gemfire.distributed.Locator; -import com.gemstone.gemfire.distributed.internal.DMStats; -import com.gemstone.gemfire.distributed.internal.DistributionConfig; -import com.gemstone.gemfire.distributed.internal.DistributionException; -import com.gemstone.gemfire.distributed.internal.DistributionManager; -import com.gemstone.gemfire.distributed.internal.DistributionMessage; -import com.gemstone.gemfire.distributed.internal.DistributionStats; -import com.gemstone.gemfire.distributed.internal.HighPriorityDistributionMessage; -import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; -import com.gemstone.gemfire.distributed.internal.InternalLocator; -import com.gemstone.gemfire.distributed.internal.SizeableRunnable; -import com.gemstone.gemfire.distributed.internal.StartupMessage; -import com.gemstone.gemfire.distributed.internal.ThrottlingMemLinkedQueueWithDMStats; +import com.gemstone.gemfire.distributed.internal.*; import com.gemstone.gemfire.distributed.internal.direct.DirectChannel; import com.gemstone.gemfire.distributed.internal.membership.DistributedMembershipListener; import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember; @@ -84,16 +66,8 @@ import com.gemstone.gemfire.internal.tcp.Stub; import com.gemstone.gemfire.internal.tcp.TCPConduit; import com.gemstone.gemfire.internal.util.Breadcrumbs; -import com.gemstone.org.jgroups.Address; -import com.gemstone.org.jgroups.Channel; -import com.gemstone.org.jgroups.ChannelClosedException; -import com.gemstone.org.jgroups.ChannelNotConnectedException; -import com.gemstone.org.jgroups.JChannel; -import com.gemstone.org.jgroups.Message; -import com.gemstone.org.jgroups.Receiver; -import com.gemstone.org.jgroups.ShunnedAddressException; -import com.gemstone.org.jgroups.SuspectMember; -import com.gemstone.org.jgroups.View; +import com.gemstone.gnu.trove.TObjectProcedure; +import com.gemstone.org.jgroups.*; import com.gemstone.org.jgroups.debug.JChannelTestHook; import com.gemstone.org.jgroups.protocols.FD; import com.gemstone.org.jgroups.protocols.FD_SOCK; @@ -109,8 +83,7 @@ import com.gemstone.org.jgroups.stack.IpAddress; import com.gemstone.org.jgroups.stack.ProtocolStack; import com.gemstone.org.jgroups.util.GemFireTracer; -import com.gemstone.gnu.trove.TObjectProcedure; -import io.snappydata.collection.IntObjectHashMap; +import org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap; public final class JGroupMembershipManager implements MembershipManager { @@ -3293,15 +3266,15 @@ public Set send(InternalDistributedMember[] destinations, calculatedMembers.add((JGroupMember)destinations[i].getNetMember()); } } // send to explicit list - IntObjectHashMap messages = IntObjectHashMap.withExpectedSize(2); + IntObjectHashMap messages = new IntObjectHashMap<>(2); long startSer = theStats.startMsgSerialization(); boolean firstMessage = true; for (Iterator it=calculatedMembers.iterator(); it.hasNext(); ) { JGroupMember mbr = (JGroupMember)it.next(); short version = mbr.getAddress().getVersionOrdinal(); - if (!messages.contains(version)) { + if (!messages.containsKey(version)) { Message jmsg = createJGMessage(msg, local, version); - messages.justPut(version, jmsg); + messages.put(version, jmsg); if (firstMessage) { theStats.incSentBytes(jmsg.getLength()); firstMessage = false; @@ -3453,7 +3426,7 @@ public void forceUDPMessagingForCurrentThread() { // MembershipManager method @Override public void releaseUDPMessagingForCurrentThread() { - forceUseJGroups.set(null); + forceUseJGroups.remove(); } private boolean isForceUDPCommunications() { diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/AvailablePort.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/AvailablePort.java index e73ebbb4b..3154e0eb6 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/AvailablePort.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/AvailablePort.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/Banner.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/Banner.java index 52bf2720d..bbb153d0b 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/Banner.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/Banner.java @@ -78,7 +78,7 @@ private static void print(PrintWriter out, String args[]) { out.println(SEPERATOR); out.println(); - out.println(" Copyright (c) 2017 SnappyData, Inc. All rights reserved."); + out.println(" Copyright (c) 2018 SnappyData, Inc. All rights reserved."); out.println(); out.println(" Licensed under the Apache License, Version 2.0 (the \"License\"); you"); out.println(" may not use this file except in compliance with the License. You"); diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/ByteBufferDataInput.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/ByteBufferDataInput.java index 8ab0661dd..ed98e0fe7 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/ByteBufferDataInput.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/ByteBufferDataInput.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/ByteBufferDataOutput.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/ByteBufferDataOutput.java index 43602a9eb..ad808d064 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/ByteBufferDataOutput.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/ByteBufferDataOutput.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/CopyOnWriteHashSet.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/CopyOnWriteHashSet.java index d4bf0a9d3..9613116e8 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/CopyOnWriteHashSet.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/CopyOnWriteHashSet.java @@ -25,7 +25,7 @@ import java.util.Iterator; import java.util.Set; -import io.snappydata.collection.OpenHashSet; +import org.eclipse.collections.impl.set.mutable.UnifiedSet; /** * A Hash set where every modification makes an internal copy @@ -43,16 +43,16 @@ public class CopyOnWriteHashSet implements Set, Serializable { private static final long serialVersionUID = 8591978652141659932L; - private static final OpenHashSet EMPTY_SET = new OpenHashSet(1); + private static final UnifiedSet EMPTY_SET = new UnifiedSet(1); @SuppressWarnings("unchecked") - private volatile transient OpenHashSet snapshot = EMPTY_SET; + private volatile transient UnifiedSet snapshot = EMPTY_SET; public CopyOnWriteHashSet() { } public CopyOnWriteHashSet(Set copy) { - this.snapshot = new OpenHashSet<>(copy); + this.snapshot = new UnifiedSet<>(copy); } /** @@ -69,7 +69,7 @@ public int size() { public boolean add(T e) { synchronized(this) { - OpenHashSet set = new OpenHashSet<>(snapshot); + UnifiedSet set = new UnifiedSet<>(snapshot); boolean result = set.add(e); snapshot = set; return result; @@ -78,7 +78,7 @@ public boolean add(T e) { public boolean addAll(Collection c) { synchronized(this) { - OpenHashSet set = new OpenHashSet<>(snapshot); + UnifiedSet set = new UnifiedSet<>(snapshot); boolean result = set.addAll(c); snapshot = set; return result; @@ -105,7 +105,7 @@ public boolean isEmpty() { public boolean remove(Object o) { synchronized(this) { - OpenHashSet set = new OpenHashSet<>(snapshot); + UnifiedSet set = new UnifiedSet<>(snapshot); boolean result = set.remove(o); snapshot = set; return result; @@ -114,7 +114,7 @@ public boolean remove(Object o) { public boolean retainAll(Collection c) { synchronized(this) { - OpenHashSet set = new OpenHashSet<>(snapshot); + UnifiedSet set = new UnifiedSet<>(snapshot); boolean result = set.retainAll(c); snapshot = set; return result; @@ -141,7 +141,7 @@ public int hashCode() { public boolean removeAll(Collection c) { synchronized(this) { - OpenHashSet set = new OpenHashSet<>(snapshot); + UnifiedSet set = new UnifiedSet<>(snapshot); boolean result = set.removeAll(c); snapshot = set; return result; @@ -174,6 +174,6 @@ private void writeObject(ObjectOutputStream s) throws IOException { private void readObject(ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { s.defaultReadObject(); - this.snapshot = (OpenHashSet)s.readObject(); + this.snapshot = (UnifiedSet)s.readObject(); } } diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/DSFIDFactory.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/DSFIDFactory.java index c6ad055d4..e355eadb7 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/DSFIDFactory.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/DSFIDFactory.java @@ -17,13 +17,31 @@ package com.gemstone.gemfire.internal; +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; +import java.io.NotSerializableException; +import java.util.function.Supplier; + import com.gemstone.gemfire.DataSerializer; -import com.gemstone.gemfire.admin.internal.*; +import com.gemstone.gemfire.admin.internal.FinishBackupRequest; +import com.gemstone.gemfire.admin.internal.FinishBackupResponse; +import com.gemstone.gemfire.admin.internal.FlushToDiskRequest; +import com.gemstone.gemfire.admin.internal.FlushToDiskResponse; +import com.gemstone.gemfire.admin.internal.PrepareBackupRequest; +import com.gemstone.gemfire.admin.internal.PrepareBackupResponse; +import com.gemstone.gemfire.admin.internal.SystemMemberCacheEventProcessor; import com.gemstone.gemfire.admin.jmx.internal.StatAlertNotification; import com.gemstone.gemfire.cache.InterestResultPolicy; import com.gemstone.gemfire.cache.client.internal.BridgeServerLoadMessage; import com.gemstone.gemfire.cache.client.internal.locator.*; -import com.gemstone.gemfire.cache.client.internal.locator.wan.*; +import com.gemstone.gemfire.cache.client.internal.locator.wan.LocatorJoinMessage; +import com.gemstone.gemfire.cache.client.internal.locator.wan.RemoteLocatorJoinRequest; +import com.gemstone.gemfire.cache.client.internal.locator.wan.RemoteLocatorJoinResponse; +import com.gemstone.gemfire.cache.client.internal.locator.wan.RemoteLocatorPingRequest; +import com.gemstone.gemfire.cache.client.internal.locator.wan.RemoteLocatorPingResponse; +import com.gemstone.gemfire.cache.client.internal.locator.wan.RemoteLocatorRequest; +import com.gemstone.gemfire.cache.client.internal.locator.wan.RemoteLocatorResponse; import com.gemstone.gemfire.cache.hdfs.internal.HDFSGatewayEventImpl; import com.gemstone.gemfire.cache.query.QueryService; import com.gemstone.gemfire.cache.query.internal.*; @@ -95,9 +113,15 @@ import com.gemstone.gemfire.internal.cache.partitioned.RemoveBucketMessage.RemoveBucketReplyMessage; import com.gemstone.gemfire.internal.cache.partitioned.RemoveIndexesMessage.RemoveIndexesReplyMessage; import com.gemstone.gemfire.internal.cache.partitioned.SizeMessage.SizeReplyMessage; -import com.gemstone.gemfire.internal.cache.persistence.*; +import com.gemstone.gemfire.internal.cache.persistence.DiskStoreID; +import com.gemstone.gemfire.internal.cache.persistence.MembershipFlushRequest; +import com.gemstone.gemfire.internal.cache.persistence.MembershipViewRequest; import com.gemstone.gemfire.internal.cache.persistence.MembershipViewRequest.MembershipViewReplyMessage; +import com.gemstone.gemfire.internal.cache.persistence.PersistentStateQueryMessage; import com.gemstone.gemfire.internal.cache.persistence.PersistentStateQueryMessage.PersistentStateQueryReplyMessage; +import com.gemstone.gemfire.internal.cache.persistence.PrepareNewPersistentMemberMessage; +import com.gemstone.gemfire.internal.cache.persistence.RemovePersistentMemberMessage; +import com.gemstone.gemfire.internal.cache.persistence.StartupSequenceQueryMesasge; import com.gemstone.gemfire.internal.cache.snapshot.FlowController.FlowControlAbortMessage; import com.gemstone.gemfire.internal.cache.snapshot.FlowController.FlowControlAckMessage; import com.gemstone.gemfire.internal.cache.snapshot.SnapshotPacket; @@ -129,13 +153,7 @@ import com.gemstone.org.jgroups.protocols.pbcast.JoinRsp; import com.gemstone.org.jgroups.stack.IpAddress; import com.gemstone.org.jgroups.util.StreamableFixedID; -import io.snappydata.collection.IntObjectHashMap; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.io.NotSerializableException; -import java.util.function.Supplier; +import org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap; /** * Factory for instances of DataSerializableFixedID instances. @@ -170,7 +188,7 @@ public Version[] getSerializationVersions() { private static volatile boolean typesRegistered; private static final Supplier[] dsfidMap = new Supplier[256]; private static final IntObjectHashMap> dsfidMap2 = - IntObjectHashMap.withExpectedSize(512); + new IntObjectHashMap<>(512); static { if (!InternalDistributedSystem.isHadoopGfxdLonerMode()) { @@ -182,7 +200,7 @@ static void registerDSFID(int dsfid, Supplier creator) { if (dsfid >= Byte.MIN_VALUE && dsfid <= Byte.MAX_VALUE) { dsfidMap[dsfid + Byte.MAX_VALUE + 1] = creator; } else { - dsfidMap2.justPut(dsfid, creator); + dsfidMap2.put(dsfid, creator); } } diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/GFToSlf4jBridge.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/GFToSlf4jBridge.java index df4cb6760..309ad2ff0 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/GFToSlf4jBridge.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/GFToSlf4jBridge.java @@ -135,8 +135,8 @@ public Logger getLogger() { ? ClientSharedUtils.LOGGER_NAME + '.' + this.logName : ClientSharedUtils.LOGGER_NAME; try { - ClientSharedUtils.initLog4j(this.logFile, - GemFireLevel.create(this.level)); + ClientSharedUtils.initLog4j(this.logFile, ClientSharedUtils + .convertToLog4LogLevel(GemFireLevel.create(this.level))); } catch (IOException ioe) { throw new GemFireIOException(ioe.getMessage(), ioe); } diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/InternalDataSerializer.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/InternalDataSerializer.java index c3a25fb64..e3bfe18b2 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/InternalDataSerializer.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/InternalDataSerializer.java @@ -62,7 +62,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/LinuxProcFsStatistics.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/LinuxProcFsStatistics.java index 3874af115..e90268f29 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/LinuxProcFsStatistics.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/LinuxProcFsStatistics.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/LinuxSystemStats.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/LinuxSystemStats.java index 25977da0b..e6aa8b17f 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/LinuxSystemStats.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/LinuxSystemStats.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/LogWriterImpl.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/LogWriterImpl.java index b50579e4b..c677e7bef 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/LogWriterImpl.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/LogWriterImpl.java @@ -258,13 +258,15 @@ public static int levelNameToCode(String levelName) { if ("all".equalsIgnoreCase(levelName)) { return ALL_LEVEL; } - if ("finest".equalsIgnoreCase(levelName)) { + if ("finest".equalsIgnoreCase(levelName) || + "trace".equalsIgnoreCase(levelName)) { return FINEST_LEVEL; } if ("finer".equalsIgnoreCase(levelName)) { return FINER_LEVEL; } - if ("fine".equalsIgnoreCase(levelName)) { + if ("fine".equalsIgnoreCase(levelName) || + "debug".equalsIgnoreCase(levelName)) { return FINE_LEVEL; } if ("config".equalsIgnoreCase(levelName)) { @@ -273,16 +275,19 @@ public static int levelNameToCode(String levelName) { if ("info".equalsIgnoreCase(levelName)) { return INFO_LEVEL; } - if ("warning".equalsIgnoreCase(levelName)) { + if ("warning".equalsIgnoreCase(levelName) || + "warn".equalsIgnoreCase(levelName)) { return WARNING_LEVEL; } if ("error".equalsIgnoreCase(levelName)) { return ERROR_LEVEL; } - if ("severe".equalsIgnoreCase(levelName)) { + if ("severe".equalsIgnoreCase(levelName) || + "fatal".equalsIgnoreCase(levelName)) { return SEVERE_LEVEL; } - if ("none".equalsIgnoreCase(levelName)) { + if ("none".equalsIgnoreCase(levelName) || + "off".equalsIgnoreCase(levelName)) { return NONE_LEVEL; } try { @@ -382,6 +387,7 @@ public static void cleanUpThreadGroups() { && !group.getName() .equals("GemFireConnectionFactory Shutdown Hook")) { group.cleanup(); + itr.remove(); } } } diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/StatisticsImpl.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/StatisticsImpl.java index 04346e61a..e7c717db6 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/StatisticsImpl.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/StatisticsImpl.java @@ -379,7 +379,7 @@ public void prepareForSample() { @Override public int hashCode() { - return (int)this.uniqueId; + return Long.hashCode(this.uniqueId); } @Override public boolean equals(Object o) { diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractLRURegionMap.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractLRURegionMap.java index c7f4bb375..5976c7990 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractLRURegionMap.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractLRURegionMap.java @@ -836,10 +836,7 @@ public final void enableLruUpdateCallbackForInline() { @Override public final void resetThreadLocals() { - ThreadLocalEntry e = threadLocals.get(); - e.lruDelta = null; - e.mustRemove = null; - e.callbackDisabled = null; + threadLocals.remove(); } @Override diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegion.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegion.java index 6b3a9a95a..0742fcdf9 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegion.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegion.java @@ -972,7 +972,11 @@ public Object getIMSync() { // Once the thread has created the Index , it will unset the value in the // ThreadLocal Object public final void setFlagForIndexCreationThread(boolean bool) { - this.isIndexCreator.set(bool ? Boolean.TRUE : null); + if (bool) { + this.isIndexCreator.set(true); + } else { + this.isIndexCreator.remove(); + } } //Asif : The boolean is used in AbstractRegionEntry to skip the synchronized @@ -2206,7 +2210,7 @@ public final void operationCompleted() { //InternalDistributedSystem.getLoggerI18n().warning(LocalizedStrings.DEBUG, "SWAP:operationCompleted", new Throwable()); if (logHDFSCalls.get() != null && logHDFSCalls.get().decNestedCall() < 0) { logHDFSCalls.get().assertCalls(); - logHDFSCalls.set(null); + logHDFSCalls.remove(); } } diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java index ab676f1cd..ddad7def7 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java @@ -308,6 +308,10 @@ public final boolean isTombstone() { public final boolean isRemovedPhase2() { return getValueAsToken() == Token.REMOVED_PHASE2; } + + public final boolean isRemovedPhase1() { + return getValueAsToken() == Token.REMOVED_PHASE1; + } public boolean fillInValue(LocalRegion region, @Retained(ABSTRACT_REGION_ENTRY_FILL_IN_VALUE) InitialImageOperation.Entry dst, @@ -1430,16 +1434,23 @@ final void _setValue(RegionEntryContext context, @Unretained final Object val) { Object rawOldVal = null; if (!isOffHeap) { rawOldVal = getValueField(); - if (rawOldVal != val && rawOldVal instanceof SerializedDiskBuffer) { - // sync block ensures that region stats and reference count update are - // atomic so any concurrent readers changing internal buffer from - // compressed to decompressed or vice-versa also update stats atomically + if (rawOldVal == val) return; + // sync blocks below ensure that region stats and reference count update are + // atomic so any concurrent readers changing internal buffer from + // compressed to decompressed or vice-versa also update stats atomically + if (rawOldVal instanceof SerializedDiskBuffer) { synchronized (rawOldVal) { setValueField(val); if (context != null) context.updateMemoryStats(rawOldVal, val); ((SerializedDiskBuffer)rawOldVal).release(); } return; + } else if (val instanceof SerializedDiskBuffer) { + synchronized (val) { + setValueField(val); + if (context != null) context.updateMemoryStats(rawOldVal, val); + } + return; } } diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/BucketRegion.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/BucketRegion.java index 9b395a6dc..7ff10014c 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/BucketRegion.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/BucketRegion.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -75,7 +75,6 @@ import com.gemstone.gemfire.internal.cache.tier.sockets.CacheClientNotifier; import com.gemstone.gemfire.internal.cache.tier.sockets.ClientTombstoneMessage; import com.gemstone.gemfire.internal.cache.tier.sockets.ClientUpdateMessage; -import com.gemstone.gemfire.internal.cache.versions.RegionVersionVector; import com.gemstone.gemfire.internal.cache.versions.VersionSource; import com.gemstone.gemfire.internal.cache.versions.VersionStamp; import com.gemstone.gemfire.internal.cache.versions.VersionTag; @@ -756,7 +755,7 @@ boolean virtualPut(EntryEventImpl event, public final boolean checkForColumnBatchCreation(TXStateInterface tx) { final PartitionedRegion pr = getPartitionedRegion(); - return pr.needsBatching() + return pr.isRowBuffer() && (tx == null || !tx.getProxy().isColumnRolloverDisabled()) && (getRegionSize() >= pr.getColumnMaxDeltaRows() || getTotalBytes() >= pr.getColumnBatchSize()); @@ -1249,7 +1248,7 @@ private boolean readLockEnabled() { if (lockGIIForSnapshot) { // test hook return true; } - if ((this.getPartitionedRegion().needsBatching() || + if ((this.getPartitionedRegion().isRowBuffer() || this.getPartitionedRegion().isInternalColumnTable()) && cache.snapshotEnabled()) { return true; @@ -1290,27 +1289,9 @@ private boolean lockPrimaryStateWriteLock() { return true; } - private volatile Boolean rowBuffer = false; - - public boolean isRowBuffer() { - final Boolean rowBuffer = this.rowBuffer; - if (rowBuffer || this.getName().toUpperCase().endsWith(StoreCallbacks.SHADOW_TABLE_SUFFIX)) { - return rowBuffer; - } - boolean isRowBuffer = false; - List childRegions = ColocationHelper.getColocatedChildRegions(this.getPartitionedRegion()); - for (PartitionedRegion pr : childRegions) { - isRowBuffer |= pr.getName().toUpperCase().endsWith(StoreCallbacks.SHADOW_TABLE_SUFFIX); - } - this.rowBuffer = isRowBuffer; - return isRowBuffer; - } - - public void takeSnapshotGIIReadLock() { if (readLockEnabled()) { - if (this.getPartitionedRegion(). - getName().toUpperCase().endsWith(StoreCallbacks.SHADOW_TABLE_SUFFIX)) { + if (this.getPartitionedRegion().isInternalColumnTable()) { BucketRegion bufferRegion = getBufferRegion(); bufferRegion.takeSnapshotGIIReadLock(); } else { @@ -1326,8 +1307,7 @@ public void takeSnapshotGIIReadLock() { public void releaseSnapshotGIIReadLock() { if (readLockEnabled()) { - if (this.getPartitionedRegion(). - getName().toUpperCase().endsWith(StoreCallbacks.SHADOW_TABLE_SUFFIX)) { + if (this.getPartitionedRegion().isInternalColumnTable()) { BucketRegion bufferRegion = getBufferRegion(); bufferRegion.releaseSnapshotGIIReadLock(); } else { @@ -1346,8 +1326,7 @@ public void releaseSnapshotGIIReadLock() { public boolean takeSnapshotGIIWriteLock(MembershipListener listener) { if (writeLockEnabled()) { - if (this.getPartitionedRegion(). - getName().toUpperCase().endsWith(StoreCallbacks.SHADOW_TABLE_SUFFIX)) { + if (this.getPartitionedRegion().isInternalColumnTable()) { BucketRegion bufferRegion = getBufferRegion(); return bufferRegion.takeSnapshotGIIWriteLock(listener); } else { @@ -1372,8 +1351,7 @@ public boolean takeSnapshotGIIWriteLock(MembershipListener listener) { public void releaseSnapshotGIIWriteLock() { if (writeLockEnabled()) { - if (this.getPartitionedRegion(). - getName().toUpperCase().endsWith(StoreCallbacks.SHADOW_TABLE_SUFFIX)) { + if (this.getPartitionedRegion().isInternalColumnTable()) { BucketRegion bufferRegion = getBufferRegion(); bufferRegion.releaseSnapshotGIIWriteLock(); } else { @@ -3403,6 +3381,11 @@ public boolean areSecondariesPingable() { } + @Override + public boolean isRowBuffer() { + return getPartitionedRegion().isRowBuffer(); + } + @Override public boolean isInternalColumnTable() { return getPartitionedRegion().isInternalColumnTable(); @@ -3411,8 +3394,6 @@ public boolean isInternalColumnTable() { @Override public boolean isSnapshotEnabledRegion() { // concurrency checks is by default true in column table - return getPartitionedRegion().isInternalColumnTable() || - getPartitionedRegion().needsBatching() || super.isSnapshotEnabledRegion(); + return isInternalColumnTable() || isRowBuffer() || super.isSnapshotEnabledRegion(); } - } diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/CacheServerLauncher.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/CacheServerLauncher.java index d393131d9..3c6e41340 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/CacheServerLauncher.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/CacheServerLauncher.java @@ -51,8 +51,8 @@ import com.gemstone.gemfire.internal.process.StartupStatusListener; import com.gemstone.gemfire.internal.shared.LauncherBase; import com.gemstone.gemfire.internal.shared.NativeCalls; -import io.snappydata.collection.OpenHashSet; import com.gemstone.gemfire.internal.util.JavaCommandBuilder; +import org.eclipse.collections.impl.set.mutable.UnifiedSet; import static com.gemstone.gemfire.internal.cache.Status.*; @@ -86,14 +86,14 @@ public class CacheServerLauncher extends LauncherBase { protected LogWriterI18n logger = null; protected String offHeapSize; protected volatile String serverStartupMessage; - protected final OpenHashSet knownOptions; + protected final UnifiedSet knownOptions; protected static CacheServerLauncher instance; public CacheServerLauncher(final String baseName) { super(baseName, null); assert baseName != null : "The base name used for the cache server launcher files cannot be null!"; - knownOptions = new OpenHashSet<>(); + knownOptions = new UnifiedSet<>(); initKnownOptions(); } diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/ColocationHelper.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/ColocationHelper.java index ed63423a5..2daa14c3b 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/ColocationHelper.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/ColocationHelper.java @@ -18,17 +18,8 @@ package com.gemstone.gemfire.internal.cache; import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; -import java.util.Set; import com.gemstone.gemfire.cache.EntryDestroyedException; import com.gemstone.gemfire.cache.Region; @@ -42,7 +33,7 @@ import com.gemstone.gemfire.internal.cache.partitioned.PRLocallyDestroyedException; import com.gemstone.gemfire.internal.cache.persistence.PRPersistentConfig; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; -import io.snappydata.collection.OpenHashSet; +import org.eclipse.collections.impl.set.mutable.UnifiedSet; /** * An utility class to retrieve colocated regions in a colocation hierarchy in @@ -169,7 +160,7 @@ public static PartitionedRegion getColocatedRegion( * be in the advisor. */ public static boolean checkMembersColocation(PartitionedRegion partitionedRegion, InternalDistributedMember member) { - OpenHashSet colocatedRegions = new OpenHashSet<>(); + UnifiedSet colocatedRegions = new UnifiedSet<>(); List tempcolocatedRegions = new ArrayList(); Region prRoot = PartitionedRegionHelper.getPRRoot(partitionedRegion .getCache()); diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskEntry.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskEntry.java index 3dee93478..f2bcb4ff5 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskEntry.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskEntry.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskId.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskId.java index 9886f13a6..d108df9fd 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskId.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskId.java @@ -248,14 +248,21 @@ public String toString() { * StringBuffer temp = new StringBuffer("Oplog Key ID = "); * temp.append(this.keyId); */ - StringBuffer temp = new StringBuffer("Oplog ID = "); - temp.append(this.getOplogId()); + StringBuilder temp = new StringBuilder("Oplog ID = "); + final long id = this.id; + //mask the first byte to get the oplogId + long oplogId = id & MAX_OPLOG_ID; + //Check to see if the oplog id should be negative + if ((id & OPLOG_ID_SIGN_BIT) != 0) { + oplogId = -1L * oplogId; + } + temp.append(oplogId); temp.append("; Offset in Oplog = "); temp.append(getOffsetInOplog()); temp.append("; Value Length = "); temp.append(getValueLength()); temp.append("; UserBits is = "); - temp.append(this.getUserBits()); + temp.append(id >> USER_BITS_SHIFT); return temp.toString(); } @@ -647,7 +654,7 @@ protected void copyFields(DiskId other) { @Override public String toString() { - StringBuffer temp = new StringBuffer("Oplog Key ID = "); + StringBuilder temp = new StringBuilder("Oplog Key ID = "); temp.append(this.keyId); temp.append("; "); temp.append(super.toString()); @@ -737,7 +744,7 @@ protected void copyFields(DiskId other) { @Override public String toString() { - StringBuffer temp = new StringBuffer("Oplog Key ID = "); + StringBuilder temp = new StringBuilder("Oplog Key ID = "); temp.append(this.keyId); temp.append("; "); temp.append(super.toString()); diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskInitFile.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskInitFile.java index 037d1c966..1bea082fe 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskInitFile.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskInitFile.java @@ -16,30 +16,9 @@ */ package com.gemstone.gemfire.internal.cache; -import java.io.BufferedInputStream; -import java.io.ByteArrayInputStream; -import java.io.DataInput; -import java.io.DataInputStream; -import java.io.DataOutput; -import java.io.EOFException; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.io.RandomAccessFile; +import java.io.*; import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; import com.gemstone.gemfire.CancelCriterion; @@ -58,15 +37,7 @@ import com.gemstone.gemfire.internal.InternalDataSerializer; import com.gemstone.gemfire.internal.InternalInstantiator; import com.gemstone.gemfire.internal.InternalInstantiator.InstantiatorAttributesHolder; -import com.gemstone.gemfire.internal.cache.persistence.CanonicalIdHolder; -import com.gemstone.gemfire.internal.cache.persistence.DiskExceptionHandler; -import com.gemstone.gemfire.internal.cache.persistence.DiskInitFileInterpreter; -import com.gemstone.gemfire.internal.cache.persistence.DiskInitFileParser; -import com.gemstone.gemfire.internal.cache.persistence.DiskRegionView; -import com.gemstone.gemfire.internal.cache.persistence.DiskStoreID; -import com.gemstone.gemfire.internal.cache.persistence.PRPersistentConfig; -import com.gemstone.gemfire.internal.cache.persistence.PersistentMemberID; -import com.gemstone.gemfire.internal.cache.persistence.PersistentMemberPattern; +import com.gemstone.gemfire.internal.cache.persistence.*; import com.gemstone.gemfire.internal.cache.versions.DiskRegionVersionVector; import com.gemstone.gemfire.internal.cache.versions.RegionVersionHolder; import com.gemstone.gemfire.internal.cache.versions.RegionVersionVector; @@ -75,7 +46,7 @@ import com.gemstone.gnu.trove.TIntHashSet; import com.gemstone.gnu.trove.TLongHashSet; import com.gemstone.gnu.trove.TLongIterator; -import io.snappydata.collection.IntObjectHashMap; +import org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap; /** * Does all the IF file work for a DiskStoreImpl. @@ -1840,10 +1811,7 @@ private void savePRConfigs() { private void saveCanonicalIds() { IntObjectHashMap mappings = canonicalIdHolder.getAllMappings(); - mappings.forEachWhile((id, v) -> { - writeCanonicalId(id, v); - return true; - }); + mappings.forEachKeyValue(this::writeCanonicalId); } private void saveRevokedMembers() { diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskRegion.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskRegion.java index 4d2834068..53ebda228 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskRegion.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskRegion.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskStoreImpl.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskStoreImpl.java index e7c0a7a43..d67ae3e23 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskStoreImpl.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DiskStoreImpl.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -45,7 +45,12 @@ import java.nio.channels.FileChannel; import java.nio.channels.FileLock; import java.util.*; -import java.util.concurrent.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.Future; +import java.util.concurrent.RejectedExecutionException; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; @@ -64,7 +69,6 @@ import com.gemstone.gemfire.cache.DiskAccessException; import com.gemstone.gemfire.cache.DiskStore; import com.gemstone.gemfire.cache.DiskStoreFactory; -import com.gemstone.gemfire.cache.LowMemoryException; import com.gemstone.gemfire.cache.RegionDestroyedException; import com.gemstone.gemfire.cache.persistence.PersistentID; import com.gemstone.gemfire.cache.query.IndexMaintenanceException; @@ -101,6 +105,8 @@ import com.gemstone.gemfire.internal.shared.Version; import com.gemstone.gnu.trove.THashMap; import com.gemstone.gnu.trove.THashSet; +import org.eclipse.collections.impl.set.mutable.primitive.IntHashSet; +import org.eclipse.collections.impl.set.mutable.primitive.LongHashSet; import static com.gemstone.gemfire.internal.cache.GemFireCacheImpl.sysProps; @@ -2214,13 +2220,8 @@ public void scheduleIndexRecovery(Set allOplogs, boolean recreateIndexes) IndexRecoveryTask task = new IndexRecoveryTask(allOplogs, recreateIndexes); // other disk store threads wait for this task, so use a different // thread pool for execution if possible (not in loner VM) - ThreadPoolExecutor executor; - if (getCache().getDistributionManager().isLoner()) { - executor = getCache().getDiskDelayedWritePool(); - } else { - executor = (ThreadPoolExecutor)getCache().getDistributionManager() - .getWaitingThreadPool(); - } + ThreadPoolExecutor executor = getCache() + .getWaitingThreadPoolOrDiskWritePool(); executeDiskStoreTask(task, executor, true); } } @@ -3949,10 +3950,8 @@ public String toString() { * in the unsigned int range. */ public static class OplogEntryIdSet { - private final TStatelessIntHashSet ints = new TStatelessIntHashSet( - (int) INVALID_ID); - private final TStatelessLongHashSet longs = new TStatelessLongHashSet( - INVALID_ID); + private final IntHashSet ints = new IntHashSet(8); + private final LongHashSet longs = new LongHashSet(8); public void add(long id) { if (id >= 0 && id <= 0x00000000FFFFFFFFL) { diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedPutAllOperation.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedPutAllOperation.java index 15207c99e..dc62363a0 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedPutAllOperation.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedPutAllOperation.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRegion.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRegion.java index 85dec606c..895e8d3dc 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRegion.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRegion.java @@ -119,6 +119,7 @@ import com.gemstone.gnu.trove.TObjectIntProcedure; import com.gemstone.gnu.trove.TObjectObjectProcedure; import com.gemstone.org.jgroups.util.StringId; +import org.eclipse.collections.impl.map.mutable.UnifiedMap; /** * @@ -1276,7 +1277,8 @@ public boolean isProfileExchanged() { * to constraint violations for replicated tables which should also be skipped * on destination */ - private final THashMapWithCreate failedEvents = new THashMapWithCreate(); + private final UnifiedMap> failedEvents = + new UnifiedMap<>(); private ConcurrentParallelGatewaySenderQueue hdfsQueue; @@ -2808,17 +2810,7 @@ public final void registerFailedEvent(final EventID eventId) { // we don't care much about perf of failed events but for correctness // hence a sync on the entire map synchronized (this.failedEvents) { - this.failedEvents.forEachEntry(new TObjectObjectProcedure() { - @Override - public boolean execute(Object a, Object b) { - @SuppressWarnings("unchecked") - ArrayList failures = (ArrayList)b; - synchronized (failures) { - failures.add(eventId); - } - return true; - } - }); + this.failedEvents.forEachValue(failures -> failures.add(eventId)); } } @@ -2828,7 +2820,7 @@ public final void initFailedEventsForMember( return; } synchronized (this.failedEvents) { - this.failedEvents.putIfAbsent(member, new ArrayList()); + this.failedEvents.getIfAbsentPut(member, new ArrayList<>()); } } @@ -2852,11 +2844,8 @@ public final ArrayList getFailedEvents( return null; } synchronized (this.failedEvents) { - @SuppressWarnings("unchecked") - ArrayList events = (ArrayList)this.failedEvents - .get(member); - return events != null && !events.isEmpty() ? new ArrayList( - events) : null; + ArrayList events = this.failedEvents.get(member); + return events != null && !events.isEmpty() ? new ArrayList<>(events) : null; } } diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryEventImpl.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryEventImpl.java index 16a73e035..ad55bf047 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryEventImpl.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/EntryEventImpl.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -2537,6 +2537,7 @@ public String toString() { } catch (IllegalStateException ex) { buf.append("OFFHEAP_VALUE_FREED"); } + if (this.isPutDML) buf.append(";isPutDML=true"); buf.append(";callbackArg="); buf.append(this.getRawCallbackArgument()); buf.append(";originRemote="); diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/ExternalTableMetaData.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/ExternalTableMetaData.java index 7358bb78b..dd8b16793 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/ExternalTableMetaData.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/ExternalTableMetaData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/GemFireCacheImpl.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/GemFireCacheImpl.java index 35d1425e0..a23c2020b 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/GemFireCacheImpl.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/GemFireCacheImpl.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -139,6 +139,9 @@ import com.gemstone.gemfire.internal.cache.xmlcache.CacheXmlParser; import com.gemstone.gemfire.internal.cache.xmlcache.CacheXmlPropertyResolver; import com.gemstone.gemfire.internal.cache.xmlcache.PropertyResolver; +import com.gemstone.gemfire.internal.concurrent.CustomEntryConcurrentHashMap; +import com.gemstone.gemfire.internal.concurrent.MapCallback; +import com.gemstone.gemfire.internal.concurrent.MapCallbackAdapter; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; import com.gemstone.gemfire.internal.jndi.JNDIInvoker; import com.gemstone.gemfire.internal.jta.TransactionManagerImpl; @@ -149,11 +152,10 @@ import com.gemstone.gemfire.internal.shared.HeapBufferAllocator; import com.gemstone.gemfire.internal.shared.LauncherBase; import com.gemstone.gemfire.internal.shared.NativeCalls; -import com.gemstone.gemfire.internal.shared.unsafe.UnsafeHolder; -import io.snappydata.collection.OpenHashSet; import com.gemstone.gemfire.internal.shared.SystemProperties; import com.gemstone.gemfire.internal.shared.Version; import com.gemstone.gemfire.internal.shared.unsafe.DirectBufferAllocator; +import com.gemstone.gemfire.internal.shared.unsafe.UnsafeHolder; import com.gemstone.gemfire.internal.snappy.CallbackFactoryProvider; import com.gemstone.gemfire.internal.snappy.StoreCallbacks; import com.gemstone.gemfire.internal.snappy.memory.MemoryManagerStats; @@ -176,7 +178,8 @@ import com.gemstone.gemfire.pdx.internal.PdxInstanceImpl; import com.gemstone.gemfire.pdx.internal.TypeRegistry; import com.gemstone.gnu.trove.THashSet; -import io.snappydata.collection.ObjectObjectHashMap; +import org.eclipse.collections.impl.map.mutable.UnifiedMap; +import org.eclipse.collections.impl.set.mutable.UnifiedSet; // @todo somebody Come up with more reasonable values for {@link #DEFAULT_LOCK_TIMEOUT}, etc. /** @@ -568,7 +571,7 @@ public class GemFireCacheImpl implements InternalCache, ClientCache, HasCachePer private final ThreadPoolExecutor diskDelayedWritePool; //TODO:Suranjan This has to be replcaed with better approach. guava cache or WeakHashMap. - private final Map + private final Map> oldEntryMap; private ScheduledExecutorService oldEntryMapCleanerService; @@ -577,8 +580,7 @@ public class GemFireCacheImpl implements InternalCache, ClientCache, HasCachePer * Time interval after which oldentries cleaner thread run */ public static long OLD_ENTRIES_CLEANER_TIME_INTERVAL = Long.getLong("gemfire" + - ".snapshot-oldentries-cleaner-time-interval", 20000); - + ".snapshot-oldentries-cleaner-time-interval", 2000); /** * Test only method @@ -600,14 +602,21 @@ public void setOldEntriesCleanerTimeIntervalAndRestart(long // For each entry this should be in sync public void removeRegionFromOldEntryMap(String regionPath) { synchronized (this.oldEntryMap) { - Map> map = oldEntryMap.remove(regionPath); + Map map = oldEntryMap.remove(regionPath); if (GemFireCacheImpl.hasNewOffHeap() && map != null) { - for (BlockingQueue values : map.values()) { - if (values != null) { - for (RegionEntry re : values) { - Object value = re._getValue(); - if (value instanceof SerializedDiskBuffer) { - ((SerializedDiskBuffer)value).release(); + for (Object value : map.values()) { + if(value != null ) { + if (value instanceof BlockingQueue) { + for (RegionEntry re : (BlockingQueue) value) { + Object val = re._getValue(); + if (val instanceof SerializedDiskBuffer) { + ((SerializedDiskBuffer) val).release(); + } + } + } else { + Object val = ((RegionEntry)value)._getValue(); + if (val instanceof SerializedDiskBuffer) { + ((SerializedDiskBuffer) val).release(); } } } @@ -616,11 +625,14 @@ public void removeRegionFromOldEntryMap(String regionPath) { } } + public static boolean SNAPSHOT_DEBUG = Boolean.getBoolean("gemfire.snapshot.VERBOSE"); + public long getOldEntryRemovalPeriod() { return OLD_ENTRIES_CLEANER_TIME_INTERVAL; } // For each entry this should be in sync + public void addOldEntry(NonLocalRegionEntry oldRe, RegionEntry newEntry, LocalRegion region, EntryEventImpl event) { if (!snapshotEnabled()) { @@ -643,27 +655,31 @@ public void addOldEntry(NonLocalRegionEntry oldRe, RegionEntry newEntry, final String regionPath = region.getFullPath(); // ask for pool memory before continuing - if (!region.reservedTable() && region.needAccounting()) { - region.calculateEntryOverhead(oldRe); - region.acquirePoolMemory(0, oldRe.getValueSize(), oldRe.isForDelete(), null, true); + + // No need to do accounting in case of offheap buffer + if (!GemFireCacheImpl.hasNewOffHeap() || !(oldRe._getValue() instanceof SerializedDiskBuffer)) { + if (!region.reservedTable() && region.needAccounting()) { + region.calculateEntryOverhead(oldRe); + region.acquirePoolMemory(0, oldRe.getValueSize(), oldRe.isForDelete(), null, true); + } } - if(getLoggerI18n().fineEnabled()) { - getLoggerI18n().fine("For region " + regionPath + " adding " + - oldRe + " to oldEntrMap"); + + if (SNAPSHOT_DEBUG || getLoggerI18n().fineEnabled()) { + getLoggerI18n().info(LocalizedStrings.DEBUG, "For " + regionPath + " adding " + + oldRe + " to oldEntrMap" + ". The entry in region is " + newEntry + " version in region " + + newEntry.getVersionStamp().getEntryVersion()); } - Map> snapshot = this.oldEntryMap.get(regionPath); + Map snapshot = this.oldEntryMap.get(regionPath); if (snapshot != null) { enqueueOldEntry(oldRe, snapshot); } else { synchronized (this.oldEntryMap) { snapshot = this.oldEntryMap.get(regionPath); if (snapshot == null) { - BlockingQueue oldEntryqueue = new LinkedBlockingDeque(); - snapshot = new ConcurrentHashMap>(); - oldEntryqueue.add(oldRe); - snapshot.put(oldRe.getKeyCopy(), oldEntryqueue); + snapshot = new CustomEntryConcurrentHashMap(); + snapshot.put(oldRe.getKeyCopy(), oldRe); this.oldEntryMap.put(regionPath, snapshot); } else { enqueueOldEntry(oldRe, snapshot); @@ -671,24 +687,73 @@ public void addOldEntry(NonLocalRegionEntry oldRe, RegionEntry newEntry, } } - if (getLoggerI18n().fineEnabled()) { - getLoggerI18n().fine("For key " + oldRe.getKeyCopy() + " " + + if (SNAPSHOT_DEBUG || getLoggerI18n().fineEnabled()) { + getLoggerI18n().info(LocalizedStrings.DEBUG, "For key " + oldRe.getKeyCopy() + " " + "the entries are " + snapshot.get(oldRe.getKeyCopy())); } } // for one entry it will always be called in a lock so assuming no sync - private void enqueueOldEntry(RegionEntry oldRe, Map> snapshot) { - BlockingQueue oldEntryqueue = snapshot.get(oldRe.getKeyCopy()); - if (oldEntryqueue == null) { - oldEntryqueue = new LinkedBlockingDeque(); + private void enqueueOldEntry(RegionEntry oldRe, Map snapshot) { + + Object oldEntry = snapshot.get(oldRe.getKeyCopy()); + if (oldEntry == null) { + snapshot.put(oldRe.getKeyCopy(), oldRe); + return; + } + if (oldEntry instanceof NonLocalRegionEntry) { + BlockingQueue oldEntryqueue = new LinkedBlockingQueue(); + oldEntryqueue.add(oldEntry); oldEntryqueue.add(oldRe); snapshot.put(oldRe.getKeyCopy(), oldEntryqueue); - } else { - oldEntryqueue.add(oldRe); + } + else if (oldEntry instanceof BlockingQueue) { + ((BlockingQueue)oldEntry).add(oldRe); + // putting it back to avoid a race where remover could remove it concurrently + snapshot.put(oldRe.getKeyCopy(), oldEntry); } } + // keeping this for debug purposes + final void printOldEntries(Region region, final Object entryKey, + final Map> snapshot, final boolean + checkValid, RegionEntry re, TXState txState) { + + String regionPath = region.getFullPath(); + List oldEntries = new ArrayList<>(); + Map regionMap = oldEntryMap.get(regionPath); + if (regionMap == null) { + if (SNAPSHOT_DEBUG) { + getLoggerI18n().info(LocalizedStrings.DEBUG, "For region " + region + " the snapshot doesn't have any snapshot yet but there " + + "are entries present in the region" + + " the RVV " + ((LocalRegion)region).getVersionVector().fullToString() + " and snapshot RVV " + + ((LocalRegion)region).getVersionVector().getSnapShotOfMemberVersion() + "against the key " + entryKey + + " the entry in region is " + re + " with version " + re.getVersionStamp().asVersionTag()); + } + return; + } + + Object entries = regionMap.get(entryKey); + if (entries == null) { + if (SNAPSHOT_DEBUG || getLoggerI18n().fineEnabled()) { + getLoggerI18n().info(LocalizedStrings.DEBUG, "For region " + region + + " the snapshot doesn't have any snapshot yet but there " + + "are entries present in the region" + + " the RVV " + ((LocalRegion)region).getVersionVector().fullToString() + " and snapshot RVV " + + ((LocalRegion)region).getVersionVector().getSnapShotOfMemberVersion() + + " the entries are " + entries + " against the key " + entryKey + + " the entry in region is " + re + " with version " + re.getVersionStamp().asVersionTag()); + } + return; + } + + getLoggerI18n().info(LocalizedStrings.DEBUG, "For region " + region + + " the RVV " + ((LocalRegion)region).getVersionVector().fullToString() + " and snapshot RVV " + + ((LocalRegion)region).getVersionVector().getSnapShotOfMemberVersion() + " the entries are " + entries + + "against the key " + entryKey + + " the entry in region is " + re + " with version " + re.getVersionStamp().asVersionTag()); + } + final Object readOldEntry(Region region, final Object entryKey, final Map> snapshot, final boolean checkValid, RegionEntry re, TXState txState) { @@ -696,16 +761,17 @@ final Object readOldEntry(Region region, final Object entryKey, if (re.getVersionStamp().getEntryVersion() <= 1) { RegionEntry oldRegionEntry = NonLocalRegionEntry.newEntry(re.getKeyCopy(), Token.TOMBSTONE, (LocalRegion)region, re.getVersionStamp().asVersionTag()); - if (getLoggerI18n().fineEnabled()) { - getLoggerI18n().fine("Returning TOMBSTONE"); + if (SNAPSHOT_DEBUG || getLoggerI18n().fineEnabled()) { + getLoggerI18n().info(LocalizedStrings.DEBUG,"Returning TOMBSTONE"); } return oldRegionEntry; } else { List oldEntries = new ArrayList<>(); - Map> regionMap = oldEntryMap.get(regionPath); + Map regionMap = oldEntryMap.get(regionPath); if (regionMap == null) { - if (getLoggerI18n().fineEnabled()) { - getLoggerI18n().fine("For region " + region + " the snapshot doesn't have any snapshot yet but there " + + if (SNAPSHOT_DEBUG || getLoggerI18n().fineEnabled()) { + getLoggerI18n().info(LocalizedStrings.DEBUG,"For region " + region + + " the snapshot doesn't have any snapshot yet but there " + "are entries present in the region" + " the RVV " + ((LocalRegion)region).getVersionVector().fullToString() + " and snapshot RVV " + ((LocalRegion)region).getVersionVector().getSnapShotOfMemberVersion() + "against the key " + entryKey + @@ -714,37 +780,50 @@ final Object readOldEntry(Region region, final Object entryKey, return null; } - BlockingQueue entries = regionMap.get(entryKey); - if (entries == null) { - if (getLoggerI18n().fineEnabled()) { - getLoggerI18n().fine("For region " + region + " the snapshot doesn't have any snapshot yet but there " + - "are entries present in the region" + - " the RVV " + ((LocalRegion)region).getVersionVector().fullToString() + " and snapshot RVV " + - ((LocalRegion)region).getVersionVector().getSnapShotOfMemberVersion() + " the entries are " + entries + " against the key " + entryKey + - " the entry in region is " + re + " with version " + re.getVersionStamp().asVersionTag()); + Object entry = regionMap.get(entryKey); + RegionEntry max = NonLocalRegionEntry.newEntry(re.getKeyCopy(), Token.TOMBSTONE, + (LocalRegion)region, null); + // returning TOMBSTONE as there could be case where an entry is inserted and + // modified multiple times after an snapshot is taken + if (entry == null) { + if (SNAPSHOT_DEBUG || getLoggerI18n().fineEnabled()) { + getLoggerI18n().info(LocalizedStrings.DEBUG, "For region " + region + + " the oldEntryMap doesn't have entry in map but there " + + "are entries present in the region" + + " the RVV " + ((LocalRegion)region).getVersionVector().fullToString() + " and snapshot RVV " + + ((LocalRegion)region).getVersionVector().getSnapShotOfMemberVersion() + + " the entries are " + entry + " against the key " + entryKey + + " the entry in region is " + re + " with version " + re.getVersionStamp().asVersionTag()); + } + return max; + } + if (entry instanceof NonLocalRegionEntry) { + if (TXState.checkEntryInSnapshot(txState, region, (RegionEntry)entry)) { + if (SNAPSHOT_DEBUG || getLoggerI18n().fineEnabled()) { + getLoggerI18n().info(LocalizedStrings.DEBUG, "The entry being returned is " + entry); + } + return entry; + } + else { + return null; } - return null; } - for (RegionEntry value : entries) { + for (RegionEntry value : (BlockingQueue) entry) { if (TXState.checkEntryInSnapshot(txState, region, value)) { oldEntries.add(value); } } - RegionEntry max = NonLocalRegionEntry.newEntry(re.getKeyCopy(), Token.TOMBSTONE, - (LocalRegion)region, null); - for (RegionEntry entry : oldEntries) { - if (null == max) { - max = entry; - } else if (max.getVersionStamp().getEntryVersion() <= entry.getVersionStamp() + for (RegionEntry en : oldEntries) { + if (max.getVersionStamp().getEntryVersion() <= en.getVersionStamp() .getEntryVersion()) { - max = entry; + max = en; } } - if (getLoggerI18n().fineEnabled()) { - getLoggerI18n().fine("For region " + region + + if (SNAPSHOT_DEBUG || getLoggerI18n().fineEnabled()) { + getLoggerI18n().info(LocalizedStrings.DEBUG,"For region " + region + " the RVV " + ((LocalRegion)region).getVersionVector().fullToString() + " and snapshot RVV " + - ((LocalRegion)region).getVersionVector().getSnapShotOfMemberVersion() + " the entries are " + entries + + ((LocalRegion)region).getVersionVector().getSnapShotOfMemberVersion() + " the entries are " + entry + "against the key " + entryKey + " the entry in region is " + re + " with version " + re.getVersionStamp().asVersionTag() + " the oldEntries are " + oldEntries + " returning : " + max); @@ -761,6 +840,10 @@ public Map getOldEntriesForRegion(String regionName) { return oldEntryMap.get(regionName); } + public Map getOldEntriesMap() { + return oldEntryMap; + } + public void startOldEntryCleanerService() { getLoggerI18n().info(LocalizedStrings.DEBUG, "Snapshot is enabled " + snapshotEnabled()); @@ -778,7 +861,7 @@ public Thread newThread(Runnable command) { }; getLoggerI18n().info(LocalizedStrings.DEBUG, - "Snapshot is enabled, starting the cleaner thread."); + "Snapshot is enabled, starting the cleaner thread. with frequency " + OLD_ENTRIES_CLEANER_TIME_INTERVAL); oldEntryMapCleanerService = Executors.newScheduledThreadPool(1, oldEntryGCtf); oldEntryMapCleanerService.scheduleAtFixedRate(new OldEntriesCleanerThread(), 0, OLD_ENTRIES_CLEANER_TIME_INTERVAL, TimeUnit.MILLISECONDS); @@ -791,43 +874,66 @@ public void runOldEntriesCleanerThread(){ class OldEntriesCleanerThread implements Runnable { // Keep each entry alive for at least 20 secs. + Random r = new Random(); + MapCallback queueRemover = new QueueRemover(); + public void run() { try { if (!oldEntryMap.isEmpty()) { - for (Entry>> entry : oldEntryMap.entrySet()) { - Map> regionEntryMap = entry.getValue(); - LocalRegion region = (LocalRegion)getRegion(entry.getKey()); + for (Entry> entry : oldEntryMap.entrySet()) { + Map regionEntryMap = entry.getValue(); + LocalRegion region = (LocalRegion) getRegion(entry.getKey()); if (region == null) continue; - for (BlockingQueue oldEntriesQueue : regionEntryMap.values()) { - for (RegionEntry re : oldEntriesQueue) { - boolean entryFoundInTxState = false; - for (TXStateProxy txProxy : getTxManager().getHostedTransactionsInProgress()) { - TXState txState = txProxy.getLocalTXState(); - if (re.isUpdateInProgress() || (txState != null && !txState.isCommitted() && TXState.checkEntryInSnapshot - (txState, region, re))) { - entryFoundInTxState = true; - break; - } - } - if (!entryFoundInTxState) { - if (getLoggerI18n().fineEnabled()) { - getLoggerI18n().fine( - "OldEntriesCleanerThread : Removing the entry " + re + " entry update in progress : " + - re.isUpdateInProgress()); - } - // continue if some explicit call removed the entry - if (!oldEntriesQueue.remove(re)) continue; - if (GemFireCacheImpl.hasNewOffHeap()) { - // also remove reference to region buffer, if any - Object value = re._getValue(); - if (value instanceof SerializedDiskBuffer) { - ((SerializedDiskBuffer)value).release(); + + if (SNAPSHOT_DEBUG || getLoggerI18n().fineEnabled()) { + getLoggerI18n().info(LocalizedStrings.DEBUG, "The size of map for region " + + region.getFullPath() + + " is " + regionEntryMap.size()); + } + + for (Entry oldEntry : regionEntryMap.entrySet()) { + Object oldEntries = oldEntry.getValue(); + + if (oldEntries != null) { + if (oldEntries instanceof NonLocalRegionEntry) { + RegionEntry re = (NonLocalRegionEntry) oldEntries; + if (re.isUpdateInProgress()) { + continue; + } else { + if (notRequired(region, re, null)) { + removeEntry(regionEntryMap, re, region); } } - // free the allocated memory - if (!region.reservedTable() && region.needAccounting()) { - NonLocalRegionEntry nre = (NonLocalRegionEntry)re; - region.freePoolMemory(nre.getValueSize(), nre.isForDelete()); + } else { + BlockingQueue oldEntriesQueue = (BlockingQueue) oldEntries; + for (RegionEntry re : oldEntriesQueue) { + // update in progress guards against the race where oldEntry and + // entry in region have same version for brief period + if (re.isUpdateInProgress()) { + continue; + } else { + if (notRequired(region, re, oldEntriesQueue)) { + if (SNAPSHOT_DEBUG || getLoggerI18n().fineEnabled()) { + getLoggerI18n().info(LocalizedStrings.DEBUG, + "OldEntriesCleanerThread : Removing the entry " + re); + } + // continue if some explicit call removed the entry + if (!oldEntriesQueue.remove(re)) continue; + + if (GemFireCacheImpl.hasNewOffHeap()) { + // also remove reference to region buffer, if any + Object value = re._getValue(); + if (value instanceof SerializedDiskBuffer) { + ((SerializedDiskBuffer) value).release(); + } + } + // free the allocated memory + if (!region.reservedTable() && region.needAccounting()) { + NonLocalRegionEntry nre = (NonLocalRegionEntry) re; + region.freePoolMemory(nre.getValueSize(), nre.isForDelete()); + } + } + } } } } @@ -835,28 +941,204 @@ public void run() { } } - synchronized (oldEntryMap) { - for (Map> regionEntryMap : oldEntryMap.values()) { - for (Entry> entry : regionEntryMap.entrySet()) { - if (entry.getValue().size() == 0) { - regionEntryMap.remove(entry.getKey()); - if (getLoggerI18n().fineEnabled()) { - getLoggerI18n().fine( - "OldEntriesCleanerThread : Removing the map against the key " + entry.getKey()); + synchronized (oldEntryMap) { + for (Map regionEntryMap : oldEntryMap.values()) { + for (Entry entry : regionEntryMap.entrySet()) { + if (entry.getValue() instanceof BlockingQueue) { + if (((BlockingQueue)entry.getValue()).isEmpty()) { + ((CustomEntryConcurrentHashMap)regionEntryMap).remove(entry.getKey(), + entry.getValue(), queueRemover, null, null); + } + if (SNAPSHOT_DEBUG || getLoggerI18n().fineEnabled()) { + getLoggerI18n().fine( + "OldEntriesCleanerThread : Removing the queue against the key " + entry.getKey()); + } } } } } - } } catch (Exception e) { - if (getLoggerI18n().warningEnabled()) { + if (SNAPSHOT_DEBUG || getLoggerI18n().warningEnabled()) { getLoggerI18n().warning(LocalizedStrings.DEBUG, - "OldEntriesCleanerThread : Error occured while cleaning the oldentries map.Actual " + + "OldEntriesCleanerThread : Error occured while cleaning the oldentries map. Actual " + "Exception:", e); } } } + + void removeEntry(Map regionEntryMap, RegionEntry re, LocalRegion region) { + Object removedVal = ((CustomEntryConcurrentHashMap)regionEntryMap).remove(re.getKey(), re); + + if (removedVal == null) return; + + boolean offHeapReleased = false; + if (GemFireCacheImpl.hasNewOffHeap()) { + // also remove reference to region buffer, if any + Object value = re._getValue(); + if (value instanceof SerializedDiskBuffer) { + ((SerializedDiskBuffer)value).release(); + offHeapReleased = true; + } + } + // free the allocated memory + if (!offHeapReleased && !region.reservedTable() && region.needAccounting()) { + NonLocalRegionEntry nre = (NonLocalRegionEntry)re; + region.freePoolMemory(nre.getValueSize(), nre.isForDelete()); + } + + } + + boolean notRequired(LocalRegion region, RegionEntry re, BlockingQueue queue) { + // 20% time just compare with the oldest tx. + /*if (r.nextInt(100) < 20) { + return notRequiredByOldest(region, re, queue); + } else {*/ + return notRequiredByAnyTx(region, re, queue); + //} + } + + boolean notRequiredByOldest(LocalRegion region, RegionEntry re, BlockingQueue queue) { + if(getLoggerI18n().fineEnabled()) { + getLoggerI18n().info(LocalizedStrings.DEBUG, "OldEntriesCleanerThread: Getting called for re " + re); + } + TXId txId = txIdQueue.peek(); + // no tx running + if (txId == null) { + return true; + } + + TXStateProxy proxy = getTxManager().getHostedTXState(txId); + if (proxy != null) { + TXState txState = proxy.getLocalTXState(); + if (txState != null && !txState.isClosed()) { + if (queue != null) { + int myVersion = re.getVersionStamp().getEntryVersion(); + for (RegionEntry otherOldEntry : queue) { + if (otherOldEntry == re) { + continue; + } + if (TXState.checkEntryInSnapshot + (txState, region, otherOldEntry) + && otherOldEntry.getVersionStamp().getEntryVersion() > myVersion) { + return true; + } + } + } + return notRequiredByTx(txState, region, re); + } + } + return notRequiredByOldest(region, re, queue); + } + + + boolean notRequiredByTx(TXState txState, LocalRegion region, RegionEntry re) { + RegionEntry entryInRegion = region.entries.getEntry(re.getKey()); + if (entryInRegion == null) { + VersionTag versionTag = VersionTag.create(re.getVersionStamp(). + asVersionTag().getMemberID()); + versionTag.setEntryVersion(re.getVersionStamp().getEntryVersion() + 1); + versionTag.setRegionVersion(region.getVersionVector().getCurrentVersion()); + entryInRegion = new NonLocalRegionEntry(re.getKey(), Token.TOMBSTONE, region, versionTag); + } + + if ((txState != null && !txState.isClosed() && TXState.checkEntryInSnapshot + (txState, region, entryInRegion))) { + return true; + } + return false; + } + + boolean notRequiredByAnyTx( LocalRegion region, RegionEntry re, + BlockingQueue queue) { + if (SNAPSHOT_DEBUG || getLoggerI18n().fineEnabled()) { + getLoggerI18n().info(LocalizedStrings.DEBUG, "OldEntriesCleanerThread: Getting called for re " + + re + " queue " + queue); + } + int myVersion = re.getVersionStamp().getEntryVersion(); + Set txIds = new UnifiedSet(4); + for (TXStateProxy txProxy : getTxManager().getHostedTransactionsInProgress()) { + TXState txState = txProxy.getLocalTXState(); + if ((txState != null && !txState.isClosed() && TXState.checkEntryInSnapshot + (txState, region, re))) { + txIds.add(txState.getTransactionId()); + } + } + + if (queue != null) { + for (RegionEntry otherOldEntry : queue) { + if (otherOldEntry == re) { + continue; + } + + Set othersTxIds = new UnifiedSet(4); + for (TXStateProxy txProxy : getTxManager().getHostedTransactionsInProgress()) { + TXState txState = txProxy.getLocalTXState(); + if ((txState != null && !txState.isClosed() && TXState.checkEntryInSnapshot + (txState, region, otherOldEntry))) { + othersTxIds.add(txState.getTransactionId()); + } + } + + if (txIds.equals(othersTxIds) + && otherOldEntry.getVersionStamp().getEntryVersion() > myVersion) { + return true; + } + } + } + + // in the end check with the entry in region + RegionEntry entryInRegion = region.entries.getEntry(re.getKey()); + if (entryInRegion == null) { + VersionTag versionTag = VersionTag.create(re.getVersionStamp(). + asVersionTag().getMemberID()); + versionTag.setEntryVersion(re.getVersionStamp().getEntryVersion() + 1); + versionTag.setRegionVersion(region.getVersionVector().getCurrentVersion()); + entryInRegion = new NonLocalRegionEntry(re.getKey(), Token.TOMBSTONE, region, versionTag); + } + + Set othersTxIds = new UnifiedSet(4); + for (TXStateProxy txProxy : getTxManager().getHostedTransactionsInProgress()) { + TXState txState = txProxy.getLocalTXState(); + if ((txState != null && !txState.isClosed() && TXState.checkEntryInSnapshotWithoutOwnChange + (txState, region, entryInRegion))) { + othersTxIds.add(txState.getTransactionId()); + } + } + + // if entry in region is valid for all tx, then remove the entry in oldEntryMap + if (txIds.equals(othersTxIds)) { + if (SNAPSHOT_DEBUG || getLoggerI18n().fineEnabled()) { + getLoggerI18n().info(LocalizedStrings.DEBUG, "OldEntriesCleanerThread: SKSK1 " + + " Entry in region " + entryInRegion + " its version " + + entryInRegion.getVersionStamp().getEntryVersion() + + " myVersion " + myVersion + " myRE " + re + " txIds " + txIds + " otherTxIds " + othersTxIds); + } + return true; + } + return false; + } + + } + + static class QueueRemover extends + MapCallbackAdapter { + + @Override + public Object removeValue(Object key, Object value, Object existingValue, + Object context, Object removeParams) { + if (value != null + && (value == NO_OBJECT_TOKEN || ((existingValue == value) + && ((BlockingQueue)existingValue).isEmpty()))) { + if (getInstance().getLoggerI18n().fineEnabled()) { + getInstance().getLoggerI18n().info(LocalizedStrings.DEBUG, "Removing queue for key " + key); + } + return null; + } + else { + return ABORT_REMOVE_TOKEN; + } + } } /** @@ -1102,7 +1384,7 @@ protected GemFireCacheImpl(boolean isClient, PoolFactory pf, DistributedSystem s deleteThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy()); //this.oldEntryMap = new CustomEntryConcurrentHashMap<>(); - this.oldEntryMap = new ConcurrentHashMap>>(); + this.oldEntryMap = new ConcurrentHashMap>(); if (snapshotEnabled()) { startOldEntryCleanerService(); @@ -1279,17 +1561,33 @@ private long getDefaultOffHeapSize() { // a negative value of numLeads indicates that one or more leads have // been started with explicit heap-size/memory-size setting in which case // auto-configuration of memory-size is disabled to keep things simpler - int numLeads = Integer.getInteger("snappydata.numLeadsOnNode", 1); + int numLeads = Integer.getInteger("snappydata.numLeadsOnHost", 1); if (launcher != null && launcher.hostData() && numLeads >= 0) { long ramSize = LauncherBase.getPhysicalRAMSize(); + int numServers = Integer.getInteger("snappydata.numServersOnHost", 1); + // if any of the servers on the host has explicit heap/memory settings, then skip + if (numServers < 0) { + return 0L; + } // use up-to 75% of total RAM for hosts having sufficiently large RAMs if (ramSize > LauncherBase.LARGE_RAM_LIMIT) { - long usableSize = (ramSize - Runtime.getRuntime().maxMemory()) * 3 / 4; - // reserve space for any leads started on this node - long reserved = numLeads > 0 ? numLeads * 1048576L * + // use max of 75% available RAM + long usableSize = ramSize * 3 / 4; + // reserve space for any leads started on this host + long leadReserved = numLeads > 0 ? 1048576L * numLeads * LauncherBase.getDefaultHeapSizeMB(ramSize, false) : 0L; + usableSize -= leadReserved; + // divide up the usable RAM into the servers running on this host + if (numServers > 1) { + usableSize = usableSize / numServers; + } + // adjust the heap memory already allocated + long maxHeapMemory = Runtime.getRuntime().maxMemory(); + usableSize -= maxHeapMemory; // round to nearest GB - return Math.max(((usableSize - reserved + (1L << 29L)) >>> 30L) << 30L, 0L); + long memorySize = Math.max(((usableSize + (1L << 29L)) >>> 30L) << 30L, 0L); + // should be at least half of the heap size else not worth it + return memorySize >= (maxHeapMemory / 2) ? memorySize : 0L; } } return 0L; @@ -1609,16 +1907,27 @@ public boolean snapshotEnabledForTest() { return DEFAULT_SNAPSHOT_ENABLED_TEST; } + private final BlockingQueue txIdQueue = new LinkedBlockingQueue(); + + public void removeTXId(TXId txId) { + //txIdQueue.remove(txId); + } + + public void addTXId(TXId txId) { + //txIdQueue.add(txId); + } + // currently it will wait for a long time // we can have differnt ds or read write locks to avoid waiting of read operations. //TODO: As an optimizations we can change the ds and maintain it at cache level and punish writes. //return snapshotRVV; - public Map getSnapshotRVV() { + public Map getSnapshotRVV(TXId txId) { lockForSnapshotRvv.readLock().lock(); + addTXId(txId); try { // Wait for all the regions to get initialized before taking snapshot. - final ObjectObjectHashMap snapshot = - ObjectObjectHashMap.withExpectedSize(this.pathToRegion.size()); + final UnifiedMap snapshot = + new UnifiedMap<>(this.pathToRegion.size()); this.pathToRegion.values().forEach(region -> { if (region.isInternalRegion() || (region instanceof HARegion)) return; PartitionedRegion pr; @@ -3426,10 +3735,27 @@ && getGatewaySender(senderId).isParallel()) { } catch (RedundancyAlreadyMetException e) { // don't log this throw e; - } catch (final RuntimeException validationException) { + } catch (final Exception validationException) { getLoggerI18n().warning(LocalizedStrings.GemFireCache_INITIALIZATION_FAILED_FOR_REGION_0, rgn.getFullPath(), validationException); throw validationException; + } catch (Error e) { + getLoggerI18n().warning(LocalizedStrings.GemFireCache_INITIALIZATION_FAILED_FOR_REGION_0, + rgn.getFullPath(), e); + // don't try cleanup for any of the fatal errors below + // else they themselves can get stuck + success = true; + if (SystemFailure.isJVMFailureError(e)) { + SystemFailure.initiateFailure(e); + // If this ever returns, rethrow the error. We're poisoned + // now, so don't let this thread continue. + throw e; + } + SystemFailure.checkFailure(); + // do cleanup for any non-fatal errors + success = false; + stopper.checkCancelInProgress(e); + throw e; } finally { if (!success) { try { @@ -3566,7 +3892,7 @@ public final Set getAllRegions() { } public final Set getApplicationRegions() { - OpenHashSet result = new OpenHashSet<>(); + UnifiedSet result = new UnifiedSet<>(); synchronized (this.rootRegions) { for (Object r : this.rootRegions.values()) { LocalRegion rgn = (LocalRegion) r; @@ -6370,6 +6696,21 @@ public final DM getDistributionManager() { return this.dm; } + /** + * Get a thread-pool for background execution. On normal DMs it will be the + * waiting thread pool which can have any size, or else in loner DMs (that + * don't have most execution thread pools) it will be the disk write pool + * that is a proper background thread pool even in loner DMs. + */ + public final ThreadPoolExecutor getWaitingThreadPoolOrDiskWritePool() { + if (getDistributionManager().isLoner()) { + return getDiskDelayedWritePool(); + } else { + return (ThreadPoolExecutor)getDistributionManager() + .getWaitingThreadPool(); + } + } + public GatewaySenderFactory createGatewaySenderFactory(){ return new GatewaySenderFactoryImpl(this); } diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/InternalPartitionResolver.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/InternalPartitionResolver.java index 010006d87..dbe9b3f67 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/InternalPartitionResolver.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/InternalPartitionResolver.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java index 3602556c9..b6569b00d 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java @@ -17,8 +17,6 @@ package com.gemstone.gemfire.internal.cache; -import static com.gemstone.gemfire.internal.offheap.annotations.OffHeapIdentifier.ENTRY_EVENT_NEW_VALUE; - import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.File; @@ -42,60 +40,9 @@ import java.util.function.Predicate; import java.util.regex.Pattern; -import com.gemstone.gemfire.CancelCriterion; -import com.gemstone.gemfire.CancelException; -import com.gemstone.gemfire.CopyHelper; -import com.gemstone.gemfire.DataSerializable; -import com.gemstone.gemfire.DataSerializer; -import com.gemstone.gemfire.DeltaSerializationException; -import com.gemstone.gemfire.InternalGemFireError; -import com.gemstone.gemfire.InternalGemFireException; -import com.gemstone.gemfire.LogWriter; -import com.gemstone.gemfire.SystemFailure; +import com.gemstone.gemfire.*; import com.gemstone.gemfire.admin.internal.SystemMemberCacheEventProcessor; -import com.gemstone.gemfire.cache.AttributesMutator; -import com.gemstone.gemfire.cache.Cache; -import com.gemstone.gemfire.cache.CacheClosedException; -import com.gemstone.gemfire.cache.CacheEvent; -import com.gemstone.gemfire.cache.CacheException; -import com.gemstone.gemfire.cache.CacheListener; -import com.gemstone.gemfire.cache.CacheLoader; -import com.gemstone.gemfire.cache.CacheLoaderException; -import com.gemstone.gemfire.cache.CacheRuntimeException; -import com.gemstone.gemfire.cache.CacheStatistics; -import com.gemstone.gemfire.cache.CacheWriter; -import com.gemstone.gemfire.cache.CacheWriterException; -import com.gemstone.gemfire.cache.ConflictException; -import com.gemstone.gemfire.cache.CustomExpiry; -import com.gemstone.gemfire.cache.DataPolicy; -import com.gemstone.gemfire.cache.DiskAccessException; -import com.gemstone.gemfire.cache.DiskStoreFactory; -import com.gemstone.gemfire.cache.DiskWriteAttributes; -import com.gemstone.gemfire.cache.DiskWriteAttributesFactory; -import com.gemstone.gemfire.cache.EntryDestroyedException; -import com.gemstone.gemfire.cache.EntryExistsException; -import com.gemstone.gemfire.cache.EntryNotFoundException; -import com.gemstone.gemfire.cache.EvictionAttributes; -import com.gemstone.gemfire.cache.ExpirationAttributes; -import com.gemstone.gemfire.cache.FailedSynchronizationException; -import com.gemstone.gemfire.cache.InterestRegistrationEvent; -import com.gemstone.gemfire.cache.InterestResultPolicy; -import com.gemstone.gemfire.cache.LoaderHelper; -import com.gemstone.gemfire.cache.LockTimeoutException; -import com.gemstone.gemfire.cache.LowMemoryException; -import com.gemstone.gemfire.cache.Operation; -import com.gemstone.gemfire.cache.PartitionedRegionStorageException; -import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache.RegionAttributes; -import com.gemstone.gemfire.cache.RegionDestroyedException; -import com.gemstone.gemfire.cache.RegionEvent; -import com.gemstone.gemfire.cache.RegionExistsException; -import com.gemstone.gemfire.cache.RegionMembershipListener; -import com.gemstone.gemfire.cache.RegionReinitializedException; -import com.gemstone.gemfire.cache.Scope; -import com.gemstone.gemfire.cache.StatisticsDisabledException; -import com.gemstone.gemfire.cache.TimeoutException; -import com.gemstone.gemfire.cache.TransactionException; +import com.gemstone.gemfire.cache.*; import com.gemstone.gemfire.cache.client.ServerOperationException; import com.gemstone.gemfire.cache.client.SubscriptionNotEnabledException; import com.gemstone.gemfire.cache.client.internal.BridgePoolImpl; @@ -113,15 +60,7 @@ import com.gemstone.gemfire.cache.hdfs.internal.hoplog.HDFSRegionDirector.HdfsRegionManager; import com.gemstone.gemfire.cache.partition.PartitionRegionHelper; import com.gemstone.gemfire.cache.persistence.ConflictingPersistentDataException; -import com.gemstone.gemfire.cache.query.FunctionDomainException; -import com.gemstone.gemfire.cache.query.IndexMaintenanceException; -import com.gemstone.gemfire.cache.query.IndexType; -import com.gemstone.gemfire.cache.query.NameResolutionException; -import com.gemstone.gemfire.cache.query.QueryException; -import com.gemstone.gemfire.cache.query.QueryInvocationTargetException; -import com.gemstone.gemfire.cache.query.QueryService; -import com.gemstone.gemfire.cache.query.SelectResults; -import com.gemstone.gemfire.cache.query.TypeMismatchException; +import com.gemstone.gemfire.cache.query.*; import com.gemstone.gemfire.cache.query.internal.CqService; import com.gemstone.gemfire.cache.query.internal.DefaultQuery; import com.gemstone.gemfire.cache.query.internal.ExecutionContext; @@ -212,8 +151,6 @@ import com.gemstone.gemfire.internal.offheap.annotations.Unretained; import com.gemstone.gemfire.internal.sequencelog.EntryLogger; import com.gemstone.gemfire.internal.shared.SystemProperties; -import com.gemstone.gemfire.management.internal.ManagementConstants; -import io.snappydata.collection.OpenHashSet; import com.gemstone.gemfire.internal.shared.Version; import com.gemstone.gemfire.internal.size.ReflectionObjectSizer; import com.gemstone.gemfire.internal.size.ReflectionSingleObjectSizer; @@ -225,6 +162,10 @@ import com.gemstone.gemfire.internal.util.concurrent.StoppableCountDownLatch; import com.gemstone.gemfire.internal.util.concurrent.StoppableReentrantReadWriteLock; import com.gemstone.gemfire.internal.util.concurrent.StoppableReentrantReadWriteLock.StoppableWriteLock; +import com.gemstone.gemfire.management.internal.ManagementConstants; +import org.eclipse.collections.impl.set.mutable.UnifiedSet; + +import static com.gemstone.gemfire.internal.offheap.annotations.OffHeapIdentifier.ENTRY_EVENT_NEW_VALUE; /** * Implementation of a local scoped-region. Note that this class has a different @@ -737,8 +678,8 @@ protected LocalRegion(String regionName, RegionAttributes attrs, Assert.assertTrue(regionName != null, "regionName must not be null"); this.sharedDataView = buildDataView(); this.regionName = regionName; - this.isInternalColumnTable = regionName.toUpperCase().endsWith( - StoreCallbacks.SHADOW_TABLE_SUFFIX); + this.isInternalColumnTable = regionName.toUpperCase(Locale.ENGLISH) + .endsWith(StoreCallbacks.SHADOW_TABLE_SUFFIX); this.parentRegion = parentRegion; this.fullPath = calcFullPath(regionName, parentRegion); // cannot support patterns like "..._/..." due to ambiguity in encoding @@ -1521,13 +1462,30 @@ else if (regionAttributes.getPartitionAttributes() != null) { } catch(RedundancyAlreadyMetException e) { //don't log this throw e; - } catch (final RuntimeException validationException) { + } catch (final Exception validationException) { this.cache.getLoggerI18n().warning(LocalizedStrings. LocalRegion_INITIALIZATION_FAILED_FOR_REGION_0, newRegion.getFullPath(), validationException); throw validationException; - } - finally { + } catch (Error e) { + this.cache.getLoggerI18n().warning(LocalizedStrings. + LocalRegion_INITIALIZATION_FAILED_FOR_REGION_0, + newRegion.getFullPath(), e); + // don't try cleanup for any of the fatal errors below + // else they themselves can get stuck + success = true; + if (SystemFailure.isJVMFailureError(e)) { + SystemFailure.initiateFailure(e); + // If this ever returns, rethrow the error. We're poisoned + // now, so don't let this thread continue. + throw e; + } + SystemFailure.checkFailure(); + // do cleanup for any non-fatal errors + success = false; + stopper.checkCancelInProgress(e); + throw e; + } finally { if (!success) { this.cache.setRegionByPath(newRegion.getFullPath(), null); initializationFailed(newRegion); @@ -1582,7 +1540,7 @@ public void initialize(LocalRegion subRegion, } catch (RedundancyAlreadyMetException e) { // don't log this throw e; - } catch (final RuntimeException validationException) { + } catch (final Exception validationException) { this.cache.getLoggerI18n().warning( LocalizedStrings.LocalRegion_INITIALIZATION_FAILED_FOR_REGION_0, subRegion.getFullPath(), validationException); @@ -1591,6 +1549,19 @@ public void initialize(LocalRegion subRegion, this.cache.getLoggerI18n().warning( LocalizedStrings.LocalRegion_INITIALIZATION_FAILED_FOR_REGION_0, subRegion.getFullPath(), e); + // don't try cleanup for any of the fatal errors below + // else they themselves can get stuck + success = true; + if (SystemFailure.isJVMFailureError(e)) { + SystemFailure.initiateFailure(e); + // If this ever returns, rethrow the error. We're poisoned + // now, so don't let this thread continue. + throw e; + } + SystemFailure.checkFailure(); + // do cleanup for any non-fatal errors + success = false; + stopper.checkCancelInProgress(e); throw e; } finally { if (!success) { @@ -5370,7 +5341,7 @@ else if (interestType == InterestType.KEY) { else if (interestType == InterestType.FILTER_CLASS) { // object class must be a Predicate if (interestArg instanceof Predicate) { - OpenHashSet result = new OpenHashSet<>(); + UnifiedSet result = new UnifiedSet<>(); @SuppressWarnings("unchecked") Predicate filter = (Predicate)interestArg; for (Object key : keySet(allowTombstones)) { @@ -11989,7 +11960,7 @@ public void postPutAllFireEvents(DistributedPutAllOperation putallOp, VersionedO successfulPuts.clear(); putallOp.fillVersionedObjectList(successfulPuts); } - OpenHashSet successfulKeys = new OpenHashSet<>(successfulPuts.size()); + UnifiedSet successfulKeys = new UnifiedSet<>(successfulPuts.size()); for (Object key: successfulPuts.getKeys()) { successfulKeys.add(key); } @@ -14636,6 +14607,10 @@ private void memTrace(String mesage) { } } + public boolean isRowBuffer() { + return false; + } + @Override public boolean isInternalColumnTable() { return isInternalColumnTable; diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/NonLocalRegionEntry.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/NonLocalRegionEntry.java index 50acbfd96..cc71e0af0 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/NonLocalRegionEntry.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/NonLocalRegionEntry.java @@ -89,12 +89,22 @@ protected NonLocalRegionEntry(RegionEntry re, LocalRegion br, v = re.getValue(br); // do an additional retain to match the behaviour of // getValueInVMOrDiskWithoutFaultIn - if (GemFireCacheImpl.hasNewOffHeap() && - (v instanceof SerializedDiskBuffer)) { - ((SerializedDiskBuffer)v).retain(); + if (v instanceof SerializedDiskBuffer) { + if (GemFireCacheImpl.hasNewOffHeap()) { + ((SerializedDiskBuffer)v).retain(); + } else { + // Setting diskEntry to null as we don't do reference count for on-heap objects + // In ColumnFormatValue, if reference count is 0, we read from DiskEntry. + ((SerializedDiskBuffer)v).setDiskEntry(null, br); + } } } else { v = re.getValueInVMOrDiskWithoutFaultIn(br); + if (v instanceof SerializedDiskBuffer && !GemFireCacheImpl.hasNewOffHeap()) { + // Setting diskEntry to null as we don't do reference count for on-heap objects + // In ColumnFormatValue, if reference count is 0, we read from DiskEntry. + ((SerializedDiskBuffer)v).setDiskEntry(null, br); + } } try { this.value = OffHeapHelper.getHeapForm(v); // OFFHEAP: copy into heap cd @@ -167,7 +177,7 @@ public boolean isForDelete() { @Override public String toString() { - return "NonLocalRegionEntry("+this.key + "; value=" + this.value + "; version=" + this.versionTag; + return "NonLocalRegionEntry(Key="+this.key + "; value=" + this.value + "; version=" + this.versionTag; } public static NonLocalRegionEntry newEntry() { @@ -376,7 +386,7 @@ public void setValue(RegionEntryContext context, Object value) { } @Override - public Object _getValue() { + public final Object _getValue() { return value; //throw new UnsupportedOperationException(LocalizedStrings.PartitionedRegion_NOT_APPROPRIATE_FOR_PARTITIONEDREGIONNONLOCALREGIONENTRY.toLocalizedString()); } diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/Oplog.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/Oplog.java index b5e8920a4..993f2cec9 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/Oplog.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/Oplog.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -35,35 +35,13 @@ package com.gemstone.gemfire.internal.cache; -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.DataOutputStream; -import java.io.EOFException; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InterruptedIOException; -import java.io.RandomAccessFile; -import java.io.SyncFailedException; +import java.io.*; import java.nio.ByteBuffer; import java.nio.channels.ClosedChannelException; import java.nio.channels.FileChannel; import java.nio.channels.WritableByteChannel; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; -import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicBoolean; @@ -118,7 +96,6 @@ import com.gemstone.gemfire.internal.sequencelog.EntryLogger; import com.gemstone.gemfire.internal.shared.ClientSharedUtils; import com.gemstone.gemfire.internal.shared.NativeCalls; -import io.snappydata.collection.OpenHashSet; import com.gemstone.gemfire.internal.shared.UnsupportedGFXDVersionException; import com.gemstone.gemfire.internal.shared.Version; import com.gemstone.gemfire.internal.shared.unsafe.ChannelBufferUnsafeDataInputStream; @@ -128,7 +105,12 @@ import com.gemstone.gemfire.internal.util.TransformUtils; import com.gemstone.gemfire.pdx.internal.PdxWriterImpl; import com.gemstone.gnu.trove.TLongHashSet; -import io.snappydata.collection.ObjectObjectHashMap; +import org.eclipse.collections.api.iterator.IntIterator; +import org.eclipse.collections.api.iterator.LongIterator; +import org.eclipse.collections.impl.map.mutable.UnifiedMap; +import org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap; +import org.eclipse.collections.impl.map.mutable.primitive.LongObjectHashMap; +import org.eclipse.collections.impl.set.mutable.UnifiedSet; /** * Implements an operation log to write to disk. @@ -1468,7 +1450,7 @@ Map mapBaseline(List baselineOplogFiles, Set allFiles) { Map baselineOplogMap = TransformUtils.transformAndMap(baselineOplogFiles,TransformUtils.fileNameTransformer); // Returned Map of baseline file to current oplog file - Map baselineToOplogMap = ObjectObjectHashMap.withExpectedSize(16); + UnifiedMap baselineToOplogMap = new UnifiedMap<>(16); for(Iterator itr = allFiles.iterator(); itr.hasNext(); ) { File file = itr.next(); // If the file is in the baseline, add it to the baseline map and remove @@ -2667,9 +2649,8 @@ private void offlineCompact(OplogEntryIdSet deletedIds, boolean latestOplog) { } else { // For every live entry in this oplog add it to the deleted set // so that we will skip it when we recovery the next oplogs. - for (OplogEntryIdMap.Iterator it = getRecoveryMap().iterator(); it.hasNext();) { - it.advance(); - deletedIds.add(it.key()); + for (LongIterator it = getRecoveryMap().keys(); it.hasNext(); ) { + deletedIds.add(it.next()); } close(); } @@ -4956,7 +4937,7 @@ void createKrf(boolean cancel) { try { krfFileCreate(); - final OpenHashSet notWrittenKRFs = new OpenHashSet<>(); + final UnifiedSet notWrittenKRFs = new UnifiedSet<>(); // sortedLiveEntries are now sorted // so we can start writing them to disk. if (sortedLiveEntries != null) { @@ -5035,7 +5016,7 @@ void createKrf(boolean cancel) { */ @SuppressWarnings("unchecked") public long writeIRF(List sortedLiveEntries, - final OpenHashSet notWrittenKRFs, + final UnifiedSet notWrittenKRFs, Set dumpIndexes, Map loadIndexes) throws IOException { @@ -5079,7 +5060,7 @@ public long writeIRF(List sortedLiveEntries, } else if (!this.indexesWritten.isEmpty()) { // remove the indexes already written for this oplog - dumpIndexes = new OpenHashSet<>(dumpIndexes); + dumpIndexes = new UnifiedSet<>(dumpIndexes); dumpIndexes.removeAll(this.indexesWritten); } if (logger.fineEnabled() || traceOn) { @@ -5136,7 +5117,7 @@ public Collection getTargetRegionsForIndexes( if (indexes != null) { ArrayList targetRegions = new ArrayList( this.regionMap.size()); - OpenHashSet usedRegionIDs = new OpenHashSet<>(indexes.size()); + UnifiedSet usedRegionIDs = new UnifiedSet<>(indexes.size()); for (SortedIndexContainer index : indexes) { usedRegionIDs.add(index.getBaseRegion().getRegionID()); } @@ -7292,8 +7273,8 @@ public boolean recoverValuesIfNeeded( List sortedLiveEntries; - ObjectObjectHashMap targetRegions = - ObjectObjectHashMap.from(this.regionMap); + UnifiedMap targetRegions = + new UnifiedMap<>(this.regionMap); synchronized (sync) { //Don't bother to include any stores that have reached the lru limit Iterator itr = diskRecoveryStores.values().iterator(); @@ -7454,8 +7435,8 @@ public long recoverIndexes( || logger.fineEnabled(); // store the affected indexes and the parent region against each disk region - final ObjectObjectHashMap indexRecoveryMap = - ObjectObjectHashMap.withExpectedSize(this.regionMap.size()); + final UnifiedMap indexRecoveryMap = + new UnifiedMap<>(this.regionMap.size()); ArrayList targetRegions = new ArrayList( this.regionMap.size()); this.idxkrf.getDiskIdToIndexDataMap(null, indexes, 0, indexRecoveryMap, @@ -8420,8 +8401,6 @@ public Object setContainerInfo(LocalRegion owner, Object val) { * * @param liveEntries * the list to fill with the live entries - * @param idx - * the first free slot in liveEntries * @param drv * the disk region these entries are on * @param pendingKrfTags @@ -8894,7 +8873,7 @@ public DiskRegionInfoWithList(DiskRegionView dr, boolean couldHaveKrf, boolean k // both in sync and async disk write cases if (!krfExists && couldHaveKrf) { - pendingKrfTags = ObjectObjectHashMap.withExpectedSize(200); + pendingKrfTags = new UnifiedMap<>(200); } else { pendingKrfTags = null; } @@ -9009,8 +8988,8 @@ public long getOffset() { * Memory is optimized by using an int[] for ids in the unsigned int range. */ public static class OplogEntryIdMap { - private final TStatelessIntObjectHashMap ints = new TStatelessIntObjectHashMap((int)DiskStoreImpl.INVALID_ID); - private final TStatelessLongObjectHashMap longs = new TStatelessLongObjectHashMap(DiskStoreImpl.INVALID_ID); + private final IntObjectHashMap ints = new IntObjectHashMap<>(8); + private final LongObjectHashMap longs = new LongObjectHashMap<>(8); public Object put(long id, Object v) { Object result; @@ -9034,15 +9013,17 @@ public Object get(long id) { } return result; } - - public Iterator iterator() { + + public LongIterator keys() { return new Iterator(); } - public class Iterator { + public class Iterator implements LongIterator { + private boolean doingInt = true; - TStatelessIntObjectIterator intIt = ints.iterator(); - TStatelessLongObjectIterator longIt = longs.iterator(); + IntIterator intIt = ints.keySet().intIterator(); + LongIterator longIt = longs.keySet().longIterator(); + public boolean hasNext() { if (this.intIt.hasNext()) { return true; @@ -9051,25 +9032,12 @@ public boolean hasNext() { return this.longIt.hasNext(); } } - public void advance() { - if (doingInt) { - this.intIt.advance(); - } else { - this.longIt.advance(); - } - } - public long key() { - if (doingInt) { - return this.intIt.key(); - } else { - return this.longIt.key(); - } - } - public Object value() { + + public long next() { if (doingInt) { - return this.intIt.value(); + return this.intIt.next(); } else { - return this.longIt.value(); + return this.longIt.next(); } } } diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/OplogIndex.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/OplogIndex.java index b3ed8365d..5ae8107f3 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/OplogIndex.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/OplogIndex.java @@ -51,8 +51,10 @@ import com.gemstone.gemfire.internal.shared.unsafe.ChannelBufferUnsafeDataOutputStream; import com.gemstone.gnu.trove.THashMap; import com.gemstone.gnu.trove.THashSet; -import com.gemstone.gnu.trove.TLongArrayList; -import com.gemstone.gnu.trove.TObjectObjectProcedure; +import org.eclipse.collections.api.block.function.Function; +import org.eclipse.collections.api.block.procedure.Procedure2; +import org.eclipse.collections.impl.list.mutable.primitive.LongArrayList; +import org.eclipse.collections.impl.map.mutable.UnifiedMap; /** * Encapsulates methods to read and write from index files in an Oplog. @@ -278,7 +280,7 @@ public void close() { public static final class IndexData { public final SortedIndexContainer index; public final SortedIndexRecoveryJob indexJob; - public final THashMapWithCreate indexEntryMap; + public final UnifiedMap indexEntryMap; public final int action; @@ -296,7 +298,7 @@ public static final class IndexData { this.index = index; this.indexJob = indexJob; this.indexEntryMap = (action != ONLY_LOAD - ? new THashMapWithCreate(entryCacheSize) : null); + ? new UnifiedMap<>(entryCacheSize) : null); this.action = action; } @@ -348,21 +350,17 @@ public void writeIndexRecords(List entries, final boolean hasOffHeap = getDiskIdToIndexDataMap(dumpIndexes, loadIndexes, entryCacheSize, drvIdToIndexes, null); - final THashMapWithCreate.ValueCreator entryListCreator = - new THashMapWithCreate.ValueCreator() { - @Override - public Object create(Object key, Object params) { - if (hasOffHeap) { - // Snapshot the key bytes, as the offheap value bytes used as index - // key would be - // released , before the data is dumped in the irf. - // Since a newTLongArrayList is created, implying this index key will - // be used in the dumping code - // Check if snap shot is needed in case of only load - ((SortedIndexKey)key).snapshotKeyFromValue(); - } - return new TLongArrayList(2); + final Function entryListCreator = key -> { + if (hasOffHeap) { + // Snapshot the key bytes, as the offheap value bytes used as index + // key would be + // released , before the data is dumped in the irf. + // Since a newTLongArrayList is created, implying this index key will + // be used in the dumping code + // Check if snap shot is needed in case of only load + key.snapshotKeyFromValue(); } + return new LongArrayList(2); }; if (DiskStoreImpl.INDEX_LOAD_DEBUG) { logger.info(LocalizedStrings.DEBUG, "OplogIndex#writeIndexRecords: " @@ -418,7 +416,7 @@ public Object create(Object key, Object params) { } private void dumpOrLoadIndex(final IndexData indexData, final Object val, - DiskEntry entry, final THashMapWithCreate.ValueCreator entryListCreator) { + DiskEntry entry, Function entryListCreator) { final SortedIndexContainer index = indexData.index; SortedIndexKey ikey = index.getIndexKey(val, entry); switch (indexData.action) { @@ -431,9 +429,8 @@ private void dumpOrLoadIndex(final IndexData indexData, final Object val, indexData.indexJob.addJob(ikey, entry); // fall-through deliberate case IndexData.ONLY_DUMP: - THashMapWithCreate entryIdsPerIndexKey = indexData.indexEntryMap; - TLongArrayList entryList = (TLongArrayList)entryIdsPerIndexKey - .create(ikey, entryListCreator, null); + LongArrayList entryList = indexData.indexEntryMap.getIfAbsentPutWith( + ikey, entryListCreator, ikey); entryList.add(Math.abs(entry.getDiskId().getKeyId())); break; default: @@ -446,7 +443,8 @@ private void flushEntries(Collection allIndexes) { for (IndexData[] indexes : allIndexes) { for (IndexData indexData : indexes) { SortedIndexContainer index = indexData.index; - THashMapWithCreate entryIdsPerIndexKey = indexData.indexEntryMap; + UnifiedMap entryIdsPerIndexKey = + indexData.indexEntryMap; if (entryIdsPerIndexKey != null && entryIdsPerIndexKey.size() > 0) { writeIRFRecords(index, entryIdsPerIndexKey, dos); entryIdsPerIndexKey.clear(); @@ -537,7 +535,7 @@ public boolean getDiskIdToIndexDataMap(Set dumpIndexes, } public void writeIRFRecords(final SortedIndexContainer indexContainer, - THashMap entryIdsPerIndexKey, + UnifiedMap entryIdsPerIndexKey, final ChannelBufferUnsafeDataOutputStream dos) { try { final LogWriterI18n logger = this.oplog.logger; @@ -552,32 +550,29 @@ public void writeIRFRecords(final SortedIndexContainer indexContainer, logger.info(LocalizedStrings.DEBUG, "OplogIndex#writeIRFRecords: " + "written indexId record for index: " + indexId); } - entryIdsPerIndexKey.forEachEntry(new TObjectObjectProcedure() { + entryIdsPerIndexKey.forEachKeyValue(new Procedure2() { @Override - public boolean execute(Object key, Object value) { + public void value(SortedIndexKey ikey, LongArrayList entryKeyIds) { try { dos.writeByte(INDEX_RECORD); - SortedIndexKey ikey = (SortedIndexKey)key; ikey.writeKeyBytes(dos); - TLongArrayList entryKeyIds = (TLongArrayList)value; int numKeyIds = entryKeyIds.size(); assert numKeyIds > 0; InternalDataSerializer.writeUnsignedVL(numKeyIds, dos); if (DiskStoreImpl.INDEX_LOAD_DEBUG_FINER) { logger.info(LocalizedStrings.DEBUG, "OplogIndex#writeIRFRecords: " - + "writing actual index record with index key: " + key + + "writing actual index record with index key: " + ikey + " list of oplogEntryIds: " + entryKeyIds.toString()); } if (numKeyIds == 1) { - InternalDataSerializer.writeUnsignedVL(entryKeyIds.getQuick(0), - dos); + InternalDataSerializer.writeUnsignedVL(entryKeyIds.getFirst(), dos); } else { // sort the key ids to keep the deltas small and thus minimize the // size of unsigned long that will be written to disk - entryKeyIds.sort(); + entryKeyIds.sortThis(); long previousValue = 0; for (int index = 0; index < numKeyIds; index++) { - long currValue = entryKeyIds.getQuick(index); + long currValue = entryKeyIds.get(index); if (previousValue == 0) { previousValue = currValue; InternalDataSerializer.writeUnsignedVL(previousValue, dos); @@ -591,7 +586,6 @@ public boolean execute(Object key, Object value) { } catch (IOException ioe) { throw new DiskAccessException(ioe); } - return true; } }); } catch (IOException ioe) { diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/OplogSet.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/OplogSet.java index fb55b15dc..2a0db4ab7 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/OplogSet.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/OplogSet.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/OverflowOplog.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/OverflowOplog.java index 0ba4a78f9..dfa901d8e 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/OverflowOplog.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/OverflowOplog.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/OverflowOplogSet.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/OverflowOplogSet.java index 2be207789..29f122047 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/OverflowOplogSet.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/OverflowOplogSet.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PRHARedundancyProvider.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PRHARedundancyProvider.java index 166f0fcf5..4e39df175 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PRHARedundancyProvider.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PRHARedundancyProvider.java @@ -60,8 +60,8 @@ import com.gemstone.gemfire.internal.cache.persistence.PersistentMemberID; import com.gemstone.gemfire.internal.cache.persistence.PersistentStateListener; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; -import io.snappydata.collection.OpenHashSet; import com.gemstone.org.jgroups.util.StringId; +import org.eclipse.collections.impl.set.mutable.UnifiedSet; /** * This class provides the redundancy management for partitioned region. It will @@ -549,7 +549,7 @@ public InternalDistributedMember createBucketOnDataStore(int bucketId, this.prRegion.bucketStringForLogs(bucketId)); } Collection acceptedMembers = new ArrayList(); // ArrayList - OpenHashSet excludedMembers = new OpenHashSet<>(); + UnifiedSet excludedMembers = new UnifiedSet<>(); ArrayListWithClearState failedMembers = new ArrayListWithClearState(); final long timeOut = System.currentTimeMillis() + computeTimeout(); BucketMembershipObserver observer = null; @@ -1395,7 +1395,7 @@ private InternalDistributedMember getPreferredDataStore( // Convert peers to DataStoreBuckets ArrayList stores = this.prRegion.getRegionAdvisor() - .adviseFilteredDataStores(new OpenHashSet<>(candidates)); + .adviseFilteredDataStores(new UnifiedSet<>(candidates)); final DM dm = this.prRegion.getDistributionManager(); // Add ourself as a candidate, if appropriate diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java index e2401d39d..3f41ccb3a 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java @@ -219,7 +219,6 @@ import com.gemstone.gemfire.internal.offheap.annotations.Unretained; import com.gemstone.gemfire.internal.sequencelog.RegionLogger; import com.gemstone.gemfire.internal.shared.SystemProperties; -import com.gemstone.gemfire.internal.snappy.StoreCallbacks; import com.gemstone.gemfire.internal.util.TransformUtils; import com.gemstone.gemfire.internal.util.concurrent.FutureResult; import com.gemstone.gemfire.internal.util.concurrent.StoppableCountDownLatch; @@ -255,20 +254,6 @@ public class PartitionedRegion extends LocalRegion implements * A debug flag used for testing calculation of starting bucket id */ public static boolean BEFORE_CALCULATE_STARTING_BUCKET_FLAG = false; - - /** - * Thread specific random number - */ - private static ThreadLocal threadRandom = new ThreadLocal() { - @Override - protected Object initialValue() { - int i = rand.nextInt(); - if (i < 0) { - i = -1 * i; - } - return Integer.valueOf(i); - } - }; /** * Global Region for storing PR config ( PRName->PRConfig). This region would @@ -781,13 +766,8 @@ public synchronized String dump() { private ParallelGatewaySenderImpl parallelGatewaySender = null; - private final ThreadLocal queryHDFS = new ThreadLocal() { - @Override - protected Boolean initialValue() { - return false; - } - }; - + private final ThreadLocal queryHDFS = new ThreadLocal<>(); + public PartitionedRegion(String regionname, RegionAttributes ra, LocalRegion parentRegion, GemFireCacheImpl cache, InternalRegionArguments internalRegionArgs) { @@ -949,12 +929,17 @@ protected final boolean isHDFSWriteOnly() { } public final void setQueryHDFS(boolean includeHDFS) { - queryHDFS.set(includeHDFS); + if (includeHDFS) { + queryHDFS.set(true); + } else { + queryHDFS.remove(); + } } @Override public final boolean includeHDFSResults() { - return queryHDFS.get(); + Boolean v = queryHDFS.get(); + return v != null && v; } public final boolean isShadowPR() { @@ -2523,28 +2508,37 @@ else if (txProxy != null || !this.concurrencyChecksEnabled) { } - private volatile Boolean columnBatching; - public boolean needsBatching() { - final Boolean columnBatching = this.columnBatching; + private volatile Boolean isRowBuffer; + + @Override + public boolean isRowBuffer() { + final Boolean columnBatching = this.isRowBuffer; if (columnBatching != null) { return columnBatching; } // Find all the child region and see if they anyone of them has name ending // with _SHADOW_ - if (this.getName().toUpperCase().endsWith(StoreCallbacks.SHADOW_TABLE_SUFFIX)) { - this.columnBatching = false; + if (isInternalColumnTable()) { + this.isRowBuffer = false; return false; } else { - boolean needsBatching = false; + boolean isRowBuffer = false; List childRegions = ColocationHelper.getColocatedChildRegions(this); for (PartitionedRegion pr : childRegions) { - needsBatching |= pr.getName().toUpperCase().endsWith(StoreCallbacks.SHADOW_TABLE_SUFFIX); + if (pr.isInternalColumnTable()) { + isRowBuffer = true; + break; + } } - this.columnBatching = needsBatching; - return needsBatching; + this.isRowBuffer = isRowBuffer; + return isRowBuffer; } } + public void clearIsRowBuffer() { + this.isRowBuffer = null; + } + private void handleSendOrWaitException(Exception ex, DistributedPutAllOperation putallO, PutAllPartialResult partialKeys, PutAllPRMessage prMsg, TXStateProxy txProxy) { @@ -5609,6 +5603,18 @@ public static PartitionedRegion getPRFromId(int prid) return (PartitionedRegion)o; } + public static List getAllPartitionedRegions() { + synchronized (prIdToPR) { + ArrayList allPRs = new ArrayList<>(prIdToPR.size()); + for (Object pr : prIdToPR.values()) { + if (pr instanceof PartitionedRegion) { + allPRs.add((PartitionedRegion)pr); + } + } + return allPRs; + } + } + /** * Verify that the given prId is correct for the given region name in this vm * @@ -8055,14 +8061,6 @@ private Map getSizeRemotely(Set targetNodes, return retVal; } - static int getRandom(int max) { - if (max <= 0) { - return 0; - } - int ti = ((Integer)PartitionedRegion.threadRandom.get()).intValue(); - return ti % max; - } - /** * Returns the lockname used by Distributed Lock service to clean the * allPartitionedRegions diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegionDataStore.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegionDataStore.java index 206e196f8..e7443201a 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegionDataStore.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegionDataStore.java @@ -18,15 +18,7 @@ package com.gemstone.gemfire.internal.cache; import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.concurrent.BlockingQueue; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; @@ -84,7 +76,7 @@ import com.gemstone.gnu.trove.THashSet; import com.gemstone.gnu.trove.TIntArrayList; import com.gemstone.org.jgroups.util.StringId; -import io.snappydata.collection.OpenHashSet; +import org.eclipse.collections.impl.set.mutable.UnifiedSet; /** * Implementation of DataStore (DS) for a PartitionedRegion (PR). This will be @@ -3094,11 +3086,11 @@ public Set getAllLocalBucketIds() { * @return a snapshot of the current set of BucketRegions */ public Set getAllLocalBucketRegions() { - return new OpenHashSet<>(localBucket2RegionMap.values()); + return new UnifiedSet<>(localBucket2RegionMap.values()); } public Set getAllLocalPrimaryBucketRegions() { - OpenHashSet retVal = new OpenHashSet<>(); + UnifiedSet retVal = new UnifiedSet<>(); for (BucketRegion br : localBucket2RegionMap.values()) { if (br.getBucketAdvisor().isPrimary()) { retVal.add(br); @@ -3108,7 +3100,7 @@ public Set getAllLocalPrimaryBucketRegions() { } public Set getAllLocalPrimaryBucketIds() { - OpenHashSet bucketIds = new OpenHashSet<>(); + UnifiedSet bucketIds = new UnifiedSet<>(); for (BucketRegion bucket : localBucket2RegionMap.values()) { if (bucket.getBucketAdvisor().isPrimary()) { bucketIds.add(Integer.valueOf(bucket.getId())); diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PersistentOplogSet.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PersistentOplogSet.java index b34132bad..712600a17 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PersistentOplogSet.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PersistentOplogSet.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PolicyTableData.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PolicyTableData.java index f8d62f607..b3819de56 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PolicyTableData.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PolicyTableData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/SortedIndexContainer.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/SortedIndexContainer.java index 5419d1ae1..720aa06bc 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/SortedIndexContainer.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/SortedIndexContainer.java @@ -45,36 +45,17 @@ public interface SortedIndexContainer { public boolean isUniqueIndex(); /** - * Get an index key object that can be inserted into this index (by calling - * {@link #insertIntoIndex}) given the serialized index key bytes and - * reference to disk entry. + * Get an index key object that can be inserted into this index given the + * serialized index key bytes and reference to disk entry. */ public SortedIndexKey getIndexKey(byte[] indexKeyBytes, RegionEntry entry); /** - * Get an index key object that can be inserted into this index (by calling - * {@link #insertIntoIndex}) given the full value extracted from a - * RegionEntry, and reference to the RegionEntry. + * Get an index key object that can be inserted into this index given the + * full value extracted from a RegionEntry, and reference to the RegionEntry. */ public SortedIndexKey getIndexKey(Object val, RegionEntry entry); - /** - * Insert a given entry into an index for given index key object during - * recovery. Unlike onEvent/postEvent, this is a one-step insert that is not - * designed to be rolled back for any case though explicit deletes may be done - * later (e.g. when recovered bucket is ignored later during bucket - * initialization/rebalance). - * - * @param indexKey - * an index key object like that returned by {@link #getIndexKey} - * @param entry - * the map entry being inserted - * @param isPutDML - * treat like a PUT DML ignoring constraint violations - */ - public void insertIntoIndex(SortedIndexKey indexKey, RegionEntry entry, - boolean isPutDML); - /** * Initialize the index with given set of sorted entries. The will fail if * there is any previous history of operations on the index. The given diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXEntry.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXEntry.java index 3d539ecae..4bf6c5314 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXEntry.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXEntry.java @@ -162,48 +162,12 @@ public void resetCounts() { public Object getUserAttribute() { throw new UnsupportedOperationException( LocalizedStrings.TXEntry_UA_NOT_SUPPORTED.toLocalizedString()); - /* - checkTX(); - throwIfUAOperationForPR(); - TXEntryUserAttrState tx = txReadUA(this.keyInfo); - if (tx != null) { - return tx.getPendingValue(); - } - else { - checkEntryDestroyed(); - return this.localRegion.basicGetEntryUserAttribute(this.keyInfo.getKey()); - } - */ } public Object setUserAttribute(Object value) { throw new UnsupportedOperationException( LocalizedStrings.TXEntry_UA_NOT_SUPPORTED.toLocalizedString()); - /* - checkTX(); - throwIfUAOperationForPR(); - TXEntryUserAttrState tx = txWriteUA(this.keyInfo); - if (tx != null) { - return tx.setPendingValue(value); - } - else { - checkEntryDestroyed(); - if (this.localRegion.entryUserAttributes == null) { - this.localRegion.entryUserAttributes = new Hashtable(); - } - return this.localRegion.entryUserAttributes.put(keyInfo, value); - } - */ - } - - /* - private void throwIfUAOperationForPR() { - if (this.localRegion instanceof PartitionedRegion) { - throw new UnsupportedOperationException(LocalizedStrings. - TXEntry_UA_NOT_SUPPORTED_FOR_PR.toLocalizedString()); - } } - */ @Override public boolean equals(Object obj) { @@ -237,29 +201,6 @@ private void checkEntryDestroyed() { } } - /* - private final TXEntryUserAttrState txReadUA(KeyInfo ki) { - TXRegionState txr = this.myTX.readRegion(this.localRegion); - if (txr != null) { - return txr.readEntryUserAttr(ki.getKey()); - } - else { - return null; - } - } - - protected final TXEntryUserAttrState txWriteUA(KeyInfo ki) { - final LocalRegion dataReg = this.localRegion.getDataRegionForWrite(ki); - final TXRegionState txr = this.myTX.writeRegion(dataReg); - if (txr != null) { - return txr.writeEntryUserAttr(ki.getKey(), this.localRegion); - } - else { - return null; - } - } - */ - /** * @since 5.0 */ diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXEntryState.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXEntryState.java index 21ea376e7..58ad192cd 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXEntryState.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXEntryState.java @@ -17,19 +17,10 @@ package com.gemstone.gemfire.internal.cache; -import static com.gemstone.gemfire.internal.offheap.annotations.OffHeapIdentifier.TX_ENTRY_STATE; - import java.util.ArrayList; import java.util.concurrent.atomic.AtomicInteger; -import com.gemstone.gemfire.cache.CacheWriter; -import com.gemstone.gemfire.cache.CacheWriterException; -import com.gemstone.gemfire.cache.EntryDestroyedException; -import com.gemstone.gemfire.cache.EntryNotFoundException; -import com.gemstone.gemfire.cache.Operation; -import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache.RegionDestroyedException; -import com.gemstone.gemfire.cache.TimeoutException; +import com.gemstone.gemfire.cache.*; import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember; import com.gemstone.gemfire.i18n.LogWriterI18n; import com.gemstone.gemfire.internal.Assert; @@ -45,10 +36,12 @@ import com.gemstone.gemfire.internal.offheap.annotations.Retained; import com.gemstone.gemfire.internal.offheap.annotations.Unretained; import com.gemstone.gemfire.internal.util.ArrayUtils; +import org.eclipse.collections.impl.map.mutable.UnifiedMap; + +import static com.gemstone.gemfire.internal.offheap.annotations.OffHeapIdentifier.TX_ENTRY_STATE; /** - * TXEntryState is the entity that tracks transactional changes, except for - * those tracked by {@link TXEntryUserAttrState}, to an entry. + * TXEntryState is the entity that tracks transactional changes. * * @author Darrel Schneider * @author swale @@ -1775,8 +1768,8 @@ protected void applyBatchOperationOnNewEntry(final TXState txState, lockPolicy.releaseLock(entry, lockPolicy.getReadLockMode(), txState.txId, false, dataRegion); } - final THashMapWithCreate entryMap = checkValid ? txrs.getEntryMap() : txrs - .getInternalEntryMap(); + final UnifiedMap entryMap = checkValid ? txrs.getEntryMap() + : txrs.getInternalEntryMap(); entryMap.put(this.regionKey, this); if (isDirty()) { updateForCommit(txState); @@ -1931,7 +1924,7 @@ protected final int entryCountMod() { /** * Returns true if this entry may have been created by this transaction. */ - protected final boolean wasCreatedByTX() { + public final boolean wasCreatedByTX() { return Token.isRemoved(this.originalVersionId); } diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXEntryUserAttrState.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXEntryUserAttrState.java deleted file mode 100644 index b4cb21d8a..000000000 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXEntryUserAttrState.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you - * may not use this file except in compliance with the License. You - * may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. See accompanying - * LICENSE file. - */ - -package com.gemstone.gemfire.internal.cache; - -/** - * TXEntryUserAttrState is the entity that tracks transactional changes - * to an entry user attribute. - * - * [sumedh] No longer supported in the new transaction model. - *

- * UNMAINTAINED -- DO NOT USE THIS CLASS. - * - * @author Darrel Schneider - * @since 4.0 - * - * @deprecated as of 7.0 support removed in the new TX model - */ -@Deprecated -public class TXEntryUserAttrState { - private final Object originalValue; - private final Object pendingValue; - - @Deprecated - public TXEntryUserAttrState(Object originalValue) - { - this.originalValue = originalValue; - this.pendingValue = originalValue; - } - /* - public Object getOriginalValue() { - return this.originalValue; - } - public Object getPendingValue() { - return this.pendingValue; - } - public Object setPendingValue(Object pv) { - Object result = this.pendingValue; - this.pendingValue = pv; - return result; - } - void checkForConflict(LocalRegion r, Object key) throws CommitConflictException { - Object curCmtValue = r.basicGetEntryUserAttribute(key); - if (this.originalValue != curCmtValue) { - throw new CommitConflictException(LocalizedStrings.TXEntryUserAttrState_ENTRY_USER_ATTRIBUTE_FOR_KEY_0_ON_REGION_1_HAD_ALREADY_BEEN_CHANGED_TO_2.toLocalizedString(new Object[] {key, r.getFullPath(), curCmtValue})); - } - } - void applyChanges(LocalRegion r, Object key) { - try { - Region.Entry re = r.getEntry(key); - re.setUserAttribute(this.pendingValue); - } catch (CacheRuntimeException ignore) { - // ignore any exceptions since we have already locked and - // found no conflicts. - } - } - */ -} diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXManagerImpl.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXManagerImpl.java index b7e89c46d..d09343362 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXManagerImpl.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXManagerImpl.java @@ -17,6 +17,27 @@ package com.gemstone.gemfire.internal.cache; +import java.io.PrintWriter; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; +import java.util.concurrent.locks.LockSupport; +import javax.transaction.Transaction; + +import com.gemstone.gemfire.CancelCriterion; +import com.gemstone.gemfire.GemFireException; +import com.gemstone.gemfire.SystemFailure; +import com.gemstone.gemfire.cache.*; +import com.gemstone.gemfire.distributed.TXManagerCancelledException; +import com.gemstone.gemfire.distributed.internal.DM; +import com.gemstone.gemfire.distributed.internal.DistributionManager; +import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; +import com.gemstone.gemfire.distributed.internal.MembershipListener; +import com.gemstone.gemfire.distributed.internal.OrderedMembershipListener; +import com.gemstone.gemfire.distributed.internal.ReplyException; +import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember; import com.gemstone.gemfire.i18n.LogWriterI18n; import com.gemstone.gemfire.internal.SystemTimer.SystemTimerTask; import com.gemstone.gemfire.internal.cache.TXRemoteCommitMessage.CommitResponse; @@ -33,40 +54,8 @@ import com.gemstone.gemfire.internal.i18n.LocalizedStrings; import com.gemstone.gemfire.internal.shared.ClientSharedUtils; import com.gemstone.gemfire.internal.shared.SystemProperties; -import com.gemstone.gemfire.cache.*; -import com.gemstone.gemfire.CancelCriterion; -import com.gemstone.gemfire.GemFireException; -import com.gemstone.gemfire.SystemFailure; -import com.gemstone.gemfire.distributed.TXManagerCancelledException; -import com.gemstone.gemfire.distributed.internal.DM; -import com.gemstone.gemfire.distributed.internal.DistributionManager; -import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; -import com.gemstone.gemfire.distributed.internal.MembershipListener; -import com.gemstone.gemfire.distributed.internal.OrderedMembershipListener; -import com.gemstone.gemfire.distributed.internal.ReplyException; -import com.gemstone.gemfire.distributed.internal.membership.*; import com.gemstone.gnu.trove.TObjectIntHashMap; - -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.ConcurrentModificationException; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.WeakHashMap; -import java.util.Queue; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; -import java.util.concurrent.locks.LockSupport; - -import javax.transaction.Transaction; +import org.eclipse.collections.impl.map.mutable.UnifiedMap; /** *

@@ -1412,7 +1401,7 @@ public void release() { final TXRegionState[] txrs = tx.getTXRegionStatesSnap(); for (TXRegionState txr : txrs) { if (txr != null) { - THashMapWithCreate entryMods = txr.getInternalEntryMap(); + UnifiedMap entryMods = txr.getInternalEntryMap(); for (Object obj : entryMods.values()) { if (obj instanceof TXEntryState) { TXEntryState txe = (TXEntryState) obj; @@ -1736,6 +1725,7 @@ public final TXStateProxy removeHostedTXState(TXId txId, P removeParams) { final TXStateProxy tx = this.hostedTXStates.remove(txId, condition, context, removeParams); + getCache().removeTXId(txId); if (tx != null) { if (TXStateProxy.LOG_FINE) { getLogger().info(LocalizedStrings.DEBUG, "TX removed: " + tx); diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXRegionState.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXRegionState.java index bf7c19bdb..3834d4312 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXRegionState.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXRegionState.java @@ -41,9 +41,10 @@ import com.gemstone.gemfire.internal.util.ArrayUtils; import com.gemstone.gemfire.internal.util.concurrent.StoppableReentrantReadWriteLock; import com.gemstone.gnu.trove.THashMap; -import com.gemstone.gnu.trove.THashSet; import com.gemstone.gnu.trove.TIntArrayList; -import com.gemstone.gnu.trove.TObjectProcedure; +import org.eclipse.collections.api.block.procedure.Procedure; +import org.eclipse.collections.impl.map.mutable.UnifiedMap; +import org.eclipse.collections.impl.set.mutable.UnifiedSet; /** * TXRegionState is the entity that tracks all the changes a transaction has @@ -69,7 +70,7 @@ public final class TXRegionState extends ReentrantLock { // A map of Objects (entry keys) -> TXEntryState - private final THashMapWithCreate entryMods; + private final UnifiedMap entryMods; // uncommitted/commit list for snapshot isolation private ArrayDeque unCommittedEntryReference; @@ -77,9 +78,6 @@ public final class TXRegionState extends ReentrantLock { TObjectLongHashMapDSFID tailKeysForParallelWAN; - // A map of Objects (entry keys) -> TXEntryUserAttrState - //private HashMap uaMods; - private transient final StoppableReentrantReadWriteLock.StoppableReadLock expiryReadLock; @@ -151,7 +149,7 @@ public TXRegionState(final LocalRegion r, final TXState tx) { this.region = r; this.isPersistent = r.getDataPolicy().withPersistence(); this.txState = tx; - this.entryMods = new THashMapWithCreate(4); + this.entryMods = new UnifiedMap<>(4); this.expiryReadLock = r.getTxEntryExpirationReadLock(); this.isValid = true; @@ -179,16 +177,12 @@ public TXRegionState(final LocalRegion r, final TXState tx) { */ @SuppressWarnings("unchecked") public final Set getEntryKeys() { - final THashSet keys = new THashSet(this.entryMods.size()); - this.entryMods.forEachKey(new TObjectProcedure() { - public final boolean execute(final Object obj) { - if (obj instanceof RegionEntry) { - keys.add(((RegionEntry)obj).getKeyCopy()); - } - else { - keys.add(obj); - } - return true; + final UnifiedSet keys = new UnifiedSet<>(this.entryMods.size()); + this.entryMods.forEachKey(obj -> { + if (obj instanceof RegionEntry) { + keys.add(((RegionEntry)obj).getKeyCopy()); + } else { + keys.add(obj); } }); return keys; @@ -197,7 +191,7 @@ public final boolean execute(final Object obj) { /** * Get the key to {@link TXEntryState} map. */ - final THashMapWithCreate getEntryMap() { + final UnifiedMap getEntryMap() { if (this.isValid) { return this.entryMods; } @@ -212,7 +206,7 @@ final THashMapWithCreate getEntryMap() { * Gets raw handle to the map returned by {@link #getEntryMap()}. Do not use * unless sure that it is being used for read-only. */ - final THashMapWithCreate getInternalEntryMap() { + final UnifiedMap getInternalEntryMap() { return this.entryMods; } @@ -225,15 +219,12 @@ final THashMapWithCreate getInternalEntryMap() { @SuppressWarnings("unchecked") public final Set getCreatedEntryKeys() { - final THashSet keys = new THashSet(this.entryMods.size()); - this.entryMods.forEachValue(new TObjectProcedure() { - public final boolean execute(final Object obj) { - if(obj instanceof TXEntryState) { - if(((TXEntryState)obj).wasCreatedByTX()) { - keys.add(((TXEntryState)obj).getUnderlyingRegionEntry()); - } + final UnifiedSet keys = new UnifiedSet<>(this.entryMods.size()); + this.entryMods.forEachValue(obj -> { + if (obj instanceof TXEntryState) { + if (((TXEntryState)obj).wasCreatedByTX()) { + keys.add(((TXEntryState)obj).getUnderlyingRegionEntry()); } - return true; } }); return keys; @@ -266,7 +257,7 @@ public final Object readEntry(final Object entryKey) { public final Object readEntry(final Object entryKey, final boolean checkValid) { if (!checkValid || this.isValid) { - final THashMapWithCreate entryMap = this.entryMods; + final UnifiedMap entryMap = this.entryMods; final Object txEntry = entryMap.size() > 0 ? entryMap.get(entryKey) : null; if (TXStateProxy.LOG_FINEST) { @@ -333,50 +324,6 @@ public final TXState getTXState() { return this.txState; } - /* - public void rmEntry(Object entryKey, TXState txState, LocalRegion r) { - rmEntryUserAttr(entryKey); - TXEntryState e = (TXEntryState)this.entryMods.remove(entryKey); - if (e != null) { - e.cleanup(r); - } - if (this.uaMods == null && this.entryMods.size() == 0) { - txState.rmRegion(r); - } - } - - public TXEntryUserAttrState readEntryUserAttr(Object entryKey) { - TXEntryUserAttrState result = null; - if (this.uaMods != null) { - result = (TXEntryUserAttrState)this.uaMods.get(entryKey); - } - return result; - } - - public TXEntryUserAttrState writeEntryUserAttr(Object entryKey, LocalRegion r) { - if (this.uaMods == null) { - this.uaMods = new HashMap(); - } - TXEntryUserAttrState result = (TXEntryUserAttrState)this.uaMods - .get(entryKey); - if (result == null) { - result = new TXEntryUserAttrState(r.basicGetEntryUserAttribute(entryKey)); - this.uaMods.put(entryKey, result); - } - return result; - } - - public void rmEntryUserAttr(Object entryKey) { - if (this.uaMods != null) { - if (this.uaMods.remove(entryKey) != null) { - if (this.uaMods.size() == 0) { - this.uaMods = null; - } - } - } - } - */ - /** * Returns the total number of modifications made by this transaction to this * region's entry count. The result will have a 1 for every create, a 0 for @@ -384,12 +331,9 @@ public void rmEntryUserAttr(Object entryKey) { */ final int entryCountMod() { this.tmpEntryCount = 0; - this.entryMods.forEachValue(new TObjectProcedure() { - public final boolean execute(final Object txes) { - if (txes instanceof TXEntryState) { - tmpEntryCount += ((TXEntryState)txes).entryCountMod(); - } - return true; + this.entryMods.forEachValue(txes -> { + if (txes instanceof TXEntryState) { + tmpEntryCount += ((TXEntryState)txes).entryCountMod(); } }); return this.tmpEntryCount; @@ -690,21 +634,6 @@ final void applyChangesStart(LocalRegion r) { final void applyChangesEnd(LocalRegion r, boolean commit) { try { - /* - try { - if (this.uaMods != null) { - Iterator it = this.uaMods.entrySet().iterator(); - while (it.hasNext()) { - Map.Entry me = (Map.Entry)it.next(); - Object eKey = me.getKey(); - TXEntryUserAttrState txes = (TXEntryUserAttrState)me.getValue(); - txes.applyChanges(r, eKey); - } - } - } finally { - r.txLRUEnd(); - } - */ r.txLRUEnd(commit); } catch (RegionDestroyedException ex) { // Region was destroyed out from under us. So act as if the region @@ -766,8 +695,9 @@ else if (this.entryMods.size() > 0) { final TXId txId = tx.txId; final LockMode readMode = lockPolicy.getReadLockMode(); this.numChanges = 0; - this.entryMods.forEachValue(new TObjectProcedure() { - public final boolean execute(final Object obj) { + this.entryMods.forEachValue(new Procedure() { + @Override + public final void value(final Object obj) { if (obj instanceof TXEntryState) { final TXEntryState txes = (TXEntryState)obj; try { @@ -797,13 +727,11 @@ public final boolean execute(final Object obj) { } tmpEx = TXState.processCleanupException(t, tmpEx); } - return true; } else { // case of read locked entry lockPolicy.releaseLock((AbstractRegionEntry)obj, readMode, txId, false, rgn); - return true; } } }); @@ -830,13 +758,9 @@ void processPendingExpires() { int getChanges() { this.tmpEntryCount = 0; - this.entryMods.forEachValue(new TObjectProcedure() { - @Override - public final boolean execute(final Object txes) { - if (txes instanceof TXEntryState && ((TXEntryState)txes).isDirty()) { - tmpEntryCount++; - } - return true; + this.entryMods.forEachValue(txes -> { + if (txes instanceof TXEntryState && ((TXEntryState)txes).isDirty()) { + tmpEntryCount++; } }); /* diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXRemoteCommitMessage.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXRemoteCommitMessage.java index bb9e39a2c..26f6e0380 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXRemoteCommitMessage.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXRemoteCommitMessage.java @@ -93,17 +93,13 @@ public static void send(final InternalDistributedSystem system, final DM dm, // if there are events to be published, then send separate member-wise // split messages as per hosted data to avoid sending full maps to all if (finishRecipients.eventsToBePublished != null) { - finishRecipients.members.forEachEntry(new TObjectObjectProcedure() { - @Override - public final boolean execute(Object mbr, Object data) { - THashMap memberEvents = (THashMap)((ArrayList)data).get(0); - final TXRemoteCommitMessage msg = new TXRemoteCommitMessage(tx, - response, callbackArg, commitTime, memberEvents, - finishRecipients.regionDiskVersionSources); - msg.setRecipient((InternalDistributedMember)mbr); - dm.putOutgoing(msg); - return true; - } + finishRecipients.members.forEachKeyValue((mbr, data) -> { + THashMap memberEvents = (THashMap)data.get(0); + final TXRemoteCommitMessage msg = new TXRemoteCommitMessage(tx, + response, callbackArg, commitTime, memberEvents, + finishRecipients.regionDiskVersionSources); + msg.setRecipient(mbr); + dm.putOutgoing(msg); }); } else { diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXState.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXState.java index 3a65cc0d3..f16542e5b 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXState.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXState.java @@ -67,7 +67,7 @@ import com.gemstone.gnu.trove.THashMap; import com.gemstone.gnu.trove.TObjectHashingStrategy; import com.gemstone.gnu.trove.TObjectProcedure; -import io.snappydata.collection.OpenHashSet; +import org.eclipse.collections.impl.map.mutable.UnifiedMap; /** * TXState is the entity that tracks the transaction state on a per thread @@ -393,7 +393,7 @@ public int find(final Object obj) { // We don't know the semantics for RR, so ideally there shouldn't be snapshot for it. // Need to disable it. if (isSnapshot() && getCache().snapshotEnabled()) { - takeSnapshot(); + takeSnapshot(this.txId); } else { this.snapshot = null; } @@ -404,9 +404,8 @@ public int find(final Object obj) { } } - //TODO: Suranjan, FOR RC: We should set create snapshot and set it in every stmt. - public void takeSnapshot() { - this.snapshot = getCache().getSnapshotRVV(); + public void takeSnapshot(TXId txId) { + this.snapshot = getCache().getSnapshotRVV(txId); if (TXStateProxy.LOG_FINE) { this.txManager.getLogger().info(LocalizedStrings.DEBUG, " The snapshot taken in txStats is " + this.snapshot); @@ -2492,8 +2491,8 @@ final boolean addReadLock(final RegionEntry entry, final Object key, } txr.lock(); try { - final THashMapWithCreate entryMap = checkForTXFinish.booleanValue() ? txr - .getEntryMap() : txr.getInternalEntryMap(); + final UnifiedMap entryMap = checkForTXFinish + ? txr.getEntryMap() : txr.getInternalEntryMap(); if (entryMap.putIfAbsent(key, entry) != null) { // entry exists and must be at least read locked, so release this lock this.lockPolicy.releaseLock(entry, this.lockPolicy.getReadLockMode(), @@ -3924,9 +3923,11 @@ public final Object getLocalEntry(final LocalRegion region, final boolean checkTX = getLockingPolicy().lockedForWrite(re, null, null); if (TXStateProxy.LOG_FINE) { final LogWriterI18n logger = region.getLogWriterI18n(); - logger.info(LocalizedStrings.DEBUG, "getLocalEntry: for region " - + region.getFullPath() + " RegionEntry(" + re + ") checkTX=" - + checkTX); + if (re.getVersionStamp() != null) { + logger.info(LocalizedStrings.DEBUG, "getLocalEntry: for region " + + region.getFullPath() + " RegionEntry(" + re + ") checkTX=" + + checkTX + "version " + re.getVersionStamp().asVersionTag()); + } } if (checkTX) { final Object key = re.getKey(); @@ -3980,6 +3981,20 @@ public final Object getLocalEntry(final LocalRegion region, } } } + + if (shouldGetOldEntry(dataRegion)) { + synchronized (re) { + if (checkEntryInSnapshot(this, dataRegion, re)) { + // TODO: SW: this is a major performance problem because it will always read value + // from disk in essentially random order and then do a faultin; higher level + // DiskBlockSorter etc will be completely ineffective + // Proper solution is to create a snapshot of the original RegionEntry with diskId + // if value has been evicted, and create NLRE only for in-memory entries. + return NonLocalRegionEntry.newEntry(re, dataRegion, true); + } + } + return getOldVersionedEntry(this, dataRegion, re.getKey(), re); + } return re; } @@ -4012,10 +4027,11 @@ private static Object getOldVersionedEntry(TXState tx, LocalRegion dataRegion, O oldEntry = dataRegion.getCache().readOldEntry(dataRegion, key, tx.getCurrentSnapshot(), true, re, tx); int numtimes = 0; while (oldEntry == null) { + LogWriterI18n logger = dataRegion.getLogWriterI18n(); if (TXStateProxy.LOG_FINE) { - LogWriterI18n logger = dataRegion.getLogWriterI18n(); logger.info(LocalizedStrings.DEBUG, " Waiting for older entry for this snapshot to arrive " + - "for key " + key + " re " + re + " for region " + dataRegion.getFullPath()); + "for key " + key + " re " + re + " for region " + dataRegion.getFullPath() + " my txId is " + + tx.getTransactionId()); } try { // Suranjan Should we wait indefinitely? or throw warning and return the current entry. @@ -4032,7 +4048,6 @@ private static Object getOldVersionedEntry(TXState tx, LocalRegion dataRegion, O } } catch (InterruptedException e) { if (TXStateProxy.LOG_FINE) { - LogWriterI18n logger = dataRegion.getLogWriterI18n(); logger.info(LocalizedStrings.DEBUG, " Interrupted while waiting for older entry."); } } @@ -4046,18 +4061,20 @@ private static Object getOldVersionedEntry(TXState tx, LocalRegion dataRegion, O * It should also include any changes done by this tx. * @return true if this vector has seen the given version */ - private boolean isVersionInSnapshot(Region region, VersionSource id, long version) { + private boolean isVersionInSnapshot(Region region, VersionSource id, long version, boolean includeOwnChange) { // For snapshot we don't need to check from the current version final LogWriterI18n logger = ((LocalRegion)region).getLogWriterI18n(); - for (VersionInformation obj : this.queue) { - if (id == obj.member && (version == obj.version) && - region == obj.region) + if (includeOwnChange) { + for (VersionInformation obj : this.queue) { + if (id == obj.member && (version == obj.version) && + region == obj.region) - if (TXStateProxy.LOG_FINE) { - logger.info(LocalizedStrings.DEBUG, " The version found in the current tx : " + this); - } + if (TXStateProxy.LOG_FINE) { + logger.info(LocalizedStrings.DEBUG, " The version found in the current tx : " + this); + } return true; + } } Map regionSnapshot; @@ -4097,7 +4114,47 @@ public static boolean checkEntryInSnapshot(TXStateInterface tx, Region region, R // if rvv is not present then TXState state = tx.getLocalTXState(); if (state.getCurrentRvvSnapShot() != null) { - if (state.isVersionInSnapshot(region, id, stamp.getRegionVersion())) { + if (state.isVersionInSnapshot(region, id, stamp.getRegionVersion(), true)) { + if (TXStateProxy.LOG_FINEST) { + logger.info(LocalizedStrings.DEBUG, "getLocalEntry: for region " + + region.getFullPath() + " RegionEntry(" + entry + ") with version " + stamp + .getRegionVersion() + " id: " + id + " , returning true."); + } + return true; + } + } + if (TXStateProxy.LOG_FINE) { + logger.info(LocalizedStrings.DEBUG, "getLocalEntry: for region " + + region.getFullPath() + " RegionEntry(" + entry + ") with version " + stamp + .getRegionVersion() + " id: " + id + " , returning false."); + } + return false; + } + return true; + } + + public static boolean checkEntryInSnapshotWithoutOwnChange(TXStateInterface tx, Region region, RegionEntry entry) { + if (tx.isSnapshot() && ((LocalRegion)region).concurrencyChecksEnabled) { + VersionStamp stamp = entry.getVersionStamp(); + VersionSource id = stamp.getMemberID(); + final LogWriterI18n logger = ((LocalRegion)region).getLogWriterI18n(); + + if (id == null) { + if (((LocalRegion)region).getVersionVector().isDiskVersionVector()) { + id = ((LocalRegion)region).getDiskStore().getDiskStoreID(); + } else { + id = InternalDistributedSystem.getAnyInstance().getDistributedMember(); + } + if (TXStateProxy.LOG_FINEST) { + logger.info(LocalizedStrings.DEBUG, "checkEntryInSnapshot: for region " + + region.getFullPath() + " RegionEntry(" + entry + ")" + " id not set in Entry, setting id to: " + + id); + } + } + // if rvv is not present then + TXState state = tx.getLocalTXState(); + if (state.getCurrentRvvSnapShot() != null) { + if (state.isVersionInSnapshot(region, id, stamp.getRegionVersion(), false)) { if (TXStateProxy.LOG_FINEST) { logger.info(LocalizedStrings.DEBUG, "getLocalEntry: for region " + region.getFullPath() + " RegionEntry(" + entry + ") with version " + stamp diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXStateProxy.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXStateProxy.java index ac7c361b6..c7db2e1a3 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXStateProxy.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TXStateProxy.java @@ -17,17 +17,9 @@ package com.gemstone.gemfire.internal.cache; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.EnumSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; - import javax.transaction.Status; import javax.transaction.Synchronization; @@ -35,25 +27,7 @@ import com.gemstone.gemfire.GemFireException; import com.gemstone.gemfire.InternalGemFireError; import com.gemstone.gemfire.SystemFailure; -import com.gemstone.gemfire.cache.CacheException; -import com.gemstone.gemfire.cache.ConflictException; -import com.gemstone.gemfire.cache.DataPolicy; -import com.gemstone.gemfire.cache.EntryNotFoundException; -import com.gemstone.gemfire.cache.IllegalTransactionStateException; -import com.gemstone.gemfire.cache.IsolationLevel; -import com.gemstone.gemfire.cache.Operation; -import com.gemstone.gemfire.cache.PartitionAttributes; -import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache.RegionDestroyedException; -import com.gemstone.gemfire.cache.SynchronizationCommitConflictException; -import com.gemstone.gemfire.cache.TransactionBatchException; -import com.gemstone.gemfire.cache.TransactionDataNodeHasDepartedException; -import com.gemstone.gemfire.cache.TransactionDataRebalancedException; -import com.gemstone.gemfire.cache.TransactionException; -import com.gemstone.gemfire.cache.TransactionFlag; -import com.gemstone.gemfire.cache.TransactionInDoubtException; -import com.gemstone.gemfire.cache.TransactionStateReadOnlyException; -import com.gemstone.gemfire.cache.UnsupportedOperationInTransactionException; +import com.gemstone.gemfire.cache.*; import com.gemstone.gemfire.cache.execute.ResultCollector; import com.gemstone.gemfire.cache.query.internal.IndexUpdater; import com.gemstone.gemfire.distributed.internal.DM; @@ -101,7 +75,9 @@ import com.gemstone.gnu.trove.THashMap; import com.gemstone.gnu.trove.THashSet; import com.gemstone.gnu.trove.TObjectLongProcedure; -import com.gemstone.gnu.trove.TObjectObjectProcedure; +import org.eclipse.collections.api.block.function.Function; +import org.eclipse.collections.api.block.procedure.Procedure2; +import org.eclipse.collections.impl.map.mutable.UnifiedMap; /** * TXStateProxy lives on the source node when we are remoting a transaction. It @@ -350,14 +326,11 @@ public boolean visit(DistributionAdvisor advisor, assert profile instanceof BucketProfile; BucketProfile bp = (BucketProfile)profile; if (!bp.inRecovery && bp.cachedOrAllEventsWithListener()) { - Object uninitializedRegions = recipients.members.create( + ArrayList uninitializedRegions = recipients.members.getIfAbsentPutWith( bp.getDistributedMember(), recipients, bp); if (uninitializedRegions != null) { final ProxyBucketRegion pbr = ((BucketAdvisor)advisor) .getProxyBucketRegion(); - @SuppressWarnings("unchecked") - final ArrayList memberData = - (ArrayList)uninitializedRegions; final THashMap tailKeys = recipients.eventsToBePublished; if (tailKeys != null) { // at this point we still don't have the actual list, but we will @@ -365,11 +338,11 @@ public boolean visit(DistributionAdvisor advisor, // show up after commit phase1, and will remove for which this // node itself is the primary; this avoids having to do full // profile scan later again - ((THashMap)memberData.get(0)).put(pbr.getFullPath(), null); + ((THashMap)uninitializedRegions.get(0)).put(pbr.getFullPath(), null); } if (!bp.regionInitialized) { RegionInfoShip regionInfo = new RegionInfoShip(pbr); - memberData.add(regionInfo); + uninitializedRegions.add(regionInfo); } } } @@ -403,13 +376,12 @@ public boolean visit(DistributionAdvisor advisor, if (!(profile instanceof PartitionProfile)) { final CacheProfile cp = (CacheProfile)profile; if (!cp.inRecovery && cp.cachedOrAllEventsWithListener()) { - Object uninitializedRegions = recipients.members.create( + ArrayList uninitializedRegions = recipients.members.getIfAbsentPutWith( cp.getDistributedMember(), recipients, cp); if (uninitializedRegions != null) { if (!cp.regionInitialized) { - RegionInfoShip regionInfo = new RegionInfoShip( - ((CacheDistributionAdvisor)advisor).getAdvisee()); - ((ArrayList)uninitializedRegions).add(regionInfo); + RegionInfoShip regionInfo = new RegionInfoShip(advisor.getAdvisee()); + uninitializedRegions.add(regionInfo); } } } @@ -420,8 +392,7 @@ public boolean visit(DistributionAdvisor advisor, if (versionSources == null) { recipients.regionDiskVersionSources = versionSources = new THashMap(); } - RegionInfoShip regionInfo = new RegionInfoShip( - ((CacheDistributionAdvisor)advisor).getAdvisee()); + RegionInfoShip regionInfo = new RegionInfoShip(advisor.getAdvisee()); versionSources.put(regionInfo, cp.persistentID.diskStoreId); recipients.hasRegionDiskVersionSource = true; } @@ -431,9 +402,9 @@ public boolean visit(DistributionAdvisor advisor, } }; - public static final class MemberToGIIRegions implements - THashMapWithCreate.ValueCreator { - final THashMapWithCreate members; + public static final class MemberToGIIRegions + implements Function> { + final UnifiedMap> members; final THashMap eventsToBePublished; long[] viewVersions; DistributionAdvisor[] viewAdvisors; @@ -459,7 +430,7 @@ public MemberToGIIRegions(int numRegions, THashMap eventsToBePublished) { MemberToGIIRegions(int initSize, int numRegions, THashMap eventsToBePublished) { - this.members = new THashMapWithCreate(initSize); + this.members = new UnifiedMap<>(initSize); this.eventsToBePublished = eventsToBePublished; if (numRegions > 0) { this.viewVersions = new long[numRegions]; @@ -475,7 +446,7 @@ public MemberToGIIRegions(int numRegions, THashMap eventsToBePublished) { this.hasUninitialized = false; } - public final THashMapWithCreate getMembers() { + public final UnifiedMap> getMembers() { return this.members; } @@ -513,8 +484,7 @@ public final boolean hasUninitialized() { } @Override - public Object create(Object key, Object params) { - CacheProfile cp = (CacheProfile)params; + public ArrayList valueOf(CacheProfile cp) { if (cp.regionInitialized) { if (this.eventsToBePublished == null) { return null; @@ -536,7 +506,7 @@ public Object create(Object key, Object params) { return data; } } - }; + } private static MapCallback checkEmpty = new MapCallbackAdapter() { @@ -899,11 +869,8 @@ final TXManagerImpl.TXContext commitPhase1(final Object callbackArg) // already filled in by finishRecipients) // b) member is not the one that sent the map in the first place // (check from the response and send separate commit messages) - finishRecipients.members - .forEachEntry(new TObjectObjectProcedure() { - @Override - public final boolean execute(Object mbr, Object data) { - THashMap memberData = (THashMap)((ArrayList)data).get(0); + finishRecipients.members.forEachKeyValue((mbr, data) -> { + THashMap memberData = (THashMap)data.get(0); Map memberEvents = eventsToBeDispatched.get(mbr); if (memberEvents != null && !memberEvents.isEmpty()) { @@ -922,8 +889,6 @@ public final boolean execute(Object mbr, Object data) { miter.setValueAtCurrent(map); } } - return true; - } }); } } @@ -1087,7 +1052,8 @@ final void commitPhase2(final TXManagerImpl.TXContext context, // final commit message checkAllCopiesDown(dm); - final THashMapWithCreate recipientsData = finishRecipients.members; + final UnifiedMap> recipientsData = + finishRecipients.members; // set the commit time only once if (this.commitTime == 0) { setCommitVersionSources(dm.cacheTimeMillis(), @@ -1488,10 +1454,12 @@ private final ArrayList sendPendingOps(final DM dm, } final ArrayList batchResponses = new ArrayList(numPending); - final THashMap pendingOpsMap = new THashMap(); - final THashMap pendingOpsRegionsMap = new THashMap(); - final THashMap pendingRegions = new THashMap( - ObjectEqualsHashingStrategy.getInstance()); + final UnifiedMap> pendingOpsMap = + new UnifiedMap<>(); + final UnifiedMap> pendingOpsRegionsMap = + new UnifiedMap<>(); + final UnifiedMap> pendingRegions = + new UnifiedMap<>(); ArrayList pendingOps; ArrayList pendingOpsRegions; Set recipients; @@ -1521,8 +1489,7 @@ private final ArrayList sendPendingOps(final DM dm, } // find the recipients for this entry // cache the recipients per region - if ((recipients = (Set)pendingRegions - .get(dataRegion)) == null) { + if ((recipients = pendingRegions.get(dataRegion)) == null) { if (dataRegion.isUsedForPartitionedRegionBucket()) { final PartitionedRegion pr = dataRegion.getPartitionedRegion(); recipients = getOtherMembersForOperation(pr, @@ -1535,16 +1502,14 @@ private final ArrayList sendPendingOps(final DM dm, pendingRegions.put(dataRegion, recipients); } for (InternalDistributedMember member : recipients) { - if ((pendingOps = (ArrayList)pendingOpsMap.get( - member)) == null) { - pendingOps = new ArrayList(); - pendingOpsRegions = new ArrayList(); + if ((pendingOps = pendingOpsMap.get(member)) == null) { + pendingOps = new ArrayList<>(); + pendingOpsRegions = new ArrayList<>(); pendingOpsMap.put(member, pendingOps); pendingOpsRegionsMap.put(member, pendingOpsRegions); } else { - pendingOpsRegions = (ArrayList)pendingOpsRegionsMap - .get(member); + pendingOpsRegions = pendingOpsRegionsMap.get(member); } pendingOps.add(op); pendingOpsRegions.add(dataRegion); @@ -1556,16 +1521,15 @@ private final ArrayList sendPendingOps(final DM dm, Assert.fail("Unexpected pending operations remaining " + numPending + " for " + toString() + " at the end of iteration."); } - pendingOpsMap.forEachEntry(new TObjectObjectProcedure() { + pendingOpsMap.forEachKeyValue(new Procedure2>() { final TXManagerImpl.TXContext context = TXManagerImpl .currentTXContext(); - public final boolean execute(Object key, Object val) { - final InternalDistributedMember m = (InternalDistributedMember)key; + @Override + public final void value(InternalDistributedMember m, ArrayList ops) { batchResponses.add(TXBatchMessage.send(dm, m, TXStateProxy.this, - this.context, (ArrayList)val, - (ArrayList)pendingOpsRegionsMap.get(m), + this.context, ops, pendingOpsRegionsMap.get(m), postMessages, conflictWithEX)); - return true; } }); // cleanup pending information for the entries sent in the batch @@ -1610,18 +1574,12 @@ private final void waitForPendingOps( protected final void sendNewGIINodeMessages( final MemberToGIIRegions finishRecipients, final DM dm, final boolean forCommit) { - THashMap members; + UnifiedMap> members; if (finishRecipients.hasUninitialized && !(members = finishRecipients.members).isEmpty()) { - members.forEachEntry(new TObjectObjectProcedure() { - @SuppressWarnings("unchecked") - @Override - public boolean execute(Object m, Object l) { - if (l != null) { - TXNewGIINode.send(dm.getSystem(), dm, TXStateProxy.this, - (InternalDistributedMember)m, (ArrayList)l, forCommit); - } - return true; + members.forEachKeyValue((m, l) -> { + if (l != null) { + TXNewGIINode.send(dm.getSystem(), dm, TXStateProxy.this, m, l, forCommit); } }); } @@ -3567,9 +3525,6 @@ protected final void addAffectedRegionNoLock(Object region, + (pbr != null ? pbr.getFullPath() : region) + " to " + this.txId.shortToString()/*, new Exception()*/); } - // TODO: SW: do we need the block below? apparently some GFE tests depend - // on this but I see no reason why below is required and the tests should - // be fixed instead if (pbr != null) { this.regions.add(pbr.getPartitionedRegion()); } diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TombstoneService.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TombstoneService.java index e1e9a2472..e7a01e928 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TombstoneService.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/TombstoneService.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/UnsharedImageState.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/UnsharedImageState.java index 6222906fa..e51aba7b8 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/UnsharedImageState.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/UnsharedImageState.java @@ -17,26 +17,27 @@ package com.gemstone.gemfire.internal.cache; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; + import com.gemstone.gemfire.CancelCriterion; import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; import com.gemstone.gemfire.i18n.LogWriterI18n; import com.gemstone.gemfire.internal.Assert; -import com.gemstone.gemfire.internal.util.concurrent.StoppableNonReentrantLock; -import com.gemstone.gemfire.internal.util.concurrent.StoppableReentrantReadWriteLock; import com.gemstone.gemfire.internal.cache.locks.NonReentrantReadWriteLock; import com.gemstone.gemfire.internal.cache.versions.RegionVersionVector; import com.gemstone.gemfire.internal.cache.versions.VersionSource; import com.gemstone.gemfire.internal.cache.versions.VersionTag; import com.gemstone.gemfire.internal.concurrent.ConcurrentTHashSet; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; +import com.gemstone.gemfire.internal.util.concurrent.StoppableNonReentrantLock; +import com.gemstone.gemfire.internal.util.concurrent.StoppableReentrantReadWriteLock; import com.gemstone.gnu.trove.TObjectIntHashMap; import com.gemstone.org.jgroups.util.StringId; - -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.Set; -import java.util.concurrent.atomic.AtomicInteger; +import org.eclipse.collections.impl.map.mutable.UnifiedMap; /** * Used on distributed replicated regions to track GII and various state. @@ -74,7 +75,7 @@ public class UnsharedImageState implements ImageState { * the set of pending TXRegionStates that have pending ops coming in before * GII is complete */ - private volatile THashMapWithCreate pendingTXRegionStates; + private volatile UnifiedMap pendingTXRegionStates; private final NonReentrantReadWriteLock pendingTXRegionStatesLock; private volatile Thread pendingTXRegionStatesLockOwner; private final AtomicInteger pendingTXOrder; @@ -99,7 +100,7 @@ public class UnsharedImageState implements ImageState { // we don't actually require much concurrency since putter will be only // the GII thread, but for multiple getters this is a concurrent set this.failedEvents = new ConcurrentTHashSet(2); - this.pendingTXRegionStates = isLocal ? null : new THashMapWithCreate(); + this.pendingTXRegionStates = isLocal ? null : new UnifiedMap<>(); this.pendingTXRegionStatesLock = isLocal ? null : new NonReentrantReadWriteLock(stopper); this.pendingTXOrder = new AtomicInteger(0); @@ -356,8 +357,8 @@ public boolean addPendingTXRegionState(TXRegionState txrs) { final LocalRegion region = txrs.region; if (region.isProfileExchanged()) { Object old; - if ((old = this.pendingTXRegionStates.putIfAbsent(txrs.getTXState() - .getTransactionId(), txrs)) != null) { + if ((old = this.pendingTXRegionStates.getIfAbsentPut(txrs.getTXState() + .getTransactionId(), txrs)) != txrs) { Assert.fail("ImageState#addPendingTXRegionState: failed to add " + txrs + ", existing=" + old); } @@ -410,7 +411,7 @@ public TXRegionState getPendingTXRegionState(TXId txId, boolean lock) { } try { if (this.pendingTXRegionStates != null) { - txrs = (TXRegionState)this.pendingTXRegionStates.get(txId); + txrs = this.pendingTXRegionStates.get(txId); if (TXStateProxy.LOG_FINE) { if (txrs != null) { final LogWriterI18n logger = txrs.region.getLogWriterI18n(); @@ -561,7 +562,7 @@ public int getFinishedTXOrder(TXId txId) { @Override public void mergeFinishedTXOrders(final LocalRegion region, final Collection txIds) { - final THashMapWithCreate pendingTXRS = this.pendingTXRegionStates; + final UnifiedMap pendingTXRS = this.pendingTXRegionStates; if (pendingTXRS != null) { this.pendingTXRegionStatesLock.attemptWriteLock(-1); try { @@ -609,7 +610,7 @@ public void mergeFinishedTXOrders(final LocalRegion region, public void clearPendingTXRegionStates(boolean reset) { if (reset) { // in this case only reset the list else null it out - final THashMapWithCreate txrs = this.pendingTXRegionStates; + final UnifiedMap txrs = this.pendingTXRegionStates; if (txrs != null) { txrs.clear(); } diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/UpdateEntryVersionOperation.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/UpdateEntryVersionOperation.java index c15a4211c..ef1db4577 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/UpdateEntryVersionOperation.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/UpdateEntryVersionOperation.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/UpdateOperation.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/UpdateOperation.java index 64cb84dce..17f6bbb79 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/UpdateOperation.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/UpdateOperation.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/control/HeapMemoryMonitor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/control/HeapMemoryMonitor.java index 5552bae5f..e1d5fcc1d 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/control/HeapMemoryMonitor.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/control/HeapMemoryMonitor.java @@ -21,6 +21,10 @@ import java.lang.management.MemoryPoolMXBean; import java.lang.management.MemoryType; import java.lang.management.MemoryUsage; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import java.util.concurrent.Executors; @@ -28,20 +32,22 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; - +import java.util.function.Function; import javax.management.ListenerNotFoundException; +import javax.management.MalformedObjectNameException; import javax.management.Notification; import javax.management.NotificationEmitter; import javax.management.NotificationListener; +import javax.management.ObjectName; import com.gemstone.gemfire.CancelException; -import com.gemstone.gemfire.LogWriter; import com.gemstone.gemfire.SystemFailure; import com.gemstone.gemfire.cache.CacheClosedException; import com.gemstone.gemfire.cache.query.internal.QueryMonitor; import com.gemstone.gemfire.distributed.internal.ProcessorKeeper21; import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember; import com.gemstone.gemfire.i18n.LogWriterI18n; +import com.gemstone.gemfire.internal.Assert; import com.gemstone.gemfire.internal.DiskCapacityMonitor; import com.gemstone.gemfire.internal.GemFireStatSampler; import com.gemstone.gemfire.internal.LocalStatListener; @@ -54,8 +60,10 @@ import com.gemstone.gemfire.internal.cache.control.ResourceAdvisor.ResourceManagerProfile; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; import com.gemstone.gemfire.internal.shared.LauncherBase; +import com.gemstone.gemfire.internal.shared.NativeCalls; import com.gemstone.gemfire.internal.shared.SystemProperties; import com.gemstone.gemfire.internal.util.LogService; +import org.apache.log4j.Logger; /** * Allows for the setting of eviction and critical thresholds. These thresholds @@ -90,6 +98,9 @@ public final class HeapMemoryMonitor implements NotificationListener, private static final int POLLER_INTERVAL = Integer.getInteger(POLLER_INTERVAL_PROP, 500); + // Duration in millis to wait for jmap -histo to finish + private static final int JMAP_HISTO_SLEEP_DURATION = 3 * 1000; + // This holds a new event as it transitions from updateStateAndSendEvent(...) to fillInProfile() private ThreadLocal upcomingEvent = new ThreadLocal(); @@ -117,6 +128,8 @@ public final class HeapMemoryMonitor implements NotificationListener, private static boolean testDisableMemoryUpdates = false; private static long testBytesUsedForThresholdSet = -1; + Logger logger = Logger.getLogger(this.getClass()); + /** * Number of eviction or critical state changes that have to occur before the @@ -144,13 +157,14 @@ public final class HeapMemoryMonitor implements NotificationListener, private static final long edenAndSurvivorPoolMaxMemory; static { - MemoryPoolMXBean matchingTenuredMemoryPoolMXBean = null; + ArrayList matchingTenuredMemoryPoolMXBeans = + new ArrayList<>(2); MemoryPoolMXBean matchingEdenMemoryPoolMXBean = null; MemoryPoolMXBean matchingSurvivorPoolMXBean = null; for (MemoryPoolMXBean memoryPoolMXBean : ManagementFactory.getMemoryPoolMXBeans()) { if (isTenured(memoryPoolMXBean)) { if (memoryPoolMXBean.isUsageThresholdSupported()) { - matchingTenuredMemoryPoolMXBean = memoryPoolMXBean; + matchingTenuredMemoryPoolMXBeans.add(memoryPoolMXBean); } } else if (isEden(memoryPoolMXBean)) { @@ -161,13 +175,18 @@ else if (isSurvivor(memoryPoolMXBean)) { } } - tenuredMemoryPoolMXBean = matchingTenuredMemoryPoolMXBean; edenMemoryPoolMXBean = matchingEdenMemoryPoolMXBean; survivorPoolMXBean = matchingSurvivorPoolMXBean; - if (tenuredMemoryPoolMXBean == null) { + if (matchingTenuredMemoryPoolMXBeans.isEmpty()) { LogWriterI18n logger = LogService.logger(); logger.error(LocalizedStrings.HeapMemoryMonitor_NO_POOL_FOUND_POOLS_0, getAllMemoryPoolNames()); + tenuredMemoryPoolMXBean = null; + } else { + tenuredMemoryPoolMXBean = matchingTenuredMemoryPoolMXBeans.size() == 1 + ? matchingTenuredMemoryPoolMXBeans.get(0) + : new CompositePoolMXBean("tenured-composite", + matchingTenuredMemoryPoolMXBeans.toArray(new MemoryPoolMXBean[0])); } /* @@ -175,8 +194,7 @@ else if (isSurvivor(memoryPoolMXBean)) { * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7078465 by getting max * memory from runtime and subtracting all other heap pools from it. */ - if (tenuredMemoryPoolMXBean != null - && tenuredMemoryPoolMXBean.getUsage().getMax() != -1) { + if (tenuredMemoryPoolMXBean.getUsage().getMax() != -1) { tenuredPoolMaxMemory = tenuredMemoryPoolMXBean.getUsage().getMax(); } else { @@ -224,14 +242,15 @@ static boolean isTenured(MemoryPoolMXBean memoryPoolMXBean) { } String name = memoryPoolMXBean.getName(); - + return name.equals("CMS Old Gen") // Sun Concurrent Mark Sweep GC || name.equals("PS Old Gen") // Sun Parallel GC || name.equals("G1 Old Gen") // Sun G1 GC || name.equals("Old Space") // BEA JRockit 1.5, 1.6 GC || name.equals("Tenured Gen") // Hitachi 1.5 GC || name.equals("Java heap") // IBM 1.5, 1.6 GC - + || name.equals("tenured-SOA") // OpenJ9 + || name.equals("tenured-LOA") // OpenJ9 // Allow an unknown pool name to monitor || (HEAP_POOL != null && name.equals(HEAP_POOL)); } @@ -252,11 +271,12 @@ static boolean isEden(MemoryPoolMXBean memoryPoolMXBean) { String name = memoryPoolMXBean.getName(); - return name.equals("Par Eden Space") // Oracle ParNew with Concurrent Mark Sweep GC - || name.equals("PS Eden Space") // Oracle Parallel GC - || name.equals("G1 Eden") // Oracle G1 GC - //|| name.equals("Nursery") // BEA JRockit 1.5, 1.6 GC - || name.equals("Eden Space") // Hitachi 1.5 GC + return name.equals("Par Eden Space") // Oracle ParNew with Concurrent Mark Sweep GC + || name.equals("PS Eden Space") // Oracle Parallel GC + || name.equals("G1 Eden") // Oracle G1 GC + //|| name.equals("Nursery") // BEA JRockit 1.5, 1.6 GC + || name.equals("Eden Space") // Hitachi 1.5 GC + || name.equals("nursery-allocate") // OpenJ9 // Allow an unknown pool name to monitor || (HEAP_EDEN_POOL != null && name.equals(HEAP_EDEN_POOL)); } @@ -281,6 +301,7 @@ static boolean isSurvivor(MemoryPoolMXBean memoryPoolMXBean) { || name.equals("PS Survivor Space") // Oracle Parallel GC || name.equals("G1 Survivor") // Oracle G1 GC || name.equals("Survivor Space") // Hitachi 1.5 GC + || name.equals("nursery-survivor") // OpenJ9 // Allow an unknown pool name to monitor || (HEAP_SURVIVOR_POOL != null && name.equals(HEAP_SURVIVOR_POOL)); } @@ -673,6 +694,34 @@ private boolean shouldDelayMemoryEvent(boolean delayMemoryEvent, MemoryState sta return false; } + /** + * Logs heap histogram for given pid + * + * @param pid PID of the process for which heap histogram is to be logged + */ + public void jmapDump(String pid) { + try { + List inputArgs = ManagementFactory.getRuntimeMXBean().getInputArguments(); + String[] jmapCommand; + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss"); + String dateSuffix = dateFormat.format(new java.util.Date( + System.currentTimeMillis())); + if (inputArgs.contains("-XX:+HeapDumpOnOutOfMemoryError")) { + jmapCommand = new String[] { "/bin/sh", "-c", "jmap -dump:format=b,file=" + + "java_pid" + pid + "-" + dateSuffix + ".hprof " + pid + }; + } else { + jmapCommand = new String[] { "/bin/sh", "-c", "jmap -histo " + pid + " > " + + "java_pid" + pid + "-" + dateSuffix + ".jmap" + }; + } + Process jmapProcess = Runtime.getRuntime().exec(jmapCommand); + jmapProcess.waitFor(JMAP_HISTO_SLEEP_DURATION, TimeUnit.MILLISECONDS); + } catch (Exception e) { + logger.error("Failed to log heap histogram for pid: " + pid, e); + } + } + /** * Update resource manager stats based upon the given event. * @@ -682,11 +731,13 @@ private boolean shouldDelayMemoryEvent(boolean delayMemoryEvent, MemoryState sta private void updateStatsFromEvent(MemoryEvent event) { if (event.isLocal()) { if (event.getState().isCritical() && !event.getPreviousState().isCritical()) { + int pid = NativeCalls.getInstance().getProcessId(); + jmapDump(Integer.toString(pid)); this.stats.incHeapCriticalEvents(); } else if (!event.getState().isCritical() && event.getPreviousState().isCritical()) { this.stats.incHeapSafeEvents(); } - + if (event.getState().isEviction() && !event.getPreviousState().isEviction()) { this.stats.incEvictionStartEvents(); } else if (!event.getState().isEviction() && event.getPreviousState().isEviction()) { @@ -706,7 +757,7 @@ public void fillInProfile(final ResourceManagerProfile profile) { final MemoryEvent tempEvent = this.upcomingEvent.get(); if (tempEvent != null) { this.mostRecentEvent = tempEvent; - this.upcomingEvent.set(null); + this.upcomingEvent.remove(); } final MemoryEvent eventToPopulate = this.mostRecentEvent; profile.setHeapData(eventToPopulate.getBytesUsed(), eventToPopulate.getState(), eventToPopulate.getThresholds()); @@ -1143,4 +1194,190 @@ public boolean failMemoryRequest(long accountedMemory) { return false; } } + + public static class CompositePoolMXBean implements MemoryPoolMXBean { + + private final String name; + private final String objectName; + private final MemoryPoolMXBean[] pools; + + public CompositePoolMXBean(String name, MemoryPoolMXBean[] pools) { + // all pool types must be same + Assert.assertTrue(pools.length > 1); + MemoryType expectedType = pools[0].getType(); + for (int i = 1; i < pools.length; i++) { + Assert.assertTrue(pools[i].getType().equals(expectedType)); + } + + this.name = name; + this.objectName = ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE + + ",name=" + name; + this.pools = pools; + } + + private MemoryUsage combineMemoryUsage( + Function getUsage) { + long init = 0L; + long used = 0L; + long committed = 0L; + long max = 0L; + for (MemoryPoolMXBean pool : this.pools) { + MemoryUsage usage = getUsage.apply(pool); + init += Math.max(0L, usage.getInit()); + used += usage.getUsed(); + committed += usage.getCommitted(); + max += Math.max(0L, usage.getMax()); + } + if (init == 0L) init = -1L; + if (max == 0L) max = -1L; + return new MemoryUsage(init, used, committed, max); + } + + @Override + public String getName() { + return this.name; + } + + @Override + public MemoryType getType() { + return this.pools[0].getType(); + } + + @Override + public MemoryUsage getUsage() { + return combineMemoryUsage(MemoryPoolMXBean::getUsage); + } + + @Override + public MemoryUsage getPeakUsage() { + return combineMemoryUsage(MemoryPoolMXBean::getPeakUsage); + } + + @Override + public void resetPeakUsage() { + for (MemoryPoolMXBean pool : this.pools) { + pool.resetPeakUsage(); + } + } + + @Override + public boolean isValid() { + for (MemoryPoolMXBean pool : this.pools) { + if (!pool.isValid()) return false; + } + return true; + } + + @Override + public String[] getMemoryManagerNames() { + LinkedHashSet managers = new LinkedHashSet<>(this.pools.length); + for (MemoryPoolMXBean pool : this.pools) { + managers.addAll(Arrays.asList(pool.getMemoryManagerNames())); + } + // noinspection ToArrayCallWithZeroLengthArrayArgument + return managers.toArray(new String[managers.size()]); + } + + @Override + public long getUsageThreshold() { + long usageThreshold = 0L; + for (MemoryPoolMXBean pool : this.pools) { + long threshold = pool.getUsageThreshold(); + if (threshold > 0L && (usageThreshold == 0L || threshold < usageThreshold)) { + usageThreshold = threshold; + } + } + return usageThreshold; + } + + @Override + public void setUsageThreshold(long threshold) { + for (MemoryPoolMXBean pool : this.pools) { + pool.setUsageThreshold(threshold); + } + } + + @Override + public boolean isUsageThresholdExceeded() { + for (MemoryPoolMXBean pool : this.pools) { + if (pool.isUsageThresholdExceeded()) return true; + } + return false; + } + + @Override + public long getUsageThresholdCount() { + long usageThresholdCount = 0L; + for (MemoryPoolMXBean pool : this.pools) { + usageThresholdCount += pool.getUsageThresholdCount(); + } + return usageThresholdCount; + } + + @Override + public boolean isUsageThresholdSupported() { + for (MemoryPoolMXBean pool : this.pools) { + if (!pool.isUsageThresholdSupported()) return false; + } + return true; + } + + @Override + public long getCollectionUsageThreshold() { + long usageThreshold = 0L; + for (MemoryPoolMXBean pool : this.pools) { + long threshold = pool.getCollectionUsageThreshold(); + if (threshold > 0L && (usageThreshold == 0L || threshold < usageThreshold)) { + usageThreshold = threshold; + } + } + return usageThreshold; + } + + @Override + public void setCollectionUsageThreshold(long threshold) { + for (MemoryPoolMXBean pool : this.pools) { + pool.setCollectionUsageThreshold(threshold); + } + } + + @Override + public boolean isCollectionUsageThresholdExceeded() { + for (MemoryPoolMXBean pool : this.pools) { + if (pool.isCollectionUsageThresholdExceeded()) return true; + } + return false; + } + + @Override + public long getCollectionUsageThresholdCount() { + long usageThresholdCount = 0L; + for (MemoryPoolMXBean pool : this.pools) { + usageThresholdCount += pool.getCollectionUsageThresholdCount(); + } + return usageThresholdCount; + } + + @Override + public MemoryUsage getCollectionUsage() { + return combineMemoryUsage(MemoryPoolMXBean::getCollectionUsage); + } + + @Override + public boolean isCollectionUsageThresholdSupported() { + for (MemoryPoolMXBean pool : this.pools) { + if (!pool.isCollectionUsageThresholdSupported()) return false; + } + return true; + } + + @Override + public ObjectName getObjectName() { + try { + return ObjectName.getInstance(this.objectName); + } catch (MalformedObjectNameException e) { + throw new IllegalArgumentException(e); + } + } + } } diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/control/InternalResourceManager.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/control/InternalResourceManager.java index ae8d01d27..ca0f60ba3 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/control/InternalResourceManager.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/control/InternalResourceManager.java @@ -342,7 +342,7 @@ public RebalanceOperation start() { op.start(); // needed for Snappy Spark Smart connector as we cache buckets to server // mapping for tables - CallbackFactoryProvider.getStoreCallbacks().registerRelationDestroyForHiveStore(); + CallbackFactoryProvider.getStoreCallbacks().registerCatalogSchemaChange(); return op; } diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/control/OffHeapMemoryMonitor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/control/OffHeapMemoryMonitor.java index 5c024f77c..674db5f53 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/control/OffHeapMemoryMonitor.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/control/OffHeapMemoryMonitor.java @@ -300,7 +300,7 @@ public void fillInProfile(final ResourceManagerProfile profile) { final MemoryEvent tempEvent = this.upcomingEvent.get(); if (tempEvent != null) { this.mostRecentEvent = tempEvent; - this.upcomingEvent.set(null); + this.upcomingEvent.remove(); } final MemoryEvent eventToPopulate = this.mostRecentEvent; profile.setOffHeapData(eventToPopulate.getBytesUsed(), eventToPopulate.getState(), eventToPopulate.getThresholds()); diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/execute/MemberFunctionExecutor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/execute/MemberFunctionExecutor.java index cfd679468..9bfc812b7 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/execute/MemberFunctionExecutor.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/execute/MemberFunctionExecutor.java @@ -43,7 +43,7 @@ import com.gemstone.gemfire.internal.cache.TXStateInterface; import com.gemstone.gemfire.internal.cache.control.MemoryThresholds; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; -import io.snappydata.collection.OpenHashSet; +import org.eclipse.collections.impl.set.mutable.UnifiedSet; /** * @@ -118,7 +118,7 @@ private MemberFunctionExecutor(MemberFunctionExecutor memberFunctionExecutor, private ResultCollector executeFunction(final Function function, ResultCollector resultCollector) { final DM dm = this.ds.getDistributionManager(); - final Set dest = new OpenHashSet<>(this.members); + final Set dest = new UnifiedSet<>(this.members); if (dest.isEmpty()) { throw new NoMemberFoundException(LocalizedStrings .MemberFunctionExecutor_NO_MEMBER_FOUND_FOR_EXECUTING_FUNCTION_0 diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/locks/LockingPolicy.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/locks/LockingPolicy.java index b5af3893b..c06d4c429 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/locks/LockingPolicy.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/locks/LockingPolicy.java @@ -501,7 +501,7 @@ public final void acquireLock(ExclusiveSharedLockObject lockObj, LockTimeoutException { // TODO: Suranjan Ideally no request should come in this mode. // put an assert here! - acquireLockFailFast(lockObj, mode, flags, lockOwner, context, msg); + // acquireLockFailFast(lockObj, mode, flags, lockOwner, context, msg); } @Override @@ -528,6 +528,12 @@ public final Object lockForRead(final ExclusiveSharedLockObject lockObj, // TODO: Suranjan try to see if we can add versioning information here and read return reader.readEntry(lockObj, context, iContext, allowTombstones); } + + @Override + public void releaseLock(ExclusiveSharedLockObject lockObj, + LockMode mode, Object lockOwner, boolean releaseAll, Object context) { + // no-op + } }, ; ; @@ -665,7 +671,7 @@ public abstract void acquireLock(ExclusiveSharedLockObject lockObj, * {@link ExclusiveSharedLockObject#releaseLock} method that can be * used by the particular locking implementation */ - public final void releaseLock(ExclusiveSharedLockObject lockObj, + public void releaseLock(ExclusiveSharedLockObject lockObj, LockMode mode, Object lockOwner, boolean releaseAll, Object context) throws IllegalMonitorStateException { if (mode != null) { diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/RegionAdvisor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/RegionAdvisor.java index 71c4f9768..a9001bfd1 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/RegionAdvisor.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/partitioned/RegionAdvisor.java @@ -38,29 +38,17 @@ import com.gemstone.gemfire.i18n.LogWriterI18n; import com.gemstone.gemfire.internal.Assert; import com.gemstone.gemfire.internal.InternalDataSerializer; -import com.gemstone.gemfire.internal.cache.BucketAdvisor; +import com.gemstone.gemfire.internal.cache.*; import com.gemstone.gemfire.internal.cache.BucketAdvisor.BucketProfile; import com.gemstone.gemfire.internal.cache.BucketAdvisor.ServerBucketProfile; -import com.gemstone.gemfire.internal.cache.BucketPersistenceAdvisor; -import com.gemstone.gemfire.internal.cache.BucketRegion; -import com.gemstone.gemfire.internal.cache.BucketServerLocation66; -import com.gemstone.gemfire.internal.cache.CacheDistributionAdvisor; -import com.gemstone.gemfire.internal.cache.EntryEventImpl; -import com.gemstone.gemfire.internal.cache.FixedPartitionAttributesImpl; -import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; -import com.gemstone.gemfire.internal.cache.InternalRegionArguments; -import com.gemstone.gemfire.internal.cache.Node; import com.gemstone.gemfire.internal.cache.PRHARedundancyProvider.DataStoreBuckets; -import com.gemstone.gemfire.internal.cache.PartitionedRegion; -import com.gemstone.gemfire.internal.cache.PartitionedRegionStats; -import com.gemstone.gemfire.internal.cache.ProxyBucketRegion; import com.gemstone.gemfire.internal.cache.control.MemoryThresholds; import com.gemstone.gemfire.internal.cache.control.ResourceAdvisor; import com.gemstone.gemfire.internal.cache.persistence.PersistenceAdvisor; import com.gemstone.gemfire.internal.cache.persistence.PersistentStateListener; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; import com.gemstone.gnu.trove.THashSet; -import io.snappydata.collection.ObjectLongHashMap; +import org.eclipse.collections.impl.map.mutable.primitive.ObjectLongHashMap; public final class RegionAdvisor extends CacheDistributionAdvisor { @@ -1547,30 +1535,29 @@ public Object next() { public ArrayList adviseFilteredDataStores(final Set memberFilter) { final ObjectLongHashMap memberToPrimaryCount = - ObjectLongHashMap.withExpectedSize(16); + new ObjectLongHashMap<>(16); for (ProxyBucketRegion pbr : this.buckets) { // quick dirty check - InternalDistributedMember p=pbr.getBucketAdvisor().basicGetPrimaryMember(); - if (p!=null) { - memberToPrimaryCount.put(p, memberToPrimaryCount.getLong(p) + 1); + InternalDistributedMember p = pbr.getBucketAdvisor().basicGetPrimaryMember(); + if (p != null) { + memberToPrimaryCount.addToValue(p, 1); } } - + final ArrayList ds = new ArrayList(memberFilter.size()); adviseFilter(new Filter() { public boolean include(Profile profile) { if (profile instanceof PartitionProfile) { PartitionProfile p = (PartitionProfile)profile; if(memberFilter.contains(p.getDistributedMember())) { - int primaryCount = (int)memberToPrimaryCount.getLong(p.getDistributedMember()); + int primaryCount = (int)memberToPrimaryCount.get(p.getDistributedMember()); ds.add(new DataStoreBuckets(p.getDistributedMember(), p.numBuckets, primaryCount, p.localMaxMemory)); } } return false; } }); - - + return ds; } diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/persistence/CanonicalIdHolder.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/persistence/CanonicalIdHolder.java index f48c8aca1..44d58a082 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/persistence/CanonicalIdHolder.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/persistence/CanonicalIdHolder.java @@ -16,8 +16,8 @@ */ package com.gemstone.gemfire.internal.cache.persistence; -import io.snappydata.collection.IntObjectHashMap; -import io.snappydata.collection.ObjectLongHashMap; +import org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap; +import org.eclipse.collections.impl.map.mutable.primitive.ObjectLongHashMap; /** * This class manages in memory copy of the canonical ids held in the disk @@ -34,13 +34,13 @@ public class CanonicalIdHolder { * Map of integer representation to canonicalized member ids. */ private final IntObjectHashMap idToObject = - IntObjectHashMap.withExpectedSize(10); + new IntObjectHashMap<>(10); /** * Map of canonicalized member ids to integer representation. */ private final ObjectLongHashMap objectToID = - ObjectLongHashMap.withExpectedSize(10); + new ObjectLongHashMap<>(10); private int highestID = 0; @@ -49,7 +49,7 @@ public class CanonicalIdHolder { */ public void addMapping(int id, Object object) { //Store the mapping - idToObject.justPut(id, object); + idToObject.put(id, object); objectToID.put(object, id); //increase the next canonical id the recovered id is higher than it. @@ -60,7 +60,7 @@ public void addMapping(int id, Object object) { * Get the id for a given object */ public int getId(Object object) { - return (int)objectToID.getLong(object); + return (int)objectToID.get(object); } /** @@ -78,7 +78,7 @@ public int createId(Object object) { assert !objectToID.containsKey(object); int id = ++highestID; objectToID.put(object, id); - idToObject.justPut(id, object); + idToObject.put(id, object); return id; } diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/store/SerializedDiskBuffer.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/store/SerializedDiskBuffer.java index e5ba97eff..4a190264f 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/store/SerializedDiskBuffer.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/store/SerializedDiskBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -92,6 +92,7 @@ public synchronized boolean retain() { return incrementReference(); } + @GuardedBy("this") protected final boolean incrementReference() { if (this.refCount > 0) { this.refCount++; @@ -116,6 +117,7 @@ public synchronized void release() { decrementReference(); } + @GuardedBy("this") protected final boolean decrementReference() { if (this.refCount > 0) { if (--this.refCount == 0) { @@ -146,6 +148,7 @@ public SerializedDiskBuffer getValueRetain(FetchRequest fetchRequest) { return retain() ? this : null; } + @GuardedBy("this") protected abstract void releaseBuffer(); /** diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/store/WrappedBytes.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/store/WrappedBytes.java index d5c0d87b9..4725813eb 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/store/WrappedBytes.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/store/WrappedBytes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/versions/RegionVersionVector.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/versions/RegionVersionVector.java index 7f70a8be3..a5ce08768 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/versions/RegionVersionVector.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/versions/RegionVersionVector.java @@ -49,10 +49,10 @@ import com.gemstone.gemfire.internal.cache.TXStateInterface; import com.gemstone.gemfire.internal.cache.persistence.DiskStoreID; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; -import io.snappydata.collection.OpenHashSet; import com.gemstone.gemfire.internal.shared.Version; import com.gemstone.gemfire.internal.util.concurrent.CopyOnWriteHashMap; -import io.snappydata.collection.ObjectObjectHashMap; +import org.eclipse.collections.impl.map.mutable.UnifiedMap; +import org.eclipse.collections.impl.set.mutable.UnifiedSet; /** * RegionVersionVector tracks the highest region-level version number of @@ -193,7 +193,7 @@ public RegionVersionVector getCloneForTransmission() { Map> liveHolders; // we need to take a lock? so that memberToVersion is not modifed as we copy them // Find out - liveHolders = ObjectObjectHashMap.from(this.memberToVersion); + liveHolders = new UnifiedMap<>(this.memberToVersion); ConcurrentHashMap> clonedHolders = new ConcurrentHashMap>(liveHolders.size(), LOAD_FACTOR, CONCURRENCY_LEVEL); @@ -238,7 +238,7 @@ protected abstract RegionVersionVector createCopy(T ownerId, */ public RegionVersionVector getCloneForTransmission(T mbr) { Map> liveHolders; - liveHolders = ObjectObjectHashMap.from(this.memberToVersion); + liveHolders = new UnifiedMap<>(this.memberToVersion); RegionVersionHolder holder = liveHolders.get(mbr); if (holder == null) { holder = new RegionVersionHolder(-1); @@ -261,7 +261,7 @@ public RegionVersionVector getCloneForTransmission(T mbr) { public Map getTombstoneGCVector() { Map result; synchronized(memberToGCVersion) { - result = ObjectObjectHashMap.from(this.memberToGCVersion); + result = new UnifiedMap<>(this.memberToGCVersion); } result.put(this.myId, this.localGCVersion.get()); return result; @@ -933,7 +933,7 @@ public final long getVersionForMember(T mbr) { */ public Set getDepartedMembersSet() { synchronized(this.memberToVersion) { - OpenHashSet result = new OpenHashSet<>(4); + UnifiedSet result = new UnifiedSet<>(4); for (RegionVersionHolder h: this.memberToVersion.values()) { if (h.isDepartedMember) { result.add((T)h.id); @@ -1494,8 +1494,8 @@ public Map> getMemberToVersion() { RegionVersionHolder myExceptions; myExceptions = this.localExceptions.clone(); - ObjectObjectHashMap> results = - ObjectObjectHashMap.from(memberToVersion); + UnifiedMap> results = + new UnifiedMap<>(memberToVersion); results.put(getOwnerId(), myExceptions); return results; @@ -1506,8 +1506,8 @@ public Map> getMemberToVersion() { * the local member. */ public Map getMemberToGCVersion() { - ObjectObjectHashMap results = - ObjectObjectHashMap.from(memberToGCVersion); + UnifiedMap results = + new UnifiedMap<>(memberToGCVersion); if(localGCVersion.get() > 0) { results.put(getOwnerId(), localGCVersion.get()); } diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/serial/SerialGatewaySenderQueue.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/serial/SerialGatewaySenderQueue.java index 8dc77585f..0f7237d39 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/serial/SerialGatewaySenderQueue.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/serial/SerialGatewaySenderQueue.java @@ -181,7 +181,7 @@ public class SerialGatewaySenderQueue implements RegionQueue { private static volatile int messageSyncInterval = DEFAULT_MESSAGE_SYNC_INTERVAL; - private BatchRemovalThread removalThread = null; + private final BatchRemovalThread removalThread; private final boolean keyPutNoSync; private final int maxPendingPuts; diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/concurrent/CustomEntryConcurrentHashMap.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/concurrent/CustomEntryConcurrentHashMap.java index ca38a50a6..80949b233 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/concurrent/CustomEntryConcurrentHashMap.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/concurrent/CustomEntryConcurrentHashMap.java @@ -1838,6 +1838,17 @@ public final V remove(final Object key, condition, context, removeParams, this.longSize); } + + public final V remove(final Object key, final Object value, + final MapCallback condition, final C context, + final P removeParams) { + // throws NullPointerException if key null + final int hash = this.entryCreator.keyHashCode(key, this.compareValues); + return segmentFor(hash).remove(key, hash, value, + condition, context, removeParams, this.longSize); + } + + // End GemStone addition /** diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/concurrent/QueryKeyedObjectPool.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/concurrent/QueryKeyedObjectPool.java index 40d246bc3..3b51080f6 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/concurrent/QueryKeyedObjectPool.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/concurrent/QueryKeyedObjectPool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/i18n/AbstractStringIdResourceBundle.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/i18n/AbstractStringIdResourceBundle.java index ec809f661..81ac605b8 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/i18n/AbstractStringIdResourceBundle.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/i18n/AbstractStringIdResourceBundle.java @@ -17,18 +17,18 @@ package com.gemstone.gemfire.internal.i18n; -import com.gemstone.gemfire.InternalGemFireException; -import com.gemstone.gemfire.i18n.StringIdImpl; -import com.gemstone.gemfire.internal.ClassPathLoader; -import com.gemstone.org.jgroups.util.StringId; -import io.snappydata.collection.IntObjectHashMap; - import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Locale; +import com.gemstone.gemfire.InternalGemFireException; +import com.gemstone.gemfire.i18n.StringIdImpl; +import com.gemstone.gemfire.internal.ClassPathLoader; +import com.gemstone.org.jgroups.util.StringId; +import org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap; + /** * Baseclass for all {@link StringId} based ResourceBundles @@ -48,7 +48,7 @@ public class AbstractStringIdResourceBundle { /** * Init method to populate the IntObjectHashMap for Non-english locales - * data = IntObjectHashMap.withExpectedSize(...); + * data = new IntObjectHashMap(...); * * The default bundle, English, will be * data = null @@ -77,7 +77,7 @@ private void initData(String baseName, Locale l) { } private IntObjectHashMap readDataFile(InputStream is) { - IntObjectHashMap map = IntObjectHashMap.withExpectedSize(128); + IntObjectHashMap map = new IntObjectHashMap<>(128); boolean complete = false; BufferedReader input = null; try { @@ -90,7 +90,7 @@ private IntObjectHashMap readDataFile(InputStream is) { String message = line.substring(equalSign+2).replaceAll("\\\\n", "\n"); try { int id = Integer.parseInt(idAsString); - map.justPut(id, message); + map.put(id, message); } catch(NumberFormatException nfe) { //unit tests should prevent this from happening in a customer situation throw new InternalGemFireException(nfe); diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/lang/SystemUtils.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/lang/SystemUtils.java index 49aab7b7e..24b14712f 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/lang/SystemUtils.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/lang/SystemUtils.java @@ -33,6 +33,7 @@ public class SystemUtils { // Java Virtual Machine (JVM) Names public static final String IBM_J9_JVM_NAME = "J9"; public static final String JAVA_HOTSPOT_JVM_NAME = "HotSpot"; + public static final String OPENJDK_JVM_NAME = "OpenJDK"; public static final String ORACLE_JROCKIT_JVM_NAME = "JRockit"; // Operating System Names @@ -71,7 +72,8 @@ public static boolean isJavaVersionAtLeast(final String expectedVersion) { */ public static boolean isHotSpotVM() { final String vm = System.getProperty("java.vm.name"); - return (vm != null && vm.contains(JAVA_HOTSPOT_JVM_NAME)); + return (vm != null && + (vm.contains(JAVA_HOTSPOT_JVM_NAME) || vm.contains(OPENJDK_JVM_NAME))); } /** diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/snappy/CallbackFactoryProvider.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/snappy/CallbackFactoryProvider.java index 6f0466740..0eb3bae41 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/snappy/CallbackFactoryProvider.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/snappy/CallbackFactoryProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -91,11 +91,7 @@ public CloseableIterator columnTableScan( } @Override - public void registerRelationDestroyForHiveStore() { - } - - @Override - public void performConnectorOp(Object ctx) { + public void registerCatalogSchemaChange() { } @Override @@ -197,6 +193,11 @@ public void clearSessionCache(boolean onlyQueryPlanCache) {} @Override public void refreshPolicies(String ldapGroup) { } + + @Override + public String checkSchemaPermission(String schema, String currentUser) { + return null; + } }; public static void setStoreCallbacks(StoreCallbacks cb) { diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/snappy/StoreCallbacks.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/snappy/StoreCallbacks.java index 9628f1f40..492639b2a 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/snappy/StoreCallbacks.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/snappy/StoreCallbacks.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -62,9 +62,7 @@ CloseableIterator columnTableScan(String qualifiedTable, int[] projection, byte[] serializedFilters, Set bucketIds) throws SQLException; - void registerRelationDestroyForHiveStore(); - - void performConnectorOp(Object ctx); + void registerCatalogSchemaChange(); Object getSnappyTableStats(); @@ -147,4 +145,9 @@ boolean acquireStorageMemory(String objectName, long numBytes, * @param ldapGroup */ void refreshPolicies(String ldapGroup); + + /** + * Check permission for current user on given schema. + */ + String checkSchemaPermission(String schema, String currentUser); } diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/snappy/UMMMemoryTracker.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/snappy/UMMMemoryTracker.java index d583aa6d5..b3029e454 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/snappy/UMMMemoryTracker.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/snappy/UMMMemoryTracker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/snappy/memory/MemoryManagerStats.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/snappy/memory/MemoryManagerStats.java index d423ea3f0..b39670b3b 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/snappy/memory/MemoryManagerStats.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/snappy/memory/MemoryManagerStats.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/snappy/memory/MemoryManagerStatsOps.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/snappy/memory/MemoryManagerStatsOps.java index b362ecc7a..77153dc0e 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/snappy/memory/MemoryManagerStatsOps.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/snappy/memory/MemoryManagerStatsOps.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/statistics/SampleCollector.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/statistics/SampleCollector.java index 6e24ffdff..fd7afb68a 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/statistics/SampleCollector.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/statistics/SampleCollector.java @@ -226,7 +226,7 @@ public void sample(long nanosTimeStamp) { List updatedResources = new ArrayList(); for (ResourceInstance ri : this.resourceInstMap.values()) { StatisticDescriptor[] stats = ri.getResourceType().getStatisticDescriptors(); - if (ri.getStatistics().isClosed()) { + if (ri.getStatistics().isClosed() || stats.length == 0) { continue; } @@ -253,6 +253,7 @@ public void sample(long nanosTimeStamp) { } } // resize updatedStats to only contain the the stats which were updated + if (updatedStatsIdx == 0) continue; updatedStats = Arrays.copyOf(updatedStats, updatedStatsIdx); } diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/Connection.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/Connection.java index 5205c0129..4bf00b0da 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/Connection.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/Connection.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/MsgChannelDestreamer.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/MsgChannelDestreamer.java index 0afabcdf4..482b533ce 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/MsgChannelDestreamer.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/MsgChannelDestreamer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/MsgChannelStreamer.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/MsgChannelStreamer.java index 0dd076b8f..e1c54f04d 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/MsgChannelStreamer.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/MsgChannelStreamer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/util/BlobHelper.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/util/BlobHelper.java index c01ba3b23..e09353ac9 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/util/BlobHelper.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/util/BlobHelper.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/util/concurrent/CopyOnWriteHashMap.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/util/concurrent/CopyOnWriteHashMap.java index 1e0a6a1b0..1e60f83ba 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/util/concurrent/CopyOnWriteHashMap.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/util/concurrent/CopyOnWriteHashMap.java @@ -22,7 +22,7 @@ import java.util.Map; import java.util.Set; -import io.snappydata.collection.ObjectObjectHashMap; +import org.eclipse.collections.impl.map.mutable.UnifiedMap; /** * A copy on write hash map. @@ -54,7 +54,7 @@ public V get(Object key) { @Override public synchronized V put(K key, V value) { - ObjectObjectHashMap tmp = ObjectObjectHashMap.from(map); + UnifiedMap tmp = new UnifiedMap(map); V result = tmp.put(key, value); map = Collections.unmodifiableMap(tmp); return result; @@ -64,14 +64,14 @@ public synchronized V put(K key, V value) { @Override public synchronized void putAll(Map m) { - ObjectObjectHashMap tmp = ObjectObjectHashMap.from(map); + UnifiedMap tmp = new UnifiedMap<>(map); tmp.putAll(m); map = Collections.unmodifiableMap(tmp); } @Override public synchronized V remove(Object key) { - ObjectObjectHashMap tmp = ObjectObjectHashMap.from(map); + UnifiedMap tmp = new UnifiedMap<>(map); V result = tmp.remove(key); map = Collections.unmodifiableMap(tmp); return result; diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/beans/PartitionedRegionBridge.java b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/beans/PartitionedRegionBridge.java index eb401c06e..c3679e355 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/beans/PartitionedRegionBridge.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/beans/PartitionedRegionBridge.java @@ -27,7 +27,6 @@ import com.gemstone.gemfire.internal.cache.BucketRegion; import com.gemstone.gemfire.internal.cache.PartitionedRegion; import com.gemstone.gemfire.internal.cache.PartitionedRegionStats; -import com.gemstone.gemfire.internal.snappy.StoreCallbacks; import com.gemstone.gemfire.management.FixedPartitionAttributesData; import com.gemstone.gemfire.management.PartitionAttributesData; import com.gemstone.gemfire.management.internal.ManagementConstants; @@ -78,8 +77,6 @@ public class PartitionedRegionBridge extends RegionMBeanBridge { private StatsAverageLatency remotePutAvgLatency; - private boolean isColumnTable = false; - public static final String PAR_REGION_MONITOR = "PartitionedRegionMonitor"; public static PartitionedRegionBridge getInstance(Region region) { @@ -100,9 +97,7 @@ protected PartitionedRegionBridge(Region region) { this.parRegion = (PartitionedRegion)region; this.prStats = parRegion.getPrStats(); - this.isColumnTable = parRegion.getName().toUpperCase().endsWith(StoreCallbacks.SHADOW_TABLE_SUFFIX); - - PartitionAttributes partAttrs = parRegion.getPartitionAttributes(); + PartitionAttributes partAttrs = parRegion.getPartitionAttributes(); this.parRegionMonitor = new MBeanStatsMonitor(PAR_REGION_MONITOR); @@ -328,7 +323,7 @@ public long getEstimatedSizeForHDFSRegion() { @Override public boolean isColumnTable() { - return isColumnTable; + return parRegion.isInternalColumnTable(); } @Override diff --git a/gemfire-examples/build.gradle b/gemfire-examples/build.gradle index 3e3e4bc54..c8caf1176 100644 --- a/gemfire-examples/build.gradle +++ b/gemfire-examples/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-junit/build.gradle b/gemfire-junit/build.gradle index 33f747ddf..f6f00eec0 100644 --- a/gemfire-junit/build.gradle +++ b/gemfire-junit/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -18,19 +18,19 @@ dependencies { compile project(subprojectBase + 'gemfire-core') - compile 'net.spy:spymemcached:2.12.0' - compile 'org.apache.bcel:bcel:5.2' + compile "net.spy:spymemcached:${memcachedVersion}" + compile "org.apache.bcel:bcel:${bcelVersion}" compile "junit:junit:${junitVersion}" - compile 'org.hamcrest:hamcrest-core:1.3' - compile 'org.hamcrest:hamcrest-library:1.3' - compile 'org.jmock:jmock:2.5.1' - compile 'org.jmock:jmock-legacy:2.5.1' - compile 'edu.umd.cs.mtc:multithreadedtc:1.01' - compile 'cglib:cglib-nodep:2.1_3' - compile 'org.objenesis:objenesis:2.6' - compile 'antlr:antlr:2.7.7' + compile "org.hamcrest:hamcrest-core:${hamcrestVersion}" + compile "org.hamcrest:hamcrest-library:${hamcrestVersion}" + compile "org.jmock:jmock:${jmockVersion}" + compile "org.jmock:jmock-legacy:${jmockVersion}" + compile "edu.umd.cs.mtc:multithreadedtc:${multiThreadedTCVersion}" + compile "cglib:cglib-nodep:${cglibVersion}" + compile "org.objenesis:objenesis:${objenesisVersion}" + compile "antlr:antlr:${antlr2Version}" - compile 'net.sourceforge.jline:jline:1.0.S2-B' + compile "net.sourceforge.jline:jline:${jlineSfVersion}" compile "org.eclipse.jetty:jetty-http:${jettyVersion}" compile "org.eclipse.jetty:jetty-io:${jettyVersion}" compile "org.eclipse.jetty:jetty-security:${jettyVersion}" @@ -49,7 +49,7 @@ dependencies { compile "org.springframework:spring-web:${springVersion}" compile "org.springframework:spring-webmvc:${springVersion}" compile "org.springframework:spring-tx:${springVersion}" - compile 'org.springframework.shell:spring-shell:1.0.0.RELEASE' + compile "org.springframework.shell:spring-shell:${springShellVersion}" compile "org.apache.hadoop:hadoop-annotations:${hadoopVersion}" compile "org.apache.hadoop:hadoop-auth:${hadoopVersion}" @@ -66,7 +66,8 @@ dependencies { compile "com.sun.jersey:jersey-servlet:${sunJerseyVersion}" compile "org.mortbay.jetty:jetty:${hadoopJettyVersion}" compile "org.mortbay.jetty:jetty-util:${hadoopJettyVersion}" - compile 'org.cloudera.htrace:htrace-core:2.05' + compile "org.mortbay.jetty:jetty-sslengine:${hadoopJettyVersion}" + compile "org.cloudera.htrace:htrace-core:${clouderaHtraceVersion}" compile "org.glassfish.jersey.core:jersey-server:${jerseyVersion}" compile "org.glassfish.jersey.containers:jersey-container-servlet-core:${jerseyVersion}" compile "org.eclipse.jetty:jetty-server:${jettyVersion}" diff --git a/gemfire-junit/src/main/java/com/gemstone/gemfire/cache/RoleExceptionJUnitTest.java b/gemfire-junit/src/main/java/com/gemstone/gemfire/cache/RoleExceptionJUnitTest.java index de3f76d46..3ad7c9aa9 100644 --- a/gemfire-junit/src/main/java/com/gemstone/gemfire/cache/RoleExceptionJUnitTest.java +++ b/gemfire-junit/src/main/java/com/gemstone/gemfire/cache/RoleExceptionJUnitTest.java @@ -16,10 +16,15 @@ */ package com.gemstone.gemfire.cache; -import java.io.*; -import java.util.*; -import junit.framework.TestCase; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.HashSet; +import java.util.Set; + import com.gemstone.gemfire.distributed.internal.membership.InternalRole; +import junit.framework.TestCase; /** Tests the subclasses of RoleException to make sure they are Serializable */ public class RoleExceptionJUnitTest extends TestCase { @@ -80,36 +85,6 @@ public void testRegionDistributionExceptionIsSerializable() throws Exception { assertEquals(out.getRegionFullPath(), in.getRegionFullPath()); } - /** - * Assert that CommitDistributionException is serializable. - */ - public void testCommitDistributionExceptionIsSerializable() throws Exception { - String s = "MyString"; - Set outExceptions = new HashSet(); - outExceptions.add(createRegionDistributionException()); - - CommitDistributionException out = new CommitDistributionException( - s, outExceptions); - ByteArrayOutputStream baos = new ByteArrayOutputStream(100); - ObjectOutputStream oos = new ObjectOutputStream(baos); - oos.writeObject(out); - - byte[] data = baos.toByteArray(); - - ByteArrayInputStream bais = new ByteArrayInputStream(data); - ObjectInputStream ois = new ObjectInputStream(bais); - CommitDistributionException in = (CommitDistributionException) ois.readObject(); - - Set inExceptions = in.getRegionDistributionExceptions(); - assertNotNull(inExceptions); - Iterator iter = inExceptions.iterator(); - assertTrue(iter.hasNext()); - RegionDistributionException e = (RegionDistributionException) iter.next(); - assertEquals(createSetOfRoles(), e.getFailedRoles()); - - assertEquals(out.getMessage(), in.getMessage()); - } - private Set createSetOfRoles() { Set set = new HashSet(); set.add(InternalRole.getRole("RoleA")); diff --git a/gemfire-junit/src/main/java/com/gemstone/gemfire/internal/BackwardCompatibilitySerializationJUnitTest.java b/gemfire-junit/src/main/java/com/gemstone/gemfire/internal/BackwardCompatibilitySerializationJUnitTest.java index 483b1e30a..3dcbcd9ac 100644 --- a/gemfire-junit/src/main/java/com/gemstone/gemfire/internal/BackwardCompatibilitySerializationJUnitTest.java +++ b/gemfire-junit/src/main/java/com/gemstone/gemfire/internal/BackwardCompatibilitySerializationJUnitTest.java @@ -27,13 +27,12 @@ import java.util.ArrayList; import java.util.function.Supplier; -import junit.framework.TestCase; - import com.gemstone.gemfire.cache.Cache; import com.gemstone.gemfire.cache.CacheFactory; import com.gemstone.gemfire.internal.cache.DistributedPutAllOperation.EntryVersionsList; import com.gemstone.gemfire.internal.shared.Version; import com.gemstone.org.jgroups.util.VersionedStreamable; +import junit.framework.TestCase; /** * Test the DSFID serialization framework added for rolling upgrades in 7.1 @@ -191,12 +190,11 @@ public void testAllMessages() throws Exception { // some msgs require distributed system Cache c = new CacheFactory().create(); - DSFIDFactory.getDsfidmap2().forEachWhile((id, cons) -> { + DSFIDFactory.getDsfidmap2().forEachValue(cons -> { if (cons != null) { DataSerializableFixedID ds = (DataSerializableFixedID)cons.get(); checkSupportForRollingUpgrade(ds); } - return true; }); c.close(); } diff --git a/gemfire-junit/src/main/java/com/gemstone/gemfire/internal/cache/OplogEntryIdMapJUnitTest.java b/gemfire-junit/src/main/java/com/gemstone/gemfire/internal/cache/OplogEntryIdMapJUnitTest.java index 2758fb87b..b45bf380c 100644 --- a/gemfire-junit/src/main/java/com/gemstone/gemfire/internal/cache/OplogEntryIdMapJUnitTest.java +++ b/gemfire-junit/src/main/java/com/gemstone/gemfire/internal/cache/OplogEntryIdMapJUnitTest.java @@ -16,15 +16,9 @@ */ package com.gemstone.gemfire.internal.cache; -import java.io.*; -import java.util.*; - -import com.gemstone.gemfire.cache.*; -import com.gemstone.gemfire.internal.Assert; -import com.gemstone.gemfire.distributed.*; import com.gemstone.gemfire.internal.cache.Oplog.OplogEntryIdMap; - import junit.framework.TestCase; +import org.eclipse.collections.api.iterator.LongIterator; /** * Tests DiskStoreImpl.OplogEntryIdMap @@ -90,11 +84,9 @@ public void testBasics() { assertEquals(777777+1+777777+1+1, m.size()); int count = 0; - for (OplogEntryIdMap.Iterator it = m.iterator(); it.hasNext();) { + for (LongIterator it = m.keys(); it.hasNext();) { count++; - it.advance(); - it.key(); - it.value(); + it.next(); } assertEquals(777777+1+777777+1+1, count); } diff --git a/gemfire-junit/src/main/java/com/gemstone/gemfire/internal/lang/SystemUtilsTest.java b/gemfire-junit/src/main/java/com/gemstone/gemfire/internal/lang/SystemUtilsTest.java index 468ac41a1..f4d0dce6a 100644 --- a/gemfire-junit/src/main/java/com/gemstone/gemfire/internal/lang/SystemUtilsTest.java +++ b/gemfire-junit/src/main/java/com/gemstone/gemfire/internal/lang/SystemUtilsTest.java @@ -50,7 +50,9 @@ public void testIsJavaVersionAtLeast() { @Test public void testIsHotSpotVM() { - final boolean expected = ManagementFactory.getRuntimeMXBean().getVmName().contains(SystemUtils.JAVA_HOTSPOT_JVM_NAME); + final String vmName = ManagementFactory.getRuntimeMXBean().getVmName(); + final boolean expected = vmName.contains(SystemUtils.JAVA_HOTSPOT_JVM_NAME) || + vmName.contains(SystemUtils.OPENJDK_JVM_NAME); assertEquals(expected, SystemUtils.isHotSpotVM()); } diff --git a/gemfire-junit/src/main/resources/com/gemstone/gemfire/codeAnalysis/sanctionedSerializables.txt b/gemfire-junit/src/main/resources/com/gemstone/gemfire/codeAnalysis/sanctionedSerializables.txt index 47f1d78d8..ce42931f5 100644 --- a/gemfire-junit/src/main/resources/com/gemstone/gemfire/codeAnalysis/sanctionedSerializables.txt +++ b/gemfire-junit/src/main/resources/com/gemstone/gemfire/codeAnalysis/sanctionedSerializables.txt @@ -44,15 +44,11 @@ com/gemstone/gemfire/cache/CacheLoaderException,true,-3383072059406642140 com/gemstone/gemfire/cache/CacheRuntimeException,false com/gemstone/gemfire/cache/CacheWriterException,true,-2872212342970454458 com/gemstone/gemfire/cache/CacheXmlException,true,-4343870964883131754 -com/gemstone/gemfire/cache/CommitConflictException,true,-1491184174802596675 -com/gemstone/gemfire/cache/CommitDistributionException,true,-3517820638706581823,regionDistributionExceptions:java/util/Set -com/gemstone/gemfire/cache/CommitIncompleteException,true,1017741483744420800 com/gemstone/gemfire/cache/DiskAccessException,true,5799100281147167888 com/gemstone/gemfire/cache/DuplicatePrimaryPartitionException,true,1 com/gemstone/gemfire/cache/EntryDestroyedException,true,831865939772672542 com/gemstone/gemfire/cache/EntryExistsException,true,2925082493103537925,oldValue:java/lang/Object com/gemstone/gemfire/cache/EntryNotFoundException,true,-2404101631744605659 -com/gemstone/gemfire/cache/EntryNotFoundInRegion,true,5572550909947420405 com/gemstone/gemfire/cache/EvictionAction,true,-98840597493242980 com/gemstone/gemfire/cache/EvictionAlgorithm,true,5778669432033106789 com/gemstone/gemfire/cache/FailedSynchronizationException,true,-6225053492344591496 @@ -72,7 +68,6 @@ com/gemstone/gemfire/cache/RegionExistsException,true,-5643670216230359426 com/gemstone/gemfire/cache/RegionReinitializedException,true,8532904304288670752 com/gemstone/gemfire/cache/RegionRoleException,false,regionFullPath:java/lang/String com/gemstone/gemfire/cache/RegionShortcut,false -com/gemstone/gemfire/cache/RemoteTransactionException,true,-2217135580436381984 com/gemstone/gemfire/cache/ResourceException,false com/gemstone/gemfire/cache/RoleException,true,-7521056108445887394 com/gemstone/gemfire/cache/StatisticsDisabledException,true,-2987721454129719551 @@ -267,12 +262,6 @@ com/gemstone/gemfire/internal/cache/RegionQueueException,true,415930758632582110 com/gemstone/gemfire/internal/cache/RemoteOperationException,true,-595988965679204903,hasHash:boolean,keyHash:int com/gemstone/gemfire/internal/cache/RemoteRegionOperation$Operation,false com/gemstone/gemfire/internal/cache/SearchLoadAndWriteProcessor$TryAgainException,false -com/gemstone/gemfire/internal/cache/TStatelessIntHash,false,_FREE:int,_hashingStrategy:com/gemstone/gnu/trove/TIntHashingStrategy -com/gemstone/gemfire/internal/cache/TStatelessIntHashSet,false -com/gemstone/gemfire/internal/cache/TStatelessIntObjectHashMap,false -com/gemstone/gemfire/internal/cache/TStatelessLongHash,false,_FREE:long,_hashingStrategy:com/gemstone/gnu/trove/TLongHashingStrategy -com/gemstone/gemfire/internal/cache/TStatelessLongHashSet,false -com/gemstone/gemfire/internal/cache/TStatelessLongObjectHashMap,false com/gemstone/gemfire/internal/cache/TXCommitMessage$CommitExceptionCollectingException,true,589384721273797822,cacheExceptions:java/util/Set,fatalExceptions:java/util/Map,id:com/gemstone/gemfire/internal/cache/TXId,regionExceptions:java/util/Map com/gemstone/gemfire/internal/cache/TXCommitMessage$RegionCommitList,true,-8910813949027683641 com/gemstone/gemfire/internal/cache/TXFarSideCMTracker$2,false,this$0:com/gemstone/gemfire/internal/cache/TXFarSideCMTracker @@ -559,7 +548,6 @@ com/gemstone/gnu/trove/TIntIntHashMap,true,-8732217708418898237 com/gemstone/gnu/trove/TIntObjectHashMap,true,-313496576027551184 com/gemstone/gnu/trove/TLongHash,false,_hashingStrategy:com/gemstone/gnu/trove/TLongHashingStrategy com/gemstone/gnu/trove/TLongHashSet,true,-7341114291520670738 -com/gemstone/gnu/trove/TLongObjectHashMap,true,7524673861954387917 com/gemstone/gnu/trove/TObjectHash,false,_hashingStrategy:com/gemstone/gnu/trove/TObjectHashingStrategy com/gemstone/gnu/trove/TObjectIntHashMap,true,309134146652813984 com/gemstone/java/util/concurrent/SynchronousQueueNoSpin,true,-3223113410248163686,qlock:java/util/concurrent/locks/ReentrantLock,waitingConsumers:com/gemstone/java/util/concurrent/SynchronousQueueNoSpin$WaitQueue,waitingProducers:com/gemstone/java/util/concurrent/SynchronousQueueNoSpin$WaitQueue diff --git a/gemfire-shared/build.gradle b/gemfire-shared/build.gradle index 707af6010..637e1cc86 100644 --- a/gemfire-shared/build.gradle +++ b/gemfire-shared/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/cache/Status.java b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/cache/Status.java index 4e8e3c531..68217bb75 100644 --- a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/cache/Status.java +++ b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/cache/Status.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/BufferAllocator.java b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/BufferAllocator.java index 9184305e0..dbcb50f0e 100644 --- a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/BufferAllocator.java +++ b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/BufferAllocator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -56,9 +56,10 @@ public ByteBuffer allocateWithFallback(int size, String owner) { public abstract ByteBuffer allocateForStorage(int size); /** - * Clears the memory to be zeros immediately after allocation. + * Clears the memory to be zeros immediately after allocation + * from given position to end. */ - public abstract void clearPostAllocate(ByteBuffer buffer); + public abstract void clearPostAllocate(ByteBuffer buffer, int position); /** * Fill the given portion of the buffer setting it with given byte. @@ -88,7 +89,8 @@ public final void fill(ByteBuffer buffer, byte b) { /** * Expand given ByteBuffer to new capacity. The new buffer is positioned - * at the start and caller has to reposition if required. + * at the start and caller has to reposition if required. The ByteOrder + * will be copied from the source buffer. * * @return the new expanded ByteBuffer */ diff --git a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/ByteBufferReference.java b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/ByteBufferReference.java index 492f3c508..aaf6588e9 100644 --- a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/ByteBufferReference.java +++ b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/ByteBufferReference.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/ClientSharedUtils.java b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/ClientSharedUtils.java index 8187b1bfd..526d504e1 100644 --- a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/ClientSharedUtils.java +++ b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/ClientSharedUtils.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -72,6 +72,8 @@ import javax.naming.directory.InitialDirContext; import com.gemstone.gemfire.internal.shared.unsafe.DirectBufferAllocator; +import org.apache.log4j.Appender; +import org.apache.log4j.FileAppender; import org.apache.log4j.LogManager; import org.apache.log4j.PropertyConfigurator; import org.apache.spark.unsafe.Platform; @@ -1400,15 +1402,18 @@ public static Path getProductJarsDirectory(Class c) throws IOException { public static Level convertToJavaLogLevel(org.apache.log4j.Level log4jLevel) { Level javaLevel = Level.CONFIG; if (log4jLevel != null) { - if (log4jLevel == org.apache.log4j.Level.ERROR) { + if (log4jLevel == org.apache.log4j.Level.ERROR || + log4jLevel == org.apache.log4j.Level.FATAL) { javaLevel = Level.SEVERE; } else if (log4jLevel == org.apache.log4j.Level.WARN) { javaLevel = Level.WARNING; } else if (log4jLevel == org.apache.log4j.Level.INFO) { javaLevel = Level.INFO; - } else if (log4jLevel == org.apache.log4j.Level.TRACE) { - javaLevel = Level.FINE; } else if (log4jLevel == org.apache.log4j.Level.DEBUG) { + javaLevel = Level.FINE; + } else if (log4jLevel == org.apache.log4j.Level.TRACE) { + javaLevel = Level.FINEST; + } else if (log4jLevel == org.apache.log4j.Level.ALL) { javaLevel = Level.ALL; } else if (log4jLevel == org.apache.log4j.Level.OFF) { javaLevel = Level.OFF; @@ -1417,31 +1422,65 @@ public static Level convertToJavaLogLevel(org.apache.log4j.Level log4jLevel) { return javaLevel; } - public static String convertToLog4LogLevel(Level level) { - String levelStr = "INFO"; + public static org.apache.log4j.Level convertToLog4LogLevel(String level) + throws IllegalArgumentException { + org.apache.log4j.Level logLevel = null; + if (level != null && !level.isEmpty()) { + level = level.trim().toUpperCase(Locale.ENGLISH); + // try log4j level first + logLevel = org.apache.log4j.Level.toLevel(level, null); + // try java util Logger next + if (logLevel == null) { + logLevel = convertToLog4LogLevel(Level.parse(level)); + } + } + return logLevel; + } + + public static org.apache.log4j.Level convertToLog4LogLevel(Level level) { + org.apache.log4j.Level log4Level = org.apache.log4j.Level.INFO; // convert to log4j level if (level == Level.SEVERE) { - levelStr = "ERROR"; + log4Level = org.apache.log4j.Level.FATAL; } else if (level == Level.WARNING) { - levelStr = "WARN"; + log4Level = org.apache.log4j.Level.WARN; } else if (level == Level.INFO || level == Level.CONFIG) { - levelStr = "INFO"; - } else if (level == Level.FINE || level == Level.FINER || - level == Level.FINEST) { - levelStr = "TRACE"; + log4Level = org.apache.log4j.Level.INFO; + } else if (level == Level.FINE) { + log4Level = org.apache.log4j.Level.DEBUG; + } else if (level == Level.FINER || level == Level.FINEST) { + log4Level = org.apache.log4j.Level.TRACE; } else if (level == Level.ALL) { - levelStr = "DEBUG"; + log4Level = org.apache.log4j.Level.ALL; } else if (level == Level.OFF) { - levelStr = "OFF"; + log4Level = org.apache.log4j.Level.OFF; + } else if ("ERROR".equalsIgnoreCase(level.getName())) { // GemFireLevel.ERROR + log4Level = org.apache.log4j.Level.ERROR; } - return levelStr; + return log4Level; } public static void initLog4j(String logFile, - Level level) throws IOException { + org.apache.log4j.Level level) throws IOException { initLog4j(logFile, null, level); } + /** + * Return currently configured log4j log-file or null if file logging is not set. + */ + public static String getLog4jLogFile(org.apache.log4j.Logger rootLogger) { + if (rootLogger != null) { + Enumeration e = rootLogger.getAllAppenders(); + while (e.hasMoreElements()) { + Appender appender = (Appender)e.nextElement(); + if (appender instanceof FileAppender) { + return ((FileAppender)appender).getFile(); + } + } + } + return null; + } + public static Properties getLog4jConfProperties( String snappyHome) throws IOException { Path confFile = Paths.get(snappyHome, "conf", "log4j.properties"); @@ -1456,7 +1495,7 @@ public static Properties getLog4jConfProperties( } private static Properties getLog4jProperties(String logFile, - Level level) throws IOException { + org.apache.log4j.Level level) throws IOException { // check for user provided properties file in "conf/" String snappyHome = NativeCalls.getInstance().getEnvironment("SNAPPY_HOME"); if (snappyHome != null) { @@ -1475,11 +1514,23 @@ private static Properties getLog4jProperties(String logFile, // override file location and level if (level != null) { - final String levelStr = convertToLog4LogLevel(level); if (logFile != null) { - props.setProperty("log4j.rootCategory", levelStr + ", file"); + props.setProperty("log4j.rootCategory", level + ", file"); } else { - props.setProperty("log4j.rootCategory", levelStr + ", console"); + props.setProperty("log4j.rootCategory", level + ", console"); + // remove all "code" appenders that dump generatedcode.log + final String[] codegenerationClasses = new String[] { + "org.apache.spark.sql.execution.WholeStageCodegenExec", + "org.apache.spark.sql.execution.WholeStageCodegenRDD", + "org.apache.spark.sql.catalyst.expressions.codegen.CodeGenerator", + "org.apache.spark.sql.store.CodeGeneration" + }; + for (String className : codegenerationClasses) { + String loggerKey = "log4j.logger." + className; + String additivityKey = "log4j.additivity." + className; + props.remove(loggerKey); + props.remove(additivityKey); + } } } if (logFile != null) { @@ -1498,7 +1549,7 @@ private static Properties getLog4jProperties(String logFile, } public static synchronized void initLog4j(String logFile, - Properties userProps, Level level) throws IOException { + Properties userProps, org.apache.log4j.Level level) throws IOException { Properties props; if (baseLoggerProperties.isEmpty() || logFile != null) { props = getLog4jProperties(logFile, level); @@ -1535,7 +1586,7 @@ public static synchronized void initLogger(String loggerName, String logFile, clearLogger(); if (initLog4j) { try { - initLog4j(logFile, level); + initLog4j(logFile, convertToLog4LogLevel(level)); } catch (IOException ioe) { throw newRuntimeException(ioe.getMessage(), ioe); } diff --git a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/HeapBufferAllocator.java b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/HeapBufferAllocator.java index c00f9bf5b..1b4892424 100644 --- a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/HeapBufferAllocator.java +++ b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/HeapBufferAllocator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -51,12 +51,12 @@ public ByteBuffer allocateForStorage(int size) { } @Override - public void clearPostAllocate(ByteBuffer buffer) { + public void clearPostAllocate(ByteBuffer buffer, int position) { // JVM clears the allocated area, so only clear for DEBUG_FILL case if (MemoryAllocator.MEMORY_DEBUG_FILL_ENABLED) { // clear till the capacity and not limit since former will be a factor // of 8 and hence more efficient in Unsafe.setMemory - fill(buffer, (byte)0, 0, buffer.capacity()); + fill(buffer, (byte)0, position, buffer.capacity() - position); } } diff --git a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/LauncherBase.java b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/LauncherBase.java index 835813220..fe8536a94 100644 --- a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/LauncherBase.java +++ b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/LauncherBase.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -101,7 +101,7 @@ public abstract class LauncherBase { "The server is still starting. " + "{0} seconds have elapsed since the last log message: \n {1}"; public static final String LAUNCHER_IS_ALREADY_RUNNING_IN_DIRECTORY = - "ERROR: A {0} is already running in directory \"{1}\""; + "WARN: A {0} is already running in directory \"{1}\""; private static final String LAUNCHER_EXPECTED_BOOLEAN = "Expected true or false for \"{0}=\" but was \"{1}\""; @@ -190,7 +190,7 @@ public static long getPhysicalRAMSize() { } catch (Exception e) { // ignore exception and return zero } - if (memSize != null && (memSize instanceof Number)) { + if (memSize instanceof Number) { totalMemory = ((Number)memSize).longValue(); } return totalMemory; diff --git a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/NativeCalls.java b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/NativeCalls.java index 897add43b..960309ccc 100644 --- a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/NativeCalls.java +++ b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/NativeCalls.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/OutputStreamChannel.java b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/OutputStreamChannel.java index 4d9d56355..53b01b79d 100644 --- a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/OutputStreamChannel.java +++ b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/OutputStreamChannel.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/StreamChannel.java b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/StreamChannel.java index 18cdc6d6b..9c5cc4285 100644 --- a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/StreamChannel.java +++ b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/StreamChannel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/SystemProperties.java b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/SystemProperties.java index e5bf990c9..1a9b591de 100644 --- a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/SystemProperties.java +++ b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/SystemProperties.java @@ -21,7 +21,8 @@ import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; -import java.util.logging.Logger; + +import org.apache.log4j.Logger; /** * Set the global system properties. This class is the supported way to change @@ -70,7 +71,7 @@ public final class SystemProperties { public static final String DEFAULT_PROPERTY_NAME_PREFIX = "gemfire."; public static final String DEFAULT_GFXDCLIENT_PROPERTY_NAME_PREFIX = - "gemfirexd.client."; + "snappydata.client."; /** The prefix used for SnappyData properties set through java system properties */ public static final String SNAPPY_PREFIX = "snappydata.store."; @@ -274,14 +275,8 @@ public String getString(final String name, final String defaultValue) { return defaultValue; } } catch (PrivilegedActionException | SecurityException e) { - Logger log = ClientSharedUtils.getLogger(); - if (log != null) { - StringBuilder msg = new StringBuilder( - "Could not read system property: "); - msg.append(name); - ClientSharedUtils.getStackTrace(e, msg, null); - log.warning(msg.toString()); - } + Logger log = Logger.getLogger(getClass()); + log.warn("Could not read system property: " + name, e); } return defaultValue; } diff --git a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/FreeBSDNativeCalls.java b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/FreeBSDNativeCalls.java index 265036426..71289b89e 100644 --- a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/FreeBSDNativeCalls.java +++ b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/FreeBSDNativeCalls.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/LinuxNativeCalls.java b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/LinuxNativeCalls.java index 63987b79d..f1e36e9b6 100644 --- a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/LinuxNativeCalls.java +++ b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/LinuxNativeCalls.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/MacOSXNativeCalls.java b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/MacOSXNativeCalls.java index 846b8322c..340704b0c 100644 --- a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/MacOSXNativeCalls.java +++ b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/MacOSXNativeCalls.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/NativeCallsJNAImpl.java b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/NativeCallsJNAImpl.java index e4c08ebad..1cde78df1 100644 --- a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/NativeCallsJNAImpl.java +++ b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/NativeCallsJNAImpl.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/OSType.java b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/OSType.java index f79774f44..c97d9a06c 100644 --- a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/OSType.java +++ b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/OSType.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/POSIXNativeCalls.java b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/POSIXNativeCalls.java index c38bb4375..64fdeb137 100644 --- a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/POSIXNativeCalls.java +++ b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/POSIXNativeCalls.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/SolarisNativeCalls.java b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/SolarisNativeCalls.java index 81bd2eff3..85765f71c 100644 --- a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/SolarisNativeCalls.java +++ b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/SolarisNativeCalls.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/WinNativeCalls.java b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/WinNativeCalls.java index f9459e945..d2dde8759 100644 --- a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/WinNativeCalls.java +++ b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/jna/WinNativeCalls.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/unsafe/ChannelBufferUnsafeDataInputStream.java b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/unsafe/ChannelBufferUnsafeDataInputStream.java index 3bfaac04d..d3f9485dc 100644 --- a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/unsafe/ChannelBufferUnsafeDataInputStream.java +++ b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/unsafe/ChannelBufferUnsafeDataInputStream.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/unsafe/ChannelBufferUnsafeInputStream.java b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/unsafe/ChannelBufferUnsafeInputStream.java index b12d184a8..02c21253e 100644 --- a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/unsafe/ChannelBufferUnsafeInputStream.java +++ b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/unsafe/ChannelBufferUnsafeInputStream.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/unsafe/ChannelBufferUnsafeOutputStream.java b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/unsafe/ChannelBufferUnsafeOutputStream.java index 06a7f0379..3cfbab4ad 100644 --- a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/unsafe/ChannelBufferUnsafeOutputStream.java +++ b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/unsafe/ChannelBufferUnsafeOutputStream.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/unsafe/DirectBufferAllocator.java b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/unsafe/DirectBufferAllocator.java index 00e5766cb..ee3ecdcba 100644 --- a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/unsafe/DirectBufferAllocator.java +++ b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/unsafe/DirectBufferAllocator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -105,10 +105,10 @@ public ByteBuffer allocateForStorage(int size) { } @Override - public void clearPostAllocate(ByteBuffer buffer) { + public void clearPostAllocate(ByteBuffer buffer, int position) { // clear till the capacity and not limit since former will be a factor // of 8 and hence more efficient in Unsafe.setMemory - fill(buffer, (byte)0, 0, buffer.capacity()); + fill(buffer, (byte)0, position, buffer.capacity() - position); } @Override diff --git a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/unsafe/UnsafeHolder.java b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/unsafe/UnsafeHolder.java index 5942d85a7..c11b7db4b 100644 --- a/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/unsafe/UnsafeHolder.java +++ b/gemfire-shared/src/main/java/com/gemstone/gemfire/internal/shared/unsafe/UnsafeHolder.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -215,17 +215,17 @@ public static long getDirectBufferAddress(ByteBuffer buffer) { } public static ByteBuffer reallocateDirectBuffer(ByteBuffer buffer, - int newSize, Class expectedClass, FreeMemory.Factory factory) { + final int newLength, Class expectedClass, FreeMemory.Factory factory) { sun.nio.ch.DirectBuffer directBuffer = (sun.nio.ch.DirectBuffer)buffer; - final long address = directBuffer.address(); long newAddress = 0L; - newSize = getAllocationSize(newSize); + final int newSize = getAllocationSize(newLength); final sun.misc.Cleaner cleaner = directBuffer.cleaner(); if (cleaner != null) { // reset the runnable to not free the memory and clean it up try { Object freeMemory = Wrapper.cleanerRunnableField.get(cleaner); + long address; if (expectedClass != null && (freeMemory == null || !expectedClass.isInstance(freeMemory))) { throw new IllegalStateException("Expected class to be " + @@ -233,9 +233,10 @@ public static ByteBuffer reallocateDirectBuffer(ByteBuffer buffer, (freeMemory != null ? freeMemory.getClass().getName() : "null")); } // use the efficient realloc call if possible + // and clear address so that cleaner.clean() below does nothing if ((freeMemory instanceof FreeMemory) && - ((FreeMemory)freeMemory).tryFree() != 0L) { - newAddress = Wrapper.unsafe.reallocateMemory(address, newSize); + (address = ((FreeMemory)freeMemory).tryFree()) != 0L) { + newAddress = getUnsafe().reallocateMemory(address, newSize); } } catch (IllegalAccessException e) { // fallback to full copy @@ -247,16 +248,18 @@ public static ByteBuffer reallocateDirectBuffer(ByteBuffer buffer, expectedClass.getName() + " in reallocate but was non-runnable"); } newAddress = getUnsafe().allocateMemory(newSize); - Platform.copyMemory(null, address, null, newAddress, - Math.min(newSize, buffer.limit())); + Platform.copyMemory(null, directBuffer.address(), null, newAddress, + Math.min(newLength, buffer.limit())); } // clean only after copying is done if (cleaner != null) { cleaner.clean(); cleaner.clear(); } - return allocateDirectBuffer(newAddress, newSize, factory) + ByteBuffer newBuffer = allocateDirectBuffer(newAddress, newSize, factory) .order(buffer.order()); + newBuffer.limit(newLength); + return newBuffer; } /** diff --git a/gemfire-shared/src/main/java/io/snappydata/log4j/PatternLayout.java b/gemfire-shared/src/main/java/io/snappydata/log4j/PatternLayout.java index 0e54973c6..f26e71213 100644 --- a/gemfire-shared/src/main/java/io/snappydata/log4j/PatternLayout.java +++ b/gemfire-shared/src/main/java/io/snappydata/log4j/PatternLayout.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-shared/src/main/java/io/snappydata/log4j/ThreadIdAppender.java b/gemfire-shared/src/main/java/io/snappydata/log4j/ThreadIdAppender.java index 17cffd560..4c7ca96b3 100644 --- a/gemfire-shared/src/main/java/io/snappydata/log4j/ThreadIdAppender.java +++ b/gemfire-shared/src/main/java/io/snappydata/log4j/ThreadIdAppender.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfire-shared/src/main/resources/store-log4j.properties b/gemfire-shared/src/main/resources/store-log4j.properties index 4f0334ca4..fe0ef7083 100644 --- a/gemfire-shared/src/main/resources/store-log4j.properties +++ b/gemfire-shared/src/main/resources/store-log4j.properties @@ -1,4 +1,21 @@ # +# Copyright (c) 2018 SnappyData, Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you +# may not use this file except in compliance with the License. You +# may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. See accompanying +# LICENSE file. +# +# Some parts taken from Spark's log4j.properties having license below. +# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. @@ -26,6 +43,15 @@ log4j.appender.file.MaxBackupIndex=10000 log4j.appender.file.layout=io.snappydata.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss.SSS zzz} %t %p %c{1}: %m%n +# Appender for code dumps of WholeStageCodegenExec, CodeGenerator etc +log4j.appender.code=org.apache.log4j.RollingFileAppender +log4j.appender.code.append=true +log4j.appender.code.file=generatedcode.log +log4j.appender.code.MaxFileSize=1GB +log4j.appender.code.MaxBackupIndex=10000 +log4j.appender.code.layout=io.snappydata.log4j.PatternLayout +log4j.appender.code.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss.SSS zzz} %t %p %c{1}: %m%n + # Console appender log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.target=System.out @@ -75,8 +101,6 @@ log4j.logger.org.apache.spark.scheduler.FairSchedulableBuilder=WARN log4j.logger.org.apache.spark.scheduler.cluster.CoarseGrainedSchedulerBackend$DriverEndpoint=WARN log4j.logger.org.apache.spark.storage.BlockManagerInfo=WARN log4j.logger.org.apache.hadoop.hive=WARN -# for all Spark generated code (including ad-hoc UnsafeProjection calls etc) -log4j.logger.org.apache.spark.sql.catalyst.expressions.codegen.CodeGenerator=WARN log4j.logger.org.apache.spark.sql.execution.datasources=WARN log4j.logger.org.apache.spark.scheduler.SnappyTaskSchedulerImpl=WARN log4j.logger.org.apache.spark.MapOutputTrackerMasterEndpoint=WARN @@ -88,11 +112,12 @@ log4j.logger.parquet=ERROR log4j.logger.org.apache.hadoop.io.compress=WARN log4j.logger.spark.jobserver.LocalContextSupervisorActor=WARN log4j.logger.spark.jobserver.JarManager=WARN -log4j.logger.org.apache.spark.sql.hive.HiveClientUtil=WARN log4j.logger.org.datanucleus=ERROR # Task logger created in SparkEnv log4j.logger.org.apache.spark.Task=WARN log4j.logger.org.apache.spark.sql.catalyst.parser.CatalystSqlParser=WARN +# HiveExternalCatalog spits out a warning every time a non-hive table is persisted in meta-store +log4j.logger.org.apache.spark.sql.hive.SnappyHiveExternalCatalog=ERROR # Keep log-level of some classes as INFO even if root level is higher log4j.logger.io.snappydata.impl.LeadImpl=INFO @@ -100,7 +125,19 @@ log4j.logger.io.snappydata.impl.ServerImpl=INFO log4j.logger.io.snappydata.impl.LocatorImpl=INFO log4j.logger.spray.can.server.HttpListener=INFO +# Note: all code generation classes that dump using "code" logger should +# also be listed in ClientSharedUtils.initLog4j for removal in case top-level +# file has not been set (e.g. common for JDBC clients) else an empty +# generatedcode.log will be created. + # for generated code of plans -# log4j.logger.org.apache.spark.sql.execution.WholeStageCodegenExec=DEBUG +log4j.logger.org.apache.spark.sql.execution.WholeStageCodegenExec=INFO, code +log4j.additivity.org.apache.spark.sql.execution.WholeStageCodegenExec=false +log4j.logger.org.apache.spark.sql.execution.WholeStageCodegenRDD=INFO, code +log4j.additivity.org.apache.spark.sql.execution.WholeStageCodegenRDD=false +# for all Spark generated code (including ad-hoc UnsafeProjection calls etc) +log4j.logger.org.apache.spark.sql.catalyst.expressions.codegen.CodeGenerator=WARN, code +log4j.additivity.org.apache.spark.sql.catalyst.expressions.codegen.CodeGenerator=false # for SnappyData generated code used on store (ComplexTypeSerializer, JDBC inserts ...) -# log4j.logger.org.apache.spark.sql.store.CodeGeneration=DEBUG +log4j.logger.org.apache.spark.sql.store.CodeGeneration=INFO, code +log4j.additivity.org.apache.spark.sql.store.CodeGeneration=false diff --git a/gemfire-web/build.gradle b/gemfire-web/build.gradle deleted file mode 100644 index c2d9bdfac..000000000 --- a/gemfire-web/build.gradle +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you - * may not use this file except in compliance with the License. You - * may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. See accompanying - * LICENSE file. - */ - -apply plugin: 'war' - -dependencies { - compile "org.springframework:spring-aop:${springVersion}" - compile "org.springframework:spring-beans:${springVersion}" - compile "org.springframework:spring-context:${springVersion}" - compile "org.springframework:spring-context-support:${springVersion}" - compile "org.springframework:spring-core:${springVersion}" - compile "org.springframework:spring-expression:${springVersion}" - compile "org.springframework:spring-web:${springVersion}" - compile "org.springframework:spring-webmvc:${springVersion}" - - runtime "org.springframework:spring-aspects:${springVersion}" - runtime "org.springframework:spring-oxm:${springVersion}" - runtime 'commons-fileupload:commons-fileupload:1.3.2' - - testCompile "javax.servlet:javax.servlet-api:${servletAPIVersion}" - - // have to use output since we exclude the dependent classes from jar :( - testCompile project(subprojectBase + 'gemfire-core').sourceSets.main.output - testCompile project(subprojectBase + 'gemfire-core') - testCompile project(subprojectBase + 'gemfire-junit') -} - -war { - classpath configurations.runtime - classpath project(subprojectBase + 'gemfire-core').webJar.archivePath -} diff --git a/gemfire-web/src/main/webapp/WEB-INF/gemfire-servlet.xml b/gemfire-web/src/main/webapp/WEB-INF/gemfire-servlet.xml deleted file mode 100644 index b38d308c4..000000000 --- a/gemfire-web/src/main/webapp/WEB-INF/gemfire-servlet.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gemfire-web/src/main/webapp/WEB-INF/web.xml b/gemfire-web/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 6baadb534..000000000 --- a/gemfire-web/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - GemFire Management and Monitoring REST API - - - Web deployment descriptor declaring the REST API for GemFire. - - - - httpPutFilter - org.springframework.web.filter.HttpPutFormContentFilter - - - - httpPutFilter - /* - - - - gemfire - org.springframework.web.servlet.DispatcherServlet - true - 1 - - - - gemfire - /* - - - diff --git a/gemfire-web/src/test/java/com/gemstone/gemfire/management/internal/web/AbstractWebTestCase.java b/gemfire-web/src/test/java/com/gemstone/gemfire/management/internal/web/AbstractWebTestCase.java deleted file mode 100644 index 974a2cde0..000000000 --- a/gemfire-web/src/test/java/com/gemstone/gemfire/management/internal/web/AbstractWebTestCase.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you - * may not use this file except in compliance with the License. You - * may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. See accompanying - * LICENSE file. - */ -package com.gemstone.gemfire.management.internal.web; - -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URLDecoder; -import java.net.URLEncoder; - -import com.gemstone.gemfire.internal.lang.StringUtils; -import com.gemstone.gemfire.management.internal.web.domain.Link; - -/** - * The AbstractWebDomainTests class is abstract base class containing functionality common to a test suite classes - * in the com.gemstone.gemfire.management.internal.web.domain package. - *

- * @author John Blum - * @see java.net.URI - * @see java.net.URLDecoder - * @see java.net.URLEncoder - * @see com.gemstone.gemfire.management.internal.web.domain.Link - * @since 7.5 - */ -public abstract class AbstractWebTestCase { - - protected String decode(final String encodedValue) throws UnsupportedEncodingException { - return URLDecoder.decode(encodedValue, StringUtils.UTF_8); - } - - protected String encode(final String value) throws UnsupportedEncodingException { - return URLEncoder.encode(value, StringUtils.UTF_8); - } - - protected String toString(final Link... links) throws UnsupportedEncodingException { - final StringBuilder buffer = new StringBuilder("["); - int count = 0; - - for (final Link link : links) { - buffer.append(count++ > 0 ? ", " : StringUtils.EMPTY_STRING).append(toString(link)); - - } - - buffer.append("]"); - - return buffer.toString(); - } - - protected String toString(final Link link) throws UnsupportedEncodingException { - return link.toHttpRequestLine(); - } - - protected String toString(final URI uri) throws UnsupportedEncodingException { - return decode(uri.toString()); - } - - protected URI toUri(final String uriString) throws UnsupportedEncodingException, URISyntaxException { - return new URI(encode(uriString)); - } - -} diff --git a/gemfire-web/src/test/java/com/gemstone/gemfire/management/internal/web/domain/LinkIndexJUnitTest.java b/gemfire-web/src/test/java/com/gemstone/gemfire/management/internal/web/domain/LinkIndexJUnitTest.java deleted file mode 100644 index 79e8fad58..000000000 --- a/gemfire-web/src/test/java/com/gemstone/gemfire/management/internal/web/domain/LinkIndexJUnitTest.java +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you - * may not use this file except in compliance with the License. You - * may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. See accompanying - * LICENSE file. - */ -package com.gemstone.gemfire.management.internal.web.domain; - -import static org.junit.Assert.*; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.gemstone.gemfire.internal.util.CollectionUtils; -import com.gemstone.gemfire.management.internal.web.AbstractWebTestCase; -import com.gemstone.gemfire.management.internal.web.http.HttpMethod; - -import org.junit.Test; - -/** - * The LinkIndexJUnitTest class is a test suite of test cases testing the contract and functionality of the LinkIndex class. - *

- * @author John Blum - * @see java.net.URI - * @see com.gemstone.gemfire.management.internal.web.AbstractWebTestCase - * @see com.gemstone.gemfire.management.internal.web.domain.LinkIndex - * @see org.junit.Assert - * @see org.junit.Test - * @since 7.5 - */ -public class LinkIndexJUnitTest extends AbstractWebTestCase { - - @Test - public void testAdd() throws Exception { - final Link link = new Link("get-resource", toUri("http://host.domain.com:port/service/v1/resources/{id}")); - - final LinkIndex linkIndex = new LinkIndex(); - - assertTrue(linkIndex.isEmpty()); - assertEquals(0, linkIndex.size()); - assertEquals(linkIndex, linkIndex.add(link)); - assertFalse(linkIndex.isEmpty()); - assertEquals(1, linkIndex.size()); - assertEquals(linkIndex, linkIndex.add(link)); // test duplicate addition - assertFalse(linkIndex.isEmpty()); - assertEquals(1, linkIndex.size()); - } - - @Test(expected = AssertionError.class) - public void testAddNullLink() { - final LinkIndex linkIndex = new LinkIndex(); - - assertTrue(linkIndex.isEmpty()); - - try { - linkIndex.add(null); - } - finally { - assertTrue(linkIndex.isEmpty()); - } - } - - @Test - public void testAddAll() throws Exception { - final Link create = new Link("create-resource", toUri("http://host.domain.com:port/service/v1/resources"), HttpMethod.POST); - final Link retrieve = new Link("get-resource", toUri("http://host.domain.com:port/service/v1/resources/{id}")); - final Link update = new Link("update-resource", toUri("http://host.domain.com:port/service/v1/resources"), HttpMethod.PUT); - final Link delete = new Link("delete-resource", toUri("http://host.domain.com:port/service/v1/resources/{id}"), HttpMethod.DELETE); - - final LinkIndex linkIndex = new LinkIndex(); - - assertTrue(linkIndex.isEmpty()); - assertEquals(linkIndex, linkIndex.addAll(create, retrieve, update, delete)); - assertFalse(linkIndex.isEmpty()); - assertEquals(4, linkIndex.size()); - } - - @Test(expected = AssertionError.class) - public void testAddAllWithNullLinks() { - final LinkIndex linkIndex = new LinkIndex(); - - assertTrue(linkIndex.isEmpty()); - - try { - linkIndex.addAll((Iterable) null); - } - finally { - assertTrue(linkIndex.isEmpty()); - } - } - - @Test - public void testFind() throws Exception { - final Link list = new Link("get-resources", toUri("http://host.domain.com:port/service/v1/resources")); - final Link create = new Link("create-resource", toUri("http://host.domain.com:port/service/v1/resources"), HttpMethod.POST); - final Link retrieve = new Link("get-resource", toUri("http://host.domain.com:port/service/v1/resources/{id}")); - final Link update = new Link("update-resource", toUri("http://host.domain.com:port/service/v1/resources"), HttpMethod.PUT); - final Link delete = new Link("delete-resource", toUri("http://host.domain.com:port/service/v1/resources/{id}"), HttpMethod.DELETE); - - final LinkIndex linkIndex = new LinkIndex(); - - assertTrue(linkIndex.isEmpty()); - assertEquals(linkIndex, linkIndex.addAll(list, create, retrieve, update, delete)); - assertFalse(linkIndex.isEmpty()); - assertEquals(5, linkIndex.size()); - assertEquals(list, linkIndex.find("get-resources")); - assertEquals(retrieve, linkIndex.find("get-resource")); - assertEquals(update, linkIndex.find("UPDATE-RESOURCE")); - assertEquals(delete, linkIndex.find("Delete-Resource")); - assertNull(linkIndex.find("destroy-resource")); - assertNull(linkIndex.find("save-resource")); - } - - @Test - public void testFindAll() throws Exception { - final Link list = new Link("get-resources", toUri("http://host.domain.com:port/service/v1/resources")); - final Link create = new Link("create-resource", toUri("http://host.domain.com:port/service/v1/resources"), HttpMethod.POST); - final Link retrieveById = new Link("get-resource", toUri("http://host.domain.com:port/service/v1/resources/{id}")); - final Link retrieveByName = new Link("get-resource", toUri("http://host.domain.com:port/service/v1/resources/{name}")); - final Link update = new Link("update-resource", toUri("http://host.domain.com:port/service/v1/resources"), HttpMethod.PUT); - final Link delete = new Link("delete-resource", toUri("http://host.domain.com:port/service/v1/resources/{id}"), HttpMethod.DELETE); - - final LinkIndex linkIndex = new LinkIndex(); - - assertTrue(linkIndex.isEmpty()); - assertEquals(linkIndex, linkIndex.addAll(list, create, retrieveById, retrieveByName, update, delete)); - assertFalse(linkIndex.isEmpty()); - assertEquals(6, linkIndex.size()); - - final Link[] retrieveLinks = linkIndex.findAll("get-resource"); - - assertNotNull(retrieveLinks); - assertEquals(2, retrieveLinks.length); - assertTrue(Arrays.asList(retrieveLinks).containsAll(Arrays.asList(retrieveById, retrieveByName))); - - final Link[] saveLinks = linkIndex.findAll("save-resource"); - - assertNotNull(saveLinks); - assertEquals(0, saveLinks.length); - } - - @Test - public void testIterator() throws Exception { - final Link list = new Link("get-resources", toUri("http://host.domain.com:port/service/v1/resources")); - final Link create = new Link("create-resource", toUri("http://host.domain.com:port/service/v1/resources"), HttpMethod.POST); - final Link retrieveById = new Link("get-resource", toUri("http://host.domain.com:port/service/v1/resources/{id}")); - final Link retrieveByName = new Link("get-resource", toUri("http://host.domain.com:port/service/v1/resources/{name}")); - final Link update = new Link("update-resource", toUri("http://host.domain.com:port/service/v1/resources"), HttpMethod.PUT); - final Link delete = new Link("delete-resource", toUri("http://host.domain.com:port/service/v1/resources/{id}"), HttpMethod.DELETE); - - final LinkIndex linkIndex = new LinkIndex(); - - assertTrue(linkIndex.isEmpty()); - assertEquals(linkIndex, linkIndex.addAll(list, create, retrieveById, retrieveByName, update, delete)); - assertFalse(linkIndex.isEmpty()); - assertEquals(6, linkIndex.size()); - - final Collection expectedLinks = Arrays.asList(list, create, retrieveById, retrieveByName, update, delete); - - final Collection actualLinks = new ArrayList(linkIndex.size()); - - for (final Link link : linkIndex) { - actualLinks.add(link); - } - - assertTrue(actualLinks.containsAll(expectedLinks)); - } - - @Test - public void testToList() throws Exception { - final Link list = new Link("get-resources", toUri("http://host.domain.com:port/service/v1/resources")); - final Link create = new Link("create-resource", toUri("http://host.domain.com:port/service/v1/resources"), HttpMethod.POST); - final Link retrieveById = new Link("get-resource", toUri("http://host.domain.com:port/service/v1/resources/{id}")); - final Link retrieveByName = new Link("get-resource", toUri("http://host.domain.com:port/service/v1/resources/{name}")); - final Link update = new Link("update-resource", toUri("http://host.domain.com:port/service/v1/resources"), HttpMethod.PUT); - final Link delete = new Link("delete-resource", toUri("http://host.domain.com:port/service/v1/resources/{id}"), HttpMethod.DELETE); - - final LinkIndex linkIndex = new LinkIndex(); - - assertTrue(linkIndex.isEmpty()); - assertEquals(linkIndex, linkIndex.addAll(list, create, retrieveById, retrieveByName, update, delete)); - assertFalse(linkIndex.isEmpty()); - assertEquals(6, linkIndex.size()); - - final List expectedList = CollectionUtils.asList(list, create, retrieveById, retrieveByName, update, delete); - - Collections.sort(expectedList); - - assertEquals(expectedList, linkIndex.toList()); - } - - @Test - public void testToMap() throws Exception { - final Link list = new Link("get-resources", toUri("http://host.domain.com:port/service/v1/resources")); - final Link create = new Link("create-resource", toUri("http://host.domain.com:port/service/v1/resources"), HttpMethod.POST); - final Link retrieveById = new Link("get-resource", toUri("http://host.domain.com:port/service/v1/resources/{id}")); - final Link retrieveByName = new Link("get-resource", toUri("http://host.domain.com:port/service/v1/resources/{name}")); - final Link update = new Link("update-resource", toUri("http://host.domain.com:port/service/v1/resources"), HttpMethod.PUT); - final Link delete = new Link("delete-resource", toUri("http://host.domain.com:port/service/v1/resources/{id}"), HttpMethod.DELETE); - - final LinkIndex linkIndex = new LinkIndex(); - - assertTrue(linkIndex.isEmpty()); - assertEquals(linkIndex, linkIndex.addAll(list, create, retrieveById, retrieveByName, update, delete)); - assertFalse(linkIndex.isEmpty()); - assertEquals(6, linkIndex.size()); - - final Map> expectedMap = new HashMap>(5); - - expectedMap.put("get-resources", Arrays.asList(list)); - expectedMap.put("create-resource", Arrays.asList(create)); - expectedMap.put("get-resource", Arrays.asList(retrieveById, retrieveByName)); - expectedMap.put("update-resource", Arrays.asList(update)); - expectedMap.put("delete-resource", Arrays.asList(delete)); - - assertEquals(expectedMap, linkIndex.toMap()); - } - -} diff --git a/gemfire-web/src/test/java/com/gemstone/gemfire/management/internal/web/domain/LinkJUnitTest.java b/gemfire-web/src/test/java/com/gemstone/gemfire/management/internal/web/domain/LinkJUnitTest.java deleted file mode 100644 index b79ef5e8a..000000000 --- a/gemfire-web/src/test/java/com/gemstone/gemfire/management/internal/web/domain/LinkJUnitTest.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you - * may not use this file except in compliance with the License. You - * may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. See accompanying - * LICENSE file. - */ -package com.gemstone.gemfire.management.internal.web.domain; - -import static org.junit.Assert.*; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import com.gemstone.gemfire.internal.util.CollectionUtils; -import com.gemstone.gemfire.management.internal.web.AbstractWebTestCase; -import com.gemstone.gemfire.management.internal.web.http.HttpMethod; - -import org.junit.Test; - -/** - * The LinkJUnitTest class is a test suite of test cases testing the contract and functionality of the Link class. - *

- * @author John Blum - * @see java.net.URI - * @see com.gemstone.gemfire.management.internal.web.AbstractWebTestCase - * @see com.gemstone.gemfire.management.internal.web.domain.Link - * @see org.junit.Assert - * @see org.junit.Test - * @since 7.5 - */ -public class LinkJUnitTest extends AbstractWebTestCase { - - @Test - public void testConstructDefaultLink() { - final Link link = new Link(); - - assertNotNull(link); - assertNull(link.getHref()); - assertNull(link.getMethod()); - assertNull(link.getRelation()); - } - - @Test - public void testConstructLinkWithRelationAndHref() throws Exception { - final Link link = new Link("get-resource", toUri("http://host:port/service/v1/resources/{id}")); - - assertNotNull(link); - assertEquals("http://host:port/service/v1/resources/{id}", toString(link.getHref())); - assertEquals(HttpMethod.GET, link.getMethod()); - assertEquals("get-resource", link.getRelation()); - } - - @Test - public void testConstructLinkWithRelationHrefAndMethod() throws Exception { - final Link link = new Link("create-resource", toUri("http://host:port/service/v1/resources"), HttpMethod.POST); - - assertNotNull(link); - assertEquals("http://host:port/service/v1/resources", toString(link.getHref())); - assertEquals(HttpMethod.POST, link.getMethod()); - assertEquals("create-resource", link.getRelation()); - } - - @Test - public void testSetAndGetMethod() { - final Link link = new Link(); - - assertNotNull(link); - assertNull(link.getMethod()); - - link.setMethod(HttpMethod.POST); - - assertEquals(HttpMethod.POST, link.getMethod()); - - link.setMethod(null); - - assertEquals(HttpMethod.GET, link.getMethod()); - } - - @Test - public void testCompareTo() throws Exception { - final Link link0 = new Link("resources", toUri("http://host:port/service/v1/resources")); - final Link link1 = new Link("resource", toUri("http://host:port/service/v1/resources"), HttpMethod.POST); - final Link link2 = new Link("resource", toUri("http://host:port/service/v1/resources/{id}")); - final Link link3 = new Link("resource", toUri("http://host:port/service/v1/resources/{name}")); - final Link link4 = new Link("resource", toUri("http://host:port/service/v1/resources/{id}"), HttpMethod.DELETE); - - final List expectedList = new ArrayList(Arrays.asList(link1, link4, link2, link3, link0)); - - final List actualList = CollectionUtils.asList(link0, link1, link2, link3, link4); - - Collections.sort(actualList); - - System.out.println(toString(expectedList.toArray(new Link[expectedList.size()]))); - System.out.println(toString(actualList.toArray(new Link[actualList.size()]))); - - assertEquals(expectedList, actualList); - } - - @Test - public void testToHttpRequestLine() throws Exception { - final Link link = new Link("get-resource", toUri("http://host.domain.com:port/service/v1/resources/{id}")); - - assertNotNull(link); - assertEquals(HttpMethod.GET, link.getMethod()); - assertEquals("http://host.domain.com:port/service/v1/resources/{id}", toString(link.getHref())); - assertEquals("GET ".concat("http://host.domain.com:port/service/v1/resources/{id}"), link.toHttpRequestLine()); - } - -} diff --git a/gemfire-web/src/test/java/com/gemstone/gemfire/management/internal/web/domain/QueryParameterSourceJUnitTest.java b/gemfire-web/src/test/java/com/gemstone/gemfire/management/internal/web/domain/QueryParameterSourceJUnitTest.java deleted file mode 100644 index d0afc01b1..000000000 --- a/gemfire-web/src/test/java/com/gemstone/gemfire/management/internal/web/domain/QueryParameterSourceJUnitTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you - * may not use this file except in compliance with the License. You - * may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. See accompanying - * LICENSE file. - */ -package com.gemstone.gemfire.management.internal.web.domain; - -import static org.junit.Assert.*; - -import java.io.IOException; -import javax.management.MalformedObjectNameException; -import javax.management.ObjectName; -import javax.management.Query; -import javax.management.QueryExp; - -import com.gemstone.gemfire.internal.util.IOUtils; - -import org.junit.Test; - -/** - * The QueryParameterSourceJUnitTest class is a test suite of test cases testing the contract and functionality of the - * QueryParameterSource class. - *

- * @author John Blum - * @see com.gemstone.gemfire.management.internal.web.domain.QueryParameterSource - * @see org.junit.Assert - * @see org.junit.Test - * @since 7.5 - */ -public class QueryParameterSourceJUnitTest { - - @Test - public void testCreateQueryParameterSource() throws MalformedObjectNameException { - final ObjectName expectedObjectName = ObjectName.getInstance("GemFire:type=Member,*"); - - final QueryExp expectedQueryExpression = Query.eq(Query.attr("id"), Query.value("12345")); - - final QueryParameterSource query = new QueryParameterSource(expectedObjectName, expectedQueryExpression); - - assertNotNull(query); - assertSame(expectedObjectName, query.getObjectName()); - assertSame(expectedQueryExpression, query.getQueryExpression()); - } - - @Test - public void testSerialization() throws ClassNotFoundException, IOException, MalformedObjectNameException { - final ObjectName expectedObjectName = ObjectName.getInstance("GemFire:type=Member,*"); - - final QueryExp expectedQueryExpression = Query.or( - Query.eq(Query.attr("name"), Query.value("myName")), - Query.eq(Query.attr("id"), Query.value("myId")) - ); - - final QueryParameterSource expectedQuery = new QueryParameterSource(expectedObjectName, expectedQueryExpression); - - assertNotNull(expectedQuery); - assertSame(expectedObjectName, expectedQuery.getObjectName()); - assertSame(expectedQueryExpression, expectedQuery.getQueryExpression()); - - final byte[] queryBytes = IOUtils.serializeObject(expectedQuery); - - assertNotNull(queryBytes); - assertTrue(queryBytes.length != 0); - - final Object queryObj = IOUtils.deserializeObject(queryBytes); - - assertTrue(queryObj instanceof QueryParameterSource); - - final QueryParameterSource actualQuery = (QueryParameterSource) queryObj; - - assertNotSame(expectedQuery, actualQuery); - assertNotNull(actualQuery.getObjectName()); - assertEquals(expectedQuery.getObjectName().toString(), actualQuery.getObjectName().toString()); - assertNotNull(actualQuery.getQueryExpression()); - assertEquals(expectedQuery.getQueryExpression().toString(), actualQuery.getQueryExpression().toString()); - } - -} diff --git a/gemfire-web/src/test/java/com/gemstone/gemfire/management/internal/web/http/ClientHttpRequestJUnitTest.java b/gemfire-web/src/test/java/com/gemstone/gemfire/management/internal/web/http/ClientHttpRequestJUnitTest.java deleted file mode 100644 index 9b4f965a9..000000000 --- a/gemfire-web/src/test/java/com/gemstone/gemfire/management/internal/web/http/ClientHttpRequestJUnitTest.java +++ /dev/null @@ -1,491 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you - * may not use this file except in compliance with the License. You - * may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. See accompanying - * LICENSE file. - */ -package com.gemstone.gemfire.management.internal.web.http; - -import static org.junit.Assert.*; - -import java.net.URI; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.gemstone.gemfire.management.internal.web.AbstractWebTestCase; -import com.gemstone.gemfire.management.internal.web.domain.Link; - -import org.jmock.Mockery; -import org.jmock.lib.legacy.ClassImposteriser; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.springframework.http.HttpEntity; -import org.springframework.http.MediaType; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; - -/** - * The ClientHttpRequestJUnitTest class is a test suite of test cases testing the contract and functionality of the - * ClientHttpRequest class. - *

- * @author John Blum - * @see com.gemstone.gemfire.management.internal.web.AbstractWebTestCase - * @see com.gemstone.gemfire.management.internal.web.http.ClientHttpRequest - * @see org.jmock.Mockery - * @see org.junit.Assert - * @see org.junit.Test - * @since 7.5 - */ -public class ClientHttpRequestJUnitTest extends AbstractWebTestCase { - - private Mockery mockContext; - - @Before - public void setUp() { - mockContext = new Mockery(); - mockContext.setImposteriser(ClassImposteriser.INSTANCE); - } - - @After - public void tearDown() { - mockContext.assertIsSatisfied(); - mockContext = null; - } - - @Test - public void testCreateClientHttpRequest() throws Exception { - final Link expectedLink = new Link("test", toUri("http://host.domain.com:8080/app/service")); - final ClientHttpRequest request = new ClientHttpRequest(expectedLink); - - assertNotNull(request); - assertEquals(expectedLink, request.getLink()); - } - - @Test(expected = AssertionError.class) - public void testCreateClientHttpRequestWithNullLink() { - new ClientHttpRequest(null); - } - - @Test - public void testGetMethod() throws Exception { - Link link = new Link("get-resource", toUri("http://host.domain.com:8080/app/resources/{id}")); - ClientHttpRequest request = new ClientHttpRequest(link); - - assertEquals(link, request.getLink()); - assertEquals(org.springframework.http.HttpMethod.GET, request.getMethod()); - - link = new Link("delete-resource", toUri("http://host.domain.com:8080/app/resources/{id}"), HttpMethod.DELETE); - request = new ClientHttpRequest(link); - - assertEquals(link, request.getLink()); - assertEquals(org.springframework.http.HttpMethod.DELETE, request.getMethod()); - - link = new Link("delete-resource", toUri("http://host.domain.com:8080/app/service"), HttpMethod.HEAD); - request = new ClientHttpRequest(link); - - assertEquals(link, request.getLink()); - assertEquals(org.springframework.http.HttpMethod.HEAD, request.getMethod()); - - link = new Link("delete-resource", toUri("http://host.domain.com:8080/app/service"), HttpMethod.OPTIONS); - request = new ClientHttpRequest(link); - - assertEquals(link, request.getLink()); - assertEquals(org.springframework.http.HttpMethod.OPTIONS, request.getMethod()); - - link = new Link("delete-resource", toUri("http://host.domain.com:8080/app/resources"), HttpMethod.POST); - request = new ClientHttpRequest(link); - - assertEquals(link, request.getLink()); - assertEquals(org.springframework.http.HttpMethod.POST, request.getMethod()); - - link = new Link("delete-resource", toUri("http://host.domain.com:8080/app/resources"), HttpMethod.PUT); - request = new ClientHttpRequest(link); - - assertEquals(link, request.getLink()); - assertEquals(org.springframework.http.HttpMethod.PUT, request.getMethod()); - - link = new Link("delete-resource", toUri("http://host.domain.com:8080/app"), HttpMethod.TRACE); - request = new ClientHttpRequest(link); - - assertEquals(link, request.getLink()); - assertEquals(org.springframework.http.HttpMethod.TRACE, request.getMethod()); - } - - @Test - public void testIsDelete() throws Exception { - final Link expectedLink = new Link("delete", toUri("http://host.domain.com:8080/app/resources/{id}"), HttpMethod.DELETE); - final ClientHttpRequest request = new ClientHttpRequest(expectedLink); - - assertEquals(expectedLink, request.getLink()); - assertTrue(request.isDelete()); - assertFalse(request.isGet()); - assertFalse(request.isPost()); - assertFalse(request.isPut()); - } - - @Test - public void testIsGet() throws Exception { - final Link expectedLink = new Link("get", toUri("http://host.domain.com:8080/app/resources/{id}"), HttpMethod.GET); - final ClientHttpRequest request = new ClientHttpRequest(expectedLink); - - assertEquals(expectedLink, request.getLink()); - assertFalse(request.isDelete()); - assertTrue(request.isGet()); - assertFalse(request.isPost()); - assertFalse(request.isPut()); - } - - @Test - public void testIsPost() throws Exception { - final Link expectedLink = new Link("post", toUri("http://host.domain.com:8080/app/resources"), HttpMethod.POST); - final ClientHttpRequest request = new ClientHttpRequest(expectedLink); - - assertEquals(expectedLink, request.getLink()); - assertFalse(request.isDelete()); - assertFalse(request.isGet()); - assertTrue(request.isPost()); - assertFalse(request.isPut()); - } - - @Test - public void testIsPut() throws Exception { - final Link expectedLink = new Link("put", toUri("http://host.domain.com:8080/app/resources/{id}"), HttpMethod.PUT); - final ClientHttpRequest request = new ClientHttpRequest(expectedLink); - - assertEquals(expectedLink, request.getLink()); - assertFalse(request.isDelete()); - assertFalse(request.isGet()); - assertFalse(request.isPost()); - assertTrue(request.isPut()); - } - - @Test - public void testGetPathVariables() throws Exception { - final Link expectedLink = new Link("test", toUri("http://host.domain.com:8080/app/libraries/{name}/books/{author}/{title}")); - final ClientHttpRequest request = new ClientHttpRequest(expectedLink); - - assertEquals(expectedLink, request.getLink()); - assertEquals(Arrays.asList("name", "author", "title"), request.getPathVariables()); - } - - @Test - public void testGetPathVariablesWithUriHavingNoPathVariables() throws Exception { - final Link expectedLink = new Link("test", toUri("http://host.domain.com:8080/app/service")); - final ClientHttpRequest request = new ClientHttpRequest(expectedLink); - - assertEquals(expectedLink, request.getLink()); - - final List actualPathVariables = request.getPathVariables(); - - assertNotNull(actualPathVariables); - assertTrue(actualPathVariables.isEmpty()); - } - - @Test - public void testGetURI() throws Exception { - final URI expectedURI = toUri("http://host.domain.com:8080/app/service"); - final Link expectedLink = new Link("test", expectedURI); - final ClientHttpRequest request = new ClientHttpRequest(expectedLink); - - assertEquals(expectedLink, request.getLink()); - assertEquals(expectedURI, request.getURI()); - } - - @Test - public void testGetURLForGet() throws Exception { - final Link expectedLink = new Link("find", toUri("http://host.domain.com:8080/app/libraries/{name}/books"), HttpMethod.GET); - final ClientHttpRequest request = new ClientHttpRequest(expectedLink); - - request.addRequestParameterValues("author", "Rowling"); - request.addRequestParameterValues("category", "science-fiction"); - - assertEquals(expectedLink, request.getLink()); - assertEquals("http://host.domain.com:8080/app/libraries/amazon/books?author=Rowling&category=science-fiction", - toString(request.getURL(Collections.singletonMap("name", "amazon")))); - } - - @Test - public void testGetURLForComplexGet() throws Exception { - final Link expectedLink = new Link("find", toUri("http://host.domain.com:8080/app/libraries/{name}/books/{author}"), HttpMethod.GET); - final ClientHttpRequest request = new ClientHttpRequest(expectedLink); - - request.addRequestParameterValues("author", "Rowling"); - request.addRequestParameterValues("category", "science-fiction"); - request.addRequestParameterValues("name", "Boston"); - request.addRequestParameterValues("year", "2007"); - - final Map uriVariables = new HashMap(4); - - uriVariables.put("author", "Rowling"); - uriVariables.put("category", "mystery"); - uriVariables.put("isbn", "0-123456789"); - uriVariables.put("name", "Amazon"); - - assertEquals(expectedLink, request.getLink()); - assertEquals("http://host.domain.com:8080/app/libraries/Amazon/books/Rowling?category=science-fiction&year=2007", - toString(request.getURL(uriVariables))); - } - - @Test - public void testGetURLForDelete() throws Exception { - final Link expectedLink = new Link("delete-all", toUri("http://host.domain.com:8080/app/libraries/{name}/books"), HttpMethod.DELETE); - final ClientHttpRequest request = new ClientHttpRequest(expectedLink); - - request.addRequestParameterValues("category", "romance"); - - assertEquals(expectedLink, request.getLink()); - assertEquals("http://host.domain.com:8080/app/libraries/congress/books?category=romance", - toString(request.getURL(Collections.singletonMap("name", "congress")))); - } - - @Test - public void testGetURLForPost() throws Exception { - final Link expectedLink = new Link("post", toUri("http://host.domain.com:8080/app/libraries/{name}/books"), HttpMethod.POST); - final ClientHttpRequest request = new ClientHttpRequest(expectedLink); - - request.addRequestParameterValues("author", "Douglas Adams"); - request.addRequestParameterValues("title", "The Hitchhiker's Guide to the Galaxy"); - request.addRequestParameterValues("year", "1979"); - request.addRequestParameterValues("isbn", "0345453743"); - - assertEquals(expectedLink, request.getLink()); - assertEquals("http://host.domain.com:8080/app/libraries/royal/books", - toString(request.getURL(Collections.singletonMap("name", "royal")))); - } - - @Test - public void testGetURLForPut() throws Exception { - final Link expectedLink = new Link("put", toUri("http://host.domain.com:8080/app/libraries/{name}/books/{isbn}"), HttpMethod.PUT); - final ClientHttpRequest request = new ClientHttpRequest(expectedLink); - - request.addRequestParameterValues("year", "1983"); - - final Map uriVariables = new HashMap(2); - - uriVariables.put("name", "royal"); - uriVariables.put("isbn", "0345453743"); - - assertEquals(expectedLink, request.getLink()); - assertEquals("http://host.domain.com:8080/app/libraries/royal/books/0345453743", - toString(request.getURL(uriVariables))); - } - - @Test - public void testCreateRequestEntityForGet() throws Exception { - final Link expectedLink = new Link("find", toUri("http://host.domain.com:8080/app/libraries/{name}/books"), HttpMethod.GET); - final ClientHttpRequest request = new ClientHttpRequest(expectedLink); - - assertEquals(expectedLink, request.getLink()); - - request.addHeaderValues(HttpHeader.CONTENT_TYPE.getName(), MediaType.TEXT_PLAIN_VALUE); - request.addRequestParameterValues("author", "Rowling"); - request.addRequestParameterValues("category", "science-fiction"); - - final HttpEntity requestEntity = request.createRequestEntity(); - - assertNotNull(requestEntity); - assertNotNull(requestEntity.getHeaders()); - assertEquals(MediaType.TEXT_PLAIN, requestEntity.getHeaders().getContentType()); - assertNull(requestEntity.getBody()); - } - - @Test - public void testCreateRequestEntityForDelete() throws Exception { - final Link expectedLink = new Link("delete-all", toUri("http://host.domain.com:8080/app/libraries/{name}/books"), HttpMethod.DELETE); - final ClientHttpRequest request = new ClientHttpRequest(expectedLink); - - assertEquals(expectedLink, request.getLink()); - - request.addHeaderValues(HttpHeader.ACCEPT.getName(), MediaType.APPLICATION_JSON_VALUE); - request.addRequestParameterValues("category", "romance"); - - final HttpEntity requestEntity = request.createRequestEntity(); - - assertNotNull(requestEntity); - assertNotNull(requestEntity.getHeaders()); - assertEquals(Collections.singletonList(MediaType.APPLICATION_JSON), requestEntity.getHeaders().getAccept()); - assertNull(requestEntity.getBody()); - } - - @Test - @SuppressWarnings("unchecked") - public void testCreateRequestEntityForPost() throws Exception { - final Link expectedLink = new Link("post", toUri("http://host.domain.com:8080/app/libraries/{name}/books"), HttpMethod.POST); - final ClientHttpRequest request = new ClientHttpRequest(expectedLink); - - assertEquals(expectedLink, request.getLink()); - - final MultiValueMap expectedRequestParameters = new LinkedMultiValueMap(4); - - expectedRequestParameters.add("author", "Douglas Adams"); - expectedRequestParameters.add("title", "The Hitchhiker's Guide to the Galaxy"); - expectedRequestParameters.add("year", "1979"); - expectedRequestParameters.add("isbn", "0345453743"); - - request.addHeaderValues(HttpHeader.CONTENT_TYPE.getName(), MediaType.APPLICATION_FORM_URLENCODED_VALUE); - request.addRequestParameterValues("author", expectedRequestParameters.getFirst("author")); - request.addRequestParameterValues("title", expectedRequestParameters.getFirst("title")); - request.addRequestParameterValues("year", expectedRequestParameters.getFirst("year")); - request.addRequestParameterValues("isbn", expectedRequestParameters.getFirst("isbn")); - - final HttpEntity> requestEntity = (HttpEntity>) - request.createRequestEntity(); - - assertNotNull(requestEntity); - assertNotNull(requestEntity.getHeaders()); - assertEquals(MediaType.APPLICATION_FORM_URLENCODED, requestEntity.getHeaders().getContentType()); - assertEquals(expectedRequestParameters, requestEntity.getBody()); - } - - @Test - @SuppressWarnings("unchecked") - public void testCreateRequestEntityForPut() throws Exception { - final Link expectedLink = new Link("put", toUri("http://host.domain.com:8080/app/libraries/{name}/books/{isbn}"), HttpMethod.PUT); - final ClientHttpRequest request = new ClientHttpRequest(expectedLink); - - assertEquals(expectedLink, request.getLink()); - - final MultiValueMap expectedRequestParameters = new LinkedMultiValueMap(4); - - expectedRequestParameters.add("year", "1979"); - - request.addHeaderValues(HttpHeader.ACCEPT.getName(), MediaType.TEXT_XML_VALUE); - request.addHeaderValues(HttpHeader.CONTENT_TYPE.getName(), MediaType.APPLICATION_FORM_URLENCODED_VALUE); - request.addRequestParameterValues("year", expectedRequestParameters.getFirst("year")); - - final HttpEntity> requestEntity = (HttpEntity>) - request.createRequestEntity(); - - assertNotNull(requestEntity); - assertNotNull(requestEntity.getHeaders()); - assertEquals(Collections.singletonList(MediaType.TEXT_XML), requestEntity.getHeaders().getAccept()); - assertEquals(MediaType.APPLICATION_FORM_URLENCODED, requestEntity.getHeaders().getContentType()); - assertEquals(expectedRequestParameters, requestEntity.getBody()); - } - - @Test - public void testCreateRequestEntityOnPost() throws Exception { - final Library mockLibrary = mockContext.mock(Library.class, "testCreateRequestEntityOnPost.Library"); - final Link expectedLink = new Link("post", toUri("http://host.domain.com:8080/app/libraries"), HttpMethod.POST); - - final ClientHttpRequest request = new ClientHttpRequest(expectedLink); - - assertEquals(expectedLink, request.getLink()); - assertTrue(request.isPost()); - assertNull(request.getContent()); - - request.setContent(mockLibrary); - - assertSame(mockLibrary, request.getContent()); - - final HttpEntity requestEntity = request.createRequestEntity(); - - assertNotNull(requestEntity); - assertTrue(requestEntity.getBody() instanceof Library); - } - - @Test - public void testCreateRequestEntityOnPut() throws Exception { - final Book mockBook = mockContext.mock(Book.class, "testCreateRequestEntityOnPut.Book"); - final Link expectedLink = new Link("put", toUri("http://host.domain.com:8080/app/libraries/{name}/books/{id}"), HttpMethod.PUT); - - final ClientHttpRequest request = new ClientHttpRequest(expectedLink); - - assertEquals(expectedLink, request.getLink()); - assertTrue(request.isPut()); - assertNull(request.getContent()); - - request.setContent(mockBook); - request.addRequestParameterValues("isbn", "0-123456789"); - request.addRequestParameterValues("category", "science-fiction", "sci-fi", "fiction"); - - assertSame(mockBook, request.getContent()); - assertEquals("0-123456789", request.getRequestParameterValue("isbn")); - assertTrue(request.getRequestParameterValues("category").containsAll(Arrays.asList("science-fiction", "sci-fi", "fiction"))); - - final HttpEntity requestEntity = request.createRequestEntity(); - - assertNotNull(requestEntity); - assertTrue(requestEntity.getBody() instanceof MultiValueMap); - assertEquals(MediaType.APPLICATION_FORM_URLENCODED, requestEntity.getHeaders().getContentType()); - } - - @Test - public void testSetAndGetHeaderValues() throws Exception { - final Link expectedLink = new Link("put", toUri("http://host.domain.com:8080/app/libraries"), HttpMethod.PUT); - final ClientHttpRequest request = new ClientHttpRequest(expectedLink); - - assertEquals(expectedLink, request.getLink()); - assertTrue(request.getHeaders().isEmpty()); - - request.addHeaderValues(HttpHeader.CONTENT_TYPE.getName(), MediaType.APPLICATION_JSON_VALUE); - request.addHeaderValues(HttpHeader.ACCEPT.getName(), MediaType.APPLICATION_JSON_VALUE, - MediaType.APPLICATION_XML_VALUE, MediaType.TEXT_PLAIN_VALUE); - - assertEquals(MediaType.APPLICATION_JSON_VALUE, request.getHeaderValue(HttpHeader.CONTENT_TYPE.getName())); - assertEquals(1, request.getHeaderValues(HttpHeader.CONTENT_TYPE.getName()).size()); - assertEquals(MediaType.APPLICATION_JSON_VALUE, request.getHeaderValue(HttpHeader.ACCEPT.getName())); - assertEquals(3, request.getHeaderValues(HttpHeader.ACCEPT.getName()).size()); - assertTrue(request.getHeaderValues(HttpHeader.ACCEPT.getName()).containsAll(Arrays.asList( - MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE, MediaType.TEXT_PLAIN_VALUE))); - - request.setHeader(HttpHeader.ACCEPT.getName(), MediaType.APPLICATION_OCTET_STREAM_VALUE); - - assertEquals(MediaType.APPLICATION_OCTET_STREAM_VALUE, request.getHeaderValue(HttpHeader.ACCEPT.getName())); - assertEquals(1, request.getHeaderValues(HttpHeader.ACCEPT.getName()).size()); - assertTrue(request.getHeaderValues(HttpHeader.ACCEPT.getName()).containsAll(Arrays.asList( - MediaType.APPLICATION_OCTET_STREAM_VALUE))); - } - - @Test - public void testSetAndGetRequestParameterValues() throws Exception { - final Link expectedLink = new Link("put", toUri("http://host.domain.com:8080/app/libraries"), HttpMethod.PUT); - final ClientHttpRequest request = new ClientHttpRequest(expectedLink); - - assertEquals(expectedLink, request.getLink()); - assertTrue(request.getParameters().isEmpty()); - - request.addRequestParameterValues("parameterOne", "value"); - request.addRequestParameterValues("parameterTwo", "test", "testing", "tested"); - - assertEquals("value", request.getRequestParameterValue("parameterOne")); - assertEquals(1, request.getRequestParameterValues("parameterOne").size()); - assertEquals("test", request.getRequestParameterValue("parameterTwo")); - assertEquals(3, request.getRequestParameterValues("parameterTwo").size()); - assertTrue(request.getRequestParameterValues("parameterTwo").containsAll(Arrays.asList("test", "testing", "tested"))); - - request.setRequestParameter("parameterTwo", "development"); - - assertEquals("development", request.getRequestParameterValue("parameterTwo")); - assertEquals(1, request.getRequestParameterValues("parameterTwo").size()); - assertTrue(request.getRequestParameterValues("parameterTwo").containsAll(Arrays.asList("development"))); - } - - @SuppressWarnings("unused") - protected static interface Library { - public String getName(); - } - - @SuppressWarnings("unused") - protected static interface Book { - public String getAuthor(); - public String getIsbn(); - public String getTitle(); - public Integer getYear(); - } - -} diff --git a/gemfire-web/src/test/java/com/gemstone/gemfire/management/internal/web/http/converter/SerializableObjectHttpMessageConverterJUnitTest.java b/gemfire-web/src/test/java/com/gemstone/gemfire/management/internal/web/http/converter/SerializableObjectHttpMessageConverterJUnitTest.java deleted file mode 100644 index f4f8fead7..000000000 --- a/gemfire-web/src/test/java/com/gemstone/gemfire/management/internal/web/http/converter/SerializableObjectHttpMessageConverterJUnitTest.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you - * may not use this file except in compliance with the License. You - * may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. See accompanying - * LICENSE file. - */ -package com.gemstone.gemfire.management.internal.web.http.converter; - -import static org.junit.Assert.*; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.Serializable; -import java.util.Calendar; - -import com.gemstone.gemfire.internal.util.IOUtils; - -import org.jmock.Expectations; -import org.jmock.Mockery; -import org.jmock.lib.legacy.ClassImposteriser; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpInputMessage; -import org.springframework.http.HttpOutputMessage; -import org.springframework.http.MediaType; - -/** - * The SerializableObjectHttpMessageConverterTest class is a test suite of test cases testing the contract - * and functionality of the SerializableObjectHttpMessageConverter class. - *

- * @author John Blum - * @see com.gemstone.gemfire.management.internal.web.http.converter.SerializableObjectHttpMessageConverter - * @see org.jmock.Mockery - * @see org.junit.Assert - * @see org.junit.Test - * @since 7.5 - */ -public class SerializableObjectHttpMessageConverterJUnitTest { - - private Mockery mockContext; - - @Before - public void setUp() { - mockContext = new Mockery(); - mockContext.setImposteriser(ClassImposteriser.INSTANCE); - } - - @After - public void tearDown() { - mockContext.assertIsSatisfied(); - mockContext = null; - } - - @Test - public void testCreateSerializableObjectHttpMessageConverter() { - final SerializableObjectHttpMessageConverter converter = new SerializableObjectHttpMessageConverter(); - - assertNotNull(converter); - assertTrue(converter.getSupportedMediaTypes().contains(MediaType.APPLICATION_OCTET_STREAM)); - assertTrue(converter.getSupportedMediaTypes().contains(MediaType.ALL)); - } - - @Test - public void testSupport() { - final SerializableObjectHttpMessageConverter converter = new SerializableObjectHttpMessageConverter(); - - assertTrue(converter.supports(Boolean.class)); - assertTrue(converter.supports(Calendar.class)); - assertTrue(converter.supports(Character.class)); - assertTrue(converter.supports(Integer.class)); - assertTrue(converter.supports(Double.class)); - assertTrue(converter.supports(String.class)); - assertTrue(converter.supports(Serializable.class)); - assertFalse(converter.supports(Object.class)); - assertFalse(converter.supports(null)); - } - - @Test - public void testReadInternal() throws IOException { - final String expectedInputMessageBody = "Expected content of the HTTP input message body!"; - - final HttpInputMessage mockInputMessage = mockContext.mock(HttpInputMessage.class, "HttpInputMessage"); - - mockContext.checking(new Expectations() {{ - oneOf(mockInputMessage).getBody(); - will(returnValue(new ByteArrayInputStream(IOUtils.serializeObject(expectedInputMessageBody)))); - }}); - - final SerializableObjectHttpMessageConverter converter = new SerializableObjectHttpMessageConverter(); - - final Serializable obj = converter.readInternal(String.class, mockInputMessage); - - assertTrue(obj instanceof String); - assertEquals(expectedInputMessageBody, obj); - } - - @Test - public void testSetContentLength() { - final byte[] bytes = { (byte) 0xCA, (byte) 0xFE, (byte) 0xBA, (byte) 0xBE }; - - final HttpHeaders headers = new HttpHeaders(); - - final HttpOutputMessage mockOutputMessage = mockContext.mock(HttpOutputMessage.class, "HttpOutputMessage"); - - mockContext.checking(new Expectations() {{ - oneOf(mockOutputMessage).getHeaders(); - will(returnValue(headers)); - }}); - - final SerializableObjectHttpMessageConverter converter = new SerializableObjectHttpMessageConverter(); - - converter.setContentLength(mockOutputMessage, bytes); - - assertEquals(bytes.length, headers.getContentLength()); - } - - @Test - public void testWriteInternal() throws IOException { - final String expectedOutputMessageBody = "Expected media of the HTTP output message body!"; - - final byte[] expectedOutputMessageBodyBytes = IOUtils.serializeObject(expectedOutputMessageBody); - - final ByteArrayOutputStream out = new ByteArrayOutputStream(expectedOutputMessageBodyBytes.length); - - final HttpHeaders headers = new HttpHeaders(); - - final HttpOutputMessage mockOutputMessage = mockContext.mock(HttpOutputMessage.class, "HttpOutputMessage"); - - mockContext.checking(new Expectations() {{ - oneOf(mockOutputMessage).getHeaders(); - will(returnValue(headers)); - oneOf(mockOutputMessage).getBody(); - will(returnValue(out)); - }}); - - final SerializableObjectHttpMessageConverter converter = new SerializableObjectHttpMessageConverter(); - - converter.writeInternal(expectedOutputMessageBody, mockOutputMessage); - - final byte[] actualOutputMessageBodyBytes = out.toByteArray(); - - assertEquals(expectedOutputMessageBodyBytes.length, headers.getContentLength()); - assertEquals(expectedOutputMessageBodyBytes.length, actualOutputMessageBodyBytes.length); - - for (int index = 0; index < actualOutputMessageBodyBytes.length; index++) { - assertEquals(expectedOutputMessageBodyBytes[index], actualOutputMessageBodyBytes[index]); - } - } - -} diff --git a/gemfire-web/src/test/java/com/gemstone/gemfire/management/internal/web/shell/RestHttpOperationInvokerJUnitTest.java b/gemfire-web/src/test/java/com/gemstone/gemfire/management/internal/web/shell/RestHttpOperationInvokerJUnitTest.java deleted file mode 100644 index ee6eb031f..000000000 --- a/gemfire-web/src/test/java/com/gemstone/gemfire/management/internal/web/shell/RestHttpOperationInvokerJUnitTest.java +++ /dev/null @@ -1,407 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you - * may not use this file except in compliance with the License. You - * may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. See accompanying - * LICENSE file. - */ -package com.gemstone.gemfire.management.internal.web.shell; - -import static org.junit.Assert.*; - -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -import com.gemstone.gemfire.internal.lang.StringUtils; -import com.gemstone.gemfire.management.internal.cli.CommandRequest; -import com.gemstone.gemfire.management.internal.web.AbstractWebTestCase; -import com.gemstone.gemfire.management.internal.web.http.ClientHttpRequest; -import com.gemstone.gemfire.management.internal.web.http.HttpMethod; -import com.gemstone.gemfire.management.internal.web.domain.Link; -import com.gemstone.gemfire.management.internal.web.domain.LinkIndex; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.springframework.core.io.Resource; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.client.ResourceAccessException; - -/** - * The RestHttpOperationInvokerJUnitTest class is a test suite of test cases testing the contract and functionality of the - * RestHttpOperationInvoker class. - *

- * @author John Blum - * @see java.net.URI - * @see com.gemstone.gemfire.management.internal.cli.CommandRequest - * @see com.gemstone.gemfire.management.internal.web.http.HttpMethod - * @see com.gemstone.gemfire.management.internal.web.domain.Link - * @see com.gemstone.gemfire.management.internal.web.domain.LinkIndex - * @see com.gemstone.gemfire.management.internal.web.shell.RestHttpOperationInvoker - * @see org.junit.Assert - * @see org.junit.Test - * @since 7.5 - */ -@SuppressWarnings("unused") -public class RestHttpOperationInvokerJUnitTest extends AbstractWebTestCase { - - private LinkIndex linkIndex; - - private RestHttpOperationInvoker operationInvoker; - - @Before - public void setUp() throws Exception { - final Link listLibraries = new Link("list-libraries", toUri("http://host.domain.com/service/v1/libraries")); - final Link getLibrary = new Link("get-library", toUri("http://host.domain.com/service/v1/libraries/{name}")); - final Link listBooks = new Link("list-books", toUri("http://host.domain.com/service/v1/libraries/{name}/books")); - final Link listBooksByAuthor = new Link("list-books", toUri("http://host.domain.com/service/v1/libraries/{name}/books/{author}")); - final Link listBooksByAuthorAndCategory = new Link("list-books", toUri("http://host.domain.com/service/v1/libraries/{name}/books/{author}/{category}")); - final Link listBooksByAuthorAndYear = new Link("list-books", toUri("http://host.domain.com/service/v1/libraries/{name}/books/{author}/{year}")); - final Link listBooksByAuthorCategoryAndYear = new Link("list-books", toUri("http://host.domain.com/service/v1/libraries/{name}/books/{author}/{category}/{year}")); - final Link addBook = new Link("add-book", toUri("http://host.domain.com/service/v1/libraries/{name}/books"), HttpMethod.POST); - final Link getBookByIsbn = new Link("get-book", toUri("http://host.domain.com/service/v1/libraries/{name}/books/{isbn}")); - final Link getBookByTitle = new Link("get-book", toUri("http://host.domain.com/service/v1/libraries/{name}/books/{title}")); - final Link removeBook = new Link("remove-book", toUri("http://host.domain.com/service/v1/libraries/{name}/books/{isbn}"), HttpMethod.DELETE); - - linkIndex = new LinkIndex(); - linkIndex.addAll(listLibraries, getLibrary, listBooks, listBooksByAuthor, listBooksByAuthorAndCategory, - listBooksByAuthorAndYear, listBooksByAuthorCategoryAndYear, addBook, getBookByIsbn, getBookByTitle, removeBook); - - assertFalse(linkIndex.isEmpty()); - assertEquals(11, linkIndex.size()); - - operationInvoker = new RestHttpOperationInvoker(linkIndex); - - assertSame(linkIndex, operationInvoker.getLinkIndex()); - } - - @After - public void tearDown() { - operationInvoker.stop(); - operationInvoker = null; - } - - protected CommandRequest createCommandRequest(final String command, final Map options) { - return new TestCommandRequest(command, options); - } - - protected CommandRequest createCommandRequest(final String command, final Map options, final byte[][] fileData) { - return new TestCommandRequest(command, options, fileData); - } - - protected LinkIndex getLinkIndex() { - assertTrue("The LinkIndex was not property initialized!", linkIndex != null); - return linkIndex; - } - - protected RestHttpOperationInvoker getOperationInvoker() { - assertTrue("The RestHttpOperationInvoker was not properly initialized!", operationInvoker != null); - return operationInvoker; - } - - @Test - public void testCreateHttpRequest() { - final Map commandOptions = new HashMap(); - - commandOptions.put("author", "Adams"); - commandOptions.put("blankOption", " "); - commandOptions.put("category", "sci-fi"); - commandOptions.put("emptyOption", StringUtils.EMPTY_STRING); - commandOptions.put("isbn", "0-123456789"); - commandOptions.put("nullOption", null); - commandOptions.put("title", "Hitch Hiker's Guide to the Galaxy"); - commandOptions.put("year", "1983"); - - final CommandRequest command = createCommandRequest("add-book", commandOptions); - - final ClientHttpRequest request = getOperationInvoker().createHttpRequest(command); - - assertNotNull(request); - assertNotNull(request.getLink()); - assertEquals("POST http://host.domain.com/service/v1/libraries/{name}/books", request.getLink().toHttpRequestLine()); - assertEquals("Adams", request.getRequestParameterValue("author")); - assertEquals("sci-fi", request.getRequestParameterValue("category")); - assertEquals("0-123456789", request.getRequestParameterValue("isbn")); - assertEquals("Hitch Hiker's Guide to the Galaxy", request.getRequestParameterValue("title")); - assertEquals("1983", request.getRequestParameterValue("year")); - assertFalse(request.getParameters().containsKey("blankOption")); - assertFalse(request.getParameters().containsKey("emptyOption")); - assertFalse(request.getParameters().containsKey("nullOption")); - } - - @Test - public void testCreatHttpRequestWithFileData() { - final Map commandOptions = Collections.singletonMap("isbn", "0-123456789"); - - final byte[][] fileData = { "/path/to/book/content.txt".getBytes(), - "Once upon a time in a galaxy far, far away...".getBytes() }; - - final CommandRequest command = createCommandRequest("add-book", commandOptions, fileData); - - final ClientHttpRequest request = getOperationInvoker().createHttpRequest(command); - - assertNotNull(request); - assertNotNull(request.getLink()); - assertEquals("POST http://host.domain.com/service/v1/libraries/{name}/books", request.getLink().toHttpRequestLine()); - assertEquals("0-123456789", request.getRequestParameterValue("isbn")); - assertTrue(request.getParameters().containsKey(RestHttpOperationInvoker.RESOURCES_REQUEST_PARAMETER)); - assertTrue(request.getRequestParameterValue(RestHttpOperationInvoker.RESOURCES_REQUEST_PARAMETER) instanceof Resource); - - final List resources = request.getRequestParameterValues(RestHttpOperationInvoker.RESOURCES_REQUEST_PARAMETER); - - assertNotNull(resources); - assertFalse(resources.isEmpty()); - assertEquals(1, resources.size()); - } - - @Test - public void testFindAndResolveLink() throws Exception { - final Map commandOptions = new HashMap(); - - commandOptions.put("name", "BarnesN'Noble"); - - Link link = getOperationInvoker().findLink(createCommandRequest("list-libraries", commandOptions)); - - assertNotNull(link); - assertEquals("http://host.domain.com/service/v1/libraries", toString(link.getHref())); - - link = getOperationInvoker().findLink(createCommandRequest("get-library", commandOptions)); - - assertNotNull(link); - assertEquals("http://host.domain.com/service/v1/libraries/{name}", toString(link.getHref())); - - commandOptions.put("author", "J.K.Rowlings"); - - link = getOperationInvoker().findLink(createCommandRequest("list-books", commandOptions)); - - assertNotNull(link); - assertEquals("http://host.domain.com/service/v1/libraries/{name}/books/{author}", toString(link.getHref())); - - commandOptions.put("category", "sci-fi"); - commandOptions.put("year", "1998"); - commandOptions.put("bogus", "data"); - - link = getOperationInvoker().findLink(createCommandRequest("list-books", commandOptions)); - - assertNotNull(link); - assertEquals("http://host.domain.com/service/v1/libraries/{name}/books/{author}/{category}/{year}", - toString(link.getHref())); - - commandOptions.remove("category"); - - link = getOperationInvoker().findLink(createCommandRequest("list-books", commandOptions)); - - assertNotNull(link); - assertEquals("http://host.domain.com/service/v1/libraries/{name}/books/{author}/{year}", - toString(link.getHref())); - - commandOptions.put("category", "fantasy"); - commandOptions.put("isbn", "0-123456789"); - commandOptions.put("title", "Harry Potter"); - - link = getOperationInvoker().findLink(createCommandRequest("add-book", commandOptions)); - - assertNotNull(link); - assertEquals("http://host.domain.com/service/v1/libraries/{name}/books", toString(link.getHref())); - - commandOptions.remove("isbn"); - - link = getOperationInvoker().findLink(createCommandRequest("get-book", commandOptions)); - - assertNotNull(link); - assertEquals("http://host.domain.com/service/v1/libraries/{name}/books/{title}", toString(link.getHref())); - - link = getOperationInvoker().findLink(createCommandRequest("remove-book", commandOptions)); - - assertNotNull(link); - assertEquals("http://host.domain.com/service/v1/libraries/{name}/books/{isbn}", toString(link.getHref())); - } - - @Test - public void testProcessCommand() { - final String expectedResult = "{\"libraries\":[{\"library-of\":\"Congress\"}]"; // JSON - - final RestHttpOperationInvoker operationInvoker = new RestHttpOperationInvoker(getLinkIndex()) { - @Override - public boolean isConnected() { - return true; - } - - @Override - @SuppressWarnings("unchecked") - protected ResponseEntity send(final ClientHttpRequest request, final Class responseType, final Map uriVariables) { - return new ResponseEntity(expectedResult, HttpStatus.OK); - } - }; - - final String actualResult = operationInvoker.processCommand(createCommandRequest("list-libraries", - Collections.emptyMap())); - - assertEquals(expectedResult, actualResult); - } - - @Test - public void testProcessCommandDelegatesToSimpleProcessCommand() { - final String expectedResult = "test"; - - final RestHttpOperationInvoker operationInvoker = new RestHttpOperationInvoker(getLinkIndex()) { - @Override - public boolean isConnected() { - return true; - } - - @Override - protected HttpOperationInvoker getHttpOperationInvoker() { - return new AbstractHttpOperationInvoker(AbstractHttpOperationInvoker.REST_API_URL) { - @Override public Object processCommand(final CommandRequest command) { - return expectedResult; - } - }; - } - - @Override - protected void printWarning(final String message, final Object... args) { - } - }; - - final String actualResult = operationInvoker.processCommand(createCommandRequest("get resource", - Collections.emptyMap())); - - assertEquals(expectedResult, actualResult); - } - - @Test - public void testProcessCommandHandlesResourceAccessException() { - final RestHttpOperationInvoker operationInvoker = new RestHttpOperationInvoker(getLinkIndex()) { - private boolean connected = true; - - @Override - public boolean isConnected() { - return connected; - } - - @Override - protected void printWarning(final String message, final Object... args) { - } - - @Override - protected ResponseEntity send(final ClientHttpRequest request, final Class responseType, final Map uriVariables) { - throw new ResourceAccessException("test"); - } - - @Override - public void stop() { - this.connected = false; - } - }; - - assertTrue(operationInvoker.isConnected()); - - final String expectedResult = String.format( - "The connection to the GemFire Manager's HTTP service @ %1$s failed with: %2$s. " - + "Please try reconnecting or see the GemFire Manager's log file for further details.", - operationInvoker.getBaseUrl(), "test"); - - final String actualResult = operationInvoker.processCommand(createCommandRequest("list-libraries", - Collections.emptyMap())); - - assertFalse(operationInvoker.isConnected()); - assertEquals(expectedResult, actualResult); - } - - @Test(expected = RestApiCallForCommandNotFoundException.class) - public void testProcessCommandThrowsRestApiCallForCommandNotFoundException() { - final RestHttpOperationInvoker operationInvoker = new RestHttpOperationInvoker(getLinkIndex()) { - @Override - public boolean isConnected() { - return true; - } - - @Override - protected HttpOperationInvoker getHttpOperationInvoker() { - return null; - } - }; - - try { - operationInvoker.processCommand(createCommandRequest("get resource", Collections.emptyMap())); - } - catch (RestApiCallForCommandNotFoundException e) { - assertEquals("No REST API call for command (get resource) was found!", e.getMessage()); - throw e; - } - } - - @Test(expected = AssertionError.class) - public void testProcessCommandWhenNotConnected() { - try { - getOperationInvoker().processCommand(createCommandRequest("get-book", Collections.emptyMap())); - } - catch (AssertionError e) { - assertEquals("Gfsh must be connected to the GemFire Manager in order to process commands remotely!", - e.getMessage()); - throw e; - } - } - - protected static final class TestCommandRequest extends CommandRequest { - - private final byte[][] fileData; - - private final Map commandParameters = new TreeMap(); - - private final String command; - - protected TestCommandRequest(final String command, final Map commandParameters) { - this(command, commandParameters, null); - } - - protected TestCommandRequest(final String command, final Map commandParameters, final byte[][] fileData) { - super(Collections.emptyMap()); - - assert command != null : "The command cannot be null!"; - - this.command = command; - - if (commandParameters != null) { - this.commandParameters.putAll(commandParameters); - } - - this.fileData = fileData; - } - - @Override - public byte[][] getFileData() { - return fileData; - } - - @Override - public String getInput() { - return command; - } - - @Override - public String getName() { - return command; - } - - @Override - public Map getParameters() { - return Collections.unmodifiableMap(commandParameters); - } - } - -} diff --git a/gemfire-web/src/test/java/com/gemstone/gemfire/management/internal/web/shell/SimpleHttpOperationInvokerJUnitTest.java b/gemfire-web/src/test/java/com/gemstone/gemfire/management/internal/web/shell/SimpleHttpOperationInvokerJUnitTest.java deleted file mode 100644 index b717f2b4b..000000000 --- a/gemfire-web/src/test/java/com/gemstone/gemfire/management/internal/web/shell/SimpleHttpOperationInvokerJUnitTest.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you - * may not use this file except in compliance with the License. You - * may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. See accompanying - * LICENSE file. - */ -package com.gemstone.gemfire.management.internal.web.shell; - -import static org.junit.Assert.*; - -import com.gemstone.gemfire.management.internal.cli.CommandRequest; -import com.gemstone.gemfire.management.internal.web.AbstractWebTestCase; -import com.gemstone.gemfire.management.internal.web.domain.Link; -import com.gemstone.gemfire.management.internal.web.http.ClientHttpRequest; -import com.gemstone.gemfire.management.internal.web.http.HttpHeader; -import com.gemstone.gemfire.management.internal.web.http.HttpMethod; - -import java.util.Collections; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.client.ResourceAccessException; - -/** - * The SimpleHttpOperationInvokerJUnitTest class is a test suite of test cases testing the contract and functionality of the - * SimpleHttpOperationInvoker class. - *

- * @author John Blum - * @see com.gemstone.gemfire.management.internal.web.AbstractWebTestCase - * @see com.gemstone.gemfire.management.internal.web.shell.SimpleHttpOperationInvoker - * @see org.junit.Assert - * @see org.junit.After - * @see org.junit.Before - * @see org.junit.Test - * @since 7.5 - */ -public class SimpleHttpOperationInvokerJUnitTest extends AbstractWebTestCase { - - private SimpleHttpOperationInvoker operationInvoker; - - @Before - public void setUp() { - operationInvoker = new SimpleHttpOperationInvoker(); - } - - @After - public void tearDown() { - operationInvoker.stop(); - operationInvoker = null; - } - - protected CommandRequest createCommandRequest(final String command) { - return new TestCommandRequest(command); - } - - protected String getExpectedHttpRequestUrl(final CommandRequest command) { - return SimpleHttpOperationInvoker.REST_API_URL.concat(SimpleHttpOperationInvoker.REST_API_MANAGEMENT_COMMANDS_URI) - .concat("?").concat(SimpleHttpOperationInvoker.CMD_QUERY_PARAMETER).concat("=").concat(command.getInput()); - } - - protected SimpleHttpOperationInvoker getOperationInvoker() { - return operationInvoker; - } - - @Test - public void testCreateHttpRequest() throws Exception { - final CommandRequest command = createCommandRequest("save resource --path=/path/to/file --size=1024KB"); - - final ClientHttpRequest request = getOperationInvoker().createHttpRequest(command); - - assertNotNull(request); - assertEquals(SimpleHttpOperationInvoker.USER_AGENT_HTTP_REQUEST_HEADER_VALUE, - request.getHeaderValue(HttpHeader.USER_AGENT.getName())); - - final Link requestLink = request.getLink(); - - assertNotNull(requestLink); - assertTrue(toString(requestLink).startsWith("POST")); - assertTrue(toString(requestLink).endsWith(command.getInput())); - } - - @Test - public void testCreateLink() throws Exception { - final CommandRequest command = createCommandRequest("delete resource --id=1"); - - final Link actualLink = getOperationInvoker().createLink(command); - - assertNotNull(actualLink); - assertEquals(SimpleHttpOperationInvoker.LINK_RELATION, actualLink.getRelation()); - assertEquals(HttpMethod.POST, actualLink.getMethod()); - assertTrue(toString(actualLink.getHref()).endsWith(command.getInput())); - } - - @Test - public void testGetHttpRequestUrl() throws Exception { - final CommandRequest command = createCommandRequest("get resource --option=value"); - - assertEquals(getExpectedHttpRequestUrl(command), toString(getOperationInvoker().getHttpRequestUrl(command))); - } - - @Test - public void testProcessCommand() { - final String expectedResult = "test"; // XML - - final SimpleHttpOperationInvoker operationInvoker = new SimpleHttpOperationInvoker() { - @Override - public boolean isConnected() { - return true; - } - - @Override - @SuppressWarnings("unchecked") - protected ResponseEntity send(final ClientHttpRequest request, final Class responseType) { - return new ResponseEntity(expectedResult, HttpStatus.OK); - } - }; - - final String actualResult = operationInvoker.processCommand(createCommandRequest("get resource --id=1")); - - assertEquals(expectedResult, actualResult); - } - - @Test - public void testProcessCommandHandlesResourceAccessException() { - final SimpleHttpOperationInvoker operationInvoker = new SimpleHttpOperationInvoker() { - private boolean connected = true; - @Override - public boolean isConnected() { - return connected; - } - - @Override - protected ResponseEntity send(final ClientHttpRequest request, final Class responseType) { - throw new ResourceAccessException("test"); - } - - @Override public void stop() { - this.connected = false; - } - }; - - assertTrue(operationInvoker.isConnected()); - - final String expectedResult = String.format( - "The connection to the GemFire Manager's HTTP service @ %1$s failed with: %2$s. " - + "Please try reconnecting or see the GemFire Manager's log file for further details.", - operationInvoker.getBaseUrl(), "test"); - - final String actualResult = operationInvoker.processCommand(createCommandRequest("get resource --id=1")); - - assertFalse(operationInvoker.isConnected()); - assertEquals(expectedResult, actualResult); - } - - @Test(expected = AssertionError.class) - public void testProcessCommandWhenNotConnected() { - try { - getOperationInvoker().processCommand(createCommandRequest("get resource")); - } - catch (AssertionError e) { - assertEquals("Gfsh must be connected to the GemFire Manager in order to process commands remotely!", - e.getMessage()); - throw e; - } - } - - protected static final class TestCommandRequest extends CommandRequest { - - private final String command; - - protected TestCommandRequest(final String command) { - super(Collections.emptyMap()); - assert command != null : "The command cannot be null!"; - this.command = command; - } - - @Override - public String getInput() { - return command; - } - } - -} diff --git a/gemfire-web/src/test/java/com/gemstone/gemfire/management/internal/web/util/ConvertUtilsJUnitTest.java b/gemfire-web/src/test/java/com/gemstone/gemfire/management/internal/web/util/ConvertUtilsJUnitTest.java deleted file mode 100644 index 6b59120ec..000000000 --- a/gemfire-web/src/test/java/com/gemstone/gemfire/management/internal/web/util/ConvertUtilsJUnitTest.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you - * may not use this file except in compliance with the License. You - * may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. See accompanying - * LICENSE file. - */ -package com.gemstone.gemfire.management.internal.web.util; - -import static org.junit.Assert.*; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -import com.gemstone.gemfire.internal.util.IOUtils; -import com.gemstone.gemfire.management.internal.web.io.MultipartFileAdapter; - -import org.junit.Test; -import org.springframework.core.io.ByteArrayResource; -import org.springframework.core.io.Resource; -import org.springframework.web.multipart.MultipartFile; - -/** - * The ConvertUtilsJUnitTest class is a test suite testing the contract and functionality of the ConvertUtilsJUnitTest class. - *

- * @author John Blum - * @see com.gemstone.gemfire.management.internal.web.util.ConvertUtils - * @see org.junit.Assert - * @see org.junit.Test - * @since 7.5 - */ -public class ConvertUtilsJUnitTest { - - protected MultipartFile createMultipartFile(final String filename, final byte[] content) { - return new MultipartFileAdapter() { - @Override public byte[] getBytes() throws IOException { - return content; - } - @Override public InputStream getInputStream() throws IOException { - return new ByteArrayInputStream(getBytes()); - } - @Override public String getName() { - return filename; - } - @Override public String getOriginalFilename() { - return filename; - } - @Override public long getSize() { - return content.length; - } - }; - } - - protected Resource createResource(final String filename, final byte[] content) { - return new ByteArrayResource(content, String.format("Content of file (%1$s).", filename)) { - @Override public String getFilename() { - return filename; - } - }; - } - - @Test - public void testConvertFileData() throws IOException { - final String[] filenames = { "/path/to/file1.ext", "/path/to/another/file2.ext" }; - final String[] fileContent = { "This is the contents of file 1.", "This is the contents of file 2." }; - - final List fileData = new ArrayList(2); - - for (int index = 0; index < filenames.length; index++) { - fileData.add(filenames[index].getBytes()); - fileData.add(fileContent[index].getBytes()); - } - - final Resource[] resources = ConvertUtils.convert(fileData.toArray(new byte[fileData.size()][])); - - assertNotNull(resources); - assertEquals(filenames.length, resources.length); - - for (int index = 0; index < resources.length; index++) { - assertEquals(filenames[index], resources[index].getFilename()); - assertEquals(fileContent[index], new String(IOUtils.toByteArray(resources[index].getInputStream()))); - } - } - - @Test - public void testConvertFileDataWithNull() { - final Resource[] resources = ConvertUtils.convert((byte[][]) null); - - assertNotNull(resources); - assertEquals(0, resources.length); - } - - @Test - public void testConvertMultipartFile() throws IOException { - final MultipartFile[] files = { - createMultipartFile("/path/to/multi-part/file1.txt", "The contents of multi-part file1.".getBytes()), - createMultipartFile("/path/to/multi-part/file2.txt", "The contents of multi-part file2.".getBytes()) - }; - - final byte[][] fileData = ConvertUtils.convert(files); - - assertNotNull(fileData); - assertEquals(files.length * 2, fileData.length); - - for (int index = 0; index < fileData.length; index += 2) { - assertEquals(files[index / 2].getOriginalFilename(), new String(fileData[index])); - assertEquals(new String(files[index / 2].getBytes()), new String(fileData[index + 1])); - } - } - - @Test - public void testConvertResource() throws IOException { - final Resource[] resources = { - createResource("/path/to/file1.txt", "Contents of file1.".getBytes()), - createResource("/path/to/file2.txt", "Contents of file2.".getBytes()) - }; - - final byte[][] fileData = ConvertUtils.convert(resources); - - assertNotNull(fileData); - assertEquals(resources.length * 2, fileData.length); - - for (int index = 0; index < fileData.length; index += 2) { - assertEquals(resources[index / 2].getFilename(), new String(fileData[index])); - assertEquals(new String(IOUtils.toByteArray(resources[index / 2].getInputStream())), new String(fileData[index + 1])); - } - } - - @Test(expected = IllegalArgumentException.class) - public void testConvertResourceWithResourceHavingNoFilename() throws IOException { - try { - ConvertUtils.convert(createResource(null, "test".getBytes())); - } - catch (IllegalArgumentException expected) { - assertEquals("The filename of Resource (Content of file (null).) must be specified!", expected.getMessage()); - throw expected; - } - } - - @Test - public void testConvertResourceWithEmpty() throws IOException { - final byte[][] fileData = ConvertUtils.convert(new Resource[0]); - - assertNotNull(fileData); - assertEquals(0, fileData.length); - } - - @Test - public void testConvertResourceWithNull() throws IOException { - final byte[][] fileData = ConvertUtils.convert((Resource[]) null); - - assertNotNull(fileData); - assertEquals(0, fileData.length); - } - -} diff --git a/gemfirexd/client/build.gradle b/gemfirexd/client/build.gradle index 3150304c0..0b16b6289 100644 --- a/gemfirexd/client/build.gradle +++ b/gemfirexd/client/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -15,23 +15,19 @@ * LICENSE file. */ -plugins { - id 'com.github.johnrengelman.shadow' version '2.0.4' -} - dependencies { compile "org.apache.thrift:libthrift:${thriftVersion}" compile "net.java.dev.jna:jna:${jnaVersion}" compile project(subprojectBase + 'snappydata-store-shared') - compile 'org.apache.tomcat:tomcat-jdbc:8.5.23' - compile group: 'org.apache.tomcat', name: 'tomcat-juli', version: '8.5.23' + compile "org.apache.tomcat:tomcat-juli:${tomcatJdbcVersion}" + compile "org.apache.tomcat:tomcat-jdbc:${tomcatJdbcVersion}" } task generatePropertiesFiles(dependsOn: 'processResources') { - def infoDir = file("${buildDir}/resources/main/com/pivotal/gemfirexd/internal/info") + def infoDir = file("${sourceSets.main.java.outputDir}/com/pivotal/gemfirexd/internal/info") outputs.files "${infoDir}/dnc.properties", "${infoDir}/thrift.properties" - inputs.dir compileJava.destinationDir + inputs.dir "${projectDir}/../core/src/main/resources/com/pivotal/gemfirexd/internal/info" doLast { println('Creating DRDA client properties') diff --git a/gemfirexd/client/src/main/java/com/pivotal/gemfirexd/internal/client/am/SingleHopPreparedStatement.java b/gemfirexd/client/src/main/java/com/pivotal/gemfirexd/internal/client/am/SingleHopPreparedStatement.java index a00503af8..7fcf6ea05 100644 --- a/gemfirexd/client/src/main/java/com/pivotal/gemfirexd/internal/client/am/SingleHopPreparedStatement.java +++ b/gemfirexd/client/src/main/java/com/pivotal/gemfirexd/internal/client/am/SingleHopPreparedStatement.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/client/src/main/java/com/pivotal/gemfirexd/internal/jdbc/ClientConnectionPoolDataSource40.java b/gemfirexd/client/src/main/java/com/pivotal/gemfirexd/internal/jdbc/ClientConnectionPoolDataSource40.java index ff8de4e77..fa3fb9654 100644 --- a/gemfirexd/client/src/main/java/com/pivotal/gemfirexd/internal/jdbc/ClientConnectionPoolDataSource40.java +++ b/gemfirexd/client/src/main/java/com/pivotal/gemfirexd/internal/jdbc/ClientConnectionPoolDataSource40.java @@ -40,7 +40,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/client/src/main/java/com/pivotal/gemfirexd/internal/jdbc/ClientDataSource40.java b/gemfirexd/client/src/main/java/com/pivotal/gemfirexd/internal/jdbc/ClientDataSource40.java index 532ae529c..f13da539f 100644 --- a/gemfirexd/client/src/main/java/com/pivotal/gemfirexd/internal/jdbc/ClientDataSource40.java +++ b/gemfirexd/client/src/main/java/com/pivotal/gemfirexd/internal/jdbc/ClientDataSource40.java @@ -40,7 +40,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/client/src/main/java/com/pivotal/gemfirexd/internal/jdbc/ClientXADataSource40.java b/gemfirexd/client/src/main/java/com/pivotal/gemfirexd/internal/jdbc/ClientXADataSource40.java index d26b62148..0fcc8d42f 100644 --- a/gemfirexd/client/src/main/java/com/pivotal/gemfirexd/internal/jdbc/ClientXADataSource40.java +++ b/gemfirexd/client/src/main/java/com/pivotal/gemfirexd/internal/jdbc/ClientXADataSource40.java @@ -40,7 +40,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/client/src/main/java/com/pivotal/gemfirexd/jdbc/ClientDRDADriver.java b/gemfirexd/client/src/main/java/com/pivotal/gemfirexd/jdbc/ClientDRDADriver.java index 903f4a74c..e5243c6f9 100644 --- a/gemfirexd/client/src/main/java/com/pivotal/gemfirexd/jdbc/ClientDRDADriver.java +++ b/gemfirexd/client/src/main/java/com/pivotal/gemfirexd/jdbc/ClientDRDADriver.java @@ -40,7 +40,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -59,6 +59,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more package com.pivotal.gemfirexd.jdbc; import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -132,7 +133,7 @@ public java.sql.Connection connect(String url, return null; } com.pivotal.gemfirexd.internal.client.net.NetConnection conn; - try { + try { if (exceptionsOnLoadDriver__ != null) { throw exceptionsOnLoadDriver__; } @@ -237,10 +238,10 @@ public java.sql.Connection connect(String url, } catch(SqlException se) { throw se.getSQLException(null /* GemStoneAddition */); } - + if(conn.isConnectionNull()) return null; - + return conn; } @@ -517,7 +518,7 @@ private static java.util.Properties tokenizeURLProperties(String url, *(or) *ClientJDBCObjectFactoryImpl40 */ - + public static ClientJDBCObjectFactory getFactory() { if(factoryObject!=null) return factoryObject; @@ -528,7 +529,7 @@ public static ClientJDBCObjectFactory getFactory() { } return factoryObject; } - + /** *Returns an instance of the ClientJDBCObjectFactoryImpl class */ @@ -550,7 +551,7 @@ private static ClientJDBCObjectFactory createDefaultFactoryImpl() { */ // GemStone changes END } - + /** *Returns an instance of the ClientJDBCObjectFactoryImpl40 class *If a ClassNotFoundException occurs then it returns an @@ -562,7 +563,7 @@ private static ClientJDBCObjectFactory createDefaultFactoryImpl() { *return the lower version thus having a sort of cascading effect *until it gets a valid instance */ - + private static ClientJDBCObjectFactory createJDBC40FactoryImpl() { final String factoryName = "com.pivotal.gemfirexd.internal.client.net.ClientJDBCObjectFactoryImpl40"; @@ -619,9 +620,8 @@ protected java.sql.Connection createThriftConnection(String server, int port, } // JDBC 4.1 methods since jdk 1.7 - public Logger getParentLogger() { - throw new AssertionError("should be overridden in JDBC 4.1"); + public Logger getParentLogger() throws SQLFeatureNotSupportedException { + throw new SQLFeatureNotSupportedException("getParentLogger not supported", "0A000"); } // GemStone changes END } - diff --git a/gemfirexd/client/src/main/java/com/pivotal/gemfirexd/jdbc/ClientDriver.java b/gemfirexd/client/src/main/java/com/pivotal/gemfirexd/jdbc/ClientDriver.java index a4940db94..ca4c106dc 100644 --- a/gemfirexd/client/src/main/java/com/pivotal/gemfirexd/jdbc/ClientDriver.java +++ b/gemfirexd/client/src/main/java/com/pivotal/gemfirexd/jdbc/ClientDriver.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/client/src/main/java/io/snappydata/jdbc/ClientConnectionPoolDataSource.java b/gemfirexd/client/src/main/java/io/snappydata/jdbc/ClientConnectionPoolDataSource.java index 41511a385..865ae3669 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/jdbc/ClientConnectionPoolDataSource.java +++ b/gemfirexd/client/src/main/java/io/snappydata/jdbc/ClientConnectionPoolDataSource.java @@ -40,7 +40,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/client/src/main/java/io/snappydata/jdbc/ClientDataSource.java b/gemfirexd/client/src/main/java/io/snappydata/jdbc/ClientDataSource.java index 81c9acde7..7f7909364 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/jdbc/ClientDataSource.java +++ b/gemfirexd/client/src/main/java/io/snappydata/jdbc/ClientDataSource.java @@ -40,7 +40,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/client/src/main/java/io/snappydata/jdbc/ClientDataSourceFactory.java b/gemfirexd/client/src/main/java/io/snappydata/jdbc/ClientDataSourceFactory.java index 712786120..8992d4c06 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/jdbc/ClientDataSourceFactory.java +++ b/gemfirexd/client/src/main/java/io/snappydata/jdbc/ClientDataSourceFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/client/src/main/java/io/snappydata/jdbc/ClientDriver.java b/gemfirexd/client/src/main/java/io/snappydata/jdbc/ClientDriver.java index 7e5f0085f..a0f5b0c21 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/jdbc/ClientDriver.java +++ b/gemfirexd/client/src/main/java/io/snappydata/jdbc/ClientDriver.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -88,7 +88,7 @@ public class ClientDriver extends ClientDRDADriver { /** * {@inheritDoc} */ - public boolean acceptsURL(String url) throws java.sql.SQLException { + public boolean acceptsURL(String url) { return (url != null && matchProtocol(url).matches()); } diff --git a/gemfirexd/client/src/main/java/io/snappydata/jdbc/ClientPoolDriver.java b/gemfirexd/client/src/main/java/io/snappydata/jdbc/ClientPoolDriver.java index ccba8f3fa..0736e1ef6 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/jdbc/ClientPoolDriver.java +++ b/gemfirexd/client/src/main/java/io/snappydata/jdbc/ClientPoolDriver.java @@ -1,7 +1,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -42,14 +42,11 @@ public class ClientPoolDriver implements Driver { private static String SNAPPY_PROTOCOL = "jdbc:snappydata:"; - private final static String SUBPROTOCOL = "(pool:){1}"; + private final static String SUBPROTOCOL = "(pool:)"; - public static final ThreadLocal CURRENT_CONNECTION = - new ThreadLocal<>(); - - protected final static String URL_PREFIX_REGEX = "(" + SNAPPY_PROTOCOL + ")"; - protected final static String URL_SUFFIX_REGEX = - "//(([^:]+:[0-9]+)|([^\\[]+\\[[0-9]+\\]))(/(snappydata;)?;?(.*)?)?"; + private final static String URL_PREFIX_REGEX = "(" + SNAPPY_PROTOCOL + ")"; + private final static String URL_SUFFIX_REGEX = + "//(([^:]+:[0-9]+)|([^\\[]+\\[[0-9]+]))(/(snappydata;)?;?(.*)?)?"; /*private final static Pattern PROTOCOL_PATTERN = Pattern.compile(URL_PREFIX_REGEX + SUBPROTOCOL + "//.*", Pattern.CASE_INSENSITIVE);*/ @@ -85,7 +82,7 @@ public class ClientPoolDriver implements Driver { /** * {@inheritDoc} */ - public boolean acceptsURL(String url) throws SQLException { + public boolean acceptsURL(String url) { return (url != null && URL_PATTERN.matcher(url).matches()); } @@ -102,10 +99,8 @@ public Connection connect(String url, Properties properties) throws SQLException clientDriverURL); properties.setProperty(TomcatConnectionPool.PoolProps.DRIVER_NAME.key, ClientDriver.class.getName()); - Connection connection = TomcatConnectionPool.getConnection(properties); - CURRENT_CONNECTION.set(connection); - //Read connection from the pool and return. - return connection; + // Read connection from the pool and return. + return TomcatConnectionPool.getConnection(properties); } @Override @@ -125,12 +120,12 @@ public boolean jdbcCompliant() { @Override public Logger getParentLogger() throws SQLFeatureNotSupportedException { - throw new AssertionError("should be overridden in JDBC 4.1"); + throw new SQLFeatureNotSupportedException("getParentLogger not supported", "0A000"); } @Override public DriverPropertyInfo[] getPropertyInfo(String url, Properties properties) throws SQLException { - return ClientDRDADriver.getPropertyInfoUtility(url,properties); + return ClientDRDADriver.getPropertyInfoUtility(url, properties); } -} \ No newline at end of file +} diff --git a/gemfirexd/client/src/main/java/io/snappydata/jdbc/ClientXADataSource.java b/gemfirexd/client/src/main/java/io/snappydata/jdbc/ClientXADataSource.java index 5e06379db..d333f9e81 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/jdbc/ClientXADataSource.java +++ b/gemfirexd/client/src/main/java/io/snappydata/jdbc/ClientXADataSource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/client/src/main/java/io/snappydata/jdbc/TomcatConnectionPool.java b/gemfirexd/client/src/main/java/io/snappydata/jdbc/TomcatConnectionPool.java index 0e25f02eb..84e4b5697 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/jdbc/TomcatConnectionPool.java +++ b/gemfirexd/client/src/main/java/io/snappydata/jdbc/TomcatConnectionPool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -27,32 +27,37 @@ import java.util.concurrent.ConcurrentMap; import java.util.stream.Collectors; +import com.pivotal.gemfirexd.Attribute; import com.sun.xml.internal.fastinfoset.stax.events.Util; import org.apache.tomcat.jdbc.pool.DataSource; import org.apache.tomcat.jdbc.pool.PoolProperties; +import org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer; /** * A class holds map of connection pools. Each pool is represented accessed * via unique key which is the connection Properties object. - * + *

* Also, class support the jdbcInterceptor which resets the autocommit, readOnly * and isolation level value to default whenever a connection borrowed from the pool. */ -class TomcatConnectionPool { +public class TomcatConnectionPool { private static final Integer MAX_POOL_SIZE = Math.max(256, Runtime.getRuntime().availableProcessors() * 8); - static enum PoolProps { + public static final ThreadLocal CURRENT_CONNECTION = + new ThreadLocal<>(); + + enum PoolProps { DRIVER_NAME("pool.driverClassName", ClientDriver.class.getName()), URL("pool.url", null), // Compulsory field user must provide - USER("pool.user", "APP"), - PASSWORD("pool.password", "APP"), - INIT_SIZE("pool.initialSize", "10"), + USER(Attribute.USERNAME_ATTR, "APP"), + PASSWORD(Attribute.PASSWORD_ATTR, "APP"), + INIT_SIZE("pool.initialSize", "4"), MAX_ACTIVE("pool.maxActive", MAX_POOL_SIZE.toString()), MAX_IDLE("pool.maxIdle", MAX_POOL_SIZE.toString()), - MIN_IDLE("pool.minIdle", "1"), + MIN_IDLE("pool.minIdle", "4"), MAX_WAIT("pool.maxWait", "30"), REMOVE_ABANDONED("pool.removeAbandoned", "true"), REMOVE_ABANDONED_TIMEOUT("pool.removeAbandonedTimeout", "60"), @@ -63,9 +68,9 @@ static enum PoolProps { VALIDATION_INTERVAL("pool.validationInterval", "10000"), JDBC_INTERCEPTOR("pool.jdbcInterceptor", "org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;" + - "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer"), + getRequiredInterceptor()), // Default transaction values which will be resetted, when connection returned to the pool. - DEFAULT_AUTO_COMMIT("pool.defaultAutoCommit","false"), + DEFAULT_AUTO_COMMIT("pool.defaultAutoCommit", "false"), DEFAULT_READ_ONLY("pool.defaultReadOnly", "false"), DEFAULT_TRANSACTION_ISOLATION("pool.defaultTransactionIsolation", String.valueOf(Connection.TRANSACTION_NONE)); @@ -91,13 +96,24 @@ public static List getKeys() { private DataSource datasource; private static final ConcurrentMap poolMap = - new ConcurrentHashMap(); + new ConcurrentHashMap<>(); + + public static final class ClearConnection extends StatementFinalizer { + @Override + public void closeInvoked() { + super.closeInvoked(); + CURRENT_CONNECTION.set(null); + } + } + + private static String getRequiredInterceptor() { + return ClearConnection.class.getName(); + } /** * Initialize the Data Source with the Connection pool and returns the connection * * @return java.sql.Connection - * @throws SQLException */ private Connection getConnection() throws SQLException { return datasource.getConnection(); @@ -105,16 +121,16 @@ private Connection getConnection() throws SQLException { public static Connection getConnection(Properties properties) throws SQLException { TomcatConnectionPool pool = poolMap.computeIfAbsent(properties, - props -> new TomcatConnectionPool(props)); - return pool.getConnection(); + TomcatConnectionPool::new); + Connection connection = pool.getConnection(); + CURRENT_CONNECTION.set(connection); + return connection; } /** * Initializes the Object with passed on properties. - * - * @param prop */ - public TomcatConnectionPool(Properties prop) { + private TomcatConnectionPool(Properties prop) { List listPoolPropKeys = PoolProps.getKeys(); @@ -124,7 +140,7 @@ public TomcatConnectionPool(Properties prop) { // connection properties to pass on. Set keys = prop.stringPropertyNames(); String connectionProperties = keys.stream().filter(x -> !listPoolPropKeys.contains(x)) - .map(i -> i.toString() + "=" + prop.getProperty(i.toString())) + .map(i -> i + "=" + prop.getProperty(i)) .collect(Collectors.joining(";")); poolProperties.setConnectionProperties(connectionProperties); @@ -136,10 +152,6 @@ public TomcatConnectionPool(Properties prop) { * Method responsible for collecting pooled properties from the * properties object passed to connection and creates PoolProperties * object by setting the pool properties into it. - * - * @param prop - * - * @return */ private PoolProperties getPoolProperties(Properties prop) { @@ -173,7 +185,7 @@ private PoolProperties getPoolProperties(Properties prop) { String minIdle = prop.getProperty(PoolProps.MIN_IDLE.key, PoolProps.MIN_IDLE.defValue); - poolProperties.setMaxIdle(Integer.parseInt(minIdle)); + poolProperties.setMinIdle(Integer.parseInt(minIdle)); String waitTime = prop.getProperty(PoolProps.MAX_WAIT.key, PoolProps.MAX_WAIT.defValue); @@ -207,7 +219,7 @@ private PoolProperties getPoolProperties(Properties prop) { String testOnReturn = prop.getProperty(PoolProps.TEST_ON_RETURN.key, PoolProps.TEST_ON_RETURN.defValue); - poolProperties.setTestOnBorrow(Boolean.parseBoolean(testOnReturn)); + poolProperties.setTestOnReturn(Boolean.parseBoolean(testOnReturn)); String validationInterval = prop.getProperty(PoolProps.VALIDATION_INTERVAL.key, @@ -225,7 +237,7 @@ private PoolProperties getPoolProperties(Properties prop) { PoolProps.DEFAULT_READ_ONLY.defValue)); poolProperties.setDefaultReadOnly(defaultReadOnly); - Integer defaultTransactionIsolation = Integer.valueOf( + int defaultTransactionIsolation = Integer.parseInt( prop.getProperty(PoolProps.DEFAULT_TRANSACTION_ISOLATION.key, PoolProps.DEFAULT_TRANSACTION_ISOLATION.defValue)); poolProperties.setDefaultTransactionIsolation(defaultTransactionIsolation); @@ -233,12 +245,17 @@ private PoolProperties getPoolProperties(Properties prop) { // the connection is reset to the desired state each time its borrowed from the pool. // In this case above three, 1. autoCommit, 2. readOnly & 3. transactionIsolation level - // is resetted with the default value. + // is reset with the default value. String jdbcInterceptor = prop.getProperty(PoolProps.JDBC_INTERCEPTOR.key, PoolProps.JDBC_INTERCEPTOR.defValue); + // force add interceptor for clearing things on connection close else it can be a leak + String requiredInterceptor = getRequiredInterceptor(); + if (!jdbcInterceptor.contains(requiredInterceptor)) { + jdbcInterceptor = jdbcInterceptor + ";" + requiredInterceptor; + } poolProperties.setJdbcInterceptors(jdbcInterceptor); return poolProperties; } -} \ No newline at end of file +} diff --git a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientBlob.java b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientBlob.java index f2b820f4e..807f84eff 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientBlob.java +++ b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientBlob.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientCallableStatement.java b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientCallableStatement.java index f38b6725b..f8716389b 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientCallableStatement.java +++ b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientCallableStatement.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientClob.java b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientClob.java index 10a25b3e2..58c43570a 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientClob.java +++ b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientClob.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientConfiguration.java b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientConfiguration.java index 023c9c7c4..c2725217a 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientConfiguration.java +++ b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientConfiguration.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientConnection.java b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientConnection.java index cd25058ae..3bf6c2a52 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientConnection.java +++ b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientConnection.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -110,6 +110,10 @@ public final ClientService getClientService() { return this.clientService; } + public final Map getConnectionProperties() { + return this.clientService.connectionProps; + } + final ClientPooledConnection getOwnerPooledConnection() { return this.clientServiceOwner; } diff --git a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientDBMetaData.java b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientDBMetaData.java index 807ff2dc3..7338a1486 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientDBMetaData.java +++ b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientDBMetaData.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientFetchColumnValue.java b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientFetchColumnValue.java index 4fc5df677..1608ac581 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientFetchColumnValue.java +++ b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientFetchColumnValue.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientFinalizer.java b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientFinalizer.java index 121dd3557..15d0391e6 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientFinalizer.java +++ b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientFinalizer.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientLobBase.java b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientLobBase.java index 084ba3dc6..18810b000 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientLobBase.java +++ b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientLobBase.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -99,8 +99,11 @@ protected final int getLength(boolean forceMaterialize) throws SQLException { final int len = this.length; if (len >= 0) { return len; - } else { + } else if (this.streamedInput) { return (this.length = streamLength(forceMaterialize)); + } else { + // LOB has been freed + return 0; } } diff --git a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientParameterMetaData.java b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientParameterMetaData.java index c18f8d91a..c3628409e 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientParameterMetaData.java +++ b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientParameterMetaData.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientPooledConnection.java b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientPooledConnection.java index 51d037632..decb8b8aa 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientPooledConnection.java +++ b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientPooledConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientPreparedStatement.java b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientPreparedStatement.java index bfa98848d..926101b4b 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientPreparedStatement.java +++ b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientPreparedStatement.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -618,7 +618,7 @@ public final void setObject(int parameterIndex, Object x) throws SQLException { public void addBatch() throws SQLException { checkClosed(); - if (this.parameterMetaData != null && this.parameterMetaData.size() > 0) { + if (this.parameterMetaData != null) { if (this.paramsBatch == null) { this.paramsBatch = new ArrayList<>(); } diff --git a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientRSMetaData.java b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientRSMetaData.java index 9dc6faeef..825446aec 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientRSMetaData.java +++ b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientRSMetaData.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientResultSet.java b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientResultSet.java index 5eab3d324..4382a5041 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientResultSet.java +++ b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientResultSet.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientService.java b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientService.java index 15b09ca81..e73431726 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientService.java +++ b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientService.java @@ -75,8 +75,10 @@ public final class ClientService extends ReentrantLock implements LobService { private HostAddress currentHostAddress; private String currentDefaultSchema; final OpenConnectionArgs connArgs; + final Map connectionProps; final List connHosts; - final boolean loadBalance; + private final boolean explicitLoadBalance; + private boolean loadBalance; final SocketParameters socketParams; final boolean framedTransport; final boolean useDirectBuffers; @@ -157,10 +159,6 @@ public void visit(String str, Collection collectAddresses, sb.append(pid).append('|'); ClientSharedUtils.formatDate(currentTime, sb); hostId = sb.toString(); - ClientConfiguration config = ClientConfiguration.getInstance(); - ClientSharedUtils.getLogger().info("Starting client on '" + hostName + - "' with ID='" + hostId + "' Source-Revision=" + - config.getSourceRevision()); // thread for periodic cleanup of finalizers invokeFinalizers = new FinalizeInvoker(); @@ -318,6 +316,12 @@ static ClientService create(String host, int port, boolean forXA, private ClientService(HostAddress hostAddr, OpenConnectionArgs connArgs) throws SnappyException { + + ClientConfiguration config = ClientConfiguration.getInstance(); + ClientSharedUtils.getLogger().info("Starting client on '" + hostName + + "' with ID='" + hostId + "' Source-Revision=" + + config.getSourceRevision()); + this.isClosed = true; this.currentHostConnection = null; @@ -325,10 +329,16 @@ private ClientService(HostAddress hostAddr, OpenConnectionArgs connArgs) this.connArgs = connArgs; Map props = connArgs.getProperties(); + this.connectionProps = props != null ? new HashMap<>(props) : new HashMap<>(); + String propValue; - // default for load-balance is true - this.loadBalance = (props == null || !"false".equalsIgnoreCase(props - .remove(ClientAttribute.LOAD_BALANCE))); + boolean hasLoadBalance = props != null && + props.containsKey(ClientAttribute.LOAD_BALANCE); + this.explicitLoadBalance = hasLoadBalance && "true".equalsIgnoreCase( + props.remove(ClientAttribute.LOAD_BALANCE)); + // default for load-balance is true on locators and false on servers + // so tentatively set as true and adjust using the ControlConnection + this.loadBalance = this.explicitLoadBalance || !hasLoadBalance; // setup the original host list if (props != null && (propValue = props.remove( @@ -438,12 +448,36 @@ void openConnection(HostAddress hostAddr, Set failedServers, try { this.currentHostAddress = hostAddr; if (this.loadBalance) { - ControlConnection controlService = ControlConnection + final ControlConnection controlService = ControlConnection .getOrCreateControlConnection(connHosts, this, failure); - // at this point query the control service for preferred server - this.currentHostAddress = hostAddr = controlService.getPreferredServer( - failedServers, this.serverGroups, false, failure); + // if connected to server then disable load-balance by default + if (!this.explicitLoadBalance) { + // check the actual host type of "locators" + Set locators = controlService.getLocatorsCopy(); + locators.retainAll(connHosts); + boolean hasLocator = false; + if (!locators.isEmpty()) { + for (HostAddress addr : locators) { + if (addr.getServerType() == null || + addr.getServerType().isThriftLocator()) { + hasLocator = true; + break; + } + } + } + if (!hasLocator) { + this.loadBalance = false; + controlService.close(true); + } + } + if (this.loadBalance) { + // at this point query the control service for preferred server + this.currentHostAddress = hostAddr = controlService.getPreferredServer( + failedServers, this.serverGroups, false, failure); + } } + this.connectionProps.put(ClientAttribute.LOAD_BALANCE, + Boolean.toString(this.loadBalance)); final TTransport currentTransport; int readTimeout; diff --git a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientStatement.java b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientStatement.java index 0a84b0114..d6c5ecdab 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientStatement.java +++ b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ClientStatement.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -137,8 +137,8 @@ public static StatementAttrs setLocalExecutionBucketIds(StatementAttrs attrs, .setRetainBucketIds(retain); } - public final void setMetadataVersion(int version) { - this.attrs.setMetadataVersion(version); + public final void setCatalogVersion(long version) { + this.attrs.setCatalogVersion(version); } public final void setSnapshotTransactionId(String txId) { diff --git a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ControlConnection.java b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ControlConnection.java index da973158c..252c98e18 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ControlConnection.java +++ b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/ControlConnection.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -310,6 +310,10 @@ HostAddress searchRandomServer(Set failedServers, throw failoverExhausted(failedServers, failure); } + synchronized Set getLocatorsCopy() { + return new HashSet<>(this.locators); + } + private synchronized Set failoverToAvailableHost( Set failedServers, boolean checkFailedControlHosts, Throwable failure) throws SnappyException { @@ -431,12 +435,21 @@ private void refreshAllHosts(List allHosts) { this.controlHostSet.addAll(allHosts); } - private SnappyException unexpectedError(Throwable t, HostAddress host) { + void close(boolean clearGlobal) { this.controlHost = null; if (this.controlLocator != null) { this.controlLocator.getOutputProtocol().getTransport().close(); this.controlLocator = null; } + if (clearGlobal) { + synchronized (allControlConnections) { + allControlConnections.remove(this); + } + } + } + + private SnappyException unexpectedError(Throwable t, HostAddress host) { + close(false); return ThriftExceptionUtil.newSnappyException(SQLState.JAVA_EXCEPTION, t, host != null ? host.toString() : null, t.getClass(), t.getMessage()); } diff --git a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/HostConnection.java b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/HostConnection.java index b2f40028a..1d2491a61 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/HostConnection.java +++ b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/HostConnection.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/MemInputStream.java b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/MemInputStream.java index 2f6294722..2b26bea38 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/MemInputStream.java +++ b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/MemInputStream.java @@ -19,7 +19,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/MemStringReader.java b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/MemStringReader.java index a6a5e7318..291a24724 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/MemStringReader.java +++ b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/MemStringReader.java @@ -19,7 +19,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/datasource/ClientXAConnection.java b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/datasource/ClientXAConnection.java index 7e38b1e26..a016f781b 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/datasource/ClientXAConnection.java +++ b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/datasource/ClientXAConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/datasource/ClientXAResource.java b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/datasource/ClientXAResource.java index 5cd6a519e..7ff0fc0ef 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/datasource/ClientXAResource.java +++ b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/datasource/ClientXAResource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/datasource/ClientXid.java b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/datasource/ClientXid.java index 67c42d8d2..8cdba8c61 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/datasource/ClientXid.java +++ b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/datasource/ClientXid.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/types/InternalSavepoint.java b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/types/InternalSavepoint.java index 964197098..98530e831 100644 --- a/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/types/InternalSavepoint.java +++ b/gemfirexd/client/src/main/java/io/snappydata/thrift/internal/types/InternalSavepoint.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/build.gradle b/gemfirexd/core/build.gradle index d01077a8c..db242c7f5 100644 --- a/gemfirexd/core/build.gradle +++ b/gemfirexd/core/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -15,10 +15,7 @@ * LICENSE file. */ -plugins { - id 'ca.coglinc.javacc' version '2.4.0' - id 'com.github.johnrengelman.shadow' version '2.0.4' -} +apply plugin: 'ca.coglinc2.javacc' dependencies { compile project(subprojectBase + 'gemfire-core') @@ -27,8 +24,8 @@ dependencies { compileOnly project(subprojectBase + 'snappydata-store-prebuild') compileOnly files("${System.getProperty('java.home')}/../lib/tools.jar") - compileOnly 'xalan:xalan:2.7.2' - compileOnly 'xalan:serializer:2.7.2' + compileOnly "xalan:xalan:${xalanVersion}" + compileOnly "xalan:serializer:${xalanVersion}" compileOnly "com.pivotal:pxf-api:${pxfVersion}" compile "org.osgi:org.osgi.core:${osgiVersion}" compile "org.apache.ant:ant:${antVersion}" @@ -83,9 +80,9 @@ task deleteGenerated(type: Delete) { clean.dependsOn deleteGenerated task generatePropertiesFiles(dependsOn: 'processResources') { - def infoDir = file("${buildDir}/resources/main/com/pivotal/gemfirexd/internal/info") + def infoDir = file("${sourceSets.main.java.outputDir}/com/pivotal/gemfirexd/internal/info") outputs.files "${infoDir}/DBMS.properties", "${infoDir}/net.properties" - inputs.dir compileJava.destinationDir + inputs.dir "${projectDir}/src/main/resources/com/pivotal/gemfirexd/internal/info" doLast { println('Creating engine properties') @@ -99,7 +96,7 @@ task generatePropertiesFiles(dependsOn: 'processResources') { } def msgDir = "${projectDir}/src/main/resources/${locDir}" -def msgEnDir = "${buildDir}/resources/main/${locDir}" +def msgEnDir = "${sourceSets.main.java.outputDir}/${locDir}" task buildMessages { dependsOn subprojectBase + 'snappydata-store-prebuild:jar', 'processResources', subprojectBase + 'snappydata-store-client:processResources' @@ -117,7 +114,7 @@ task buildMessages { ant.taskdef(name: 'buildMessages', classname: 'org.apache.derbyBuild.MessageBuilder', - classpath: project(subprojectBase + 'snappydata-store-prebuild').sourceSets.main.output.classesDir) + classpath: project(subprojectBase + 'snappydata-store-prebuild').sourceSets.main.java.outputDir) ant.buildMessages(xmlSourceFile: msgXml, propertiesTargetFile: msgEn, ditaTargetFile: "${projectDir}/doc/rrefexcept71493.dita") @@ -138,7 +135,7 @@ def splitMessages(def msgFile, def msgDir) { // create the client messages files for various languages task doSplit(dependsOn: buildMessages) { def msgXml = "${msgDir}/messages.xml" - def clientResourceDir = "${project(subprojectBase + 'snappydata-store-client').buildDir}/resources/main/${locDir}" + def clientResourceDir = "${project(subprojectBase + 'snappydata-store-client').sourceSets.main.java.outputDir}/${locDir}" inputs.file msgXml outputs.files "${msgEnDir}/m0_en.properties", "${clientResourceDir}/clientmessages_en.properties" @@ -169,7 +166,7 @@ task doSplit(dependsOn: buildMessages) { // copy the remaining properties files to their place in engine jar copy { from clientMsgOutDir - into "${buildDir}/resources/main/${locDir}" + into msgEnDir include 'm*.properties' } } @@ -177,9 +174,10 @@ task doSplit(dependsOn: buildMessages) { task odbcMeta { dependsOn "${subprojectBase}snappydata-store-prebuild:processResources", 'processResources', "${subprojectBase}snappydata-store-prebuild:jar" - def metaDir = file("${buildDir}/resources/main/com/pivotal/gemfirexd/internal/impl/jdbc") + def metaDir = file("${sourceSets.main.java.outputDir}/com/pivotal/gemfirexd/internal/impl/jdbc") outputs.file "${metaDir}/metadata.properties" - inputs.dir compileJava.destinationDir + inputs.dir "${projectDir}/../prebuild/src/main/resources/com/pivotal/gemfirexd/internal/impl/jdbc" + inputs.dir "${projectDir}/../prebuild/src/main/java/org/apache/derbyBuild" doFirst { metaDir.mkdirs() @@ -201,7 +199,7 @@ task odbcMeta { /* task createClassSizeCatalog { def internalDir = 'com/pivotal/gemfirexd/internal' - def internalOut = "${sourceSets.main.output.classesDir}/${internalDir}" + def internalOut = "${sourceSets.main.java.outputDir}/${internalDir}" // need to re-generate class size catalog if any of the classes below change inputs.files [ "${internalOut}/iapi/types/DataValueDescriptor.class", @@ -267,7 +265,7 @@ jar { } copy { from "${projectDir}/lib" - into gemfireCoreProject.sourceSets.main.output.classesDir + into gemfireCoreProject.sourceSets.main.java.outputDir } } } diff --git a/gemfirexd/core/lib/libgemfirexd.dylib b/gemfirexd/core/lib/libgemfirexd.dylib new file mode 100644 index 000000000..005e85a66 Binary files /dev/null and b/gemfirexd/core/lib/libgemfirexd.dylib differ diff --git a/gemfirexd/core/lib/libgemfirexd.so b/gemfirexd/core/lib/libgemfirexd.so old mode 100755 new mode 100644 index 705cf0f1d..f938619ff Binary files a/gemfirexd/core/lib/libgemfirexd.so and b/gemfirexd/core/lib/libgemfirexd.so differ diff --git a/gemfirexd/core/lib/libgemfirexd64.dylib b/gemfirexd/core/lib/libgemfirexd64.dylib new file mode 100644 index 000000000..e7d18bc76 Binary files /dev/null and b/gemfirexd/core/lib/libgemfirexd64.dylib differ diff --git a/gemfirexd/core/lib/libgemfirexd64.so b/gemfirexd/core/lib/libgemfirexd64.so index 82c88b96f..4dce332e6 100644 Binary files a/gemfirexd/core/lib/libgemfirexd64.so and b/gemfirexd/core/lib/libgemfirexd64.so differ diff --git a/gemfirexd/core/lib/libgemfirexd64_g.so b/gemfirexd/core/lib/libgemfirexd64_g.so deleted file mode 100644 index d08b9b330..000000000 Binary files a/gemfirexd/core/lib/libgemfirexd64_g.so and /dev/null differ diff --git a/gemfirexd/core/lib/libgemfirexd_g.so b/gemfirexd/core/lib/libgemfirexd_g.so deleted file mode 100644 index 546c88213..000000000 Binary files a/gemfirexd/core/lib/libgemfirexd_g.so and /dev/null differ diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/catalog/ExternalCatalog.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/catalog/ExternalCatalog.java index eb95b27b1..baa326472 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/catalog/ExternalCatalog.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/catalog/ExternalCatalog.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -17,11 +17,14 @@ package com.pivotal.gemfirexd.internal.catalog; -import java.util.HashMap; import java.util.List; +import java.util.Map; import com.gemstone.gemfire.internal.cache.ExternalTableMetaData; +import com.gemstone.gemfire.internal.cache.LocalRegion; import com.gemstone.gemfire.internal.cache.PolicyTableData; +import io.snappydata.thrift.CatalogMetadataDetails; +import io.snappydata.thrift.CatalogMetadataRequest; /** * Need to keep GemXD independent of any snappy/spark/hive related @@ -46,54 +49,70 @@ public interface ExternalCatalog { */ boolean isColumnTable(String schema, String tableName, boolean skipLocks); - /** - * Will be used by the execution engine to execute query in gemfirexd - * if tablename is of a row table. - * - * @return true if the table is column table, false if row/ref table - */ - boolean isRowTable(String schema, String tableName, boolean skipLocks); - /** * Get the schema for a column table in Json format (as in Spark). */ - String getColumnTableSchemaAsJson(String schema, String tableName, boolean skipLocks); + String getColumnTableSchemaAsJson(String schema, String tableName); /** - * Retruns a map of DBs to list of store tables(those tables that - * are in store DD) in catalog + * Returns a map of DBs to list of store tables(those tables that + * are in store DD) in catalog. Both schema name and table names + * are returned in upper-case. */ - HashMap> getAllStoreTablesInCatalog(boolean skipLocks); + Map> getAllStoreTablesInCatalogUppercase(); /** - * Removes a table from the external catalog + * Removes a table from the external catalog if it exists. */ - boolean removeTable(String schema, String table, boolean skipLocks); + void removeTableIfExists(String schema, String table, boolean skipLocks); /** * Returns the schema in which this catalog is created - * - * @return */ - public String catalogSchemaName(); - - Object getTable(String schema, String tableName, boolean skipLocks); + String catalogSchemaName(); /** * Get the metadata for all external hive tables (including all their columns). */ - public List getHiveTables(boolean skipLocks); + List getCatalogTables(); /** * Get the details of all the policies created. */ - public List getPolicies(boolean skipLocks); + List getPolicies(); /** * Returns the meta data of the Hive Table */ - public ExternalTableMetaData getHiveTableMetaData(String schema, String tableName, - boolean skipLocks); + ExternalTableMetaData getCatalogTableMetadata(String schema, String tableName); + + /** + * Generic method to get metadata from catalog. + * + * @param operation one of the get operation types with prefix CATALOG_ in thrift IDL + * @param request parameters for operation + * @param result the result filled filled in with metadata + * + * @return the current region for table metadata lookup if applicable else null + */ + LocalRegion fillCatalogMetadata(int operation, CatalogMetadataRequest request, + CatalogMetadataDetails result); + + /** + * Generic method to update metadata of catalog. This will also perform + * schema permission checks internally so callers don't need to do it. + * + * @param operation one of the update operation types with prefix CATALOG_ in thrift IDL + * @param request parameters for operation + * @param user current user executing the operation who will be checked for + * required permissions + */ + void updateCatalogMetadata(int operation, CatalogMetadataDetails request, String user); + + /** + * Get the current catalog schema version + */ + long getCatalogSchemaVersion(); void close(); } diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/GfxdDataSerializable.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/GfxdDataSerializable.java index 201bb0acd..72e9be902 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/GfxdDataSerializable.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/GfxdDataSerializable.java @@ -18,7 +18,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -90,7 +90,6 @@ import com.pivotal.gemfirexd.internal.engine.ui.SnappyRegionStatsCollectorResult; import com.pivotal.gemfirexd.internal.impl.store.raw.data.GfxdJarMessage; import com.pivotal.gemfirexd.internal.snappy.LeadNodeExecutionContext; -import com.pivotal.gemfirexd.internal.snappy.LeadNodeSmartConnectorOpContext; import com.pivotal.gemfirexd.tools.planexporter.ExecutionPlanMessage; /** @@ -272,10 +271,6 @@ public static synchronized boolean initTypes() { () -> new MemberStatisticsMessage()); DSFIDFactory.registerGemFireXDClass(MEMBER_LOGS_MESSAGE, () -> new MemberLogsMessage()); - DSFIDFactory.registerGemFireXDClass(LEAD_NODE_CONN_OP_CTX, - () -> new LeadNodeSmartConnectorOpContext()); - DSFIDFactory.registerGemFireXDClass(LEAD_NODE_CONN_OP_MSG, - () -> new LeadNodeSmartConnectorOpMsg()); DSFIDFactory.registerGemFireXDClass(LEAD_NODE_GET_STATS, () -> new LeadNodeGetStatsMessage()); DSFIDFactory.registerGemFireXDClass(PROJECTION_ROW, diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/GfxdSerializable.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/GfxdSerializable.java index ea1eb3480..18689c07f 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/GfxdSerializable.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/GfxdSerializable.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -207,7 +207,7 @@ public interface GfxdSerializable extends GfxdDSFID { byte LEAD_NODE_EXN_MSG = 56; - byte LEAD_NODE_CONN_OP_MSG = 57; + // 57 is unused -- use for the next new message ID byte LEAD_NODE_GET_STATS = 58; @@ -324,7 +324,7 @@ public interface GfxdSerializable extends GfxdDSFID { byte SNAPPY_REGION_STATS_RESULT = 111; - byte LEAD_NODE_CONN_OP_CTX = 112; + // 112 is unused -- use for new IDs byte COLUMN_FORMAT_KEY = 113; diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/Misc.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/Misc.java index 17e4200e9..5ca7a60b7 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/Misc.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/Misc.java @@ -362,20 +362,22 @@ public void close() {} }; } - public static String getReservoirRegionNameForSampleTable(String schema, String resolvedBaseName) { - Region regionBase = Misc.getRegionForTable(resolvedBaseName, false); + public static String getReservoirRegionNameForSampleTable( + String schema, String resolvedBaseName) { + Region regionBase = Misc.getRegionForTable(resolvedBaseName, true); return schema + "_SAMPLE_INTERNAL_" + regionBase.getName(); } public volatile static boolean reservoirRegionCreated = false; - public static PartitionedRegion createReservoirRegionForSampleTable(String reservoirRegionName, String resolvedBaseName) { - Region regionBase = Misc.getRegionForTable(resolvedBaseName, false); - GemFireCacheImpl cache = GemFireCacheImpl.getInstance(); - Region childRegion = cache.getRegion(reservoirRegionName); - if (childRegion == null) { - RegionAttributes attributesBase = regionBase.getAttributes(); - PartitionAttributes partitionAttributesBase = attributesBase.getPartitionAttributes(); + public static PartitionedRegion createReservoirRegionForSampleTable( + String reservoirRegionName, String resolvedBaseName) { + Region regionBase = Misc.getRegionForTable(resolvedBaseName, false); + GemFireCacheImpl cache = GemFireCacheImpl.getExisting(); + Region childRegion = cache.getRegion(reservoirRegionName); + if (childRegion == null && regionBase != null) { + RegionAttributes attributesBase = regionBase.getAttributes(); + PartitionAttributes partitionAttributesBase = attributesBase.getPartitionAttributes(); AttributesFactory afact = new AttributesFactory(); afact.setDataPolicy(attributesBase.getDataPolicy()); PartitionAttributesFactory paf = new PartitionAttributesFactory(); @@ -388,27 +390,21 @@ public static PartitionedRegion createReservoirRegionForSampleTable(Strin afact.setPartitionAttributes(paf.create()); childRegion = cache.createRegion(reservoirRegionName, afact.create()); } - reservoirRegionCreated = true; + if (childRegion != null) reservoirRegionCreated = true; return (PartitionedRegion)childRegion; } - public static PartitionedRegion getReservoirRegionForSampleTable(String reservoirRegionName) { + public static PartitionedRegion getReservoirRegionForSampleTable(String reservoirRegionName) { if (reservoirRegionName != null) { - GemFireCacheImpl cache = GemFireCacheImpl.getInstance(); - Region childRegion = cache.getRegion(reservoirRegionName); + GemFireCacheImpl cache = GemFireCacheImpl.getExisting(); + Region childRegion = cache.getRegion(reservoirRegionName); if (childRegion != null) { - return (PartitionedRegion) childRegion; + return (PartitionedRegion)childRegion; } } return null; } - public static void dropReservoirRegionForSampleTable(PartitionedRegion reservoirRegion) { - if (reservoirRegion != null) { - reservoirRegion.destroyRegion(null); - } - } - public static PartitionedRegion.PRLocalScanIterator getLocalBucketsIteratorForSampleTable(PartitionedRegion reservoirRegion, Set bucketSet, boolean fetchFromRemote) { @@ -1159,13 +1155,12 @@ public final static long estimateMemoryUsage( public final static StandardException generateLowMemoryException( final String query) { - LogWriter logger = getCacheLogWriterNoThrow(); if (logger != null && logger.warningEnabled()) { logger.warning(GfxdConstants.TRACE_HEAPTHRESH + " cancelling statement [" + query + "] due to low memory"); } - + CallbackFactoryProvider.getStoreCallbacks().logMemoryStats(); final StandardException se = StandardException.newException( SQLState.LANG_STATEMENT_CANCELLED_ON_LOW_MEMORY, query, GemFireStore.getMyId()); diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/GemFireTransaction.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/GemFireTransaction.java index 8da10064c..8da5f0901 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/GemFireTransaction.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/GemFireTransaction.java @@ -123,7 +123,7 @@ import com.pivotal.gemfirexd.internal.impl.store.raw.xact.XactId; import com.pivotal.gemfirexd.internal.shared.common.error.ExceptionSeverity; import com.pivotal.gemfirexd.internal.shared.common.sanity.SanityManager; -import io.snappydata.collection.LongObjectHashMap; +import org.eclipse.collections.impl.map.mutable.primitive.LongObjectHashMap; import static com.gemstone.gemfire.internal.offheap.annotations.OffHeapIdentifier.GEMFIRE_TRANSACTION_BYTE_SOURCE; @@ -975,9 +975,9 @@ public long createConglomerate(String implementation, if ((temporaryFlag & TransactionController.IS_TEMPORARY) == TransactionController.IS_TEMPORARY) { if (this.tempCongloms == null) { - this.tempCongloms = LongObjectHashMap.withExpectedSize(8); + this.tempCongloms = new LongObjectHashMap<>(8); } - this.tempCongloms.justPut(conglomId, conglom); + this.tempCongloms.put(conglomId, conglom); } final GemFireContainer container = conglom.getGemFireContainer(); if (container != null) { @@ -1089,9 +1089,8 @@ public String debugOpened() throws StandardException { } } if (this.tempCongloms != null) { - this.tempCongloms.forEachWhile((key, val) -> { + this.tempCongloms.forEachKeyValue((key, val) -> { sb.append("temp conglomerate id = ").append(key).append(": ").append(val); - return true; }); } } @@ -1134,7 +1133,7 @@ public void dropConglomerate(long conglomId) throws StandardException { if (conglomId < 0) { if (this.tempCongloms != null) { - this.tempCongloms.remove(conglomId); + this.tempCongloms.removeKey(conglomId); } if (GemFireXDUtils.TraceConglom) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_CONGLOM, @@ -3711,7 +3710,12 @@ public static final void reattachTransaction( else if (tx != TXStateProxy.TX_NOT_SET && tx != (context = TXManagerImpl.getOrCreateTXContext()) .getTXState()) { - if (tx != null) { + // for snapshot TX, never set into thread-context from GemFireTransaction + // but always the other way + if (context.getSnapshotTXState() != null) { + tran.setTXState(context.getSnapshotTXState()); + } + else if (tx != null) { context.setTXState(tx); } else { @@ -3757,7 +3761,12 @@ public static final void switchContextManager(final ContextManager nextCM) { else if (tx != TXStateProxy.TX_NOT_SET && tx != (context = TXManagerImpl.getOrCreateTXContext()) .getTXState()) { - if (tx != null) { + // for snapshot TX, never set into thread-context from GemFireTransaction + // but always the other way + if (context.getSnapshotTXState() != null) { + tran.setTXState(context.getSnapshotTXState()); + } + else if (tx != null) { context.setTXState(tx); } else { @@ -3811,9 +3820,9 @@ public long addAndLoadStreamContainer(final long segmentId, final long conglomId = getNextTempConglomId(); if (this.tempCongloms == null) { - this.tempCongloms = LongObjectHashMap.withExpectedSize(8); + this.tempCongloms = new LongObjectHashMap<>(8); } - this.tempCongloms.justPut(conglomId, new FileStreamInputOutput(conglomId, this, + this.tempCongloms.put(conglomId, new FileStreamInputOutput(conglomId, this, rowSource, rwBuffer)); return conglomId; @@ -3991,7 +4000,7 @@ public void dropStreamContainer(long segmentId, long containerId) } final FileStreamInputOutput container = (FileStreamInputOutput)this.tempCongloms - .remove(containerId); + .removeKey(containerId); if (SanityManager.DEBUG) { SanityManager.ASSERT(container != null, diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/GfxdTXStateProxy.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/GfxdTXStateProxy.java index 7dbc241d6..673dd9285 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/GfxdTXStateProxy.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/GfxdTXStateProxy.java @@ -67,7 +67,7 @@ /** * Extends GFE {@link TXStateProxy} to add GFXD specific artifacts including * DBSynchronizer message list to be sent out at commit time. - * + * * @author swale * @since 7.0 */ @@ -117,6 +117,12 @@ public static final TXStateProxyFactory getGfxdFactory() { @Override protected Set getRollbackTargets( VMIdAdvisor advisor) { + // hive meta-store tables are persisted on locators too, so send rollback + // to all nodes for the case when "default-persistent" is set on the connection + final LanguageConnectionContext lcc = Misc.getLanguageConnectionContext(); + if (lcc != null && lcc.isDefaultPersistent()) { + return super.getRollbackTargets(advisor); + } // send rollback only to GFXD stores @SuppressWarnings({ "unchecked", "rawtypes" }) Set stores = (Set)GemFireXDUtils @@ -427,7 +433,7 @@ final void cleanupIndexEntryForDestroy(Object container, false /* isPutDML */); if (GemFireXDUtils.TraceIndex | GemFireXDUtils.TraceQuery) { - GfxdIndexManager.traceIndex("SortedMap2Index cleanup: " + GfxdIndexManager.traceIndex("GfxdTXStateProxy cleanupIndexEntryForDestroy: " + "rolled back key=%s to value=(%s) in %s", indexKey, GemFireXDUtils.TraceIndex ? oldRowLocation : ArrayUtils .objectRefString(oldRowLocation), indexContainer); @@ -470,7 +476,7 @@ public final boolean execute(final Object k1, final Object k2, } }); } - + if (unaffectedIndexInfo != null) { unaffectedIndexInfo.forEachEntry(new TObjectObjectObjectProcedure() { @Override @@ -657,12 +663,12 @@ private void updateIndexAtCommitAbortNoThrow(GfxdTXEntryState sqle, throws StandardException { boolean deleted; Object valueBytesBeingReplaced = sqle.getPendingValue(); - - //TODO:Asif: This will cause a memory leak if an existing entry is + + //TODO:Asif: This will cause a memory leak if an existing entry is //updated in txn, such a new index key is introduced, and then again - // a txn update happens such that byte [] changes . Then + // a txn update happens such that byte [] changes . Then // the firts indexkey's byte[] will not match the pending value - + try { if (rollback) { if (!indexContainer.isGlobalIndex()) { diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/index/ContainsUniqueKeyExecutorMessage.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/index/ContainsUniqueKeyExecutorMessage.java index f956cdb62..c606996f2 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/index/ContainsUniqueKeyExecutorMessage.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/index/ContainsUniqueKeyExecutorMessage.java @@ -143,7 +143,7 @@ public static boolean existsKey(TXStateInterface tx, LocalRegion lr, if (rl != null && (rlTXId = rl.getTXId()) != null) { rl = SortedMap2IndexScanController.AbstractRowLocationIterator .isRowLocationValidForTransaction(rl, rlTXId, tx, - GfxdConstants.SCAN_OPENMODE_FOR_READONLY_LOCK); + GfxdConstants.SCAN_OPENMODE_FOR_READONLY_LOCK, indexContainer.isUniqueIndex()); } final Object ckey = fetch.getCurrentKey(); final CompactCompositeIndexKey mapKey = ckey != null diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/index/GfxdIndexManager.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/index/GfxdIndexManager.java index f81d16110..a8a31bb29 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/index/GfxdIndexManager.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/index/GfxdIndexManager.java @@ -28,14 +28,7 @@ import com.gemstone.gemfire.InternalGemFireError; import com.gemstone.gemfire.LogWriter; import com.gemstone.gemfire.SystemFailure; -import com.gemstone.gemfire.cache.DataPolicy; -import com.gemstone.gemfire.cache.DiskAccessException; -import com.gemstone.gemfire.cache.EntryExistsException; -import com.gemstone.gemfire.cache.EntryNotFoundException; -import com.gemstone.gemfire.cache.Operation; -import com.gemstone.gemfire.cache.PartitionAttributes; -import com.gemstone.gemfire.cache.RegionDestroyedException; -import com.gemstone.gemfire.cache.TimeoutException; +import com.gemstone.gemfire.cache.*; import com.gemstone.gemfire.cache.execute.EmptyRegionFunctionException; import com.gemstone.gemfire.cache.query.internal.IndexUpdater; import com.gemstone.gemfire.distributed.LockNotHeldException; @@ -89,16 +82,7 @@ import com.pivotal.gemfirexd.internal.engine.locks.GfxdReadWriteLock; import com.pivotal.gemfirexd.internal.engine.locks.impl.GfxdReentrantReadWriteLock; import com.pivotal.gemfirexd.internal.engine.sql.catalog.ExtraTableInfo; -import com.pivotal.gemfirexd.internal.engine.store.AbstractCompactExecRow; -import com.pivotal.gemfirexd.internal.engine.store.CompactCompositeIndexKey; -import com.pivotal.gemfirexd.internal.engine.store.CompactCompositeRegionKey; -import com.pivotal.gemfirexd.internal.engine.store.CompositeRegionKey; -import com.pivotal.gemfirexd.internal.engine.store.ExtractingIndexKey; -import com.pivotal.gemfirexd.internal.engine.store.GemFireContainer; -import com.pivotal.gemfirexd.internal.engine.store.GemFireStore; -import com.pivotal.gemfirexd.internal.engine.store.RegionEntryUtils; -import com.pivotal.gemfirexd.internal.engine.store.RowFormatter; -import com.pivotal.gemfirexd.internal.engine.store.ServerGroupUtils; +import com.pivotal.gemfirexd.internal.engine.store.*; import com.pivotal.gemfirexd.internal.engine.store.entry.GfxdTXEntryState; import com.pivotal.gemfirexd.internal.engine.store.offheap.OffHeapByteSource; import com.pivotal.gemfirexd.internal.engine.store.offheap.OffHeapDelta; @@ -118,15 +102,7 @@ import com.pivotal.gemfirexd.internal.iapi.sql.depend.DependencyManager; import com.pivotal.gemfirexd.internal.iapi.sql.depend.Dependent; import com.pivotal.gemfirexd.internal.iapi.sql.depend.Provider; -import com.pivotal.gemfirexd.internal.iapi.sql.dictionary.ConglomerateDescriptor; -import com.pivotal.gemfirexd.internal.iapi.sql.dictionary.ConstraintDescriptor; -import com.pivotal.gemfirexd.internal.iapi.sql.dictionary.ConstraintDescriptorList; -import com.pivotal.gemfirexd.internal.iapi.sql.dictionary.DataDictionary; -import com.pivotal.gemfirexd.internal.iapi.sql.dictionary.ForeignKeyConstraintDescriptor; -import com.pivotal.gemfirexd.internal.iapi.sql.dictionary.IndexRowGenerator; -import com.pivotal.gemfirexd.internal.iapi.sql.dictionary.ReferencedKeyConstraintDescriptor; -import com.pivotal.gemfirexd.internal.iapi.sql.dictionary.TableDescriptor; -import com.pivotal.gemfirexd.internal.iapi.sql.dictionary.TriggerDescriptor; +import com.pivotal.gemfirexd.internal.iapi.sql.dictionary.*; import com.pivotal.gemfirexd.internal.iapi.sql.execute.ExecRow; import com.pivotal.gemfirexd.internal.iapi.store.access.TransactionController; import com.pivotal.gemfirexd.internal.iapi.store.raw.ContainerHandle; @@ -209,13 +185,12 @@ public final class GfxdIndexManager implements Dependent, IndexUpdater, private MembershipManager membershipManager; - - public enum Index{ + public enum Index { LOCAL, GLOBAL, BOTH } - + protected GfxdIndexManager(DataDictionary dd, TableDescriptor td, Database db, GemFireContainer gfc, boolean hasFk) { this.dd = (GfxdDataDictionary)dd; @@ -802,7 +777,8 @@ else if (isGIIEvent) { execRow = getExecRow(this.td, tmpOldValue, null, 0, false, null); try { deleteFromIndexes(null, null, owner, event, skipDistribution, - entry, indexes, execRow, null, true, isPutDML, true); + entry, indexes, execRow, null, true, + isPutDML, skipConstraintChecks, true); } finally { newRow = getExecRow(this.td, event.getNewValueAsOffHeapDeserializedOrRaw(), null, 0, false, @@ -810,7 +786,7 @@ else if (isGIIEvent) { insertIntoIndexes(tc, tx, owner, event, diskRecovery, skipDistribution, rl, newRow, null, null, bucketId, indexes, - null, isPutDML, Index.BOTH, isGIIEvent); + null, isPutDML, skipConstraintChecks, Index.BOTH, isGIIEvent); } return; } @@ -884,7 +860,7 @@ else if (isPutDML) { eventContext = new EntryEventContext(conn, lcc, tc, skipDistribution, execRow, newRow, changedColumns, undoList, lockedForGII, bucketId, origSkipLocks, origIsRemote, restoreFlags, - lccPosDupSet, isGIIEvent, isPutDML, routingObject); + lccPosDupSet, isGIIEvent, isPutDML, skipConstraintChecks, routingObject); event.setContextObject(eventContext); contextSet = true; if (op.isUpdate() && event.isLoadedFromHDFS()) { @@ -897,7 +873,7 @@ else if (isPutDML) { eventContext = new EntryEventContext(conn, lcc, tc, skipDistribution, execRow, newRow, changedColumns, null, lockedForGII, bucketId, origSkipLocks, origIsRemote, restoreFlags, - lccPosDupSet, isGIIEvent, isPutDML, routingObject); + lccPosDupSet, isGIIEvent, isPutDML, skipConstraintChecks, routingObject); event.setContextObject(eventContext); contextSet = true; if (op.isUpdate() && event.isLoadedFromHDFS()) { @@ -1125,6 +1101,7 @@ this.container, getObjectString(indexes), entry, success, final LanguageConnectionContext lcc = ctx.lcc; final GemFireTransaction tc = ctx.tc; final boolean isPutDML = ctx.isPutDML; + final boolean skipConstraintChecks = ctx.skipConstraintChecks; final boolean skipDistribution = ctx.skipDistribution // recheck flag in event; set for TX abort explicitly to skip ops || event.getSkipDistributionOps(); @@ -1181,24 +1158,26 @@ this.container, getObjectString(indexes), entry, success, if (success) { execRow = ctx.execRow; if (isPutDML) { - if (execRow != null ) { - if(op.isUpdate()) { - if ((undoList = ctx.undoList) != null && !undoList.isEmpty()) { - deleteFromIndexes(tc, tx, owner, event, skipDistribution, entry, - ctx.undoList, execRow, null, true, isPutDML, success); - } - else { - if(ctx.changedColumns != null) { + if (execRow != null) { + if (op.isUpdate()) { + if ((undoList = ctx.undoList) != null && !undoList.isEmpty()) { deleteFromIndexes(tc, tx, owner, event, skipDistribution, entry, - indexes, execRow, ctx.changedColumns, true, isPutDML, success); - }else { - this.refreshIndexKeyForContainers(indexes, null, - event, entry, execRow, null, success); + ctx.undoList, execRow, null, true, + isPutDML, skipConstraintChecks, success); + } else { + if (ctx.changedColumns != null) { + deleteFromIndexes(tc, tx, owner, event, skipDistribution, entry, + indexes, execRow, ctx.changedColumns, true, + isPutDML, skipConstraintChecks, success); + } else { + this.refreshIndexKeyForContainers(indexes, null, + event, entry, execRow, null, success); + } } - } - }else if(op.isDestroy()) { + } else if (op.isDestroy()) { deleteFromIndexes(tc, tx, owner, event, skipDistribution, entry, - indexes, execRow, null, false, isPutDML, success); + indexes, execRow, null, false, + isPutDML, skipConstraintChecks, success); } } } @@ -1215,11 +1194,13 @@ else if (op.isUpdate() && (event.hasDelta() || event.hasOffHeapValue())) { // indexes and we do not need to pass the changedColumns if ((undoList = ctx.undoList) != null && !undoList.isEmpty()) { deleteFromIndexes(tc, tx, owner, event, skipDistribution, entry, - undoList, ctx.triggerExecRow, null, true, isPutDML, success); + undoList, ctx.triggerExecRow, null, true, + isPutDML, skipConstraintChecks, success); } else { deleteFromIndexes(tc, tx, owner, event, skipDistribution, entry, - indexes, ctx.triggerExecRow, changedColumns, true, isPutDML, success); + indexes, ctx.triggerExecRow, changedColumns, true, + isPutDML, skipConstraintChecks, success); } if (SanityManager.DEBUG) { checkIndexListChange(indexes, "update"); @@ -1238,11 +1219,13 @@ else if (op.isUpdate() && (event.hasDelta() || event.hasOffHeapValue())) { // indexes and we do not need to pass the changedColumns if ((undoList = ctx.undoList) != null && !undoList.isEmpty()) { deleteFromIndexes(tc, tx, owner, event, skipDistribution, entry, - undoList, execRow, null, true, isPutDML, success); + undoList, execRow, null, true, + isPutDML, skipConstraintChecks, success); } else { deleteFromIndexes(tc, tx, owner, event, skipDistribution, entry, - indexes, execRow, changedColumns, true, isPutDML, success); + indexes, execRow, changedColumns, true, + isPutDML, skipConstraintChecks, success); } if (SanityManager.DEBUG) { checkIndexListChange(indexes, "update"); @@ -1262,7 +1245,7 @@ else if (op.isDestroy()) { // is a ListOfDeltas in which case ignore the destroy (bug #41529) if (execRow != null) { doDelete(tc, tx, owner, event, skipDistribution, entry, execRow, - indexes, isPutDML, success); + indexes, isPutDML, skipConstraintChecks, success); } } @@ -1284,14 +1267,16 @@ else if ((undoList = ctx.undoList) != null) { if (event.isGFXDCreate(true) || isPutDML) { execRow = ctx.execRow; deleteFromIndexes(tc, tx, owner, event, skipDistribution, entry, - undoList, execRow, null, false, isPutDML, success /* case false*/); + undoList, execRow, null, false, + isPutDML, skipConstraintChecks, success /* case false*/); } else if (op.isUpdate()) { newRow = getExecRow(this.td, event.getNewValueAsOffHeapDeserializedOrRaw(), null, 0, false, getTableInfo(entry)); deleteFromIndexes(tc, tx, owner, event, skipDistribution, entry, - undoList, newRow, null, false, isPutDML, success /* case false*/); + undoList, newRow, null, false, + isPutDML, skipConstraintChecks, success /* case false*/); } } } catch (Throwable t) { @@ -1904,7 +1889,7 @@ private void doInsert(GemFireTransaction tc, final TXStateInterface tx, } insertIntoIndexes(tc, tx, owner, event, diskRecovery, skipDistribution, rl, execRow, null, null, bucketId, localIndexContainers, undoList, - isPutDML, Index.BOTH, isGIIEvent); + isPutDML, skipConstraintChecks, Index.BOTH, isGIIEvent); } private void logKeyValue(String op, Object key, @Unretained Object value) { @@ -1929,7 +1914,8 @@ private void insertIntoIndexes(GemFireTransaction tran, ExecRow newRow, ExecRow oldRow, FormatableBitSet changedColumns, int bucketId, List localIndexContainers, ArrayList undoList, boolean isPutDML, - Index indexToUpdate, boolean isGIIEvent) throws StandardException { + boolean skipConstraintChecks, Index indexToUpdate, + boolean isGIIEvent) throws StandardException { final int numContainers = localIndexContainers.size(); for (int index = 0; index < numContainers; index++) { if (SanityManager.DEBUG) { @@ -1937,8 +1923,8 @@ private void insertIntoIndexes(GemFireTransaction tran, } insertIntoIndex(tran, tx, owner, event, diskRecovery, skipDistribution, rl, newRow, oldRow, changedColumns, bucketId, - localIndexContainers.get(index), undoList, isPutDML, indexToUpdate, - isGIIEvent); + localIndexContainers.get(index), undoList, isPutDML, + skipConstraintChecks, indexToUpdate, isGIIEvent); } } @@ -1947,8 +1933,8 @@ public final void insertIntoIndex(GemFireTransaction tran, boolean diskRecovery, boolean skipDistribution, RowLocation rl, ExecRow newRow, ExecRow oldRow, FormatableBitSet changedColumns, int bucketId, final GemFireContainer indexContainer, - ArrayList undoList, boolean isPutDML, - Index indexToUpdate, boolean isGIIEvent) + ArrayList undoList, boolean isPutDML, + boolean skipConstraintChecks, Index indexToUpdate, boolean isGIIEvent) throws StandardException { if (GemFireXDUtils.TraceIndex) { @@ -2046,7 +2032,7 @@ else if(!isIndexTypeGlobal && (indexToUpdate==Index.LOCAL || indexToUpdate==Inde result = SortedMap2IndexInsertOperation.doMe(tran, tx, indexContainer, insertedIndexKey, rowLocation, unique, - null, isPutDML); + null, isPutDML, skipConstraintChecks); if (tx != null) { ((GfxdTXEntryState)rowLocation).updateIndexInfos(indexContainer, @@ -2101,7 +2087,8 @@ else if (unchangedIndexKey( WrapperRowLocationForTxn wrl = new WrapperRowLocationForTxn( stxe, insertedIndexKey, !event.getOperation().isDestroy()); SortedMap2IndexInsertOperation.doMe(tran, tx, indexContainer, - insertedIndexKey, rowLocation, isUnique, wrl, isPutDML); + insertedIndexKey, rowLocation, isUnique, wrl, isPutDML, + skipConstraintChecks); if (GemFireXDUtils.TraceIndex) { traceIndex("GfxdIndexManager#insertIntoIndexes: wrapper " + "%s for container (%s) with indexes %s for key[%s] " @@ -2235,14 +2222,14 @@ private void doUpdateForOperationOnHDFSFaultedInRow(GemFireTransaction tc, final // Local insert insertIntoIndexes(tc, tx, owner, event, diskRecovery, skipDistribution, rl, oldRow, null, null, bucketId, localIndexContainers, - undoList, isPutDML, Index.LOCAL, false); + undoList, isPutDML, skipConstraintChecks, Index.LOCAL, false); //Global update // We update the global index as global index gets evicted and not deleted // when a row is evicted. insertIntoIndexes(tc, tx, owner, event, diskRecovery, skipDistribution, rl, triggerNewRow, triggerExecRow, changedColumns, bucketId, localIndexContainers, - undoList, isPutDML, Index.GLOBAL, false); + undoList, isPutDML, skipConstraintChecks, Index.GLOBAL, false); } } @@ -2289,7 +2276,7 @@ private void doUpdate(GemFireTransaction tc, final TXStateInterface tx, // is required to not clash with an existing entry. insertIntoIndexes(tc, tx, owner, event, diskRecovery, skipDistribution, rl, newRow, oldRow, changedColumns, bucketId, localIndexContainers, - undoList, isPutDML, Index.BOTH, isGIIEvent); + undoList, isPutDML, skipConstraintChecks, Index.BOTH, isGIIEvent); } } @@ -2298,7 +2285,8 @@ private void deleteFromIndexes(GemFireTransaction tran, boolean skipDistribution, RegionEntry entry, List containers, ExecRow execRow, FormatableBitSet changedColumns, boolean refreshIndexKey, - boolean isPutDML, boolean isSuccess) throws StandardException { + boolean isPutDML, boolean skipConstraintChecks, + boolean isSuccess) throws StandardException { // if (event.isLoadedFromHDFS()) { // if (GemFireXDUtils.TraceIndex) { // traceIndex("GfxdIndexManager#deleteFromIndexes: " @@ -2408,7 +2396,7 @@ && unchangedIndexKey(indexContainer.getBaseColumnPositions(), txEntry = (GfxdTXEntryState)rowLocation; // for rollback, just remove the inserted GfxdTXEntryState (#51553) if (isSuccess) { - wrapper = txEntry.wrapperForRollback(indexContainer, indexKey); + wrapper = txEntry.wrapperForRollback(indexContainer, indexKey, event); } } try { @@ -2483,7 +2471,6 @@ && unchangedIndexKey(indexContainer.getBaseColumnPositions(), } } - if (!deleted && exceptionToThrow == null) { try { handleNotDeleted(event.isPossibleDuplicate(), owner, indexContainer, @@ -2500,7 +2487,7 @@ && unchangedIndexKey(indexContainer.getBaseColumnPositions(), if (event.getOperation().isDestroy()) { if(tx == null) { this.undoDeleteIndexesForUnsuccessfulDestroy(entry, owner, event, - isPutDML, containers, i - 1, tran, execRow); + isPutDML, skipConstraintChecks, containers, i - 1, tran, execRow); } break; } @@ -2528,8 +2515,8 @@ && unchangedIndexKey(indexContainer.getBaseColumnPositions(), private void undoDeleteIndexesForUnsuccessfulDestroy(RegionEntry entry, LocalRegion owner, EntryEventImpl event, boolean isPutDML, - List containers, final int undoIndex, - GemFireTransaction tran, final ExecRow rowToInsert) { + boolean skipConstraintChecks, List containers, + final int undoIndex, GemFireTransaction tran, final ExecRow rowToInsert) { final RowLocation rl = entry instanceof RowLocation ? (RowLocation) entry : null; int bucketId; @@ -2554,7 +2541,7 @@ private void undoDeleteIndexesForUnsuccessfulDestroy(RegionEntry entry, try { this.insertIntoIndex(tran, null, owner, event, false, false, rl, rowToInsert, null, null, bucketId, containerToInsert, null, - isPutDML, Index.BOTH, false); + isPutDML, skipConstraintChecks, Index.BOTH, false); } catch (Exception e) { LogWriter logger = Misc.getCacheLogWriterNoThrow(); if(logger != null) { @@ -2784,15 +2771,16 @@ public boolean unchangedIndexKey(int[] indexedColumns, private void doDelete(GemFireTransaction tran, final TXStateInterface tx, LocalRegion owner, EntryEventImpl event, boolean skipDistribution, RegionEntry entry, ExecRow execRow, - List localIndexContainers, boolean isPutDML, - boolean success) + List localIndexContainers, + boolean isPutDML, boolean skipConstraintChecks, boolean success) throws StandardException { if (GemFireXDUtils.TraceIndex) { traceIndex("GfxdIndexManager#doDelete: invoked for container %s for " + "entry %s", this.container, entry); } deleteFromIndexes(tran, tx, owner, event, skipDistribution, entry, - localIndexContainers, execRow, null, false, isPutDML, success); + localIndexContainers, execRow, null, false, + isPutDML, skipConstraintChecks, success); if (SanityManager.DEBUG) { checkIndexListChange(localIndexContainers, "delete"); } @@ -4499,7 +4487,7 @@ void basicClearEntry(LocalRegion region, DiskRegion dr, GemFireTransaction tc, * do not touch * global indexes */, entry, - oldRow, indexes, false, true); + oldRow, indexes, false, false, true); } catch (Throwable t) { Error err; if (t instanceof Error && SystemFailure.isJVMFailureError( @@ -4841,6 +4829,8 @@ private static final class EntryEventContext { final boolean isPutDML; + final boolean skipConstraintChecks; + final int bucketId; final boolean origSkipLocks; @@ -4859,7 +4849,7 @@ private static final class EntryEventContext { ArrayList undoList, boolean isGIILocked, int bucketId, boolean skipLocks, boolean isRemote, boolean restoreFlags, boolean lccPosDupSet, boolean isGIIEvent, - boolean isPutDML, Object routingObject) { + boolean isPutDML, boolean skipConstraintChecks, Object routingObject) { this.conn = conn; this.lcc = lcc; this.tc = tc; @@ -4876,6 +4866,7 @@ private static final class EntryEventContext { this.lccPosDupSet = lccPosDupSet; this.isGIIEvent = isGIIEvent; this.isPutDML = isPutDML; + this.skipConstraintChecks = skipConstraintChecks; this.routingObject = routingObject; } diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/index/MemIndexScanController.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/index/MemIndexScanController.java index 3d989aef8..7470b5fa3 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/index/MemIndexScanController.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/index/MemIndexScanController.java @@ -170,12 +170,11 @@ public final void init(GemFireTransaction tran, MemConglomerate conglomerate, if (GemFireXDUtils.TraceIndex) { GfxdIndexManager.traceIndex("Opening MemIndexScanController for index " + "container=%s, in mode=0x%s with scanColumnList=%s startKey=%s " - + "startOp=%s stopKey=%s stopOp=%s qualifier=%s tx=%s", + + "startOp=%s stopKey=%s stopOp=%s qualifier=%s", conglomerate.getGemFireContainer(), Integer.toHexString(openMode), scanColumnList, ArrayUtils.objectString(startKeyValue), startSearchOperator, ArrayUtils.objectString(stopKeyValue), - stopSearchOperator, ArrayUtils.objectString(qualifier), - tran.getActiveTXState()); + stopSearchOperator, ArrayUtils.objectString(qualifier)); } this.openMode = openMode; diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/index/SortedMap2IndexController.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/index/SortedMap2IndexController.java index 51c46310f..5f2f50a7f 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/index/SortedMap2IndexController.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/index/SortedMap2IndexController.java @@ -23,6 +23,7 @@ import com.pivotal.gemfirexd.internal.engine.store.GemFireContainer; import com.pivotal.gemfirexd.internal.iapi.error.StandardException; import com.pivotal.gemfirexd.internal.iapi.reference.SQLState; +import com.pivotal.gemfirexd.internal.iapi.sql.conn.LanguageConnectionContext; import com.pivotal.gemfirexd.internal.iapi.store.access.ConglomerateController; import com.pivotal.gemfirexd.internal.iapi.types.DataValueDescriptor; import com.pivotal.gemfirexd.internal.iapi.types.DataValueFactory; @@ -69,13 +70,16 @@ protected int doInsert(DataValueDescriptor[] row) throws StandardException { assert rowLocation != DataValueFactory.DUMMY; try { final GemFireTransaction tran = this.open_conglom.getTransaction(); + final LanguageConnectionContext lcc = tran.getLanguageConnectionContext(); + final boolean skipConstraintChecks = lcc != null && lcc.isSkipConstraintChecks(); final GemFireContainer container = this.open_conglom .getGemFireContainer(); // this path is only taken for DataDictionary ops, so // isPutDML/skipConstraintChecks are always false SortedMap2IndexInsertOperation.doMe(tran, container.getActiveTXState(tran), container, key, rowLocation, - this.open_conglom.isUnique(), null, false /* isPutDML */); + this.open_conglom.isUnique(), null, + false /* isPutDML */, skipConstraintChecks); } catch (StandardException se) { if (SQLState.LANG_DUPLICATE_KEY_CONSTRAINT.equals(se.getMessageId())) { // for system tables return back ROWISDUPLICATE else throw back the diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/index/SortedMap2IndexScanController.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/index/SortedMap2IndexScanController.java index c02ab9b21..fa96a3652 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/index/SortedMap2IndexScanController.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/index/SortedMap2IndexScanController.java @@ -863,7 +863,7 @@ static abstract class AbstractRowLocationIterator { public static final RowLocation isRowLocationValidForTransaction( final RowLocation rl, final TXId rlTXId, final TXStateInterface tx, - final int openMode) { + final int openMode, final boolean isUniqIndex) { RowLocation ret = null; final boolean sameTransaction = tx != null && rlTXId.equals(tx.getTransactionId()); @@ -904,6 +904,10 @@ public static final RowLocation isRowLocationValidForTransaction( } if (sameTransaction) { ret = rl; + // check if it is a case of unique index and then see if the underlying region entry + // should be returned or not. + } else if (isUniqIndex) { + ret = (RowLocation) ((GfxdTXEntryState)rl).getCommittedEntry(); } } return ret; @@ -912,7 +916,7 @@ public static final RowLocation isRowLocationValidForTransaction( public static final RowLocation isRowLocationValid(RowLocation rowloc, final LanguageConnectionContext lcc, final TXStateInterface tx, final GemFireContainer container, final boolean[] localBucketSet, - final int openMode) { + final int openMode, final OpenMemIndex openConglom) { final TXId rlTXId; if (GemFireXDUtils.TraceIndex) { @@ -927,7 +931,7 @@ public static final RowLocation isRowLocationValid(RowLocation rowloc, // below will tell whether RowLocation has to be skipped for this // transaction and also unwrap a TX deleted row if required rowloc = isRowLocationValidForTransaction(rowloc, rlTXId, tx, - openMode); + openMode, openConglom.isUnique()); if (rowloc == null) { if (GfxdTXStateProxy.LOG_FINEST | GemFireXDUtils.TraceIndex) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_INDEX, @@ -1012,7 +1016,7 @@ public RowLocation next() throws StandardException { for (;;) { if (this.index < this.rlArray.length) { RowLocation rl = isRowLocationValid(this.rlArray[this.index], lcc, - txState, this.container, this.localBucketSet, openMode); + txState, this.container, this.localBucketSet, openMode, openConglom); this.index++; if (rl != null) { return rl; @@ -1063,7 +1067,7 @@ public RowLocation next() throws StandardException { while (itrPos < itrLen) { RowLocation rl = (RowLocation)itrCache[itrPos++]; rl = isRowLocationValid(rl, lcc, txState, this.container, - this.localBucketSet, openMode); + this.localBucketSet, openMode, openConglom); if (rl != null) { return rl; } @@ -1075,7 +1079,7 @@ public RowLocation next() throws StandardException { else if ((itr = this.itr) != null) { while (itr.hasNext()) { RowLocation rl = isRowLocationValid((RowLocation)itr.next(), lcc, - txState, this.container, this.localBucketSet, openMode); + txState, this.container, this.localBucketSet, openMode, openConglom); if (rl != null) { return rl; } @@ -1265,7 +1269,7 @@ else if (valueCls == ConcurrentTHashSet.class) { this.rlIterator = null; if ((rl = AbstractRowLocationIterator.isRowLocationValid( (RowLocation)nextValue, lcc, this.txState, this.baseContainer, - this.localBucketSet, this.openMode)) != null) { + this.localBucketSet, this.openMode, openConglom)) != null) { //this.movedToNextIndexKey = true; ++this.scanKeyGroupID; return rl; @@ -1343,7 +1347,7 @@ private final RowLocation scanHashSet(final ConcurrentTHashSet set) if (set.contains(this.initRowLocation)) { return AbstractRowLocationIterator.isRowLocationValid( this.initRowLocation, lcc, this.txState, this.baseContainer, - this.localBucketSet, this.openMode); + this.localBucketSet, this.openMode, openConglom); } return null; } diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/operations/SortedMap2IndexInsertOperation.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/operations/SortedMap2IndexInsertOperation.java index 5d0f44c8f..6c0f53c9c 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/operations/SortedMap2IndexInsertOperation.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/access/operations/SortedMap2IndexInsertOperation.java @@ -18,18 +18,16 @@ package com.pivotal.gemfirexd.internal.engine.access.operations; import java.io.IOException; +import java.util.concurrent.Callable; +import java.util.concurrent.Future; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; import com.gemstone.gemfire.LogWriter; import com.gemstone.gemfire.cache.ConflictException; import com.gemstone.gemfire.cache.query.IndexMaintenanceException; import com.gemstone.gemfire.i18n.LogWriterI18n; -import com.gemstone.gemfire.internal.cache.AbstractRegionEntry; -import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; -import com.gemstone.gemfire.internal.cache.ObjectEqualsHashingStrategy; -import com.gemstone.gemfire.internal.cache.OffHeapRegionEntry; -import com.gemstone.gemfire.internal.cache.TXEntryState; -import com.gemstone.gemfire.internal.cache.TXId; -import com.gemstone.gemfire.internal.cache.TXStateInterface; +import com.gemstone.gemfire.internal.cache.*; import com.gemstone.gemfire.internal.cache.locks.ExclusiveSharedSynchronizer; import com.gemstone.gemfire.internal.cache.locks.LockMode; import com.gemstone.gemfire.internal.cache.locks.LockingPolicy; @@ -41,13 +39,13 @@ import com.gemstone.gemfire.internal.offheap.annotations.Released; import com.gemstone.gemfire.internal.offheap.annotations.Retained; import com.gemstone.gemfire.internal.util.ArrayUtils; -import com.pivotal.gemfirexd.internal.engine.Misc; import com.pivotal.gemfirexd.internal.engine.GemFireXDQueryObserver; import com.pivotal.gemfirexd.internal.engine.GemFireXDQueryObserverHolder; import com.pivotal.gemfirexd.internal.engine.GfxdConstants; +import com.pivotal.gemfirexd.internal.engine.Misc; import com.pivotal.gemfirexd.internal.engine.access.GemFireTransaction; -import com.pivotal.gemfirexd.internal.engine.access.index.SortedMap2Index; import com.pivotal.gemfirexd.internal.engine.access.index.GfxdIndexManager; +import com.pivotal.gemfirexd.internal.engine.access.index.SortedMap2Index; import com.pivotal.gemfirexd.internal.engine.access.operations.SortedMap2IndexDeleteOperation.UpdateReplacementValue; import com.pivotal.gemfirexd.internal.engine.distributed.utils.GemFireXDUtils; import com.pivotal.gemfirexd.internal.engine.store.CompactCompositeIndexKey; @@ -89,13 +87,13 @@ public SortedMap2IndexInsertOperation(GemFireContainer container, Object key, public void doMe(Transaction tran, LogInstant instant, LimitObjectInput in) throws StandardException, IOException { this.result = doMe(null, null, this.memcontainer, this.key, this.row, - this.isUnique, null, false /*isPutDML*/); + this.isUnique, null, false /* isPutDML */, false); } public static boolean doMe(GemFireTransaction tran, TXStateInterface tx, GemFireContainer container, Object key, RowLocation value, boolean isUnique, WrapperRowLocationForTxn wrapperToReplaceUniqEntry, - boolean isPutDML) throws StandardException { + boolean isPutDML, boolean skipConstraintChecks) throws StandardException { if (tran != null && tran.needLogging()) { SortedMap2IndexInsertOperation op = new SortedMap2IndexInsertOperation( container, key, value, isUnique); @@ -104,14 +102,15 @@ public static boolean doMe(GemFireTransaction tran, TXStateInterface tx, } return insertIntoSkipListMap(tx, container, key, value, isUnique, - wrapperToReplaceUniqEntry, isPutDML); + wrapperToReplaceUniqEntry, isPutDML, skipConstraintChecks); } private static boolean insertIntoSkipListMap(final TXStateInterface tx, final GemFireContainer container, Object key, final RowLocation value, final boolean isUnique, final WrapperRowLocationForTxn wrapperToReplaceUniqEntry, - boolean isPutDML) throws StandardException { + boolean isPutDML, boolean skipConstraintChecks) throws StandardException { + isPutDML |= skipConstraintChecks; final ConcurrentSkipListMap skipListMap = container .getSkipListMap(); long lockTimeout = -1L; @@ -163,7 +162,7 @@ private static boolean insertIntoSkipListMap(final TXStateInterface tx, container, null); } catch (IndexMaintenanceException ime) { if (isPutDML) { - // indicate to higher layer that don't try the delete portion + // indicate to higher layer to not try the delete portion if applicable return false; } // this always wraps a StandardException @@ -192,80 +191,99 @@ else if (oldValue != null) { final TXId txId, rlTXId; final RowLocation rl; if (tx != null && oldValue instanceof RowLocation - && (rlTXId = (rl = (RowLocation)oldValue).getTXId()) != null - && !rlTXId.equals(txId = tx.getTransactionId())) { - final LockingPolicy lockPolicy = tx.getLockingPolicy(); - if (lockTimeout < 0) { // not set - final AbstractRegionEntry re = (AbstractRegionEntry)rl - .getUnderlyingRegionEntry(); - final LockMode currentMode; - if (re == null || (currentMode = ExclusiveSharedSynchronizer - .getLockModeFromState(re.getState())) == null) { - throw GemFireXDUtils.newDuplicateKeyViolation("unique constraint", - container.getQualifiedTableName(), "key=" + key.toString() - + ", row=" + value, rl, null, null); - } - lockTimeout = lockPolicy.getTimeout(rl, - lockPolicy.getWriteLockMode(), currentMode, 0, 0); - waitThreshold = re.getWaitThreshold() * 1000; - if (lockTimeout < 0) { - lockTimeout = ExclusiveSharedSynchronizer.getMaxMillis(); - } - continue; - } - else if (lockTimeout > 0) { // wait before throwing conflict - final long sleepTime = lockTimeout < 5 ? lockTimeout : 5; - final long start = System.nanoTime(); - final GemFireCacheImpl cache = Misc.getGemFireCache(); - try { - Thread.sleep(sleepTime); - long elapsed = (System.nanoTime() - start + 500000) / 1000000; - if (elapsed <= 0) { - elapsed = 1; + && (rlTXId = (rl = (RowLocation) oldValue).getTXId()) != null) { + if (!rlTXId.equals(txId = tx.getTransactionId())) { + final LockingPolicy lockPolicy = tx.getLockingPolicy(); + if (lockTimeout < 0) { // not set + final AbstractRegionEntry re = (AbstractRegionEntry) rl + .getUnderlyingRegionEntry(); + final LockMode currentMode; + if (re == null || (currentMode = ExclusiveSharedSynchronizer + .getLockModeFromState(re.getState())) == null) { + throw GemFireXDUtils.newDuplicateKeyViolation("unique constraint", + container.getQualifiedTableName(), "key=" + key.toString() + + ", row=" + value, rl, null, null); } - final long origLockTimeout = lockTimeout; - if (lockTimeout < elapsed) { - lockTimeout = 0; + lockTimeout = lockPolicy.getTimeout(rl, + lockPolicy.getWriteLockMode(), currentMode, 0, 0); + waitThreshold = re.getWaitThreshold() * 1000; + if (lockTimeout < 0) { + lockTimeout = ExclusiveSharedSynchronizer.getMaxMillis(); } - else { - lockTimeout -= elapsed; - } - if (waitThreshold > 0) { - // check if there is a factor of waitThreshold between - // origLockTimeout and lockTimeout - final long origQuotient = origLockTimeout / waitThreshold; - final long quotient = lockTimeout / waitThreshold; - if (origQuotient > quotient - || (origLockTimeout % waitThreshold) == 0) { - final LogWriterI18n logger = cache.getLoggerI18n(); - if (logger.warningEnabled()) { - logger.warning(LocalizedStrings.LocalLock_Waiting, - new Object[] { "SortedMap2IndexInsertOperation", - Double.toString(waitThreshold / 1000.0), - lockPolicy.getWriteLockMode().toString(), - "index key with oldValue=" + ArrayUtils - .objectStringNonRecursive(oldValue) + ", owner=" - + rlTXId, ArrayUtils.objectString(key), - lockTimeout }); + continue; + } else if (lockTimeout > 0) { // wait before throwing conflict + final long sleepTime = lockTimeout < 5 ? lockTimeout : 5; + final long start = System.nanoTime(); + final GemFireCacheImpl cache = Misc.getGemFireCache(); + try { + Thread.sleep(sleepTime); + long elapsed = (System.nanoTime() - start + 500000) / 1000000; + if (elapsed <= 0) { + elapsed = 1; + } + final long origLockTimeout = lockTimeout; + if (lockTimeout < elapsed) { + lockTimeout = 0; + } else { + lockTimeout -= elapsed; + } + if (waitThreshold > 0) { + // check if there is a factor of waitThreshold between + // origLockTimeout and lockTimeout + final long origQuotient = origLockTimeout / waitThreshold; + final long quotient = lockTimeout / waitThreshold; + if (origQuotient > quotient + || (origLockTimeout % waitThreshold) == 0) { + final LogWriterI18n logger = cache.getLoggerI18n(); + if (logger.warningEnabled()) { + logger.warning(LocalizedStrings.LocalLock_Waiting, + new Object[]{"SortedMap2IndexInsertOperation", + Double.toString(waitThreshold / 1000.0), + lockPolicy.getWriteLockMode().toString(), + "index key with oldValue=" + ArrayUtils + .objectStringNonRecursive(oldValue) + ", owner=" + + rlTXId, ArrayUtils.objectString(key), + lockTimeout}); + } + // increase waitThreshold by a factor of 2 for next iteration + waitThreshold <<= 1; } - // increase waitThreshold by a factor of 2 for next iteration - waitThreshold <<= 1; } + } catch (InterruptedException ie) { + cache.getCancelCriterion().checkCancelInProgress(ie); + } + continue; + } + final ConflictException ce = new ConflictException( + LocalizedStrings.TX_CONFLICT_ON_OBJECT.toLocalizedString("index=" + + container + "; indexKey=" + ArrayUtils.objectString(key) + + "; having oldValue=" + ArrayUtils.objectStringNonRecursive( + oldValue) + "; owner TX=" + rlTXId + + "; requested for TX=" + txId, + lockPolicy.getWriteLockMode().toString())); + throw StandardException.newException( + SQLState.GFXD_OPERATION_CONFLICT, ce, ce.getMessage()); + } else { + if (oldValue instanceof WrapperRowLocationForTxn) { + GfxdTXEntryState gfxdtxentry = (GfxdTXEntryState)value; + gfxdtxentry.setCommittedRegionEntry( + ((WrapperRowLocationForTxn)oldValue).getUnderlyingRegionEntry()); + if (skipListMap.replace(key, oldValue, value)) { + // remove txentry, wrapper pair for reinstated map + // which is with TXRegionState + TXRegionState txrs = tx.readRegion((gfxdtxentry).getDataRegion()); + if (txrs.getToBeReinstatedIndexMap() != null) { + Object wrappedRL = ((WrapperRowLocationForTxn)oldValue).getWrappedRowLocation(); + txrs.getToBeReinstatedIndexMap().removeKeyPair(wrappedRL, container); + gfxdtxentry.updateIndexInfos(container, key); + } + break; + } + else { + continue; } - } catch (InterruptedException ie) { - cache.getCancelCriterion().checkCancelInProgress(ie); } - continue; } - final ConflictException ce = new ConflictException( - LocalizedStrings.TX_CONFLICT_ON_OBJECT.toLocalizedString("index=" - + container + "; indexKey=" + ArrayUtils.objectString(key) - + "; having oldValue=" + ArrayUtils.objectStringNonRecursive( - oldValue) + "; owner TX=" + rlTXId - + "; requested for TX=" + txId, - lockPolicy.getWriteLockMode().toString())); - throw StandardException.newException( - SQLState.GFXD_OPERATION_CONFLICT, ce, ce.getMessage()); } if (wrapperToReplaceUniqEntry != null) { // if existing value is already a wrapper then no need to replace; @@ -287,20 +305,52 @@ else if (lockTimeout > 0) { // wait before throwing conflict // TODO: identify the cause of Bug SNAP-2627 // Till then this is the crude fix - if (oldValue instanceof AbstractRegionEntry && - ((AbstractRegionEntry)oldValue).isDestroyedOrRemoved()) { - // create a dummy exception - Throwable th = GemFireXDUtils.newDuplicateKeyViolation("unique constraint", - container.getQualifiedTableName(), "key=" + key.toString() - + ", row=" + value, oldValue, null, null); - final GemFireCacheImpl cache = Misc.getGemFireCache(); - final LogWriter logger = cache.getLogger(); - logger.error("Unique index constraint violation caused due to " + - "removed/destroyed entry. The index is corrupted. Cleaning the index", th); - skipListMap.remove(key, oldValue); - continue; - } + if (oldValue instanceof AbstractRegionEntry) { + final AbstractRegionEntry existingRe = (AbstractRegionEntry)oldValue; + if (existingRe.isDestroyedOrRemoved()) { + Callable deadEntryRemover = new Callable() { + @Override + public Boolean call() { + synchronized (existingRe) { + if (existingRe.isDestroyedOrRemoved()) { + if (!existingRe.isRemovedPhase1()) { + // create a dummy exception + Throwable th = GemFireXDUtils.newDuplicateKeyViolation("unique constraint", + container.getQualifiedTableName(), "key=" + key.toString() + + ", row=" + value, oldValue, null, null); + final GemFireCacheImpl cache = Misc.getGemFireCache(); + final LogWriter logger = cache.getLogger(); + logger.error("Unique index constraint violation caused due to " + + "removed/destroyed entry. The index is corrupted. Cleaning the index", th); + + skipListMap.remove(key, oldValue); + } + return true; + } + + } + return false; + } + + }; + ThreadPoolExecutor executor = Misc.getGemFireCache() + .getWaitingThreadPoolOrDiskWritePool(); + try { + Future outcome = executor.submit(deadEntryRemover); + if (outcome.get(2000, TimeUnit.MILLISECONDS)) { + // either the entry was token removed or token destroyed, try again + continue; + } + } catch (Exception e) { + // not much can be done? let this thread throw duplicate key exception + } + } + } + if (skipConstraintChecks) { + // indicate to higher layer to not try the delete portion if applicable + return false; + } throw GemFireXDUtils.newDuplicateKeyViolation("unique constraint", container.getQualifiedTableName(), "key=" + key.toString() + ", row=" + value, oldValue, null, null); @@ -384,7 +434,7 @@ public static boolean replaceInSkipListMap(final GemFireContainer container, } } catch (IndexMaintenanceException ime) { if (isPutDML) { - // indicate to higher layer that don't try the delete portion + // indicate to higher layer to not try the delete portion if applicable return false; } // this always wraps a StandardException diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/build.sh b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/build.sh old mode 100644 new mode 100755 index 6dd8d086c..a18e3b509 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/build.sh +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/build.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash ################## # helper functions @@ -26,46 +26,75 @@ function absPath() { perl -MCwd -le 'print Cwd::abs_path(shift)' "$1" } +if [ "$JAVA_HOME" == "" ]; then + echo "ERROR: JAVA_HOME is not set" + exit 1; +fi + CURR_DIR=`pwd` -script_real_path==`absPath $0` +script_real_path=`absPath $0` # script home is assumed to be # /store/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ script_home=`dirname $script_real_path` -snappy_store_home=$script_home/../../../../../../../../../../ -gemfire_core_java=$snappy_store_home/gemfire-core/src/main/java/ -gemfirexd_core_java=$script_home/../../../../../ +snappy_store_home=$script_home/../../../../../../../../../.. +gemfire_core_java=$snappy_store_home/gemfire-core/src/main/java +gemfirexd_core_java=$snappy_store_home/gemfirexd/core/src/main/java +gemfirexd_core_lib=$snappy_store_home/gemfirexd/core/lib # modify below variables as per requirement gemfire_version="\"7.5.Beta\"" gemfire_buildid="\"1234\"" gemfire_builddate="\"2018-10-12\"" gemfire_buildos="\"linux\"" - -rm_if_exists $script_home/libgemfirexd.so -rm_if_exists $script_home/libgemfirexd64.so - +echo "WARNING: verify below values that are being used" +echo "gemfire_version=$gemfire_version" +echo "gemfire_buildid=$gemfire_buildid" +echo "gemfire_builddate=$gemfire_builddate" +echo "gemfire_buildos=$gemfire_buildos" # generate and fetch ./com_gemstone_gemfire_internal_NanoTimer.h cd $gemfire_core_java -javah -d $script_home/ com.gemstone.gemfire.internal.NanoTimer -is_file_generated $script_home/com_gemstone_gemfire_internal_NanoTimer.h +javah -d $gemfirexd_core_lib/ com.gemstone.gemfire.internal.NanoTimer +is_file_generated $gemfirexd_core_lib/com_gemstone_gemfire_internal_NanoTimer.h # generate and fetch com_pivotal_gemfirexd_internal_GemFireXDVersion.h cd $gemfirexd_core_java -javah -d $script_home/ com.pivotal.gemfirexd.internal.GemFireXDVersion -is_file_generated $script_home/com_pivotal_gemfirexd_internal_GemFireXDVersion.h +javah -d $gemfirexd_core_lib/ com.pivotal.gemfirexd.internal.GemFireXDVersion +is_file_generated $gemfirexd_core_lib/com_pivotal_gemfirexd_internal_GemFireXDVersion.h # generate so files cd $script_home +case "$(uname -s)" in + Darwin) + os_name="darwin" + rm_if_exists $gemfirexd_core_lib/libgemfirexd.dylib + rm_if_exists $gemfirexd_core_lib/libgemfirexd64.dylib + clang -DGEMFIRE_VERSION=$gemfire_version -DGEMFIRE_BUILDID=$gemfire_buildid -DGEMFIRE_BUILDDATE=$gemfire_builddate -DGEMFIRE_BUILDOS=$gemfire_buildos -m64 -O3 -fPIC -DPIC -D_REENTRANT -I $JAVA_HOME/include -I $JAVA_HOME/include/$os_name -I $gemfirexd_core_lib/ -dynamiclib utils.c jvmkill.c -o $gemfirexd_core_lib/libgemfirexd64.dylib + is_file_generated $gemfirexd_core_lib/libgemfirexd64.dylib -gcc -DGEMFIRE_VERSION=$gemfire_version -DGEMFIRE_BUILDID=$gemfire_buildid -DGEMFIRE_BUILDDATE=$gemfire_builddate -DGEMFIRE_BUILDOS=$gemfire_buildos -m32 -O3 -fPIC -DPIC -D_REENTRANT -I $JAVA_HOME/include -I $JAVA_HOME/include/linux -I $script_home/ -shared utils.c jvmkill.c -o libgemfirexd.so -is_file_generated $script_home/libgemfirexd.so + clang -DGEMFIRE_VERSION=$gemfire_version -DGEMFIRE_BUILDID=$gemfire_buildid -DGEMFIRE_BUILDDATE=$gemfire_builddate -DGEMFIRE_BUILDOS=$gemfire_buildos -m32 -O3 -fPIC -DPIC -D_REENTRANT -I $JAVA_HOME/include -I $JAVA_HOME/include/$os_name -I $gemfirexd_core_lib/ -dynamiclib utils.c jvmkill.c -o $gemfirexd_core_lib/libgemfirexd.dylib + is_file_generated $gemfirexd_core_lib/libgemfirexd.dylib -gcc -DGEMFIRE_VERSION=$gemfire_version -DGEMFIRE_BUILDID=$gemfire_buildid -DGEMFIRE_BUILDDATE=$gemfire_builddate -DGEMFIRE_BUILDOS=$gemfire_buildos -m64 -O3 -fPIC -DPIC -D_REENTRANT -I $JAVA_HOME/include -I $JAVA_HOME/include/linux -I $script_home/ -shared utils.c jvmkill.c -o libgemfirexd64.so -is_file_generated $script_home/libgemfirexd64.so + chmod -x $gemfirexd_core_lib/*.dylib + ;; + Linux) + os_name="linux" + rm_if_exists $gemfirexd_core_lib/libgemfirexd.so + rm_if_exists $gemfirexd_core_lib/libgemfirexd64.so + gcc -DGEMFIRE_VERSION=$gemfire_version -DGEMFIRE_BUILDID=$gemfire_buildid -DGEMFIRE_BUILDDATE=$gemfire_builddate -DGEMFIRE_BUILDOS=$gemfire_buildos -m32 -O3 -fPIC -DPIC -D_REENTRANT -I $JAVA_HOME/include -I $JAVA_HOME/include/$os_name -I $gemfirexd_core_lib/ -shared utils.c jvmkill.c -o $gemfirexd_core_lib/libgemfirexd.so + is_file_generated $gemfirexd_core_lib/libgemfirexd.so -chmod -x *.so + gcc -DGEMFIRE_VERSION=$gemfire_version -DGEMFIRE_BUILDID=$gemfire_buildid -DGEMFIRE_BUILDDATE=$gemfire_builddate -DGEMFIRE_BUILDOS=$gemfire_buildos -m64 -O3 -fPIC -DPIC -D_REENTRANT -I $JAVA_HOME/include -I $JAVA_HOME/include/$os_name -I $gemfirexd_core_lib/ -shared utils.c jvmkill.c -o $gemfirexd_core_lib/libgemfirexd64.so + is_file_generated $gemfirexd_core_lib/libgemfirexd64.so + + chmod -x $gemfirexd_core_lib/*.so + ;; + *) + echo "ERROR: kernel not recognized" + exit 1 + ;; +esac # go back to initial working dir cd $CURR_DIR diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/db/FabricDatabase.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/db/FabricDatabase.java index 3f17f559c..7b155d108 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/db/FabricDatabase.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/db/FabricDatabase.java @@ -440,11 +440,12 @@ synchronized public void postCreate( notifyRunning(); return; } + final GemFireCacheImpl cache = GemFireCacheImpl.getExisting(); + final LogWriter logger = cache.getLogger(); + final EmbedConnection embedConn = (EmbedConnection)conn; + List postMsgs = null; try { - final EmbedConnection embedConn = (EmbedConnection)conn; - final GemFireCacheImpl cache = GemFireCacheImpl.getExisting(); - final LogWriter logger = cache.getLogger(); final LanguageConnectionContext lcc = embedConn.getLanguageConnection(); final GemFireTransaction tc = (GemFireTransaction)lcc .getTransactionExecute(); @@ -488,7 +489,7 @@ synchronized public void postCreate( else { this.memStore.getDDLStmtQueue().initializeQueue(this.dd); } - postCreateDDLReplay(embedConn, bootProps, lcc, tc, logger); + postMsgs = postCreateDDLReplay(embedConn, bootProps, lcc, tc, logger); } finally { if (ddReadLockAcquired) { this.dd.unlockAfterReading(null); @@ -508,7 +509,7 @@ synchronized public void postCreate( initializeCatalog(); } catch (Throwable t) { try { - LogWriter logger = Misc.getCacheLogWriter(); + if (logger != null) { logger.warning("got throwable: " + t.getMessage() + " calling shut down", t); } @@ -539,6 +540,30 @@ synchronized public void postCreate( throw StandardException.newException(SQLState.BOOT_DATABASE_FAILED, t, Attribute.GFXD_DBNAME); } + + + for (GfxdSystemProcedureMessage msg : postMsgs) { + if (msg.getSysProcMethod().isOffHeapMethod() + && this.memStore.getGemFireCache().getOffHeapStore() == null) { + if (logger.severeEnabled()) { + logger.severe("FabricDatabase: aborted initial replay " + + "for message " + msg + " method " + + msg.getSysProcMethod().name()); + } + continue; + } + try { + msg.execute(); + } catch (Exception ex) { + if (logger.severeEnabled()) { + logger.severe("FabricDatabase: failed initial replay " + + "for message " + msg + " due to exception", ex); + } + throw StandardException.newException(SQLState.BOOT_DATABASE_FAILED, ex, + Attribute.GFXD_DBNAME); + } + } + } private Region createSnappySpecificGlobalCmdRegion(boolean isLead) throws IOException, ClassNotFoundException { @@ -653,12 +678,12 @@ public static void checkSnappyCatalogConsistency(EmbedConnection embedConn, final LanguageConnectionContext lcc = embedConn.getLanguageConnection(); final GemFireTransaction tc = (GemFireTransaction)lcc .getTransactionExecute(); - HashMap> hiveDBTablesMap = null; - HashMap> gfDBTablesMap = null; + Map> hiveDBTablesMap; + Map> gfDBTablesMap; try { lcc.getDataDictionary().lockForReading(tc); - hiveDBTablesMap = externalCatalog.getAllStoreTablesInCatalog(true); + hiveDBTablesMap = externalCatalog.getAllStoreTablesInCatalogUppercase(); gfDBTablesMap = getAllGFXDTables(); } finally { lcc.getDataDictionary().unlockAfterReading(tc); @@ -682,15 +707,13 @@ public static void checkSnappyCatalogConsistency(EmbedConnection embedConn, } // creating a set here just for lookup, will not consume too much // memory as size limited by no of tables - Set internalColumnTablesSet = new HashSet<>(); - if (internalColumnTablesList != null) { - internalColumnTablesSet.addAll(internalColumnTablesList); - } + Set internalColumnTablesSet = new HashSet<>(internalColumnTablesList); // SanityManager.DEBUG_PRINT("info", "tables in hive store = " + hiveDBTablesMap); // SanityManager.DEBUG_PRINT("info", "tables in DD = " + gfDBTablesMap); removeInconsistentDDEntries(embedConn, hiveDBTablesMap, - gfDBTablesMap, internalColumnTablesSet, externalCatalog, removeInconsistentEntries, removeTablesWithData); + gfDBTablesMap, internalColumnTablesSet, externalCatalog, + removeInconsistentEntries, removeTablesWithData); removeInconsistentHiveEntries(hiveDBTablesMap, gfDBTablesMap, externalCatalog, removeInconsistentEntries, removeTablesWithData); } @@ -708,8 +731,8 @@ public static void checkSnappyCatalogConsistency(EmbedConnection embedConn, * @throws SQLException */ private static void removeInconsistentDDEntries(EmbedConnection embedConn, - HashMap> hiveDBTablesMap, - HashMap> gfDBTablesMap, + Map> hiveDBTablesMap, + Map> gfDBTablesMap, Set internalColumnTablesSet, ExternalCatalog externalCatalog, boolean removeInconsistentEntries, boolean removeTablesWithData) throws SQLException { @@ -773,8 +796,8 @@ private static void removeInconsistentDDEntries(EmbedConnection embedConn, * @param removeTablesWithData remove entries for tables even if there is data in tables */ private static void removeInconsistentHiveEntries( - HashMap> hiveDBTablesMap, - HashMap> gfDBTablesMap, + Map> hiveDBTablesMap, + Map> gfDBTablesMap, ExternalCatalog externalCatalog, boolean removeInconsistentEntries, boolean removeTablesWithData) { // remove tables that are in Hive store but not in datadictionary for (Map.Entry> hiveEntry : hiveDBTablesMap.entrySet()) { @@ -810,7 +833,7 @@ private static final void removeTableFromHivestore(String schema, for (String table : tables) { SanityManager.DEBUG_PRINT("warning:CATALOG", "Removing table " + schema + "." + table + " from Hive metastore"); - externalCatalog.removeTable(schema, table, false); + externalCatalog.removeTableIfExists(schema, table, false); } } @@ -891,7 +914,7 @@ private static final HashMap> getAllGFXDTables() { * Replays the initial DDL received by GII from other nodes or recovered from * disc. */ - private void postCreateDDLReplay(final EmbedConnection embedConn, + private List postCreateDDLReplay(final EmbedConnection embedConn, final Properties bootProps, final LanguageConnectionContext lcc, final GemFireTransaction tc, final LogWriter logger) throws Exception { @@ -972,7 +995,7 @@ private void postCreateDDLReplay(final EmbedConnection embedConn, final LinkedHashSet uninitializedTables = new LinkedHashSet(); final Statement stmt = embedConn.createStatement(); - + List postMessages = new ArrayList<>(); try { // commenting out for snap-585 /* @@ -1069,6 +1092,7 @@ private void postCreateDDLReplay(final EmbedConnection embedConn, .getPreprocessedDDLQueue(currentQueue, skipRegionInit, lastCurrentSchema, pre11TableSchemaVer, traceConflation); + for (GfxdDDLQueueEntry entry : preprocessedQueue) { qEntry = entry; Object qVal = qEntry.getValue(); @@ -1085,6 +1109,10 @@ private void postCreateDDLReplay(final EmbedConnection embedConn, if (qVal instanceof GfxdSystemProcedureMessage) { final GfxdSystemProcedureMessage msg = (GfxdSystemProcedureMessage)qVal; + if (msg.postprocess()) { + postMessages.add(msg); + continue; + } if (msg.getSysProcMethod().isOffHeapMethod() && this.memStore.getGemFireCache().getOffHeapStore() == null) { if (logger.severeEnabled()) { @@ -1502,12 +1530,13 @@ else if (qVal instanceof AbstractGfxdReplayableMessage) { stmt.close(); // Setting this to false so that the waiting compactor thread finishes this.memStore.setInitialDDLReplayInProgress(false); - } + // restore the original schema if required + if (!ArrayUtils.objectEquals(initSchema, lcc.getCurrentSchemaName())) { + FabricDatabase.setupDefaultSchema(dd, lcc, tc, initSchema, true); + } - // restore the original schema if required - if (!ArrayUtils.objectEquals(initSchema, lcc.getCurrentSchemaName())) { - FabricDatabase.setupDefaultSchema(dd, lcc, tc, initSchema, true); } + return postMessages; } private void checkRecoveredIndex(ArrayList uninitializedContainers, @@ -1865,8 +1894,12 @@ synchronized public void stop() { // Clean up GemFireXD MBeans if management was not disabled //GfxdManagementService.handleEvent(GfxdResourceEvent.FABRIC_DB__STOP, this.memStore); active = false; - tempDir.deleteAll(); - tempDir = null; + final DirFile tempDir = this.tempDir; + if (tempDir != null) { + // noinspection ResultOfMethodCallIgnored + tempDir.deleteAll(); + this.tempDir = null; + } runtimeStatisticsOn = false; } @@ -2547,8 +2580,8 @@ public DirFile run() throws IOException { .nextInt(Integer.MAX_VALUE); final DirFile df = new DirFile(tDir, TEMP_DIR_PREFIX + Integer.toString(rl) + ".d"); - df.deleteOnExit(); if (df.mkdirs()) { + df.deleteOnExit(); assert df.canWrite(); return df; } diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ddl/DDLConflatable.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ddl/DDLConflatable.java index 71a3b843e..c34eb2f51 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ddl/DDLConflatable.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ddl/DDLConflatable.java @@ -60,7 +60,7 @@ * @author swale */ public final class DDLConflatable extends GfxdDataSerializable implements - ReplayableConflatable, GfxdDDLPreprocess { + ReplayableConflatable, GfxdDDLPreprocessOrPostProcess { private static final long serialVersionUID = -7222789225768258894L; @@ -278,6 +278,7 @@ else if (constantAction instanceof CreateIndexConstantAction) { || (this.isDropStatement && constantAction.isDropIfExists()) || (this.fullTableName != null) : "Expected " + "a non-null schema/table name when conflation is requested"; + // assert !(preprocess() && postprocess()); } /** @@ -385,7 +386,7 @@ public boolean shouldBeMerged() { public boolean merge(Conflatable existing) { if (GemFireXDUtils.TraceConflation | DistributionManager.VERBOSE) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_CONFLATION, - "DDLConflatable#merge called this=" + this + + "DDLConflatable#merge called this=" + this + " existing conflatable=" + existing ); } assert ((DDLConflatable) existing).isAlterTableDropFKConstraint(); @@ -540,6 +541,11 @@ public boolean preprocess() { return isCreateSchemaText(); } + public boolean postprocess() { + // only "CREATE SCHEMA" is pre-processed + return false; + } + @Override public int hashCode() { // ddlId is zero for old product version in which case use SQL text diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ddl/GfxdDDLMessage.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ddl/GfxdDDLMessage.java index aa0b3f14a..5ff50b729 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ddl/GfxdDDLMessage.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ddl/GfxdDDLMessage.java @@ -22,7 +22,10 @@ import java.io.IOException; import java.sql.SQLException; import java.sql.Statement; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; import com.gemstone.gemfire.DataSerializer; import com.gemstone.gemfire.GemFireCheckedException; @@ -59,7 +62,7 @@ import com.pivotal.gemfirexd.internal.impl.jdbc.EmbedConnection; import com.pivotal.gemfirexd.internal.impl.jdbc.EmbedStatement; import com.pivotal.gemfirexd.internal.shared.common.sanity.SanityManager; -import io.snappydata.collection.LongObjectHashMap; +import org.eclipse.collections.impl.map.mutable.primitive.LongObjectHashMap; /** * {@link DistributionMessage} for sending GemFireXD DDL statements to members @@ -95,7 +98,7 @@ public final class GfxdDDLMessage extends GfxdMessage implements * pending commit/rollback messages. */ private static final LongObjectHashMap pendingDDLMessages = - LongObjectHashMap.withExpectedSize(4); + new LongObjectHashMap<>(4); /** * MembershipListener to commit/rollback DDLs if node fails before sending @@ -269,7 +272,7 @@ protected void processMessage(final DistributionManager dm) // indicates that this node should not execute anything in finish // message or if origin node goes down before finish message this.args.connId = EmbedConnection.UNINITIALIZED; - pendingDDLMessages.justPut(ddlId, this); + pendingDDLMessages.put(ddlId, this); } return; } @@ -358,7 +361,7 @@ protected void processMessage(final DistributionManager dm) // add self as the pending message to handle sender failure before // DDL commit/rollback synchronized (pendingDDLMessages) { - pendingDDLMessages.justPut(ddlId, this); + pendingDDLMessages.put(ddlId, this); } } if (GemFireXDUtils.TraceDDLReplay) { @@ -450,7 +453,7 @@ protected void handleProcessorReplyException(String exPrefix, static GfxdDDLMessage removePendingDDLMessage(final long ddlId) { synchronized (pendingDDLMessages) { - return pendingDDLMessages.remove(ddlId); + return pendingDDLMessages.removeKey(ddlId); } } @@ -587,12 +590,11 @@ public void memberDeparted(final InternalDistributedMember member, final ArrayList memberPendingMessages = new ArrayList(4); synchronized (pendingDDLMessages) { - pendingDDLMessages.forEachWhile((ddlId, pendingMessage) -> { + pendingDDLMessages.forEachKeyValue((ddlId, pendingMessage) -> { if (member.equals(pendingMessage.getSender())) { memberPendingMessages.add(pendingMessage); - pendingDDLMessages.remove(ddlId); + pendingDDLMessages.removeKey(ddlId); } - return true; }); } @@ -608,7 +610,7 @@ public void memberDeparted(final InternalDistributedMember member, if (doCommit) { actionStr = "committed"; GfxdDDLFinishMessage.doPutInDDLRegion( - Long.valueOf(pendingMessage.args.id), pendingMessage.args.ddl, + pendingMessage.args.id, pendingMessage.args.ddl, -1, "MembershipListener for DDLs:"); } else { diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ddl/GfxdDDLPreprocess.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ddl/GfxdDDLPreprocessOrPostProcess.java similarity index 93% rename from gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ddl/GfxdDDLPreprocess.java rename to gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ddl/GfxdDDLPreprocessOrPostProcess.java index 24901b604..a190f0a91 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ddl/GfxdDDLPreprocess.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ddl/GfxdDDLPreprocessOrPostProcess.java @@ -25,7 +25,7 @@ * @author swale * @since 7.5 */ -public interface GfxdDDLPreprocess { +public interface GfxdDDLPreprocessOrPostProcess { /** * @return if this message/object should be pre-processed in the DDL queue @@ -33,6 +33,8 @@ public interface GfxdDDLPreprocess { */ public boolean preprocess(); + public boolean postprocess(); + /** Get a string representation of this message/object */ public void appendFields(StringBuilder sb); } diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ddl/GfxdDDLRegionQueue.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ddl/GfxdDDLRegionQueue.java index 1bb587820..53a23c4dc 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ddl/GfxdDDLRegionQueue.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ddl/GfxdDDLRegionQueue.java @@ -796,7 +796,7 @@ public List getPreprocessedDDLQueue( final ArrayList preprocessedQueue = new ArrayList(); ListIterator iter = currentQueue.listIterator(); - GfxdDDLPreprocess preprocessMsg; + GfxdDDLPreprocessOrPostProcess preprocessMsg; if (currentSchema == null) { currentSchema = SchemaDescriptor.STD_DEFAULT_SCHEMA_NAME; } @@ -812,8 +812,8 @@ public List getPreprocessedDDLQueue( } } // system/jar procedures should be executed at the start - if (qVal instanceof GfxdDDLPreprocess - && (preprocessMsg = (GfxdDDLPreprocess)qVal).preprocess()) { + if (qVal instanceof GfxdDDLPreprocessOrPostProcess + && (preprocessMsg = (GfxdDDLPreprocessOrPostProcess)qVal).preprocess()) { if (pre11TableSchemaVer != null && preprocessMsg instanceof GfxdSystemProcedureMessage) { GfxdSystemProcedureMessage m = (GfxdSystemProcedureMessage)qVal; diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ddl/catalog/GfxdSystemProcedures.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ddl/catalog/GfxdSystemProcedures.java index 1bad9762a..97a5cff11 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ddl/catalog/GfxdSystemProcedures.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ddl/catalog/GfxdSystemProcedures.java @@ -17,9 +17,6 @@ package com.pivotal.gemfirexd.internal.engine.ddl.catalog; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectOutputStream; import java.sql.Blob; import java.sql.Clob; import java.sql.Connection; @@ -33,7 +30,6 @@ import java.util.concurrent.Future; import javax.annotation.Nonnull; -import com.gemstone.gemfire.DataSerializer; import com.gemstone.gemfire.cache.CacheException; import com.gemstone.gemfire.cache.EvictionAttributes; import com.gemstone.gemfire.cache.IsolationLevel; @@ -45,13 +41,13 @@ import com.gemstone.gemfire.distributed.DistributedMember; import com.gemstone.gemfire.distributed.internal.ServerLocation; import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember; +import com.gemstone.gemfire.internal.Assert; import com.gemstone.gemfire.internal.NanoTimer; import com.gemstone.gemfire.internal.cache.*; import com.gemstone.gemfire.internal.cache.control.InternalResourceManager; import com.gemstone.gemfire.internal.cache.persistence.query.CloseableIterator; import com.gemstone.gemfire.internal.snappy.CallbackFactoryProvider; import com.gemstone.gemfire.internal.snappy.ColumnTableEntry; -import com.gemstone.gnu.trove.THashSet; import com.gemstone.gnu.trove.TIntArrayList; import com.pivotal.gemfirexd.Attribute; import com.pivotal.gemfirexd.auth.callback.UserAuthenticator; @@ -68,24 +64,19 @@ import com.pivotal.gemfirexd.internal.engine.ddl.GfxdDDLRegionQueue; import com.pivotal.gemfirexd.internal.engine.ddl.callbacks.CallbackProcedures; import com.pivotal.gemfirexd.internal.engine.ddl.catalog.messages.GfxdSystemProcedureMessage; -import com.pivotal.gemfirexd.internal.engine.ddl.resolver.GfxdPartitionByExpressionResolver; import com.pivotal.gemfirexd.internal.engine.ddl.wan.messages.AbstractGfxdReplayableMessage; -import com.pivotal.gemfirexd.internal.engine.distributed.AckResultCollector; -import com.pivotal.gemfirexd.internal.engine.distributed.ByteArrayDataOutput; -import com.pivotal.gemfirexd.internal.engine.distributed.GfxdDistributionAdvisor; import com.pivotal.gemfirexd.internal.engine.distributed.GfxdListResultCollector; import com.pivotal.gemfirexd.internal.engine.distributed.GfxdMessage; import com.pivotal.gemfirexd.internal.engine.distributed.QueryCancelFunction; import com.pivotal.gemfirexd.internal.engine.distributed.QueryCancelFunction.QueryCancelFunctionArgs; import com.pivotal.gemfirexd.internal.engine.distributed.message.GetLeadNodeInfoAsStringMessage; -import com.pivotal.gemfirexd.internal.engine.distributed.message.LeadNodeGetStatsMessage; -import com.pivotal.gemfirexd.internal.engine.distributed.message.LeadNodeSmartConnectorOpMsg; import com.pivotal.gemfirexd.internal.engine.distributed.utils.GemFireXDUtils; import com.pivotal.gemfirexd.internal.engine.distributed.utils.SecurityUtils; import com.pivotal.gemfirexd.internal.engine.jdbc.GemFireXDRuntimeException; import com.pivotal.gemfirexd.internal.engine.store.CustomRowsResultSet; import com.pivotal.gemfirexd.internal.engine.store.GemFireContainer; import com.pivotal.gemfirexd.internal.engine.store.GemFireStore; +import com.pivotal.gemfirexd.internal.engine.store.ServerGroupUtils; import com.pivotal.gemfirexd.internal.iapi.db.PropertyInfo; import com.pivotal.gemfirexd.internal.iapi.error.PublicAPI; import com.pivotal.gemfirexd.internal.iapi.error.StandardException; @@ -113,36 +104,45 @@ import com.pivotal.gemfirexd.internal.impl.jdbc.authentication.AuthenticationServiceBase; import com.pivotal.gemfirexd.internal.impl.jdbc.authentication.LDAPAuthenticationSchemeImpl; import com.pivotal.gemfirexd.internal.impl.sql.catalog.GfxdDataDictionary; +import com.pivotal.gemfirexd.internal.impl.sql.conn.GenericLanguageConnectionContext; import com.pivotal.gemfirexd.internal.impl.sql.execute.JarUtil; import com.pivotal.gemfirexd.internal.impl.store.raw.data.GfxdJarMessage; import com.pivotal.gemfirexd.internal.jdbc.InternalDriver; import com.pivotal.gemfirexd.internal.shared.common.SharedUtils; import com.pivotal.gemfirexd.internal.shared.common.reference.SQLState; import com.pivotal.gemfirexd.internal.shared.common.sanity.SanityManager; -import com.pivotal.gemfirexd.internal.snappy.LeadNodeSmartConnectorOpContext; import com.pivotal.gemfirexd.load.Import; +import io.snappydata.thrift.BucketOwners; +import io.snappydata.thrift.CatalogMetadataDetails; +import io.snappydata.thrift.CatalogMetadataRequest; +import io.snappydata.thrift.CatalogTableObject; import io.snappydata.thrift.ServerType; import io.snappydata.thrift.internal.ClientBlob; +import io.snappydata.thrift.snappydataConstants; +import org.apache.log4j.Logger; +import org.eclipse.collections.impl.set.mutable.UnifiedSet; /** * GemFireXD built-in system procedures that will get executed on every * distributed member. - * + * * @author soubhikc */ -@SuppressWarnings("unused") +@SuppressWarnings({ "unused", "WeakerAccess" }) public class GfxdSystemProcedures extends SystemProcedures { + public static final Logger logger = Logger.getLogger(GfxdSystemProcedures.class); + /** * Create distributed system users to authenticate connections and also * authenticate join request to peer members. These users will not become a * distributed system owner and hence limited by authorizations granted to * them by the system administrative users. - * + * *

* A system administrative user connection can only create/drop distributed * system users or grant/revoke privileges from these users. - * + * * @param userID * User login id (also used as authorization id).
*
@@ -168,9 +168,8 @@ public class GfxdSystemProcedures extends SystemProcedures { * {@link com.pivotal.gemfirexd.Constants#AUTHENTICATION_PROVIDER_LDAP * LDAP} scheme uses ldap server to verify credentials passed in * during connection. - * - * @throws SQLException - * @see {@link #DROP_USER(String)} + * + * @see #DROP_USER(String) */ public static void CREATE_USER(String userID, String password) throws SQLException { @@ -179,7 +178,7 @@ public static void CREATE_USER(String userID, String password) SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_AUTHENTICATION, "executing SYS.CREATE_USER for " + userID); } - + // A null userid is illegal but should not disconnect from current connection if (userID == null) { @@ -218,9 +217,9 @@ public static void CREATE_USER(String userID, String password) * otherwise 'null'. So pass the key as value to remote hosts because * there too password won't be stored. Later, when credentials are passed * password shall be authenticated by external source. - * + * * leaving it to NULL here will remove the users in remote VMs. - * + * * hyphened so that it can't be used as key & this value will go to void as * it has here. */ @@ -228,13 +227,11 @@ public static void CREATE_USER(String userID, String password) encryptedpwd = "--W-O-NTS-TOR-E-" + userID; } - if ( // for ldap, value can be un-encrypted non-null and equal to value // because LDAP scheme uses the same gemfirexd.user. prefixed short // user name to capture full user DN. // i.e. gemfirexd.user.xxx= - isBUILTIN) { - + if (isBUILTIN) { if (encryptedpwd.equals(password) && !AuthenticationServiceBase.isEncrypted(password)) { SanityManager @@ -252,7 +249,7 @@ public static void CREATE_USER(String userID, String password) publishMessage(new Object[] { userID, encryptedpwd }, false, GfxdSystemProcedureMessage.SysProcMethod.createUser, true, true); cleanupOnError = false; - + if (GemFireXDUtils.TraceAuthentication) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_AUTHENTICATION, "returning from SYS.CREATE_USER(" + userID + "," + encryptedpwd @@ -266,7 +263,7 @@ public static void CREATE_USER(String userID, String password) } finally { if (cleanupOnError) { // create_user failed for some reason, so nullify the definition in local VM - PropertyInfo.setDatabaseProperty(userID, null, false); + PropertyInfo.setDatabaseProperty(userID, null, false); } if (ddLocked) { try { @@ -282,11 +279,11 @@ public static void CREATE_USER(String userID, String password) /** * Change a distributed system users password credential. This definition is * effective for BUILTIN scheme only. - * + * *

* A system administrative user connection can change any users password * otherwise user can only change his/her own password. - * + * * @param userID * User login id (also used as authorization id).
*
@@ -314,9 +311,8 @@ public static void CREATE_USER(String userID, String password) * @param newPassword * User identification new password that will be used for subsequent * new connection validation. - * - * @throws SQLException - * @see {@link #CREATE_USER(String, String)} + * + * @see #CREATE_USER(String, String) */ public static void CHANGE_PASSWORD(String userID, String oldPassword, String newPassword) throws SQLException { @@ -325,7 +321,7 @@ public static void CHANGE_PASSWORD(String userID, String oldPassword, SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_AUTHENTICATION, "executing SYS.CHANGE_PASSWORD for " + userID); } - + // A null userid is illegal but should not disconnect from current connection if (userID == null) { @@ -358,7 +354,7 @@ public static void CHANGE_PASSWORD(String userID, String oldPassword, // always allow self to change own password, else check if the user has // permissions to change someone else's password final String authorizationId = lcc.getAuthorizationId(); - final String userName = getUserName(userID, isBUILTIN); + final String userName = getBUILTINUserName(userID); if (lcc.usesSqlAuthorization() && !authorizationId.equals(IdUtil.getUserAuthorizationId(userName))) { List list = dd.getRoutineList(dd.getSystemSchemaDescriptor() @@ -385,7 +381,7 @@ else if (!lcc.usesSqlAuthorization()) { } } - userID = IdUtil.getDBUserId(userID, isBUILTIN); + userID = IdUtil.getDBUserId(userID, true); AuthenticationServiceBase .validateUserPassword(userID, newPassword, false); @@ -421,9 +417,9 @@ else if (!lcc.usesSqlAuthorization()) { * otherwise 'null'. So pass the key as value to remote hosts because * there too password won't be stored. Later, when credentials are passed * password shall be authenticated by external source. - * + * * leaving it to NULL here will remove the users in remote VMs. - * + * * hyphened so that it can't be used as key & this value will go to void as * it has here. */ @@ -479,12 +475,10 @@ else if (!lcc.usesSqlAuthorization()) { /** * Drop a distributed system users created via * {@link #CREATE_USER(String,String)}. - * + * * @param userID * Existing user ID that must be dropped. - * - * @throws SQLException - * @throws StandardException + * * @see #CREATE_USER(String, String) */ public static void DROP_USER(String userID) throws SQLException { @@ -552,15 +546,13 @@ public static void DROP_USER(String userID) throws SQLException { } } - private static String getUserName(String userID, boolean isBUILTIN) { - if (isBUILTIN) { - if (userID.startsWith(Property.USER_PROPERTY_PREFIX)) { - userID = userID.substring(Property.USER_PROPERTY_PREFIX.length()); - } - //SQLF:BC - else if (userID.startsWith(Property.SQLF_USER_PROPERTY_PREFIX)) { - userID = userID.substring(Property.SQLF_USER_PROPERTY_PREFIX.length()); - } + private static String getBUILTINUserName(String userID) { + if (userID.startsWith(Property.USER_PROPERTY_PREFIX)) { + userID = userID.substring(Property.USER_PROPERTY_PREFIX.length()); + } + //SQLF:BC + else if (userID.startsWith(Property.SQLF_USER_PROPERTY_PREFIX)) { + userID = userID.substring(Property.SQLF_USER_PROPERTY_PREFIX.length()); } return userID; } @@ -569,10 +561,10 @@ else if (userID.startsWith(Property.SQLF_USER_PROPERTY_PREFIX)) { * Show all distributed system users using BUILTIN authentication scheme * created via {@link #CREATE_USER(String,String)}, or defined via system * property. - * + * * @param users * Returned set of users. - * + * * @see #CREATE_USER(String, String) */ public static void SHOW_USERS(ResultSet[] users) throws SQLException { @@ -594,7 +586,7 @@ public static void SHOW_USERS(ResultSet[] users) throws SQLException { final Iterator keys = allProps.stringPropertyNames().iterator(); @Override public boolean getNext(DataValueDescriptor[] template) - throws SQLException, StandardException { + throws StandardException { String key, user; while (this.keys.hasNext()) { key = this.keys.next(); @@ -636,8 +628,7 @@ else if (key != null && key.startsWith(Property.SQLF_USER_PROPERTY_PREFIX)) { * @param password plain text password * @param transformation algorithm to be used, default is AES, if null is passed for arg * @param keySize encryption key size, default is 128 if a value <=0 is passed for this arg - * @param encryptedPwdRs - * @throws SQLException + * @param encryptedPwdRs result encrypted password */ public static void ENCRYPT_PASSWORD(String userID, String password, String transformation, int keySize, ResultSet[] encryptedPwdRs) @@ -672,7 +663,7 @@ public static void ENCRYPT_PASSWORD(String userID, String password, @Override public boolean getNext(DataValueDescriptor[] template) - throws SQLException, StandardException { + throws StandardException { if (!resultReturned) { template[0].setValue(userID + " = " + encryptedString); resultReturned = true; @@ -698,16 +689,16 @@ public boolean getNext(DataValueDescriptor[] template) * Set the percentage of heap at or above which the GFXD server instance is * considered in danger of becoming inoperable due to garbage collection * pauses or out of memory exceptions. - * + * *

* Changing this value can cause LowMemoryException or SQLException with * SQLState XCL52.S (query cancelled or timedout) to be thrown during any DML * operations i.e. inserts/updates/deletes/selects etc.. - * + * *

* Only current VM is set with this attribute and other overload propagates * the setting to remote VMs. - * + * *

* When using this threshold, the VM must be launched with the * -Xmx and -Xms switches set to the same values. @@ -721,36 +712,36 @@ public boolean getNext(DataValueDescriptor[] template) * -XX:CMSInitiatingOccupancyFraction=N should be set with N * being a percentage that is less than the {@link ResourceManager} critical * and eviction heap thresholds. - * + * *

* Example: setting a critical heap percent to 50 means 50% of max tenured * generation bytes (say 2048 MB) equates to critical heap threshold limit as * 1024 MB. - * + * *

* Similarly, setting eviction heap percent to 30 means 30% of max tenured * generation bytes (say 2048 MB) equates to eviction heap threshold limit as * 614.4 MB. - * + * *

* An Eviction heap threshold must be less than Critical heap threshold. If a * VM reaches its eviction threshold limit, GemFireXD will attempt to re-claim * memory depending on the {@link EvictionAttributes} of the tables. - * + * *

* Default CRITICAL_HEAP_PERCENT or EVICTION_HEAP_PERCENT is 0 which means its * disabled by default. - * + * *

* Property 'gemfire.disableLowMemoryException' can be used to suppress any * LowMemoryException whereas query cancellation cannot be suppressed. - * + * *

* A threshold thickness percentage can be defined using * 'gemfire.thresholdThickness' property that controls the heap usage must go * down by (THRESHOLD minus THRESHOLD-THICKNESS) before critical down event * i.e. VM is considered in non-critical memory state. - * + * *

* The JRockit VM has similar flags, -Xgc:gencon and * -XXgcTrigger:N, which are required if using this feature. @@ -758,39 +749,35 @@ public boolean getNext(DataValueDescriptor[] template) * use like the GemFire parameter. This means you need to set gcTrigger to * 100-N. for example, if your eviction threshold is 30 percent, you will need * to set gcTrigger to 70 percent. - * + * * On the IBM VM, the flag to get a similar collector is * -Xgcpolicy:gencon, but there is no corollary to the * gcTrigger/CMSInitiatingOccupancyFraction flags, so when using this feature * with an IBM VM, the heap usage statistics might lag the true memory usage * of the VM, and thresholds may need to be set sufficiently high that the VM * will initiate GC before the thresholds are crossed. - * + * * @param heapPercentage * a percentage of the maximum tenured heap for the VM. - * + * * @throws IllegalStateException * if the heapPercentage value is not >= 0 or <= 100 or when less * than the current eviction heap percentage. - * + * * @see #GET_CRITICAL_HEAP_PERCENTAGE() * @see #GET_EVICTION_HEAP_PERCENTAGE() */ - public static void SET_CRITICAL_HEAP_PERCENTAGE(float heapPercentage) - throws StandardException { + public static void SET_CRITICAL_HEAP_PERCENTAGE(float heapPercentage) { final InternalResourceManager rmgr = Misc.getGemFireCache() .getResourceManager(); rmgr.setCriticalHeapPercentage(heapPercentage); - // TODO: merge: shouldn't this be distributed to all members - // usage inconsistent with other system procedures; same for eviction proc SanityManager.DEBUG_PRINT("info:" + GfxdConstants.TRACE_SYS_PROCEDURES, "configured critical heap percentage to " + rmgr.getCriticalHeapPercentage()); } - public static void SET_CRITICAL_OFFHEAP_PERCENTAGE(float offHeapPercentage) - throws StandardException { + public static void SET_CRITICAL_OFFHEAP_PERCENTAGE(float offHeapPercentage) { final InternalResourceManager rmgr = Misc.getGemFireCache() .getResourceManager(); @@ -799,21 +786,19 @@ public static void SET_CRITICAL_OFFHEAP_PERCENTAGE(float offHeapPercentage) "configured critical off heap percentage to " + rmgr.getCriticalOffHeapPercentage()); } - + /** * An overload that will set critical heap percent to VMs part of the server * group. A NULL value in server group will mean setting percentage to ALL * GFXD members. - * + * * @param heapPercentage * a percentage of the maximum tenured heap for the VM * @param serverGroups * a comma delimited list of server group names on which this * procedure is to be executed. Optionally it can be NULL indicating * all. - * - * @throws SQLException - * @throws StandardException + * * @throws IllegalStateException * if the heapPercentage value is not >= 0 or <= 100 or when less * than the current eviction heap percentage @@ -848,11 +833,11 @@ public static void SET_CRITICAL_OFFHEAP_PERCENTAGE_SG(float offHeapPercentage, GfxdSystemProcedureMessage.SysProcMethod.setCriticalOffHeapPercentage, true, true); } - + /** * Get the percentage of heap at or above which the cache is considered in * danger of becoming inoperable. - * + * * @return either the current or recently used percentage of the maximum * tenured heap * @see #SET_CRITICAL_HEAP_PERCENTAGE(float) @@ -866,35 +851,34 @@ public static float GET_CRITICAL_OFFHEAP_PERCENTAGE() { return Misc.getGemFireCache().getResourceManager() .getCriticalOffHeapPercentage(); } - + /** * Set the percentage of heap at or above which the eviction should begin on * table's underlying region configured for * {@linkplain EvictionAttributes#createLRUHeapAttributes() HeapLRU eviction}. - * + * *

* Changing this value may cause eviction to begin immediately. - * + * *

* Only one change to this attribute or critical heap percentage will be * allowed at any given time and its effect will be fully realized before the * next change is allowed. - * + * * This feature requires additional VM flags to perform properly. See * {@link #SET_CRITICAL_HEAP_PERCENTAGE(float)} for details. - * + * * @param heapPercentage * a percentage of the maximum tenured heap for the VM - * + * * @throws IllegalStateException * if the heapPercentage value is not >= 0 or <= 100 or when greater * than the current critical heap percentage. - * + * * @see #GET_EVICTION_HEAP_PERCENTAGE() * @see #GET_CRITICAL_HEAP_PERCENTAGE() */ - public static void SET_EVICTION_HEAP_PERCENTAGE(float heapPercentage) - throws StandardException { + public static void SET_EVICTION_HEAP_PERCENTAGE(float heapPercentage) { final InternalResourceManager rmgr = Misc.getGemFireCache() .getResourceManager(); @@ -904,8 +888,7 @@ public static void SET_EVICTION_HEAP_PERCENTAGE(float heapPercentage) + rmgr.getEvictionHeapPercentage()); } - public static void SET_EVICTION_OFFHEAP_PERCENTAGE(float offHeapPercentage) - throws StandardException { + public static void SET_EVICTION_OFFHEAP_PERCENTAGE(float offHeapPercentage) { final InternalResourceManager rmgr = Misc.getGemFireCache() .getResourceManager(); @@ -914,25 +897,23 @@ public static void SET_EVICTION_OFFHEAP_PERCENTAGE(float offHeapPercentage) "configured eviction off heap percentage to " + rmgr.getEvictionOffHeapPercentage()); } - + /** * An overload that will set eviction heap percent to VMs part of the server * group. A NULL value in server group will mean setting percentage to ALL * GFXD members. - * + * * @param heapPercentage * a percentage of the maximum tenured heap for the VM * @param serverGroups * a comma delimited list of server group names on which this * procedure is to be executed. Optionally it can be NULL indicating * all. - * @throws SQLException - * @throws StandardException - * + * * @throws IllegalStateException * if the heapPercentage value is not >= 0 or <= 100 or when less * than the current eviction heap percentage - * + * * @see #SET_EVICTION_HEAP_PERCENTAGE(float) */ public static void SET_EVICTION_HEAP_PERCENTAGE_SG(float heapPercentage, @@ -949,7 +930,7 @@ public static void SET_EVICTION_HEAP_PERCENTAGE_SG(float heapPercentage, GfxdSystemProcedureMessage.SysProcMethod.setEvictionHeapPercentage, true, true); } - + public static void SET_EVICTION_OFFHEAP_PERCENTAGE_SG(float offHeapPercentage, String serverGroups) throws SQLException, StandardException { @@ -969,7 +950,7 @@ public static void SET_EVICTION_OFFHEAP_PERCENTAGE_SG(float offHeapPercentage, * Get the percentage of heap at or above which the eviction should begin on * Regions configured for * {@linkplain EvictionAttributes#createLRUHeapAttributes() HeapLRU eviction}. - * + * * @return either the current or recently used percentage of the maximum * tenured heap * @see #SET_EVICTION_HEAP_PERCENTAGE(float) @@ -978,7 +959,7 @@ public static float GET_EVICTION_HEAP_PERCENTAGE() { return Misc.getGemFireCache().getResourceManager() .getEvictionHeapPercentage(); } - + public static float GET_EVICTION_OFFHEAP_PERCENTAGE() { return Misc.getGemFireCache().getResourceManager() .getEvictionOffHeapPercentage(); @@ -990,11 +971,11 @@ public static float GET_EVICTION_OFFHEAP_PERCENTAGE() { * connect to from a JDBC client as out parameter. A set of servers to be * excluded from consideration can be passed as a comma-separated string (e.g. * to ignore the failed server during failover). - * + * * The format of network server list is: - * + * * host1[port1]{kind1},host2[port2]{kind2},... - * + * * i.e. comma-separated list of each network server followed by the * VMKind of the VM in curly braces. The network servers on * stand-alone locators are given preference and appear at the front. If the @@ -1002,7 +983,7 @@ public static float GET_EVICTION_OFFHEAP_PERCENTAGE() { * {@link TypeId#LONGVARCHAR_MAXWIDTH} then null is returned for this result * in which case the client is supposed to get the list from the SYS.MEMBERS * VTI table in a separate call. - * + * * This is primarily to avoid making two calls to the servers from the clients * during connection creation or failover. */ @@ -1082,10 +1063,9 @@ public static void GET_PREFSERVER(String excludedServers, /** * Enable execution statistics capturing for individual statements. - * - * @throws SQLException */ - public static void SET_STATEMENT_STATISTICS(int enable) throws SQLException { + public static void SET_STATEMENT_STATISTICS(int enable) + throws SQLException, StandardException { if (SanityManager.DEBUG) { if (GemFireXDUtils.TracePlanGeneration) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_PLAN_GENERATION, @@ -1123,11 +1103,10 @@ public static void SET_GLOBAL_STATEMENT_STATISTICS(Boolean enableStats, /** * Enable to collect table level transformed statistics of statement * executions. - * + * * @param archiveFile * stats archive file name (absolute or relative path). null disables * stats collection. - * @throws SQLException */ public static void SET_STATISTICS_SUMMARY(String archiveFile) throws SQLException { @@ -1166,11 +1145,9 @@ public static void SET_STATISTICS_SUMMARY(String archiveFile) * switch will be tracked and recorded by this connection. To retrieve the * query plans, one will have to switch back to individual schemas and execute * 'select stmt_id, stmt_text from sys.statementplans'; - * - * @param enable - * @throws SQLException */ - public static void SET_EXPLAIN_CONNECTION(int enable) throws SQLException { + public static void SET_EXPLAIN_CONNECTION(int enable) + throws SQLException, StandardException { if (SanityManager.DEBUG) { if (GemFireXDUtils.TracePlanGeneration) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_PLAN_GENERATION, @@ -1207,24 +1184,22 @@ public static void SET_EXPLAIN_CONNECTION(int enable) throws SQLException { /** * This procedure returns the current status of the explain mode. - * + * * If the EXPLAIN mode is non-zero, meaning that it is ON, then statements are * being EXPLAIN'd only via this connection. - * + * * @return 0 if EXPLAIN mode is off, non-zero if on. - * @throws SQLException */ - public static int GET_EXPLAIN_CONNECTION() throws SQLException, - StandardException { + public static int GET_EXPLAIN_CONNECTION() throws SQLException { return ConnectionUtil.getCurrentLCC().explainConnection() ? 1 : 0; } /** * Return all the DDLs executed in the system so far as a ResultSet with three * columns: - * + * * SCHEMANAME | OBJECTNAME | SQLTEXT - * + * * The "exportAll" parameter allows exporting everything including * configuration commands using system procedures. */ @@ -1257,7 +1232,7 @@ public static void EXPORT_DDLS(final Boolean exportAll, final ResultSet[] rs) @Override public boolean getNext(DataValueDescriptor[] template) - throws SQLException, StandardException { + throws StandardException { final boolean debugOn = SanityManager.DEBUG_ON("ExportDDLs"); String currentSchema; // get all elements in the queue removing them from the queue @@ -1324,15 +1299,15 @@ public boolean getNext(DataValueDescriptor[] template) /** * Install a jar file in the database using given jar bytes. - * + * * SQLJ.INSTALL_JAR_BYTES(Blob,String) - * + * * @param jarBlob * Raw bytes of the jar file as a Blob to be installed in the * database. * @param jarName * SQL name of jar to be installed. - * + * * @exception SQLException * Error replacing jar file. */ @@ -1362,15 +1337,15 @@ public static void INSTALL_JAR_BYTES(Blob jarBlob, String jarName) /** * Replace a jar file in the database using given jar bytes. - * + * * SQLJ.REPLACE_JAR_BYTES(Blob,String) - * + * * @param jarBlob * Raw bytes of the jar file as a Blob to be installed in the * database. * @param jarName * SQL name of jar to be replaced. - * + * * @exception SQLException * Error replacing jar file. */ @@ -1401,8 +1376,7 @@ public static void REPLACE_JAR_BYTES(Blob jarBlob, String jarName) * Start the rebalancing of buckets of all partitioned tables and * wait for it to complete. */ - public static void REBALANCE_ALL_BUCKETS() throws SQLException, - StandardException { + public static void REBALANCE_ALL_BUCKETS() throws SQLException { try { final RebalanceOperation rebalanceOp = Misc.getGemFireCache() @@ -1417,162 +1391,103 @@ public static void REBALANCE_ALL_BUCKETS() throws SQLException, } /** + * Get catalog metadata from SnappyHiveExternalCatalog. * - * @param tableName input param - table for which metadata is needed - * @param tableObject output param - Hive matastore object for table - * @param bucketCount output param - 0 for replicated tables otherwise the actual count - * @param partColumns output param - partitioning columns - * @param bucketToServerMapping output param - bucket to server mapping for partitioned tables OR - * replica to server mapping for replicated table - * @throws SQLException + * @param operation one of the read operation types with prefix CATALOG_ in snappydata.thrift + * @param args thrift serialized CatalogMetadataRequest + * @param outMetadata output thrift serialized CatalogMetadataDetails */ - public static void GET_TABLE_METADATA( - String tableName, Blob[] tableObject, - int[] bucketCount, - String[] partColumns, - String[] indexColumns, - Clob[] bucketToServerMapping, - int[] relationDestroyVersion, - String[] pkColumns) - throws SQLException { - String schema; - String table; - int dotIndex; - // NULL table name is illegal - if (tableName == null) { - throw Util.generateCsSQLException(SQLState.ENTITY_NAME_MISSING); - } - - if (GemFireXDUtils.TraceSysProcedures) { - SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_SYS_PROCEDURES, - "executing GET_TABLE_METADATA for table " + tableName); - } - - if ((dotIndex = tableName.indexOf('.')) >= 0) { - schema = tableName.substring(0, dotIndex); - table = tableName.substring(dotIndex + 1); - } else { - schema = Misc.getDefaultSchemaName(ConnectionUtil.getCurrentLCC()); - table = tableName; - } - - ExternalCatalog hiveCatalog = Misc.getMemStore().getExistingExternalCatalog(); - // get the hive matadata object and return as a blob - Object t = hiveCatalog.getTable(schema, table, true); - if (t != null) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try { - ObjectOutputStream os = new ObjectOutputStream(baos); - os.writeObject(t); - byte[] tableObjectBytes = baos.toByteArray(); - tableObject[0] = new HarmonySerialBlob(tableObjectBytes); - } catch (IOException ioe) { - TransactionResourceImpl.wrapInSQLException(ioe); - } - } else { - tableObject[0] = null; - } - - // get other attributes bucket count, partitioning cols, - // bucket to server/replica to server mapping - if (tableObject[0] != null) { - try { - final GemFireContainer container = CallbackProcedures - .getContainerForTable(schema, table); - final LocalRegion region = container.getRegion(); + public static void GET_CATALOG_METADATA(int operation, Blob args, + Blob[] outMetadata) throws SQLException { + try { + final CatalogMetadataRequest request = new CatalogMetadataRequest(); + Assert.assertTrue(GemFireXDUtils.readThriftObject(request, + args.getBytes(1, (int)args.length())) == 0); + args.free(); + if (GemFireXDUtils.TraceSysProcedures) { + logger.info("Executing GET_CATALOG_METADATA operation=" + operation + ": " + request); + } + + ExternalCatalog catalog = Misc.getMemStore().getExistingExternalCatalog(); + final CatalogMetadataDetails result = new CatalogMetadataDetails(); + final LocalRegion region = catalog.fillCatalogMetadata(operation, request, result); + // need to fill in additional bucket/column information for getTable + if (operation == snappydataConstants.CATALOG_GET_TABLE && + result.isSetCatalogTable() && region != null) { + CatalogTableObject catalogTable = result.getCatalogTable(); + String schema = request.getSchemaName(); + String table = request.getNameOrPattern(); + // set other attributes: redundancy, bucket to server/replica to server mapping if (region.getAttributes().getPartitionAttributes() != null) { - getPRMetaData((PartitionedRegion)region, tableName, - partColumns, bucketCount, bucketToServerMapping); + getBucketToServerMapping((PartitionedRegion)region, catalogTable); } else { - getRRMetaData((DistributedRegion)region, bucketToServerMapping); - bucketCount[0] = 0; - } - // get index columns - if (hiveCatalog.isRowTable(schema, table, true)) { - getIndexColumns(indexColumns, region); - getPKColumns(pkColumns, region); - } - } catch (StandardException se) { - // getContainerForTable can throw error for external tables - // (parquet / csv etc.) - if (se.getSQLState().equals(SQLState.LANG_TABLE_NOT_FOUND)) { - bucketCount[0] = 0; - partColumns[0] = null; - indexColumns[0] = null; - bucketToServerMapping[0] = new HarmonySerialClob(""); // to avoid NPE - pkColumns[0] = null; - } else { - throw PublicAPI.wrapStandardException(se); + getReplicaServerMapping((DistributedRegion)region, catalogTable); } } - } else { - throw Util.generateCsSQLException(SQLState.LANG_TABLE_NOT_FOUND, tableName); + outMetadata[0] = new HarmonySerialBlob(GemFireXDUtils.writeThriftObject(result)); + } catch (Throwable t) { + throw TransactionResourceImpl.wrapInSQLException(t); } - - final GfxdDistributionAdvisor.GfxdProfile profile = GemFireXDUtils. - getGfxdProfile(Misc.getMyId()); - relationDestroyVersion[0] = profile.getRelationDestroyVersion(); - } - private static void getPRMetaData(final PartitionedRegion region, - final String tableName, final String[] partColumns, - final int[] bucketCount, final Clob[] bucketToServerMapping) throws SQLException { - bucketCount[0] = region.getTotalNumberOfBuckets(); + /** + * Update catalog metadata of SnappyHiveExternalCatalog. + * + * @param operation one of the update operation types with prefix CATALOG_ in snappydata.thrift + * @param args thrift serialized CatalogMetadataDetails + */ + public static void UPDATE_CATALOG_METADATA(int operation, Blob args) throws SQLException { + try { + final CatalogMetadataDetails request = new CatalogMetadataDetails(); + Assert.assertTrue(GemFireXDUtils.readThriftObject(request, + args.getBytes(1, (int)args.length())) == 0); + args.free(); + if (GemFireXDUtils.TraceSysProcedures) { + logger.info("Executing UPDATE_CATALOG_METADATA operation=" + operation + ": " + request); + } - // get partitioning columns - GfxdPartitionByExpressionResolver resolver = - (GfxdPartitionByExpressionResolver)region.getPartitionResolver(); - StringBuilder stringBuffer = new StringBuilder(); - for (String col : resolver.getColumnNames()) { - stringBuffer.append(col).append(':'); + ExternalCatalog catalog = Misc.getMemStore().getExistingExternalCatalog(); + String currentUser = ((GenericLanguageConnectionContext)ConnectionUtil + .getCurrentLCC()).getUserName(); + catalog.updateCatalogMetadata(operation, request, currentUser); + } catch (Throwable t) { + throw TransactionResourceImpl.wrapInSQLException(t); } - partColumns[0] = stringBuffer.toString(); - - // bucket to server mapping - GET_BUCKET_TO_SERVER_MAPPING2(tableName, bucketToServerMapping); } - private static void getRRMetaData(final DistributedRegion region, - final Clob[] replicaNodes) { + private static void getReplicaServerMapping(final DistributedRegion region, + final CatalogTableObject catalogTable) { // replica to server mapping - Set owners = new HashSet<>(); + Set owners = new UnifiedSet<>(); Set replicas = region.getDistributionAdvisor().adviseInitializedReplicates(); Map mbrToServerMap = GemFireXDUtils .getGfxdAdvisor().getAllNetServersWithMembers(); - StringBuilder stringBuffer = new StringBuilder(); - if (GemFireXDUtils.getMyVMKind().isStore()) { + ArrayList replicaOwners = new ArrayList<>(owners.size()); + if (ServerGroupUtils.isDataStore()) { owners.add(Misc.getGemFireCache().getMyId()); } owners.addAll(replicas); for (InternalDistributedMember node : owners) { String netServer = mbrToServerMap.get(node); - if ( netServer != null) { - stringBuffer.append(netServer).append(';'); + if (netServer != null) { + replicaOwners.add(netServer); } } - if (stringBuffer.length() > 0) { - replicaNodes[0] = new HarmonySerialClob(stringBuffer.toString()); - } else { - replicaNodes[0] = null; - } + BucketOwners bucketOwners = new BucketOwners(-1); + bucketOwners.setSecondaries(replicaOwners); + catalogTable.setBucketOwners(Collections.singletonList(bucketOwners)); } /** - * Returns the index columns in string format separated by ":" - * in the element indexColumns[0] - * for example, "col1:col2:col3" - * @param indexColumns - * @param region - * @throws StandardException + * Returns the list of index columns. */ - public static void getIndexColumns(String[] indexColumns, LocalRegion region) + public static List getIndexColumns(LocalRegion region) throws StandardException { GemFireContainer container = (GemFireContainer)region.getUserAttribute(); TableDescriptor td = container.getTableDescriptor(); - StringBuilder cols = new StringBuilder(); + ArrayList cols = new ArrayList<>(2); if (td != null) { String[] baseColumns = td.getColumnNamesArray(); GfxdIndexManager im = container.getIndexManager(); @@ -1580,7 +1495,7 @@ public static void getIndexColumns(String[] indexColumns, LocalRegion region) for (ConglomerateDescriptor cd : im.getIndexConglomerateDescriptors()) { // first column of index has to be present in filter to be usable int[] indexCols = cd.getIndexDescriptor().baseColumnPositions(); - cols.append(baseColumns[indexCols[0] - 1]).append(':'); + cols.add(baseColumns[indexCols[0] - 1]); } } // also add primary key @@ -1589,226 +1504,116 @@ public static void getIndexColumns(String[] indexColumns, LocalRegion region) // first column of primary key has to be present in filter to be usable int[] pkCols = primaryKey.getKeyColumns(); if (pkCols != null && pkCols.length > 0) { - cols.append(baseColumns[pkCols[0] - 1]); + cols.add(baseColumns[pkCols[0] - 1]); } } } - int len = cols.length(); - if (len > 0 && cols.charAt(len - 1) == ':') { - indexColumns[0] = cols.substring(0, len - 1); - } else { - indexColumns[0] = cols.toString(); - } + return cols; } - public static void getPKColumns(String[] pkColumns, - LocalRegion region) throws StandardException { + public static List getPKColumns(LocalRegion region) throws StandardException { GemFireContainer container = (GemFireContainer)region.getUserAttribute(); TableDescriptor td = container.getTableDescriptor(); - String cols = null; + ArrayList cols = new ArrayList<>(2); if (td != null) { String[] baseColumns = td.getColumnNamesArray(); ReferencedKeyConstraintDescriptor primaryKey = td.getPrimaryKey(); if (primaryKey != null) { int[] pkCols = primaryKey.getKeyColumns(); if (pkCols != null) { - for (int i = 0; i < pkCols.length; i++) { - cols += baseColumns[pkCols[i] - 1] + ":"; + for (int pkCol : pkCols) { + cols.add(baseColumns[pkCol - 1]); } } } } - pkColumns[0] = cols; - } - - public static void CREATE_SNAPPY_TABLE( - String tableIdentifier, - String provider, - String userSpecifiedSchema, - String schemaDDL, - Blob mode, - Blob options, - Boolean isBuiltIn) - throws SQLException { - if (GemFireXDUtils.TraceSysProcedures) { - SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_SYS_PROCEDURES, - "executing CREATE_SNAPPY_TABLE "); - } - LeadNodeSmartConnectorOpContext ctx = new LeadNodeSmartConnectorOpContext( - LeadNodeSmartConnectorOpContext.OpType.CREATE_TABLE, - tableIdentifier, provider, userSpecifiedSchema, schemaDDL, - mode.getBytes(1, (int)mode.length()), options.getBytes(1, (int)options.length()), - isBuiltIn, false, null, null, null, null, - null, null, false, null, null, false); - - sendConnectorOpToLead(ctx); - } - - public static void DROP_SNAPPY_TABLE(String tableIdentifier, - Boolean ifExists, Boolean isExternal) throws SQLException { - if (GemFireXDUtils.TraceSysProcedures) { - SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_SYS_PROCEDURES, - "executing DROP_SNAPPY_TABLE "); - } - LeadNodeSmartConnectorOpContext ctx = new LeadNodeSmartConnectorOpContext( - // in smart connector calls, either the table will be builtin or - // an external one and cannot be a temporary one so !isExternal is - // same as isBuiltIn - LeadNodeSmartConnectorOpContext.OpType.DROP_TABLE, - tableIdentifier, null, null, null, null, null, !isExternal, ifExists, - null, null, null, null, null, null,false, null, null, false); - - sendConnectorOpToLead(ctx); - } - - public static void CREATE_SNAPPY_INDEX( - String indexIdentifier, - String tableIdentifier, - Blob indexColumns, - Blob options) throws SQLException { - if (GemFireXDUtils.TraceSysProcedures) { - SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_SYS_PROCEDURES, - "executing CREATE_SNAPPY_INDEX "); - } - - LeadNodeSmartConnectorOpContext ctx = new LeadNodeSmartConnectorOpContext( - LeadNodeSmartConnectorOpContext.OpType.CREATE_INDEX, - tableIdentifier, null, null, null, null, - options.getBytes(1, (int)options.length()), true, false, - indexIdentifier, indexColumns.getBytes(1, (int)indexColumns.length()), null, null, null, null ,false, null, null, false); - - sendConnectorOpToLead(ctx); - - } - - public static void DROP_SNAPPY_INDEX(String indexIdentifier, - Boolean ifExists) throws SQLException { - if (GemFireXDUtils.TraceSysProcedures) { - SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_SYS_PROCEDURES, - "executing DROP_SNAPPY_INDEX "); - } - - LeadNodeSmartConnectorOpContext ctx = new LeadNodeSmartConnectorOpContext( - LeadNodeSmartConnectorOpContext.OpType.DROP_INDEX, - null, null, null, null, null, null, true, ifExists, - indexIdentifier, null, null, null, null, null, false, null, null, false); - - sendConnectorOpToLead(ctx); - } - - public static void CREATE_SNAPPY_UDF(String db, String functionName, - String className, String jarURI) throws SQLException { - if (GemFireXDUtils.TraceSysProcedures) { - SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_SYS_PROCEDURES, - "executing CREATE_SNAPPY_UDF "); - } - LeadNodeSmartConnectorOpContext ctx = new LeadNodeSmartConnectorOpContext( - LeadNodeSmartConnectorOpContext.OpType.CREATE_UDF, - null, null, null, null, null, null, true, false, null, null, - db, functionName, className, jarURI,false, null, null, false); - - sendConnectorOpToLead(ctx); - } - - public static void DROP_SNAPPY_UDF(String db, String functionName) throws SQLException { - if (GemFireXDUtils.TraceSysProcedures) { - SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_SYS_PROCEDURES, - "executing DROP_SNAPPY_UDF "); - } - - LeadNodeSmartConnectorOpContext ctx = new LeadNodeSmartConnectorOpContext( - LeadNodeSmartConnectorOpContext.OpType.DROP_UDF, - null, null, null, null, null, null, true, false, null, null, - db, functionName, null, null, false, null, null, false); - - sendConnectorOpToLead(ctx); - } - - public static void ALTER_SNAPPY_TABLE(String tableIdentifier, Boolean addOrDropCol, - String columnName, String columnType, - Boolean columnNullable) throws SQLException { - if (GemFireXDUtils.TraceSysProcedures) { - SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_SYS_PROCEDURES, - "executing ALTER_SNAPPY_TABLE "); - } - - LeadNodeSmartConnectorOpContext ctx = new LeadNodeSmartConnectorOpContext( - LeadNodeSmartConnectorOpContext.OpType.ALTER_TABLE, - tableIdentifier, null, null, null, null, - null, true, false, null, null, - null, null, null, null, addOrDropCol, columnName, columnType, columnNullable); - - sendConnectorOpToLead(ctx); + return cols; } public static void GET_DEPLOYED_JARS(String[] jarStrings) throws SQLException { try { if (GemFireXDUtils.TraceSysProcedures) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_SYS_PROCEDURES, - "executing GET_DEPLOYED_JARS "); + "executing GET_DEPLOYED_JARS"); } GfxdListResultCollector collector = new GfxdListResultCollector(); GetLeadNodeInfoAsStringMessage msg = new GetLeadNodeInfoAsStringMessage( collector, GetLeadNodeInfoAsStringMessage.DataReqType.GET_JARS, (Object[])null); msg.executeFunction(); - List result = (ArrayList) collector.getResult(); - String resJarStrings = (String) result.get(0); + ArrayList result = collector.getResult(); + String resJarStrings = (String)result.get(0); jarStrings[0] = resJarStrings; } catch (StandardException se) { throw PublicAPI.wrapStandardException(se); } } - private static void sendConnectorOpToLead(LeadNodeSmartConnectorOpContext ctx) - throws SQLException { - LeadNodeSmartConnectorOpMsg msg = new LeadNodeSmartConnectorOpMsg(ctx, - AckResultCollector.INSTANCE); + /** + * Create or drop reservoir region for sampler. + */ + public static void CREATE_OR_DROP_RESERVOIR_REGION(String reservoirRegionName, + String resolvedBaseName, Boolean isDrop) throws SQLException { try { - msg.executeFunction(); - } catch(StandardException se) { + // check for permission on the sample table schema + LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC(); + String currentUser = ((GenericLanguageConnectionContext)lcc).getUserName(); + int dotIndex = resolvedBaseName.indexOf('.'); + if (dotIndex == -1) { + throw new UnsupportedOperationException( + "Cannot created reservoir region for base name = " + + resolvedBaseName + " having no schema"); + } + String schema = resolvedBaseName.substring(0, dotIndex); + CallbackFactoryProvider.getStoreCallbacks().checkSchemaPermission( + schema, currentUser); + + // first create/drop locally + if (createOrDropReservoirRegion(reservoirRegionName, resolvedBaseName, isDrop)) { + // don't send to other nodes or persist if local operation is unsuccessful + final Object[] args = new Object[] { reservoirRegionName, + resolvedBaseName, isDrop }; + // send to other nodes + publishMessage(args, false, + GfxdSystemProcedureMessage.SysProcMethod.createOrDropReservoirRegion, + true, false); + } + } catch (StandardException se) { throw PublicAPI.wrapStandardException(se); + } catch (Throwable t) { + throw TransactionResourceImpl.wrapInSQLException(t); } } - /** Deprecated. To be removed in next release. */ - public static void GET_SNAPPY_TABLE_STATS(Blob[] statsMap) throws SQLException { - try { - if (GemFireXDUtils.TraceSysProcedures) { - SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_SYS_PROCEDURES, - "executing GET_SNAPPY_TABLE_STATS "); - } - GfxdListResultCollector collector = new GfxdListResultCollector(); - LeadNodeGetStatsMessage msg = new LeadNodeGetStatsMessage(collector); - msg.executeFunction(); - List result = (ArrayList)collector.getResult(); - if (result != null) { - for (Object oneResult : result) { - Object o = oneResult; - try { - ByteArrayDataOutput bdos = new ByteArrayDataOutput(); - DataSerializer.writeObject(o, bdos); - statsMap[0] = new HarmonySerialBlob(bdos.toByteArray()); - } catch (IOException ioe) { - TransactionResourceImpl.wrapInSQLException(ioe); - } - } + public static boolean createOrDropReservoirRegion(String reservoirRegionName, + String resolvedBaseName, boolean isDrop) { + PartitionedRegion existingRegion = Misc.getReservoirRegionForSampleTable( + reservoirRegionName); + if (isDrop) { + if (existingRegion != null) { + existingRegion.destroyRegion(null); + return true; } else { - statsMap[0] = null; + return false; } - } catch (StandardException se) { - throw PublicAPI.wrapStandardException(se); + } else if (existingRegion == null) { + PartitionedRegion region = Misc.createReservoirRegionForSampleTable( + reservoirRegionName, resolvedBaseName); + if (Misc.initialDDLReplayDone()) { + Assert.assertTrue(region != null); + } + return true; + } else { + return false; } } - /** * Create all buckets in the given table. - * + * * @param tableName * the fully qualified table name */ - public static void CREATE_ALL_BUCKETS(String tableName) throws SQLException, - StandardException { + public static void CREATE_ALL_BUCKETS(String tableName) throws SQLException { String schema; String table; int dotIndex; @@ -1899,9 +1704,61 @@ public boolean visit(RegionAdvisor advisor, ProxyBucketRegion pbr, } } + private static void getBucketToServerMapping(PartitionedRegion region, + CatalogTableObject catalogTable) throws SQLException { + // String servers = GemFireXDUtils.getGfxdAdvisor().getAllNetworkServers(); + + Map bidToAdvsrMap = region.getRegionAdvisor() + .getAllBucketAdvisorsHostedAndProxies(); + int totalBuckets = region.getTotalNumberOfBuckets(); + int redundancy = region.getRedundantCopies(); + if (SanityManager.TraceSingleHop || logger.isDebugEnabled()) { + logger.info("getBucketToServerMapping called for region: " + region.getName() + + ", with total buckets = " + totalBuckets + " and redundancy = " + + redundancy + " and bidToAdvsrMap size = " + bidToAdvsrMap.size() + + ", full map: " + bidToAdvsrMap); + } + ArrayList allBucketOwners = new ArrayList<>(totalBuckets); + Map mbrToServerMap = GemFireXDUtils + .getGfxdAdvisor().getAllNetServersWithMembers(); + for (Map.Entry entry : bidToAdvsrMap.entrySet()) { + BucketOwners bucketOwners = new BucketOwners(entry.getKey()); + BucketAdvisor advisor = entry.getValue(); + ProxyBucketRegion pbr = advisor.getProxyBucketRegion(); + // throws PartitionOfflineException if appropriate + try { + pbr.checkBucketRedundancyBeforeGrab(null, false); + } catch (Exception e) { + throw TransactionResourceImpl.wrapInSQLException(e); + } + InternalDistributedMember pmbr = advisor.getPrimary(); + Set bOwners = pbr.getBucketOwners(); + if (pmbr != null) { + bOwners.remove(pmbr); + String primaryServer = mbrToServerMap.get(pmbr); + if (primaryServer != null && primaryServer.length() > 0) { + bucketOwners.setPrimary(primaryServer); + } + } + List secondaries = Collections.emptyList(); + for (InternalDistributedMember mbr : bOwners) { + String secondary = mbrToServerMap.get(mbr); + if (secondary != null && secondary.length() > 0) { + if (secondaries.isEmpty()) { + secondaries = new ArrayList<>(bOwners.size()); + } + secondaries.add(secondary); + } + } + bucketOwners.setSecondaries(secondaries); + allBucketOwners.add(bucketOwners); + } + catalogTable.setRedundancy(redundancy).setBucketOwners(allBucketOwners); + } + /** * Get all buckets location information network server addr wise. - * + * * @param fqtn * the fully qualified table name * @param bktToServerMapping @@ -1911,71 +1768,53 @@ public boolean visit(RegionAdvisor advisor, ProxyBucketRegion pbr, * "113:2:0;pc25.pune.gemstone.com/10.112.204.14[25005]{datastore}; * null;null|2;pc25.pune.gemstone.com/10.112.204.14[25005] * {datastore};null;null" - * @throws SQLException */ public static void GET_BUCKET_TO_SERVER_MAPPING(String fqtn, String[] bktToServerMapping) throws SQLException { - PartitionedRegion region = (PartitionedRegion)Misc.getRegionForTable(fqtn, - true); - //String servers = GemFireXDUtils.getGfxdAdvisor().getAllNetworkServers(); - - Map bidToAdvsrMap = region.getRegionAdvisor() - .getAllBucketAdvisorsHostedAndProxies(); - int totalBuckets = region.getTotalNumberOfBuckets(); - int redundancy = region.getRedundantCopies(); - if (SanityManager.TraceSingleHop) { - SanityManager.DEBUG_PRINT(SanityManager.TRACE_SINGLE_HOP, - "GET_BUCKET_TO_SERVER_MAPPING called for region: " + region.getName() - + ", with tot buckets: " + totalBuckets + " and redundancy: " - + redundancy + " and bidToAdvsrMap size: " + bidToAdvsrMap.size() - + ", full map: " + bidToAdvsrMap); + String schema, table; + int dotIndex; + if ((dotIndex = fqtn.indexOf('.')) >= 0) { + schema = fqtn.substring(0, dotIndex); + table = fqtn.substring(dotIndex + 1); + } else { + schema = Misc.getDefaultSchemaName(ConnectionUtil.getCurrentLCC()); + table = fqtn; } + + CatalogTableObject catalogTable = new CatalogTableObject(); + PartitionedRegion region = (PartitionedRegion)Misc.getRegionForTable( + Misc.getRegionPath(schema, table, null), true); + getBucketToServerMapping(region, catalogTable); StringBuilder bucketInfo = new StringBuilder(); - bucketInfo.append(totalBuckets); + bucketInfo.append(region.getTotalNumberOfBuckets()); bucketInfo.append(':'); - bucketInfo.append(redundancy); + bucketInfo.append(catalogTable.getRedundancy()); bucketInfo.append(':'); - int sz = bidToAdvsrMap.size(); + int sz = catalogTable.getBucketOwners().size(); int cnt = 0; - Map mbrToServerMap = GemFireXDUtils - .getGfxdAdvisor().getAllNetServersWithMembers(); - for (Map.Entry entry : bidToAdvsrMap.entrySet()) { + for (BucketOwners bucketOwners : catalogTable.getBucketOwners()) { cnt++; - bucketInfo.append(entry.getKey()); + bucketInfo.append(bucketOwners.getBucketId()); bucketInfo.append(';'); - BucketAdvisor advisor = entry.getValue(); - ProxyBucketRegion pbr = advisor.getProxyBucketRegion(); - // throws PartitionOfflineException if appropriate - try { - pbr.checkBucketRedundancyBeforeGrab(null, false); - } catch (Exception e) { - throw TransactionResourceImpl.wrapInSQLException(e); - } - InternalDistributedMember pmbr = advisor.getPrimary(); - Set bOwners = pbr.getBucketOwners(); - bOwners.remove(pmbr); - String primaryServer = mbrToServerMap.get(pmbr); - if (primaryServer == null || primaryServer.length() == 0) { + String primaryServer = bucketOwners.getPrimary(); + if (primaryServer == null) { bucketInfo.append("null"); - } - else { + } else { bucketInfo.append(primaryServer); } int idx = 0; - for (InternalDistributedMember mbr : bOwners) { + for (String secondary : bucketOwners.getSecondaries()) { bucketInfo.append(';'); - String secondary = mbrToServerMap.get(mbr); - if (secondary == null || secondary.length() == 0) { + if (secondary == null) { bucketInfo.append("null"); - } - else { + } else { bucketInfo.append(secondary); } idx++; } - int shortfall = redundancy - idx; + int shortfall = catalogTable.getRedundancy() - idx; if (shortfall != 0) { - for(int i=0; i0 - * + * * @see #GET_TABLE_VERSION(String, String) */ public static void INCREMENT_TABLE_VERSION(String schemaName, @@ -2458,7 +2293,7 @@ public static void INCREMENT_TABLE_VERSION(String schemaName, /** * Flush and fsync disk store data to disk on all members of the cluster. - * + * * @param diskStoreName * name of the disk store to flush and fsync to disk; if null then * all disk stores are fsynced @@ -2492,7 +2327,7 @@ public static void DISKSTORE_FSYNC(String diskStoreName) throws SQLException, } } - public static void FIX_PREVIOUS_OPS_COUNT(String tableName) throws SQLException { + public static void FIX_PREVIOUS_OPS_COUNT(String tableName) { Region region = Misc.getRegionForTable(tableName, true); if (region != null) { if (region instanceof PartitionedRegion) { @@ -2505,6 +2340,7 @@ public static void FIX_PREVIOUS_OPS_COUNT(String tableName) throws SQLException } } } + /** * This procedure dumps the thread stacks, locks, transaction stats of current * node to log file. It is identical to sending SIGURG on UNIX systems. The @@ -2542,24 +2378,24 @@ public static void setBucketsForLocalExecution(String tableName, * BUCKET_RENTION_FOR_LOCAL_EXECUTION is set. */ public static void SET_BUCKETS_FOR_LOCAL_EXECUTION(String tableName, - String buckets, int relationDestroyVersion) + String buckets, long catalogSchemaVersion) throws SQLException, StandardException { if (tableName == null) { throw Util.generateCsSQLException(SQLState.ENTITY_NAME_MISSING); } - final GfxdDistributionAdvisor.GfxdProfile profile = GemFireXDUtils. - getGfxdProfile(Misc.getMyId()); - final int actualVersion = profile.getRelationDestroyVersion(); + ExternalCatalog catalog = Misc.getMemStore().getExistingExternalCatalog(); + final long actualVersion = catalog.getCatalogSchemaVersion(); - if ((relationDestroyVersion != -1) && - (actualVersion != relationDestroyVersion)) { - throw StandardException.newException(SQLState.SNAPPY_RELATION_DESTROY_VERSION_MISMATCH); + if ((catalogSchemaVersion != -1) && + (actualVersion != catalogSchemaVersion)) { + throw StandardException.newException(SQLState.SNAPPY_CATALOG_SCHEMA_VERSION_MISMATCH, + actualVersion, catalogSchemaVersion); } Region region = Misc.getRegionForTable(tableName, true); LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC(); - Set bucketSet = new HashSet(); + Set bucketSet = new UnifiedSet<>(); StringTokenizer st = new StringTokenizer(buckets,","); while(st.hasMoreTokens()){ bucketSet.add(Integer.parseInt(st.nextToken())); @@ -2569,18 +2405,17 @@ public static void SET_BUCKETS_FOR_LOCAL_EXECUTION(String tableName, /** - * This procedure sets the Nanotimer type. NanoTimer are used extensively while - * generating the Explain plans. The timer can either be set to use - * Java's java.lang.System.nanoTime() or to make a native call to get the nanoTime. - * If native timer is to be used, the native timer type can be specified as one of these: + * This procedure sets the Nanotimer type. NanoTimer are used extensively while + * generating the Explain plans. The timer can either be set to use + * Java's java.lang.System.nanoTime() or to make a native call to get the nanoTime. + * If native timer is to be used, the native timer type can be specified as one of these: * CLOCK_REALTIME; * CLOCK_MONOTONIC; * CLOCK_PROCESS_CPUTIME_ID; * CLOCK_THREAD_CPUTIME_ID; - * CLOCK_MONOTONIC_RAW; - * - * Java's java.lang.System.nanoTime() is much faster than native timer calls. - * + * CLOCK_MONOTONIC_RAW; + *

+ * Java's java.lang.System.nanoTime() is much faster than native timer calls. */ public static void SET_NANOTIMER_TYPE(Boolean useNativeTimer, String nativeTimerType) throws SQLException, StandardException { @@ -2611,25 +2446,46 @@ public static void flushLocalBuckets(String resolvedName, boolean forceFlush) { } public static void COMMIT_SNAPSHOT_TXID(String txId, String rolloverTable) - throws SQLException, StandardException { - TXStateInterface txState = null; - LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC(); - GemFireTransaction tc = (GemFireTransaction) lcc.getTransactionExecute(); - TXManagerImpl txManager = tc.getTransactionManager(); + throws SQLException { + try { + LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC(); + GemFireTransaction tc = (GemFireTransaction)lcc.getTransactionExecute(); - if (!rolloverTable.isEmpty()) { - flushLocalBuckets(rolloverTable, false); - } - if (!txId.isEmpty()) { - StringTokenizer st = new StringTokenizer(txId, ":"); if (GemFireXDUtils.TraceExecution) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_EXECUTION, "in procedure COMMIT_SNAPSHOT_TXID() " + txId + " rolloverTable=" + rolloverTable + " for connid " + tc.getConnectionID() + " rolloverTable=" + rolloverTable + " TxManager " + TXManagerImpl.getCurrentTXId() - + " snapshot tx : " + TXManagerImpl.getCurrentSnapshotTXState()); + + " snapshot tx = " + TXManagerImpl.getCurrentSnapshotTXState()); } + boolean success = false; + try { + if (!rolloverTable.isEmpty()) { + flushLocalBuckets(rolloverTable, false); + } + success = true; + } finally { + if (success) { + commitSnapShotTXId(txId, lcc, tc); + } else { + rollbackSnapshotTXId(txId, lcc, tc); + } + } + } catch (SQLException sqle) { + throw sqle; + } catch (Throwable t) { + throw TransactionResourceImpl.wrapInSQLException(t); + } + } + + private static void commitSnapShotTXId(String txId, + LanguageConnectionContext lcc, GemFireTransaction tc) { + TXStateInterface txState = null; + TXManagerImpl txManager = tc.getTransactionManager(); + + if (!txId.isEmpty()) { + StringTokenizer st = new StringTokenizer(txId, ":"); long memberId = Long.parseLong(st.nextToken()); int uniqId = Integer.parseInt(st.nextToken()); @@ -2668,21 +2524,34 @@ public static void COMMIT_SNAPSHOT_TXID(String txId, String rolloverTable) } } - public static void ROLLBACK_SNAPSHOT_TXID(String txId) throws SQLException, StandardException { + public static void ROLLBACK_SNAPSHOT_TXID(String txId) throws SQLException { + try { + LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC(); + GemFireTransaction tc = (GemFireTransaction)lcc.getTransactionExecute(); + + rollbackSnapshotTXId(txId, lcc, tc); + } catch (SQLException sqle) { + throw sqle; + } catch (Throwable t) { + throw TransactionResourceImpl.wrapInSQLException(t); + } + } + + private static void rollbackSnapshotTXId(String txId, + LanguageConnectionContext lcc, GemFireTransaction tc) { TXStateProxy txState = null; TXManagerImpl.TXContext context; - LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC(); - GemFireTransaction tc = (GemFireTransaction) lcc.getTransactionExecute(); TXManagerImpl txManager = tc.getTransactionManager(); + if (GemFireXDUtils.TraceExecution) { + SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_EXECUTION, + "in procedure ROLLBACK_SNAPSHOT_TXID() " + txId + " for connid " + tc.getConnectionID() + + " TxManager " + TXManagerImpl.getCurrentTXId() + + " snapshot tx : " + TXManagerImpl.getCurrentSnapshotTXState()); + } + if (!txId.isEmpty()) { StringTokenizer st = new StringTokenizer(txId, ":"); - if (GemFireXDUtils.TraceExecution) { - SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_EXECUTION, - "in procedure ROLLBACK_SNAPSHOT_TXID() " + txId + " for connid " + tc.getConnectionID() - + " TxManager " + TXManagerImpl.getCurrentTXId() - + " snapshot tx : " + TXManagerImpl.getCurrentSnapshotTXState()); - } long memberId = Long.parseLong(st.nextToken()); int uniqId = Integer.parseInt(st.nextToken()); @@ -2708,26 +2577,27 @@ public static void ROLLBACK_SNAPSHOT_TXID(String txId) throws SQLException, Stan } } - public static String GET_SNAPSHOT_TXID(Boolean delayRollover) - throws SQLException, StandardException { + public static String GET_SNAPSHOT_TXID_AND_HOSTURL(Boolean delayRollover) + throws SQLException { LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC(); GemFireTransaction tc = (GemFireTransaction)lcc.getTransactionExecute(); TXManagerImpl.TXContext context = TXManagerImpl.currentTXContext(); TXStateInterface tx = context != null ? context.getSnapshotTXState() : null; if (GemFireXDUtils.TraceExecution) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_EXECUTION, - "in function GET_SNAPSHOT_TXID() for conn " + tc.getConnectionID() + "in function GET_SNAPSHOT_TXID_AND_HOSTURL() for conn " + tc.getConnectionID() + " delayRollover=" + delayRollover + " tc id" + tc.getTransactionIdString() + " TxManager " + TXManagerImpl.getCurrentTXId() + " snapshot tx : " + tx); } - String txId; + String txIdAndHostUrl; if (tx != null && !tx.isClosed()) { tx.getProxy().setColumnRolloverDisabled(delayRollover); - txId = tx.getTransactionId().stringFormat(); + txIdAndHostUrl = tx.getTransactionId().stringFormat() + '@' + + GemFireXDUtils.getGfxdAdvisor().getOwnNetServers(); } else { - txId = ""; + txIdAndHostUrl = "@"; } // tc commit will clear all the artifacts but will not commit actual txState // that should be committed in COMMIT procedure @@ -2736,11 +2606,11 @@ public static String GET_SNAPSHOT_TXID(Boolean delayRollover) if (context != null) { context.setSnapshotTXState(null); } - return txId; + return txIdAndHostUrl; } public static void START_SNAPSHOT_TXID(Boolean delayRollover, String[] txid) - throws SQLException, StandardException { + throws SQLException { TXManagerImpl txManager = Misc.getGemFireCache().getCacheTransactionManager(); TXManagerImpl.TXContext context = TXManagerImpl.getOrCreateTXContext(); // rollback any previous transaction (e.g. after task kill) @@ -2767,7 +2637,7 @@ public static void START_SNAPSHOT_TXID(Boolean delayRollover, String[] txid) + " snapshot tx : " + tx); } - if (tx != null && !tx.isClosed()) { + if (!tx.isClosed()) { tx.getProxy().setColumnRolloverDisabled(delayRollover); txid[0] = tx.getTransactionId().stringFormat(); } else { @@ -2824,14 +2694,14 @@ public static void useSnapshotTXId(String txId, } /** - * Get whether the NanoTimer is internally making a native call to get the nanoTime. + * Get whether the NanoTimer is internally making a native call to get the nanoTime. */ public static Boolean GET_IS_NATIVE_NANOTIMER() { return NanoTimer.getIsNativeTimer(); } - + /** - * Get the type of the native NanoTimer being used. + * Get the type of the native NanoTimer being used. */ public static String GET_NATIVE_NANOTIMER_TYPE() { return NanoTimer.getNativeTimerType(); @@ -2846,8 +2716,6 @@ public static String GET_NATIVE_NANOTIMER_TYPE() { * * @param removeInconsistentEntries if true remove inconsistent entries from catalog * @param removeTablesWithData remove entries for tables even if those contain data (by default not removed) - * @throws SQLException - * @throws StandardException */ public static void REPAIR_CATALOG(Boolean removeInconsistentEntries, Boolean removeTablesWithData) throws SQLException, StandardException { @@ -2861,19 +2729,16 @@ public static void REPAIR_CATALOG(Boolean removeInconsistentEntries, Boolean rem private static void runCatalogConsistencyChecks(boolean removeInconsistentEntries, boolean removeTablesWithData) throws SQLException, StandardException { - EmbedConnection conn = GemFireXDUtils.createNewInternalConnection(false); - try { + try (EmbedConnection conn = GemFireXDUtils.createNewInternalConnection(false)) { FabricDatabase.checkSnappyCatalogConsistency(conn, removeInconsistentEntries, removeTablesWithData); - CallbackFactoryProvider.getStoreCallbacks().registerRelationDestroyForHiveStore(); - } finally { - conn.close(); + CallbackFactoryProvider.getStoreCallbacks().registerCatalogSchemaChange(); } } /** * Cancel a statement asynchronously on all nodes i.e. this will not wait for * the response of cancel message. - * + * * @param statementUUID * A UUID of the statement.
*
@@ -2882,24 +2747,20 @@ private static void runCatalogConsistencyChecks(boolean removeInconsistentEntrie * If ExecutionID is 0 in the in the statement UUID, it will be * ignored and the statement that has matching ConncetionID and * StatementID will be cancelled
- * - * @throws SQLException - * @throws StandardException */ public static void CANCEL_STATEMENT(String statementUUID) - throws SQLException, StandardException { - if ((statementUUID == null) || + throws StandardException { + if ((statementUUID == null) || !(statementUUID.matches("[0-9]+-[0-9]+-[0-9]+"))) { throw StandardException.newException( SQLState.LANG_INVALID_FUNCTION_ARGUMENT, statementUUID, "CANCEL_STATEMENT"); } - String s[] = statementUUID.split("-"); long connectionId = Long.parseLong(s[0]); long statementId = Long.parseLong(s[1]); long executionID = Long.parseLong(s[2]); - + if (GemFireXDUtils.TraceExecution) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_EXECUTION, "CANCEL_STATEMENT connectionId=" + connectionId + " statementId=" @@ -2918,14 +2779,8 @@ public static void CANCEL_STATEMENT(String statementUUID) /** * Checks consistency of indexes(local and global) on the given table * - * @param schema - * @param table * @return returns 1 when indexes are consistent, otherwise * throws exception - * - * @throws SQLException - * @throws StandardException - * @throws InterruptedException */ public static int CHECK_TABLE_EX(String schema, String table) throws SQLException, StandardException, InterruptedException { @@ -2943,7 +2798,8 @@ public static int CHECK_TABLE_EX(String schema, String table) throws // just add any one data store member id as 3rd param on which // we will verify global index region size with base table size - if (GemFireXDUtils.getMyVMKind().isStore()) { + final boolean isStore = ServerGroupUtils.isDataStore(); + if (isStore) { params = new Object[]{schema, table, Misc.getMyId()}; } else { Set dataStores = GfxdMessage.getAllDataStores(); @@ -2956,16 +2812,13 @@ public static int CHECK_TABLE_EX(String schema, String table) throws try { // execute on self in a different thread as this procedure might be time // consuming and then send message to other nodes in parallel to execute - if (GemFireXDUtils.getMyVMKind().isStore()) { - thread = new Thread(new Runnable() { - @Override - public void run() { - try { - GfxdSystemProcedureMessage.SysProcMethod. - checkTableEx.processMessage(params, Misc.getMyId()); - } catch (StandardException s) { - failure[0] = s; - } + if (isStore) { + thread = new Thread(() -> { + try { + GfxdSystemProcedureMessage.SysProcMethod. + checkTableEx.processMessage(params, Misc.getMyId()); + } catch (StandardException s) { + failure[0] = s; } }, "CHECK_TABLE_EX sys proc executor"); thread.start(); @@ -2976,11 +2829,11 @@ public void run() { } finally { if (thread != null) { thread.join(); - if (failure[0] != null) { - throw failure[0]; - } } } + if (failure[0] != null) { + throw failure[0]; + } return 1; } @@ -3000,8 +2853,7 @@ public void run() { public static void REFRESH_LDAP_GROUP(String ldapGroup) throws SQLException { if (ldapGroup == null) { throw PublicAPI.wrapStandardException(StandardException.newException( - SQLState.LANG_INVALID_FUNCTION_ARGUMENT, ldapGroup, - "REFRESH_LDAP_GROUP")); + SQLState.LANG_INVALID_FUNCTION_ARGUMENT, null, "REFRESH_LDAP_GROUP")); } ldapGroup = StringUtil.SQLToUpperCase(ldapGroup); @@ -3014,15 +2866,14 @@ public static void REFRESH_LDAP_GROUP(String ldapGroup) throws SQLException { final LDAPAuthenticationSchemeImpl ldapAuth; final Set currentMembers; try { - AuthenticationService authService = Misc.getMemStoreBooting() + AuthenticationServiceBase authService = Misc.getMemStoreBooting() .getDatabase().getAuthenticationService(); if (authService == null) { throw new javax.naming.NameNotFoundException( "Require LDAP authentication scheme for " + "LDAP group support no authentication is disabled"); } - UserAuthenticator auth = ((AuthenticationServiceBase)authService) - .getAuthenticationScheme(); + UserAuthenticator auth = authService.getAuthenticationScheme(); if (auth instanceof LDAPAuthenticationSchemeImpl) { ldapAuth = (LDAPAuthenticationSchemeImpl)auth; } else { @@ -3046,7 +2897,7 @@ public static void REFRESH_LDAP_GROUP(String ldapGroup) throws SQLException { ddLocked = lcc.getDataDictionary().lockForWriting(tc, false); // make a copy of currentMembers since it gets modified in // refreshLdapGroup call below - final THashSet origMembers = new THashSet(currentMembers); + final UnifiedSet origMembers = new UnifiedSet<>(currentMembers); // refresh the LDAP groups on this node first final Object[] params = new Object[] { ldapGroup, currentMembers }; GfxdSystemProcedureMessage.SysProcMethod.refreshLdapGroup @@ -3082,7 +2933,7 @@ public static void GET_COLUMN_TABLE_SCHEMA(String schema, String table, Clob[] schemaAsJson) throws SQLException { String schemaString = Misc.getMemStore().getExistingExternalCatalog() - .getColumnTableSchemaAsJson(schema, table, true); + .getColumnTableSchemaAsJson(schema, table); if (schemaString == null) { throw PublicAPI.wrapStandardException(StandardException.newException( SQLState.TABLE_NOT_FOUND, table)); @@ -3139,7 +2990,7 @@ public static void COLUMN_TABLE_SCAN(String columnTable, String projection, result[0] = new CustomRowsResultSet(new CustomRowsResultSet.FetchDVDRows() { @Override public boolean getNext(DataValueDescriptor[] template) - throws SQLException, StandardException { + throws StandardException { if (iter.hasNext()) { ColumnTableEntry entry = iter.next(); template[0].setValue(entry.uuid); @@ -3159,7 +3010,7 @@ public boolean getNext(DataValueDescriptor[] template) } @Override - public void close() throws SQLException { + public void close() { iter.close(); } }, columnScanInfo); @@ -3192,8 +3043,7 @@ public static void authorizeTableOperation(LanguageConnectionContext lcc, permissions.add(new StatementTablePermission(td.getUUID(), authType)); if (numColumns > 0) { FormatableBitSet bitSet = new FormatableBitSet(td.getNumberOfColumns()); - for (int i = 0; i < numColumns; i++) { - int col = columns[i]; + for (int col : columns) { ColumnDescriptor cd = td.getColumnDescriptor(col); if (cd == null) { throw StandardException.newException(SQLState.LANG_COLUMN_NOT_FOUND, @@ -3214,7 +3064,7 @@ public static void authorizeTableOperation(LanguageConnectionContext lcc, * supported in JSR 169. IN addition we need to perform more checks for null * drivers or the driver returing null from connect as that logic is in * DriverManager. - * + * * @return The nested connection * @throws SQLException * Not running in a SQL statement diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ddl/catalog/messages/GfxdSystemProcedureMessage.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ddl/catalog/messages/GfxdSystemProcedureMessage.java index 02c6d355a..9ff24444d 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ddl/catalog/messages/GfxdSystemProcedureMessage.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ddl/catalog/messages/GfxdSystemProcedureMessage.java @@ -41,6 +41,7 @@ import com.gemstone.gemfire.internal.cache.DiskStoreImpl; import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; import com.gemstone.gemfire.internal.cache.LocalRegion; +import com.gemstone.gemfire.internal.shared.ClientSharedUtils; import com.gemstone.gemfire.internal.snappy.CallbackFactoryProvider; import com.gemstone.gemfire.internal.util.ArrayUtils; import com.pivotal.gemfirexd.Constants; @@ -51,7 +52,7 @@ import com.pivotal.gemfirexd.internal.engine.GfxdSerializable; import com.pivotal.gemfirexd.internal.engine.Misc; import com.pivotal.gemfirexd.internal.engine.access.index.GfxdIndexManager; -import com.pivotal.gemfirexd.internal.engine.ddl.GfxdDDLPreprocess; +import com.pivotal.gemfirexd.internal.engine.ddl.GfxdDDLPreprocessOrPostProcess; import com.pivotal.gemfirexd.internal.engine.ddl.callbacks.CallbackProcedures; import com.pivotal.gemfirexd.internal.engine.ddl.catalog.GfxdSystemProcedures; import com.pivotal.gemfirexd.internal.engine.ddl.wan.messages.AbstractGfxdReplayableMessage; @@ -98,7 +99,7 @@ * */ public final class GfxdSystemProcedureMessage extends - AbstractGfxdReplayableMessage implements GfxdDDLPreprocess { + AbstractGfxdReplayableMessage implements GfxdDDLPreprocessOrPostProcess { private static final long serialVersionUID = 2039841562674551814L; @@ -106,6 +107,7 @@ public final class GfxdSystemProcedureMessage extends protected static final short INITIAL_DDL_REPLAY_IN_PROGRESS = (HAS_SERVER_GROUPS << 1); + public enum SysProcMethod { setDatabaseProperty { @@ -1082,7 +1084,7 @@ public void processMessage(Object[] params, DistributedMember sender) throws StandardException { try { String logClass = (String) params[0]; - Level level = org.apache.log4j.Level.toLevel((String) params[1]); + Level level = ClientSharedUtils.convertToLog4LogLevel((String)params[1]); SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_SYS_PROCEDURES, "GfxdSystemProcedureMessage: setting log level for class '" + logClass + "' to " + level); @@ -1505,7 +1507,7 @@ public void processMessage(Object[] params, DistributedMember sender) { Boolean useNativeTimer = (Boolean)params[0]; String nativeTimerType = (String)params[1]; SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_SYS_PROCEDURES, - "GfxdSystemProcedureMessage:SET_NANOTIMER_TYPE native timer: " + useNativeTimer + + "GfxdSystemProcedureMessage:SET_NANOTIMER_TYPE native timer: " + useNativeTimer + " NativeTimerType: " + nativeTimerType ); NanoTimer.setNativeTimer(useNativeTimer, nativeTimerType); } @@ -1535,6 +1537,68 @@ String getSQLStatement(Object[] params) throws StandardException { } }, + createOrDropReservoirRegion { + @Override + public void processMessage(Object[] params, DistributedMember sender) { + String reservoirRegionName = (String)params[0]; + String resolvedBaseName = (String)params[1]; + Boolean isDrop = (Boolean)params[2]; + SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_SYS_PROCEDURES, + "GfxdSystemProcedureMessage:CREATE_OR_DROP_RESERVOIR_REGION " + + "reservoirRegionName=" + reservoirRegionName + + " resolvedBaseName=" + resolvedBaseName + " isDrop=" + isDrop); + GfxdSystemProcedures.createOrDropReservoirRegion(reservoirRegionName, + resolvedBaseName, isDrop); + } + + @Override + public Object[] readParams(DataInput in, short flags) throws IOException { + Object[] inParams = new Object[3]; + inParams[0] = in.readUTF(); + inParams[1] = in.readUTF(); + inParams[2] = in.readBoolean(); + return inParams; + } + + @Override + public void writeParams(Object[] params, DataOutput out) + throws IOException { + out.writeUTF((String)params[0]); + out.writeUTF((String)params[1]); + out.writeBoolean((Boolean)params[2]); + } + + @Override + boolean preprocess() { + return false; + } + + boolean postprocess() { + return true; + } + + @Override + boolean shouldBeConflated(Object[] params) { + return (Boolean)params[2]; + } + + @Override + String getRegionToConflate(Object[] params) { + return "SYS.__SNAPPY_INTERNAL_RESERVOIR"; + } + + @Override + Object getKeyToConflate(Object[] params) { + return params[0]; + } + + @Override + String getSQLStatement(Object[] params) { + return "CALL SYS.CREATE_OR_DROP_RESERVOIR_REGION('" + params[0] + + "','" + params[1] + "'," + params[2] + ')'; + } + }, + checkTableEx { @Override @@ -1882,7 +1946,7 @@ String getSQLStatement(Object[] params) throws StandardException { * if it is a {@link VMKind#LOCATOR}, for example. */ boolean allowExecution(Object[] params) throws StandardException { - return GemFireXDUtils.getMyVMKind().isAccessorOrStore(); + return Misc.getMemStoreBooting().getMyVMKind().isAccessorOrStore(); } public abstract void processMessage(Object[] params, @@ -1954,6 +2018,10 @@ boolean preprocess() { return true; } + boolean postprocess() { + return false; + } + abstract String getSQLStatement(Object[] params) throws StandardException; void appendParams(Object[] params, StringBuilder sb) { @@ -1989,6 +2057,7 @@ public GfxdSystemProcedureMessage() { this.procMethod = null; this.params = null; this.sender = null; + //assert !(preprocess() && postprocess()); } public GfxdSystemProcedureMessage(SysProcMethod procMethod, Object[] params, @@ -2001,6 +2070,7 @@ public GfxdSystemProcedureMessage(SysProcMethod procMethod, Object[] params, this.params = params; this.sender = sender; this.initialDDLReplayInProgress = Misc.initialDDLReplayInProgress(); + assert !(procMethod.preprocess() && procMethod.postprocess()); } @Override @@ -2234,6 +2304,10 @@ public boolean preprocess() { return this.procMethod.preprocess(); } + public boolean postprocess() { + return this.procMethod.postprocess(); + } + /** * {@inheritDoc} */ diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/diag/DiskStoreIDs.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/diag/DiskStoreIDs.java index 6b3d83a09..553658a91 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/diag/DiskStoreIDs.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/diag/DiskStoreIDs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/diag/HiveTablesVTI.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/diag/HiveTablesVTI.java index 9a7a80108..f0be6f493 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/diag/HiveTablesVTI.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/diag/HiveTablesVTI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -36,6 +36,8 @@ import com.pivotal.gemfirexd.internal.iapi.types.HarmonySerialClob; import com.pivotal.gemfirexd.internal.impl.jdbc.EmbedResultSetMetaData; import com.pivotal.gemfirexd.internal.impl.jdbc.Util; +import com.pivotal.gemfirexd.internal.impl.sql.catalog.GfxdDataDictionary; +import com.pivotal.gemfirexd.internal.shared.common.SharedUtils; import com.pivotal.gemfirexd.internal.shared.common.reference.Limits; import com.pivotal.gemfirexd.internal.shared.common.reference.SQLState; import org.slf4j.Logger; @@ -48,9 +50,6 @@ public class HiveTablesVTI extends GfxdVTITemplate implements GfxdVTITemplateNoAllNodesRoute { - public static final ThreadLocal SKIP_HIVE_TABLE_CALLS = - new ThreadLocal<>(); - private final Logger logger = LoggerFactory.getLogger(getClass().getName()); private Iterator tableMetas; @@ -67,10 +66,10 @@ public ResultSetMetaData getMetaData() throws SQLException { public boolean next() { if (this.tableMetas == null) { final ExternalCatalog hiveCatalog; - if (!Boolean.TRUE.equals(HiveTablesVTI.SKIP_HIVE_TABLE_CALLS.get()) && + if (!GfxdDataDictionary.SKIP_CATALOG_OPS.get().skipHiveCatalogCalls && (hiveCatalog = Misc.getMemStore().getExternalCatalog()) != null) { try { - this.tableMetas = hiveCatalog.getHiveTables(true).iterator(); + this.tableMetas = hiveCatalog.getCatalogTables().iterator(); } catch (Exception e) { // log and move on logger.warn("ERROR in retrieving Hive tables: " + e.toString()); @@ -98,13 +97,13 @@ public boolean next() { } @Override - protected Object getObjectForColumn(int columnNumber) throws SQLException { + protected Object getObjectForColumn(int columnNumber) { String provider = this.currentTableMeta.shortProvider; switch (columnNumber) { case 1: // SCHEMA - return this.currentTableMeta.schema; + return SharedUtils.SQLToUpperCase(this.currentTableMeta.schema.toString()); case 2: // TABLE - return this.currentTableMeta.entityName; + return SharedUtils.SQLToUpperCase(this.currentTableMeta.entityName); case 3: // TYPE return this.currentTableMeta.tableType; case 4: // PROVIDER @@ -117,14 +116,14 @@ protected Object getObjectForColumn(int columnNumber) throws SQLException { case 5: // SOURCEPATH // only show for ordinal 0 and avoid repetition if (this.currentTableColumns.nextIndex() == 1) { - return provider != null && (provider.startsWith("jdbc") - || provider.endsWith("JdbcRelationProvider")) - ? currentTableMeta.driverClass : currentTableMeta.dataSourcePath; + return currentTableMeta.dataSourcePath; } else return ""; case 6: // COMPRESSION String compression = this.currentTableMeta.compressionCodec; return compression != null ? compression - : ("COLUMN".equals(this.currentTableMeta.tableType) + : ("COLUMN".equalsIgnoreCase(this.currentTableMeta.tableType) || + "INDEX".equalsIgnoreCase(this.currentTableMeta.tableType) || + "SAMPLE".equalsIgnoreCase(this.currentTableMeta.tableType) ? SystemProperties.SNAPPY_DEFAULT_COMPRESSION_CODEC : null); case 7: // COLUMN return this.currentTableColumn.name; diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/diag/SnappyTableStatsVTI.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/diag/SnappyTableStatsVTI.java index 8c2691d8f..3d71f0b6a 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/diag/SnappyTableStatsVTI.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/diag/SnappyTableStatsVTI.java @@ -127,7 +127,7 @@ protected Object getObjectForColumn(int columnNumber) throws SQLException { * Metadata */ - private static final String TABLE = "TABLE"; + private static final String TABLENAME = "TABLENAME"; private static final String IS_COLUMN_TABLE = "IS_COLUMN_TABLE"; @@ -142,7 +142,7 @@ protected Object getObjectForColumn(int columnNumber) throws SQLException { private static final String BUCKETS = "BUCKETS"; private static final ResultColumnDescriptor[] columnInfo = { - EmbedResultSetMetaData.getResultColumnDescriptor(TABLE, + EmbedResultSetMetaData.getResultColumnDescriptor(TABLENAME, Types.VARCHAR, false, 512), EmbedResultSetMetaData.getResultColumnDescriptor(IS_COLUMN_TABLE, Types.BOOLEAN, false), diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/diag/SysPoliciesVTI.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/diag/SysPoliciesVTI.java index 625436c2d..66ba91735 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/diag/SysPoliciesVTI.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/diag/SysPoliciesVTI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -31,6 +31,8 @@ import com.pivotal.gemfirexd.internal.engine.jdbc.GemFireXDRuntimeException; import com.pivotal.gemfirexd.internal.iapi.sql.ResultColumnDescriptor; import com.pivotal.gemfirexd.internal.impl.jdbc.EmbedResultSetMetaData; +import com.pivotal.gemfirexd.internal.impl.sql.catalog.GfxdDataDictionary; +import com.pivotal.gemfirexd.internal.shared.common.SharedUtils; import com.pivotal.gemfirexd.internal.shared.common.reference.Limits; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -55,10 +57,10 @@ public ResultSetMetaData getMetaData() throws SQLException { public boolean next() { if (this.policyDatas == null) { final ExternalCatalog hiveCatalog; - if (!Boolean.TRUE.equals(HiveTablesVTI.SKIP_HIVE_TABLE_CALLS.get()) && + if (!GfxdDataDictionary.SKIP_CATALOG_OPS.get().skipHiveCatalogCalls && (hiveCatalog = Misc.getMemStore().getExternalCatalog()) != null) { try { - this.policyDatas = hiveCatalog.getPolicies(true).iterator(); + this.policyDatas = hiveCatalog.getPolicies().iterator(); } catch (Exception e) { // log and move on logger.warn("ERROR in retrieving Policies : " + e.toString()); @@ -78,14 +80,14 @@ public boolean next() { } @Override - protected Object getObjectForColumn(int columnNumber) throws SQLException { + protected Object getObjectForColumn(int columnNumber) { switch (columnNumber) { case 1: // Policy Name - return this.currentPolicyMeta.policyName; + return SharedUtils.SQLToUpperCase(this.currentPolicyMeta.policyName); case 2: // TABLE SCHEMA NAME - return this.currentPolicyMeta.schemaName; + return SharedUtils.SQLToUpperCase(this.currentPolicyMeta.schemaName); case 3: // TABLE - return this.currentPolicyMeta.tableName; + return SharedUtils.SQLToUpperCase(this.currentPolicyMeta.tableName); case 4: // For return this.currentPolicyMeta.policyFor; case 5: // Apply To diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/GfxdConnectionWrapper.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/GfxdConnectionWrapper.java index 8dc2e8f47..2c666fd3f 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/GfxdConnectionWrapper.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/GfxdConnectionWrapper.java @@ -33,7 +33,6 @@ import com.gemstone.gemfire.internal.shared.SystemProperties; import com.gemstone.gemfire.internal.util.ArrayUtils; import com.gemstone.gnu.trove.THashMap; -import com.koloboke.function.LongObjPredicate; import com.pivotal.gemfirexd.Attribute; import com.pivotal.gemfirexd.internal.engine.GemFireXDQueryObserver; import com.pivotal.gemfirexd.internal.engine.GemFireXDQueryObserverHolder; @@ -58,7 +57,8 @@ import com.pivotal.gemfirexd.internal.impl.sql.execute.ResultSetStatisticsVisitor; import com.pivotal.gemfirexd.internal.jdbc.InternalDriver; import com.pivotal.gemfirexd.internal.shared.common.sanity.SanityManager; -import io.snappydata.collection.LongObjectHashMap; +import org.eclipse.collections.api.block.procedure.Procedure; +import org.eclipse.collections.impl.map.mutable.primitive.LongObjectHashMap; /** * Wrapper class for Connections that provides for statement caching, convert to @@ -137,8 +137,8 @@ public final class GfxdConnectionWrapper { final EmbedConnection conn = createConnection(defaultSchema, isRemote, isRemoteDDL, props); this.embedConn = conn; - this.stmntMap = LongObjectHashMap.withExpectedSize(8); - this.sqlMap = LongObjectHashMap.withExpectedSize(8); + this.stmntMap = new LongObjectHashMap<>(8); + this.sqlMap = new LongObjectHashMap<>(8); this.refQueue = new ReferenceQueue(); } else { @@ -252,11 +252,11 @@ public EmbedStatement getStatement(String sql, long stmtId, } else { stmnt = (EmbedStatement)getConnection().prepareCall(sql, stmtId); } - this.stmntMap.justPut(stmtId, new StmntWeakReference(stmnt, stmtId, + this.stmntMap.put(stmtId, new StmntWeakReference(stmnt, stmtId, this.refQueue)); if (!(defaultSchema != null && defaultSchema.equalsIgnoreCase(SystemProperties.SNAPPY_HIVE_METASTORE))) { - this.sqlMap.justPut(stmtId, sql); + this.sqlMap.put(stmtId, sql); } if (GemFireXDUtils.TraceQuery | GemFireXDUtils.TraceNCJ) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_QUERYDISTRIB, @@ -287,7 +287,7 @@ public EmbedStatement getStatement(String sql, long stmtId, // cleanup statement map first cleanUpStmntMap(); stmnt = (EmbedStatement)getConnection().createStatement(stmtId); - this.stmntMap.justPut(stmtId, new StmntWeakReference(stmnt, stmtId, + this.stmntMap.put(stmtId, new StmntWeakReference(stmnt, stmtId, this.refQueue)); if (GemFireXDUtils.TraceQuery) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_QUERYDISTRIB, @@ -717,7 +717,7 @@ private boolean clearStatementMap() { // Iterate over the map & close the statements // no need to synchronize since we expect only one thread to access // a connection at a time in any case - this.stmntMap.forEachWhile(collectStmts); + this.stmntMap.forEachValue(collectStmts); stmts = collectStmts.stmts; this.stmntMap.clear(); } @@ -762,7 +762,7 @@ public boolean isCached() { public void closeStatement(long statementID) throws SQLException { Object stmt; synchronized (this.stmntMap) { - stmt = this.stmntMap.remove(statementID); + stmt = this.stmntMap.removeKey(statementID); // also cleanup statement map cleanUpStmntMap(); } @@ -961,7 +961,7 @@ private void removeWeakReferenceFromStmntMap(long stmntId, SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_QUERYDISTRIB, "GfxdConnectionWrapper#removeWeakReferenceFromStmntMap: " + "removing statement with id: " + stmntId); - this.stmntMap.remove(stmntId); + this.stmntMap.removeKey(stmntId); } } } @@ -972,7 +972,7 @@ private void removeWeakReferenceFromStmntMap(long stmntId, public void removeStmtFromMap(long stmntId) { if (this.stmntMap != null) { synchronized (this.stmntMap) { - this.stmntMap.remove(stmntId); + this.stmntMap.removeKey(stmntId); } } } @@ -1003,12 +1003,14 @@ public final void process(final EmbedConnection conn, } private static final class CollectStmts - implements LongObjPredicate { + implements Procedure { + + private static final long serialVersionUID = -5116743221959686823L; ArrayList stmts; @Override - public boolean test(final long id, StmntWeakReference stmtRef) { + public void value(StmntWeakReference stmtRef) { Object stmt = stmtRef.get(); if (stmt != null) { if (this.stmts == null) { @@ -1016,7 +1018,6 @@ public boolean test(final long id, StmntWeakReference stmtRef) { } this.stmts.add(stmt); } - return true; } } diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/GfxdDistributionAdvisor.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/GfxdDistributionAdvisor.java index 6a50eb7b6..3fade95d3 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/GfxdDistributionAdvisor.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/GfxdDistributionAdvisor.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -45,7 +45,7 @@ import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; -import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; import com.gemstone.gemfire.CancelCriterion; import com.gemstone.gemfire.DataSerializer; @@ -72,7 +72,6 @@ import com.gemstone.gemfire.internal.shared.ClientSharedUtils; import com.gemstone.gemfire.internal.shared.Version; import com.gemstone.gemfire.internal.util.concurrent.StoppableReentrantReadWriteLock; -import com.gemstone.gnu.trove.THashMap; import com.gemstone.gnu.trove.THashSet; import com.gemstone.gnu.trove.TObjectProcedure; import com.pivotal.gemfirexd.FabricService; @@ -268,8 +267,11 @@ public void handshake(LogWriter logger) { @Override protected final GfxdProfile instantiateProfile( InternalDistributedMember memberId, int version) { - return new GfxdProfile(memberId, version, - CallbackFactoryProvider.getClusterCallbacks().getDriverURL()); + final GfxdProfile currentProfile = this.myProfile; + long catalogVersion = currentProfile != null + ? currentProfile.getCatalogSchemaVersion() : 0; + return new GfxdProfile(memberId, version, CallbackFactoryProvider + .getClusterCallbacks().getDriverURL(), catalogVersion); } /** @@ -309,6 +311,11 @@ protected final synchronized boolean basicAddProfile(Profile p) { removeMemberGroups(m); addMemberGroups(m, profile.getServerGroups(), profile.getVMKind()); } + // update own catalog version + final GfxdProfile myProfile = this.myProfile; + if (myProfile != null) { + myProfile.updateCatalogSchemaVersion(profile.getCatalogSchemaVersion()); + } } else if (p instanceof BridgeServerProfile) { final BridgeServerProfile bp = (BridgeServerProfile)p; @@ -633,51 +640,11 @@ public final DistributedMember adviseOperationNode(Set groups, return adviseSingleVMOfKind(groups, VMKindToken.SERVER, preferSelf); } - /** - * Return a single member that has a server locator running, including those - * with pure GFE locators when the "skipNonGfxd" parameter is false. - * - * @param preferSelf - * prefer this VM if it has a server locator running - * @param skipNonGfxd - * when true then skip non GemFireXD locators else include pure GFE - * locators too in the search - */ - public final DistributedMember adviseServerLocator(boolean preferSelf, - boolean skipNonGfxd) { - this.mapLock.readLock().lock(); - try { - InternalDistributedMember member; - if (preferSelf) { - member = this.myProfile.getDistributedMember(); - if (this.locatorMap.get(member) != null) { - return member; - } - } - Map gfxdMembers = null; - if (skipNonGfxd) { - gfxdMembers = this.serverGroupMap.get(DEFAULT_GROUP); - } - for (Map.Entry entry : locatorMap - .entrySet()) { - if (entry.getValue() != null) { - member = entry.getKey(); - if (gfxdMembers == null || gfxdMembers.containsKey(member)) { - return member; - } - } - } - } finally { - this.mapLock.readLock().unlock(); - } - return null; - } - /** Get the {@link Profile} for the given member including self. */ public GfxdProfile getProfile(InternalDistributedMember member) { Profile profile = super.getProfile(member); - if (profile != null - || (profile = getMyProfile()).getDistributedMember().equals(member)) { + if (profile != null || ((profile = getMyProfile()) != null && + profile.getDistributedMember().equals(member))) { return (GfxdProfile)profile; } return null; @@ -696,7 +663,8 @@ public GfxdProfile getProfile(String memberStr) { } } GfxdProfile profile = getMyProfile(); - if (profile.getDistributedMember().canonicalString().equals(memberStr)) { + if (profile != null && + profile.getDistributedMember().canonicalString().equals(memberStr)) { return profile; } else { return null; @@ -889,43 +857,6 @@ else if (!serverTypes.contains(serverType)) { } } - /** - * Get all the thrift servers in the distributed system. Returns a map from - * the {@link InternalDistributedMember} for the member to the set of - * {@link HostAddress}es of the thrift servers active on that member. - */ - public final Map> - getAllThriftServers() { - @SuppressWarnings("unchecked") - Map> servers = new THashMap(); - this.mapLock.readLock().lock(); - try { - // first add for self - final FabricService service = FabricServiceManager - .currentFabricServiceInstance(); - if (service != null) { - ServerType serverType; - Collection ifaces = service.getAllNetworkServers(); - @SuppressWarnings("unchecked") - Set thriftServers = new THashSet(ifaces.size()); - for (NetworkInterface ni : ifaces) { - serverType = ni.getServerType(); - if (!serverType.isThrift()) { - continue; - } - thriftServers.add(ThriftUtils.getHostAddress(ni.getHostName(), - ni.getPort()).setServerType(serverType)); - } - servers.put(this.myProfile.getDistributedMember(), thriftServers); - } - // then for all the other members of the DS - servers.putAll(this.thriftServers); - } finally { - this.mapLock.readLock().unlock(); - } - return servers; - } - /** * Get all the Thrift servers running on the given member as a comma-separated * host[port] list. @@ -1033,6 +964,43 @@ public final String getAllDRDAServers() { return allServers.toString(); } + /** + * Get the network servers hosted on this server, if any. + */ + public final String getOwnNetServers() { + this.mapLock.readLock().lock(); + try { + return getSelfNetServers(ClientSharedUtils.isThriftDefault()); + } finally { + this.mapLock.readLock().unlock(); + } + } + + /** + * Get the network servers hosted on this server, if any. + * Should be invoked under mapLock.readLock(). + */ + private String getSelfNetServers(boolean useThrift) { + StringBuilder serverSB = new StringBuilder(); + VMKind kind = this.myProfile.getVMKind(); + // first add for self + final FabricService service = FabricServiceManager + .currentFabricServiceInstance(); + if (service != null) { + for (NetworkInterface ni : service.getAllNetworkServers()) { + if (useThrift) { + if (!ni.getServerType().isThrift()) continue; + } else if (!ni.getServerType().isDRDA()) continue; + if (serverSB.length() > 0) { + serverSB.append(','); + } + serverSB.append(ni.asString()).append(MEMBER_KIND_BEGIN) + .append(kind.toString()).append(MEMBER_KIND_END); + } + } + return serverSB.toString(); + } + /** * Get the mapping of InternalDistributedMember to corresponding DRDA/Thrift servers * they have in the entire system. The format of the network server string is: @@ -1050,33 +1018,22 @@ public final String getAllDRDAServers() { public final Map getAllNetServersWithMembers() { HashMap mbrToNetworkServerMap = new HashMap(); - StringBuilder serverSB = new StringBuilder(); final boolean useThrift = ClientSharedUtils.isThriftDefault(); this.mapLock.readLock().lock(); try { - VMKind kind = this.myProfile.getVMKind(); // first add for self - final FabricService service = FabricServiceManager - .currentFabricServiceInstance(); - if (service != null) { - for (NetworkInterface ni : service.getAllNetworkServers()) { - if (useThrift) { - if (!ni.getServerType().isThrift()) continue; - } else if (!ni.getServerType().isDRDA()) continue; - if (serverSB.length() > 0) { - serverSB.append(','); - } - serverSB.append(ni.asString()).append(MEMBER_KIND_BEGIN) - .append(kind.toString()).append(MEMBER_KIND_END); - } + String selfNetServers = getSelfNetServers(useThrift); + if (selfNetServers.length() > 0) { mbrToNetworkServerMap.put(this.myProfile.getDistributedMember(), - serverSB.toString()); + selfNetServers); } // then for all the other members of the DS final Map gfxdMembers = this.serverGroupMap.get(DEFAULT_GROUP); Set servers; Map serverMap = useThrift ? thriftServers : drdaServerMap; + StringBuilder serverSB; + VMKind kind; for (Map.Entry entry : serverMap.entrySet()) { InternalDistributedMember m = (InternalDistributedMember)entry.getKey(); servers = (Set)entry.getValue(); @@ -1096,8 +1053,8 @@ public final Map getAllNetServersWithMembers( serverSB.append(MEMBER_KIND_BEGIN).append(kind.toString()) .append(MEMBER_KIND_END); } + mbrToNetworkServerMap.put(m, serverSB.toString()); } - mbrToNetworkServerMap.put(m, serverSB.toString()); } } finally { this.mapLock.readLock().unlock(); @@ -1339,6 +1296,8 @@ public static final class GfxdProfile extends DistributionAdvisor.Profile private static final byte F_HAS_SPARK_DRIVERURL = 0x4; private static final byte F_HAS_PROCESSOR_COUNT = 0x8; + + private static final byte F_HAS_LONG_CATALOG_VERSION = 0x10; // end bitmasks /** OR of various bitmasks above */ @@ -1365,7 +1324,12 @@ public static final class GfxdProfile extends DistributionAdvisor.Profile */ private String sparkDriverUrl; - private AtomicInteger relationDestroyVersion; + /** + * The schema version of ExternalCatalog implementation (SnappyHiveExternalCatalog) + * is tracked in the profile because it needs to be exchanged with other nodes + * to make sure that it is consistent on all the nodes. + */ + private AtomicLong catalogSchemaVersion; /** for deserialization */ public GfxdProfile() { @@ -1373,20 +1337,22 @@ public GfxdProfile() { } /** construct a new instance for given member and with given version */ - public GfxdProfile(InternalDistributedMember memberId, int version, String sparkUrl) { + public GfxdProfile(InternalDistributedMember memberId, int version, + String sparkUrl, long catalogVersion) { super(memberId, version); this.initialized = true; this.numProcessors = Runtime.getRuntime().availableProcessors(); this.sparkDriverUrl = sparkUrl; boolean hasURL = sparkDriverUrl != null && !sparkDriverUrl.equals(""); + this.catalogSchemaVersion = new AtomicLong(catalogVersion); setHasSparkURL(hasURL); initFlags(); - relationDestroyVersion = new AtomicInteger(0); } private void initFlags() { this.flags |= F_HASLOCALE; this.flags |= F_HAS_PROCESSOR_COUNT; + this.flags |= F_HAS_LONG_CATALOG_VERSION; } public final VMKind getVMKind() { @@ -1435,9 +1401,25 @@ public final boolean hasSparkURL() { return (this.flags & F_HAS_SPARK_DRIVERURL) != 0; } - public final void setRelationDestroyVersion(int value){ relationDestroyVersion.set(value); } + public final long getCatalogSchemaVersion() { + return catalogSchemaVersion.get(); + } - public final int getRelationDestroyVersion() { return relationDestroyVersion.get(); } + public final void updateCatalogSchemaVersion(long version) { + // update the catalog version only if it is higher than the one already present + while (true) { + long currentVersion = catalogSchemaVersion.get(); + if (version > currentVersion) { + if (catalogSchemaVersion.compareAndSet(currentVersion, version)) { + return; + } + } else return; + } + } + + public final void incrementCatalogSchemaVersion() { + this.catalogSchemaVersion.incrementAndGet(); + } public final void setInitialized(boolean initialized) { this.initialized = initialized; @@ -1539,7 +1521,7 @@ public final void toData(DataOutput out) throws IOException { if (hasSparkURL()) { DataSerializer.writeString(sparkDriverUrl, out); } - DataSerializer.writeInteger(relationDestroyVersion.get(), out); + out.writeLong(this.catalogSchemaVersion.get()); } @Override @@ -1571,7 +1553,12 @@ public final void fromData(DataInput in) throws IOException, if (hasSparkURL()) { this.sparkDriverUrl = DataSerializer.readString(in); } - relationDestroyVersion = new AtomicInteger(DataSerializer.readInteger(in)); + // older version nodes have integer catalog version while new ones use long + if ((this.flags & F_HAS_LONG_CATALOG_VERSION) != 0) { + this.catalogSchemaVersion = new AtomicLong(in.readLong()); + } else { + this.catalogSchemaVersion = new AtomicLong(in.readInt()); + } } @Override @@ -1589,6 +1576,7 @@ public final void fillInToString(StringBuilder sb) { sb.append("; initialized=").append(this.initialized); sb.append("; dbLocaleStr=").append(this.dbLocaleStr); sb.append("; numProcessors=").append(this.numProcessors); + sb.append("; catalogVersion=").append(this.catalogSchemaVersion.get()); } } diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/ReferencedKeyCheckerMessage.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/ReferencedKeyCheckerMessage.java index ba391e8fd..4d2982d66 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/ReferencedKeyCheckerMessage.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/ReferencedKeyCheckerMessage.java @@ -92,7 +92,7 @@ import com.pivotal.gemfirexd.internal.impl.jdbc.EmbedConnection; import com.pivotal.gemfirexd.internal.impl.sql.execute.xplain.XPLAINUtil; import com.pivotal.gemfirexd.internal.shared.common.sanity.SanityManager; -import io.snappydata.collection.IntObjectHashMap; +import org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap; /** * This function is used to check the referenced key constraint after we @@ -885,8 +885,7 @@ public void fromData(DataInput in) boolean refColSameAfterModFlag = in.readBoolean(); if (refColSameAfterModFlag) { int numElements = in.readInt(); - this.refColSameAfterModBitsMapping = IntObjectHashMap.withExpectedSize( - numElements); + this.refColSameAfterModBitsMapping = new IntObjectHashMap<>(numElements); int byteArraySize = FormatableBitSet .numBytesFromBits(this.refColsUpdtdBits.getNumBitsSet()); for (int i = 0; i < numElements; ++i) { @@ -896,7 +895,7 @@ public void fromData(DataInput in) for (int j = 0; j < byteArraySize; ++j) { bytes[j] = in.readByte(); } - this.refColSameAfterModBitsMapping.justPut(rowNum,bytes); + this.refColSameAfterModBitsMapping.put(rowNum,bytes); } } @@ -989,13 +988,12 @@ public void toData(final DataOutput out) throws IOException { if (this.refColSameAfterModBitsMapping != null) { out.writeBoolean(true); out.writeInt(this.refColSameAfterModBitsMapping.size()); - this.refColSameAfterModBitsMapping.forEachWhile((rowNum, refColSameAfterUpdt) -> { + this.refColSameAfterModBitsMapping.forEachKeyValue((rowNum, refColSameAfterUpdt) -> { try { out.writeInt(rowNum); for (byte b : refColSameAfterUpdt) { out.writeByte(b); } - return true; } catch (IOException ioe) { throw new GemFireIOException(ioe.getMessage(), ioe); } @@ -1121,14 +1119,13 @@ private void identifyUpdatedColsUnchangedAndColsToWrite( if (old.equals(modified)) { // set bit on to indicate no change if (this.refColSameAfterModBitsMapping == null) { - this.refColSameAfterModBitsMapping = - IntObjectHashMap.withExpectedSize(8); + this.refColSameAfterModBitsMapping = new IntObjectHashMap<>(8); } if (refColSameAfterUpdt == null) { int numCols = this.refColUpdtd2DependentCols.size(); refColSameAfterUpdt = new byte[FormatableBitSet .numBytesFromBits(numCols)]; - this.refColSameAfterModBitsMapping.justPut(rowNum, refColSameAfterUpdt); + this.refColSameAfterModBitsMapping.put(rowNum, refColSameAfterUpdt); } // based on j identify the right byte from array & its pos // TODO:Asif clean up. diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/SnappyResultHolder.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/SnappyResultHolder.java index 91f6a1b28..4a2351a07 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/SnappyResultHolder.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/SnappyResultHolder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -20,6 +20,7 @@ import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; +import java.sql.SQLWarning; import java.sql.Types; import java.util.Iterator; @@ -53,15 +54,16 @@ public final class SnappyResultHolder extends GfxdDataSerializable { private transient volatile int[] precisions; private transient volatile int[] scales; private transient volatile Object[] dataTypes; + private transient volatile SQLWarning warnings; private DataValueDescriptor[] templateDVDRow; private Iterator execRows; private DataTypeDescriptor[] dtds; private boolean hasMetadata; - private boolean isUpdateOrDelete; + private boolean isUpdateOrDeleteOrPut; - public SnappyResultHolder(SparkSQLExecute exec, Boolean isUpdateOrDelete) { + public SnappyResultHolder(SparkSQLExecute exec, Boolean isUpdateOrDeleteOrPut) { this.exec = exec; - this.isUpdateOrDelete = isUpdateOrDelete; + this.isUpdateOrDeleteOrPut = isUpdateOrDeleteOrPut; } /** for deserialization */ @@ -81,6 +83,7 @@ public void setMetadata(SnappyResultHolder other) { this.precisions = other.precisions; this.scales = other.scales; this.dataTypes = other.dataTypes; + this.warnings = other.warnings; } public ByteArrayDataInput getByteArrayDataInput() { @@ -105,7 +108,7 @@ public void toData(final DataOutput out) throws IOException { } @Override - public void fromData(DataInput in) throws IOException { + public void fromData(DataInput in) throws IOException, ClassNotFoundException { final int numBytes = InternalDataSerializer.readArrayLength(in); if (numBytes > 0) { final byte[] rawData = DataSerializer.readByteArray(in, numBytes); @@ -115,7 +118,8 @@ public void fromData(DataInput in) throws IOException { } public final void fromSerializedData(final byte[] rawData, - final int numBytes, final Version v) throws IOException { + final int numBytes, final Version v) + throws IOException, ClassNotFoundException { final ByteArrayDataInput dis = new ByteArrayDataInput(); dis.initialize(rawData, 0, numBytes, v); byte metaInfo = dis.readByte(); @@ -150,12 +154,13 @@ public final void fromSerializedData(final byte[] rawData, scales[i] = -1; } } + this.warnings = DataSerializer.readObject(dis); } this.dis = dis; } private void makeTemplateDVDArr() { - if (this.isUpdateOrDelete) { + if (this.isUpdateOrDeleteOrPut) { DataValueDescriptor[] dvds = new DataValueDescriptor[1]; dvds[0] = new SQLInteger(); dtds = new DataTypeDescriptor[1]; @@ -333,4 +338,8 @@ public DataTypeDescriptor[] getDtds() { makeTemplateDVDArr(); return this.dtds; } + + public SQLWarning getWarnings() { + return this.warnings; + } } diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/message/GetLeadNodeInfoAsStringMessage.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/message/GetLeadNodeInfoAsStringMessage.java index 1f38e7854..d3bbc398e 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/message/GetLeadNodeInfoAsStringMessage.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/message/GetLeadNodeInfoAsStringMessage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/message/GfxdFunctionMessage.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/message/GfxdFunctionMessage.java index 9acebf6ca..d18f8f5c9 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/message/GfxdFunctionMessage.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/message/GfxdFunctionMessage.java @@ -42,20 +42,11 @@ import com.gemstone.gemfire.cache.execute.ResultCollector; import com.gemstone.gemfire.distributed.DistributedMember; import com.gemstone.gemfire.distributed.DistributedSystemDisconnectedException; -import com.gemstone.gemfire.distributed.internal.DM; -import com.gemstone.gemfire.distributed.internal.DistributionAdvisor; -import com.gemstone.gemfire.distributed.internal.DistributionManager; -import com.gemstone.gemfire.distributed.internal.DistributionMessage; -import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; -import com.gemstone.gemfire.distributed.internal.ReplyException; -import com.gemstone.gemfire.distributed.internal.ReplyMessage; -import com.gemstone.gemfire.distributed.internal.ReplyProcessor21; -import com.gemstone.gemfire.distributed.internal.ReplySender; +import com.gemstone.gemfire.distributed.internal.*; import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember; import com.gemstone.gemfire.internal.Assert; import com.gemstone.gemfire.internal.cache.DirectReplyMessage; import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; -import com.gemstone.gemfire.internal.cache.THashMapWithCreate; import com.gemstone.gemfire.internal.cache.TXManagerImpl; import com.gemstone.gemfire.internal.cache.TXStateInterface; import com.gemstone.gemfire.internal.cache.TXStateProxy; @@ -71,18 +62,10 @@ import com.gemstone.gemfire.internal.util.ArrayUtils; import com.gemstone.gemfire.internal.util.concurrent.StoppableCountDownLatch; import com.gemstone.gnu.trove.THashSet; -import com.pivotal.gemfirexd.internal.engine.Misc; import com.pivotal.gemfirexd.internal.engine.GfxdConstants; +import com.pivotal.gemfirexd.internal.engine.Misc; import com.pivotal.gemfirexd.internal.engine.access.GemFireTransaction; -import com.pivotal.gemfirexd.internal.engine.distributed.FunctionExecutionException; -import com.pivotal.gemfirexd.internal.engine.distributed.ResultHolder; -import com.pivotal.gemfirexd.internal.engine.distributed.GfxdMessage; -import com.pivotal.gemfirexd.internal.engine.distributed.GfxdReplyMessage; -import com.pivotal.gemfirexd.internal.engine.distributed.GfxdReplyMessageProcessor; -import com.pivotal.gemfirexd.internal.engine.distributed.GfxdResponseCode; -import com.pivotal.gemfirexd.internal.engine.distributed.GfxdResultCollector; -import com.pivotal.gemfirexd.internal.engine.distributed.GfxdResultCollectorHelper; -import com.pivotal.gemfirexd.internal.engine.distributed.GfxdWaitingReplyProcessorBase; +import com.pivotal.gemfirexd.internal.engine.distributed.*; import com.pivotal.gemfirexd.internal.engine.distributed.utils.GemFireXDUtils; import com.pivotal.gemfirexd.internal.engine.jdbc.GemFireXDRuntimeException; import com.pivotal.gemfirexd.internal.engine.jdbc.GfxdDDLReplayInProgressException; @@ -95,6 +78,8 @@ import com.pivotal.gemfirexd.internal.impl.sql.execute.xplain.XPLAINUtil; import com.pivotal.gemfirexd.internal.shared.common.reference.SQLState; import com.pivotal.gemfirexd.internal.shared.common.sanity.SanityManager; +import org.eclipse.collections.api.block.function.Function0; +import org.eclipse.collections.impl.map.mutable.UnifiedMap; /** * Base abstract class for GemFireXD function messages. This is not directly @@ -1702,28 +1687,22 @@ else if (minCapacity > oldCapacity) { /** * Map of a DistributedMember to its pending {@link ListOfReplies}. */ - protected final THashMapWithCreate pendingReplies; + protected final UnifiedMap pendingReplies; - static final THashMapWithCreate.ValueCreator pendingListCreator = - new THashMapWithCreate.ValueCreator() { - @Override - public final Object create(Object key, Object params) { - // create with size zero optimizing for the case when no out of order - // replies are received - return new ListOfReplies(0); - } - }; + // create with size zero optimizing for the case when no out of order + // replies are received + static final Function0 pendingListCreator = () -> new ListOfReplies(0); public GfxdFunctionOrderedReplyMessageProcessor(DM dm, Set members, GfxdFunctionMessage msg) { super(dm, members, msg); - this.pendingReplies = new THashMapWithCreate(); + this.pendingReplies = new UnifiedMap<>(); } public GfxdFunctionOrderedReplyMessageProcessor(DM dm, InternalDistributedMember member, GfxdFunctionMessage msg) { super(dm, member, msg); - this.pendingReplies = new THashMapWithCreate(); + this.pendingReplies = new UnifiedMap<>(); } /** @@ -1737,8 +1716,8 @@ protected synchronized boolean addResult( final InternalDistributedMember sender = replyMsg.getSender(); final boolean isLastResult = responseCode.isGrant(); if (isLastResult || responseCode.isWaiting()) { - final Object replies = this.pendingReplies.create(sender, - pendingListCreator, null); + final Object replies = this.pendingReplies.getIfAbsentPut(sender, + pendingListCreator); if (replies != Token.DESTROYED) { return ((ListOfReplies)replies).add(this, sender, replyMsg .singleResult, isLastResult ? responseCode.grantedSequenceId() diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/message/LeadNodeExecutorMsg.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/message/LeadNodeExecutorMsg.java index a95cbdce4..47ab49d57 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/message/LeadNodeExecutorMsg.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/message/LeadNodeExecutorMsg.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -36,7 +36,6 @@ import com.gemstone.gemfire.internal.HeapDataOutputStream; import com.gemstone.gemfire.internal.InternalDataSerializer; import com.gemstone.gemfire.internal.shared.Version; -import com.pivotal.gemfirexd.internal.engine.GfxdConstants; import com.pivotal.gemfirexd.internal.engine.Misc; import com.pivotal.gemfirexd.internal.engine.distributed.DVDIOUtil; import com.pivotal.gemfirexd.internal.engine.distributed.FunctionExecutionException; @@ -51,10 +50,10 @@ import com.pivotal.gemfirexd.internal.iapi.types.SQLDecimal; import com.pivotal.gemfirexd.internal.impl.sql.GenericParameterValueSet; import com.pivotal.gemfirexd.internal.shared.common.reference.SQLState; -import com.pivotal.gemfirexd.internal.shared.common.sanity.SanityManager; import com.pivotal.gemfirexd.internal.snappy.CallbackFactoryProvider; import com.pivotal.gemfirexd.internal.snappy.LeadNodeExecutionContext; import com.pivotal.gemfirexd.internal.snappy.SparkSQLExecute; +import org.apache.log4j.Logger; /** * Route query to Snappy Spark Lead node. @@ -75,14 +74,14 @@ public final class LeadNodeExecutorMsg extends MemberExecutorMessage { // possible values for leadNodeFlags private static final byte IS_PREPARED_STATEMENT = 0x1; private static final byte IS_PREPARED_PHASE = 0x2; - private static final byte IS_UPDATE_OR_DELETE = 0x4; + private static final byte IS_UPDATE_OR_DELETE_OR_PUT = 0x4; private static final Pattern PARSE_EXCEPTION = Pattern.compile( "(Pars[a-zA-Z]*Exception)|(Pars[a-zA-Z]*Error)"); public LeadNodeExecutorMsg(String sql, String schema, LeadNodeExecutionContext ctx, GfxdResultCollector rc, ParameterValueSet inpvs, boolean isPreparedStatement, - boolean isPreparedPhase, Boolean isUpdateOrDelete) { + boolean isPreparedPhase, Boolean isUpdateOrDeleteOrPut) { super(rc, null, false, true); this.schema = schema; this.sql = sql; @@ -90,7 +89,7 @@ public LeadNodeExecutorMsg(String sql, String schema, LeadNodeExecutionContext c this.pvs = inpvs; if (isPreparedStatement) leadNodeFlags |= IS_PREPARED_STATEMENT; if (isPreparedPhase) leadNodeFlags |= IS_PREPARED_PHASE; - if (isUpdateOrDelete) leadNodeFlags |= IS_UPDATE_OR_DELETE; + if (isUpdateOrDeleteOrPut) leadNodeFlags |= IS_UPDATE_OR_DELETE_OR_PUT; } /** @@ -108,7 +107,7 @@ public boolean isPreparedPhase() { return (leadNodeFlags & IS_PREPARED_PHASE) != 0; } - public boolean isUpdateOrDelete() { return (leadNodeFlags & IS_UPDATE_OR_DELETE) != 0; } + public boolean isUpdateOrDeleteOrPut() { return (leadNodeFlags & IS_UPDATE_OR_DELETE_OR_PUT) != 0; } @Override public Set getMembers() { @@ -137,27 +136,31 @@ protected void execute() throws Exception { if (isPreparedStatement() && !isPreparedPhase()) { getParams(); } + Logger logger = null; if (GemFireXDUtils.TraceQuery) { + logger = Logger.getLogger(getClass()); StringBuilder str = new StringBuilder(); appendFields(str); - SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_QUERYDISTRIB, - "LeadNodeExecutorMsg.execute: Got sql = " + str.toString()); + logger.info("LeadNodeExecutorMsg.execute: Got sql = " + str.toString()); } InternalDistributedMember m = this.getSenderForReply(); final Version v = m.getVersionObject(); exec = CallbackFactoryProvider.getClusterCallbacks().getSQLExecute( sql, schema, ctx, v, this.isPreparedStatement(), this.isPreparedPhase(), this.pvs); - SnappyResultHolder srh = new SnappyResultHolder(exec, isUpdateOrDelete()); + SnappyResultHolder srh = new SnappyResultHolder(exec, isUpdateOrDeleteOrPut()); srh.prepareSend(this); this.lastResultSent = true; this.endMessage(); if (GemFireXDUtils.TraceQuery) { - SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_QUERYDISTRIB, - "LeadNodeExecutorMsg.execute: Sent Last result "); + assert logger != null; + logger.info("LeadNodeExecutorMsg.execute: Sent Last result "); } } catch (Exception ex) { - throw getExceptionToSendToServer(ex); + Exception serverException = getExceptionToSendToServer(ex); + Logger.getLogger(getClass()).warn( + "LeadNodeExecutorMsg.execute: failed with exception: " + ex); + throw serverException; } finally { Thread.currentThread().setContextClassLoader(origLoader); } @@ -167,7 +170,8 @@ private static class SparkExceptionWrapper extends Exception { private static final long serialVersionUID = -4668836542769295434L; public SparkExceptionWrapper(Throwable ex) { - super(ex.getClass().getName() + ": " + ex.getMessage(), ex.getCause()); + super(ex.getClass().getName() + ": " + ex.getMessage(), + ex.getCause() != null ? new SparkExceptionWrapper(ex.getCause()) : null); this.setStackTrace(ex.getStackTrace()); } } @@ -175,7 +179,10 @@ public SparkExceptionWrapper(Throwable ex) { public static Exception getExceptionToSendToServer(Exception ex) { // Catch all exceptions and convert so can be caught at XD side // Check if the exception can be serialized or not - boolean wrapException = false; + // Now always wrapping exception because some exception classes may be deployed + // only on lead and may not be available on server esp. in system class loader + boolean wrapException = true; + /* HeapDataOutputStream hdos = null; try { hdos = new HeapDataOutputStream(); @@ -187,6 +194,7 @@ public static Exception getExceptionToSendToServer(Exception ex) { hdos.close(); } } + */ Throwable cause = ex; Throwable sparkEx = null; @@ -288,7 +296,7 @@ public static RuntimeException handleLeadNodeRuntimeException( protected LeadNodeExecutorMsg clone() { final LeadNodeExecutorMsg msg = new LeadNodeExecutorMsg(this.sql, this.schema, this.ctx, (GfxdResultCollector)this.userCollector, this.pvs, this.isPreparedStatement(), - this.isPreparedPhase(), this.isUpdateOrDelete()); + this.isPreparedPhase(), this.isUpdateOrDeleteOrPut()); msg.exec = this.exec; return msg; } @@ -369,7 +377,7 @@ public void toData(final DataOutput out) throws IOException { public void appendFields(final StringBuilder sb) { sb.append("sql: " + sql); sb.append(" ;schema: " + schema); - sb.append(" ;isUpdateOrDelete=").append(this.isUpdateOrDelete()); + sb.append(" ;isUpdateOrDelete=").append(this.isUpdateOrDeleteOrPut()); sb.append(" ;isPreparedStatement=").append(this.isPreparedStatement()); sb.append(" ;isPreparedPhase=").append(this.isPreparedPhase()); sb.append(" ;pvs=").append(this.pvs); diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/message/LeadNodeGetStatsMessage.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/message/LeadNodeGetStatsMessage.java index 0f1271253..124e09cd6 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/message/LeadNodeGetStatsMessage.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/message/LeadNodeGetStatsMessage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/message/LeadNodeSmartConnectorOpMsg.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/message/LeadNodeSmartConnectorOpMsg.java deleted file mode 100644 index 15cb93282..000000000 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/message/LeadNodeSmartConnectorOpMsg.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you - * may not use this file except in compliance with the License. You - * may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. See accompanying - * LICENSE file. - */ - -package com.pivotal.gemfirexd.internal.engine.distributed.message; - - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.sql.SQLException; -import java.util.Set; - -import com.gemstone.gemfire.DataSerializer; -import com.gemstone.gemfire.cache.execute.ResultCollector; -import com.gemstone.gemfire.distributed.DistributedMember; -import com.gemstone.gemfire.internal.snappy.CallbackFactoryProvider; -import com.pivotal.gemfirexd.internal.engine.GfxdConstants; -import com.pivotal.gemfirexd.internal.engine.Misc; -import com.pivotal.gemfirexd.internal.engine.distributed.utils.GemFireXDUtils; -import com.pivotal.gemfirexd.internal.iapi.error.StandardException; -import com.pivotal.gemfirexd.internal.shared.common.sanity.SanityManager; -import com.pivotal.gemfirexd.internal.snappy.LeadNodeSmartConnectorOpContext; - -/** - * This message is used in Smart Connector mode that uses thin client. This message is - * sent to lead node for DDL operations on external cluster (connector). This is sent from - * a system proc invoked by the connector. - */ -public final class LeadNodeSmartConnectorOpMsg extends MemberExecutorMessage { - - private LeadNodeSmartConnectorOpContext ctx; - - public LeadNodeSmartConnectorOpMsg(LeadNodeSmartConnectorOpContext ctx, - final ResultCollector rc) { - super(rc, null, false, true); - this.ctx = ctx; - } - - public LeadNodeSmartConnectorOpMsg() {super(true);} - - @Override - public Set getMembers() { - return Misc.getLeadNode(); - } - - @Override - public void postExecutionCallback() { - } - - @Override - public boolean isHA() { - return true; - } - - @Override - public boolean optimizeForWrite() { - return false; - } - - @Override - protected void execute() throws Exception { - if (GemFireXDUtils.TraceQuery) { - SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_QUERYDISTRIB, - "LeadNodeSmartConnectorOpMsg.execute: "); - } - try { - CallbackFactoryProvider.getStoreCallbacks().performConnectorOp(this.ctx); - lastResult(Boolean.TRUE, false, false, true); - } catch (Exception ex) { - throw LeadNodeExecutorMsg.getExceptionToSendToServer(ex); - } - } - - @Override - protected void executeFunction(boolean enableStreaming) - throws StandardException, SQLException { - try { - super.executeFunction(enableStreaming); - } catch (RuntimeException re) { - throw LeadNodeExecutorMsg.handleLeadNodeRuntimeException(re); - } - } - - @Override - protected LeadNodeSmartConnectorOpMsg clone() { - return new LeadNodeSmartConnectorOpMsg(this.ctx, this.userCollector); - } - - @Override - public byte getGfxdID() { - return LEAD_NODE_CONN_OP_MSG; - } - - @Override - public void fromData(DataInput in) throws IOException, ClassNotFoundException { - super.fromData(in); - this.ctx = DataSerializer.readObject(in); - } - - @Override - public void toData(final DataOutput out) throws IOException { - super.toData(out); - DataSerializer.writeObject(ctx, out); - } - - public void appendFields(final StringBuilder sb) { - super.appendFields(sb); - sb.append(";opType=").append(ctx.getType()) - .append(";table=").append(ctx.getTableIdentifier()) - .append(";ifExists=").append(ctx.getIfExists()) - .append(";isBuiltIn=").append(ctx.getIsBuiltIn()); - if (ctx.getProvider() != null) { - sb.append(";provider=").append(ctx.getProvider()); - } - if (ctx.getSchemaDDL() != null) { - sb.append(";schemaDDL=").append(ctx.getSchemaDDL()); - } - } -} diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/metadata/InsertQueryInfo.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/metadata/InsertQueryInfo.java index c5ff17572..ae9877276 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/metadata/InsertQueryInfo.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/metadata/InsertQueryInfo.java @@ -36,10 +36,13 @@ public class InsertQueryInfo extends DMLQueryInfo { */ private static final long serialVersionUID = 1L; private final SelectQueryInfo subSelectInfo; + private boolean isPutDml = false; - public InsertQueryInfo(QueryInfoContext qic, SelectQueryInfo selectInfo) throws StandardException { + + public InsertQueryInfo(QueryInfoContext qic, SelectQueryInfo selectInfo, Boolean isPutDml) throws StandardException { super(qic); this.subSelectInfo = selectInfo; + this.isPutDml = isPutDml; } @Override @@ -47,6 +50,10 @@ public boolean isInsert() { return true; } + public boolean isPutDML() { + return isPutDml; + } + @Override public boolean hasSubSelect() { return subSelectInfo != null; diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/utils/GemFireXDUtils.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/utils/GemFireXDUtils.java index 1da3d3f38..b4702f7c8 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/utils/GemFireXDUtils.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/utils/GemFireXDUtils.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -46,6 +46,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; +import javax.annotation.Nonnull; import javax.crypto.Cipher; import javax.crypto.KeyGenerator; import javax.crypto.spec.SecretKeySpec; @@ -165,6 +166,11 @@ import com.pivotal.gemfirexd.internal.shared.common.sanity.SanityManager; import org.apache.log4j.Logger; import org.apache.spark.unsafe.hash.Murmur3_x86_32; +import org.apache.thrift.TBase; +import org.apache.thrift.TException; +import org.apache.thrift.protocol.TCompactProtocol; +import org.apache.thrift.transport.AutoExpandingBufferWriteTransport; +import org.apache.thrift.transport.TMemoryInputTransport; /** * Various static utility methods used by GemFireXD. @@ -180,7 +186,7 @@ public final class GemFireXDUtils { .getBoolean("gemfirexd.optimizer.trace"); private static final ConcurrentHashMap lockableMap = - new ConcurrentHashMap(); + new ConcurrentHashMap<>(); private static long defaultRecoveryDelay = PartitionAttributesFactory.RECOVERY_DELAY_DEFAULT; @@ -221,8 +227,7 @@ public final class GemFireXDUtils { */ public static final Object MAX_KEY = new Object(); - private final static ThreadLocal tssConn = - new ThreadLocal(); + private final static ThreadLocal tssConn = new ThreadLocal<>(); private GemFireXDUtils() { // cannot be constructed @@ -719,6 +724,17 @@ public static VMKind getMyVMKind() { return store != null ? store.getMyVMKind() : null; } + public static GfxdDistributionAdvisor.GfxdProfile getMyProfile(boolean throwIfAbsent) { + final GemFireStore store = GemFireStore.getBootingInstance(); + GfxdDistributionAdvisor.GfxdProfile profile = store != null + ? store.getDistributionAdvisor().getMyProfile() : null; + if (profile == null && throwIfAbsent) { + throw new CacheClosedException("GemFireXDUtils.getMyProfile: no store found." + + " GemFireXD not booted or closed down."); + } + return profile; + } + /** * Return a globally unique ID efficiently (with occasional messaging and not * for each call) which can be used as Connection ID, for example, that is @@ -2671,6 +2687,22 @@ public void visit(String str, Set excludedServerSet, } }; + public static byte[] writeThriftObject(@Nonnull TBase obj) throws TException { + AutoExpandingBufferWriteTransport transport = + new AutoExpandingBufferWriteTransport(128, 1.5); + obj.write(new TCompactProtocol(transport)); + byte[] bytes = transport.getBuf().array(); + int size = transport.getPos(); + return (size == bytes.length) ? bytes : Arrays.copyOf(bytes, size); + } + + public static int readThriftObject(@Nonnull TBase obj, + byte[] bytes) throws TException { + TMemoryInputTransport transport = new TMemoryInputTransport(bytes); + obj.read(new TCompactProtocol(transport)); + return transport.getBytesRemainingInBuffer(); + } + @SuppressWarnings("unchecked") public static ServerLocation getPreferredServer( Collection serverGroups, Collection intersectGroups, @@ -3400,7 +3432,8 @@ public static void initFlags() { TraceSysProcedures = SanityManager .TRACE_ON(GfxdConstants.TRACE_SYS_PROCEDURES) || (TraceExecution && !SanityManager.TRACE_OFF( - GfxdConstants.TRACE_SYS_PROCEDURES)); + GfxdConstants.TRACE_SYS_PROCEDURES)) || + GfxdSystemProcedures.logger.isDebugEnabled(); } private static void setTraceExecution(boolean force) { diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/utils/LogFileUtils.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/utils/LogFileUtils.java index 842c96cc9..4f453d86c 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/utils/LogFileUtils.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/distributed/utils/LogFileUtils.java @@ -1,7 +1,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/jvmkill.c b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/jvmkill.c index 6e85bfa47..53096e82c 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/jvmkill.c +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/jvmkill.c @@ -17,31 +17,45 @@ #include #include #include - +#include #include + +static FILE* g_logFile = NULL; + +void logMessage(char *format, ...) { + FILE* logFile = g_logFile; + if (logFile == NULL) { + char fname[100]; + sprintf(fname, "jvmkill_pid%d.log", getpid()); + logFile = fopen(fname, "a"); + g_logFile = logFile; + } + va_list args; + va_start(args, format); + vfprintf(logFile, format, args); + va_end(args); + fflush(logFile); +} + static void JNICALL resourceExhausted( jvmtiEnv *jvmti_env, JNIEnv *jni_env, jint flags, const void *reserved, - const char *description) -{ - fprintf(stderr, - "ResourceExhausted: %s: killing current process!\n", description); + const char *description) { + logMessage("ResourceExhausted: %s: killing current process!", description); kill(getpid(), SIGKILL); } JNIEXPORT jint JNICALL -Agent_OnLoad(JavaVM *vm, char *options, void *reserved) -{ +Agent_OnLoad(JavaVM *vm, char *options, void *reserved) { jvmtiEnv *jvmti; jvmtiError err; - jint rc = (*vm)->GetEnv(vm, (void **) &jvmti, JVMTI_VERSION); if (rc != JNI_OK) { - fprintf(stderr, "ERROR: GetEnv failed: %d\n", rc); + logMessage("ERROR: GetEnv failed: %d\n", rc); return JNI_ERR; } @@ -52,14 +66,14 @@ Agent_OnLoad(JavaVM *vm, char *options, void *reserved) err = (*jvmti)->SetEventCallbacks(jvmti, &callbacks, sizeof(callbacks)); if (err != JVMTI_ERROR_NONE) { - fprintf(stderr, "ERROR: SetEventCallbacks failed: %d\n", err); + logMessage("ERROR: SetEventCallbacks failed: %d\n", err); return JNI_ERR; } err = (*jvmti)->SetEventNotificationMode( jvmti, JVMTI_ENABLE, JVMTI_EVENT_RESOURCE_EXHAUSTED, NULL); if (err != JVMTI_ERROR_NONE) { - fprintf(stderr, "ERROR: SetEventNotificationMode failed: %d\n", err); + logMessage("ERROR: SetEventNotificationMode failed: %d\n", err); return JNI_ERR; } diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/management/impl/InternalManagementService.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/management/impl/InternalManagementService.java index 4a2433ecf..96a421f7a 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/management/impl/InternalManagementService.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/management/impl/InternalManagementService.java @@ -513,6 +513,7 @@ private void handleTableDrop(String fullTableName) { } private void handleEmbedConnectionInit(final EmbedConnection connection, boolean checkStore) { + if (connection == null) return; final InternalDistributedSystem system = Misc.getDistributedSystem(); GemFireStore store = GemFireStore.getBootingInstance(); if (checkStore && (store == null || !store.initialDDLReplayDone())) { @@ -534,19 +535,21 @@ private void handleEmbedConnectionInit(final EmbedConnection connection, boolean Misc.checkIfCacheClosing(ie); } } - long timeout = Math.max(end - current, 1000L); + long timeout = Math.max(end - current, 5000L); GemFireXDUtils.waitForNodeInitialization(timeout, true, false); // try to proceed in any case even if node has not initialized yet handleEmbedConnectionInit(connection, false); }); return; } + final LanguageConnectionContext lcc = connection.getLanguageConnectionContext(); + if (lcc == null) return; GfxdConnectionHolder holder = GfxdConnectionHolder.getHolder(); GfxdConnectionWrapper connectionWrapper = null; try { Properties props = new Properties(); - props.setProperty(Attribute.QUERY_HDFS, Boolean.toString(connection.getLanguageConnectionContext().getQueryHDFS())); - props.setProperty(Attribute.ROUTE_QUERY, Boolean.toString(connection.getLanguageConnectionContext().isQueryRoutingFlagTrue())); + props.setProperty(Attribute.QUERY_HDFS, Boolean.toString(lcc.getQueryHDFS())); + props.setProperty(Attribute.ROUTE_QUERY, Boolean.toString(lcc.isQueryRoutingFlagTrue())); connectionWrapper = holder.createWrapper(connection.getSchema(), GemFireXDUtils.newUUID(), false, props); } catch (SQLException e) { logInfo("Error creating EmbedConnection for Management. Reason: " + e.getMessage()); diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/procedure/coordinate/DistributedProcedureCallNode.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/procedure/coordinate/DistributedProcedureCallNode.java index 5fb751d1c..afce19648 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/procedure/coordinate/DistributedProcedureCallNode.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/procedure/coordinate/DistributedProcedureCallNode.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/reflect/SnappyActivationClass.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/reflect/SnappyActivationClass.java index 67a6d7f07..ea2e6be6a 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/reflect/SnappyActivationClass.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/reflect/SnappyActivationClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -29,15 +29,15 @@ public class SnappyActivationClass implements GeneratedClass { private final boolean returnRows; private final int classLoaderVersion; boolean isPrepStmt; - boolean isUpdateOrDelete; + boolean isUpdateOrDeleteOrPut; public SnappyActivationClass(LanguageConnectionContext lcc, boolean returnRows, - boolean isPrepStmt, boolean isUpdateOrDelete) { + boolean isPrepStmt, boolean isUpdateOrDeleteOrPut) { this.returnRows = returnRows; this.classLoaderVersion = lcc.getLanguageConnectionFactory() .getClassFactory().getClassLoaderVersion(); this.isPrepStmt = isPrepStmt; - this.isUpdateOrDelete = isUpdateOrDelete; + this.isUpdateOrDeleteOrPut = isUpdateOrDeleteOrPut; } public int getClassLoaderVersion() { @@ -55,7 +55,7 @@ public final String getName() { public final Object newInstance(final LanguageConnectionContext lcc, final boolean addToLCC, final ExecPreparedStatement eps) throws StandardException { SnappyActivation sa = new SnappyActivation(lcc, eps, this.returnRows, this.isPrepStmt, - this.isUpdateOrDelete); + this.isUpdateOrDeleteOrPut); if (isPrepStmt) { sa.initialize_pvs(); } diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/catalog/DistributionDescriptor.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/catalog/DistributionDescriptor.java index 4e0af3d82..616b22d28 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/catalog/DistributionDescriptor.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/catalog/DistributionDescriptor.java @@ -14,9 +14,6 @@ * permissions and limitations under the License. See accompanying * LICENSE file. */ -/** - * - */ package com.pivotal.gemfirexd.internal.engine.sql.catalog; import java.util.ArrayList; @@ -89,7 +86,7 @@ public DistributionDescriptor(int policy, String[] columns, int redundancy, int maxPartSize, String colocateTable, boolean isPersistent, SortedSet serverGroups) { this.policy = policy; - this.columns = columns; + this.columns = columns != null ? columns.clone() : null; this.values = null; this.redundancy = redundancy; this.maxPartSize = maxPartSize; @@ -114,7 +111,7 @@ public void addValueSet(ArrayList valueSet) { } public void setPartitionColumnNames(String[] cols) { - this.columns = cols; + this.columns = cols != null ? cols.clone() : null; } public final String[] getPartitionColumnNames() { @@ -237,7 +234,7 @@ public static void checkAvailableDataStore( public int getPartitioningColumnIdx(String colName) { for (int i = 0; i < columns.length; i++) { - if (columns[i].toUpperCase().equals(colName.toUpperCase())) { + if (columns[i].equalsIgnoreCase(colName)) { return i; } } diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/catalog/ExtraTableInfo.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/catalog/ExtraTableInfo.java index 8abaf6e7e..7d56363ee 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/catalog/ExtraTableInfo.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/catalog/ExtraTableInfo.java @@ -25,7 +25,6 @@ import com.gemstone.gemfire.internal.cache.LocalRegion; import com.gemstone.gemfire.internal.offheap.annotations.Unretained; import com.gemstone.gnu.trove.TIntArrayList; -import com.koloboke.function.IntObjPredicate; import com.pivotal.gemfirexd.internal.catalog.DependableFinder; import com.pivotal.gemfirexd.internal.catalog.UUID; import com.pivotal.gemfirexd.internal.engine.Misc; @@ -42,18 +41,11 @@ import com.pivotal.gemfirexd.internal.iapi.sql.depend.DependencyManager; import com.pivotal.gemfirexd.internal.iapi.sql.depend.Dependent; import com.pivotal.gemfirexd.internal.iapi.sql.depend.Provider; -import com.pivotal.gemfirexd.internal.iapi.sql.dictionary.ColumnDescriptor; -import com.pivotal.gemfirexd.internal.iapi.sql.dictionary.ColumnDescriptorList; -import com.pivotal.gemfirexd.internal.iapi.sql.dictionary.ConglomerateDescriptor; -import com.pivotal.gemfirexd.internal.iapi.sql.dictionary.ConstraintDescriptor; -import com.pivotal.gemfirexd.internal.iapi.sql.dictionary.ConstraintDescriptorList; -import com.pivotal.gemfirexd.internal.iapi.sql.dictionary.DataDictionary; -import com.pivotal.gemfirexd.internal.iapi.sql.dictionary.ForeignKeyConstraintDescriptor; -import com.pivotal.gemfirexd.internal.iapi.sql.dictionary.ReferencedKeyConstraintDescriptor; -import com.pivotal.gemfirexd.internal.iapi.sql.dictionary.TableDescriptor; +import com.pivotal.gemfirexd.internal.iapi.sql.dictionary.*; import com.pivotal.gemfirexd.internal.iapi.store.raw.ContainerHandle; import com.pivotal.gemfirexd.internal.iapi.store.raw.ContainerKey; -import io.snappydata.collection.IntObjectHashMap; +import org.eclipse.collections.api.block.procedure.primitive.IntProcedure; +import org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap; public final class ExtraTableInfo extends ExtraInfo implements Dependent { @@ -327,10 +319,10 @@ private final void refreshAutoGenColumnInfo() { cd = cdl.elementAt(index); if (cd.isAutoincrement()) { if (this.autoGenColumns == null) { // user provided column indexes - this.autoGenColumns = IntObjectHashMap.withExpectedSize(4); + this.autoGenColumns = new IntObjectHashMap<>(4); this.autoGenColumnNames = new HashMap<>(); } - this.autoGenColumns.justPut(cd.getPosition(), cd); + this.autoGenColumns.put(cd.getPosition(), cd); this.autoGenColumnNames.put(cd.getColumnName(), cd); } } @@ -466,19 +458,20 @@ public final ColumnDescriptor getAutoGeneratedColumn(final String name) { public final boolean isAutoGeneratedColumn(final int position) { return this.autoGenColumns != null - && this.autoGenColumns.contains(position); + && this.autoGenColumns.containsKey(position); } public final int[] getAutoGeneratedColumns() { if (this.autoGenColumns != null) { final int[] keys = new int[this.autoGenColumns.size()]; - this.autoGenColumns.forEachWhile(new IntObjPredicate() { + this.autoGenColumns.forEachKey(new IntProcedure() { + private static final long serialVersionUID = 1126691153868080143L; + private int index; @Override - public boolean test(int k, ColumnDescriptor cd) { + public void value(int k) { keys[index++] = k; - return true; } }); return keys; diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/AbstractGemFireResultSet.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/AbstractGemFireResultSet.java index 332f47ece..ad51e6d11 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/AbstractGemFireResultSet.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/AbstractGemFireResultSet.java @@ -53,8 +53,6 @@ public abstract class AbstractGemFireResultSet implements ResultSet { protected final GemFireTransaction tran; - protected SQLWarning warnings; - protected boolean isClosed; protected final GemFireXDQueryObserver observer = GemFireXDQueryObserverHolder @@ -114,7 +112,6 @@ public AbstractGemFireResultSet(final Activation act) { } this.tran = (GemFireTransaction)act.getTransactionController(); - this.warnings = null; this.isClosed = true; } @@ -402,16 +399,12 @@ public final ExecRow setAfterLastRow() throws StandardException { } protected final void addWarning(SQLWarning w) { - if (warnings == null) - warnings = w; - else - warnings.setNextWarning(w); - return; + this.activation.addResultsetWarning(w); } @Override public final SQLWarning getWarnings() { - return this.warnings; + return this.activation.getResultsetWarnings(); } @Override diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/AbstractSnappyResultSet.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/AbstractSnappyResultSet.java index a063cf947..2e3a32149 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/AbstractSnappyResultSet.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/AbstractSnappyResultSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/GemFireInsertResultSet.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/GemFireInsertResultSet.java index c983c885c..560385d22 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/GemFireInsertResultSet.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/GemFireInsertResultSet.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/GemFireResultSet.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/GemFireResultSet.java index a364f550e..9d1dddd7a 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/GemFireResultSet.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/GemFireResultSet.java @@ -25,7 +25,6 @@ import java.util.Map; import java.util.NoSuchElementException; import java.util.Set; - import javax.annotation.Nonnull; import com.gemstone.gemfire.GemFireException; @@ -46,7 +45,6 @@ import com.gemstone.gemfire.internal.cache.TXState; import com.gemstone.gemfire.internal.cache.TXStateInterface; import com.gemstone.gemfire.internal.offheap.annotations.Unretained; -import io.snappydata.collection.OpenHashSet; import com.pivotal.gemfirexd.internal.engine.GfxdConstants; import com.pivotal.gemfirexd.internal.engine.Misc; import com.pivotal.gemfirexd.internal.engine.access.index.GlobalRowLocation; @@ -97,7 +95,8 @@ import com.pivotal.gemfirexd.internal.impl.sql.execute.RowUtil; import com.pivotal.gemfirexd.internal.impl.sql.execute.xplain.XPLAINUtil; import com.pivotal.gemfirexd.internal.shared.common.reference.SQLState; -import io.snappydata.collection.ObjectObjectHashMap; +import org.eclipse.collections.impl.map.mutable.UnifiedMap; +import org.eclipse.collections.impl.set.mutable.UnifiedSet; /** * @author soubhikc @@ -150,7 +149,7 @@ public final class GemFireResultSet extends AbstractGemFireResultSet implements * Map Keys -> Routing Objects * Store keys and routingObjects used in getAll for Global Index Case. */ - private ObjectObjectHashMap getAllKeysAndRoutingObjects; + private UnifiedMap getAllKeysAndRoutingObjects; private int currPos; @@ -300,7 +299,7 @@ public GemFireResultSet(Activation activation, */ if (policy.withPartitioning()) { this.doGetAll = true; - this.getAllKeysAndRoutingObjects = ObjectObjectHashMap.withExpectedSize(8); + this.getAllKeysAndRoutingObjects = new UnifiedMap<>(8); if (GemFireXDUtils.TraceQuery | GemFireXDUtils.TraceNCJ) { SanityManager .DEBUG_PRINT( @@ -961,8 +960,8 @@ private int callGetAllOnGlobalIndex(final LocalRegion region, assert giRegion != null; // Also remove duplicates - ObjectObjectHashMap giKeys = - ObjectObjectHashMap.withExpectedSize(this.gfKeys.length); + UnifiedMap giKeys = + new UnifiedMap<>(this.gfKeys.length); for (Object gfKey : this.gfKeys) { // also see assertion in constructor assert gfKey instanceof CompactCompositeRegionKey; @@ -1089,7 +1088,7 @@ private ExecRow executeGetAll() throws StandardException { } else { - OpenHashSet keysSet = new OpenHashSet<>(this.gfKeys.length); + UnifiedSet keysSet = new UnifiedSet<>(this.gfKeys.length); // remove duplicates for (Object key : this.gfKeys) { keysSet.add(key); @@ -1180,7 +1179,7 @@ private ExecRow executeGetAllOnLocalIndex() throws StandardException { final Object[] getAllKeys; @SuppressWarnings("unchecked") - OpenHashSet keysSet = new OpenHashSet<>(this.gfKeys.length); + UnifiedSet keysSet = new UnifiedSet<>(this.gfKeys.length); // remove duplicates for (Object key : this.gfKeys) { keysSet.add(key); diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/MemberLogsMessage.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/MemberLogsMessage.java index 8af05fd2e..55eca9f74 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/MemberLogsMessage.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/MemberLogsMessage.java @@ -1,7 +1,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/MemberStatisticsMessage.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/MemberStatisticsMessage.java index 761072e71..374cecd48 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/MemberStatisticsMessage.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/MemberStatisticsMessage.java @@ -3,7 +3,6 @@ import java.net.InetAddress; import java.net.UnknownHostException; import java.util.Collection; -import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -25,6 +24,7 @@ import com.gemstone.gemfire.internal.cache.DirectoryHolder; import com.gemstone.gemfire.internal.cache.DiskStoreImpl; import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; +import com.gemstone.gemfire.internal.shared.ClientSharedUtils; import com.gemstone.gemfire.internal.shared.NativeCalls; import com.gemstone.gemfire.internal.snappy.StoreCallbacks; import com.gemstone.gemfire.internal.statistics.VMStats; @@ -39,8 +39,6 @@ import com.pivotal.gemfirexd.internal.engine.stats.ConnectionStats; import com.pivotal.gemfirexd.internal.engine.store.ServerGroupUtils; import com.pivotal.gemfirexd.internal.snappy.CallbackFactoryProvider; -import org.apache.log4j.Appender; -import org.apache.log4j.FileAppender; import org.apache.log4j.Logger; public class MemberStatisticsMessage extends MemberExecutorMessage { @@ -199,18 +197,8 @@ private String getUserDir(){ } private String getLogFile() { - Logger rootLogger = Logger.getRootLogger(); - Appender appender; - if (rootLogger != null) { - Enumeration e = rootLogger.getAllAppenders(); - while (e.hasMoreElements()) { - appender = (Appender)e.nextElement(); - if (appender instanceof FileAppender) { - return ((FileAppender)appender).getFile(); - } - } - } - return ""; + String logFile = ClientSharedUtils.getLog4jLogFile(Logger.getRootLogger()); + return logFile != null ? logFile : ""; } private String getProcessId(){ diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/SnappyActivation.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/SnappyActivation.java index cea821f10..dc3a75847 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/SnappyActivation.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/SnappyActivation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -57,17 +57,17 @@ public class SnappyActivation extends BaseActivation { private String sql; private boolean returnRows; private boolean isPrepStmt; - private boolean isUpdateOrDelete; + private boolean isUpdateOrDeleteOrPut; public SnappyActivation(LanguageConnectionContext lcc, ExecPreparedStatement eps, - boolean returnRows, boolean isPrepStmt, boolean isUpdateOrDelete) { + boolean returnRows, boolean isPrepStmt, boolean isUpdateOrDeleteOrPut) { super(lcc); sql = eps.getSource(); this.preStmt = eps; this.returnRows = returnRows; this.connectionID = lcc.getConnectionId(); this.isPrepStmt = isPrepStmt; - this.isUpdateOrDelete = isUpdateOrDelete; + this.isUpdateOrDeleteOrPut = isUpdateOrDeleteOrPut; } public void initialize_pvs() throws StandardException { @@ -100,7 +100,7 @@ public void initialize_pvs() throws StandardException { GenericPreparedStatement gps = (GenericPreparedStatement)preStmt; gps.setParameterTypes(types); final String statementType; - if (isUpdateOrDelete) { + if (isUpdateOrDeleteOrPut) { statementType = "INSERT"; // Default } else { statementType = "SELECT"; @@ -182,8 +182,8 @@ private StandardException getCause(GemFireXDRuntimeException gfxe) { private SnappySelectResultSet createResultSet() throws StandardException { - if (isUpdateOrDelete) { - return new SnappyUpdateDeleteResultSet(this, this.returnRows); + if (isUpdateOrDeleteOrPut) { + return new SnappyUpdateDeletePutResultSet(this, this.returnRows); } else { return new SnappySelectResultSet(this, this.returnRows); } @@ -199,14 +199,14 @@ private void executeWithResultSet(SnappySelectResultSet rs) boolean enableStreaming = this.lcc.streamingEnabled(); GfxdResultCollector rc = getResultCollector(enableStreaming, rs); executeOnLeadNode(rs, rc, this.sql, enableStreaming, this.getConnectionID(), this.lcc - .getCurrentSchemaName(), this.pvs, this.isPrepStmt, this.isUpdateOrDelete, this.lcc); + .getCurrentSchemaName(), this.pvs, this.isPrepStmt, this.isUpdateOrDeleteOrPut, this.lcc); } private void prepareWithResultSet(SnappyPrepareResultSet rs) throws StandardException { GfxdResultCollector rc = getPrepareResultCollector(rs); prepareOnLeadNode(rs, rc, this.sql, this.getConnectionID(), this.lcc - .getCurrentSchemaName(), this.pvs, this.isUpdateOrDelete, this.lcc); + .getCurrentSchemaName(), this.pvs, this.isUpdateOrDeleteOrPut, this.lcc); } private GfxdResultCollector getResultCollector(final boolean enableStreaming, @@ -316,13 +316,13 @@ public void setResultDescription(GenericResultDescription resultDescription) { private static void executeOnLeadNode(SnappySelectResultSet rs, GfxdResultCollector rc, String sql, boolean enableStreaming, long connId, String schema, ParameterValueSet pvs, - boolean isPreparedStatement, boolean isUpdateOrDelete, LanguageConnectionContext lcc) + boolean isPreparedStatement, boolean isUpdateOrDeleteOrPut, LanguageConnectionContext lcc) throws StandardException { // TODO: KN probably username, statement id and connId to be sent in // execution and of course tx id when transaction will be supported. LeadNodeExecutionContext ctx = new LeadNodeExecutionContext(connId); LeadNodeExecutorMsg msg = new LeadNodeExecutorMsg(sql, schema, ctx, rc, pvs, - isPreparedStatement, false, isUpdateOrDelete); + isPreparedStatement, false, isUpdateOrDeleteOrPut); // release all locks before sending the message else it can lead to deadlocks if (lcc != null) { lcc.getTransactionExecute().releaseAllLocks(true, true); @@ -344,12 +344,12 @@ private static void executeOnLeadNode(SnappySelectResultSet rs, GfxdResultCollec private static void prepareOnLeadNode(SnappyPrepareResultSet rs, GfxdResultCollector rc, String sql, long connId, String schema, ParameterValueSet pvs, - boolean isUpdateOrDelete, LanguageConnectionContext lcc) throws StandardException { + boolean isUpdateOrDeleteOrPut, LanguageConnectionContext lcc) throws StandardException { // TODO: KN probably username, statement id and connId to be sent in // execution and of course tx id when transaction will be supported. LeadNodeExecutionContext ctx = new LeadNodeExecutionContext(connId); LeadNodeExecutorMsg msg = new LeadNodeExecutorMsg(sql, schema, ctx, rc, pvs, - true, true, isUpdateOrDelete); + true, true, isUpdateOrDeleteOrPut); if (lcc != null) { lcc.getTransactionExecute().releaseAllLocks(true, true); } diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/SnappyPrepareResultSet.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/SnappyPrepareResultSet.java index 6ff869365..4942fff7e 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/SnappyPrepareResultSet.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/sql/execute/SnappyPrepareResultSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -18,6 +18,7 @@ package com.pivotal.gemfirexd.internal.engine.sql.execute; import java.io.IOException; +import java.sql.SQLWarning; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; @@ -285,13 +286,22 @@ public ResultDescription makeResultDescription(String statementType) { GenericResultDescription resultDescription = new GenericResultDescription( new ResultColumnDescriptor[colTypes.length], statementType); - // TODO: KN remove hard coding - for(int i=0; i(); @@ -1403,24 +1418,6 @@ public SortedIndexKey getIndexKey(Object val, RegionEntry entry) { } } - /** - * {@inheritDoc} - */ - @Override - public void insertIntoIndex(SortedIndexKey indexKey, RegionEntry entry, - boolean isPutDML) { - if (GemFireXDUtils.TraceIndex) { - GfxdIndexManager.traceIndex("GemFireContainer#insertIntoIndexes: " - + "index key = %s DiskEntry to be inserted = %s", entry); - } - try { - SortedMap2IndexInsertOperation.doMe(null, null, this, indexKey, - (RowLocation)entry, isUniqueIndex(), null, isPutDML); - } catch (StandardException se) { - throw new IndexMaintenanceException(se); - } - } - /** * {@inheritDoc} */ @@ -2524,7 +2521,7 @@ public long getRowSize() { try { final RowLocation rl = (RowLocation)itr.next(); Assert.assertTrue(rl != null, "unexpected null encountered"); - if (rl.isUpdateInProgress()) { + if (rl.isUpdateInProgress() || rl.isDestroyedOrRemoved()) { continue; } // #43228 @@ -5086,7 +5083,6 @@ public final RowEncoder getRowEncoder() { private final boolean isCandidateForByteArrayStore() { return !GfxdConstants.SYSTEM_SCHEMA_NAME.equals(this.schemaName) - // TODO: SW: why for session schema?? && !GfxdConstants.SESSION_SCHEMA_NAME.equals(this.schemaName) && !isObjectStore(); } @@ -5099,15 +5095,14 @@ public final boolean isPartitioned() { } public final boolean isRowBuffer() { - return isPartitioned() && ((PartitionedRegion)this.region).needsBatching(); + return isPartitioned() && this.region.isRowBuffer(); } public final boolean isColumnStore() { // latter check is not useful currently since only column tables use // object store, but still added the check for possible future use // (e.g. local index table on column store) - return isObjectStore() && - this.tableName.endsWith(SystemProperties.SHADOW_TABLE_SUFFIX); + return isObjectStore() && this.region.isInternalColumnTable(); } public final boolean isOffHeap() { @@ -5628,18 +5623,8 @@ public final ValueRow newValueRow(DataValueDescriptor[] dvds) { if (senderIds != null) { senderIdsStr = SharedUtils.toCSV(senderIds); } - - final DataValueDescriptor tType = dvds[SYSTABLESRowFactory.SYSTABLES_TABLETYPE - 1]; - if (tType != null && "T".equalsIgnoreCase(tType.toString()) && - !LocalRegion.isMetaTable(region.getFullPath())) { - ExternalCatalog ec = Misc.getMemStore().getExternalCatalog(); - LanguageConnectionContext lcc = Misc.getLanguageConnectionContext(); - if (ec != null && lcc != null && (lcc.isQueryRoutingFlagTrue() || - lcc.isSnappyInternalConnection()) && Misc.initialDDLReplayDone()) { - if (ec.isColumnTable(schemaName, table.toString(), true)) { - dvds[SYSTABLESRowFactory.SYSTABLES_TABLETYPE - 1] = new SQLChar("C"); - } - } + if (region.isRowBuffer() || region.isInternalColumnTable()) { + dvds[SYSTABLESRowFactory.SYSTABLES_TABLETYPE - 1] = new SQLChar("C"); } dvds[SYSTABLESRowFactory.SYSTABLES_DATAPOLICY - 1] = new SQLVarchar( @@ -6301,7 +6286,7 @@ public boolean lockContainer(final Transaction tran, GemFireXDUtils.TraceLock ? new Throwable() : null); } final GfxdLockSet lockSet = t.getLockSpace(); - if (GfxdDataDictionary.SKIP_LOCKS.get()) { + if (GfxdDataDictionary.SKIP_CATALOG_OPS.get().skipDDLocks) { return true; } if (lockSet.acquireLock(lockObject, diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/store/GemFireStore.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/store/GemFireStore.java index fbbf2d187..377c38c92 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/store/GemFireStore.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/store/GemFireStore.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -378,6 +378,8 @@ public final class GemFireStore implements AccessFactory, ModuleControl, private final IndexPersistenceStats indexPersistenceStats; + private final long createTime; + /** * Not keeping as volatile as the expectation is that this field * should be set as soon as the first embedded connection is created @@ -417,6 +419,7 @@ public GemFireStore() { this.indexLoadSync = new Object(); this.indexLoadBegin = false; this.indexPersistenceStats = new IndexPersistenceStats(); + this.createTime = System.currentTimeMillis(); } /** @@ -428,6 +431,10 @@ public GemFireStore() { public void createFinished() throws StandardException { } + public long getCreateTime() { + return this.createTime; + } + /** * Find an access method that implements an implementation type. * @@ -1538,7 +1545,8 @@ private void bootRegions() throws StandardException { // set then that can be used for overflow/gateway String serverGroup = this.getBootProperty("server-groups"); - Boolean isLeadMember = serverGroup != null ? serverGroup.contains("IMPLICIT_LEADER_SERVERGROUP") : false; + boolean isLeadMember = serverGroup != null && + serverGroup.contains(ServerGroupUtils.LEADER_SERVERGROUP); if (this.persistingDD || this.persistenceDir != null || isLeadMember) { try { @@ -2424,7 +2432,7 @@ public void initExternalCatalog() { // Instantiate using reflection try { this.externalCatalog = (ExternalCatalog)ClassPathLoader - .getLatest().forName("io.snappydata.impl.SnappyHiveCatalog") + .getLatest().forName("io.snappydata.sql.catalog.impl.StoreHiveCatalog") .newInstance(); } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/store/IndexStats.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/store/IndexStats.java index da56da386..157c25060 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/store/IndexStats.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/store/IndexStats.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/store/NonLocalRowLocationRegionEntry.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/store/NonLocalRowLocationRegionEntry.java index 75ed5f30f..2b1d46d40 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/store/NonLocalRowLocationRegionEntry.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/store/NonLocalRowLocationRegionEntry.java @@ -120,7 +120,7 @@ public Object getValueWithoutFaultIn(GemFireContainer baseContainer) @Override public ExecRow getRow(GemFireContainer baseContainer) throws StandardException { - return baseContainer.newExecRow(this.value); + return baseContainer.newExecRow(this.key, this.value); } /** @@ -129,7 +129,7 @@ public ExecRow getRow(GemFireContainer baseContainer) @Override public ExecRow getRowWithoutFaultIn(GemFireContainer baseContainer) throws StandardException { - return baseContainer.newExecRow(this.value); + return baseContainer.newExecRow(this.key, this.value); } /** diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/store/NonLocalRowLocationRegionEntryWithStats.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/store/NonLocalRowLocationRegionEntryWithStats.java index 2f26b3c2a..c336893e2 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/store/NonLocalRowLocationRegionEntryWithStats.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/store/NonLocalRowLocationRegionEntryWithStats.java @@ -116,7 +116,7 @@ public Object getValueWithoutFaultIn(GemFireContainer baseContainer) @Override public ExecRow getRow(GemFireContainer baseContainer) throws StandardException { - return baseContainer.newExecRow(this.value); + return baseContainer.newExecRow(this.key, this.value); } /** @@ -125,7 +125,7 @@ public ExecRow getRow(GemFireContainer baseContainer) @Override public ExecRow getRowWithoutFaultIn(GemFireContainer baseContainer) throws StandardException { - return baseContainer.newExecRow(this.value); + return baseContainer.newExecRow(this.key, this.value); } /** diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/store/RowEncoder.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/store/RowEncoder.java index b12704aa0..aedad75c2 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/store/RowEncoder.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/store/RowEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/store/entry/GfxdTXEntryState.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/store/entry/GfxdTXEntryState.java index 436ac9516..359ab477d 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/store/entry/GfxdTXEntryState.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/store/entry/GfxdTXEntryState.java @@ -35,6 +35,7 @@ import com.gemstone.gemfire.cache.CacheWriterException; import com.gemstone.gemfire.cache.EntryEvent; import com.gemstone.gemfire.cache.EntryNotFoundException; +import com.gemstone.gemfire.cache.IllegalTransactionStateException; import com.gemstone.gemfire.cache.Operation; import com.gemstone.gemfire.cache.TimeoutException; import com.gemstone.gemfire.cache.query.internal.IndexUpdater; @@ -690,23 +691,26 @@ protected final void cleanup(final TXState txState, final LocalRegion r, } public WrapperRowLocationForTxn wrapperForRollback( - GemFireContainer indexContainer, Object oldKey) { + GemFireContainer indexContainer, Object oldKey, EntryEventImpl event) { // in case of op = INSERT/CREATE we need not reinstate the old index // during rollback. if (wasCreatedByTX()) { return null; } + final boolean isOpPut = isOpPut() || event.isPutDML(); + final boolean isOpDestroy = isOpDestroy(); // in case of op = destroy or op = update/put of an existing entry // we need to reinstate the old index during rollback - if (!isOpPut() && !isOpDestroy()) { - if (GemFireXDUtils.TraceTran | GemFireXDUtils.TraceQuery) { - SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_TRAN, "op is: " + this.op - + " and opToString returns: " + this.opToString()); - } + if (!isOpPut && !isOpDestroy) { + SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_TRAN, "ERROR: Unexpected op = " + + this.op + ", opToString returns: " + this.opToString() + " for " + toString() + + ", event: " + event); + throw new IllegalTransactionStateException("TXEntryState.wrapperForRollback: unexpected " + + "operation " + opToString() + " for event: " + event + ", on entry: " + toString()); } - boolean isOpDestroy = isOpDestroy(); - assert isOpPut() || isOpDestroy; + // TODO This has to be commented out. Check side effects. + // assert isOpPut() || isOpDestroy; final TXRegionState txrs = this.txRegionState; txrs.lock(); @@ -1714,4 +1718,14 @@ public void endIndexKeyUpdate() { public Version[] getSerializationVersions() { return null; } + + private volatile RegionEntry committedRegionEntry = null; + + public void setCommittedRegionEntry(RegionEntry committedRegionEntry) { + this.committedRegionEntry = committedRegionEntry; + } + + public RegionEntry getCommittedEntry() { + return this.committedRegionEntry; + } } diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ui/ClusterStatistics.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ui/ClusterStatistics.java index 5489fdbdd..dee5f71e4 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ui/ClusterStatistics.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ui/ClusterStatistics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ui/MemberStatistics.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ui/MemberStatistics.java index 96bbfbcbe..6d1740619 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ui/MemberStatistics.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ui/MemberStatistics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ui/SnappyExternalTableStats.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ui/SnappyExternalTableStats.java index 3a9938ced..1303b3d00 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ui/SnappyExternalTableStats.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ui/SnappyExternalTableStats.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -18,23 +18,30 @@ package com.pivotal.gemfirexd.internal.engine.ui; public class SnappyExternalTableStats { + private String tableFullyQualifiedName; private String tableName; private String tableType; + private Object schema; private String provider; private String dataSourcePath; private String driverClass; private Object externalStore; - public SnappyExternalTableStats(String tableName, String tableType, + public SnappyExternalTableStats(String tableName, String tableType, Object schema, String provider, Object externalStore, String dataSourcePath, String driverClass) { this.tableName = tableName; this.tableType = tableType; + this.schema = schema; + this.tableFullyQualifiedName = schema.toString().concat(".").concat(tableName); this.provider = provider; this.externalStore = externalStore; this.dataSourcePath = dataSourcePath; this.driverClass = driverClass; } + public String getTableFullyQualifiedName() { + return tableFullyQualifiedName; + } public String getTableName() { return tableName; @@ -44,6 +51,10 @@ public String getTableType() { return tableType; } + public Object getSchema() { + return schema; + } + public String getProvider() { return provider; } diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ui/SnappyRegionStats.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ui/SnappyRegionStats.java index fcafb458b..34d01e468 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ui/SnappyRegionStats.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ui/SnappyRegionStats.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -27,10 +27,13 @@ public class SnappyRegionStats implements VersionedDataSerializable { + private static final long serialVersionUID = -2793473664036745905L; + private boolean isColumnTable = false; private String tableName; private long rowCount = 0; private long sizeInMemory = 0; + private long sizeSpillToDisk = 0; private long totalSize = 0; private boolean isReplicatedTable = false; private int bucketCount; @@ -48,16 +51,13 @@ public SnappyRegionStats(String tableName, long totalSize, long sizeInMemory, this.tableName = tableName; this.totalSize = totalSize; this.sizeInMemory = sizeInMemory; + this.sizeSpillToDisk = totalSize - sizeInMemory; this.rowCount = rowCount; this.isColumnTable = isColumnTable; this.isReplicatedTable = isReplicatedTable; this.bucketCount = bucketCount; } - public void setTotalSize(long totalSize) { - this.totalSize = totalSize; - } - public String getTableName() { return tableName; } @@ -99,10 +99,22 @@ public void setSizeInMemory(long sizeInMemory) { this.sizeInMemory = sizeInMemory; } + public long getSizeSpillToDisk() { + return sizeSpillToDisk; + } + + public void setSizeSpillToDisk(long sizeSpillToDisk) { + this.sizeSpillToDisk = sizeSpillToDisk; + } + public long getTotalSize() { return this.totalSize; } + public void setTotalSize(long totalSize) { + this.totalSize = totalSize; + } + public int getBucketCount() { return this.bucketCount; } @@ -122,6 +134,7 @@ public SnappyRegionStats getCombinedStats(SnappyRegionStats stats) { } combinedStats.setSizeInMemory(stats.sizeInMemory + this.sizeInMemory); + combinedStats.setSizeSpillToDisk(stats.sizeSpillToDisk + this.sizeSpillToDisk); combinedStats.setTotalSize(stats.totalSize + this.totalSize); combinedStats.setColumnTable(this.isColumnTable || stats.isColumnTable); combinedStats.setReplicatedTable(this.isReplicatedTable()); @@ -149,6 +162,7 @@ public void toDataPre_STORE_1_6_2_0(final DataOutput out) throws IOException { public void toData(final DataOutput out) throws IOException { toDataPre_STORE_1_6_2_0(out); out.writeInt(bucketCount); + out.writeLong(sizeSpillToDisk); } public void fromDataPre_STORE_1_6_2_0(DataInput in) throws IOException { @@ -164,13 +178,14 @@ public void fromDataPre_STORE_1_6_2_0(DataInput in) throws IOException { public void fromData(DataInput in) throws IOException { fromDataPre_STORE_1_6_2_0(in); this.bucketCount = in.readInt(); + this.sizeSpillToDisk = in.readLong(); } @Override public String toString() { return "RegionStats for " + tableName + ": totalSize=" + totalSize + - " sizeInMemory=" + sizeInMemory + " rowCount=" + rowCount + - " isColumnTable=" + isColumnTable + " isReplicatedTable=" + + " sizeInMemory=" + sizeInMemory + " sizeSpillToDisk=" + sizeSpillToDisk + + " rowCount=" + rowCount + " isColumnTable=" + isColumnTable + " isReplicatedTable=" + isReplicatedTable + " bucketCount=" + bucketCount; } } diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ui/SnappyRegionStatsCollectorFunction.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ui/SnappyRegionStatsCollectorFunction.java index 3bd684ea5..610214203 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ui/SnappyRegionStatsCollectorFunction.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ui/SnappyRegionStatsCollectorFunction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -33,6 +33,8 @@ import com.pivotal.gemfirexd.internal.engine.access.index.GfxdIndexManager; import com.pivotal.gemfirexd.internal.engine.store.GemFireContainer; import com.pivotal.gemfirexd.internal.iapi.error.StandardException; +import com.pivotal.gemfirexd.internal.iapi.reference.Property; +import com.pivotal.gemfirexd.internal.shared.common.SharedUtils; import com.pivotal.gemfirexd.tools.sizer.GemFireXDInstrumentation; import com.pivotal.gemfirexd.tools.sizer.ObjectSizer; import org.slf4j.Logger; @@ -103,11 +105,20 @@ public void execute(FunctionContext context) { if (Misc.reservoirRegionCreated) { for (SnappyRegionStats tableStats : otherStats) { - String tableName = tableStats.getTableName(); + String tableName = SharedUtils.SQLToUpperCase(tableStats.getTableName()); StoreCallbacks callback = CallbackFactoryProvider.getStoreCallbacks(); String columnBatchTableName = callback.columnBatchTableName(tableName); if (cachBatchStats.containsKey(columnBatchTableName)) { - String reservoirRegionName = Misc.getReservoirRegionNameForSampleTable("APP", tableName); + String schemaName; + int dotIndex = tableName.indexOf('.'); + if (dotIndex > 0) { + schemaName = tableName.substring(0, dotIndex); + } else { + schemaName = Property.DEFAULT_USER_NAME; + tableName = schemaName + '.' + tableName; + } + String reservoirRegionName = Misc.getReservoirRegionNameForSampleTable( + schemaName, tableName); PartitionedRegion pr = Misc.getReservoirRegionForSampleTable(reservoirRegionName); if (managementService != null && pr != null) { RegionMXBean reservoirBean = managementService.getLocalRegionMBean(pr.getFullPath()); @@ -211,6 +222,7 @@ private SnappyRegionStats collectDataFromBeanImpl(LocalRegion lr, RegionMXBean b } } tableStats.setTotalSize(size); + tableStats.setSizeSpillToDisk(size - tableStats.getSizeInMemory()); } else { PartitionedRegion pr = (PartitionedRegion)lr; PartitionedRegionDataStore datastore = pr.getDataStore(); @@ -243,6 +255,7 @@ private SnappyRegionStats collectDataFromBeanImpl(LocalRegion lr, RegionMXBean b tableStats.setSizeInMemory(sizeInMemory + offHeapBytes + entryOverhead); tableStats.setTotalSize(sizeOfRegion + offHeapBytes + entryOverhead); + tableStats.setSizeSpillToDisk(tableStats.getTotalSize() - tableStats.getSizeInMemory()); } return tableStats; } diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ui/SnappyRegionStatsCollectorResult.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ui/SnappyRegionStatsCollectorResult.java index a277e436f..f4988f7ce 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ui/SnappyRegionStatsCollectorResult.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ui/SnappyRegionStatsCollectorResult.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ui/SnappyUtils.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ui/SnappyUtils.java index 524390eda..d1f092978 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ui/SnappyUtils.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/ui/SnappyUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/iapi/services/context/ContextService.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/iapi/services/context/ContextService.java index e0ed0a163..40151594b 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/iapi/services/context/ContextService.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/iapi/services/context/ContextService.java @@ -242,7 +242,11 @@ public static void stop() { if (fact != null) { synchronized (fact) { fact.allContexts = null; - fact.threadContextList = null; + final ThreadLocal contextList = fact.threadContextList; + if (contextList != null) { + contextList.remove(); + fact.threadContextList = null; + } ContextService.factory = null; } } diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/iapi/tools/i18n/PagedLocalizedOutput.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/iapi/tools/i18n/PagedLocalizedOutput.java index 2dc6019ab..abafde2d8 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/iapi/tools/i18n/PagedLocalizedOutput.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/iapi/tools/i18n/PagedLocalizedOutput.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/jdbc/EmbedDatabaseMetaData.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/jdbc/EmbedDatabaseMetaData.java index 178a9a2f4..0d1b7e428 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/jdbc/EmbedDatabaseMetaData.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/jdbc/EmbedDatabaseMetaData.java @@ -40,14 +40,6 @@ Licensed to the Apache Software Foundation (ASF) under one or more package com.pivotal.gemfirexd.internal.impl.jdbc; - - - - - - - - import java.util.Properties; import java.util.concurrent.TimeUnit; import java.sql.DatabaseMetaData; @@ -73,6 +65,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more import com.pivotal.gemfirexd.internal.iapi.sql.conn.LanguageConnectionContext; import com.pivotal.gemfirexd.internal.iapi.sql.dictionary.DataDictionary; import com.pivotal.gemfirexd.internal.iapi.sql.dictionary.SPSDescriptor; +import com.pivotal.gemfirexd.internal.iapi.util.StringUtil; import com.pivotal.gemfirexd.internal.impl.sql.execute.GenericConstantActionFactory; import com.pivotal.gemfirexd.internal.impl.sql.execute.GenericExecutionFactory; @@ -1799,40 +1792,47 @@ public ResultSet getTables(String catalog, String schemaPattern, //GemStone changes END if (types == null) {// null means all types - types = new String[] {"ROW TABLE","VIEW","SYNONYM","SYSTEM TABLE" - /* GemStone changes BEGIN */, "COLUMN TABLE", - "EXTERNAL TABLE", "STREAM TABLE", "SAMPLE TABLE", "TOPK TABLE", "VIRTUAL TABLE", - /* GemStone changes END */}; + types = new String[] {"TABLE","VIEW","SYNONYM","SYSTEM TABLE","VIRTUAL TABLE"}; } String[] typeParams = new String[numberOfTableTypesInDerby]; for (int i=0; i < numberOfTableTypesInDerby;i++) typeParams[i] = null; - for (int i = 0; i groupMembers) throws NamingException { - NamingEnumeration results; - // Construct Search Filter - SearchControls ctls = new SearchControls(); - if (topLevel) { - // Setup an LDAP subtree search scope - ctls.setSearchScope(SearchControls.SUBTREE_SCOPE); - } else { - // Setup an LDAP single object search scope - ctls.setSearchScope(SearchControls.OBJECT_SCOPE); + /** + * Search for the LDAP group's DN in the LDAP server. LDAP server bind + * may or not be anonymous. + *

+ * If the admin does not want us to do anonymous bind/search, then we + * must have been given principal/credentials in order to successfully + * bind to perform the user's DN search. + * + * @throws NamingException on failure to retrieve the LDAP group's base DN + */ + public Set getLDAPGroupMembers(String ldapGroup) + throws Exception { + ArrayList groupMembers = new ArrayList(); + // Return all the unique members collected for the group + this.recurseGroups(ldapGroup, groupMembers, null); + return new UnifiedSet<>(groupMembers); + } + + + + + + /** + * Search for the all the Groups the user is member of, the LDAP server. LDAP server bind + * may or not be anonymous. + *

+ * If the admin does not want us to do anonymous bind/search, then we + * must have been given principal/credentials in order to successfully + * bind to perform the user's DN search. + * + * @throws NamingException on failure to retrieve the LDAP group's base DN + */ + public Set getLdapGroupsOfUser(String uid) + throws Exception { + + DirContext ctx = getDirContext(uid); + String attributesNeeded[] = Arrays.copyOf(attrDN, attrDN.length + 1); + attributesNeeded[attributesNeeded.length - 1] = memberOfAttr; + NamingEnumeration results = getUserInformation(uid, ctx, attributesNeeded); + // If we did not find anything then login failed + if (results == null || !results.hasMore()) + throw new NameNotFoundException(); + + SearchResult result = (SearchResult) results.next(); + ArrayList ldapGroups = new ArrayList(); + Attribute memberOfAttr = result.getAttributes().get("memberOf"); + if (memberOfAttr != null) { + NamingEnumeration ne = memberOfAttr.getAll(); + while (ne.hasMore()) { + String group = (String) ne.next(); + LdapName groupDn = new LdapName(group); + Iterator iter = groupDn.getRdns().iterator(); + + while (iter.hasNext()) { + Rdn rdn = iter.next(); + if (rdn.getType().equalsIgnoreCase("cn")) { + String cn = rdn.getValue().toString(); + if ((cn = cn.trim()).length() > 0) { + ldapGroups.add(StringUtil.SQLToUpperCase(cn)); + } + break; } - // Retrieve the specified (or default) member attributes - ctls.setReturningAttributes(searchAttributes); - - results = ctx.search(baseDN, searchFilter, ctls); - - // If we did not find anything then login failed - if (results == null || !results.hasMore()) { - throw new NameNotFoundException("Lookup for LDAP group = " + - group + " failed. Filter=" + searchFilter + " DN: " + baseDN); + } + } + } else { + String userDN = getDNFromSearchResult(ctx, result); + this.recurseGroups("*", ldapGroups, userDN); + } + return new UnifiedSet<>(ldapGroups); + + } + + private void recurseGroups(String ldapGroup, List storage, + String userDN) + throws Exception { + + // We bind to the LDAP server here + // Note that this bind might be anonymous (if anonymous searches + // are allowed in the LDAP server, or authenticated if we were + // told/configured to. + Properties env = null; + if (this.searchAuthDN != null) { + env = (Properties) initDirContextEnv.clone(); + env.put(Context.SECURITY_PRINCIPAL, this.searchAuthDN); + env.put(Context.SECURITY_CREDENTIALS, getSearchAuthPwd()); + } else { + env = initDirContextEnv; + } + + if (GemFireXDUtils.TraceAuthentication) { + SanityManager.DEBUG_PRINT(AuthenticationServiceBase.AuthenticationTrace, + "Initializing search for LDAP group =" + ldapGroup != null ? ldapGroup : userDN); + } + DirContext ctx = privInitialDirContext(env); + + // Construct Search Filter + String searchFilter = null; + if (ldapGroup != null) { + searchFilter = groupPattern.matcher(this.searchGroupFilter) + .replaceAll(ldapGroup); + } else { + searchFilter = groupPattern.matcher(this.searchGroupFilter) + .replaceAll("*"); + } + + // Call the resolve method that will walk through the group members + // recursively, if required + if (GemFireXDUtils.TraceAuthentication) { + SanityManager.DEBUG_PRINT(AuthenticationServiceBase.AuthenticationTrace, + "Searching for LDAP group=" + ldapGroup + ", groupBase=" + + this.searchGroupBase + ", searchFilter=" + searchFilter); + } + + resolveDNForGroup(ctx, this.searchGroupBase, searchFilter, + this.searchGroupAttributes, true, ldapGroup, + storage, userDN); + ctx.close(); + + } + + /** + * Search for the given DN for any LDAP group members. The DN can + * correspond to a user's UID entry or another LDAP group itself. + * LDAP server bind may or not be anonymous. + * + * @throws NamingException on failure to retrieve the given DN + */ + private void resolveDNForGroup(DirContext ctx, String baseDN, + String searchFilter, String[] searchAttributes, boolean topLevel, + String group, List storage, + String userDN) throws Exception { + + NamingEnumeration results; + // Construct Search Filter + SearchControls ctls = new SearchControls(); + if (topLevel) { + // Setup an LDAP subtree search scope + ctls.setSearchScope(SearchControls.SUBTREE_SCOPE); + } else { + // Setup an LDAP single object search scope + ctls.setSearchScope(SearchControls.OBJECT_SCOPE); + } + // Retrieve the specified (or default) member attributes + ctls.setReturningAttributes(searchAttributes); + + results = ctx.search(baseDN, searchFilter, ctls); + + // If we did not find anything then login failed + if (results == null || !results.hasMore()) { + throw new NameNotFoundException("Lookup for LDAP group = " + + group + " failed. Filter=" + searchFilter + " DN: " + baseDN); + } + + // loop through all matches + while (true) { + SearchResult result = results.next(); + Attributes attrs = result.getAttributes(); + // loop through all matching attributes + if (attrs != null) { + NamingEnumeration allAttrs = attrs.getAll(); + while (true) { + try { + if (!allAttrs.hasMore()) { + break; + } + } catch (NamingException ne) { + // ignore; can happen with Active Directory + break; } - - // loop through all matches + Attribute attr = allAttrs.next(); + NamingEnumeration attrVals = attr.getAll(); while (true) { - SearchResult result = results.next(); - Attributes attrs = result.getAttributes(); - // loop through all matching attributes - if (attrs != null) { - NamingEnumeration allAttrs = attrs.getAll(); - while (true) { - try { - if (!allAttrs.hasMore()) { - break; - } - } catch (NamingException ne) { - // ignore; can happen with Active Directory - break; - } - Attribute attr = allAttrs.next(); - NamingEnumeration attrVals = attr.getAll(); - while (true) { - try { - if (!attrVals.hasMore()) { - break; - } - } catch (NamingException ne) { - // ignore; can happen with Active Directory - break; - } - String member = (String)attrVals.next(); - if (member == null) { - continue; - } - if (member.indexOf('=') >= 0) { - // the result here is a fully qualified name so parse - LdapName memberDN = new LdapName(member); - // the member object can be a user or a group itself - // if it has a uid= then its a member and can be - // added directly else lookup the DN again to get - // the members (or it can be a cn= of a member - // itself but still needs to be looked up) - if (!memberDN.isEmpty()) { - Rdn id = memberDN.getRdn(memberDN.size() - 1); - if (attributeExists(id.getType(), - this.searchGroupUserAttributes)) { - member = id.getValue().toString(); - } else { - // need to do a full search again - if (topLevel) { - // match any objectClass for recursive searches - // since the DN expressed in member attribute - // should be fully qualified to match a single entry - searchFilter = "(objectClass=*)"; - // add attributes for both groups and users - int nAttrs = searchAttributes.length; - int nSearchAttrs = this.searchGroupUserAttributes.length; - searchAttributes = Arrays.copyOf(searchAttributes, - nAttrs + nSearchAttrs); - System.arraycopy(this.searchGroupUserAttributes, 0, - searchAttributes, nAttrs, nSearchAttrs); - } - if (GemFireXDUtils.TraceAuthentication) { - SanityManager.DEBUG_PRINT( - AuthenticationServiceBase.AuthenticationTrace, - "Searching DN " + member + " in LDAP group = " - + group + " filter = " + searchFilter - + " attributes = " + Arrays.toString( - searchAttributes)); - } - resolveDNForGroup(ctx, member, searchFilter, - searchAttributes, false, group, groupMembers); - continue; - } - } - } - if ((member = member.trim()).length() > 0) { - member = StringUtil.SQLToUpperCase(member); - if (GemFireXDUtils.TraceAuthentication) { - SanityManager.DEBUG_PRINT( - AuthenticationServiceBase.AuthenticationTrace, - "Found member " + member + " in LDAP group = " + group); - } - groupMembers.add(member); - } - } - } - } - try { - if (!results.hasMore()) { + if (!attrVals.hasMore()) { break; } } catch (NamingException ne) { // ignore; can happen with Active Directory break; } + String member = (String) attrVals.next(); + if (member == null) { + continue; + } + if (userDN == null) { + collectGroupMembers(ctx, member, group, storage, topLevel, searchFilter, + searchAttributes); + } else { + collectGroups(ctx, member, userDN, storage, searchFilter, + searchAttributes, result); + } } } + } - private boolean attributeExists(String attr, String[] attrs) { - for (String a : attrs) { - if (attr.equalsIgnoreCase(a)) { - return true; - } + try { + if (!results.hasMore()) { + break; + } + } catch (NamingException ne) { + // ignore; can happen with Active Directory + break; + } + } + } + + + private void collectGroupMembers(DirContext ctx, String member, String group, + List groupMembers, boolean topLevel, + String searchFilter, String[] searchAttributes) throws Exception { + if (member.indexOf('=') >= 0) { + // the result here is a fully qualified name so parse + LdapName memberDN = new LdapName(member); + // the member object can be a user or a group itself + // if it has a uid= then its a member and can be + // added directly else lookup the DN again to get + // the members (or it can be a cn= of a member + // itself but still needs to be looked up) + if (!memberDN.isEmpty()) { + Rdn id = memberDN.getRdn(memberDN.size() - 1); + if (attributeExists(id.getType(), + this.searchGroupUserAttributes)) { + member = id.getValue().toString(); + } else { + // need to do a full search again + if (topLevel) { + // match any objectClass for recursive searches + // since the DN expressed in member attribute + // should be fully qualified to match a single entry + searchFilter = "(objectClass=*)"; + // add attributes for both groups and users + int nAttrs = searchAttributes.length; + int nSearchAttrs = this.searchGroupUserAttributes.length; + searchAttributes = Arrays.copyOf(searchAttributes, + nAttrs + nSearchAttrs); + System.arraycopy(this.searchGroupUserAttributes, 0, + searchAttributes, nAttrs, nSearchAttrs); } - return false; + if (GemFireXDUtils.TraceAuthentication) { + SanityManager.DEBUG_PRINT( + AuthenticationServiceBase.AuthenticationTrace, + "Searching DN " + member + " in LDAP group = " + + group + " filter = " + searchFilter + + " attributes = " + Arrays.toString( + searchAttributes)); + } + resolveDNForGroup(ctx, member, searchFilter, + searchAttributes, false, group, + groupMembers, null); + return; } - - /** - * Search for the LDAP group's DN in the LDAP server. LDAP server bind - * may or not be anonymous. - * - * If the admin does not want us to do anonymous bind/search, then we - * must have been given principal/credentials in order to successfully - * bind to perform the user's DN search. - * - * @exception NamingException - * on failure to retrieve the LDAP group's base DN - */ - public Set getLDAPGroupMembers(String ldapGroup) - throws Exception { - - // We bind to the LDAP server here - // Note that this bind might be anonymous (if anonymous searches - // are allowed in the LDAP server, or authenticated if we were - // told/configured to. - Properties env = null; - if (this.searchAuthDN != null) { - env = (Properties)initDirContextEnv.clone(); - env.put(Context.SECURITY_PRINCIPAL, this.searchAuthDN); - env.put(Context.SECURITY_CREDENTIALS, getSearchAuthPwd()); + } + } + if ((member = member.trim()).length() > 0) { + member = StringUtil.SQLToUpperCase(member); + if (GemFireXDUtils.TraceAuthentication) { + SanityManager.DEBUG_PRINT( + AuthenticationServiceBase.AuthenticationTrace, + "Found member " + member + " in LDAP group = " + group); + } + groupMembers.add(member); + } + } + + + private void collectGroups(DirContext ctx, String member, String userDN, + List groupsOfUser, + String searchFilter, String[] searchAttributes, + SearchResult result) throws Exception { + int currentSize = groupsOfUser.size(); + if (member.indexOf('=') >= 0) { + // the result here is a fully qualified name so parse + LdapName memberDN = new LdapName(member); + + if (!memberDN.isEmpty()) { + Rdn id = memberDN.getRdn(memberDN.size() - 1); + if (attributeExists(id.getType(), + this.searchGroupUserAttributes)) { + member = id.getValue().toString(); + String dnOfMember = getDNFromUID(member); + if (dnOfMember.equals(userDN)) { + LdapName groupDn = new LdapName(getDNFromSearchResult(ctx, result)); + groupsOfUser.add(StringUtil.SQLToUpperCase(groupDn.getRdn(groupDn.size() - 1). + getValue().toString())); + } + } else { + // if not uid , then it must be dn? + if (userDN.equals(member)) { + LdapName groupDn = new LdapName(getDNFromSearchResult(ctx, result)); + groupsOfUser.add(StringUtil.SQLToUpperCase(groupDn.getRdn(groupDn.size() - 1). + getValue().toString())); } else { - env = initDirContextEnv; + if (GemFireXDUtils.TraceAuthentication) { + SanityManager.DEBUG_PRINT( + AuthenticationServiceBase.AuthenticationTrace, + "Searching DN " + member + " in LDAP userDN = " + + userDN + " filter = " + searchFilter + + " attributes = " + Arrays.toString( + searchAttributes)); + } + LdapName dnOfMember = new LdapName(member); + String cn = dnOfMember.getRdn(dnOfMember.size() - 1).getValue().toString(); + dnOfMember.remove(dnOfMember.size() - 1); + String baseDn = dnOfMember.toString(); + searchFilter = groupPattern.matcher(this.searchGroupFilter) + .replaceAll(cn); + resolveDNForGroup(ctx, baseDn, searchFilter, + searchAttributes, true, null, + groupsOfUser, userDN); + if (currentSize < groupsOfUser.size()) { + // add parent group , as child group has been found to be a match + LdapName groupDn = new LdapName(getDNFromSearchResult(ctx, result)); + groupsOfUser.add(StringUtil.SQLToUpperCase(groupDn.getRdn(groupDn.size() - 1). + getValue().toString())); + } + return; } + } + } + } - if (GemFireXDUtils.TraceAuthentication) { - SanityManager.DEBUG_PRINT(AuthenticationServiceBase.AuthenticationTrace, - "Initializing search for LDAP group=" + ldapGroup); - } - DirContext ctx = privInitialDirContext(env); + } - // Construct Search Filter - String searchFilter = groupPattern.matcher(this.searchGroupFilter) - .replaceAll(ldapGroup); - // Call the resolve method that will walk through the group members - // recursively, if required - if (GemFireXDUtils.TraceAuthentication) { - SanityManager.DEBUG_PRINT(AuthenticationServiceBase.AuthenticationTrace, - "Searching for LDAP group=" + ldapGroup + ", groupBase=" - + this.searchGroupBase + ", searchFilter=" + searchFilter); - } - ArrayList groupMembers = new ArrayList(); - resolveDNForGroup(ctx, this.searchGroupBase, searchFilter, - this.searchGroupAttributes, true, ldapGroup, groupMembers); - ctx.close(); - // Return all the unique members collected for the group - @SuppressWarnings("unchecked") - final Set uniqueMembers = new THashSet(groupMembers); - return uniqueMembers; - } + private boolean attributeExists(String attr, String[] attrs) { + for (String a : attrs) { + if (attr.equalsIgnoreCase(a)) { + return true; + } + } + return false; + } - @Override + + + @Override public String toString() { return Constants.AUTHENTICATION_PROVIDER_LDAP; } diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/GenericStatement.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/GenericStatement.java index 41c83c2e7..edffbeabb 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/GenericStatement.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/GenericStatement.java @@ -49,6 +49,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more import java.util.Set; import java.util.regex.Pattern; +import com.gemstone.gemfire.cache.Region; import com.gemstone.gemfire.internal.cache.LocalRegion; import com.gemstone.gemfire.internal.cache.PartitionedRegion; import com.gemstone.gnu.trove.THashMap; @@ -102,6 +103,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more import com.pivotal.gemfirexd.internal.shared.common.sanity.AssertFailure; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import com.pivotal.gemfirexd.internal.impl.sql.rules.ExecutionEngineRule.ExecutionEngine; +import org.apache.log4j.Logger; //GemStone changes BEGIN @@ -119,6 +121,7 @@ public class GenericStatement // protected boolean createQueryInfo; //final private boolean needGfxdSubactivation; //protected final boolean isPreparedStatement; + static final Logger LOGGER = Logger.getLogger(GenericStatement.class); protected int hash; protected int stmtHash; protected short execFlags; @@ -142,10 +145,11 @@ public class GenericStatement //private ProcedureProxy procProxy; private final GfxdHeapThresholdListener thresholdListener; private THashMap ncjMetaData = null; - private static final String MISC_DDL_PREFIX = "(STREAMING|DEPLOY|UNDEPLOY)"; + private static final String MISC_DDL_PREFIX = + "(STREAMING|DEPLOY|UNDEPLOY|CACHE|UNCACHE|REFRESH|RESET)"; private static final String TABLE_DML_SELECT_PATTERN = "((((INSERT|PUT)\\s+INTO)|(DELETE\\s+FROM))\\s+(TABLE)?.*\\s+SELECT)"; - private static final String CREATE_OR_DROP_PATTERN = "(FUNCTION|POLICY)"; + private static final String CREATE_OR_DROP_PATTERN = "(FUNCTION|POLICY|SCHEMA)"; private static final String ALTER_TABLE_PREFIX = "ALTER\\s+(TABLE)?\\s+.*\\s+"; private static final String ALTER_TABLE_COMMANDS = "(ADD|DROP|ENABLE|DISABLE)"; @@ -235,10 +239,10 @@ public final PreparedStatement prepare(final LanguageConnectionContext lcc, fina // GemStone changes BEGIN private GenericPreparedStatement getPreparedStatementForSnappy(boolean commitNestedTransaction, StatementContext statementContext, LanguageConnectionContext lcc, boolean isDDL, - boolean checkCancellation, boolean isUpdateOrDelete) throws StandardException { + boolean checkCancellation, boolean isUpdateOrDeleteOrPut, Throwable cause) throws StandardException { GenericPreparedStatement gps = preparedStmt; GeneratedClass ac = new SnappyActivationClass(lcc, !isDDL, isPreparedStatement() && !isDDL, - isUpdateOrDelete); + isUpdateOrDeleteOrPut); gps.setActivationClass(ac); gps.incrementVersionCounter(); gps.makeValid(); @@ -252,8 +256,12 @@ private GenericPreparedStatement getPreparedStatementForSnappy(boolean commitNes if (GemFireXDUtils.TraceQuery) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_QUERYDISTRIB, "GenericStatement.getPreparedStatementForSnappy: Created SnappyActivation for sql: " + - this.getSource() + " ,isDDL=" + isDDL + " ,isUpdateOrDelete=" + isUpdateOrDelete); - } + this.getSource() + " ,isDDL=" + isDDL + " ,isUpdateOrDeleteOrPut=" + isUpdateOrDeleteOrPut); + } + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("GenericStatement.getPreparedStatementForSnappy: routing sql: " + + this.getSource() + " ,isDDL=" + isDDL + " ,isUpdateOrDeleteOrPut=" + isUpdateOrDeleteOrPut, cause); + } if (checkCancellation) { Misc.checkMemory(thresholdListener, statementText, -1); } @@ -609,7 +617,7 @@ private final PreparedStatement prepMinion( cc.markAsDDLForSnappyUse(true); return getPreparedStatementForSnappy(false, statementContext, lcc, cc.isMarkedAsDDLForSnappyUse(), checkCancellation, - DML_TABLE_PATTERN.matcher(source).find()); + DML_TABLE_PATTERN.matcher(source).find(), null); } qt = p.parseStatement(getQueryStringForParse(lcc), paramDefaults); } @@ -619,7 +627,7 @@ private final PreparedStatement prepMinion( !NON_ROUTED_QUERY.matcher(source).find()) { return getPreparedStatementForSnappy(false, statementContext, lcc, cc.isMarkedAsDDLForSnappyUse(), checkCancellation, - DML_TABLE_PATTERN.matcher(source).find()); + DML_TABLE_PATTERN.matcher(source).find(), ex); } throw ex; } @@ -632,7 +640,7 @@ private final PreparedStatement prepMinion( observer.testExecutionEngineDecision(qinfo, ExecutionEngine.SPARK, this.statementText); } return getPreparedStatementForSnappy(false, statementContext, lcc, true, - checkCancellation, DML_TABLE_PATTERN.matcher(source).find()); + checkCancellation, DML_TABLE_PATTERN.matcher(source).find(), null); } //GemStone changes END parseTime = getCurrentTimeMillis(lcc); @@ -708,7 +716,7 @@ private final PreparedStatement prepMinion( observer.testExecutionEngineDecision(qinfo, ExecutionEngine.SPARK, this.statementText); } return getPreparedStatementForSnappy(true, statementContext, lcc, false, - checkCancellation, DML_TABLE_PATTERN.matcher(source).find()); + checkCancellation, DML_TABLE_PATTERN.matcher(source).find(), ex); } throw ex; } @@ -777,7 +785,7 @@ private final PreparedStatement prepMinion( observer.testExecutionEngineDecision(qinfo, ExecutionEngine.SPARK, this.statementText); } return getPreparedStatementForSnappy(true, statementContext, lcc, false, - checkCancellation, DML_TABLE_PATTERN.matcher(source).find()); + checkCancellation, DML_TABLE_PATTERN.matcher(source).find(), ex); } throw ex; } @@ -810,7 +818,7 @@ private final PreparedStatement prepMinion( ExecutionEngine.SPARK, this.statementText); } return getPreparedStatementForSnappy(true, - statementContext, lcc, false, checkCancellation, false); + statementContext, lcc, false, checkCancellation, false, null); } if(this.createQueryInfo() && !forceSkipQueryInfoCreation) { final DataTypeDescriptor paramDTDS[] = qt.getParameterTypes(); @@ -839,11 +847,24 @@ private final PreparedStatement prepMinion( } return getPreparedStatementForSnappy(true, statementContext, lcc, false, - checkCancellation, isUpdateOrDelete); + checkCancellation, isUpdateOrDelete, null); } } } + if (routeQuery && qinfo != null && qinfo.isDML() && qinfo.isInsert() && ((InsertQueryInfo)qinfo).isPutDML()) { + InsertNode in = qt instanceof InsertNode ? ((InsertNode)qt) : null; + TableDescriptor ttd = in != null ? in.targetTableDescriptor : null; + String table = ttd.getQualifiedName(); + Region region = Misc.getRegionForTable(table.replaceAll("\"", ""), true); + GemFireContainer container = (GemFireContainer)region.getUserAttribute(); + boolean isColumnTable = container.isRowBuffer(); + if (isColumnTable) { + return getPreparedStatementForSnappy(true, statementContext, lcc, + false, checkCancellation, true, null); + } + } + if (observer != null && qinfo != null && qinfo.isSelect()) { observer.testExecutionEngineDecision(qinfo, ExecutionEngine.STORE, this.statementText); } @@ -955,7 +976,7 @@ else if (SQLState.INTERNAL_SKIP_ORLIST_OPTIMIZATION.equals(messgId)) { observer.testExecutionEngineDecision(qinfo, ExecutionEngine.SPARK, this.statementText); } return getPreparedStatementForSnappy(true, statementContext, lcc, false, - checkCancellation, DML_TABLE_PATTERN.matcher(source).find()); + checkCancellation, DML_TABLE_PATTERN.matcher(source).find(), se); } // GemStone changes END lcc.commitNestedTransaction(); diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/catalog/GfxdDataDictionary.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/catalog/GfxdDataDictionary.java index be79287c1..b0326bd60 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/catalog/GfxdDataDictionary.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/catalog/GfxdDataDictionary.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -38,6 +38,7 @@ import java.sql.ResultSetMetaData; import java.sql.Types; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -236,24 +237,35 @@ private final static class SYSFUNEntry { { SYSFUN_MODE, SYSFUN_MODE }, { SYSFUN_MODE, SYSFUN_MODE, SYSFUN_MODE }, { SYSFUN_MODE, SYSFUN_MODE, SYSFUN_MODE, SYSFUN_MODE } }; + public static final class SkipCatalogOperations { + /** + * Skip calls to inbuilt hive catalog (for cases that can lead + * to recursive calls from within hive catalog query threads). + */ + public boolean skipHiveCatalogCalls; + /** + * Skip DataDictionary locks to avoid deadlocks in some cases. + */ + public boolean skipDDLocks; + + SkipCatalogOperations(boolean skipHiveCatalogCalls, boolean skipDDLocks) { + this.skipHiveCatalogCalls = skipHiveCatalogCalls; + this.skipDDLocks = skipDDLocks; + } + } + /** * This allows a thread to skip acquiring read lock on GfxdDataDictionary * and/or GemFireContainer. Used at the time of checking if a table is * columnar or not while setting its tabletype. */ - public static final ThreadLocal SKIP_LOCKS = new ThreadLocal() { - public Boolean initialValue() { - return Boolean.FALSE; - } - }; + public static final ThreadLocal SKIP_CATALOG_OPS = + ThreadLocal.withInitial(() -> new SkipCatalogOperations(false, false)); - /** static block */ static { // populate the set of system schemas - sysSchemaSet = new HashSet(systemSchemaNames.length * 2); - for (String sysSchema : systemSchemaNames) { - sysSchemaSet.add(sysSchema); - } + sysSchemaSet = new HashSet<>(systemSchemaNames.length * 2); + Collections.addAll(sysSchemaSet, systemSchemaNames); } @Override @@ -419,8 +431,8 @@ public final void lockForReading(TransactionController tc) public final boolean lockForReadingNoThrow(TransactionController tc, long maxWaitMillis) { try { - return SKIP_LOCKS.get() || GemFireXDUtils.lockObjectNoThrow(ddLockObject, null, false, false, - tc, maxWaitMillis) != GfxdLockSet.LOCK_FAIL; + return SKIP_CATALOG_OPS.get().skipDDLocks || GemFireXDUtils.lockObjectNoThrow( + ddLockObject, null, false, false, tc, maxWaitMillis) != GfxdLockSet.LOCK_FAIL; } catch (StandardException se) { // unexpected throw GemFireXDRuntimeException.newRuntimeException( @@ -476,7 +488,7 @@ public final boolean lockForReadingInDDLReplayNoThrow( */ @Override public final boolean unlockAfterReading(TransactionController tc) { - if (!SKIP_LOCKS.get()) { + if (!SKIP_CATALOG_OPS.get().skipDDLocks) { return GemFireXDUtils.unlockObject(ddLockObject, null, false, false, tc); } else { return false; @@ -617,8 +629,8 @@ public void transactionFinished() throws StandardException { @Override public final boolean lockForWriting(TransactionController tc, boolean localOnly) throws StandardException { - return SKIP_LOCKS.get() || GemFireXDUtils.lockObject(ddLockObject, null, true, localOnly, tc, - GfxdLockSet.MAX_LOCKWAIT_VAL); + return SKIP_CATALOG_OPS.get().skipDDLocks || GemFireXDUtils.lockObject( + ddLockObject, null, true, localOnly, tc, GfxdLockSet.MAX_LOCKWAIT_VAL); } /** @@ -649,7 +661,7 @@ public final GfxdLockable getLockObject() { @Override public final void unlockAfterWriting(TransactionController tc, boolean localOnly) { - if (!SKIP_LOCKS.get()) { + if (!SKIP_CATALOG_OPS.get().skipDDLocks) { GemFireXDUtils.unlockObject(ddLockObject, null, true, localOnly, tc); } } @@ -1630,12 +1642,11 @@ private void createGfxdSystemProcedures(TransactionController tc, { // void SET_BUCKETS_FOR_LOCAL_EXECUTION(TableName, buckets) - String[] argNames = new String[] { "TABLE_NAME", "BUCKETS", - "RELATION_DESTROY_VERSIONS"}; + String[] argNames = new String[] { "TABLE_NAME", "BUCKETS", "CATALOG_VERSION"}; TypeDescriptor[] argTypes = new TypeDescriptor[] { DataTypeDescriptor.getCatalogType(Types.VARCHAR), DataTypeDescriptor.getCatalogType(Types.VARCHAR), - DataTypeDescriptor.getCatalogType(Types.INTEGER) + DataTypeDescriptor.getCatalogType(Types.BIGINT) }; super.createSystemProcedureOrFunction("SET_BUCKETS_FOR_LOCAL_EXECUTION", sysUUID, argNames, argTypes, 0, 0, RoutineAliasInfo.NO_SQL, null, newlyCreatedRoutines, @@ -1664,6 +1675,20 @@ private void createGfxdSystemProcedures(TransactionController tc, newlyCreatedRoutines, tc, GFXD_SYS_PROC_CLASSNAME, true); } + { + // CREATE_OR_DROP_RESERVOIR_REGION(String reservoirRegionName, + // String resolvedBaseName, Boolean isDrop) + String[] arg_names = new String[] { "RESERVOIR_REGION_NAME", + "RESOLVED_BASE_NAME", "IS_DROP" }; + TypeDescriptor[] arg_types = new TypeDescriptor[] { + DataTypeDescriptor.getCatalogType(Types.LONGVARCHAR), + DataTypeDescriptor.getCatalogType(Types.LONGVARCHAR), + DataTypeDescriptor.getCatalogType(Types.BOOLEAN) }; + super.createSystemProcedureOrFunction("CREATE_OR_DROP_RESERVOIR_REGION", + sysUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.NO_SQL, null, + newlyCreatedRoutines, tc, GFXD_SYS_PROC_CLASSNAME, false); + } + { // REBALANCE_ALL_BUCKETS() super.createSystemProcedureOrFunction("REBALANCE_ALL_BUCKETS", sysUUID, @@ -1725,7 +1750,7 @@ private void createGfxdSystemProcedures(TransactionController tc, TypeDescriptor[] argTypes = new TypeDescriptor[] { DataTypeDescriptor.getBuiltInDataTypeDescriptor( Types.BOOLEAN, false).getCatalogType() }; - super.createSystemProcedureOrFunction("GET_SNAPSHOT_TXID", sysUUID, + super.createSystemProcedureOrFunction("GET_SNAPSHOT_TXID_AND_HOSTURL", sysUUID, argNames, argTypes, 0, 0, RoutineAliasInfo.READS_SQL_DATA, DataTypeDescriptor.getCatalogType(Types.VARCHAR), newlyCreatedRoutines, tc, GFXD_SYS_PROC_CLASSNAME, false); @@ -1733,129 +1758,28 @@ private void createGfxdSystemProcedures(TransactionController tc, } { - // GET_TABLE_METADATA - String[] arg_names = new String[] { "TABLE_NAME", - "TABLE_OBJECT", "BUCKET_COUNT", "PARTITIONING_COLUMNS", - "INDEX_COLUMNS", "BUCKET_TO_SERVER_MAPPING", - "RELATION_DESTROY_VERSION", "PK_COLUMNS" }; - TypeDescriptor[] arg_types = new TypeDescriptor[] { DataTypeDescriptor - .getCatalogType(Types.VARCHAR), - DataTypeDescriptor.getCatalogType(Types.BLOB), - DataTypeDescriptor.getCatalogType(Types.INTEGER), - DataTypeDescriptor.getCatalogType(Types.VARCHAR), - DataTypeDescriptor.getCatalogType(Types.VARCHAR), - DataTypeDescriptor.getCatalogType(Types.CLOB), - DataTypeDescriptor.getCatalogType(Types.INTEGER), - DataTypeDescriptor.getCatalogType(Types.VARCHAR)}; - super.createSystemProcedureOrFunction("GET_TABLE_METADATA", - sysUUID, arg_names, arg_types, 7, 0, RoutineAliasInfo.READS_SQL_DATA, null, - newlyCreatedRoutines, tc, GFXD_SYS_PROC_CLASSNAME, false); - } - - { - // CREATE_SNAPPY_TABLE - String[] arg_names = new String[] { "TABLE_IDENT", - "PROVIDER", "USER_SCHEMA", "SCHEMA_DDL", "MODE", - "OPTIONS", "IS_BUILTIN"}; - TypeDescriptor[] arg_types = new TypeDescriptor[] { - DataTypeDescriptor.getCatalogType(Types.VARCHAR), - DataTypeDescriptor.getCatalogType(Types.VARCHAR), - DataTypeDescriptor.getCatalogType(Types.VARCHAR), - DataTypeDescriptor.getCatalogType(Types.VARCHAR), - DataTypeDescriptor.getCatalogType(Types.BLOB), - DataTypeDescriptor.getCatalogType(Types.BLOB), - DataTypeDescriptor.getCatalogType(Types.BOOLEAN)}; - super.createSystemProcedureOrFunction("CREATE_SNAPPY_TABLE", - sysUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.READS_SQL_DATA, null, - newlyCreatedRoutines, tc, GFXD_SYS_PROC_CLASSNAME, false); - } - - { - // DROP_SNAPPY_TABLE - String[] arg_names = new String[] { "TABLE_IDENT", "IF_EXISTS", "IS_EXTERNAL" }; + // GET_CATALOG_METADATA + String[] arg_names = new String[] { "OPERATION", "ARGS", "RESULT" }; TypeDescriptor[] arg_types = new TypeDescriptor[] { - DataTypeDescriptor.getCatalogType(Types.VARCHAR), - DataTypeDescriptor.getCatalogType(Types.BOOLEAN), - DataTypeDescriptor.getCatalogType(Types.BOOLEAN) }; - super.createSystemProcedureOrFunction("DROP_SNAPPY_TABLE", - sysUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.READS_SQL_DATA, null, - newlyCreatedRoutines, tc, GFXD_SYS_PROC_CLASSNAME, false); - } - - { - // CREATE_SNAPPY_INDEX - String[] arg_names = new String[] { "INDEX_IDENT", - "TABLE_IDENT", "INDEX_COLUMNS", "OPTIONS"}; - TypeDescriptor[] arg_types = new TypeDescriptor[] { - DataTypeDescriptor.getCatalogType(Types.VARCHAR), - DataTypeDescriptor.getCatalogType(Types.VARCHAR), + DataTypeDescriptor.getCatalogType(Types.INTEGER), DataTypeDescriptor.getCatalogType(Types.BLOB), - DataTypeDescriptor.getCatalogType(Types.BLOB)}; - super.createSystemProcedureOrFunction("CREATE_SNAPPY_INDEX", - sysUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.READS_SQL_DATA, null, - newlyCreatedRoutines, tc, GFXD_SYS_PROC_CLASSNAME, false); - } - - { - // DROP_SNAPPY_INDEX - String[] arg_names = new String[] { "INDEX_IDENT", "IF_EXISTS"}; - TypeDescriptor[] arg_types = new TypeDescriptor[] { - DataTypeDescriptor.getCatalogType(Types.VARCHAR), - DataTypeDescriptor.getCatalogType(Types.BOOLEAN)}; - super.createSystemProcedureOrFunction("DROP_SNAPPY_INDEX", - sysUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.READS_SQL_DATA, null, - newlyCreatedRoutines, tc, GFXD_SYS_PROC_CLASSNAME, false); - } - - { - // CREATE_SNAPPY_UDF - String[] arg_names = new String[] { "DB", "FUNCTION_NAME", "CLASS_NAME", "JAR_URI"}; - TypeDescriptor[] arg_types = new TypeDescriptor[] { - DataTypeDescriptor.getCatalogType(Types.VARCHAR), - DataTypeDescriptor.getCatalogType(Types.VARCHAR), - DataTypeDescriptor.getCatalogType(Types.VARCHAR), - DataTypeDescriptor.getCatalogType(Types.VARCHAR)}; - super.createSystemProcedureOrFunction("CREATE_SNAPPY_UDF", - sysUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.READS_SQL_DATA, null, - newlyCreatedRoutines, tc, GFXD_SYS_PROC_CLASSNAME, false); - } - - { - // DROP_SNAPPY_UDF - String[] arg_names = new String[] { "DB", "FUNCTION_NAME"}; - TypeDescriptor[] arg_types = new TypeDescriptor[] { - DataTypeDescriptor.getCatalogType(Types.VARCHAR), - DataTypeDescriptor.getCatalogType(Types.VARCHAR)}; - super.createSystemProcedureOrFunction("DROP_SNAPPY_UDF", - sysUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.READS_SQL_DATA, null, + DataTypeDescriptor.getCatalogType(Types.BLOB) }; + super.createSystemProcedureOrFunction("GET_CATALOG_METADATA", + sysUUID, arg_names, arg_types, 1, 0, RoutineAliasInfo.READS_SQL_DATA, null, newlyCreatedRoutines, tc, GFXD_SYS_PROC_CLASSNAME, false); } { - // ALTER_SNAPPY_TABLE - String[] arg_names = new String[] { "TABLE_IDENT", "IS_ADD_COL", "COL_NAME", "COL_DATATYPE", "COL_IS_NULLABLE"}; + // UPDATE_CATALOG_METADATA + String[] arg_names = new String[] { "OPERATION", "ARGS" }; TypeDescriptor[] arg_types = new TypeDescriptor[] { - DataTypeDescriptor.getCatalogType(Types.VARCHAR), - DataTypeDescriptor.getCatalogType(Types.BOOLEAN), - DataTypeDescriptor.getCatalogType(Types.VARCHAR), - DataTypeDescriptor.getCatalogType(Types.VARCHAR), - DataTypeDescriptor.getCatalogType(Types.BOOLEAN)}; - super.createSystemProcedureOrFunction("ALTER_SNAPPY_TABLE", - sysUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.READS_SQL_DATA, null, - newlyCreatedRoutines, tc, GFXD_SYS_PROC_CLASSNAME, false); - } - - { - // GET_SNAPPY_TABLE_STATS - String[] arg_names = new String[] { "STATS_OBJECT"}; - TypeDescriptor[] arg_types = new TypeDescriptor[] { - DataTypeDescriptor.getCatalogType(Types.BLOB)}; - super.createSystemProcedureOrFunction("GET_SNAPPY_TABLE_STATS", - sysUUID, arg_names, arg_types, 1, 0, RoutineAliasInfo.READS_SQL_DATA, null, + DataTypeDescriptor.getCatalogType(Types.INTEGER), + DataTypeDescriptor.getCatalogType(Types.BLOB) }; + super.createSystemProcedureOrFunction("UPDATE_CATALOG_METADATA", + sysUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.MODIFIES_SQL_DATA, null, newlyCreatedRoutines, tc, GFXD_SYS_PROC_CLASSNAME, false); } - { // GET_JARS -- Smart Connectors will pull all the jars String[] arg_names = new String[] { "JAR_PATHS"}; diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/compile/InsertNode.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/compile/InsertNode.java index 115e9e0bc..8e4e61c90 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/compile/InsertNode.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/compile/InsertNode.java @@ -985,7 +985,7 @@ public QueryInfo computeQueryInfo(QueryInfoContext qic) try { { SelectQueryInfo sInfo = (SelectQueryInfo)computeSubSelectQueryInfo(qic); - InsertQueryInfo insInfo = new InsertQueryInfo(qic, sInfo); + InsertQueryInfo insInfo = new InsertQueryInfo(qic, sInfo, isPutDML); qic.setRootQueryInfo(insInfo); this.accept(insInfo); insInfo.init(); diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/compile/UCode_CharStream.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/compile/UCode_CharStream.java index c0d98c7c5..2829c843c 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/compile/UCode_CharStream.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/compile/UCode_CharStream.java @@ -417,7 +417,8 @@ public String GetImage(int jjmatchedKind) if (jjmatchedKind == SQLParserConstants.STRING // GemStone changes BEGIN -- also removed final from GetImage method - || jjmatchedKind == SQLParserConstants.DELIMITED_IDENTIFIER) { + || jjmatchedKind == SQLParserConstants.DELIMITED_IDENTIFIER + || jjmatchedKind == SQLParserConstants.BACKQUOTED_IDENTIFIER) { // GemStone changes END if (bufpos >= tokenBegin) diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/execute/CreateDiskStoreConstantAction.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/execute/CreateDiskStoreConstantAction.java index ca243f1a7..c9f833d56 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/execute/CreateDiskStoreConstantAction.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/execute/CreateDiskStoreConstantAction.java @@ -28,7 +28,6 @@ import com.gemstone.gemfire.cache.DiskAccessException; import com.gemstone.gemfire.cache.DiskStoreFactory; -import io.snappydata.collection.OpenHashSet; import com.pivotal.gemfirexd.internal.engine.GfxdConstants; import com.pivotal.gemfirexd.internal.engine.Misc; import com.pivotal.gemfirexd.internal.engine.access.GemFireTransaction; @@ -44,6 +43,7 @@ import com.pivotal.gemfirexd.internal.iapi.sql.dictionary.SchemaDescriptor; import com.pivotal.gemfirexd.internal.impl.sql.compile.NumericConstantNode; import com.pivotal.gemfirexd.internal.shared.common.sanity.SanityManager; +import org.eclipse.collections.impl.set.mutable.UnifiedSet; public class CreateDiskStoreConstantAction extends DDLConstantAction { @@ -140,7 +140,7 @@ private static void executeConstantAction(String diskStoreName, int sizes[] = new int[numDirs]; boolean dirCreated[] = new boolean[numDirs]; Arrays.fill(dirCreated, false); - OpenHashSet ht = new OpenHashSet<>(numDirs); + UnifiedSet ht = new UnifiedSet<>(numDirs); String canonicalPath; boolean foundExplicitSize = false; for (int i = 0; i < numDirs; ++i) { diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/execute/CreateIndexConstantAction.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/execute/CreateIndexConstantAction.java index 2e5fe045a..a1f6d878f 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/execute/CreateIndexConstantAction.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/execute/CreateIndexConstantAction.java @@ -1608,7 +1608,7 @@ private void loadIndexConglomerate(ExecRow[] baseRows, .findConglomerate(ContainerKey.valueOf( ContainerHandle.TABLE_SEGMENT, conglomId)); final GemFireContainer indexContainer = conglom.getGemFireContainer(); - final boolean isPutDML = lcc != null && lcc.isSkipConstraintChecks(); + final boolean skipConstraintChecks = lcc != null && lcc.isSkipConstraintChecks(); boolean loadIndex = true; final LocalRegion baseRegion = indexManager.getContainer().getRegion(); @@ -1670,7 +1670,8 @@ private void loadIndexConglomerate(ExecRow[] baseRows, indexManager.insertIntoIndex(null, null, owners[i], event, false, false, rl, baseRowArray[i], null, null, rl.getBucketID(), - indexContainer, null, isPutDML, Index.BOTH, false); + indexContainer, null, skipConstraintChecks, skipConstraintChecks, + Index.BOTH, false); rowCount++; } diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/execute/UpdateResultSet.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/execute/UpdateResultSet.java index 250b6aefb..31f19198a 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/execute/UpdateResultSet.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/execute/UpdateResultSet.java @@ -89,7 +89,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more import com.pivotal.gemfirexd.internal.iapi.types.RowLocation; import com.pivotal.gemfirexd.internal.iapi.util.ReuseFactory; import com.pivotal.gemfirexd.internal.impl.sql.execute.xplain.XPLAINUtil; -import io.snappydata.collection.IntObjectHashMap; +import org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap; /** @@ -315,7 +315,7 @@ public final class UpdateResultSet extends DMLWriteResultSet implements OffHeapR .getGemFireContainer(); if (!this.container.isTemporaryContainer()) { IntObjectHashMap tempRefColUpdtd2DependentCols = - IntObjectHashMap.withExpectedSize(4); + new IntObjectHashMap<>(4); Map refColsImpactedMap = this.getReferencedUpdateCols(tempRefColUpdtd2DependentCols); @@ -386,7 +386,7 @@ private Map getReferencedUpdateCols( if (refKeyColID == modColID) { // onlyRefUpadtedCols.add(refKeyColID); TIntHashSet dependentCols = new TIntHashSet(refKeyCols.length); - tempRefColUpdtd2DependentCols.justPut(refKeyColID, dependentCols); + tempRefColUpdtd2DependentCols.put(refKeyColID, dependentCols); referencedImpactedColsMap.put(refKeyColID, Boolean.TRUE); addCompanionRefColsToMap(refKeyColID, referencedImpactedColsMap, dependentCols); diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/rules/AccumulativeExecutionEngineRule.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/rules/AccumulativeExecutionEngineRule.java index 0140bd4fd..f1cc6e111 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/rules/AccumulativeExecutionEngineRule.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/rules/AccumulativeExecutionEngineRule.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/rules/AnyOneOfExecutionEngineRule.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/rules/AnyOneOfExecutionEngineRule.java index 545ed9ae9..77a506dcf 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/rules/AnyOneOfExecutionEngineRule.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/rules/AnyOneOfExecutionEngineRule.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/rules/ColumnTableExecutionEngineRule.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/rules/ColumnTableExecutionEngineRule.java index fcf547d5f..398ac3d26 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/rules/ColumnTableExecutionEngineRule.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/rules/ColumnTableExecutionEngineRule.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/rules/ExecutionEngineArbiter.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/rules/ExecutionEngineArbiter.java index 57044cb63..1a2cf319d 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/rules/ExecutionEngineArbiter.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/rules/ExecutionEngineArbiter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/rules/ExecutionEngineRule.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/rules/ExecutionEngineRule.java index 34d68b9a2..84942f634 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/rules/ExecutionEngineRule.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/rules/ExecutionEngineRule.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/rules/ExecutionRuleContext.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/rules/ExecutionRuleContext.java index 51f8f328f..effc35cef 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/rules/ExecutionRuleContext.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/rules/ExecutionRuleContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/rules/ReplicatedTableExecutionEngineRule.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/rules/ReplicatedTableExecutionEngineRule.java index 0a4d5b34c..cf7ca9883 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/rules/ReplicatedTableExecutionEngineRule.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/sql/rules/ReplicatedTableExecutionEngineRule.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/store/raw/data/GfxdJarMessage.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/store/raw/data/GfxdJarMessage.java index 6913c6084..3b824a507 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/store/raw/data/GfxdJarMessage.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/store/raw/data/GfxdJarMessage.java @@ -37,7 +37,7 @@ import com.pivotal.gemfirexd.internal.catalog.SystemProcedures; import com.pivotal.gemfirexd.internal.engine.GfxdConstants; import com.pivotal.gemfirexd.internal.engine.GfxdSerializable; -import com.pivotal.gemfirexd.internal.engine.ddl.GfxdDDLPreprocess; +import com.pivotal.gemfirexd.internal.engine.ddl.GfxdDDLPreprocessOrPostProcess; import com.pivotal.gemfirexd.internal.engine.ddl.wan.messages.AbstractGfxdReplayableMessage; import com.pivotal.gemfirexd.internal.engine.distributed.FunctionExecutionException; import com.pivotal.gemfirexd.internal.engine.distributed.utils.GemFireXDUtils; @@ -52,7 +52,7 @@ import com.pivotal.gemfirexd.internal.shared.common.reference.SQLState; public final class GfxdJarMessage extends AbstractGfxdReplayableMessage - implements StorageFile, GfxdDDLPreprocess { + implements StorageFile, GfxdDDLPreprocessOrPostProcess { private static final long serialVersionUID = 8648222850391801895L; @@ -94,6 +94,7 @@ public GfxdJarMessage(String alias, int type, byte[] bytes, this.schemaName = ret[0]; this.sqlName = ret[1]; this.fullName = this.schemaName + '.' + this.sqlName; + assert !(preprocess() && postprocess()); } public void setOldId(long oldId) { @@ -291,6 +292,10 @@ public boolean preprocess() { return true; } + public boolean postprocess() { + return false; + } + /** * {@inheritDoc} */ diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/store/raw/data/GfxdJarResource.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/store/raw/data/GfxdJarResource.java index a2f38fc31..05333dfee 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/store/raw/data/GfxdJarResource.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/impl/store/raw/data/GfxdJarResource.java @@ -35,8 +35,6 @@ import com.gemstone.gemfire.internal.Assert; import com.gemstone.gemfire.internal.InternalDataSerializer; import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; -import com.gemstone.gemfire.internal.cache.NoDataStoreAvailableException; -import com.gemstone.gemfire.internal.i18n.LocalizedStrings; import com.pivotal.gemfirexd.internal.engine.Misc; import com.pivotal.gemfirexd.internal.engine.GfxdConstants; import com.pivotal.gemfirexd.internal.engine.ddl.GfxdDDLRegion.RegionValue; diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/jdbc/AutoloadedDriver.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/jdbc/AutoloadedDriver.java index 5ae1d1fec..bec30ea43 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/jdbc/AutoloadedDriver.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/jdbc/AutoloadedDriver.java @@ -40,7 +40,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/snappy/CallbackFactoryProvider.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/snappy/CallbackFactoryProvider.java index 8f8e694c9..0a9f256d1 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/snappy/CallbackFactoryProvider.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/snappy/CallbackFactoryProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/snappy/ClusterCallbacks.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/snappy/ClusterCallbacks.java index ce8de0a03..0fca0b4ce 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/snappy/ClusterCallbacks.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/snappy/ClusterCallbacks.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/snappy/ColumnBatchKey.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/snappy/ColumnBatchKey.java index 401890f19..c1d7758fd 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/snappy/ColumnBatchKey.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/snappy/ColumnBatchKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/snappy/LeadNodeExecutionContext.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/snappy/LeadNodeExecutionContext.java index b1c50ebc5..c1ecb9289 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/snappy/LeadNodeExecutionContext.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/snappy/LeadNodeExecutionContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/snappy/LeadNodeSmartConnectorOpContext.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/snappy/LeadNodeSmartConnectorOpContext.java deleted file mode 100644 index 1445ca28c..000000000 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/snappy/LeadNodeSmartConnectorOpContext.java +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you - * may not use this file except in compliance with the License. You - * may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. See accompanying - * LICENSE file. - */ - -package com.pivotal.gemfirexd.internal.snappy; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; - -import com.gemstone.gemfire.DataSerializer; -import com.gemstone.gemfire.internal.DataSerializableFixedID; -import com.gemstone.gemfire.internal.shared.Version; -import com.pivotal.gemfirexd.internal.engine.GfxdSerializable; -import com.pivotal.gemfirexd.internal.engine.Misc; -import com.pivotal.gemfirexd.internal.iapi.sql.conn.LanguageConnectionContext; -import com.pivotal.gemfirexd.internal.impl.sql.conn.GenericLanguageConnectionContext; - -/** - * A class that holds parameters for operations to be done do for LeadNodeSmartConnectorOpMsg - */ -public final class LeadNodeSmartConnectorOpContext implements GfxdSerializable { - - public enum OpType { CREATE_TABLE, DROP_TABLE, CREATE_INDEX, DROP_INDEX, CREATE_UDF, DROP_UDF, ALTER_TABLE } - - private OpType type; - - // not all of these members are always used - // these are used based on the OpType - private String tableIdentifier; - private String userSpecifiedJsonSchema; - private String schemaDDL; - private String provider; - private byte[] options; - private byte[] mode; - private Boolean isBuiltIn = true; - private Boolean ifExists = false; - private String indexIdentifier; //set only by index operations - private byte[] indexColumns; //set only by index operations - - private String db; // for udf - private String functionName; // for udf - private String className; // for udf - private String jarURI; // for udf - - private String user; // for security - private String authToken; // for security - - private Boolean addOrDropCol; // for alter table - private String columnName; // for alter table - private String columnDataType; // for alter table - private Boolean columnNullable; // for alter table - - public LeadNodeSmartConnectorOpContext() { - - } - - public LeadNodeSmartConnectorOpContext(OpType type, - String tableIdentifier, - String provider, - String userSpecifiedJsonSchema, - String schemaDDL, - byte[] mode, - byte[] options, - Boolean isBuiltIn, - Boolean ifExists, - String indexIdentifier, - byte[] indexColumns, - String db, - String functionName, - String className, - String jarURI, - Boolean addOrDropCol, - String columnName, - String columnDataType, - Boolean columnNullable) { - this.type = type; - this.tableIdentifier = tableIdentifier; - this.provider = provider; - this.userSpecifiedJsonSchema = userSpecifiedJsonSchema; - this.schemaDDL = schemaDDL; - this.mode = mode; - this.options = options; - this.isBuiltIn = isBuiltIn; - this.ifExists = ifExists; - this.indexIdentifier = indexIdentifier; - this.indexColumns = indexColumns; - this.db = db; - this.functionName = functionName; - this.className = className; - this.jarURI = jarURI; - LanguageConnectionContext lcc = Misc.getLanguageConnectionContext(); - if (lcc != null) { - this.user = ((GenericLanguageConnectionContext)lcc).getUserName(); - this.authToken = ((GenericLanguageConnectionContext)lcc).getAuthToken(); - } - this.addOrDropCol = addOrDropCol; - this.columnName = columnName; - this.columnDataType = columnDataType; - this.columnNullable = columnNullable; - } - - @Override - public byte getGfxdID() { - return LEAD_NODE_CONN_OP_CTX; - } - - @Override - public int getDSFID() { - return DataSerializableFixedID.GFXD_TYPE; - } - - @Override - public void toData(DataOutput out) throws IOException { - DataSerializer.writeObject(type, out); - DataSerializer.writeString(tableIdentifier, out); - DataSerializer.writeString(userSpecifiedJsonSchema, out); - DataSerializer.writeByteArray(indexColumns, out); - DataSerializer.writeString(indexIdentifier, out); - DataSerializer.writeString(schemaDDL, out); - DataSerializer.writeString(provider, out); - DataSerializer.writeByteArray(mode, out); - DataSerializer.writeByteArray(options, out); - DataSerializer.writeBoolean(isBuiltIn, out); - DataSerializer.writeBoolean(ifExists, out); - DataSerializer.writeString(db, out); - DataSerializer.writeString(functionName, out); - DataSerializer.writeString(className, out); - DataSerializer.writeString(jarURI, out); - DataSerializer.writeString(this.user, out); - DataSerializer.writeString(this.authToken, out); - DataSerializer.writeBoolean(addOrDropCol, out); - DataSerializer.writeString(columnName, out); - DataSerializer.writeString(columnDataType, out); - DataSerializer.writeBoolean(columnNullable, out); - } - - @Override - public void fromData(DataInput in) throws IOException, ClassNotFoundException { - this.type = DataSerializer.readObject(in); - this.tableIdentifier = DataSerializer.readString(in); - this.userSpecifiedJsonSchema = DataSerializer.readString(in); - this.indexColumns = DataSerializer.readByteArray(in); - this.indexIdentifier = DataSerializer.readString(in); - this.schemaDDL = DataSerializer.readString(in); - this.provider = DataSerializer.readString(in); - this.mode = DataSerializer.readByteArray(in); - this.options = DataSerializer.readByteArray(in); - this.isBuiltIn = DataSerializer.readBoolean(in); - this.ifExists = DataSerializer.readBoolean(in); - this.db = DataSerializer.readString(in); - this.functionName = DataSerializer.readString(in); - this.className = DataSerializer.readString(in); - this.jarURI = DataSerializer.readString(in); - this.user = DataSerializer.readString(in); - this.authToken = DataSerializer.readString(in); - this.addOrDropCol = DataSerializer.readBoolean(in); - this.columnName = DataSerializer.readString(in); - this.columnDataType = DataSerializer.readString(in); - this.columnNullable = DataSerializer.readBoolean(in); - } - - @Override - public Version[] getSerializationVersions() { - return new Version[0]; - } - - public String getTableIdentifier() { - return tableIdentifier; - } - - public String getProvider() { - return provider; - } - - public byte[] getOptions() { - return options; - } - - public OpType getType() { - return type; - } - - public String getUserSpecifiedJsonSchema() { - return userSpecifiedJsonSchema; - } - - public String getSchemaDDL() { - return schemaDDL; - } - - public byte[] getMode() { - return mode; - } - - public Boolean getIsBuiltIn() { - return isBuiltIn; - } - - public Boolean getIfExists() { - return ifExists; - } - - public String getIndexIdentifier() { - return indexIdentifier; - } - - public byte[] getIndexColumns() { return indexColumns; } - - public String getDb() { return db;} - - public String getFunctionName() { return functionName; } - - public String getClassName() { return className; } - - public String getjarURI() { return jarURI; } - - public String getUserName() { return this.user; } - - public String getAuthToken() { return this.authToken; } - - public Boolean getAddOrDropCol() { return addOrDropCol; } - - public String getColumnName() { return columnName; } - - public String getColumnDataType() { return columnDataType; } - - public Boolean getColumnNullable() { return columnNullable; } - -} diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/snappy/SparkSQLExecute.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/snappy/SparkSQLExecute.java index df00ccc64..8c61f7433 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/snappy/SparkSQLExecute.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/snappy/SparkSQLExecute.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/jdbc/EmbeddedDriver.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/jdbc/EmbeddedDriver.java index 2b580a52a..e7098478d 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/jdbc/EmbeddedDriver.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/jdbc/EmbeddedDriver.java @@ -40,7 +40,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/snappy/ComplexTypeSerializer.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/snappy/ComplexTypeSerializer.java index a25830f5b..ee7b78a26 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/snappy/ComplexTypeSerializer.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/snappy/ComplexTypeSerializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/tools/sizer/ObjectSizer.java b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/tools/sizer/ObjectSizer.java index de91c15fa..c42926219 100644 --- a/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/tools/sizer/ObjectSizer.java +++ b/gemfirexd/core/src/main/java/com/pivotal/gemfirexd/tools/sizer/ObjectSizer.java @@ -36,7 +36,6 @@ import java.util.TreeSet; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.LinkedBlockingDeque; -import java.util.regex.Pattern; import com.gemstone.gemfire.LogWriter; import com.gemstone.gemfire.cache.PartitionAttributesFactory; @@ -66,7 +65,6 @@ import com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl.Chunk; import com.gemstone.gemfire.internal.offheap.annotations.Released; import com.gemstone.gemfire.internal.offheap.annotations.Retained; -import com.gemstone.gemfire.internal.shared.SystemProperties; import com.gemstone.gemfire.internal.size.ReflectionSingleObjectSizer; import com.pivotal.gemfirexd.Constants; import com.pivotal.gemfirexd.Constants.QueryHints.SizerHints; @@ -639,7 +637,7 @@ private void iterateRegionEntries(final GemFireContainer c, long valInOffheapCount = 0; final boolean agentAttached = SIZE_OF_UTIL.isAgentAttached(); boolean isValueTypeEvaluated = false; - final boolean isColumnTable = isColumnTable(c.getQualifiedTableName()); + final boolean isColumnTable = c.isColumnStore(); int numColumnsInColumnTable = -1; long dvdArraySize = 0; boolean gatewayEntries = false; @@ -843,7 +841,7 @@ else if (!isSingleEntrySizeComputed) { } else if (valClass == byte[][].class) { - if (isColumnTable(c.getQualifiedTableName())) { + if (c.isColumnStore()) { columnRowCount += getRowCountFromColumnTable(c, (byte[][])value); } @@ -995,13 +993,6 @@ else if (GatewaySenderEventImpl.class.isAssignableFrom(valClass)) { } - private static final Pattern columnTableRegex = - Pattern.compile(".*" + SystemProperties.SHADOW_SCHEMA_NAME + "(.*)" + - SystemProperties.SHADOW_TABLE_SUFFIX); - private Boolean isColumnTable(String fullyQualifiedTable) { - return columnTableRegex.matcher(fullyQualifiedTable).matches(); - } - private int getRowCountFromColumnTable(GemFireContainer c, byte[][] value) throws StandardException { int rowCount = 0; RowFormatter rf = c.getRowFormatter(value); diff --git a/gemfirexd/core/src/main/java/io/snappydata/jdbc/AutoloadedDriver.java b/gemfirexd/core/src/main/java/io/snappydata/jdbc/AutoloadedDriver.java index d6d64de04..280861d49 100644 --- a/gemfirexd/core/src/main/java/io/snappydata/jdbc/AutoloadedDriver.java +++ b/gemfirexd/core/src/main/java/io/snappydata/jdbc/AutoloadedDriver.java @@ -40,7 +40,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/io/snappydata/jdbc/EmbeddedDriver.java b/gemfirexd/core/src/main/java/io/snappydata/jdbc/EmbeddedDriver.java index 4a94b0f8d..3e2a90f58 100644 --- a/gemfirexd/core/src/main/java/io/snappydata/jdbc/EmbeddedDriver.java +++ b/gemfirexd/core/src/main/java/io/snappydata/jdbc/EmbeddedDriver.java @@ -40,7 +40,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/io/snappydata/thrift/server/ClientTracker.java b/gemfirexd/core/src/main/java/io/snappydata/thrift/server/ClientTracker.java index 7252c7ab7..a8dfb07d8 100644 --- a/gemfirexd/core/src/main/java/io/snappydata/thrift/server/ClientTracker.java +++ b/gemfirexd/core/src/main/java/io/snappydata/thrift/server/ClientTracker.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/io/snappydata/thrift/server/ConnectionHolder.java b/gemfirexd/core/src/main/java/io/snappydata/thrift/server/ConnectionHolder.java index 48551e628..8f6f8d7b1 100644 --- a/gemfirexd/core/src/main/java/io/snappydata/thrift/server/ConnectionHolder.java +++ b/gemfirexd/core/src/main/java/io/snappydata/thrift/server/ConnectionHolder.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/io/snappydata/thrift/server/LocatorServiceImpl.java b/gemfirexd/core/src/main/java/io/snappydata/thrift/server/LocatorServiceImpl.java index bed2529c3..a237bde93 100644 --- a/gemfirexd/core/src/main/java/io/snappydata/thrift/server/LocatorServiceImpl.java +++ b/gemfirexd/core/src/main/java/io/snappydata/thrift/server/LocatorServiceImpl.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/io/snappydata/thrift/server/SnappyDataServiceImpl.java b/gemfirexd/core/src/main/java/io/snappydata/thrift/server/SnappyDataServiceImpl.java index a4819da6e..d6731572d 100644 --- a/gemfirexd/core/src/main/java/io/snappydata/thrift/server/SnappyDataServiceImpl.java +++ b/gemfirexd/core/src/main/java/io/snappydata/thrift/server/SnappyDataServiceImpl.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -60,10 +60,10 @@ import com.gemstone.gnu.trove.THashMap; import com.gemstone.gnu.trove.TObjectProcedure; import com.pivotal.gemfirexd.Attribute; +import com.pivotal.gemfirexd.internal.catalog.ExternalCatalog; import com.pivotal.gemfirexd.internal.engine.GfxdConstants; import com.pivotal.gemfirexd.internal.engine.Misc; import com.pivotal.gemfirexd.internal.engine.ddl.catalog.GfxdSystemProcedures; -import com.pivotal.gemfirexd.internal.engine.distributed.GfxdDistributionAdvisor; import com.pivotal.gemfirexd.internal.engine.distributed.utils.GemFireXDUtils; import com.pivotal.gemfirexd.internal.engine.sql.conn.GfxdHeapThresholdListener; import com.pivotal.gemfirexd.internal.engine.store.GemFireStore; @@ -1619,8 +1619,8 @@ private StatementAttrs applyMergeAttributes(StatementAttrs source, if (source.isSetRetainBucketIds() && !target.isSetRetainBucketIds()) { target.setRetainBucketIds(source.isRetainBucketIds()); } - if (source.isSetMetadataVersion() && !target.isSetMetadataVersion()) { - target.setMetadataVersion(source.getMetadataVersion()); + if (source.isSetCatalogVersion() && !target.isSetCatalogVersion()) { + target.setCatalogVersion(source.getCatalogVersion()); } if (source.isSetSnapshotTransactionId() && !target.isSetSnapshotTransactionId()) { target.setSnapshotTransactionId(source.getSnapshotTransactionId()); @@ -1647,14 +1647,14 @@ private StatementAttrs applyMergeAttributes(StatementAttrs source, target.getBucketIdsTable(), target.getBucketIds(), target.isRetainBucketIds(), conn.getLanguageConnectionContext()); } - if (target.isSetMetadataVersion()) { - final GfxdDistributionAdvisor.GfxdProfile profile = GemFireXDUtils. - getGfxdProfile(Misc.getMyId()); - final int actualVersion = profile.getRelationDestroyVersion(); - final int metadataVersion = target.getMetadataVersion(); - if (metadataVersion != -1 && actualVersion != metadataVersion) { + if (target.isSetCatalogVersion()) { + final ExternalCatalog catalog = Misc.getMemStore().getExistingExternalCatalog(); + final long actualVersion = catalog.getCatalogSchemaVersion(); + final long catalogVersion = target.getCatalogVersion(); + if (catalogVersion != -1 && actualVersion != catalogVersion) { throw Util.generateCsSQLException( - SQLState.SNAPPY_RELATION_DESTROY_VERSION_MISMATCH); + SQLState.SNAPPY_CATALOG_SCHEMA_VERSION_MISMATCH, + actualVersion, catalogVersion); } } if (target.isSetSnapshotTransactionId()) { diff --git a/gemfirexd/core/src/main/java/io/snappydata/thrift/server/SnappyTSSLServerSocket.java b/gemfirexd/core/src/main/java/io/snappydata/thrift/server/SnappyTSSLServerSocket.java index 4881e0de3..007040cf7 100644 --- a/gemfirexd/core/src/main/java/io/snappydata/thrift/server/SnappyTSSLServerSocket.java +++ b/gemfirexd/core/src/main/java/io/snappydata/thrift/server/SnappyTSSLServerSocket.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/io/snappydata/thrift/server/SnappyTSSLServerSocketFactory.java b/gemfirexd/core/src/main/java/io/snappydata/thrift/server/SnappyTSSLServerSocketFactory.java index b00a19a88..d9ce3f10b 100644 --- a/gemfirexd/core/src/main/java/io/snappydata/thrift/server/SnappyTSSLServerSocketFactory.java +++ b/gemfirexd/core/src/main/java/io/snappydata/thrift/server/SnappyTSSLServerSocketFactory.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/io/snappydata/thrift/server/SnappyTServerSocket.java b/gemfirexd/core/src/main/java/io/snappydata/thrift/server/SnappyTServerSocket.java index f845c7143..3ab67c7ff 100644 --- a/gemfirexd/core/src/main/java/io/snappydata/thrift/server/SnappyTServerSocket.java +++ b/gemfirexd/core/src/main/java/io/snappydata/thrift/server/SnappyTServerSocket.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/io/snappydata/thrift/server/SnappyThriftServer.java b/gemfirexd/core/src/main/java/io/snappydata/thrift/server/SnappyThriftServer.java index da61bc7c9..261f0b850 100644 --- a/gemfirexd/core/src/main/java/io/snappydata/thrift/server/SnappyThriftServer.java +++ b/gemfirexd/core/src/main/java/io/snappydata/thrift/server/SnappyThriftServer.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/io/snappydata/thrift/server/SnappyThriftServerSelector.java b/gemfirexd/core/src/main/java/io/snappydata/thrift/server/SnappyThriftServerSelector.java index 5b39c3f1a..67447f9b7 100644 --- a/gemfirexd/core/src/main/java/io/snappydata/thrift/server/SnappyThriftServerSelector.java +++ b/gemfirexd/core/src/main/java/io/snappydata/thrift/server/SnappyThriftServerSelector.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/java/io/snappydata/thrift/server/SnappyThriftServerThreadPool.java b/gemfirexd/core/src/main/java/io/snappydata/thrift/server/SnappyThriftServerThreadPool.java index 74933c52d..bf0cb8f96 100644 --- a/gemfirexd/core/src/main/java/io/snappydata/thrift/server/SnappyThriftServerThreadPool.java +++ b/gemfirexd/core/src/main/java/io/snappydata/thrift/server/SnappyThriftServerThreadPool.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/core/src/main/javacc/com/pivotal/gemfirexd/internal/impl/sql/compile/sqlgrammar.jj b/gemfirexd/core/src/main/javacc/com/pivotal/gemfirexd/internal/impl/sql/compile/sqlgrammar.jj index 0557d2120..27aaca493 100644 --- a/gemfirexd/core/src/main/javacc/com/pivotal/gemfirexd/internal/impl/sql/compile/sqlgrammar.jj +++ b/gemfirexd/core/src/main/javacc/com/pivotal/gemfirexd/internal/impl/sql/compile/sqlgrammar.jj @@ -311,6 +311,7 @@ public class SQLParser static final String SINGLEQUOTES = "\'\'"; static final String DOUBLEQUOTES = "\"\""; + static final String DOUBLEBACKTICK = "``"; // GemStone changes BEGIN static final String DEFAULT_INDEX_TYPE = GfxdConstants.LOCAL_SORTEDMAP_INDEX_TYPE; // "BTREE"; @@ -733,7 +734,7 @@ public class SQLParser * characters of a string (quotes enclosing string), need to adjust here accordingly. * index = result.indexOf(quotes, 1); */ - index = result.indexOf(quotes, 0); + index = result.indexOf(quotes); /* Replace each occurrence with a single quote and begin the * search for the next occurrence from where we left off. @@ -744,7 +745,7 @@ public class SQLParser /*originally * result = result.substring(0, index + 1) + result.substring(index + 2); */ - result = result.substring(0, index + 0) + result.substring(index + 1); + result = result.substring(0, index) + result.substring(index + 1); //GemStone changes END index = result.indexOf(quotes, index + 1); @@ -767,11 +768,16 @@ public class SQLParser ** Post process delimited identifiers to eliminate leading and ** trailing " and convert all occurrences of "" to ". */ - private static String normalizeDelimitedID(String str) + private static String normalizeDelimitedID(String str, boolean backTickDelim) { - str = compressQuotes(str, DOUBLEQUOTES); - return str; + str = compressQuotes(str, backTickDelim ? DOUBLEBACKTICK : DOUBLEQUOTES); + // All identifiers are case-insensitive in snappy-store. + // Case-sensitivity only depends on Spark session setting during query execution + // and not for storage and will be determined by Spark-side catalog if required. + return Misc.getMemStoreBooting().isSnappyStore() + ? StringUtil.SQLToUpperCase(str) : str; } + private static boolean isDATETIME(int val) { if (val == DATE || val == TIME || val == TIMESTAMP) @@ -16304,7 +16310,7 @@ dropSchemaStatement() throws StandardException : } { // GemStone changes BEGIN - + ( | ) { CompilerContext cc = getCompilerContext(); cc.markAsDDLForSnappyUse(true); @@ -17704,7 +17710,7 @@ delimitedIdentifier() : str = tok.image; //originally str = tok.image.substring(1, tok.image.length() -1); //GemStone changes END - str = normalizeDelimitedID( str ); + str = normalizeDelimitedID(str, tok.kind == BACKQUOTED_IDENTIFIER); // Remember whether last token was a delimited identifier nextToLastTokenDelimitedIdentifier = lastTokenDelimitedIdentifier; lastTokenDelimitedIdentifier = Boolean.TRUE; diff --git a/gemfirexd/core/src/main/resources/com/pivotal/gemfirexd/internal/loc/messages.xml b/gemfirexd/core/src/main/resources/com/pivotal/gemfirexd/internal/loc/messages.xml index 2c4b05704..e9d3679c5 100644 --- a/gemfirexd/core/src/main/resources/com/pivotal/gemfirexd/internal/loc/messages.xml +++ b/gemfirexd/core/src/main/resources/com/pivotal/gemfirexd/internal/loc/messages.xml @@ -3864,6 +3864,12 @@ Guide. Exception occurred in creating row encoder for '{0}'. name + + X0Z39 + Table schema changed due to DROP/CREATE/ALTER operation (current version = {0}, passed = {1}. Please retry the operation. + clusterVersion + connectorVersion + @@ -4557,10 +4563,6 @@ ln=lower-case two-letter ISO-639 language code, CO=upper-case two-letter ISO-316 XCL56.T The statement has been cancelled due to a user request. - - XCL57 - Table schema changed(due to DROP/CREATE/ALTER operation). Please retry the query - diff --git a/gemfirexd/prebuild/build.gradle b/gemfirexd/prebuild/build.gradle index 8bcfd1c5a..4cbfe52fe 100644 --- a/gemfirexd/prebuild/build.gradle +++ b/gemfirexd/prebuild/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/prebuild/src/main/java/org/apache/derbyBuild/ODBCMetadataGenerator.java b/gemfirexd/prebuild/src/main/java/org/apache/derbyBuild/ODBCMetadataGenerator.java index dd0ab2799..745f97597 100644 --- a/gemfirexd/prebuild/src/main/java/org/apache/derbyBuild/ODBCMetadataGenerator.java +++ b/gemfirexd/prebuild/src/main/java/org/apache/derbyBuild/ODBCMetadataGenerator.java @@ -40,7 +40,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -919,7 +919,7 @@ private void addHelperColsToSubquery(String queryName, if (queryName.equals("getColumns")) { subqueryText.insert(insertPos, - getFragment(unionIndex < 2 ? "GET_COLS_HELPER_COLS" : "GET_COLS_HELPER_COLS2")); + getFragment("GET_COLS_HELPER_COLS" + unionIndex)); } else if (queryName.startsWith("getBestRowIdentifier")) { subqueryText.insert(insertPos, diff --git a/gemfirexd/prebuild/src/main/resources/com/pivotal/gemfirexd/internal/impl/jdbc/metadata.properties b/gemfirexd/prebuild/src/main/resources/com/pivotal/gemfirexd/internal/impl/jdbc/metadata.properties index 9a71b4d73..8cd53d457 100644 --- a/gemfirexd/prebuild/src/main/resources/com/pivotal/gemfirexd/internal/impl/jdbc/metadata.properties +++ b/gemfirexd/prebuild/src/main/resources/com/pivotal/gemfirexd/internal/impl/jdbc/metadata.properties @@ -35,7 +35,7 @@ # # Changes for SnappyData distributed computational and data platform. # -# Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. +# Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you # may not use this file except in compliance with the License. You @@ -375,8 +375,8 @@ ORDER BY PROCEDURE_SCHEM, PROCEDURE_NAME, SPECIFIC_NAME, METHOD_ID, PARAMETER_ID # so we wrap the values in a select to name it. # GemStone change: added 'COLUMN TABLE', 'EXTERNAL TABLE' and other non-store table types below getTableTypes=\ - SELECT CAST (RTRIM(TABLE_TYPE) AS VARCHAR(12)) AS TABLE_TYPE \ - FROM (VALUES 'SYNONYM', 'SYSTEM TABLE', 'ROW TABLE', 'VIEW', 'COLUMN TABLE', \ + SELECT CAST (RTRIM(TABLE_TYPE) AS VARCHAR(16)) AS TABLE_TYPE \ + FROM (VALUES 'SYNONYM', 'SYSTEM TABLE', 'TABLE', 'ROW TABLE', 'VIEW', 'COLUMN TABLE', \ 'EXTERNAL TABLE', 'STREAM TABLE', 'SAMPLE TABLE', 'TOPK TABLE', 'VIRTUAL TABLE') \ TABLETYPES(TABLE_TYPE) \ ORDER BY TABLE_TYPE diff --git a/gemfirexd/prebuild/src/main/resources/org/apache/derbyBuild/odbcgen_fragments.properties b/gemfirexd/prebuild/src/main/resources/org/apache/derbyBuild/odbcgen_fragments.properties index 1db6a7f38..09787abae 100644 --- a/gemfirexd/prebuild/src/main/resources/org/apache/derbyBuild/odbcgen_fragments.properties +++ b/gemfirexd/prebuild/src/main/resources/org/apache/derbyBuild/odbcgen_fragments.properties @@ -219,10 +219,14 @@ CAST (NULL AS SMALLINT) AS INTERVAL_PRECISION # addHelperColsToSubquery method in the ODBC meta- # data generator class for more details. # -GET_COLS_HELPER_COLS=, \ +GET_COLS_HELPER_COLS0=, \ +\\\n C.COLUMNDATATYPE.getMaximumWidthInBytes() AS COL_MAX_WIDTH_IN_BYTES +GET_COLS_HELPER_COLS1=, \ \\\n C.COLUMNDATATYPE.getMaximumWidthInBytes() AS COL_MAX_WIDTH_IN_BYTES GET_COLS_HELPER_COLS2=, \ \\\n MAXWIDTH AS COL_MAX_WIDTH_IN_BYTES +GET_COLS_HELPER_COLS3=, \ +\\\n DISPLAYWIDTH AS COL_MAX_WIDTH_IN_BYTES # ---------- # diff --git a/gemfirexd/shared/build.gradle b/gemfirexd/shared/build.gradle index 30bfe1343..6708b5f25 100644 --- a/gemfirexd/shared/build.gradle +++ b/gemfirexd/shared/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -18,7 +18,7 @@ dependencies { compileOnly "org.apache.thrift:libthrift:${thriftVersion}" compile "net.java.dev.jna:jna:${jnaVersion}" - compile 'commons-io:commons-io:2.5' + compile "commons-io:commons-io:${commonsIoVersion}" compile project(subprojectBase + 'gemfire-shared') compile project(subprojectBase + 'gemfire-trove') @@ -30,9 +30,9 @@ ext { // Creates the version properties file and writes it to the resources dir task createVersionPropertiesFile(dependsOn: 'processResources') { - def propertiesDir = file("${buildDir}/resources/main/com/pivotal/gemfirexd/internal") + def propertiesDir = file("${sourceSets.main.java.outputDir}/com/pivotal/gemfirexd/internal") outputs.file "${propertiesDir}/GemFireXDVersion.properties" - inputs.dir compileJava.destinationDir + inputs.file "${rootProject.projectDir}/build.gradle" if (rootProject.hasProperty('snappydata.enterprise')) { isEnterprise = 'true' } diff --git a/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/iapi/reference/Attribute.java b/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/iapi/reference/Attribute.java index 3e57c17ca..14f110bea 100644 --- a/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/iapi/reference/Attribute.java +++ b/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/iapi/reference/Attribute.java @@ -331,7 +331,7 @@ public interface Attribute { * These 2 attributes can be sent through jdbc url directly (supported way) or * as JVM properties with the following prefix (undocumented way). DERBY-1275 * - String CLIENT_JVM_PROPERTY_PREFIX = "gemfirexd.client."; + String CLIENT_JVM_PROPERTY_PREFIX = "snappydata.client."; */ // GemStone changes END diff --git a/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/AbstractClientResolver.java b/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/AbstractClientResolver.java index 503bfdff4..5decb800c 100644 --- a/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/AbstractClientResolver.java +++ b/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/AbstractClientResolver.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/ClientColumnResolver.java b/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/ClientColumnResolver.java index 81f8e127c..27cf6822c 100644 --- a/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/ClientColumnResolver.java +++ b/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/ClientColumnResolver.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/ClientListResolver.java b/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/ClientListResolver.java index 6fb024ea6..2315866a0 100644 --- a/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/ClientListResolver.java +++ b/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/ClientListResolver.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/ClientRangeResolver.java b/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/ClientRangeResolver.java index 475fbeab1..d470db833 100644 --- a/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/ClientRangeResolver.java +++ b/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/ClientRangeResolver.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/ResolverUtils.java b/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/ResolverUtils.java index 34e56f4d9..9e73098c6 100644 --- a/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/ResolverUtils.java +++ b/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/ResolverUtils.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/SingleHopInformation.java b/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/SingleHopInformation.java index 8be0085ba..2c8c12b85 100644 --- a/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/SingleHopInformation.java +++ b/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/SingleHopInformation.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/reference/JDBC40Translation.java b/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/reference/JDBC40Translation.java index 17979be3d..8612c9154 100644 --- a/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/reference/JDBC40Translation.java +++ b/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/reference/JDBC40Translation.java @@ -40,7 +40,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/reference/SQLState.java b/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/reference/SQLState.java index cd90e820c..853f9d1c5 100644 --- a/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/reference/SQLState.java +++ b/gemfirexd/shared/src/main/java/com/pivotal/gemfirexd/internal/shared/common/reference/SQLState.java @@ -1442,6 +1442,7 @@ public interface SQLState { String UNEXPECTED_EXCEPTION_FOR_PARTITION_RESOLVER = "X0Z36.S"; String UNEXPECTED_EXCEPTION_FOR_ROW_ENCODER = "X0Z37.S"; String ROW_LEVEL_SECURITY_ENABLED = "X0Z38.S"; + String SNAPPY_CATALOG_SCHEMA_VERSION_MISMATCH = "X0Z39"; // GemStone changes END // TEMPORARY EXECUTION RESTRICTIONS @@ -1516,7 +1517,6 @@ public interface SQLState { // GemStone changes BEGIN String LANG_STATEMENT_CANCELLED_ON_LOW_MEMORY = "XCL54.T"; String LANG_STATEMENT_CANCELLED_ON_USER_REQUEST = "XCL56.T"; - String SNAPPY_RELATION_DESTROY_VERSION_MISMATCH = "XCL57"; // GemStone changes END /* diff --git a/gemfirexd/shared/src/main/java/io/snappydata/ResultSetWithNull.java b/gemfirexd/shared/src/main/java/io/snappydata/ResultSetWithNull.java index 0ac1eaba5..54c7813b7 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/ResultSetWithNull.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/ResultSetWithNull.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/BlobChunk.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/BlobChunk.java index b47d66047..8579507e4 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/BlobChunk.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/BlobChunk.java @@ -7,7 +7,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/BucketOwners.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/BucketOwners.java new file mode 100644 index 000000000..3b3671e95 --- /dev/null +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/BucketOwners.java @@ -0,0 +1,657 @@ +/** + * Autogenerated by Thrift Compiler (0.9.3) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package io.snappydata.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-10") +public class BucketOwners implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("BucketOwners"); + + private static final org.apache.thrift.protocol.TField BUCKET_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("bucketId", org.apache.thrift.protocol.TType.I32, (short)1); + private static final org.apache.thrift.protocol.TField PRIMARY_FIELD_DESC = new org.apache.thrift.protocol.TField("primary", org.apache.thrift.protocol.TType.STRING, (short)2); + private static final org.apache.thrift.protocol.TField SECONDARIES_FIELD_DESC = new org.apache.thrift.protocol.TField("secondaries", org.apache.thrift.protocol.TType.LIST, (short)3); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new BucketOwnersStandardSchemeFactory()); + schemes.put(TupleScheme.class, new BucketOwnersTupleSchemeFactory()); + } + + public int bucketId; // required + public String primary; // optional + public List secondaries; // optional + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + BUCKET_ID((short)1, "bucketId"), + PRIMARY((short)2, "primary"), + SECONDARIES((short)3, "secondaries"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // BUCKET_ID + return BUCKET_ID; + case 2: // PRIMARY + return PRIMARY; + case 3: // SECONDARIES + return SECONDARIES; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __BUCKETID_ISSET_ID = 0; + private byte __isset_bitfield = 0; + private static final _Fields optionals[] = {_Fields.PRIMARY,_Fields.SECONDARIES}; + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.BUCKET_ID, new org.apache.thrift.meta_data.FieldMetaData("bucketId", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); + tmpMap.put(_Fields.PRIMARY, new org.apache.thrift.meta_data.FieldMetaData("primary", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.SECONDARIES, new org.apache.thrift.meta_data.FieldMetaData("secondaries", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(BucketOwners.class, metaDataMap); + } + + public BucketOwners() { + } + + public BucketOwners( + int bucketId) + { + this(); + this.bucketId = bucketId; + setBucketIdIsSet(true); + } + + /** + * Performs a deep copy on other. + */ + public BucketOwners(BucketOwners other) { + __isset_bitfield = other.__isset_bitfield; + this.bucketId = other.bucketId; + if (other.isSetPrimary()) { + this.primary = other.primary; + } + if (other.isSetSecondaries()) { + List __this__secondaries = new ArrayList(other.secondaries); + this.secondaries = __this__secondaries; + } + } + + public BucketOwners deepCopy() { + return new BucketOwners(this); + } + + @Override + public void clear() { + setBucketIdIsSet(false); + this.bucketId = 0; + this.primary = null; + this.secondaries = null; + } + + public int getBucketId() { + return this.bucketId; + } + + public BucketOwners setBucketId(int bucketId) { + this.bucketId = bucketId; + setBucketIdIsSet(true); + return this; + } + + public void unsetBucketId() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __BUCKETID_ISSET_ID); + } + + /** Returns true if field bucketId is set (has been assigned a value) and false otherwise */ + public boolean isSetBucketId() { + return EncodingUtils.testBit(__isset_bitfield, __BUCKETID_ISSET_ID); + } + + public void setBucketIdIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __BUCKETID_ISSET_ID, value); + } + + public String getPrimary() { + return this.primary; + } + + public BucketOwners setPrimary(String primary) { + this.primary = primary; + return this; + } + + public void unsetPrimary() { + this.primary = null; + } + + /** Returns true if field primary is set (has been assigned a value) and false otherwise */ + public boolean isSetPrimary() { + return this.primary != null; + } + + public void setPrimaryIsSet(boolean value) { + if (!value) { + this.primary = null; + } + } + + public int getSecondariesSize() { + return (this.secondaries == null) ? 0 : this.secondaries.size(); + } + + public java.util.Iterator getSecondariesIterator() { + return (this.secondaries == null) ? null : this.secondaries.iterator(); + } + + public void addToSecondaries(String elem) { + if (this.secondaries == null) { + this.secondaries = new ArrayList(); + } + this.secondaries.add(elem); + } + + public List getSecondaries() { + return this.secondaries; + } + + public BucketOwners setSecondaries(List secondaries) { + this.secondaries = secondaries; + return this; + } + + public void unsetSecondaries() { + this.secondaries = null; + } + + /** Returns true if field secondaries is set (has been assigned a value) and false otherwise */ + public boolean isSetSecondaries() { + return this.secondaries != null; + } + + public void setSecondariesIsSet(boolean value) { + if (!value) { + this.secondaries = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case BUCKET_ID: + if (value == null) { + unsetBucketId(); + } else { + setBucketId((Integer)value); + } + break; + + case PRIMARY: + if (value == null) { + unsetPrimary(); + } else { + setPrimary((String)value); + } + break; + + case SECONDARIES: + if (value == null) { + unsetSecondaries(); + } else { + setSecondaries((List)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case BUCKET_ID: + return getBucketId(); + + case PRIMARY: + return getPrimary(); + + case SECONDARIES: + return getSecondaries(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case BUCKET_ID: + return isSetBucketId(); + case PRIMARY: + return isSetPrimary(); + case SECONDARIES: + return isSetSecondaries(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof BucketOwners) + return this.equals((BucketOwners)that); + return false; + } + + public boolean equals(BucketOwners that) { + if (that == null) + return false; + + boolean this_present_bucketId = true; + boolean that_present_bucketId = true; + if (this_present_bucketId || that_present_bucketId) { + if (!(this_present_bucketId && that_present_bucketId)) + return false; + if (this.bucketId != that.bucketId) + return false; + } + + boolean this_present_primary = true && this.isSetPrimary(); + boolean that_present_primary = true && that.isSetPrimary(); + if (this_present_primary || that_present_primary) { + if (!(this_present_primary && that_present_primary)) + return false; + if (!this.primary.equals(that.primary)) + return false; + } + + boolean this_present_secondaries = true && this.isSetSecondaries(); + boolean that_present_secondaries = true && that.isSetSecondaries(); + if (this_present_secondaries || that_present_secondaries) { + if (!(this_present_secondaries && that_present_secondaries)) + return false; + if (!this.secondaries.equals(that.secondaries)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_bucketId = true; + list.add(present_bucketId); + if (present_bucketId) + list.add(bucketId); + + boolean present_primary = true && (isSetPrimary()); + list.add(present_primary); + if (present_primary) + list.add(primary); + + boolean present_secondaries = true && (isSetSecondaries()); + list.add(present_secondaries); + if (present_secondaries) + list.add(secondaries); + + return list.hashCode(); + } + + @Override + public int compareTo(BucketOwners other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetBucketId()).compareTo(other.isSetBucketId()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetBucketId()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.bucketId, other.bucketId); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetPrimary()).compareTo(other.isSetPrimary()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetPrimary()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.primary, other.primary); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetSecondaries()).compareTo(other.isSetSecondaries()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSecondaries()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.secondaries, other.secondaries); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("BucketOwners("); + boolean first = true; + + sb.append("bucketId:"); + sb.append(this.bucketId); + first = false; + if (isSetPrimary()) { + if (!first) sb.append(", "); + sb.append("primary:"); + if (this.primary == null) { + sb.append("null"); + } else { + sb.append(this.primary); + } + first = false; + } + if (isSetSecondaries()) { + if (!first) sb.append(", "); + sb.append("secondaries:"); + if (this.secondaries == null) { + sb.append("null"); + } else { + sb.append(this.secondaries); + } + first = false; + } + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // alas, we cannot check 'bucketId' because it's a primitive and you chose the non-beans generator. + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bitfield = 0; + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class BucketOwnersStandardSchemeFactory implements SchemeFactory { + public BucketOwnersStandardScheme getScheme() { + return new BucketOwnersStandardScheme(); + } + } + + private static class BucketOwnersStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, BucketOwners struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // BUCKET_ID + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.bucketId = iprot.readI32(); + struct.setBucketIdIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // PRIMARY + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.primary = iprot.readString(); + struct.setPrimaryIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // SECONDARIES + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list270 = iprot.readListBegin(); + struct.secondaries = new ArrayList(_list270.size); + String _elem271; + for (int _i272 = 0; _i272 < _list270.size; ++_i272) + { + _elem271 = iprot.readString(); + struct.secondaries.add(_elem271); + } + iprot.readListEnd(); + } + struct.setSecondariesIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + if (!struct.isSetBucketId()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'bucketId' was not found in serialized data! Struct: " + toString()); + } + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, BucketOwners struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + oprot.writeFieldBegin(BUCKET_ID_FIELD_DESC); + oprot.writeI32(struct.bucketId); + oprot.writeFieldEnd(); + if (struct.primary != null) { + if (struct.isSetPrimary()) { + oprot.writeFieldBegin(PRIMARY_FIELD_DESC); + oprot.writeString(struct.primary); + oprot.writeFieldEnd(); + } + } + if (struct.secondaries != null) { + if (struct.isSetSecondaries()) { + oprot.writeFieldBegin(SECONDARIES_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.secondaries.size())); + for (String _iter273 : struct.secondaries) + { + oprot.writeString(_iter273); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class BucketOwnersTupleSchemeFactory implements SchemeFactory { + public BucketOwnersTupleScheme getScheme() { + return new BucketOwnersTupleScheme(); + } + } + + private static class BucketOwnersTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, BucketOwners struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + oprot.writeI32(struct.bucketId); + BitSet optionals = new BitSet(); + if (struct.isSetPrimary()) { + optionals.set(0); + } + if (struct.isSetSecondaries()) { + optionals.set(1); + } + oprot.writeBitSet(optionals, 2); + if (struct.isSetPrimary()) { + oprot.writeString(struct.primary); + } + if (struct.isSetSecondaries()) { + { + oprot.writeI32(struct.secondaries.size()); + for (String _iter274 : struct.secondaries) + { + oprot.writeString(_iter274); + } + } + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, BucketOwners struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.bucketId = iprot.readI32(); + struct.setBucketIdIsSet(true); + BitSet incoming = iprot.readBitSet(2); + if (incoming.get(0)) { + struct.primary = iprot.readString(); + struct.setPrimaryIsSet(true); + } + if (incoming.get(1)) { + { + org.apache.thrift.protocol.TList _list275 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.secondaries = new ArrayList(_list275.size); + String _elem276; + for (int _i277 = 0; _i277 < _list275.size; ++_i277) + { + _elem276 = iprot.readString(); + struct.secondaries.add(_elem276); + } + } + struct.setSecondariesIsSet(true); + } + } + } + +} + diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/CatalogFunctionObject.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/CatalogFunctionObject.java new file mode 100644 index 000000000..2e9e14db9 --- /dev/null +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/CatalogFunctionObject.java @@ -0,0 +1,753 @@ +/** + * Autogenerated by Thrift Compiler (0.9.3) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package io.snappydata.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-10") +public class CatalogFunctionObject implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("CatalogFunctionObject"); + + private static final org.apache.thrift.protocol.TField FUNCTION_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("functionName", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField SCHEMA_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("schemaName", org.apache.thrift.protocol.TType.STRING, (short)2); + private static final org.apache.thrift.protocol.TField CLASS_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("className", org.apache.thrift.protocol.TType.STRING, (short)3); + private static final org.apache.thrift.protocol.TField RESOURCES_FIELD_DESC = new org.apache.thrift.protocol.TField("resources", org.apache.thrift.protocol.TType.LIST, (short)4); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new CatalogFunctionObjectStandardSchemeFactory()); + schemes.put(TupleScheme.class, new CatalogFunctionObjectTupleSchemeFactory()); + } + + public String functionName; // required + public String schemaName; // optional + public String className; // required + public List resources; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + FUNCTION_NAME((short)1, "functionName"), + SCHEMA_NAME((short)2, "schemaName"), + CLASS_NAME((short)3, "className"), + RESOURCES((short)4, "resources"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // FUNCTION_NAME + return FUNCTION_NAME; + case 2: // SCHEMA_NAME + return SCHEMA_NAME; + case 3: // CLASS_NAME + return CLASS_NAME; + case 4: // RESOURCES + return RESOURCES; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final _Fields optionals[] = {_Fields.SCHEMA_NAME}; + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.FUNCTION_NAME, new org.apache.thrift.meta_data.FieldMetaData("functionName", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.SCHEMA_NAME, new org.apache.thrift.meta_data.FieldMetaData("schemaName", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.CLASS_NAME, new org.apache.thrift.meta_data.FieldMetaData("className", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.RESOURCES, new org.apache.thrift.meta_data.FieldMetaData("resources", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(CatalogFunctionObject.class, metaDataMap); + } + + public CatalogFunctionObject() { + } + + public CatalogFunctionObject( + String functionName, + String className, + List resources) + { + this(); + this.functionName = functionName; + this.className = className; + this.resources = resources; + } + + /** + * Performs a deep copy on other. + */ + public CatalogFunctionObject(CatalogFunctionObject other) { + if (other.isSetFunctionName()) { + this.functionName = other.functionName; + } + if (other.isSetSchemaName()) { + this.schemaName = other.schemaName; + } + if (other.isSetClassName()) { + this.className = other.className; + } + if (other.isSetResources()) { + List __this__resources = new ArrayList(other.resources); + this.resources = __this__resources; + } + } + + public CatalogFunctionObject deepCopy() { + return new CatalogFunctionObject(this); + } + + @Override + public void clear() { + this.functionName = null; + this.schemaName = null; + this.className = null; + this.resources = null; + } + + public String getFunctionName() { + return this.functionName; + } + + public CatalogFunctionObject setFunctionName(String functionName) { + this.functionName = functionName; + return this; + } + + public void unsetFunctionName() { + this.functionName = null; + } + + /** Returns true if field functionName is set (has been assigned a value) and false otherwise */ + public boolean isSetFunctionName() { + return this.functionName != null; + } + + public void setFunctionNameIsSet(boolean value) { + if (!value) { + this.functionName = null; + } + } + + public String getSchemaName() { + return this.schemaName; + } + + public CatalogFunctionObject setSchemaName(String schemaName) { + this.schemaName = schemaName; + return this; + } + + public void unsetSchemaName() { + this.schemaName = null; + } + + /** Returns true if field schemaName is set (has been assigned a value) and false otherwise */ + public boolean isSetSchemaName() { + return this.schemaName != null; + } + + public void setSchemaNameIsSet(boolean value) { + if (!value) { + this.schemaName = null; + } + } + + public String getClassName() { + return this.className; + } + + public CatalogFunctionObject setClassName(String className) { + this.className = className; + return this; + } + + public void unsetClassName() { + this.className = null; + } + + /** Returns true if field className is set (has been assigned a value) and false otherwise */ + public boolean isSetClassName() { + return this.className != null; + } + + public void setClassNameIsSet(boolean value) { + if (!value) { + this.className = null; + } + } + + public int getResourcesSize() { + return (this.resources == null) ? 0 : this.resources.size(); + } + + public java.util.Iterator getResourcesIterator() { + return (this.resources == null) ? null : this.resources.iterator(); + } + + public void addToResources(String elem) { + if (this.resources == null) { + this.resources = new ArrayList(); + } + this.resources.add(elem); + } + + public List getResources() { + return this.resources; + } + + public CatalogFunctionObject setResources(List resources) { + this.resources = resources; + return this; + } + + public void unsetResources() { + this.resources = null; + } + + /** Returns true if field resources is set (has been assigned a value) and false otherwise */ + public boolean isSetResources() { + return this.resources != null; + } + + public void setResourcesIsSet(boolean value) { + if (!value) { + this.resources = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case FUNCTION_NAME: + if (value == null) { + unsetFunctionName(); + } else { + setFunctionName((String)value); + } + break; + + case SCHEMA_NAME: + if (value == null) { + unsetSchemaName(); + } else { + setSchemaName((String)value); + } + break; + + case CLASS_NAME: + if (value == null) { + unsetClassName(); + } else { + setClassName((String)value); + } + break; + + case RESOURCES: + if (value == null) { + unsetResources(); + } else { + setResources((List)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case FUNCTION_NAME: + return getFunctionName(); + + case SCHEMA_NAME: + return getSchemaName(); + + case CLASS_NAME: + return getClassName(); + + case RESOURCES: + return getResources(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case FUNCTION_NAME: + return isSetFunctionName(); + case SCHEMA_NAME: + return isSetSchemaName(); + case CLASS_NAME: + return isSetClassName(); + case RESOURCES: + return isSetResources(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof CatalogFunctionObject) + return this.equals((CatalogFunctionObject)that); + return false; + } + + public boolean equals(CatalogFunctionObject that) { + if (that == null) + return false; + + boolean this_present_functionName = true && this.isSetFunctionName(); + boolean that_present_functionName = true && that.isSetFunctionName(); + if (this_present_functionName || that_present_functionName) { + if (!(this_present_functionName && that_present_functionName)) + return false; + if (!this.functionName.equals(that.functionName)) + return false; + } + + boolean this_present_schemaName = true && this.isSetSchemaName(); + boolean that_present_schemaName = true && that.isSetSchemaName(); + if (this_present_schemaName || that_present_schemaName) { + if (!(this_present_schemaName && that_present_schemaName)) + return false; + if (!this.schemaName.equals(that.schemaName)) + return false; + } + + boolean this_present_className = true && this.isSetClassName(); + boolean that_present_className = true && that.isSetClassName(); + if (this_present_className || that_present_className) { + if (!(this_present_className && that_present_className)) + return false; + if (!this.className.equals(that.className)) + return false; + } + + boolean this_present_resources = true && this.isSetResources(); + boolean that_present_resources = true && that.isSetResources(); + if (this_present_resources || that_present_resources) { + if (!(this_present_resources && that_present_resources)) + return false; + if (!this.resources.equals(that.resources)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_functionName = true && (isSetFunctionName()); + list.add(present_functionName); + if (present_functionName) + list.add(functionName); + + boolean present_schemaName = true && (isSetSchemaName()); + list.add(present_schemaName); + if (present_schemaName) + list.add(schemaName); + + boolean present_className = true && (isSetClassName()); + list.add(present_className); + if (present_className) + list.add(className); + + boolean present_resources = true && (isSetResources()); + list.add(present_resources); + if (present_resources) + list.add(resources); + + return list.hashCode(); + } + + @Override + public int compareTo(CatalogFunctionObject other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetFunctionName()).compareTo(other.isSetFunctionName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetFunctionName()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.functionName, other.functionName); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetSchemaName()).compareTo(other.isSetSchemaName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSchemaName()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.schemaName, other.schemaName); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetClassName()).compareTo(other.isSetClassName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetClassName()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.className, other.className); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetResources()).compareTo(other.isSetResources()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetResources()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.resources, other.resources); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("CatalogFunctionObject("); + boolean first = true; + + sb.append("functionName:"); + if (this.functionName == null) { + sb.append("null"); + } else { + sb.append(this.functionName); + } + first = false; + if (isSetSchemaName()) { + if (!first) sb.append(", "); + sb.append("schemaName:"); + if (this.schemaName == null) { + sb.append("null"); + } else { + sb.append(this.schemaName); + } + first = false; + } + if (!first) sb.append(", "); + sb.append("className:"); + if (this.className == null) { + sb.append("null"); + } else { + sb.append(this.className); + } + first = false; + if (!first) sb.append(", "); + sb.append("resources:"); + if (this.resources == null) { + sb.append("null"); + } else { + sb.append(this.resources); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (functionName == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'functionName' was not present! Struct: " + toString()); + } + if (className == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'className' was not present! Struct: " + toString()); + } + if (resources == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'resources' was not present! Struct: " + toString()); + } + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class CatalogFunctionObjectStandardSchemeFactory implements SchemeFactory { + public CatalogFunctionObjectStandardScheme getScheme() { + return new CatalogFunctionObjectStandardScheme(); + } + } + + private static class CatalogFunctionObjectStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, CatalogFunctionObject struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // FUNCTION_NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.functionName = iprot.readString(); + struct.setFunctionNameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // SCHEMA_NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.schemaName = iprot.readString(); + struct.setSchemaNameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // CLASS_NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.className = iprot.readString(); + struct.setClassNameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 4: // RESOURCES + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list382 = iprot.readListBegin(); + struct.resources = new ArrayList(_list382.size); + String _elem383; + for (int _i384 = 0; _i384 < _list382.size; ++_i384) + { + _elem383 = iprot.readString(); + struct.resources.add(_elem383); + } + iprot.readListEnd(); + } + struct.setResourcesIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, CatalogFunctionObject struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.functionName != null) { + oprot.writeFieldBegin(FUNCTION_NAME_FIELD_DESC); + oprot.writeString(struct.functionName); + oprot.writeFieldEnd(); + } + if (struct.schemaName != null) { + if (struct.isSetSchemaName()) { + oprot.writeFieldBegin(SCHEMA_NAME_FIELD_DESC); + oprot.writeString(struct.schemaName); + oprot.writeFieldEnd(); + } + } + if (struct.className != null) { + oprot.writeFieldBegin(CLASS_NAME_FIELD_DESC); + oprot.writeString(struct.className); + oprot.writeFieldEnd(); + } + if (struct.resources != null) { + oprot.writeFieldBegin(RESOURCES_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.resources.size())); + for (String _iter385 : struct.resources) + { + oprot.writeString(_iter385); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class CatalogFunctionObjectTupleSchemeFactory implements SchemeFactory { + public CatalogFunctionObjectTupleScheme getScheme() { + return new CatalogFunctionObjectTupleScheme(); + } + } + + private static class CatalogFunctionObjectTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, CatalogFunctionObject struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + oprot.writeString(struct.functionName); + oprot.writeString(struct.className); + { + oprot.writeI32(struct.resources.size()); + for (String _iter386 : struct.resources) + { + oprot.writeString(_iter386); + } + } + BitSet optionals = new BitSet(); + if (struct.isSetSchemaName()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetSchemaName()) { + oprot.writeString(struct.schemaName); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, CatalogFunctionObject struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.functionName = iprot.readString(); + struct.setFunctionNameIsSet(true); + struct.className = iprot.readString(); + struct.setClassNameIsSet(true); + { + org.apache.thrift.protocol.TList _list387 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.resources = new ArrayList(_list387.size); + String _elem388; + for (int _i389 = 0; _i389 < _list387.size; ++_i389) + { + _elem388 = iprot.readString(); + struct.resources.add(_elem388); + } + } + struct.setResourcesIsSet(true); + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.schemaName = iprot.readString(); + struct.setSchemaNameIsSet(true); + } + } + } + +} + diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/CatalogMetadataDetails.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/CatalogMetadataDetails.java new file mode 100644 index 000000000..cec7f002a --- /dev/null +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/CatalogMetadataDetails.java @@ -0,0 +1,1702 @@ +/** + * Autogenerated by Thrift Compiler (0.9.3) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package io.snappydata.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-10") +public class CatalogMetadataDetails implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("CatalogMetadataDetails"); + + private static final org.apache.thrift.protocol.TField NAMES_FIELD_DESC = new org.apache.thrift.protocol.TField("names", org.apache.thrift.protocol.TType.LIST, (short)1); + private static final org.apache.thrift.protocol.TField PROPERTIES_FIELD_DESC = new org.apache.thrift.protocol.TField("properties", org.apache.thrift.protocol.TType.LIST, (short)2); + private static final org.apache.thrift.protocol.TField NEW_PROPERTIES_FIELD_DESC = new org.apache.thrift.protocol.TField("newProperties", org.apache.thrift.protocol.TType.LIST, (short)3); + private static final org.apache.thrift.protocol.TField CATALOG_SCHEMA_VERSION_FIELD_DESC = new org.apache.thrift.protocol.TField("catalogSchemaVersion", org.apache.thrift.protocol.TType.I64, (short)4); + private static final org.apache.thrift.protocol.TField EXISTS_FIELD_DESC = new org.apache.thrift.protocol.TField("exists", org.apache.thrift.protocol.TType.BOOL, (short)5); + private static final org.apache.thrift.protocol.TField OTHER_FLAGS_FIELD_DESC = new org.apache.thrift.protocol.TField("otherFlags", org.apache.thrift.protocol.TType.LIST, (short)6); + private static final org.apache.thrift.protocol.TField CATALOG_SCHEMA_FIELD_DESC = new org.apache.thrift.protocol.TField("catalogSchema", org.apache.thrift.protocol.TType.STRUCT, (short)7); + private static final org.apache.thrift.protocol.TField CATALOG_TABLE_FIELD_DESC = new org.apache.thrift.protocol.TField("catalogTable", org.apache.thrift.protocol.TType.STRUCT, (short)8); + private static final org.apache.thrift.protocol.TField CATALOG_FUNCTION_FIELD_DESC = new org.apache.thrift.protocol.TField("catalogFunction", org.apache.thrift.protocol.TType.STRUCT, (short)9); + private static final org.apache.thrift.protocol.TField CATALOG_PARTITIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("catalogPartitions", org.apache.thrift.protocol.TType.LIST, (short)10); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new CatalogMetadataDetailsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new CatalogMetadataDetailsTupleSchemeFactory()); + } + + public List names; // optional + public List> properties; // optional + public List> newProperties; // optional + public long catalogSchemaVersion; // optional + public boolean exists; // optional + public List otherFlags; // optional + public CatalogSchemaObject catalogSchema; // optional + public CatalogTableObject catalogTable; // optional + public CatalogFunctionObject catalogFunction; // optional + public List catalogPartitions; // optional + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + NAMES((short)1, "names"), + PROPERTIES((short)2, "properties"), + NEW_PROPERTIES((short)3, "newProperties"), + CATALOG_SCHEMA_VERSION((short)4, "catalogSchemaVersion"), + EXISTS((short)5, "exists"), + OTHER_FLAGS((short)6, "otherFlags"), + CATALOG_SCHEMA((short)7, "catalogSchema"), + CATALOG_TABLE((short)8, "catalogTable"), + CATALOG_FUNCTION((short)9, "catalogFunction"), + CATALOG_PARTITIONS((short)10, "catalogPartitions"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // NAMES + return NAMES; + case 2: // PROPERTIES + return PROPERTIES; + case 3: // NEW_PROPERTIES + return NEW_PROPERTIES; + case 4: // CATALOG_SCHEMA_VERSION + return CATALOG_SCHEMA_VERSION; + case 5: // EXISTS + return EXISTS; + case 6: // OTHER_FLAGS + return OTHER_FLAGS; + case 7: // CATALOG_SCHEMA + return CATALOG_SCHEMA; + case 8: // CATALOG_TABLE + return CATALOG_TABLE; + case 9: // CATALOG_FUNCTION + return CATALOG_FUNCTION; + case 10: // CATALOG_PARTITIONS + return CATALOG_PARTITIONS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __CATALOGSCHEMAVERSION_ISSET_ID = 0; + private static final int __EXISTS_ISSET_ID = 1; + private byte __isset_bitfield = 0; + private static final _Fields optionals[] = {_Fields.NAMES,_Fields.PROPERTIES,_Fields.NEW_PROPERTIES,_Fields.CATALOG_SCHEMA_VERSION,_Fields.EXISTS,_Fields.OTHER_FLAGS,_Fields.CATALOG_SCHEMA,_Fields.CATALOG_TABLE,_Fields.CATALOG_FUNCTION,_Fields.CATALOG_PARTITIONS}; + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.NAMES, new org.apache.thrift.meta_data.FieldMetaData("names", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); + tmpMap.put(_Fields.PROPERTIES, new org.apache.thrift.meta_data.FieldMetaData("properties", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))))); + tmpMap.put(_Fields.NEW_PROPERTIES, new org.apache.thrift.meta_data.FieldMetaData("newProperties", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))))); + tmpMap.put(_Fields.CATALOG_SCHEMA_VERSION, new org.apache.thrift.meta_data.FieldMetaData("catalogSchemaVersion", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); + tmpMap.put(_Fields.EXISTS, new org.apache.thrift.meta_data.FieldMetaData("exists", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); + tmpMap.put(_Fields.OTHER_FLAGS, new org.apache.thrift.meta_data.FieldMetaData("otherFlags", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)))); + tmpMap.put(_Fields.CATALOG_SCHEMA, new org.apache.thrift.meta_data.FieldMetaData("catalogSchema", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, CatalogSchemaObject.class))); + tmpMap.put(_Fields.CATALOG_TABLE, new org.apache.thrift.meta_data.FieldMetaData("catalogTable", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, CatalogTableObject.class))); + tmpMap.put(_Fields.CATALOG_FUNCTION, new org.apache.thrift.meta_data.FieldMetaData("catalogFunction", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, CatalogFunctionObject.class))); + tmpMap.put(_Fields.CATALOG_PARTITIONS, new org.apache.thrift.meta_data.FieldMetaData("catalogPartitions", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, CatalogPartitionObject.class)))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(CatalogMetadataDetails.class, metaDataMap); + } + + public CatalogMetadataDetails() { + } + + /** + * Performs a deep copy on other. + */ + public CatalogMetadataDetails(CatalogMetadataDetails other) { + __isset_bitfield = other.__isset_bitfield; + if (other.isSetNames()) { + List __this__names = new ArrayList(other.names); + this.names = __this__names; + } + if (other.isSetProperties()) { + List> __this__properties = new ArrayList>(other.properties.size()); + for (Map other_element : other.properties) { + Map __this__properties_copy = new HashMap(other_element); + __this__properties.add(__this__properties_copy); + } + this.properties = __this__properties; + } + if (other.isSetNewProperties()) { + List> __this__newProperties = new ArrayList>(other.newProperties.size()); + for (Map other_element : other.newProperties) { + Map __this__newProperties_copy = new HashMap(other_element); + __this__newProperties.add(__this__newProperties_copy); + } + this.newProperties = __this__newProperties; + } + this.catalogSchemaVersion = other.catalogSchemaVersion; + this.exists = other.exists; + if (other.isSetOtherFlags()) { + List __this__otherFlags = new ArrayList(other.otherFlags); + this.otherFlags = __this__otherFlags; + } + if (other.isSetCatalogSchema()) { + this.catalogSchema = new CatalogSchemaObject(other.catalogSchema); + } + if (other.isSetCatalogTable()) { + this.catalogTable = new CatalogTableObject(other.catalogTable); + } + if (other.isSetCatalogFunction()) { + this.catalogFunction = new CatalogFunctionObject(other.catalogFunction); + } + if (other.isSetCatalogPartitions()) { + List __this__catalogPartitions = new ArrayList(other.catalogPartitions.size()); + for (CatalogPartitionObject other_element : other.catalogPartitions) { + __this__catalogPartitions.add(new CatalogPartitionObject(other_element)); + } + this.catalogPartitions = __this__catalogPartitions; + } + } + + public CatalogMetadataDetails deepCopy() { + return new CatalogMetadataDetails(this); + } + + @Override + public void clear() { + this.names = null; + this.properties = null; + this.newProperties = null; + setCatalogSchemaVersionIsSet(false); + this.catalogSchemaVersion = 0; + setExistsIsSet(false); + this.exists = false; + this.otherFlags = null; + this.catalogSchema = null; + this.catalogTable = null; + this.catalogFunction = null; + this.catalogPartitions = null; + } + + public int getNamesSize() { + return (this.names == null) ? 0 : this.names.size(); + } + + public java.util.Iterator getNamesIterator() { + return (this.names == null) ? null : this.names.iterator(); + } + + public void addToNames(String elem) { + if (this.names == null) { + this.names = new ArrayList(); + } + this.names.add(elem); + } + + public List getNames() { + return this.names; + } + + public CatalogMetadataDetails setNames(List names) { + this.names = names; + return this; + } + + public void unsetNames() { + this.names = null; + } + + /** Returns true if field names is set (has been assigned a value) and false otherwise */ + public boolean isSetNames() { + return this.names != null; + } + + public void setNamesIsSet(boolean value) { + if (!value) { + this.names = null; + } + } + + public int getPropertiesSize() { + return (this.properties == null) ? 0 : this.properties.size(); + } + + public java.util.Iterator> getPropertiesIterator() { + return (this.properties == null) ? null : this.properties.iterator(); + } + + public void addToProperties(Map elem) { + if (this.properties == null) { + this.properties = new ArrayList>(); + } + this.properties.add(elem); + } + + public List> getProperties() { + return this.properties; + } + + public CatalogMetadataDetails setProperties(List> properties) { + this.properties = properties; + return this; + } + + public void unsetProperties() { + this.properties = null; + } + + /** Returns true if field properties is set (has been assigned a value) and false otherwise */ + public boolean isSetProperties() { + return this.properties != null; + } + + public void setPropertiesIsSet(boolean value) { + if (!value) { + this.properties = null; + } + } + + public int getNewPropertiesSize() { + return (this.newProperties == null) ? 0 : this.newProperties.size(); + } + + public java.util.Iterator> getNewPropertiesIterator() { + return (this.newProperties == null) ? null : this.newProperties.iterator(); + } + + public void addToNewProperties(Map elem) { + if (this.newProperties == null) { + this.newProperties = new ArrayList>(); + } + this.newProperties.add(elem); + } + + public List> getNewProperties() { + return this.newProperties; + } + + public CatalogMetadataDetails setNewProperties(List> newProperties) { + this.newProperties = newProperties; + return this; + } + + public void unsetNewProperties() { + this.newProperties = null; + } + + /** Returns true if field newProperties is set (has been assigned a value) and false otherwise */ + public boolean isSetNewProperties() { + return this.newProperties != null; + } + + public void setNewPropertiesIsSet(boolean value) { + if (!value) { + this.newProperties = null; + } + } + + public long getCatalogSchemaVersion() { + return this.catalogSchemaVersion; + } + + public CatalogMetadataDetails setCatalogSchemaVersion(long catalogSchemaVersion) { + this.catalogSchemaVersion = catalogSchemaVersion; + setCatalogSchemaVersionIsSet(true); + return this; + } + + public void unsetCatalogSchemaVersion() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __CATALOGSCHEMAVERSION_ISSET_ID); + } + + /** Returns true if field catalogSchemaVersion is set (has been assigned a value) and false otherwise */ + public boolean isSetCatalogSchemaVersion() { + return EncodingUtils.testBit(__isset_bitfield, __CATALOGSCHEMAVERSION_ISSET_ID); + } + + public void setCatalogSchemaVersionIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __CATALOGSCHEMAVERSION_ISSET_ID, value); + } + + public boolean isExists() { + return this.exists; + } + + public CatalogMetadataDetails setExists(boolean exists) { + this.exists = exists; + setExistsIsSet(true); + return this; + } + + public void unsetExists() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __EXISTS_ISSET_ID); + } + + /** Returns true if field exists is set (has been assigned a value) and false otherwise */ + public boolean isSetExists() { + return EncodingUtils.testBit(__isset_bitfield, __EXISTS_ISSET_ID); + } + + public void setExistsIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __EXISTS_ISSET_ID, value); + } + + public int getOtherFlagsSize() { + return (this.otherFlags == null) ? 0 : this.otherFlags.size(); + } + + public java.util.Iterator getOtherFlagsIterator() { + return (this.otherFlags == null) ? null : this.otherFlags.iterator(); + } + + public void addToOtherFlags(int elem) { + if (this.otherFlags == null) { + this.otherFlags = new ArrayList(); + } + this.otherFlags.add(elem); + } + + public List getOtherFlags() { + return this.otherFlags; + } + + public CatalogMetadataDetails setOtherFlags(List otherFlags) { + this.otherFlags = otherFlags; + return this; + } + + public void unsetOtherFlags() { + this.otherFlags = null; + } + + /** Returns true if field otherFlags is set (has been assigned a value) and false otherwise */ + public boolean isSetOtherFlags() { + return this.otherFlags != null; + } + + public void setOtherFlagsIsSet(boolean value) { + if (!value) { + this.otherFlags = null; + } + } + + public CatalogSchemaObject getCatalogSchema() { + return this.catalogSchema; + } + + public CatalogMetadataDetails setCatalogSchema(CatalogSchemaObject catalogSchema) { + this.catalogSchema = catalogSchema; + return this; + } + + public void unsetCatalogSchema() { + this.catalogSchema = null; + } + + /** Returns true if field catalogSchema is set (has been assigned a value) and false otherwise */ + public boolean isSetCatalogSchema() { + return this.catalogSchema != null; + } + + public void setCatalogSchemaIsSet(boolean value) { + if (!value) { + this.catalogSchema = null; + } + } + + public CatalogTableObject getCatalogTable() { + return this.catalogTable; + } + + public CatalogMetadataDetails setCatalogTable(CatalogTableObject catalogTable) { + this.catalogTable = catalogTable; + return this; + } + + public void unsetCatalogTable() { + this.catalogTable = null; + } + + /** Returns true if field catalogTable is set (has been assigned a value) and false otherwise */ + public boolean isSetCatalogTable() { + return this.catalogTable != null; + } + + public void setCatalogTableIsSet(boolean value) { + if (!value) { + this.catalogTable = null; + } + } + + public CatalogFunctionObject getCatalogFunction() { + return this.catalogFunction; + } + + public CatalogMetadataDetails setCatalogFunction(CatalogFunctionObject catalogFunction) { + this.catalogFunction = catalogFunction; + return this; + } + + public void unsetCatalogFunction() { + this.catalogFunction = null; + } + + /** Returns true if field catalogFunction is set (has been assigned a value) and false otherwise */ + public boolean isSetCatalogFunction() { + return this.catalogFunction != null; + } + + public void setCatalogFunctionIsSet(boolean value) { + if (!value) { + this.catalogFunction = null; + } + } + + public int getCatalogPartitionsSize() { + return (this.catalogPartitions == null) ? 0 : this.catalogPartitions.size(); + } + + public java.util.Iterator getCatalogPartitionsIterator() { + return (this.catalogPartitions == null) ? null : this.catalogPartitions.iterator(); + } + + public void addToCatalogPartitions(CatalogPartitionObject elem) { + if (this.catalogPartitions == null) { + this.catalogPartitions = new ArrayList(); + } + this.catalogPartitions.add(elem); + } + + public List getCatalogPartitions() { + return this.catalogPartitions; + } + + public CatalogMetadataDetails setCatalogPartitions(List catalogPartitions) { + this.catalogPartitions = catalogPartitions; + return this; + } + + public void unsetCatalogPartitions() { + this.catalogPartitions = null; + } + + /** Returns true if field catalogPartitions is set (has been assigned a value) and false otherwise */ + public boolean isSetCatalogPartitions() { + return this.catalogPartitions != null; + } + + public void setCatalogPartitionsIsSet(boolean value) { + if (!value) { + this.catalogPartitions = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case NAMES: + if (value == null) { + unsetNames(); + } else { + setNames((List)value); + } + break; + + case PROPERTIES: + if (value == null) { + unsetProperties(); + } else { + setProperties((List>)value); + } + break; + + case NEW_PROPERTIES: + if (value == null) { + unsetNewProperties(); + } else { + setNewProperties((List>)value); + } + break; + + case CATALOG_SCHEMA_VERSION: + if (value == null) { + unsetCatalogSchemaVersion(); + } else { + setCatalogSchemaVersion((Long)value); + } + break; + + case EXISTS: + if (value == null) { + unsetExists(); + } else { + setExists((Boolean)value); + } + break; + + case OTHER_FLAGS: + if (value == null) { + unsetOtherFlags(); + } else { + setOtherFlags((List)value); + } + break; + + case CATALOG_SCHEMA: + if (value == null) { + unsetCatalogSchema(); + } else { + setCatalogSchema((CatalogSchemaObject)value); + } + break; + + case CATALOG_TABLE: + if (value == null) { + unsetCatalogTable(); + } else { + setCatalogTable((CatalogTableObject)value); + } + break; + + case CATALOG_FUNCTION: + if (value == null) { + unsetCatalogFunction(); + } else { + setCatalogFunction((CatalogFunctionObject)value); + } + break; + + case CATALOG_PARTITIONS: + if (value == null) { + unsetCatalogPartitions(); + } else { + setCatalogPartitions((List)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case NAMES: + return getNames(); + + case PROPERTIES: + return getProperties(); + + case NEW_PROPERTIES: + return getNewProperties(); + + case CATALOG_SCHEMA_VERSION: + return getCatalogSchemaVersion(); + + case EXISTS: + return isExists(); + + case OTHER_FLAGS: + return getOtherFlags(); + + case CATALOG_SCHEMA: + return getCatalogSchema(); + + case CATALOG_TABLE: + return getCatalogTable(); + + case CATALOG_FUNCTION: + return getCatalogFunction(); + + case CATALOG_PARTITIONS: + return getCatalogPartitions(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case NAMES: + return isSetNames(); + case PROPERTIES: + return isSetProperties(); + case NEW_PROPERTIES: + return isSetNewProperties(); + case CATALOG_SCHEMA_VERSION: + return isSetCatalogSchemaVersion(); + case EXISTS: + return isSetExists(); + case OTHER_FLAGS: + return isSetOtherFlags(); + case CATALOG_SCHEMA: + return isSetCatalogSchema(); + case CATALOG_TABLE: + return isSetCatalogTable(); + case CATALOG_FUNCTION: + return isSetCatalogFunction(); + case CATALOG_PARTITIONS: + return isSetCatalogPartitions(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof CatalogMetadataDetails) + return this.equals((CatalogMetadataDetails)that); + return false; + } + + public boolean equals(CatalogMetadataDetails that) { + if (that == null) + return false; + + boolean this_present_names = true && this.isSetNames(); + boolean that_present_names = true && that.isSetNames(); + if (this_present_names || that_present_names) { + if (!(this_present_names && that_present_names)) + return false; + if (!this.names.equals(that.names)) + return false; + } + + boolean this_present_properties = true && this.isSetProperties(); + boolean that_present_properties = true && that.isSetProperties(); + if (this_present_properties || that_present_properties) { + if (!(this_present_properties && that_present_properties)) + return false; + if (!this.properties.equals(that.properties)) + return false; + } + + boolean this_present_newProperties = true && this.isSetNewProperties(); + boolean that_present_newProperties = true && that.isSetNewProperties(); + if (this_present_newProperties || that_present_newProperties) { + if (!(this_present_newProperties && that_present_newProperties)) + return false; + if (!this.newProperties.equals(that.newProperties)) + return false; + } + + boolean this_present_catalogSchemaVersion = true && this.isSetCatalogSchemaVersion(); + boolean that_present_catalogSchemaVersion = true && that.isSetCatalogSchemaVersion(); + if (this_present_catalogSchemaVersion || that_present_catalogSchemaVersion) { + if (!(this_present_catalogSchemaVersion && that_present_catalogSchemaVersion)) + return false; + if (this.catalogSchemaVersion != that.catalogSchemaVersion) + return false; + } + + boolean this_present_exists = true && this.isSetExists(); + boolean that_present_exists = true && that.isSetExists(); + if (this_present_exists || that_present_exists) { + if (!(this_present_exists && that_present_exists)) + return false; + if (this.exists != that.exists) + return false; + } + + boolean this_present_otherFlags = true && this.isSetOtherFlags(); + boolean that_present_otherFlags = true && that.isSetOtherFlags(); + if (this_present_otherFlags || that_present_otherFlags) { + if (!(this_present_otherFlags && that_present_otherFlags)) + return false; + if (!this.otherFlags.equals(that.otherFlags)) + return false; + } + + boolean this_present_catalogSchema = true && this.isSetCatalogSchema(); + boolean that_present_catalogSchema = true && that.isSetCatalogSchema(); + if (this_present_catalogSchema || that_present_catalogSchema) { + if (!(this_present_catalogSchema && that_present_catalogSchema)) + return false; + if (!this.catalogSchema.equals(that.catalogSchema)) + return false; + } + + boolean this_present_catalogTable = true && this.isSetCatalogTable(); + boolean that_present_catalogTable = true && that.isSetCatalogTable(); + if (this_present_catalogTable || that_present_catalogTable) { + if (!(this_present_catalogTable && that_present_catalogTable)) + return false; + if (!this.catalogTable.equals(that.catalogTable)) + return false; + } + + boolean this_present_catalogFunction = true && this.isSetCatalogFunction(); + boolean that_present_catalogFunction = true && that.isSetCatalogFunction(); + if (this_present_catalogFunction || that_present_catalogFunction) { + if (!(this_present_catalogFunction && that_present_catalogFunction)) + return false; + if (!this.catalogFunction.equals(that.catalogFunction)) + return false; + } + + boolean this_present_catalogPartitions = true && this.isSetCatalogPartitions(); + boolean that_present_catalogPartitions = true && that.isSetCatalogPartitions(); + if (this_present_catalogPartitions || that_present_catalogPartitions) { + if (!(this_present_catalogPartitions && that_present_catalogPartitions)) + return false; + if (!this.catalogPartitions.equals(that.catalogPartitions)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_names = true && (isSetNames()); + list.add(present_names); + if (present_names) + list.add(names); + + boolean present_properties = true && (isSetProperties()); + list.add(present_properties); + if (present_properties) + list.add(properties); + + boolean present_newProperties = true && (isSetNewProperties()); + list.add(present_newProperties); + if (present_newProperties) + list.add(newProperties); + + boolean present_catalogSchemaVersion = true && (isSetCatalogSchemaVersion()); + list.add(present_catalogSchemaVersion); + if (present_catalogSchemaVersion) + list.add(catalogSchemaVersion); + + boolean present_exists = true && (isSetExists()); + list.add(present_exists); + if (present_exists) + list.add(exists); + + boolean present_otherFlags = true && (isSetOtherFlags()); + list.add(present_otherFlags); + if (present_otherFlags) + list.add(otherFlags); + + boolean present_catalogSchema = true && (isSetCatalogSchema()); + list.add(present_catalogSchema); + if (present_catalogSchema) + list.add(catalogSchema); + + boolean present_catalogTable = true && (isSetCatalogTable()); + list.add(present_catalogTable); + if (present_catalogTable) + list.add(catalogTable); + + boolean present_catalogFunction = true && (isSetCatalogFunction()); + list.add(present_catalogFunction); + if (present_catalogFunction) + list.add(catalogFunction); + + boolean present_catalogPartitions = true && (isSetCatalogPartitions()); + list.add(present_catalogPartitions); + if (present_catalogPartitions) + list.add(catalogPartitions); + + return list.hashCode(); + } + + @Override + public int compareTo(CatalogMetadataDetails other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetNames()).compareTo(other.isSetNames()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetNames()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.names, other.names); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetProperties()).compareTo(other.isSetProperties()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetProperties()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.properties, other.properties); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetNewProperties()).compareTo(other.isSetNewProperties()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetNewProperties()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.newProperties, other.newProperties); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetCatalogSchemaVersion()).compareTo(other.isSetCatalogSchemaVersion()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetCatalogSchemaVersion()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.catalogSchemaVersion, other.catalogSchemaVersion); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetExists()).compareTo(other.isSetExists()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetExists()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.exists, other.exists); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetOtherFlags()).compareTo(other.isSetOtherFlags()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetOtherFlags()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.otherFlags, other.otherFlags); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetCatalogSchema()).compareTo(other.isSetCatalogSchema()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetCatalogSchema()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.catalogSchema, other.catalogSchema); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetCatalogTable()).compareTo(other.isSetCatalogTable()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetCatalogTable()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.catalogTable, other.catalogTable); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetCatalogFunction()).compareTo(other.isSetCatalogFunction()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetCatalogFunction()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.catalogFunction, other.catalogFunction); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetCatalogPartitions()).compareTo(other.isSetCatalogPartitions()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetCatalogPartitions()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.catalogPartitions, other.catalogPartitions); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("CatalogMetadataDetails("); + boolean first = true; + + if (isSetNames()) { + sb.append("names:"); + if (this.names == null) { + sb.append("null"); + } else { + sb.append(this.names); + } + first = false; + } + if (isSetProperties()) { + if (!first) sb.append(", "); + sb.append("properties:"); + if (this.properties == null) { + sb.append("null"); + } else { + sb.append(this.properties); + } + first = false; + } + if (isSetNewProperties()) { + if (!first) sb.append(", "); + sb.append("newProperties:"); + if (this.newProperties == null) { + sb.append("null"); + } else { + sb.append(this.newProperties); + } + first = false; + } + if (isSetCatalogSchemaVersion()) { + if (!first) sb.append(", "); + sb.append("catalogSchemaVersion:"); + sb.append(this.catalogSchemaVersion); + first = false; + } + if (isSetExists()) { + if (!first) sb.append(", "); + sb.append("exists:"); + sb.append(this.exists); + first = false; + } + if (isSetOtherFlags()) { + if (!first) sb.append(", "); + sb.append("otherFlags:"); + if (this.otherFlags == null) { + sb.append("null"); + } else { + sb.append(this.otherFlags); + } + first = false; + } + if (isSetCatalogSchema()) { + if (!first) sb.append(", "); + sb.append("catalogSchema:"); + if (this.catalogSchema == null) { + sb.append("null"); + } else { + sb.append(this.catalogSchema); + } + first = false; + } + if (isSetCatalogTable()) { + if (!first) sb.append(", "); + sb.append("catalogTable:"); + if (this.catalogTable == null) { + sb.append("null"); + } else { + sb.append(this.catalogTable); + } + first = false; + } + if (isSetCatalogFunction()) { + if (!first) sb.append(", "); + sb.append("catalogFunction:"); + if (this.catalogFunction == null) { + sb.append("null"); + } else { + sb.append(this.catalogFunction); + } + first = false; + } + if (isSetCatalogPartitions()) { + if (!first) sb.append(", "); + sb.append("catalogPartitions:"); + if (this.catalogPartitions == null) { + sb.append("null"); + } else { + sb.append(this.catalogPartitions); + } + first = false; + } + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + if (catalogSchema != null) { + catalogSchema.validate(); + } + if (catalogTable != null) { + catalogTable.validate(); + } + if (catalogFunction != null) { + catalogFunction.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bitfield = 0; + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class CatalogMetadataDetailsStandardSchemeFactory implements SchemeFactory { + public CatalogMetadataDetailsStandardScheme getScheme() { + return new CatalogMetadataDetailsStandardScheme(); + } + } + + private static class CatalogMetadataDetailsStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, CatalogMetadataDetails struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // NAMES + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list420 = iprot.readListBegin(); + struct.names = new ArrayList(_list420.size); + String _elem421; + for (int _i422 = 0; _i422 < _list420.size; ++_i422) + { + _elem421 = iprot.readString(); + struct.names.add(_elem421); + } + iprot.readListEnd(); + } + struct.setNamesIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // PROPERTIES + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list423 = iprot.readListBegin(); + struct.properties = new ArrayList>(_list423.size); + Map _elem424; + for (int _i425 = 0; _i425 < _list423.size; ++_i425) + { + { + org.apache.thrift.protocol.TMap _map426 = iprot.readMapBegin(); + _elem424 = new HashMap(2*_map426.size); + String _key427; + String _val428; + for (int _i429 = 0; _i429 < _map426.size; ++_i429) + { + _key427 = iprot.readString(); + _val428 = iprot.readString(); + _elem424.put(_key427, _val428); + } + iprot.readMapEnd(); + } + struct.properties.add(_elem424); + } + iprot.readListEnd(); + } + struct.setPropertiesIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // NEW_PROPERTIES + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list430 = iprot.readListBegin(); + struct.newProperties = new ArrayList>(_list430.size); + Map _elem431; + for (int _i432 = 0; _i432 < _list430.size; ++_i432) + { + { + org.apache.thrift.protocol.TMap _map433 = iprot.readMapBegin(); + _elem431 = new HashMap(2*_map433.size); + String _key434; + String _val435; + for (int _i436 = 0; _i436 < _map433.size; ++_i436) + { + _key434 = iprot.readString(); + _val435 = iprot.readString(); + _elem431.put(_key434, _val435); + } + iprot.readMapEnd(); + } + struct.newProperties.add(_elem431); + } + iprot.readListEnd(); + } + struct.setNewPropertiesIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 4: // CATALOG_SCHEMA_VERSION + if (schemeField.type == org.apache.thrift.protocol.TType.I64) { + struct.catalogSchemaVersion = iprot.readI64(); + struct.setCatalogSchemaVersionIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 5: // EXISTS + if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { + struct.exists = iprot.readBool(); + struct.setExistsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 6: // OTHER_FLAGS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list437 = iprot.readListBegin(); + struct.otherFlags = new ArrayList(_list437.size); + int _elem438; + for (int _i439 = 0; _i439 < _list437.size; ++_i439) + { + _elem438 = iprot.readI32(); + struct.otherFlags.add(_elem438); + } + iprot.readListEnd(); + } + struct.setOtherFlagsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 7: // CATALOG_SCHEMA + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.catalogSchema = new CatalogSchemaObject(); + struct.catalogSchema.read(iprot); + struct.setCatalogSchemaIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 8: // CATALOG_TABLE + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.catalogTable = new CatalogTableObject(); + struct.catalogTable.read(iprot); + struct.setCatalogTableIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 9: // CATALOG_FUNCTION + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.catalogFunction = new CatalogFunctionObject(); + struct.catalogFunction.read(iprot); + struct.setCatalogFunctionIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 10: // CATALOG_PARTITIONS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list440 = iprot.readListBegin(); + struct.catalogPartitions = new ArrayList(_list440.size); + CatalogPartitionObject _elem441; + for (int _i442 = 0; _i442 < _list440.size; ++_i442) + { + _elem441 = new CatalogPartitionObject(); + _elem441.read(iprot); + struct.catalogPartitions.add(_elem441); + } + iprot.readListEnd(); + } + struct.setCatalogPartitionsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, CatalogMetadataDetails struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.names != null) { + if (struct.isSetNames()) { + oprot.writeFieldBegin(NAMES_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.names.size())); + for (String _iter443 : struct.names) + { + oprot.writeString(_iter443); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + if (struct.properties != null) { + if (struct.isSetProperties()) { + oprot.writeFieldBegin(PROPERTIES_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.MAP, struct.properties.size())); + for (Map _iter444 : struct.properties) + { + { + oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, _iter444.size())); + for (Map.Entry _iter445 : _iter444.entrySet()) + { + oprot.writeString(_iter445.getKey()); + oprot.writeString(_iter445.getValue()); + } + oprot.writeMapEnd(); + } + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + if (struct.newProperties != null) { + if (struct.isSetNewProperties()) { + oprot.writeFieldBegin(NEW_PROPERTIES_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.MAP, struct.newProperties.size())); + for (Map _iter446 : struct.newProperties) + { + { + oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, _iter446.size())); + for (Map.Entry _iter447 : _iter446.entrySet()) + { + oprot.writeString(_iter447.getKey()); + oprot.writeString(_iter447.getValue()); + } + oprot.writeMapEnd(); + } + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + if (struct.isSetCatalogSchemaVersion()) { + oprot.writeFieldBegin(CATALOG_SCHEMA_VERSION_FIELD_DESC); + oprot.writeI64(struct.catalogSchemaVersion); + oprot.writeFieldEnd(); + } + if (struct.isSetExists()) { + oprot.writeFieldBegin(EXISTS_FIELD_DESC); + oprot.writeBool(struct.exists); + oprot.writeFieldEnd(); + } + if (struct.otherFlags != null) { + if (struct.isSetOtherFlags()) { + oprot.writeFieldBegin(OTHER_FLAGS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, struct.otherFlags.size())); + for (int _iter448 : struct.otherFlags) + { + oprot.writeI32(_iter448); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + if (struct.catalogSchema != null) { + if (struct.isSetCatalogSchema()) { + oprot.writeFieldBegin(CATALOG_SCHEMA_FIELD_DESC); + struct.catalogSchema.write(oprot); + oprot.writeFieldEnd(); + } + } + if (struct.catalogTable != null) { + if (struct.isSetCatalogTable()) { + oprot.writeFieldBegin(CATALOG_TABLE_FIELD_DESC); + struct.catalogTable.write(oprot); + oprot.writeFieldEnd(); + } + } + if (struct.catalogFunction != null) { + if (struct.isSetCatalogFunction()) { + oprot.writeFieldBegin(CATALOG_FUNCTION_FIELD_DESC); + struct.catalogFunction.write(oprot); + oprot.writeFieldEnd(); + } + } + if (struct.catalogPartitions != null) { + if (struct.isSetCatalogPartitions()) { + oprot.writeFieldBegin(CATALOG_PARTITIONS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.catalogPartitions.size())); + for (CatalogPartitionObject _iter449 : struct.catalogPartitions) + { + _iter449.write(oprot); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class CatalogMetadataDetailsTupleSchemeFactory implements SchemeFactory { + public CatalogMetadataDetailsTupleScheme getScheme() { + return new CatalogMetadataDetailsTupleScheme(); + } + } + + private static class CatalogMetadataDetailsTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, CatalogMetadataDetails struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetNames()) { + optionals.set(0); + } + if (struct.isSetProperties()) { + optionals.set(1); + } + if (struct.isSetNewProperties()) { + optionals.set(2); + } + if (struct.isSetCatalogSchemaVersion()) { + optionals.set(3); + } + if (struct.isSetExists()) { + optionals.set(4); + } + if (struct.isSetOtherFlags()) { + optionals.set(5); + } + if (struct.isSetCatalogSchema()) { + optionals.set(6); + } + if (struct.isSetCatalogTable()) { + optionals.set(7); + } + if (struct.isSetCatalogFunction()) { + optionals.set(8); + } + if (struct.isSetCatalogPartitions()) { + optionals.set(9); + } + oprot.writeBitSet(optionals, 10); + if (struct.isSetNames()) { + { + oprot.writeI32(struct.names.size()); + for (String _iter450 : struct.names) + { + oprot.writeString(_iter450); + } + } + } + if (struct.isSetProperties()) { + { + oprot.writeI32(struct.properties.size()); + for (Map _iter451 : struct.properties) + { + { + oprot.writeI32(_iter451.size()); + for (Map.Entry _iter452 : _iter451.entrySet()) + { + oprot.writeString(_iter452.getKey()); + oprot.writeString(_iter452.getValue()); + } + } + } + } + } + if (struct.isSetNewProperties()) { + { + oprot.writeI32(struct.newProperties.size()); + for (Map _iter453 : struct.newProperties) + { + { + oprot.writeI32(_iter453.size()); + for (Map.Entry _iter454 : _iter453.entrySet()) + { + oprot.writeString(_iter454.getKey()); + oprot.writeString(_iter454.getValue()); + } + } + } + } + } + if (struct.isSetCatalogSchemaVersion()) { + oprot.writeI64(struct.catalogSchemaVersion); + } + if (struct.isSetExists()) { + oprot.writeBool(struct.exists); + } + if (struct.isSetOtherFlags()) { + { + oprot.writeI32(struct.otherFlags.size()); + for (int _iter455 : struct.otherFlags) + { + oprot.writeI32(_iter455); + } + } + } + if (struct.isSetCatalogSchema()) { + struct.catalogSchema.write(oprot); + } + if (struct.isSetCatalogTable()) { + struct.catalogTable.write(oprot); + } + if (struct.isSetCatalogFunction()) { + struct.catalogFunction.write(oprot); + } + if (struct.isSetCatalogPartitions()) { + { + oprot.writeI32(struct.catalogPartitions.size()); + for (CatalogPartitionObject _iter456 : struct.catalogPartitions) + { + _iter456.write(oprot); + } + } + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, CatalogMetadataDetails struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(10); + if (incoming.get(0)) { + { + org.apache.thrift.protocol.TList _list457 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.names = new ArrayList(_list457.size); + String _elem458; + for (int _i459 = 0; _i459 < _list457.size; ++_i459) + { + _elem458 = iprot.readString(); + struct.names.add(_elem458); + } + } + struct.setNamesIsSet(true); + } + if (incoming.get(1)) { + { + org.apache.thrift.protocol.TList _list460 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.MAP, iprot.readI32()); + struct.properties = new ArrayList>(_list460.size); + Map _elem461; + for (int _i462 = 0; _i462 < _list460.size; ++_i462) + { + { + org.apache.thrift.protocol.TMap _map463 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + _elem461 = new HashMap(2*_map463.size); + String _key464; + String _val465; + for (int _i466 = 0; _i466 < _map463.size; ++_i466) + { + _key464 = iprot.readString(); + _val465 = iprot.readString(); + _elem461.put(_key464, _val465); + } + } + struct.properties.add(_elem461); + } + } + struct.setPropertiesIsSet(true); + } + if (incoming.get(2)) { + { + org.apache.thrift.protocol.TList _list467 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.MAP, iprot.readI32()); + struct.newProperties = new ArrayList>(_list467.size); + Map _elem468; + for (int _i469 = 0; _i469 < _list467.size; ++_i469) + { + { + org.apache.thrift.protocol.TMap _map470 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + _elem468 = new HashMap(2*_map470.size); + String _key471; + String _val472; + for (int _i473 = 0; _i473 < _map470.size; ++_i473) + { + _key471 = iprot.readString(); + _val472 = iprot.readString(); + _elem468.put(_key471, _val472); + } + } + struct.newProperties.add(_elem468); + } + } + struct.setNewPropertiesIsSet(true); + } + if (incoming.get(3)) { + struct.catalogSchemaVersion = iprot.readI64(); + struct.setCatalogSchemaVersionIsSet(true); + } + if (incoming.get(4)) { + struct.exists = iprot.readBool(); + struct.setExistsIsSet(true); + } + if (incoming.get(5)) { + { + org.apache.thrift.protocol.TList _list474 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.otherFlags = new ArrayList(_list474.size); + int _elem475; + for (int _i476 = 0; _i476 < _list474.size; ++_i476) + { + _elem475 = iprot.readI32(); + struct.otherFlags.add(_elem475); + } + } + struct.setOtherFlagsIsSet(true); + } + if (incoming.get(6)) { + struct.catalogSchema = new CatalogSchemaObject(); + struct.catalogSchema.read(iprot); + struct.setCatalogSchemaIsSet(true); + } + if (incoming.get(7)) { + struct.catalogTable = new CatalogTableObject(); + struct.catalogTable.read(iprot); + struct.setCatalogTableIsSet(true); + } + if (incoming.get(8)) { + struct.catalogFunction = new CatalogFunctionObject(); + struct.catalogFunction.read(iprot); + struct.setCatalogFunctionIsSet(true); + } + if (incoming.get(9)) { + { + org.apache.thrift.protocol.TList _list477 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.catalogPartitions = new ArrayList(_list477.size); + CatalogPartitionObject _elem478; + for (int _i479 = 0; _i479 < _list477.size; ++_i479) + { + _elem478 = new CatalogPartitionObject(); + _elem478.read(iprot); + struct.catalogPartitions.add(_elem478); + } + } + struct.setCatalogPartitionsIsSet(true); + } + } + } + +} + diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/CatalogMetadataRequest.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/CatalogMetadataRequest.java new file mode 100644 index 000000000..db582c507 --- /dev/null +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/CatalogMetadataRequest.java @@ -0,0 +1,662 @@ +/** + * Autogenerated by Thrift Compiler (0.9.3) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package io.snappydata.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-10") +public class CatalogMetadataRequest implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("CatalogMetadataRequest"); + + private static final org.apache.thrift.protocol.TField SCHEMA_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("schemaName", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField NAME_OR_PATTERN_FIELD_DESC = new org.apache.thrift.protocol.TField("nameOrPattern", org.apache.thrift.protocol.TType.STRING, (short)2); + private static final org.apache.thrift.protocol.TField PROPERTIES_FIELD_DESC = new org.apache.thrift.protocol.TField("properties", org.apache.thrift.protocol.TType.MAP, (short)3); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new CatalogMetadataRequestStandardSchemeFactory()); + schemes.put(TupleScheme.class, new CatalogMetadataRequestTupleSchemeFactory()); + } + + public String schemaName; // optional + public String nameOrPattern; // optional + public Map properties; // optional + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SCHEMA_NAME((short)1, "schemaName"), + NAME_OR_PATTERN((short)2, "nameOrPattern"), + PROPERTIES((short)3, "properties"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // SCHEMA_NAME + return SCHEMA_NAME; + case 2: // NAME_OR_PATTERN + return NAME_OR_PATTERN; + case 3: // PROPERTIES + return PROPERTIES; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final _Fields optionals[] = {_Fields.SCHEMA_NAME,_Fields.NAME_OR_PATTERN,_Fields.PROPERTIES}; + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SCHEMA_NAME, new org.apache.thrift.meta_data.FieldMetaData("schemaName", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.NAME_OR_PATTERN, new org.apache.thrift.meta_data.FieldMetaData("nameOrPattern", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.PROPERTIES, new org.apache.thrift.meta_data.FieldMetaData("properties", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(CatalogMetadataRequest.class, metaDataMap); + } + + public CatalogMetadataRequest() { + } + + /** + * Performs a deep copy on other. + */ + public CatalogMetadataRequest(CatalogMetadataRequest other) { + if (other.isSetSchemaName()) { + this.schemaName = other.schemaName; + } + if (other.isSetNameOrPattern()) { + this.nameOrPattern = other.nameOrPattern; + } + if (other.isSetProperties()) { + Map __this__properties = new HashMap(other.properties); + this.properties = __this__properties; + } + } + + public CatalogMetadataRequest deepCopy() { + return new CatalogMetadataRequest(this); + } + + @Override + public void clear() { + this.schemaName = null; + this.nameOrPattern = null; + this.properties = null; + } + + public String getSchemaName() { + return this.schemaName; + } + + public CatalogMetadataRequest setSchemaName(String schemaName) { + this.schemaName = schemaName; + return this; + } + + public void unsetSchemaName() { + this.schemaName = null; + } + + /** Returns true if field schemaName is set (has been assigned a value) and false otherwise */ + public boolean isSetSchemaName() { + return this.schemaName != null; + } + + public void setSchemaNameIsSet(boolean value) { + if (!value) { + this.schemaName = null; + } + } + + public String getNameOrPattern() { + return this.nameOrPattern; + } + + public CatalogMetadataRequest setNameOrPattern(String nameOrPattern) { + this.nameOrPattern = nameOrPattern; + return this; + } + + public void unsetNameOrPattern() { + this.nameOrPattern = null; + } + + /** Returns true if field nameOrPattern is set (has been assigned a value) and false otherwise */ + public boolean isSetNameOrPattern() { + return this.nameOrPattern != null; + } + + public void setNameOrPatternIsSet(boolean value) { + if (!value) { + this.nameOrPattern = null; + } + } + + public int getPropertiesSize() { + return (this.properties == null) ? 0 : this.properties.size(); + } + + public void putToProperties(String key, String val) { + if (this.properties == null) { + this.properties = new HashMap(); + } + this.properties.put(key, val); + } + + public Map getProperties() { + return this.properties; + } + + public CatalogMetadataRequest setProperties(Map properties) { + this.properties = properties; + return this; + } + + public void unsetProperties() { + this.properties = null; + } + + /** Returns true if field properties is set (has been assigned a value) and false otherwise */ + public boolean isSetProperties() { + return this.properties != null; + } + + public void setPropertiesIsSet(boolean value) { + if (!value) { + this.properties = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SCHEMA_NAME: + if (value == null) { + unsetSchemaName(); + } else { + setSchemaName((String)value); + } + break; + + case NAME_OR_PATTERN: + if (value == null) { + unsetNameOrPattern(); + } else { + setNameOrPattern((String)value); + } + break; + + case PROPERTIES: + if (value == null) { + unsetProperties(); + } else { + setProperties((Map)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SCHEMA_NAME: + return getSchemaName(); + + case NAME_OR_PATTERN: + return getNameOrPattern(); + + case PROPERTIES: + return getProperties(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SCHEMA_NAME: + return isSetSchemaName(); + case NAME_OR_PATTERN: + return isSetNameOrPattern(); + case PROPERTIES: + return isSetProperties(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof CatalogMetadataRequest) + return this.equals((CatalogMetadataRequest)that); + return false; + } + + public boolean equals(CatalogMetadataRequest that) { + if (that == null) + return false; + + boolean this_present_schemaName = true && this.isSetSchemaName(); + boolean that_present_schemaName = true && that.isSetSchemaName(); + if (this_present_schemaName || that_present_schemaName) { + if (!(this_present_schemaName && that_present_schemaName)) + return false; + if (!this.schemaName.equals(that.schemaName)) + return false; + } + + boolean this_present_nameOrPattern = true && this.isSetNameOrPattern(); + boolean that_present_nameOrPattern = true && that.isSetNameOrPattern(); + if (this_present_nameOrPattern || that_present_nameOrPattern) { + if (!(this_present_nameOrPattern && that_present_nameOrPattern)) + return false; + if (!this.nameOrPattern.equals(that.nameOrPattern)) + return false; + } + + boolean this_present_properties = true && this.isSetProperties(); + boolean that_present_properties = true && that.isSetProperties(); + if (this_present_properties || that_present_properties) { + if (!(this_present_properties && that_present_properties)) + return false; + if (!this.properties.equals(that.properties)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_schemaName = true && (isSetSchemaName()); + list.add(present_schemaName); + if (present_schemaName) + list.add(schemaName); + + boolean present_nameOrPattern = true && (isSetNameOrPattern()); + list.add(present_nameOrPattern); + if (present_nameOrPattern) + list.add(nameOrPattern); + + boolean present_properties = true && (isSetProperties()); + list.add(present_properties); + if (present_properties) + list.add(properties); + + return list.hashCode(); + } + + @Override + public int compareTo(CatalogMetadataRequest other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetSchemaName()).compareTo(other.isSetSchemaName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSchemaName()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.schemaName, other.schemaName); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetNameOrPattern()).compareTo(other.isSetNameOrPattern()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetNameOrPattern()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.nameOrPattern, other.nameOrPattern); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetProperties()).compareTo(other.isSetProperties()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetProperties()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.properties, other.properties); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("CatalogMetadataRequest("); + boolean first = true; + + if (isSetSchemaName()) { + sb.append("schemaName:"); + if (this.schemaName == null) { + sb.append("null"); + } else { + sb.append(this.schemaName); + } + first = false; + } + if (isSetNameOrPattern()) { + if (!first) sb.append(", "); + sb.append("nameOrPattern:"); + if (this.nameOrPattern == null) { + sb.append("null"); + } else { + sb.append(this.nameOrPattern); + } + first = false; + } + if (isSetProperties()) { + if (!first) sb.append(", "); + sb.append("properties:"); + if (this.properties == null) { + sb.append("null"); + } else { + sb.append(this.properties); + } + first = false; + } + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class CatalogMetadataRequestStandardSchemeFactory implements SchemeFactory { + public CatalogMetadataRequestStandardScheme getScheme() { + return new CatalogMetadataRequestStandardScheme(); + } + } + + private static class CatalogMetadataRequestStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, CatalogMetadataRequest struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // SCHEMA_NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.schemaName = iprot.readString(); + struct.setSchemaNameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // NAME_OR_PATTERN + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.nameOrPattern = iprot.readString(); + struct.setNameOrPatternIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // PROPERTIES + if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { + { + org.apache.thrift.protocol.TMap _map410 = iprot.readMapBegin(); + struct.properties = new HashMap(2*_map410.size); + String _key411; + String _val412; + for (int _i413 = 0; _i413 < _map410.size; ++_i413) + { + _key411 = iprot.readString(); + _val412 = iprot.readString(); + struct.properties.put(_key411, _val412); + } + iprot.readMapEnd(); + } + struct.setPropertiesIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, CatalogMetadataRequest struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.schemaName != null) { + if (struct.isSetSchemaName()) { + oprot.writeFieldBegin(SCHEMA_NAME_FIELD_DESC); + oprot.writeString(struct.schemaName); + oprot.writeFieldEnd(); + } + } + if (struct.nameOrPattern != null) { + if (struct.isSetNameOrPattern()) { + oprot.writeFieldBegin(NAME_OR_PATTERN_FIELD_DESC); + oprot.writeString(struct.nameOrPattern); + oprot.writeFieldEnd(); + } + } + if (struct.properties != null) { + if (struct.isSetProperties()) { + oprot.writeFieldBegin(PROPERTIES_FIELD_DESC); + { + oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.properties.size())); + for (Map.Entry _iter414 : struct.properties.entrySet()) + { + oprot.writeString(_iter414.getKey()); + oprot.writeString(_iter414.getValue()); + } + oprot.writeMapEnd(); + } + oprot.writeFieldEnd(); + } + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class CatalogMetadataRequestTupleSchemeFactory implements SchemeFactory { + public CatalogMetadataRequestTupleScheme getScheme() { + return new CatalogMetadataRequestTupleScheme(); + } + } + + private static class CatalogMetadataRequestTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, CatalogMetadataRequest struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetSchemaName()) { + optionals.set(0); + } + if (struct.isSetNameOrPattern()) { + optionals.set(1); + } + if (struct.isSetProperties()) { + optionals.set(2); + } + oprot.writeBitSet(optionals, 3); + if (struct.isSetSchemaName()) { + oprot.writeString(struct.schemaName); + } + if (struct.isSetNameOrPattern()) { + oprot.writeString(struct.nameOrPattern); + } + if (struct.isSetProperties()) { + { + oprot.writeI32(struct.properties.size()); + for (Map.Entry _iter415 : struct.properties.entrySet()) + { + oprot.writeString(_iter415.getKey()); + oprot.writeString(_iter415.getValue()); + } + } + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, CatalogMetadataRequest struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(3); + if (incoming.get(0)) { + struct.schemaName = iprot.readString(); + struct.setSchemaNameIsSet(true); + } + if (incoming.get(1)) { + struct.nameOrPattern = iprot.readString(); + struct.setNameOrPatternIsSet(true); + } + if (incoming.get(2)) { + { + org.apache.thrift.protocol.TMap _map416 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.properties = new HashMap(2*_map416.size); + String _key417; + String _val418; + for (int _i419 = 0; _i419 < _map416.size; ++_i419) + { + _key417 = iprot.readString(); + _val418 = iprot.readString(); + struct.properties.put(_key417, _val418); + } + } + struct.setPropertiesIsSet(true); + } + } + } + +} + diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/CatalogPartitionObject.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/CatalogPartitionObject.java new file mode 100644 index 000000000..53002fd2c --- /dev/null +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/CatalogPartitionObject.java @@ -0,0 +1,702 @@ +/** + * Autogenerated by Thrift Compiler (0.9.3) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package io.snappydata.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-10") +public class CatalogPartitionObject implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("CatalogPartitionObject"); + + private static final org.apache.thrift.protocol.TField SPEC_FIELD_DESC = new org.apache.thrift.protocol.TField("spec", org.apache.thrift.protocol.TType.MAP, (short)1); + private static final org.apache.thrift.protocol.TField STORAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("storage", org.apache.thrift.protocol.TType.STRUCT, (short)2); + private static final org.apache.thrift.protocol.TField PARAMETERS_FIELD_DESC = new org.apache.thrift.protocol.TField("parameters", org.apache.thrift.protocol.TType.MAP, (short)3); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new CatalogPartitionObjectStandardSchemeFactory()); + schemes.put(TupleScheme.class, new CatalogPartitionObjectTupleSchemeFactory()); + } + + public Map spec; // required + public CatalogStorage storage; // required + public Map parameters; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SPEC((short)1, "spec"), + STORAGE((short)2, "storage"), + PARAMETERS((short)3, "parameters"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // SPEC + return SPEC; + case 2: // STORAGE + return STORAGE; + case 3: // PARAMETERS + return PARAMETERS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SPEC, new org.apache.thrift.meta_data.FieldMetaData("spec", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); + tmpMap.put(_Fields.STORAGE, new org.apache.thrift.meta_data.FieldMetaData("storage", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, CatalogStorage.class))); + tmpMap.put(_Fields.PARAMETERS, new org.apache.thrift.meta_data.FieldMetaData("parameters", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(CatalogPartitionObject.class, metaDataMap); + } + + public CatalogPartitionObject() { + } + + public CatalogPartitionObject( + Map spec, + CatalogStorage storage, + Map parameters) + { + this(); + this.spec = spec; + this.storage = storage; + this.parameters = parameters; + } + + /** + * Performs a deep copy on other. + */ + public CatalogPartitionObject(CatalogPartitionObject other) { + if (other.isSetSpec()) { + Map __this__spec = new HashMap(other.spec); + this.spec = __this__spec; + } + if (other.isSetStorage()) { + this.storage = new CatalogStorage(other.storage); + } + if (other.isSetParameters()) { + Map __this__parameters = new HashMap(other.parameters); + this.parameters = __this__parameters; + } + } + + public CatalogPartitionObject deepCopy() { + return new CatalogPartitionObject(this); + } + + @Override + public void clear() { + this.spec = null; + this.storage = null; + this.parameters = null; + } + + public int getSpecSize() { + return (this.spec == null) ? 0 : this.spec.size(); + } + + public void putToSpec(String key, String val) { + if (this.spec == null) { + this.spec = new HashMap(); + } + this.spec.put(key, val); + } + + public Map getSpec() { + return this.spec; + } + + public CatalogPartitionObject setSpec(Map spec) { + this.spec = spec; + return this; + } + + public void unsetSpec() { + this.spec = null; + } + + /** Returns true if field spec is set (has been assigned a value) and false otherwise */ + public boolean isSetSpec() { + return this.spec != null; + } + + public void setSpecIsSet(boolean value) { + if (!value) { + this.spec = null; + } + } + + public CatalogStorage getStorage() { + return this.storage; + } + + public CatalogPartitionObject setStorage(CatalogStorage storage) { + this.storage = storage; + return this; + } + + public void unsetStorage() { + this.storage = null; + } + + /** Returns true if field storage is set (has been assigned a value) and false otherwise */ + public boolean isSetStorage() { + return this.storage != null; + } + + public void setStorageIsSet(boolean value) { + if (!value) { + this.storage = null; + } + } + + public int getParametersSize() { + return (this.parameters == null) ? 0 : this.parameters.size(); + } + + public void putToParameters(String key, String val) { + if (this.parameters == null) { + this.parameters = new HashMap(); + } + this.parameters.put(key, val); + } + + public Map getParameters() { + return this.parameters; + } + + public CatalogPartitionObject setParameters(Map parameters) { + this.parameters = parameters; + return this; + } + + public void unsetParameters() { + this.parameters = null; + } + + /** Returns true if field parameters is set (has been assigned a value) and false otherwise */ + public boolean isSetParameters() { + return this.parameters != null; + } + + public void setParametersIsSet(boolean value) { + if (!value) { + this.parameters = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SPEC: + if (value == null) { + unsetSpec(); + } else { + setSpec((Map)value); + } + break; + + case STORAGE: + if (value == null) { + unsetStorage(); + } else { + setStorage((CatalogStorage)value); + } + break; + + case PARAMETERS: + if (value == null) { + unsetParameters(); + } else { + setParameters((Map)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SPEC: + return getSpec(); + + case STORAGE: + return getStorage(); + + case PARAMETERS: + return getParameters(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SPEC: + return isSetSpec(); + case STORAGE: + return isSetStorage(); + case PARAMETERS: + return isSetParameters(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof CatalogPartitionObject) + return this.equals((CatalogPartitionObject)that); + return false; + } + + public boolean equals(CatalogPartitionObject that) { + if (that == null) + return false; + + boolean this_present_spec = true && this.isSetSpec(); + boolean that_present_spec = true && that.isSetSpec(); + if (this_present_spec || that_present_spec) { + if (!(this_present_spec && that_present_spec)) + return false; + if (!this.spec.equals(that.spec)) + return false; + } + + boolean this_present_storage = true && this.isSetStorage(); + boolean that_present_storage = true && that.isSetStorage(); + if (this_present_storage || that_present_storage) { + if (!(this_present_storage && that_present_storage)) + return false; + if (!this.storage.equals(that.storage)) + return false; + } + + boolean this_present_parameters = true && this.isSetParameters(); + boolean that_present_parameters = true && that.isSetParameters(); + if (this_present_parameters || that_present_parameters) { + if (!(this_present_parameters && that_present_parameters)) + return false; + if (!this.parameters.equals(that.parameters)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_spec = true && (isSetSpec()); + list.add(present_spec); + if (present_spec) + list.add(spec); + + boolean present_storage = true && (isSetStorage()); + list.add(present_storage); + if (present_storage) + list.add(storage); + + boolean present_parameters = true && (isSetParameters()); + list.add(present_parameters); + if (present_parameters) + list.add(parameters); + + return list.hashCode(); + } + + @Override + public int compareTo(CatalogPartitionObject other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetSpec()).compareTo(other.isSetSpec()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSpec()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.spec, other.spec); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetStorage()).compareTo(other.isSetStorage()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetStorage()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.storage, other.storage); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetParameters()).compareTo(other.isSetParameters()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetParameters()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.parameters, other.parameters); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("CatalogPartitionObject("); + boolean first = true; + + sb.append("spec:"); + if (this.spec == null) { + sb.append("null"); + } else { + sb.append(this.spec); + } + first = false; + if (!first) sb.append(", "); + sb.append("storage:"); + if (this.storage == null) { + sb.append("null"); + } else { + sb.append(this.storage); + } + first = false; + if (!first) sb.append(", "); + sb.append("parameters:"); + if (this.parameters == null) { + sb.append("null"); + } else { + sb.append(this.parameters); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (spec == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'spec' was not present! Struct: " + toString()); + } + if (storage == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'storage' was not present! Struct: " + toString()); + } + if (parameters == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'parameters' was not present! Struct: " + toString()); + } + // check for sub-struct validity + if (storage != null) { + storage.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class CatalogPartitionObjectStandardSchemeFactory implements SchemeFactory { + public CatalogPartitionObjectStandardScheme getScheme() { + return new CatalogPartitionObjectStandardScheme(); + } + } + + private static class CatalogPartitionObjectStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, CatalogPartitionObject struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // SPEC + if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { + { + org.apache.thrift.protocol.TMap _map390 = iprot.readMapBegin(); + struct.spec = new HashMap(2*_map390.size); + String _key391; + String _val392; + for (int _i393 = 0; _i393 < _map390.size; ++_i393) + { + _key391 = iprot.readString(); + _val392 = iprot.readString(); + struct.spec.put(_key391, _val392); + } + iprot.readMapEnd(); + } + struct.setSpecIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // STORAGE + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.storage = new CatalogStorage(); + struct.storage.read(iprot); + struct.setStorageIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // PARAMETERS + if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { + { + org.apache.thrift.protocol.TMap _map394 = iprot.readMapBegin(); + struct.parameters = new HashMap(2*_map394.size); + String _key395; + String _val396; + for (int _i397 = 0; _i397 < _map394.size; ++_i397) + { + _key395 = iprot.readString(); + _val396 = iprot.readString(); + struct.parameters.put(_key395, _val396); + } + iprot.readMapEnd(); + } + struct.setParametersIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, CatalogPartitionObject struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.spec != null) { + oprot.writeFieldBegin(SPEC_FIELD_DESC); + { + oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.spec.size())); + for (Map.Entry _iter398 : struct.spec.entrySet()) + { + oprot.writeString(_iter398.getKey()); + oprot.writeString(_iter398.getValue()); + } + oprot.writeMapEnd(); + } + oprot.writeFieldEnd(); + } + if (struct.storage != null) { + oprot.writeFieldBegin(STORAGE_FIELD_DESC); + struct.storage.write(oprot); + oprot.writeFieldEnd(); + } + if (struct.parameters != null) { + oprot.writeFieldBegin(PARAMETERS_FIELD_DESC); + { + oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.parameters.size())); + for (Map.Entry _iter399 : struct.parameters.entrySet()) + { + oprot.writeString(_iter399.getKey()); + oprot.writeString(_iter399.getValue()); + } + oprot.writeMapEnd(); + } + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class CatalogPartitionObjectTupleSchemeFactory implements SchemeFactory { + public CatalogPartitionObjectTupleScheme getScheme() { + return new CatalogPartitionObjectTupleScheme(); + } + } + + private static class CatalogPartitionObjectTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, CatalogPartitionObject struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + { + oprot.writeI32(struct.spec.size()); + for (Map.Entry _iter400 : struct.spec.entrySet()) + { + oprot.writeString(_iter400.getKey()); + oprot.writeString(_iter400.getValue()); + } + } + struct.storage.write(oprot); + { + oprot.writeI32(struct.parameters.size()); + for (Map.Entry _iter401 : struct.parameters.entrySet()) + { + oprot.writeString(_iter401.getKey()); + oprot.writeString(_iter401.getValue()); + } + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, CatalogPartitionObject struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + { + org.apache.thrift.protocol.TMap _map402 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.spec = new HashMap(2*_map402.size); + String _key403; + String _val404; + for (int _i405 = 0; _i405 < _map402.size; ++_i405) + { + _key403 = iprot.readString(); + _val404 = iprot.readString(); + struct.spec.put(_key403, _val404); + } + } + struct.setSpecIsSet(true); + struct.storage = new CatalogStorage(); + struct.storage.read(iprot); + struct.setStorageIsSet(true); + { + org.apache.thrift.protocol.TMap _map406 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.parameters = new HashMap(2*_map406.size); + String _key407; + String _val408; + for (int _i409 = 0; _i409 < _map406.size; ++_i409) + { + _key407 = iprot.readString(); + _val408 = iprot.readString(); + struct.parameters.put(_key407, _val408); + } + } + struct.setParametersIsSet(true); + } + } + +} + diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/CatalogSchemaObject.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/CatalogSchemaObject.java new file mode 100644 index 000000000..6b28583f7 --- /dev/null +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/CatalogSchemaObject.java @@ -0,0 +1,746 @@ +/** + * Autogenerated by Thrift Compiler (0.9.3) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package io.snappydata.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-10") +public class CatalogSchemaObject implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("CatalogSchemaObject"); + + private static final org.apache.thrift.protocol.TField NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("name", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField DESCRIPTION_FIELD_DESC = new org.apache.thrift.protocol.TField("description", org.apache.thrift.protocol.TType.STRING, (short)2); + private static final org.apache.thrift.protocol.TField LOCATION_URI_FIELD_DESC = new org.apache.thrift.protocol.TField("locationUri", org.apache.thrift.protocol.TType.STRING, (short)3); + private static final org.apache.thrift.protocol.TField PROPERTIES_FIELD_DESC = new org.apache.thrift.protocol.TField("properties", org.apache.thrift.protocol.TType.MAP, (short)4); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new CatalogSchemaObjectStandardSchemeFactory()); + schemes.put(TupleScheme.class, new CatalogSchemaObjectTupleSchemeFactory()); + } + + public String name; // required + public String description; // required + public String locationUri; // required + public Map properties; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + NAME((short)1, "name"), + DESCRIPTION((short)2, "description"), + LOCATION_URI((short)3, "locationUri"), + PROPERTIES((short)4, "properties"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // NAME + return NAME; + case 2: // DESCRIPTION + return DESCRIPTION; + case 3: // LOCATION_URI + return LOCATION_URI; + case 4: // PROPERTIES + return PROPERTIES; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.NAME, new org.apache.thrift.meta_data.FieldMetaData("name", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.DESCRIPTION, new org.apache.thrift.meta_data.FieldMetaData("description", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.LOCATION_URI, new org.apache.thrift.meta_data.FieldMetaData("locationUri", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.PROPERTIES, new org.apache.thrift.meta_data.FieldMetaData("properties", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(CatalogSchemaObject.class, metaDataMap); + } + + public CatalogSchemaObject() { + } + + public CatalogSchemaObject( + String name, + String description, + String locationUri, + Map properties) + { + this(); + this.name = name; + this.description = description; + this.locationUri = locationUri; + this.properties = properties; + } + + /** + * Performs a deep copy on other. + */ + public CatalogSchemaObject(CatalogSchemaObject other) { + if (other.isSetName()) { + this.name = other.name; + } + if (other.isSetDescription()) { + this.description = other.description; + } + if (other.isSetLocationUri()) { + this.locationUri = other.locationUri; + } + if (other.isSetProperties()) { + Map __this__properties = new HashMap(other.properties); + this.properties = __this__properties; + } + } + + public CatalogSchemaObject deepCopy() { + return new CatalogSchemaObject(this); + } + + @Override + public void clear() { + this.name = null; + this.description = null; + this.locationUri = null; + this.properties = null; + } + + public String getName() { + return this.name; + } + + public CatalogSchemaObject setName(String name) { + this.name = name; + return this; + } + + public void unsetName() { + this.name = null; + } + + /** Returns true if field name is set (has been assigned a value) and false otherwise */ + public boolean isSetName() { + return this.name != null; + } + + public void setNameIsSet(boolean value) { + if (!value) { + this.name = null; + } + } + + public String getDescription() { + return this.description; + } + + public CatalogSchemaObject setDescription(String description) { + this.description = description; + return this; + } + + public void unsetDescription() { + this.description = null; + } + + /** Returns true if field description is set (has been assigned a value) and false otherwise */ + public boolean isSetDescription() { + return this.description != null; + } + + public void setDescriptionIsSet(boolean value) { + if (!value) { + this.description = null; + } + } + + public String getLocationUri() { + return this.locationUri; + } + + public CatalogSchemaObject setLocationUri(String locationUri) { + this.locationUri = locationUri; + return this; + } + + public void unsetLocationUri() { + this.locationUri = null; + } + + /** Returns true if field locationUri is set (has been assigned a value) and false otherwise */ + public boolean isSetLocationUri() { + return this.locationUri != null; + } + + public void setLocationUriIsSet(boolean value) { + if (!value) { + this.locationUri = null; + } + } + + public int getPropertiesSize() { + return (this.properties == null) ? 0 : this.properties.size(); + } + + public void putToProperties(String key, String val) { + if (this.properties == null) { + this.properties = new HashMap(); + } + this.properties.put(key, val); + } + + public Map getProperties() { + return this.properties; + } + + public CatalogSchemaObject setProperties(Map properties) { + this.properties = properties; + return this; + } + + public void unsetProperties() { + this.properties = null; + } + + /** Returns true if field properties is set (has been assigned a value) and false otherwise */ + public boolean isSetProperties() { + return this.properties != null; + } + + public void setPropertiesIsSet(boolean value) { + if (!value) { + this.properties = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case NAME: + if (value == null) { + unsetName(); + } else { + setName((String)value); + } + break; + + case DESCRIPTION: + if (value == null) { + unsetDescription(); + } else { + setDescription((String)value); + } + break; + + case LOCATION_URI: + if (value == null) { + unsetLocationUri(); + } else { + setLocationUri((String)value); + } + break; + + case PROPERTIES: + if (value == null) { + unsetProperties(); + } else { + setProperties((Map)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case NAME: + return getName(); + + case DESCRIPTION: + return getDescription(); + + case LOCATION_URI: + return getLocationUri(); + + case PROPERTIES: + return getProperties(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case NAME: + return isSetName(); + case DESCRIPTION: + return isSetDescription(); + case LOCATION_URI: + return isSetLocationUri(); + case PROPERTIES: + return isSetProperties(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof CatalogSchemaObject) + return this.equals((CatalogSchemaObject)that); + return false; + } + + public boolean equals(CatalogSchemaObject that) { + if (that == null) + return false; + + boolean this_present_name = true && this.isSetName(); + boolean that_present_name = true && that.isSetName(); + if (this_present_name || that_present_name) { + if (!(this_present_name && that_present_name)) + return false; + if (!this.name.equals(that.name)) + return false; + } + + boolean this_present_description = true && this.isSetDescription(); + boolean that_present_description = true && that.isSetDescription(); + if (this_present_description || that_present_description) { + if (!(this_present_description && that_present_description)) + return false; + if (!this.description.equals(that.description)) + return false; + } + + boolean this_present_locationUri = true && this.isSetLocationUri(); + boolean that_present_locationUri = true && that.isSetLocationUri(); + if (this_present_locationUri || that_present_locationUri) { + if (!(this_present_locationUri && that_present_locationUri)) + return false; + if (!this.locationUri.equals(that.locationUri)) + return false; + } + + boolean this_present_properties = true && this.isSetProperties(); + boolean that_present_properties = true && that.isSetProperties(); + if (this_present_properties || that_present_properties) { + if (!(this_present_properties && that_present_properties)) + return false; + if (!this.properties.equals(that.properties)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_name = true && (isSetName()); + list.add(present_name); + if (present_name) + list.add(name); + + boolean present_description = true && (isSetDescription()); + list.add(present_description); + if (present_description) + list.add(description); + + boolean present_locationUri = true && (isSetLocationUri()); + list.add(present_locationUri); + if (present_locationUri) + list.add(locationUri); + + boolean present_properties = true && (isSetProperties()); + list.add(present_properties); + if (present_properties) + list.add(properties); + + return list.hashCode(); + } + + @Override + public int compareTo(CatalogSchemaObject other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetName()).compareTo(other.isSetName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetName()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.name, other.name); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetDescription()).compareTo(other.isSetDescription()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetDescription()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.description, other.description); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetLocationUri()).compareTo(other.isSetLocationUri()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetLocationUri()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.locationUri, other.locationUri); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetProperties()).compareTo(other.isSetProperties()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetProperties()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.properties, other.properties); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("CatalogSchemaObject("); + boolean first = true; + + sb.append("name:"); + if (this.name == null) { + sb.append("null"); + } else { + sb.append(this.name); + } + first = false; + if (!first) sb.append(", "); + sb.append("description:"); + if (this.description == null) { + sb.append("null"); + } else { + sb.append(this.description); + } + first = false; + if (!first) sb.append(", "); + sb.append("locationUri:"); + if (this.locationUri == null) { + sb.append("null"); + } else { + sb.append(this.locationUri); + } + first = false; + if (!first) sb.append(", "); + sb.append("properties:"); + if (this.properties == null) { + sb.append("null"); + } else { + sb.append(this.properties); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (name == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'name' was not present! Struct: " + toString()); + } + if (description == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'description' was not present! Struct: " + toString()); + } + if (locationUri == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'locationUri' was not present! Struct: " + toString()); + } + if (properties == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'properties' was not present! Struct: " + toString()); + } + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class CatalogSchemaObjectStandardSchemeFactory implements SchemeFactory { + public CatalogSchemaObjectStandardScheme getScheme() { + return new CatalogSchemaObjectStandardScheme(); + } + } + + private static class CatalogSchemaObjectStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, CatalogSchemaObject struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.name = iprot.readString(); + struct.setNameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // DESCRIPTION + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.description = iprot.readString(); + struct.setDescriptionIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // LOCATION_URI + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.locationUri = iprot.readString(); + struct.setLocationUriIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 4: // PROPERTIES + if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { + { + org.apache.thrift.protocol.TMap _map288 = iprot.readMapBegin(); + struct.properties = new HashMap(2*_map288.size); + String _key289; + String _val290; + for (int _i291 = 0; _i291 < _map288.size; ++_i291) + { + _key289 = iprot.readString(); + _val290 = iprot.readString(); + struct.properties.put(_key289, _val290); + } + iprot.readMapEnd(); + } + struct.setPropertiesIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, CatalogSchemaObject struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.name != null) { + oprot.writeFieldBegin(NAME_FIELD_DESC); + oprot.writeString(struct.name); + oprot.writeFieldEnd(); + } + if (struct.description != null) { + oprot.writeFieldBegin(DESCRIPTION_FIELD_DESC); + oprot.writeString(struct.description); + oprot.writeFieldEnd(); + } + if (struct.locationUri != null) { + oprot.writeFieldBegin(LOCATION_URI_FIELD_DESC); + oprot.writeString(struct.locationUri); + oprot.writeFieldEnd(); + } + if (struct.properties != null) { + oprot.writeFieldBegin(PROPERTIES_FIELD_DESC); + { + oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.properties.size())); + for (Map.Entry _iter292 : struct.properties.entrySet()) + { + oprot.writeString(_iter292.getKey()); + oprot.writeString(_iter292.getValue()); + } + oprot.writeMapEnd(); + } + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class CatalogSchemaObjectTupleSchemeFactory implements SchemeFactory { + public CatalogSchemaObjectTupleScheme getScheme() { + return new CatalogSchemaObjectTupleScheme(); + } + } + + private static class CatalogSchemaObjectTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, CatalogSchemaObject struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + oprot.writeString(struct.name); + oprot.writeString(struct.description); + oprot.writeString(struct.locationUri); + { + oprot.writeI32(struct.properties.size()); + for (Map.Entry _iter293 : struct.properties.entrySet()) + { + oprot.writeString(_iter293.getKey()); + oprot.writeString(_iter293.getValue()); + } + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, CatalogSchemaObject struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.name = iprot.readString(); + struct.setNameIsSet(true); + struct.description = iprot.readString(); + struct.setDescriptionIsSet(true); + struct.locationUri = iprot.readString(); + struct.setLocationUriIsSet(true); + { + org.apache.thrift.protocol.TMap _map294 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.properties = new HashMap(2*_map294.size); + String _key295; + String _val296; + for (int _i297 = 0; _i297 < _map294.size; ++_i297) + { + _key295 = iprot.readString(); + _val296 = iprot.readString(); + struct.properties.put(_key295, _val296); + } + } + struct.setPropertiesIsSet(true); + } + } + +} + diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/CatalogStorage.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/CatalogStorage.java new file mode 100644 index 000000000..b61607238 --- /dev/null +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/CatalogStorage.java @@ -0,0 +1,975 @@ +/** + * Autogenerated by Thrift Compiler (0.9.3) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package io.snappydata.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-10") +public class CatalogStorage implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("CatalogStorage"); + + private static final org.apache.thrift.protocol.TField PROPERTIES_FIELD_DESC = new org.apache.thrift.protocol.TField("properties", org.apache.thrift.protocol.TType.MAP, (short)1); + private static final org.apache.thrift.protocol.TField COMPRESSED_FIELD_DESC = new org.apache.thrift.protocol.TField("compressed", org.apache.thrift.protocol.TType.BOOL, (short)2); + private static final org.apache.thrift.protocol.TField LOCATION_URI_FIELD_DESC = new org.apache.thrift.protocol.TField("locationUri", org.apache.thrift.protocol.TType.STRING, (short)3); + private static final org.apache.thrift.protocol.TField INPUT_FORMAT_FIELD_DESC = new org.apache.thrift.protocol.TField("inputFormat", org.apache.thrift.protocol.TType.STRING, (short)4); + private static final org.apache.thrift.protocol.TField OUTPUT_FORMAT_FIELD_DESC = new org.apache.thrift.protocol.TField("outputFormat", org.apache.thrift.protocol.TType.STRING, (short)5); + private static final org.apache.thrift.protocol.TField SERDE_FIELD_DESC = new org.apache.thrift.protocol.TField("serde", org.apache.thrift.protocol.TType.STRING, (short)6); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new CatalogStorageStandardSchemeFactory()); + schemes.put(TupleScheme.class, new CatalogStorageTupleSchemeFactory()); + } + + public Map properties; // required + public boolean compressed; // required + public String locationUri; // optional + public String inputFormat; // optional + public String outputFormat; // optional + public String serde; // optional + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + PROPERTIES((short)1, "properties"), + COMPRESSED((short)2, "compressed"), + LOCATION_URI((short)3, "locationUri"), + INPUT_FORMAT((short)4, "inputFormat"), + OUTPUT_FORMAT((short)5, "outputFormat"), + SERDE((short)6, "serde"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // PROPERTIES + return PROPERTIES; + case 2: // COMPRESSED + return COMPRESSED; + case 3: // LOCATION_URI + return LOCATION_URI; + case 4: // INPUT_FORMAT + return INPUT_FORMAT; + case 5: // OUTPUT_FORMAT + return OUTPUT_FORMAT; + case 6: // SERDE + return SERDE; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __COMPRESSED_ISSET_ID = 0; + private byte __isset_bitfield = 0; + private static final _Fields optionals[] = {_Fields.LOCATION_URI,_Fields.INPUT_FORMAT,_Fields.OUTPUT_FORMAT,_Fields.SERDE}; + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.PROPERTIES, new org.apache.thrift.meta_data.FieldMetaData("properties", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); + tmpMap.put(_Fields.COMPRESSED, new org.apache.thrift.meta_data.FieldMetaData("compressed", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); + tmpMap.put(_Fields.LOCATION_URI, new org.apache.thrift.meta_data.FieldMetaData("locationUri", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.INPUT_FORMAT, new org.apache.thrift.meta_data.FieldMetaData("inputFormat", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.OUTPUT_FORMAT, new org.apache.thrift.meta_data.FieldMetaData("outputFormat", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.SERDE, new org.apache.thrift.meta_data.FieldMetaData("serde", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(CatalogStorage.class, metaDataMap); + } + + public CatalogStorage() { + } + + public CatalogStorage( + Map properties, + boolean compressed) + { + this(); + this.properties = properties; + this.compressed = compressed; + setCompressedIsSet(true); + } + + /** + * Performs a deep copy on other. + */ + public CatalogStorage(CatalogStorage other) { + __isset_bitfield = other.__isset_bitfield; + if (other.isSetProperties()) { + Map __this__properties = new HashMap(other.properties); + this.properties = __this__properties; + } + this.compressed = other.compressed; + if (other.isSetLocationUri()) { + this.locationUri = other.locationUri; + } + if (other.isSetInputFormat()) { + this.inputFormat = other.inputFormat; + } + if (other.isSetOutputFormat()) { + this.outputFormat = other.outputFormat; + } + if (other.isSetSerde()) { + this.serde = other.serde; + } + } + + public CatalogStorage deepCopy() { + return new CatalogStorage(this); + } + + @Override + public void clear() { + this.properties = null; + setCompressedIsSet(false); + this.compressed = false; + this.locationUri = null; + this.inputFormat = null; + this.outputFormat = null; + this.serde = null; + } + + public int getPropertiesSize() { + return (this.properties == null) ? 0 : this.properties.size(); + } + + public void putToProperties(String key, String val) { + if (this.properties == null) { + this.properties = new HashMap(); + } + this.properties.put(key, val); + } + + public Map getProperties() { + return this.properties; + } + + public CatalogStorage setProperties(Map properties) { + this.properties = properties; + return this; + } + + public void unsetProperties() { + this.properties = null; + } + + /** Returns true if field properties is set (has been assigned a value) and false otherwise */ + public boolean isSetProperties() { + return this.properties != null; + } + + public void setPropertiesIsSet(boolean value) { + if (!value) { + this.properties = null; + } + } + + public boolean isCompressed() { + return this.compressed; + } + + public CatalogStorage setCompressed(boolean compressed) { + this.compressed = compressed; + setCompressedIsSet(true); + return this; + } + + public void unsetCompressed() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __COMPRESSED_ISSET_ID); + } + + /** Returns true if field compressed is set (has been assigned a value) and false otherwise */ + public boolean isSetCompressed() { + return EncodingUtils.testBit(__isset_bitfield, __COMPRESSED_ISSET_ID); + } + + public void setCompressedIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __COMPRESSED_ISSET_ID, value); + } + + public String getLocationUri() { + return this.locationUri; + } + + public CatalogStorage setLocationUri(String locationUri) { + this.locationUri = locationUri; + return this; + } + + public void unsetLocationUri() { + this.locationUri = null; + } + + /** Returns true if field locationUri is set (has been assigned a value) and false otherwise */ + public boolean isSetLocationUri() { + return this.locationUri != null; + } + + public void setLocationUriIsSet(boolean value) { + if (!value) { + this.locationUri = null; + } + } + + public String getInputFormat() { + return this.inputFormat; + } + + public CatalogStorage setInputFormat(String inputFormat) { + this.inputFormat = inputFormat; + return this; + } + + public void unsetInputFormat() { + this.inputFormat = null; + } + + /** Returns true if field inputFormat is set (has been assigned a value) and false otherwise */ + public boolean isSetInputFormat() { + return this.inputFormat != null; + } + + public void setInputFormatIsSet(boolean value) { + if (!value) { + this.inputFormat = null; + } + } + + public String getOutputFormat() { + return this.outputFormat; + } + + public CatalogStorage setOutputFormat(String outputFormat) { + this.outputFormat = outputFormat; + return this; + } + + public void unsetOutputFormat() { + this.outputFormat = null; + } + + /** Returns true if field outputFormat is set (has been assigned a value) and false otherwise */ + public boolean isSetOutputFormat() { + return this.outputFormat != null; + } + + public void setOutputFormatIsSet(boolean value) { + if (!value) { + this.outputFormat = null; + } + } + + public String getSerde() { + return this.serde; + } + + public CatalogStorage setSerde(String serde) { + this.serde = serde; + return this; + } + + public void unsetSerde() { + this.serde = null; + } + + /** Returns true if field serde is set (has been assigned a value) and false otherwise */ + public boolean isSetSerde() { + return this.serde != null; + } + + public void setSerdeIsSet(boolean value) { + if (!value) { + this.serde = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case PROPERTIES: + if (value == null) { + unsetProperties(); + } else { + setProperties((Map)value); + } + break; + + case COMPRESSED: + if (value == null) { + unsetCompressed(); + } else { + setCompressed((Boolean)value); + } + break; + + case LOCATION_URI: + if (value == null) { + unsetLocationUri(); + } else { + setLocationUri((String)value); + } + break; + + case INPUT_FORMAT: + if (value == null) { + unsetInputFormat(); + } else { + setInputFormat((String)value); + } + break; + + case OUTPUT_FORMAT: + if (value == null) { + unsetOutputFormat(); + } else { + setOutputFormat((String)value); + } + break; + + case SERDE: + if (value == null) { + unsetSerde(); + } else { + setSerde((String)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case PROPERTIES: + return getProperties(); + + case COMPRESSED: + return isCompressed(); + + case LOCATION_URI: + return getLocationUri(); + + case INPUT_FORMAT: + return getInputFormat(); + + case OUTPUT_FORMAT: + return getOutputFormat(); + + case SERDE: + return getSerde(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case PROPERTIES: + return isSetProperties(); + case COMPRESSED: + return isSetCompressed(); + case LOCATION_URI: + return isSetLocationUri(); + case INPUT_FORMAT: + return isSetInputFormat(); + case OUTPUT_FORMAT: + return isSetOutputFormat(); + case SERDE: + return isSetSerde(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof CatalogStorage) + return this.equals((CatalogStorage)that); + return false; + } + + public boolean equals(CatalogStorage that) { + if (that == null) + return false; + + boolean this_present_properties = true && this.isSetProperties(); + boolean that_present_properties = true && that.isSetProperties(); + if (this_present_properties || that_present_properties) { + if (!(this_present_properties && that_present_properties)) + return false; + if (!this.properties.equals(that.properties)) + return false; + } + + boolean this_present_compressed = true; + boolean that_present_compressed = true; + if (this_present_compressed || that_present_compressed) { + if (!(this_present_compressed && that_present_compressed)) + return false; + if (this.compressed != that.compressed) + return false; + } + + boolean this_present_locationUri = true && this.isSetLocationUri(); + boolean that_present_locationUri = true && that.isSetLocationUri(); + if (this_present_locationUri || that_present_locationUri) { + if (!(this_present_locationUri && that_present_locationUri)) + return false; + if (!this.locationUri.equals(that.locationUri)) + return false; + } + + boolean this_present_inputFormat = true && this.isSetInputFormat(); + boolean that_present_inputFormat = true && that.isSetInputFormat(); + if (this_present_inputFormat || that_present_inputFormat) { + if (!(this_present_inputFormat && that_present_inputFormat)) + return false; + if (!this.inputFormat.equals(that.inputFormat)) + return false; + } + + boolean this_present_outputFormat = true && this.isSetOutputFormat(); + boolean that_present_outputFormat = true && that.isSetOutputFormat(); + if (this_present_outputFormat || that_present_outputFormat) { + if (!(this_present_outputFormat && that_present_outputFormat)) + return false; + if (!this.outputFormat.equals(that.outputFormat)) + return false; + } + + boolean this_present_serde = true && this.isSetSerde(); + boolean that_present_serde = true && that.isSetSerde(); + if (this_present_serde || that_present_serde) { + if (!(this_present_serde && that_present_serde)) + return false; + if (!this.serde.equals(that.serde)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_properties = true && (isSetProperties()); + list.add(present_properties); + if (present_properties) + list.add(properties); + + boolean present_compressed = true; + list.add(present_compressed); + if (present_compressed) + list.add(compressed); + + boolean present_locationUri = true && (isSetLocationUri()); + list.add(present_locationUri); + if (present_locationUri) + list.add(locationUri); + + boolean present_inputFormat = true && (isSetInputFormat()); + list.add(present_inputFormat); + if (present_inputFormat) + list.add(inputFormat); + + boolean present_outputFormat = true && (isSetOutputFormat()); + list.add(present_outputFormat); + if (present_outputFormat) + list.add(outputFormat); + + boolean present_serde = true && (isSetSerde()); + list.add(present_serde); + if (present_serde) + list.add(serde); + + return list.hashCode(); + } + + @Override + public int compareTo(CatalogStorage other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetProperties()).compareTo(other.isSetProperties()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetProperties()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.properties, other.properties); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetCompressed()).compareTo(other.isSetCompressed()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetCompressed()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.compressed, other.compressed); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetLocationUri()).compareTo(other.isSetLocationUri()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetLocationUri()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.locationUri, other.locationUri); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetInputFormat()).compareTo(other.isSetInputFormat()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetInputFormat()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.inputFormat, other.inputFormat); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetOutputFormat()).compareTo(other.isSetOutputFormat()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetOutputFormat()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.outputFormat, other.outputFormat); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetSerde()).compareTo(other.isSetSerde()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSerde()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.serde, other.serde); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("CatalogStorage("); + boolean first = true; + + sb.append("properties:"); + if (this.properties == null) { + sb.append("null"); + } else { + sb.append(this.properties); + } + first = false; + if (!first) sb.append(", "); + sb.append("compressed:"); + sb.append(this.compressed); + first = false; + if (isSetLocationUri()) { + if (!first) sb.append(", "); + sb.append("locationUri:"); + if (this.locationUri == null) { + sb.append("null"); + } else { + sb.append(this.locationUri); + } + first = false; + } + if (isSetInputFormat()) { + if (!first) sb.append(", "); + sb.append("inputFormat:"); + if (this.inputFormat == null) { + sb.append("null"); + } else { + sb.append(this.inputFormat); + } + first = false; + } + if (isSetOutputFormat()) { + if (!first) sb.append(", "); + sb.append("outputFormat:"); + if (this.outputFormat == null) { + sb.append("null"); + } else { + sb.append(this.outputFormat); + } + first = false; + } + if (isSetSerde()) { + if (!first) sb.append(", "); + sb.append("serde:"); + if (this.serde == null) { + sb.append("null"); + } else { + sb.append(this.serde); + } + first = false; + } + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (properties == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'properties' was not present! Struct: " + toString()); + } + // alas, we cannot check 'compressed' because it's a primitive and you chose the non-beans generator. + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bitfield = 0; + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class CatalogStorageStandardSchemeFactory implements SchemeFactory { + public CatalogStorageStandardScheme getScheme() { + return new CatalogStorageStandardScheme(); + } + } + + private static class CatalogStorageStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, CatalogStorage struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // PROPERTIES + if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { + { + org.apache.thrift.protocol.TMap _map278 = iprot.readMapBegin(); + struct.properties = new HashMap(2*_map278.size); + String _key279; + String _val280; + for (int _i281 = 0; _i281 < _map278.size; ++_i281) + { + _key279 = iprot.readString(); + _val280 = iprot.readString(); + struct.properties.put(_key279, _val280); + } + iprot.readMapEnd(); + } + struct.setPropertiesIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // COMPRESSED + if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { + struct.compressed = iprot.readBool(); + struct.setCompressedIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // LOCATION_URI + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.locationUri = iprot.readString(); + struct.setLocationUriIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 4: // INPUT_FORMAT + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.inputFormat = iprot.readString(); + struct.setInputFormatIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 5: // OUTPUT_FORMAT + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.outputFormat = iprot.readString(); + struct.setOutputFormatIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 6: // SERDE + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.serde = iprot.readString(); + struct.setSerdeIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + if (!struct.isSetCompressed()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'compressed' was not found in serialized data! Struct: " + toString()); + } + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, CatalogStorage struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.properties != null) { + oprot.writeFieldBegin(PROPERTIES_FIELD_DESC); + { + oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.properties.size())); + for (Map.Entry _iter282 : struct.properties.entrySet()) + { + oprot.writeString(_iter282.getKey()); + oprot.writeString(_iter282.getValue()); + } + oprot.writeMapEnd(); + } + oprot.writeFieldEnd(); + } + oprot.writeFieldBegin(COMPRESSED_FIELD_DESC); + oprot.writeBool(struct.compressed); + oprot.writeFieldEnd(); + if (struct.locationUri != null) { + if (struct.isSetLocationUri()) { + oprot.writeFieldBegin(LOCATION_URI_FIELD_DESC); + oprot.writeString(struct.locationUri); + oprot.writeFieldEnd(); + } + } + if (struct.inputFormat != null) { + if (struct.isSetInputFormat()) { + oprot.writeFieldBegin(INPUT_FORMAT_FIELD_DESC); + oprot.writeString(struct.inputFormat); + oprot.writeFieldEnd(); + } + } + if (struct.outputFormat != null) { + if (struct.isSetOutputFormat()) { + oprot.writeFieldBegin(OUTPUT_FORMAT_FIELD_DESC); + oprot.writeString(struct.outputFormat); + oprot.writeFieldEnd(); + } + } + if (struct.serde != null) { + if (struct.isSetSerde()) { + oprot.writeFieldBegin(SERDE_FIELD_DESC); + oprot.writeString(struct.serde); + oprot.writeFieldEnd(); + } + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class CatalogStorageTupleSchemeFactory implements SchemeFactory { + public CatalogStorageTupleScheme getScheme() { + return new CatalogStorageTupleScheme(); + } + } + + private static class CatalogStorageTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, CatalogStorage struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + { + oprot.writeI32(struct.properties.size()); + for (Map.Entry _iter283 : struct.properties.entrySet()) + { + oprot.writeString(_iter283.getKey()); + oprot.writeString(_iter283.getValue()); + } + } + oprot.writeBool(struct.compressed); + BitSet optionals = new BitSet(); + if (struct.isSetLocationUri()) { + optionals.set(0); + } + if (struct.isSetInputFormat()) { + optionals.set(1); + } + if (struct.isSetOutputFormat()) { + optionals.set(2); + } + if (struct.isSetSerde()) { + optionals.set(3); + } + oprot.writeBitSet(optionals, 4); + if (struct.isSetLocationUri()) { + oprot.writeString(struct.locationUri); + } + if (struct.isSetInputFormat()) { + oprot.writeString(struct.inputFormat); + } + if (struct.isSetOutputFormat()) { + oprot.writeString(struct.outputFormat); + } + if (struct.isSetSerde()) { + oprot.writeString(struct.serde); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, CatalogStorage struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + { + org.apache.thrift.protocol.TMap _map284 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.properties = new HashMap(2*_map284.size); + String _key285; + String _val286; + for (int _i287 = 0; _i287 < _map284.size; ++_i287) + { + _key285 = iprot.readString(); + _val286 = iprot.readString(); + struct.properties.put(_key285, _val286); + } + } + struct.setPropertiesIsSet(true); + struct.compressed = iprot.readBool(); + struct.setCompressedIsSet(true); + BitSet incoming = iprot.readBitSet(4); + if (incoming.get(0)) { + struct.locationUri = iprot.readString(); + struct.setLocationUriIsSet(true); + } + if (incoming.get(1)) { + struct.inputFormat = iprot.readString(); + struct.setInputFormatIsSet(true); + } + if (incoming.get(2)) { + struct.outputFormat = iprot.readString(); + struct.setOutputFormatIsSet(true); + } + if (incoming.get(3)) { + struct.serde = iprot.readString(); + struct.setSerdeIsSet(true); + } + } + } + +} + diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/CatalogTableObject.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/CatalogTableObject.java new file mode 100644 index 000000000..d6844c9f6 --- /dev/null +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/CatalogTableObject.java @@ -0,0 +1,3625 @@ +/** + * Autogenerated by Thrift Compiler (0.9.3) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package io.snappydata.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-10") +public class CatalogTableObject implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("CatalogTableObject"); + + private static final org.apache.thrift.protocol.TField TABLE_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("tableName", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField SCHEMA_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("schemaName", org.apache.thrift.protocol.TType.STRING, (short)2); + private static final org.apache.thrift.protocol.TField TABLE_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("tableType", org.apache.thrift.protocol.TType.STRING, (short)3); + private static final org.apache.thrift.protocol.TField STORAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("storage", org.apache.thrift.protocol.TType.STRUCT, (short)4); + private static final org.apache.thrift.protocol.TField TABLE_SCHEMA_FIELD_DESC = new org.apache.thrift.protocol.TField("tableSchema", org.apache.thrift.protocol.TType.STRING, (short)5); + private static final org.apache.thrift.protocol.TField PROVIDER_FIELD_DESC = new org.apache.thrift.protocol.TField("provider", org.apache.thrift.protocol.TType.STRING, (short)6); + private static final org.apache.thrift.protocol.TField PARTITION_COLUMNS_FIELD_DESC = new org.apache.thrift.protocol.TField("partitionColumns", org.apache.thrift.protocol.TType.LIST, (short)7); + private static final org.apache.thrift.protocol.TField INDEX_COLUMNS_FIELD_DESC = new org.apache.thrift.protocol.TField("indexColumns", org.apache.thrift.protocol.TType.LIST, (short)8); + private static final org.apache.thrift.protocol.TField PRIMARY_KEY_COLUMNS_FIELD_DESC = new org.apache.thrift.protocol.TField("primaryKeyColumns", org.apache.thrift.protocol.TType.LIST, (short)9); + private static final org.apache.thrift.protocol.TField NUM_BUCKETS_FIELD_DESC = new org.apache.thrift.protocol.TField("numBuckets", org.apache.thrift.protocol.TType.I32, (short)10); + private static final org.apache.thrift.protocol.TField REDUNDANCY_FIELD_DESC = new org.apache.thrift.protocol.TField("redundancy", org.apache.thrift.protocol.TType.I32, (short)11); + private static final org.apache.thrift.protocol.TField BUCKET_OWNERS_FIELD_DESC = new org.apache.thrift.protocol.TField("bucketOwners", org.apache.thrift.protocol.TType.LIST, (short)12); + private static final org.apache.thrift.protocol.TField BUCKET_COLUMNS_FIELD_DESC = new org.apache.thrift.protocol.TField("bucketColumns", org.apache.thrift.protocol.TType.LIST, (short)13); + private static final org.apache.thrift.protocol.TField SORT_COLUMNS_FIELD_DESC = new org.apache.thrift.protocol.TField("sortColumns", org.apache.thrift.protocol.TType.LIST, (short)14); + private static final org.apache.thrift.protocol.TField OWNER_FIELD_DESC = new org.apache.thrift.protocol.TField("owner", org.apache.thrift.protocol.TType.STRING, (short)15); + private static final org.apache.thrift.protocol.TField CREATE_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("createTime", org.apache.thrift.protocol.TType.I64, (short)16); + private static final org.apache.thrift.protocol.TField LAST_ACCESS_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("lastAccessTime", org.apache.thrift.protocol.TType.I64, (short)17); + private static final org.apache.thrift.protocol.TField PROPERTIES_FIELD_DESC = new org.apache.thrift.protocol.TField("properties", org.apache.thrift.protocol.TType.MAP, (short)18); + private static final org.apache.thrift.protocol.TField SIZE_IN_BYTES_FIELD_DESC = new org.apache.thrift.protocol.TField("sizeInBytes", org.apache.thrift.protocol.TType.I64, (short)19); + private static final org.apache.thrift.protocol.TField ROW_COUNT_FIELD_DESC = new org.apache.thrift.protocol.TField("rowCount", org.apache.thrift.protocol.TType.I64, (short)20); + private static final org.apache.thrift.protocol.TField COL_STATS_FIELD_DESC = new org.apache.thrift.protocol.TField("colStats", org.apache.thrift.protocol.TType.LIST, (short)21); + private static final org.apache.thrift.protocol.TField IS_BROADCASTABLE_FIELD_DESC = new org.apache.thrift.protocol.TField("isBroadcastable", org.apache.thrift.protocol.TType.BOOL, (short)22); + private static final org.apache.thrift.protocol.TField VIEW_ORIGINAL_TEXT_FIELD_DESC = new org.apache.thrift.protocol.TField("viewOriginalText", org.apache.thrift.protocol.TType.STRING, (short)23); + private static final org.apache.thrift.protocol.TField VIEW_TEXT_FIELD_DESC = new org.apache.thrift.protocol.TField("viewText", org.apache.thrift.protocol.TType.STRING, (short)24); + private static final org.apache.thrift.protocol.TField COMMENT_FIELD_DESC = new org.apache.thrift.protocol.TField("comment", org.apache.thrift.protocol.TType.STRING, (short)25); + private static final org.apache.thrift.protocol.TField UNSUPPORTED_FEATURES_FIELD_DESC = new org.apache.thrift.protocol.TField("unsupportedFeatures", org.apache.thrift.protocol.TType.LIST, (short)26); + private static final org.apache.thrift.protocol.TField TRACKS_PARTITIONS_IN_CATALOG_FIELD_DESC = new org.apache.thrift.protocol.TField("tracksPartitionsInCatalog", org.apache.thrift.protocol.TType.BOOL, (short)27); + private static final org.apache.thrift.protocol.TField SCHEMA_PRESERVES_CASE_FIELD_DESC = new org.apache.thrift.protocol.TField("schemaPreservesCase", org.apache.thrift.protocol.TType.BOOL, (short)28); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new CatalogTableObjectStandardSchemeFactory()); + schemes.put(TupleScheme.class, new CatalogTableObjectTupleSchemeFactory()); + } + + public String tableName; // required + public String schemaName; // optional + public String tableType; // required + public CatalogStorage storage; // required + public String tableSchema; // required + public String provider; // optional + public List partitionColumns; // required + public List indexColumns; // required + public List primaryKeyColumns; // required + public int numBuckets; // optional + public int redundancy; // optional + public List bucketOwners; // required + public List bucketColumns; // required + public List sortColumns; // required + public String owner; // required + public long createTime; // required + public long lastAccessTime; // required + public Map properties; // required + public long sizeInBytes; // optional + public long rowCount; // optional + public List> colStats; // required + public boolean isBroadcastable; // required + public String viewOriginalText; // optional + public String viewText; // optional + public String comment; // optional + public List unsupportedFeatures; // required + public boolean tracksPartitionsInCatalog; // required + public boolean schemaPreservesCase; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + TABLE_NAME((short)1, "tableName"), + SCHEMA_NAME((short)2, "schemaName"), + TABLE_TYPE((short)3, "tableType"), + STORAGE((short)4, "storage"), + TABLE_SCHEMA((short)5, "tableSchema"), + PROVIDER((short)6, "provider"), + PARTITION_COLUMNS((short)7, "partitionColumns"), + INDEX_COLUMNS((short)8, "indexColumns"), + PRIMARY_KEY_COLUMNS((short)9, "primaryKeyColumns"), + NUM_BUCKETS((short)10, "numBuckets"), + REDUNDANCY((short)11, "redundancy"), + BUCKET_OWNERS((short)12, "bucketOwners"), + BUCKET_COLUMNS((short)13, "bucketColumns"), + SORT_COLUMNS((short)14, "sortColumns"), + OWNER((short)15, "owner"), + CREATE_TIME((short)16, "createTime"), + LAST_ACCESS_TIME((short)17, "lastAccessTime"), + PROPERTIES((short)18, "properties"), + SIZE_IN_BYTES((short)19, "sizeInBytes"), + ROW_COUNT((short)20, "rowCount"), + COL_STATS((short)21, "colStats"), + IS_BROADCASTABLE((short)22, "isBroadcastable"), + VIEW_ORIGINAL_TEXT((short)23, "viewOriginalText"), + VIEW_TEXT((short)24, "viewText"), + COMMENT((short)25, "comment"), + UNSUPPORTED_FEATURES((short)26, "unsupportedFeatures"), + TRACKS_PARTITIONS_IN_CATALOG((short)27, "tracksPartitionsInCatalog"), + SCHEMA_PRESERVES_CASE((short)28, "schemaPreservesCase"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // TABLE_NAME + return TABLE_NAME; + case 2: // SCHEMA_NAME + return SCHEMA_NAME; + case 3: // TABLE_TYPE + return TABLE_TYPE; + case 4: // STORAGE + return STORAGE; + case 5: // TABLE_SCHEMA + return TABLE_SCHEMA; + case 6: // PROVIDER + return PROVIDER; + case 7: // PARTITION_COLUMNS + return PARTITION_COLUMNS; + case 8: // INDEX_COLUMNS + return INDEX_COLUMNS; + case 9: // PRIMARY_KEY_COLUMNS + return PRIMARY_KEY_COLUMNS; + case 10: // NUM_BUCKETS + return NUM_BUCKETS; + case 11: // REDUNDANCY + return REDUNDANCY; + case 12: // BUCKET_OWNERS + return BUCKET_OWNERS; + case 13: // BUCKET_COLUMNS + return BUCKET_COLUMNS; + case 14: // SORT_COLUMNS + return SORT_COLUMNS; + case 15: // OWNER + return OWNER; + case 16: // CREATE_TIME + return CREATE_TIME; + case 17: // LAST_ACCESS_TIME + return LAST_ACCESS_TIME; + case 18: // PROPERTIES + return PROPERTIES; + case 19: // SIZE_IN_BYTES + return SIZE_IN_BYTES; + case 20: // ROW_COUNT + return ROW_COUNT; + case 21: // COL_STATS + return COL_STATS; + case 22: // IS_BROADCASTABLE + return IS_BROADCASTABLE; + case 23: // VIEW_ORIGINAL_TEXT + return VIEW_ORIGINAL_TEXT; + case 24: // VIEW_TEXT + return VIEW_TEXT; + case 25: // COMMENT + return COMMENT; + case 26: // UNSUPPORTED_FEATURES + return UNSUPPORTED_FEATURES; + case 27: // TRACKS_PARTITIONS_IN_CATALOG + return TRACKS_PARTITIONS_IN_CATALOG; + case 28: // SCHEMA_PRESERVES_CASE + return SCHEMA_PRESERVES_CASE; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __NUMBUCKETS_ISSET_ID = 0; + private static final int __REDUNDANCY_ISSET_ID = 1; + private static final int __CREATETIME_ISSET_ID = 2; + private static final int __LASTACCESSTIME_ISSET_ID = 3; + private static final int __SIZEINBYTES_ISSET_ID = 4; + private static final int __ROWCOUNT_ISSET_ID = 5; + private static final int __ISBROADCASTABLE_ISSET_ID = 6; + private static final int __TRACKSPARTITIONSINCATALOG_ISSET_ID = 7; + private static final int __SCHEMAPRESERVESCASE_ISSET_ID = 8; + private short __isset_bitfield = 0; + private static final _Fields optionals[] = {_Fields.SCHEMA_NAME,_Fields.PROVIDER,_Fields.NUM_BUCKETS,_Fields.REDUNDANCY,_Fields.SIZE_IN_BYTES,_Fields.ROW_COUNT,_Fields.VIEW_ORIGINAL_TEXT,_Fields.VIEW_TEXT,_Fields.COMMENT}; + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.TABLE_NAME, new org.apache.thrift.meta_data.FieldMetaData("tableName", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.SCHEMA_NAME, new org.apache.thrift.meta_data.FieldMetaData("schemaName", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.TABLE_TYPE, new org.apache.thrift.meta_data.FieldMetaData("tableType", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.STORAGE, new org.apache.thrift.meta_data.FieldMetaData("storage", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, CatalogStorage.class))); + tmpMap.put(_Fields.TABLE_SCHEMA, new org.apache.thrift.meta_data.FieldMetaData("tableSchema", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.PROVIDER, new org.apache.thrift.meta_data.FieldMetaData("provider", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.PARTITION_COLUMNS, new org.apache.thrift.meta_data.FieldMetaData("partitionColumns", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); + tmpMap.put(_Fields.INDEX_COLUMNS, new org.apache.thrift.meta_data.FieldMetaData("indexColumns", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); + tmpMap.put(_Fields.PRIMARY_KEY_COLUMNS, new org.apache.thrift.meta_data.FieldMetaData("primaryKeyColumns", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); + tmpMap.put(_Fields.NUM_BUCKETS, new org.apache.thrift.meta_data.FieldMetaData("numBuckets", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); + tmpMap.put(_Fields.REDUNDANCY, new org.apache.thrift.meta_data.FieldMetaData("redundancy", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); + tmpMap.put(_Fields.BUCKET_OWNERS, new org.apache.thrift.meta_data.FieldMetaData("bucketOwners", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, BucketOwners.class)))); + tmpMap.put(_Fields.BUCKET_COLUMNS, new org.apache.thrift.meta_data.FieldMetaData("bucketColumns", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); + tmpMap.put(_Fields.SORT_COLUMNS, new org.apache.thrift.meta_data.FieldMetaData("sortColumns", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); + tmpMap.put(_Fields.OWNER, new org.apache.thrift.meta_data.FieldMetaData("owner", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.CREATE_TIME, new org.apache.thrift.meta_data.FieldMetaData("createTime", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); + tmpMap.put(_Fields.LAST_ACCESS_TIME, new org.apache.thrift.meta_data.FieldMetaData("lastAccessTime", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); + tmpMap.put(_Fields.PROPERTIES, new org.apache.thrift.meta_data.FieldMetaData("properties", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); + tmpMap.put(_Fields.SIZE_IN_BYTES, new org.apache.thrift.meta_data.FieldMetaData("sizeInBytes", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); + tmpMap.put(_Fields.ROW_COUNT, new org.apache.thrift.meta_data.FieldMetaData("rowCount", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); + tmpMap.put(_Fields.COL_STATS, new org.apache.thrift.meta_data.FieldMetaData("colStats", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))))); + tmpMap.put(_Fields.IS_BROADCASTABLE, new org.apache.thrift.meta_data.FieldMetaData("isBroadcastable", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); + tmpMap.put(_Fields.VIEW_ORIGINAL_TEXT, new org.apache.thrift.meta_data.FieldMetaData("viewOriginalText", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.VIEW_TEXT, new org.apache.thrift.meta_data.FieldMetaData("viewText", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.COMMENT, new org.apache.thrift.meta_data.FieldMetaData("comment", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.UNSUPPORTED_FEATURES, new org.apache.thrift.meta_data.FieldMetaData("unsupportedFeatures", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); + tmpMap.put(_Fields.TRACKS_PARTITIONS_IN_CATALOG, new org.apache.thrift.meta_data.FieldMetaData("tracksPartitionsInCatalog", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); + tmpMap.put(_Fields.SCHEMA_PRESERVES_CASE, new org.apache.thrift.meta_data.FieldMetaData("schemaPreservesCase", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(CatalogTableObject.class, metaDataMap); + } + + public CatalogTableObject() { + } + + public CatalogTableObject( + String tableName, + String tableType, + CatalogStorage storage, + String tableSchema, + List partitionColumns, + List indexColumns, + List primaryKeyColumns, + List bucketOwners, + List bucketColumns, + List sortColumns, + String owner, + long createTime, + long lastAccessTime, + Map properties, + List> colStats, + boolean isBroadcastable, + List unsupportedFeatures, + boolean tracksPartitionsInCatalog, + boolean schemaPreservesCase) + { + this(); + this.tableName = tableName; + this.tableType = tableType; + this.storage = storage; + this.tableSchema = tableSchema; + this.partitionColumns = partitionColumns; + this.indexColumns = indexColumns; + this.primaryKeyColumns = primaryKeyColumns; + this.bucketOwners = bucketOwners; + this.bucketColumns = bucketColumns; + this.sortColumns = sortColumns; + this.owner = owner; + this.createTime = createTime; + setCreateTimeIsSet(true); + this.lastAccessTime = lastAccessTime; + setLastAccessTimeIsSet(true); + this.properties = properties; + this.colStats = colStats; + this.isBroadcastable = isBroadcastable; + setIsBroadcastableIsSet(true); + this.unsupportedFeatures = unsupportedFeatures; + this.tracksPartitionsInCatalog = tracksPartitionsInCatalog; + setTracksPartitionsInCatalogIsSet(true); + this.schemaPreservesCase = schemaPreservesCase; + setSchemaPreservesCaseIsSet(true); + } + + /** + * Performs a deep copy on other. + */ + public CatalogTableObject(CatalogTableObject other) { + __isset_bitfield = other.__isset_bitfield; + if (other.isSetTableName()) { + this.tableName = other.tableName; + } + if (other.isSetSchemaName()) { + this.schemaName = other.schemaName; + } + if (other.isSetTableType()) { + this.tableType = other.tableType; + } + if (other.isSetStorage()) { + this.storage = new CatalogStorage(other.storage); + } + if (other.isSetTableSchema()) { + this.tableSchema = other.tableSchema; + } + if (other.isSetProvider()) { + this.provider = other.provider; + } + if (other.isSetPartitionColumns()) { + List __this__partitionColumns = new ArrayList(other.partitionColumns); + this.partitionColumns = __this__partitionColumns; + } + if (other.isSetIndexColumns()) { + List __this__indexColumns = new ArrayList(other.indexColumns); + this.indexColumns = __this__indexColumns; + } + if (other.isSetPrimaryKeyColumns()) { + List __this__primaryKeyColumns = new ArrayList(other.primaryKeyColumns); + this.primaryKeyColumns = __this__primaryKeyColumns; + } + this.numBuckets = other.numBuckets; + this.redundancy = other.redundancy; + if (other.isSetBucketOwners()) { + List __this__bucketOwners = new ArrayList(other.bucketOwners.size()); + for (BucketOwners other_element : other.bucketOwners) { + __this__bucketOwners.add(new BucketOwners(other_element)); + } + this.bucketOwners = __this__bucketOwners; + } + if (other.isSetBucketColumns()) { + List __this__bucketColumns = new ArrayList(other.bucketColumns); + this.bucketColumns = __this__bucketColumns; + } + if (other.isSetSortColumns()) { + List __this__sortColumns = new ArrayList(other.sortColumns); + this.sortColumns = __this__sortColumns; + } + if (other.isSetOwner()) { + this.owner = other.owner; + } + this.createTime = other.createTime; + this.lastAccessTime = other.lastAccessTime; + if (other.isSetProperties()) { + Map __this__properties = new HashMap(other.properties); + this.properties = __this__properties; + } + this.sizeInBytes = other.sizeInBytes; + this.rowCount = other.rowCount; + if (other.isSetColStats()) { + List> __this__colStats = new ArrayList>(other.colStats.size()); + for (Map other_element : other.colStats) { + Map __this__colStats_copy = new HashMap(other_element); + __this__colStats.add(__this__colStats_copy); + } + this.colStats = __this__colStats; + } + this.isBroadcastable = other.isBroadcastable; + if (other.isSetViewOriginalText()) { + this.viewOriginalText = other.viewOriginalText; + } + if (other.isSetViewText()) { + this.viewText = other.viewText; + } + if (other.isSetComment()) { + this.comment = other.comment; + } + if (other.isSetUnsupportedFeatures()) { + List __this__unsupportedFeatures = new ArrayList(other.unsupportedFeatures); + this.unsupportedFeatures = __this__unsupportedFeatures; + } + this.tracksPartitionsInCatalog = other.tracksPartitionsInCatalog; + this.schemaPreservesCase = other.schemaPreservesCase; + } + + public CatalogTableObject deepCopy() { + return new CatalogTableObject(this); + } + + @Override + public void clear() { + this.tableName = null; + this.schemaName = null; + this.tableType = null; + this.storage = null; + this.tableSchema = null; + this.provider = null; + this.partitionColumns = null; + this.indexColumns = null; + this.primaryKeyColumns = null; + setNumBucketsIsSet(false); + this.numBuckets = 0; + setRedundancyIsSet(false); + this.redundancy = 0; + this.bucketOwners = null; + this.bucketColumns = null; + this.sortColumns = null; + this.owner = null; + setCreateTimeIsSet(false); + this.createTime = 0; + setLastAccessTimeIsSet(false); + this.lastAccessTime = 0; + this.properties = null; + setSizeInBytesIsSet(false); + this.sizeInBytes = 0; + setRowCountIsSet(false); + this.rowCount = 0; + this.colStats = null; + setIsBroadcastableIsSet(false); + this.isBroadcastable = false; + this.viewOriginalText = null; + this.viewText = null; + this.comment = null; + this.unsupportedFeatures = null; + setTracksPartitionsInCatalogIsSet(false); + this.tracksPartitionsInCatalog = false; + setSchemaPreservesCaseIsSet(false); + this.schemaPreservesCase = false; + } + + public String getTableName() { + return this.tableName; + } + + public CatalogTableObject setTableName(String tableName) { + this.tableName = tableName; + return this; + } + + public void unsetTableName() { + this.tableName = null; + } + + /** Returns true if field tableName is set (has been assigned a value) and false otherwise */ + public boolean isSetTableName() { + return this.tableName != null; + } + + public void setTableNameIsSet(boolean value) { + if (!value) { + this.tableName = null; + } + } + + public String getSchemaName() { + return this.schemaName; + } + + public CatalogTableObject setSchemaName(String schemaName) { + this.schemaName = schemaName; + return this; + } + + public void unsetSchemaName() { + this.schemaName = null; + } + + /** Returns true if field schemaName is set (has been assigned a value) and false otherwise */ + public boolean isSetSchemaName() { + return this.schemaName != null; + } + + public void setSchemaNameIsSet(boolean value) { + if (!value) { + this.schemaName = null; + } + } + + public String getTableType() { + return this.tableType; + } + + public CatalogTableObject setTableType(String tableType) { + this.tableType = tableType; + return this; + } + + public void unsetTableType() { + this.tableType = null; + } + + /** Returns true if field tableType is set (has been assigned a value) and false otherwise */ + public boolean isSetTableType() { + return this.tableType != null; + } + + public void setTableTypeIsSet(boolean value) { + if (!value) { + this.tableType = null; + } + } + + public CatalogStorage getStorage() { + return this.storage; + } + + public CatalogTableObject setStorage(CatalogStorage storage) { + this.storage = storage; + return this; + } + + public void unsetStorage() { + this.storage = null; + } + + /** Returns true if field storage is set (has been assigned a value) and false otherwise */ + public boolean isSetStorage() { + return this.storage != null; + } + + public void setStorageIsSet(boolean value) { + if (!value) { + this.storage = null; + } + } + + public String getTableSchema() { + return this.tableSchema; + } + + public CatalogTableObject setTableSchema(String tableSchema) { + this.tableSchema = tableSchema; + return this; + } + + public void unsetTableSchema() { + this.tableSchema = null; + } + + /** Returns true if field tableSchema is set (has been assigned a value) and false otherwise */ + public boolean isSetTableSchema() { + return this.tableSchema != null; + } + + public void setTableSchemaIsSet(boolean value) { + if (!value) { + this.tableSchema = null; + } + } + + public String getProvider() { + return this.provider; + } + + public CatalogTableObject setProvider(String provider) { + this.provider = provider; + return this; + } + + public void unsetProvider() { + this.provider = null; + } + + /** Returns true if field provider is set (has been assigned a value) and false otherwise */ + public boolean isSetProvider() { + return this.provider != null; + } + + public void setProviderIsSet(boolean value) { + if (!value) { + this.provider = null; + } + } + + public int getPartitionColumnsSize() { + return (this.partitionColumns == null) ? 0 : this.partitionColumns.size(); + } + + public java.util.Iterator getPartitionColumnsIterator() { + return (this.partitionColumns == null) ? null : this.partitionColumns.iterator(); + } + + public void addToPartitionColumns(String elem) { + if (this.partitionColumns == null) { + this.partitionColumns = new ArrayList(); + } + this.partitionColumns.add(elem); + } + + public List getPartitionColumns() { + return this.partitionColumns; + } + + public CatalogTableObject setPartitionColumns(List partitionColumns) { + this.partitionColumns = partitionColumns; + return this; + } + + public void unsetPartitionColumns() { + this.partitionColumns = null; + } + + /** Returns true if field partitionColumns is set (has been assigned a value) and false otherwise */ + public boolean isSetPartitionColumns() { + return this.partitionColumns != null; + } + + public void setPartitionColumnsIsSet(boolean value) { + if (!value) { + this.partitionColumns = null; + } + } + + public int getIndexColumnsSize() { + return (this.indexColumns == null) ? 0 : this.indexColumns.size(); + } + + public java.util.Iterator getIndexColumnsIterator() { + return (this.indexColumns == null) ? null : this.indexColumns.iterator(); + } + + public void addToIndexColumns(String elem) { + if (this.indexColumns == null) { + this.indexColumns = new ArrayList(); + } + this.indexColumns.add(elem); + } + + public List getIndexColumns() { + return this.indexColumns; + } + + public CatalogTableObject setIndexColumns(List indexColumns) { + this.indexColumns = indexColumns; + return this; + } + + public void unsetIndexColumns() { + this.indexColumns = null; + } + + /** Returns true if field indexColumns is set (has been assigned a value) and false otherwise */ + public boolean isSetIndexColumns() { + return this.indexColumns != null; + } + + public void setIndexColumnsIsSet(boolean value) { + if (!value) { + this.indexColumns = null; + } + } + + public int getPrimaryKeyColumnsSize() { + return (this.primaryKeyColumns == null) ? 0 : this.primaryKeyColumns.size(); + } + + public java.util.Iterator getPrimaryKeyColumnsIterator() { + return (this.primaryKeyColumns == null) ? null : this.primaryKeyColumns.iterator(); + } + + public void addToPrimaryKeyColumns(String elem) { + if (this.primaryKeyColumns == null) { + this.primaryKeyColumns = new ArrayList(); + } + this.primaryKeyColumns.add(elem); + } + + public List getPrimaryKeyColumns() { + return this.primaryKeyColumns; + } + + public CatalogTableObject setPrimaryKeyColumns(List primaryKeyColumns) { + this.primaryKeyColumns = primaryKeyColumns; + return this; + } + + public void unsetPrimaryKeyColumns() { + this.primaryKeyColumns = null; + } + + /** Returns true if field primaryKeyColumns is set (has been assigned a value) and false otherwise */ + public boolean isSetPrimaryKeyColumns() { + return this.primaryKeyColumns != null; + } + + public void setPrimaryKeyColumnsIsSet(boolean value) { + if (!value) { + this.primaryKeyColumns = null; + } + } + + public int getNumBuckets() { + return this.numBuckets; + } + + public CatalogTableObject setNumBuckets(int numBuckets) { + this.numBuckets = numBuckets; + setNumBucketsIsSet(true); + return this; + } + + public void unsetNumBuckets() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __NUMBUCKETS_ISSET_ID); + } + + /** Returns true if field numBuckets is set (has been assigned a value) and false otherwise */ + public boolean isSetNumBuckets() { + return EncodingUtils.testBit(__isset_bitfield, __NUMBUCKETS_ISSET_ID); + } + + public void setNumBucketsIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __NUMBUCKETS_ISSET_ID, value); + } + + public int getRedundancy() { + return this.redundancy; + } + + public CatalogTableObject setRedundancy(int redundancy) { + this.redundancy = redundancy; + setRedundancyIsSet(true); + return this; + } + + public void unsetRedundancy() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __REDUNDANCY_ISSET_ID); + } + + /** Returns true if field redundancy is set (has been assigned a value) and false otherwise */ + public boolean isSetRedundancy() { + return EncodingUtils.testBit(__isset_bitfield, __REDUNDANCY_ISSET_ID); + } + + public void setRedundancyIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __REDUNDANCY_ISSET_ID, value); + } + + public int getBucketOwnersSize() { + return (this.bucketOwners == null) ? 0 : this.bucketOwners.size(); + } + + public java.util.Iterator getBucketOwnersIterator() { + return (this.bucketOwners == null) ? null : this.bucketOwners.iterator(); + } + + public void addToBucketOwners(BucketOwners elem) { + if (this.bucketOwners == null) { + this.bucketOwners = new ArrayList(); + } + this.bucketOwners.add(elem); + } + + public List getBucketOwners() { + return this.bucketOwners; + } + + public CatalogTableObject setBucketOwners(List bucketOwners) { + this.bucketOwners = bucketOwners; + return this; + } + + public void unsetBucketOwners() { + this.bucketOwners = null; + } + + /** Returns true if field bucketOwners is set (has been assigned a value) and false otherwise */ + public boolean isSetBucketOwners() { + return this.bucketOwners != null; + } + + public void setBucketOwnersIsSet(boolean value) { + if (!value) { + this.bucketOwners = null; + } + } + + public int getBucketColumnsSize() { + return (this.bucketColumns == null) ? 0 : this.bucketColumns.size(); + } + + public java.util.Iterator getBucketColumnsIterator() { + return (this.bucketColumns == null) ? null : this.bucketColumns.iterator(); + } + + public void addToBucketColumns(String elem) { + if (this.bucketColumns == null) { + this.bucketColumns = new ArrayList(); + } + this.bucketColumns.add(elem); + } + + public List getBucketColumns() { + return this.bucketColumns; + } + + public CatalogTableObject setBucketColumns(List bucketColumns) { + this.bucketColumns = bucketColumns; + return this; + } + + public void unsetBucketColumns() { + this.bucketColumns = null; + } + + /** Returns true if field bucketColumns is set (has been assigned a value) and false otherwise */ + public boolean isSetBucketColumns() { + return this.bucketColumns != null; + } + + public void setBucketColumnsIsSet(boolean value) { + if (!value) { + this.bucketColumns = null; + } + } + + public int getSortColumnsSize() { + return (this.sortColumns == null) ? 0 : this.sortColumns.size(); + } + + public java.util.Iterator getSortColumnsIterator() { + return (this.sortColumns == null) ? null : this.sortColumns.iterator(); + } + + public void addToSortColumns(String elem) { + if (this.sortColumns == null) { + this.sortColumns = new ArrayList(); + } + this.sortColumns.add(elem); + } + + public List getSortColumns() { + return this.sortColumns; + } + + public CatalogTableObject setSortColumns(List sortColumns) { + this.sortColumns = sortColumns; + return this; + } + + public void unsetSortColumns() { + this.sortColumns = null; + } + + /** Returns true if field sortColumns is set (has been assigned a value) and false otherwise */ + public boolean isSetSortColumns() { + return this.sortColumns != null; + } + + public void setSortColumnsIsSet(boolean value) { + if (!value) { + this.sortColumns = null; + } + } + + public String getOwner() { + return this.owner; + } + + public CatalogTableObject setOwner(String owner) { + this.owner = owner; + return this; + } + + public void unsetOwner() { + this.owner = null; + } + + /** Returns true if field owner is set (has been assigned a value) and false otherwise */ + public boolean isSetOwner() { + return this.owner != null; + } + + public void setOwnerIsSet(boolean value) { + if (!value) { + this.owner = null; + } + } + + public long getCreateTime() { + return this.createTime; + } + + public CatalogTableObject setCreateTime(long createTime) { + this.createTime = createTime; + setCreateTimeIsSet(true); + return this; + } + + public void unsetCreateTime() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __CREATETIME_ISSET_ID); + } + + /** Returns true if field createTime is set (has been assigned a value) and false otherwise */ + public boolean isSetCreateTime() { + return EncodingUtils.testBit(__isset_bitfield, __CREATETIME_ISSET_ID); + } + + public void setCreateTimeIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __CREATETIME_ISSET_ID, value); + } + + public long getLastAccessTime() { + return this.lastAccessTime; + } + + public CatalogTableObject setLastAccessTime(long lastAccessTime) { + this.lastAccessTime = lastAccessTime; + setLastAccessTimeIsSet(true); + return this; + } + + public void unsetLastAccessTime() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __LASTACCESSTIME_ISSET_ID); + } + + /** Returns true if field lastAccessTime is set (has been assigned a value) and false otherwise */ + public boolean isSetLastAccessTime() { + return EncodingUtils.testBit(__isset_bitfield, __LASTACCESSTIME_ISSET_ID); + } + + public void setLastAccessTimeIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __LASTACCESSTIME_ISSET_ID, value); + } + + public int getPropertiesSize() { + return (this.properties == null) ? 0 : this.properties.size(); + } + + public void putToProperties(String key, String val) { + if (this.properties == null) { + this.properties = new HashMap(); + } + this.properties.put(key, val); + } + + public Map getProperties() { + return this.properties; + } + + public CatalogTableObject setProperties(Map properties) { + this.properties = properties; + return this; + } + + public void unsetProperties() { + this.properties = null; + } + + /** Returns true if field properties is set (has been assigned a value) and false otherwise */ + public boolean isSetProperties() { + return this.properties != null; + } + + public void setPropertiesIsSet(boolean value) { + if (!value) { + this.properties = null; + } + } + + public long getSizeInBytes() { + return this.sizeInBytes; + } + + public CatalogTableObject setSizeInBytes(long sizeInBytes) { + this.sizeInBytes = sizeInBytes; + setSizeInBytesIsSet(true); + return this; + } + + public void unsetSizeInBytes() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __SIZEINBYTES_ISSET_ID); + } + + /** Returns true if field sizeInBytes is set (has been assigned a value) and false otherwise */ + public boolean isSetSizeInBytes() { + return EncodingUtils.testBit(__isset_bitfield, __SIZEINBYTES_ISSET_ID); + } + + public void setSizeInBytesIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __SIZEINBYTES_ISSET_ID, value); + } + + public long getRowCount() { + return this.rowCount; + } + + public CatalogTableObject setRowCount(long rowCount) { + this.rowCount = rowCount; + setRowCountIsSet(true); + return this; + } + + public void unsetRowCount() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __ROWCOUNT_ISSET_ID); + } + + /** Returns true if field rowCount is set (has been assigned a value) and false otherwise */ + public boolean isSetRowCount() { + return EncodingUtils.testBit(__isset_bitfield, __ROWCOUNT_ISSET_ID); + } + + public void setRowCountIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __ROWCOUNT_ISSET_ID, value); + } + + public int getColStatsSize() { + return (this.colStats == null) ? 0 : this.colStats.size(); + } + + public java.util.Iterator> getColStatsIterator() { + return (this.colStats == null) ? null : this.colStats.iterator(); + } + + public void addToColStats(Map elem) { + if (this.colStats == null) { + this.colStats = new ArrayList>(); + } + this.colStats.add(elem); + } + + public List> getColStats() { + return this.colStats; + } + + public CatalogTableObject setColStats(List> colStats) { + this.colStats = colStats; + return this; + } + + public void unsetColStats() { + this.colStats = null; + } + + /** Returns true if field colStats is set (has been assigned a value) and false otherwise */ + public boolean isSetColStats() { + return this.colStats != null; + } + + public void setColStatsIsSet(boolean value) { + if (!value) { + this.colStats = null; + } + } + + public boolean isIsBroadcastable() { + return this.isBroadcastable; + } + + public CatalogTableObject setIsBroadcastable(boolean isBroadcastable) { + this.isBroadcastable = isBroadcastable; + setIsBroadcastableIsSet(true); + return this; + } + + public void unsetIsBroadcastable() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __ISBROADCASTABLE_ISSET_ID); + } + + /** Returns true if field isBroadcastable is set (has been assigned a value) and false otherwise */ + public boolean isSetIsBroadcastable() { + return EncodingUtils.testBit(__isset_bitfield, __ISBROADCASTABLE_ISSET_ID); + } + + public void setIsBroadcastableIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __ISBROADCASTABLE_ISSET_ID, value); + } + + public String getViewOriginalText() { + return this.viewOriginalText; + } + + public CatalogTableObject setViewOriginalText(String viewOriginalText) { + this.viewOriginalText = viewOriginalText; + return this; + } + + public void unsetViewOriginalText() { + this.viewOriginalText = null; + } + + /** Returns true if field viewOriginalText is set (has been assigned a value) and false otherwise */ + public boolean isSetViewOriginalText() { + return this.viewOriginalText != null; + } + + public void setViewOriginalTextIsSet(boolean value) { + if (!value) { + this.viewOriginalText = null; + } + } + + public String getViewText() { + return this.viewText; + } + + public CatalogTableObject setViewText(String viewText) { + this.viewText = viewText; + return this; + } + + public void unsetViewText() { + this.viewText = null; + } + + /** Returns true if field viewText is set (has been assigned a value) and false otherwise */ + public boolean isSetViewText() { + return this.viewText != null; + } + + public void setViewTextIsSet(boolean value) { + if (!value) { + this.viewText = null; + } + } + + public String getComment() { + return this.comment; + } + + public CatalogTableObject setComment(String comment) { + this.comment = comment; + return this; + } + + public void unsetComment() { + this.comment = null; + } + + /** Returns true if field comment is set (has been assigned a value) and false otherwise */ + public boolean isSetComment() { + return this.comment != null; + } + + public void setCommentIsSet(boolean value) { + if (!value) { + this.comment = null; + } + } + + public int getUnsupportedFeaturesSize() { + return (this.unsupportedFeatures == null) ? 0 : this.unsupportedFeatures.size(); + } + + public java.util.Iterator getUnsupportedFeaturesIterator() { + return (this.unsupportedFeatures == null) ? null : this.unsupportedFeatures.iterator(); + } + + public void addToUnsupportedFeatures(String elem) { + if (this.unsupportedFeatures == null) { + this.unsupportedFeatures = new ArrayList(); + } + this.unsupportedFeatures.add(elem); + } + + public List getUnsupportedFeatures() { + return this.unsupportedFeatures; + } + + public CatalogTableObject setUnsupportedFeatures(List unsupportedFeatures) { + this.unsupportedFeatures = unsupportedFeatures; + return this; + } + + public void unsetUnsupportedFeatures() { + this.unsupportedFeatures = null; + } + + /** Returns true if field unsupportedFeatures is set (has been assigned a value) and false otherwise */ + public boolean isSetUnsupportedFeatures() { + return this.unsupportedFeatures != null; + } + + public void setUnsupportedFeaturesIsSet(boolean value) { + if (!value) { + this.unsupportedFeatures = null; + } + } + + public boolean isTracksPartitionsInCatalog() { + return this.tracksPartitionsInCatalog; + } + + public CatalogTableObject setTracksPartitionsInCatalog(boolean tracksPartitionsInCatalog) { + this.tracksPartitionsInCatalog = tracksPartitionsInCatalog; + setTracksPartitionsInCatalogIsSet(true); + return this; + } + + public void unsetTracksPartitionsInCatalog() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __TRACKSPARTITIONSINCATALOG_ISSET_ID); + } + + /** Returns true if field tracksPartitionsInCatalog is set (has been assigned a value) and false otherwise */ + public boolean isSetTracksPartitionsInCatalog() { + return EncodingUtils.testBit(__isset_bitfield, __TRACKSPARTITIONSINCATALOG_ISSET_ID); + } + + public void setTracksPartitionsInCatalogIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __TRACKSPARTITIONSINCATALOG_ISSET_ID, value); + } + + public boolean isSchemaPreservesCase() { + return this.schemaPreservesCase; + } + + public CatalogTableObject setSchemaPreservesCase(boolean schemaPreservesCase) { + this.schemaPreservesCase = schemaPreservesCase; + setSchemaPreservesCaseIsSet(true); + return this; + } + + public void unsetSchemaPreservesCase() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __SCHEMAPRESERVESCASE_ISSET_ID); + } + + /** Returns true if field schemaPreservesCase is set (has been assigned a value) and false otherwise */ + public boolean isSetSchemaPreservesCase() { + return EncodingUtils.testBit(__isset_bitfield, __SCHEMAPRESERVESCASE_ISSET_ID); + } + + public void setSchemaPreservesCaseIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __SCHEMAPRESERVESCASE_ISSET_ID, value); + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case TABLE_NAME: + if (value == null) { + unsetTableName(); + } else { + setTableName((String)value); + } + break; + + case SCHEMA_NAME: + if (value == null) { + unsetSchemaName(); + } else { + setSchemaName((String)value); + } + break; + + case TABLE_TYPE: + if (value == null) { + unsetTableType(); + } else { + setTableType((String)value); + } + break; + + case STORAGE: + if (value == null) { + unsetStorage(); + } else { + setStorage((CatalogStorage)value); + } + break; + + case TABLE_SCHEMA: + if (value == null) { + unsetTableSchema(); + } else { + setTableSchema((String)value); + } + break; + + case PROVIDER: + if (value == null) { + unsetProvider(); + } else { + setProvider((String)value); + } + break; + + case PARTITION_COLUMNS: + if (value == null) { + unsetPartitionColumns(); + } else { + setPartitionColumns((List)value); + } + break; + + case INDEX_COLUMNS: + if (value == null) { + unsetIndexColumns(); + } else { + setIndexColumns((List)value); + } + break; + + case PRIMARY_KEY_COLUMNS: + if (value == null) { + unsetPrimaryKeyColumns(); + } else { + setPrimaryKeyColumns((List)value); + } + break; + + case NUM_BUCKETS: + if (value == null) { + unsetNumBuckets(); + } else { + setNumBuckets((Integer)value); + } + break; + + case REDUNDANCY: + if (value == null) { + unsetRedundancy(); + } else { + setRedundancy((Integer)value); + } + break; + + case BUCKET_OWNERS: + if (value == null) { + unsetBucketOwners(); + } else { + setBucketOwners((List)value); + } + break; + + case BUCKET_COLUMNS: + if (value == null) { + unsetBucketColumns(); + } else { + setBucketColumns((List)value); + } + break; + + case SORT_COLUMNS: + if (value == null) { + unsetSortColumns(); + } else { + setSortColumns((List)value); + } + break; + + case OWNER: + if (value == null) { + unsetOwner(); + } else { + setOwner((String)value); + } + break; + + case CREATE_TIME: + if (value == null) { + unsetCreateTime(); + } else { + setCreateTime((Long)value); + } + break; + + case LAST_ACCESS_TIME: + if (value == null) { + unsetLastAccessTime(); + } else { + setLastAccessTime((Long)value); + } + break; + + case PROPERTIES: + if (value == null) { + unsetProperties(); + } else { + setProperties((Map)value); + } + break; + + case SIZE_IN_BYTES: + if (value == null) { + unsetSizeInBytes(); + } else { + setSizeInBytes((Long)value); + } + break; + + case ROW_COUNT: + if (value == null) { + unsetRowCount(); + } else { + setRowCount((Long)value); + } + break; + + case COL_STATS: + if (value == null) { + unsetColStats(); + } else { + setColStats((List>)value); + } + break; + + case IS_BROADCASTABLE: + if (value == null) { + unsetIsBroadcastable(); + } else { + setIsBroadcastable((Boolean)value); + } + break; + + case VIEW_ORIGINAL_TEXT: + if (value == null) { + unsetViewOriginalText(); + } else { + setViewOriginalText((String)value); + } + break; + + case VIEW_TEXT: + if (value == null) { + unsetViewText(); + } else { + setViewText((String)value); + } + break; + + case COMMENT: + if (value == null) { + unsetComment(); + } else { + setComment((String)value); + } + break; + + case UNSUPPORTED_FEATURES: + if (value == null) { + unsetUnsupportedFeatures(); + } else { + setUnsupportedFeatures((List)value); + } + break; + + case TRACKS_PARTITIONS_IN_CATALOG: + if (value == null) { + unsetTracksPartitionsInCatalog(); + } else { + setTracksPartitionsInCatalog((Boolean)value); + } + break; + + case SCHEMA_PRESERVES_CASE: + if (value == null) { + unsetSchemaPreservesCase(); + } else { + setSchemaPreservesCase((Boolean)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case TABLE_NAME: + return getTableName(); + + case SCHEMA_NAME: + return getSchemaName(); + + case TABLE_TYPE: + return getTableType(); + + case STORAGE: + return getStorage(); + + case TABLE_SCHEMA: + return getTableSchema(); + + case PROVIDER: + return getProvider(); + + case PARTITION_COLUMNS: + return getPartitionColumns(); + + case INDEX_COLUMNS: + return getIndexColumns(); + + case PRIMARY_KEY_COLUMNS: + return getPrimaryKeyColumns(); + + case NUM_BUCKETS: + return getNumBuckets(); + + case REDUNDANCY: + return getRedundancy(); + + case BUCKET_OWNERS: + return getBucketOwners(); + + case BUCKET_COLUMNS: + return getBucketColumns(); + + case SORT_COLUMNS: + return getSortColumns(); + + case OWNER: + return getOwner(); + + case CREATE_TIME: + return getCreateTime(); + + case LAST_ACCESS_TIME: + return getLastAccessTime(); + + case PROPERTIES: + return getProperties(); + + case SIZE_IN_BYTES: + return getSizeInBytes(); + + case ROW_COUNT: + return getRowCount(); + + case COL_STATS: + return getColStats(); + + case IS_BROADCASTABLE: + return isIsBroadcastable(); + + case VIEW_ORIGINAL_TEXT: + return getViewOriginalText(); + + case VIEW_TEXT: + return getViewText(); + + case COMMENT: + return getComment(); + + case UNSUPPORTED_FEATURES: + return getUnsupportedFeatures(); + + case TRACKS_PARTITIONS_IN_CATALOG: + return isTracksPartitionsInCatalog(); + + case SCHEMA_PRESERVES_CASE: + return isSchemaPreservesCase(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case TABLE_NAME: + return isSetTableName(); + case SCHEMA_NAME: + return isSetSchemaName(); + case TABLE_TYPE: + return isSetTableType(); + case STORAGE: + return isSetStorage(); + case TABLE_SCHEMA: + return isSetTableSchema(); + case PROVIDER: + return isSetProvider(); + case PARTITION_COLUMNS: + return isSetPartitionColumns(); + case INDEX_COLUMNS: + return isSetIndexColumns(); + case PRIMARY_KEY_COLUMNS: + return isSetPrimaryKeyColumns(); + case NUM_BUCKETS: + return isSetNumBuckets(); + case REDUNDANCY: + return isSetRedundancy(); + case BUCKET_OWNERS: + return isSetBucketOwners(); + case BUCKET_COLUMNS: + return isSetBucketColumns(); + case SORT_COLUMNS: + return isSetSortColumns(); + case OWNER: + return isSetOwner(); + case CREATE_TIME: + return isSetCreateTime(); + case LAST_ACCESS_TIME: + return isSetLastAccessTime(); + case PROPERTIES: + return isSetProperties(); + case SIZE_IN_BYTES: + return isSetSizeInBytes(); + case ROW_COUNT: + return isSetRowCount(); + case COL_STATS: + return isSetColStats(); + case IS_BROADCASTABLE: + return isSetIsBroadcastable(); + case VIEW_ORIGINAL_TEXT: + return isSetViewOriginalText(); + case VIEW_TEXT: + return isSetViewText(); + case COMMENT: + return isSetComment(); + case UNSUPPORTED_FEATURES: + return isSetUnsupportedFeatures(); + case TRACKS_PARTITIONS_IN_CATALOG: + return isSetTracksPartitionsInCatalog(); + case SCHEMA_PRESERVES_CASE: + return isSetSchemaPreservesCase(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof CatalogTableObject) + return this.equals((CatalogTableObject)that); + return false; + } + + public boolean equals(CatalogTableObject that) { + if (that == null) + return false; + + boolean this_present_tableName = true && this.isSetTableName(); + boolean that_present_tableName = true && that.isSetTableName(); + if (this_present_tableName || that_present_tableName) { + if (!(this_present_tableName && that_present_tableName)) + return false; + if (!this.tableName.equals(that.tableName)) + return false; + } + + boolean this_present_schemaName = true && this.isSetSchemaName(); + boolean that_present_schemaName = true && that.isSetSchemaName(); + if (this_present_schemaName || that_present_schemaName) { + if (!(this_present_schemaName && that_present_schemaName)) + return false; + if (!this.schemaName.equals(that.schemaName)) + return false; + } + + boolean this_present_tableType = true && this.isSetTableType(); + boolean that_present_tableType = true && that.isSetTableType(); + if (this_present_tableType || that_present_tableType) { + if (!(this_present_tableType && that_present_tableType)) + return false; + if (!this.tableType.equals(that.tableType)) + return false; + } + + boolean this_present_storage = true && this.isSetStorage(); + boolean that_present_storage = true && that.isSetStorage(); + if (this_present_storage || that_present_storage) { + if (!(this_present_storage && that_present_storage)) + return false; + if (!this.storage.equals(that.storage)) + return false; + } + + boolean this_present_tableSchema = true && this.isSetTableSchema(); + boolean that_present_tableSchema = true && that.isSetTableSchema(); + if (this_present_tableSchema || that_present_tableSchema) { + if (!(this_present_tableSchema && that_present_tableSchema)) + return false; + if (!this.tableSchema.equals(that.tableSchema)) + return false; + } + + boolean this_present_provider = true && this.isSetProvider(); + boolean that_present_provider = true && that.isSetProvider(); + if (this_present_provider || that_present_provider) { + if (!(this_present_provider && that_present_provider)) + return false; + if (!this.provider.equals(that.provider)) + return false; + } + + boolean this_present_partitionColumns = true && this.isSetPartitionColumns(); + boolean that_present_partitionColumns = true && that.isSetPartitionColumns(); + if (this_present_partitionColumns || that_present_partitionColumns) { + if (!(this_present_partitionColumns && that_present_partitionColumns)) + return false; + if (!this.partitionColumns.equals(that.partitionColumns)) + return false; + } + + boolean this_present_indexColumns = true && this.isSetIndexColumns(); + boolean that_present_indexColumns = true && that.isSetIndexColumns(); + if (this_present_indexColumns || that_present_indexColumns) { + if (!(this_present_indexColumns && that_present_indexColumns)) + return false; + if (!this.indexColumns.equals(that.indexColumns)) + return false; + } + + boolean this_present_primaryKeyColumns = true && this.isSetPrimaryKeyColumns(); + boolean that_present_primaryKeyColumns = true && that.isSetPrimaryKeyColumns(); + if (this_present_primaryKeyColumns || that_present_primaryKeyColumns) { + if (!(this_present_primaryKeyColumns && that_present_primaryKeyColumns)) + return false; + if (!this.primaryKeyColumns.equals(that.primaryKeyColumns)) + return false; + } + + boolean this_present_numBuckets = true && this.isSetNumBuckets(); + boolean that_present_numBuckets = true && that.isSetNumBuckets(); + if (this_present_numBuckets || that_present_numBuckets) { + if (!(this_present_numBuckets && that_present_numBuckets)) + return false; + if (this.numBuckets != that.numBuckets) + return false; + } + + boolean this_present_redundancy = true && this.isSetRedundancy(); + boolean that_present_redundancy = true && that.isSetRedundancy(); + if (this_present_redundancy || that_present_redundancy) { + if (!(this_present_redundancy && that_present_redundancy)) + return false; + if (this.redundancy != that.redundancy) + return false; + } + + boolean this_present_bucketOwners = true && this.isSetBucketOwners(); + boolean that_present_bucketOwners = true && that.isSetBucketOwners(); + if (this_present_bucketOwners || that_present_bucketOwners) { + if (!(this_present_bucketOwners && that_present_bucketOwners)) + return false; + if (!this.bucketOwners.equals(that.bucketOwners)) + return false; + } + + boolean this_present_bucketColumns = true && this.isSetBucketColumns(); + boolean that_present_bucketColumns = true && that.isSetBucketColumns(); + if (this_present_bucketColumns || that_present_bucketColumns) { + if (!(this_present_bucketColumns && that_present_bucketColumns)) + return false; + if (!this.bucketColumns.equals(that.bucketColumns)) + return false; + } + + boolean this_present_sortColumns = true && this.isSetSortColumns(); + boolean that_present_sortColumns = true && that.isSetSortColumns(); + if (this_present_sortColumns || that_present_sortColumns) { + if (!(this_present_sortColumns && that_present_sortColumns)) + return false; + if (!this.sortColumns.equals(that.sortColumns)) + return false; + } + + boolean this_present_owner = true && this.isSetOwner(); + boolean that_present_owner = true && that.isSetOwner(); + if (this_present_owner || that_present_owner) { + if (!(this_present_owner && that_present_owner)) + return false; + if (!this.owner.equals(that.owner)) + return false; + } + + boolean this_present_createTime = true; + boolean that_present_createTime = true; + if (this_present_createTime || that_present_createTime) { + if (!(this_present_createTime && that_present_createTime)) + return false; + if (this.createTime != that.createTime) + return false; + } + + boolean this_present_lastAccessTime = true; + boolean that_present_lastAccessTime = true; + if (this_present_lastAccessTime || that_present_lastAccessTime) { + if (!(this_present_lastAccessTime && that_present_lastAccessTime)) + return false; + if (this.lastAccessTime != that.lastAccessTime) + return false; + } + + boolean this_present_properties = true && this.isSetProperties(); + boolean that_present_properties = true && that.isSetProperties(); + if (this_present_properties || that_present_properties) { + if (!(this_present_properties && that_present_properties)) + return false; + if (!this.properties.equals(that.properties)) + return false; + } + + boolean this_present_sizeInBytes = true && this.isSetSizeInBytes(); + boolean that_present_sizeInBytes = true && that.isSetSizeInBytes(); + if (this_present_sizeInBytes || that_present_sizeInBytes) { + if (!(this_present_sizeInBytes && that_present_sizeInBytes)) + return false; + if (this.sizeInBytes != that.sizeInBytes) + return false; + } + + boolean this_present_rowCount = true && this.isSetRowCount(); + boolean that_present_rowCount = true && that.isSetRowCount(); + if (this_present_rowCount || that_present_rowCount) { + if (!(this_present_rowCount && that_present_rowCount)) + return false; + if (this.rowCount != that.rowCount) + return false; + } + + boolean this_present_colStats = true && this.isSetColStats(); + boolean that_present_colStats = true && that.isSetColStats(); + if (this_present_colStats || that_present_colStats) { + if (!(this_present_colStats && that_present_colStats)) + return false; + if (!this.colStats.equals(that.colStats)) + return false; + } + + boolean this_present_isBroadcastable = true; + boolean that_present_isBroadcastable = true; + if (this_present_isBroadcastable || that_present_isBroadcastable) { + if (!(this_present_isBroadcastable && that_present_isBroadcastable)) + return false; + if (this.isBroadcastable != that.isBroadcastable) + return false; + } + + boolean this_present_viewOriginalText = true && this.isSetViewOriginalText(); + boolean that_present_viewOriginalText = true && that.isSetViewOriginalText(); + if (this_present_viewOriginalText || that_present_viewOriginalText) { + if (!(this_present_viewOriginalText && that_present_viewOriginalText)) + return false; + if (!this.viewOriginalText.equals(that.viewOriginalText)) + return false; + } + + boolean this_present_viewText = true && this.isSetViewText(); + boolean that_present_viewText = true && that.isSetViewText(); + if (this_present_viewText || that_present_viewText) { + if (!(this_present_viewText && that_present_viewText)) + return false; + if (!this.viewText.equals(that.viewText)) + return false; + } + + boolean this_present_comment = true && this.isSetComment(); + boolean that_present_comment = true && that.isSetComment(); + if (this_present_comment || that_present_comment) { + if (!(this_present_comment && that_present_comment)) + return false; + if (!this.comment.equals(that.comment)) + return false; + } + + boolean this_present_unsupportedFeatures = true && this.isSetUnsupportedFeatures(); + boolean that_present_unsupportedFeatures = true && that.isSetUnsupportedFeatures(); + if (this_present_unsupportedFeatures || that_present_unsupportedFeatures) { + if (!(this_present_unsupportedFeatures && that_present_unsupportedFeatures)) + return false; + if (!this.unsupportedFeatures.equals(that.unsupportedFeatures)) + return false; + } + + boolean this_present_tracksPartitionsInCatalog = true; + boolean that_present_tracksPartitionsInCatalog = true; + if (this_present_tracksPartitionsInCatalog || that_present_tracksPartitionsInCatalog) { + if (!(this_present_tracksPartitionsInCatalog && that_present_tracksPartitionsInCatalog)) + return false; + if (this.tracksPartitionsInCatalog != that.tracksPartitionsInCatalog) + return false; + } + + boolean this_present_schemaPreservesCase = true; + boolean that_present_schemaPreservesCase = true; + if (this_present_schemaPreservesCase || that_present_schemaPreservesCase) { + if (!(this_present_schemaPreservesCase && that_present_schemaPreservesCase)) + return false; + if (this.schemaPreservesCase != that.schemaPreservesCase) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_tableName = true && (isSetTableName()); + list.add(present_tableName); + if (present_tableName) + list.add(tableName); + + boolean present_schemaName = true && (isSetSchemaName()); + list.add(present_schemaName); + if (present_schemaName) + list.add(schemaName); + + boolean present_tableType = true && (isSetTableType()); + list.add(present_tableType); + if (present_tableType) + list.add(tableType); + + boolean present_storage = true && (isSetStorage()); + list.add(present_storage); + if (present_storage) + list.add(storage); + + boolean present_tableSchema = true && (isSetTableSchema()); + list.add(present_tableSchema); + if (present_tableSchema) + list.add(tableSchema); + + boolean present_provider = true && (isSetProvider()); + list.add(present_provider); + if (present_provider) + list.add(provider); + + boolean present_partitionColumns = true && (isSetPartitionColumns()); + list.add(present_partitionColumns); + if (present_partitionColumns) + list.add(partitionColumns); + + boolean present_indexColumns = true && (isSetIndexColumns()); + list.add(present_indexColumns); + if (present_indexColumns) + list.add(indexColumns); + + boolean present_primaryKeyColumns = true && (isSetPrimaryKeyColumns()); + list.add(present_primaryKeyColumns); + if (present_primaryKeyColumns) + list.add(primaryKeyColumns); + + boolean present_numBuckets = true && (isSetNumBuckets()); + list.add(present_numBuckets); + if (present_numBuckets) + list.add(numBuckets); + + boolean present_redundancy = true && (isSetRedundancy()); + list.add(present_redundancy); + if (present_redundancy) + list.add(redundancy); + + boolean present_bucketOwners = true && (isSetBucketOwners()); + list.add(present_bucketOwners); + if (present_bucketOwners) + list.add(bucketOwners); + + boolean present_bucketColumns = true && (isSetBucketColumns()); + list.add(present_bucketColumns); + if (present_bucketColumns) + list.add(bucketColumns); + + boolean present_sortColumns = true && (isSetSortColumns()); + list.add(present_sortColumns); + if (present_sortColumns) + list.add(sortColumns); + + boolean present_owner = true && (isSetOwner()); + list.add(present_owner); + if (present_owner) + list.add(owner); + + boolean present_createTime = true; + list.add(present_createTime); + if (present_createTime) + list.add(createTime); + + boolean present_lastAccessTime = true; + list.add(present_lastAccessTime); + if (present_lastAccessTime) + list.add(lastAccessTime); + + boolean present_properties = true && (isSetProperties()); + list.add(present_properties); + if (present_properties) + list.add(properties); + + boolean present_sizeInBytes = true && (isSetSizeInBytes()); + list.add(present_sizeInBytes); + if (present_sizeInBytes) + list.add(sizeInBytes); + + boolean present_rowCount = true && (isSetRowCount()); + list.add(present_rowCount); + if (present_rowCount) + list.add(rowCount); + + boolean present_colStats = true && (isSetColStats()); + list.add(present_colStats); + if (present_colStats) + list.add(colStats); + + boolean present_isBroadcastable = true; + list.add(present_isBroadcastable); + if (present_isBroadcastable) + list.add(isBroadcastable); + + boolean present_viewOriginalText = true && (isSetViewOriginalText()); + list.add(present_viewOriginalText); + if (present_viewOriginalText) + list.add(viewOriginalText); + + boolean present_viewText = true && (isSetViewText()); + list.add(present_viewText); + if (present_viewText) + list.add(viewText); + + boolean present_comment = true && (isSetComment()); + list.add(present_comment); + if (present_comment) + list.add(comment); + + boolean present_unsupportedFeatures = true && (isSetUnsupportedFeatures()); + list.add(present_unsupportedFeatures); + if (present_unsupportedFeatures) + list.add(unsupportedFeatures); + + boolean present_tracksPartitionsInCatalog = true; + list.add(present_tracksPartitionsInCatalog); + if (present_tracksPartitionsInCatalog) + list.add(tracksPartitionsInCatalog); + + boolean present_schemaPreservesCase = true; + list.add(present_schemaPreservesCase); + if (present_schemaPreservesCase) + list.add(schemaPreservesCase); + + return list.hashCode(); + } + + @Override + public int compareTo(CatalogTableObject other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetTableName()).compareTo(other.isSetTableName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetTableName()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tableName, other.tableName); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetSchemaName()).compareTo(other.isSetSchemaName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSchemaName()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.schemaName, other.schemaName); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetTableType()).compareTo(other.isSetTableType()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetTableType()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tableType, other.tableType); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetStorage()).compareTo(other.isSetStorage()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetStorage()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.storage, other.storage); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetTableSchema()).compareTo(other.isSetTableSchema()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetTableSchema()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tableSchema, other.tableSchema); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetProvider()).compareTo(other.isSetProvider()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetProvider()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.provider, other.provider); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetPartitionColumns()).compareTo(other.isSetPartitionColumns()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetPartitionColumns()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.partitionColumns, other.partitionColumns); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetIndexColumns()).compareTo(other.isSetIndexColumns()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetIndexColumns()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.indexColumns, other.indexColumns); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetPrimaryKeyColumns()).compareTo(other.isSetPrimaryKeyColumns()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetPrimaryKeyColumns()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.primaryKeyColumns, other.primaryKeyColumns); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetNumBuckets()).compareTo(other.isSetNumBuckets()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetNumBuckets()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.numBuckets, other.numBuckets); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetRedundancy()).compareTo(other.isSetRedundancy()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetRedundancy()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.redundancy, other.redundancy); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetBucketOwners()).compareTo(other.isSetBucketOwners()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetBucketOwners()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.bucketOwners, other.bucketOwners); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetBucketColumns()).compareTo(other.isSetBucketColumns()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetBucketColumns()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.bucketColumns, other.bucketColumns); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetSortColumns()).compareTo(other.isSetSortColumns()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSortColumns()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sortColumns, other.sortColumns); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetOwner()).compareTo(other.isSetOwner()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetOwner()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.owner, other.owner); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetCreateTime()).compareTo(other.isSetCreateTime()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetCreateTime()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.createTime, other.createTime); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetLastAccessTime()).compareTo(other.isSetLastAccessTime()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetLastAccessTime()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.lastAccessTime, other.lastAccessTime); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetProperties()).compareTo(other.isSetProperties()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetProperties()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.properties, other.properties); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetSizeInBytes()).compareTo(other.isSetSizeInBytes()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSizeInBytes()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sizeInBytes, other.sizeInBytes); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetRowCount()).compareTo(other.isSetRowCount()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetRowCount()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.rowCount, other.rowCount); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetColStats()).compareTo(other.isSetColStats()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetColStats()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.colStats, other.colStats); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetIsBroadcastable()).compareTo(other.isSetIsBroadcastable()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetIsBroadcastable()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.isBroadcastable, other.isBroadcastable); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetViewOriginalText()).compareTo(other.isSetViewOriginalText()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetViewOriginalText()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.viewOriginalText, other.viewOriginalText); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetViewText()).compareTo(other.isSetViewText()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetViewText()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.viewText, other.viewText); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetComment()).compareTo(other.isSetComment()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetComment()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.comment, other.comment); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetUnsupportedFeatures()).compareTo(other.isSetUnsupportedFeatures()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetUnsupportedFeatures()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.unsupportedFeatures, other.unsupportedFeatures); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetTracksPartitionsInCatalog()).compareTo(other.isSetTracksPartitionsInCatalog()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetTracksPartitionsInCatalog()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tracksPartitionsInCatalog, other.tracksPartitionsInCatalog); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetSchemaPreservesCase()).compareTo(other.isSetSchemaPreservesCase()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSchemaPreservesCase()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.schemaPreservesCase, other.schemaPreservesCase); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("CatalogTableObject("); + boolean first = true; + + sb.append("tableName:"); + if (this.tableName == null) { + sb.append("null"); + } else { + sb.append(this.tableName); + } + first = false; + if (isSetSchemaName()) { + if (!first) sb.append(", "); + sb.append("schemaName:"); + if (this.schemaName == null) { + sb.append("null"); + } else { + sb.append(this.schemaName); + } + first = false; + } + if (!first) sb.append(", "); + sb.append("tableType:"); + if (this.tableType == null) { + sb.append("null"); + } else { + sb.append(this.tableType); + } + first = false; + if (!first) sb.append(", "); + sb.append("storage:"); + if (this.storage == null) { + sb.append("null"); + } else { + sb.append(this.storage); + } + first = false; + if (!first) sb.append(", "); + sb.append("tableSchema:"); + if (this.tableSchema == null) { + sb.append("null"); + } else { + sb.append(this.tableSchema); + } + first = false; + if (isSetProvider()) { + if (!first) sb.append(", "); + sb.append("provider:"); + if (this.provider == null) { + sb.append("null"); + } else { + sb.append(this.provider); + } + first = false; + } + if (!first) sb.append(", "); + sb.append("partitionColumns:"); + if (this.partitionColumns == null) { + sb.append("null"); + } else { + sb.append(this.partitionColumns); + } + first = false; + if (!first) sb.append(", "); + sb.append("indexColumns:"); + if (this.indexColumns == null) { + sb.append("null"); + } else { + sb.append(this.indexColumns); + } + first = false; + if (!first) sb.append(", "); + sb.append("primaryKeyColumns:"); + if (this.primaryKeyColumns == null) { + sb.append("null"); + } else { + sb.append(this.primaryKeyColumns); + } + first = false; + if (isSetNumBuckets()) { + if (!first) sb.append(", "); + sb.append("numBuckets:"); + sb.append(this.numBuckets); + first = false; + } + if (isSetRedundancy()) { + if (!first) sb.append(", "); + sb.append("redundancy:"); + sb.append(this.redundancy); + first = false; + } + if (!first) sb.append(", "); + sb.append("bucketOwners:"); + if (this.bucketOwners == null) { + sb.append("null"); + } else { + sb.append(this.bucketOwners); + } + first = false; + if (!first) sb.append(", "); + sb.append("bucketColumns:"); + if (this.bucketColumns == null) { + sb.append("null"); + } else { + sb.append(this.bucketColumns); + } + first = false; + if (!first) sb.append(", "); + sb.append("sortColumns:"); + if (this.sortColumns == null) { + sb.append("null"); + } else { + sb.append(this.sortColumns); + } + first = false; + if (!first) sb.append(", "); + sb.append("owner:"); + if (this.owner == null) { + sb.append("null"); + } else { + sb.append(this.owner); + } + first = false; + if (!first) sb.append(", "); + sb.append("createTime:"); + sb.append(this.createTime); + first = false; + if (!first) sb.append(", "); + sb.append("lastAccessTime:"); + sb.append(this.lastAccessTime); + first = false; + if (!first) sb.append(", "); + sb.append("properties:"); + if (this.properties == null) { + sb.append("null"); + } else { + sb.append(this.properties); + } + first = false; + if (isSetSizeInBytes()) { + if (!first) sb.append(", "); + sb.append("sizeInBytes:"); + sb.append(this.sizeInBytes); + first = false; + } + if (isSetRowCount()) { + if (!first) sb.append(", "); + sb.append("rowCount:"); + sb.append(this.rowCount); + first = false; + } + if (!first) sb.append(", "); + sb.append("colStats:"); + if (this.colStats == null) { + sb.append("null"); + } else { + sb.append(this.colStats); + } + first = false; + if (!first) sb.append(", "); + sb.append("isBroadcastable:"); + sb.append(this.isBroadcastable); + first = false; + if (isSetViewOriginalText()) { + if (!first) sb.append(", "); + sb.append("viewOriginalText:"); + if (this.viewOriginalText == null) { + sb.append("null"); + } else { + sb.append(this.viewOriginalText); + } + first = false; + } + if (isSetViewText()) { + if (!first) sb.append(", "); + sb.append("viewText:"); + if (this.viewText == null) { + sb.append("null"); + } else { + sb.append(this.viewText); + } + first = false; + } + if (isSetComment()) { + if (!first) sb.append(", "); + sb.append("comment:"); + if (this.comment == null) { + sb.append("null"); + } else { + sb.append(this.comment); + } + first = false; + } + if (!first) sb.append(", "); + sb.append("unsupportedFeatures:"); + if (this.unsupportedFeatures == null) { + sb.append("null"); + } else { + sb.append(this.unsupportedFeatures); + } + first = false; + if (!first) sb.append(", "); + sb.append("tracksPartitionsInCatalog:"); + sb.append(this.tracksPartitionsInCatalog); + first = false; + if (!first) sb.append(", "); + sb.append("schemaPreservesCase:"); + sb.append(this.schemaPreservesCase); + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (tableName == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'tableName' was not present! Struct: " + toString()); + } + if (tableType == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'tableType' was not present! Struct: " + toString()); + } + if (storage == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'storage' was not present! Struct: " + toString()); + } + if (tableSchema == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'tableSchema' was not present! Struct: " + toString()); + } + if (partitionColumns == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'partitionColumns' was not present! Struct: " + toString()); + } + if (indexColumns == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'indexColumns' was not present! Struct: " + toString()); + } + if (primaryKeyColumns == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'primaryKeyColumns' was not present! Struct: " + toString()); + } + if (bucketOwners == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'bucketOwners' was not present! Struct: " + toString()); + } + if (bucketColumns == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'bucketColumns' was not present! Struct: " + toString()); + } + if (sortColumns == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'sortColumns' was not present! Struct: " + toString()); + } + if (owner == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'owner' was not present! Struct: " + toString()); + } + // alas, we cannot check 'createTime' because it's a primitive and you chose the non-beans generator. + // alas, we cannot check 'lastAccessTime' because it's a primitive and you chose the non-beans generator. + if (properties == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'properties' was not present! Struct: " + toString()); + } + if (colStats == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'colStats' was not present! Struct: " + toString()); + } + // alas, we cannot check 'isBroadcastable' because it's a primitive and you chose the non-beans generator. + if (unsupportedFeatures == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'unsupportedFeatures' was not present! Struct: " + toString()); + } + // alas, we cannot check 'tracksPartitionsInCatalog' because it's a primitive and you chose the non-beans generator. + // alas, we cannot check 'schemaPreservesCase' because it's a primitive and you chose the non-beans generator. + // check for sub-struct validity + if (storage != null) { + storage.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bitfield = 0; + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class CatalogTableObjectStandardSchemeFactory implements SchemeFactory { + public CatalogTableObjectStandardScheme getScheme() { + return new CatalogTableObjectStandardScheme(); + } + } + + private static class CatalogTableObjectStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, CatalogTableObject struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // TABLE_NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.tableName = iprot.readString(); + struct.setTableNameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // SCHEMA_NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.schemaName = iprot.readString(); + struct.setSchemaNameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // TABLE_TYPE + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.tableType = iprot.readString(); + struct.setTableTypeIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 4: // STORAGE + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.storage = new CatalogStorage(); + struct.storage.read(iprot); + struct.setStorageIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 5: // TABLE_SCHEMA + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.tableSchema = iprot.readString(); + struct.setTableSchemaIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 6: // PROVIDER + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.provider = iprot.readString(); + struct.setProviderIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 7: // PARTITION_COLUMNS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list298 = iprot.readListBegin(); + struct.partitionColumns = new ArrayList(_list298.size); + String _elem299; + for (int _i300 = 0; _i300 < _list298.size; ++_i300) + { + _elem299 = iprot.readString(); + struct.partitionColumns.add(_elem299); + } + iprot.readListEnd(); + } + struct.setPartitionColumnsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 8: // INDEX_COLUMNS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list301 = iprot.readListBegin(); + struct.indexColumns = new ArrayList(_list301.size); + String _elem302; + for (int _i303 = 0; _i303 < _list301.size; ++_i303) + { + _elem302 = iprot.readString(); + struct.indexColumns.add(_elem302); + } + iprot.readListEnd(); + } + struct.setIndexColumnsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 9: // PRIMARY_KEY_COLUMNS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list304 = iprot.readListBegin(); + struct.primaryKeyColumns = new ArrayList(_list304.size); + String _elem305; + for (int _i306 = 0; _i306 < _list304.size; ++_i306) + { + _elem305 = iprot.readString(); + struct.primaryKeyColumns.add(_elem305); + } + iprot.readListEnd(); + } + struct.setPrimaryKeyColumnsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 10: // NUM_BUCKETS + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.numBuckets = iprot.readI32(); + struct.setNumBucketsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 11: // REDUNDANCY + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.redundancy = iprot.readI32(); + struct.setRedundancyIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 12: // BUCKET_OWNERS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list307 = iprot.readListBegin(); + struct.bucketOwners = new ArrayList(_list307.size); + BucketOwners _elem308; + for (int _i309 = 0; _i309 < _list307.size; ++_i309) + { + _elem308 = new BucketOwners(); + _elem308.read(iprot); + struct.bucketOwners.add(_elem308); + } + iprot.readListEnd(); + } + struct.setBucketOwnersIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 13: // BUCKET_COLUMNS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list310 = iprot.readListBegin(); + struct.bucketColumns = new ArrayList(_list310.size); + String _elem311; + for (int _i312 = 0; _i312 < _list310.size; ++_i312) + { + _elem311 = iprot.readString(); + struct.bucketColumns.add(_elem311); + } + iprot.readListEnd(); + } + struct.setBucketColumnsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 14: // SORT_COLUMNS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list313 = iprot.readListBegin(); + struct.sortColumns = new ArrayList(_list313.size); + String _elem314; + for (int _i315 = 0; _i315 < _list313.size; ++_i315) + { + _elem314 = iprot.readString(); + struct.sortColumns.add(_elem314); + } + iprot.readListEnd(); + } + struct.setSortColumnsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 15: // OWNER + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.owner = iprot.readString(); + struct.setOwnerIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 16: // CREATE_TIME + if (schemeField.type == org.apache.thrift.protocol.TType.I64) { + struct.createTime = iprot.readI64(); + struct.setCreateTimeIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 17: // LAST_ACCESS_TIME + if (schemeField.type == org.apache.thrift.protocol.TType.I64) { + struct.lastAccessTime = iprot.readI64(); + struct.setLastAccessTimeIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 18: // PROPERTIES + if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { + { + org.apache.thrift.protocol.TMap _map316 = iprot.readMapBegin(); + struct.properties = new HashMap(2*_map316.size); + String _key317; + String _val318; + for (int _i319 = 0; _i319 < _map316.size; ++_i319) + { + _key317 = iprot.readString(); + _val318 = iprot.readString(); + struct.properties.put(_key317, _val318); + } + iprot.readMapEnd(); + } + struct.setPropertiesIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 19: // SIZE_IN_BYTES + if (schemeField.type == org.apache.thrift.protocol.TType.I64) { + struct.sizeInBytes = iprot.readI64(); + struct.setSizeInBytesIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 20: // ROW_COUNT + if (schemeField.type == org.apache.thrift.protocol.TType.I64) { + struct.rowCount = iprot.readI64(); + struct.setRowCountIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 21: // COL_STATS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list320 = iprot.readListBegin(); + struct.colStats = new ArrayList>(_list320.size); + Map _elem321; + for (int _i322 = 0; _i322 < _list320.size; ++_i322) + { + { + org.apache.thrift.protocol.TMap _map323 = iprot.readMapBegin(); + _elem321 = new HashMap(2*_map323.size); + String _key324; + String _val325; + for (int _i326 = 0; _i326 < _map323.size; ++_i326) + { + _key324 = iprot.readString(); + _val325 = iprot.readString(); + _elem321.put(_key324, _val325); + } + iprot.readMapEnd(); + } + struct.colStats.add(_elem321); + } + iprot.readListEnd(); + } + struct.setColStatsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 22: // IS_BROADCASTABLE + if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { + struct.isBroadcastable = iprot.readBool(); + struct.setIsBroadcastableIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 23: // VIEW_ORIGINAL_TEXT + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.viewOriginalText = iprot.readString(); + struct.setViewOriginalTextIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 24: // VIEW_TEXT + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.viewText = iprot.readString(); + struct.setViewTextIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 25: // COMMENT + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.comment = iprot.readString(); + struct.setCommentIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 26: // UNSUPPORTED_FEATURES + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list327 = iprot.readListBegin(); + struct.unsupportedFeatures = new ArrayList(_list327.size); + String _elem328; + for (int _i329 = 0; _i329 < _list327.size; ++_i329) + { + _elem328 = iprot.readString(); + struct.unsupportedFeatures.add(_elem328); + } + iprot.readListEnd(); + } + struct.setUnsupportedFeaturesIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 27: // TRACKS_PARTITIONS_IN_CATALOG + if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { + struct.tracksPartitionsInCatalog = iprot.readBool(); + struct.setTracksPartitionsInCatalogIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 28: // SCHEMA_PRESERVES_CASE + if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { + struct.schemaPreservesCase = iprot.readBool(); + struct.setSchemaPreservesCaseIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + if (!struct.isSetCreateTime()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'createTime' was not found in serialized data! Struct: " + toString()); + } + if (!struct.isSetLastAccessTime()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'lastAccessTime' was not found in serialized data! Struct: " + toString()); + } + if (!struct.isSetIsBroadcastable()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'isBroadcastable' was not found in serialized data! Struct: " + toString()); + } + if (!struct.isSetTracksPartitionsInCatalog()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'tracksPartitionsInCatalog' was not found in serialized data! Struct: " + toString()); + } + if (!struct.isSetSchemaPreservesCase()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'schemaPreservesCase' was not found in serialized data! Struct: " + toString()); + } + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, CatalogTableObject struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.tableName != null) { + oprot.writeFieldBegin(TABLE_NAME_FIELD_DESC); + oprot.writeString(struct.tableName); + oprot.writeFieldEnd(); + } + if (struct.schemaName != null) { + if (struct.isSetSchemaName()) { + oprot.writeFieldBegin(SCHEMA_NAME_FIELD_DESC); + oprot.writeString(struct.schemaName); + oprot.writeFieldEnd(); + } + } + if (struct.tableType != null) { + oprot.writeFieldBegin(TABLE_TYPE_FIELD_DESC); + oprot.writeString(struct.tableType); + oprot.writeFieldEnd(); + } + if (struct.storage != null) { + oprot.writeFieldBegin(STORAGE_FIELD_DESC); + struct.storage.write(oprot); + oprot.writeFieldEnd(); + } + if (struct.tableSchema != null) { + oprot.writeFieldBegin(TABLE_SCHEMA_FIELD_DESC); + oprot.writeString(struct.tableSchema); + oprot.writeFieldEnd(); + } + if (struct.provider != null) { + if (struct.isSetProvider()) { + oprot.writeFieldBegin(PROVIDER_FIELD_DESC); + oprot.writeString(struct.provider); + oprot.writeFieldEnd(); + } + } + if (struct.partitionColumns != null) { + oprot.writeFieldBegin(PARTITION_COLUMNS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.partitionColumns.size())); + for (String _iter330 : struct.partitionColumns) + { + oprot.writeString(_iter330); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + if (struct.indexColumns != null) { + oprot.writeFieldBegin(INDEX_COLUMNS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.indexColumns.size())); + for (String _iter331 : struct.indexColumns) + { + oprot.writeString(_iter331); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + if (struct.primaryKeyColumns != null) { + oprot.writeFieldBegin(PRIMARY_KEY_COLUMNS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.primaryKeyColumns.size())); + for (String _iter332 : struct.primaryKeyColumns) + { + oprot.writeString(_iter332); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + if (struct.isSetNumBuckets()) { + oprot.writeFieldBegin(NUM_BUCKETS_FIELD_DESC); + oprot.writeI32(struct.numBuckets); + oprot.writeFieldEnd(); + } + if (struct.isSetRedundancy()) { + oprot.writeFieldBegin(REDUNDANCY_FIELD_DESC); + oprot.writeI32(struct.redundancy); + oprot.writeFieldEnd(); + } + if (struct.bucketOwners != null) { + oprot.writeFieldBegin(BUCKET_OWNERS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.bucketOwners.size())); + for (BucketOwners _iter333 : struct.bucketOwners) + { + _iter333.write(oprot); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + if (struct.bucketColumns != null) { + oprot.writeFieldBegin(BUCKET_COLUMNS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.bucketColumns.size())); + for (String _iter334 : struct.bucketColumns) + { + oprot.writeString(_iter334); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + if (struct.sortColumns != null) { + oprot.writeFieldBegin(SORT_COLUMNS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.sortColumns.size())); + for (String _iter335 : struct.sortColumns) + { + oprot.writeString(_iter335); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + if (struct.owner != null) { + oprot.writeFieldBegin(OWNER_FIELD_DESC); + oprot.writeString(struct.owner); + oprot.writeFieldEnd(); + } + oprot.writeFieldBegin(CREATE_TIME_FIELD_DESC); + oprot.writeI64(struct.createTime); + oprot.writeFieldEnd(); + oprot.writeFieldBegin(LAST_ACCESS_TIME_FIELD_DESC); + oprot.writeI64(struct.lastAccessTime); + oprot.writeFieldEnd(); + if (struct.properties != null) { + oprot.writeFieldBegin(PROPERTIES_FIELD_DESC); + { + oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.properties.size())); + for (Map.Entry _iter336 : struct.properties.entrySet()) + { + oprot.writeString(_iter336.getKey()); + oprot.writeString(_iter336.getValue()); + } + oprot.writeMapEnd(); + } + oprot.writeFieldEnd(); + } + if (struct.isSetSizeInBytes()) { + oprot.writeFieldBegin(SIZE_IN_BYTES_FIELD_DESC); + oprot.writeI64(struct.sizeInBytes); + oprot.writeFieldEnd(); + } + if (struct.isSetRowCount()) { + oprot.writeFieldBegin(ROW_COUNT_FIELD_DESC); + oprot.writeI64(struct.rowCount); + oprot.writeFieldEnd(); + } + if (struct.colStats != null) { + oprot.writeFieldBegin(COL_STATS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.MAP, struct.colStats.size())); + for (Map _iter337 : struct.colStats) + { + { + oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, _iter337.size())); + for (Map.Entry _iter338 : _iter337.entrySet()) + { + oprot.writeString(_iter338.getKey()); + oprot.writeString(_iter338.getValue()); + } + oprot.writeMapEnd(); + } + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + oprot.writeFieldBegin(IS_BROADCASTABLE_FIELD_DESC); + oprot.writeBool(struct.isBroadcastable); + oprot.writeFieldEnd(); + if (struct.viewOriginalText != null) { + if (struct.isSetViewOriginalText()) { + oprot.writeFieldBegin(VIEW_ORIGINAL_TEXT_FIELD_DESC); + oprot.writeString(struct.viewOriginalText); + oprot.writeFieldEnd(); + } + } + if (struct.viewText != null) { + if (struct.isSetViewText()) { + oprot.writeFieldBegin(VIEW_TEXT_FIELD_DESC); + oprot.writeString(struct.viewText); + oprot.writeFieldEnd(); + } + } + if (struct.comment != null) { + if (struct.isSetComment()) { + oprot.writeFieldBegin(COMMENT_FIELD_DESC); + oprot.writeString(struct.comment); + oprot.writeFieldEnd(); + } + } + if (struct.unsupportedFeatures != null) { + oprot.writeFieldBegin(UNSUPPORTED_FEATURES_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.unsupportedFeatures.size())); + for (String _iter339 : struct.unsupportedFeatures) + { + oprot.writeString(_iter339); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + oprot.writeFieldBegin(TRACKS_PARTITIONS_IN_CATALOG_FIELD_DESC); + oprot.writeBool(struct.tracksPartitionsInCatalog); + oprot.writeFieldEnd(); + oprot.writeFieldBegin(SCHEMA_PRESERVES_CASE_FIELD_DESC); + oprot.writeBool(struct.schemaPreservesCase); + oprot.writeFieldEnd(); + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class CatalogTableObjectTupleSchemeFactory implements SchemeFactory { + public CatalogTableObjectTupleScheme getScheme() { + return new CatalogTableObjectTupleScheme(); + } + } + + private static class CatalogTableObjectTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, CatalogTableObject struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + oprot.writeString(struct.tableName); + oprot.writeString(struct.tableType); + struct.storage.write(oprot); + oprot.writeString(struct.tableSchema); + { + oprot.writeI32(struct.partitionColumns.size()); + for (String _iter340 : struct.partitionColumns) + { + oprot.writeString(_iter340); + } + } + { + oprot.writeI32(struct.indexColumns.size()); + for (String _iter341 : struct.indexColumns) + { + oprot.writeString(_iter341); + } + } + { + oprot.writeI32(struct.primaryKeyColumns.size()); + for (String _iter342 : struct.primaryKeyColumns) + { + oprot.writeString(_iter342); + } + } + { + oprot.writeI32(struct.bucketOwners.size()); + for (BucketOwners _iter343 : struct.bucketOwners) + { + _iter343.write(oprot); + } + } + { + oprot.writeI32(struct.bucketColumns.size()); + for (String _iter344 : struct.bucketColumns) + { + oprot.writeString(_iter344); + } + } + { + oprot.writeI32(struct.sortColumns.size()); + for (String _iter345 : struct.sortColumns) + { + oprot.writeString(_iter345); + } + } + oprot.writeString(struct.owner); + oprot.writeI64(struct.createTime); + oprot.writeI64(struct.lastAccessTime); + { + oprot.writeI32(struct.properties.size()); + for (Map.Entry _iter346 : struct.properties.entrySet()) + { + oprot.writeString(_iter346.getKey()); + oprot.writeString(_iter346.getValue()); + } + } + { + oprot.writeI32(struct.colStats.size()); + for (Map _iter347 : struct.colStats) + { + { + oprot.writeI32(_iter347.size()); + for (Map.Entry _iter348 : _iter347.entrySet()) + { + oprot.writeString(_iter348.getKey()); + oprot.writeString(_iter348.getValue()); + } + } + } + } + oprot.writeBool(struct.isBroadcastable); + { + oprot.writeI32(struct.unsupportedFeatures.size()); + for (String _iter349 : struct.unsupportedFeatures) + { + oprot.writeString(_iter349); + } + } + oprot.writeBool(struct.tracksPartitionsInCatalog); + oprot.writeBool(struct.schemaPreservesCase); + BitSet optionals = new BitSet(); + if (struct.isSetSchemaName()) { + optionals.set(0); + } + if (struct.isSetProvider()) { + optionals.set(1); + } + if (struct.isSetNumBuckets()) { + optionals.set(2); + } + if (struct.isSetRedundancy()) { + optionals.set(3); + } + if (struct.isSetSizeInBytes()) { + optionals.set(4); + } + if (struct.isSetRowCount()) { + optionals.set(5); + } + if (struct.isSetViewOriginalText()) { + optionals.set(6); + } + if (struct.isSetViewText()) { + optionals.set(7); + } + if (struct.isSetComment()) { + optionals.set(8); + } + oprot.writeBitSet(optionals, 9); + if (struct.isSetSchemaName()) { + oprot.writeString(struct.schemaName); + } + if (struct.isSetProvider()) { + oprot.writeString(struct.provider); + } + if (struct.isSetNumBuckets()) { + oprot.writeI32(struct.numBuckets); + } + if (struct.isSetRedundancy()) { + oprot.writeI32(struct.redundancy); + } + if (struct.isSetSizeInBytes()) { + oprot.writeI64(struct.sizeInBytes); + } + if (struct.isSetRowCount()) { + oprot.writeI64(struct.rowCount); + } + if (struct.isSetViewOriginalText()) { + oprot.writeString(struct.viewOriginalText); + } + if (struct.isSetViewText()) { + oprot.writeString(struct.viewText); + } + if (struct.isSetComment()) { + oprot.writeString(struct.comment); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, CatalogTableObject struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.tableName = iprot.readString(); + struct.setTableNameIsSet(true); + struct.tableType = iprot.readString(); + struct.setTableTypeIsSet(true); + struct.storage = new CatalogStorage(); + struct.storage.read(iprot); + struct.setStorageIsSet(true); + struct.tableSchema = iprot.readString(); + struct.setTableSchemaIsSet(true); + { + org.apache.thrift.protocol.TList _list350 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.partitionColumns = new ArrayList(_list350.size); + String _elem351; + for (int _i352 = 0; _i352 < _list350.size; ++_i352) + { + _elem351 = iprot.readString(); + struct.partitionColumns.add(_elem351); + } + } + struct.setPartitionColumnsIsSet(true); + { + org.apache.thrift.protocol.TList _list353 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.indexColumns = new ArrayList(_list353.size); + String _elem354; + for (int _i355 = 0; _i355 < _list353.size; ++_i355) + { + _elem354 = iprot.readString(); + struct.indexColumns.add(_elem354); + } + } + struct.setIndexColumnsIsSet(true); + { + org.apache.thrift.protocol.TList _list356 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.primaryKeyColumns = new ArrayList(_list356.size); + String _elem357; + for (int _i358 = 0; _i358 < _list356.size; ++_i358) + { + _elem357 = iprot.readString(); + struct.primaryKeyColumns.add(_elem357); + } + } + struct.setPrimaryKeyColumnsIsSet(true); + { + org.apache.thrift.protocol.TList _list359 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.bucketOwners = new ArrayList(_list359.size); + BucketOwners _elem360; + for (int _i361 = 0; _i361 < _list359.size; ++_i361) + { + _elem360 = new BucketOwners(); + _elem360.read(iprot); + struct.bucketOwners.add(_elem360); + } + } + struct.setBucketOwnersIsSet(true); + { + org.apache.thrift.protocol.TList _list362 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.bucketColumns = new ArrayList(_list362.size); + String _elem363; + for (int _i364 = 0; _i364 < _list362.size; ++_i364) + { + _elem363 = iprot.readString(); + struct.bucketColumns.add(_elem363); + } + } + struct.setBucketColumnsIsSet(true); + { + org.apache.thrift.protocol.TList _list365 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.sortColumns = new ArrayList(_list365.size); + String _elem366; + for (int _i367 = 0; _i367 < _list365.size; ++_i367) + { + _elem366 = iprot.readString(); + struct.sortColumns.add(_elem366); + } + } + struct.setSortColumnsIsSet(true); + struct.owner = iprot.readString(); + struct.setOwnerIsSet(true); + struct.createTime = iprot.readI64(); + struct.setCreateTimeIsSet(true); + struct.lastAccessTime = iprot.readI64(); + struct.setLastAccessTimeIsSet(true); + { + org.apache.thrift.protocol.TMap _map368 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.properties = new HashMap(2*_map368.size); + String _key369; + String _val370; + for (int _i371 = 0; _i371 < _map368.size; ++_i371) + { + _key369 = iprot.readString(); + _val370 = iprot.readString(); + struct.properties.put(_key369, _val370); + } + } + struct.setPropertiesIsSet(true); + { + org.apache.thrift.protocol.TList _list372 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.MAP, iprot.readI32()); + struct.colStats = new ArrayList>(_list372.size); + Map _elem373; + for (int _i374 = 0; _i374 < _list372.size; ++_i374) + { + { + org.apache.thrift.protocol.TMap _map375 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + _elem373 = new HashMap(2*_map375.size); + String _key376; + String _val377; + for (int _i378 = 0; _i378 < _map375.size; ++_i378) + { + _key376 = iprot.readString(); + _val377 = iprot.readString(); + _elem373.put(_key376, _val377); + } + } + struct.colStats.add(_elem373); + } + } + struct.setColStatsIsSet(true); + struct.isBroadcastable = iprot.readBool(); + struct.setIsBroadcastableIsSet(true); + { + org.apache.thrift.protocol.TList _list379 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.unsupportedFeatures = new ArrayList(_list379.size); + String _elem380; + for (int _i381 = 0; _i381 < _list379.size; ++_i381) + { + _elem380 = iprot.readString(); + struct.unsupportedFeatures.add(_elem380); + } + } + struct.setUnsupportedFeaturesIsSet(true); + struct.tracksPartitionsInCatalog = iprot.readBool(); + struct.setTracksPartitionsInCatalogIsSet(true); + struct.schemaPreservesCase = iprot.readBool(); + struct.setSchemaPreservesCaseIsSet(true); + BitSet incoming = iprot.readBitSet(9); + if (incoming.get(0)) { + struct.schemaName = iprot.readString(); + struct.setSchemaNameIsSet(true); + } + if (incoming.get(1)) { + struct.provider = iprot.readString(); + struct.setProviderIsSet(true); + } + if (incoming.get(2)) { + struct.numBuckets = iprot.readI32(); + struct.setNumBucketsIsSet(true); + } + if (incoming.get(3)) { + struct.redundancy = iprot.readI32(); + struct.setRedundancyIsSet(true); + } + if (incoming.get(4)) { + struct.sizeInBytes = iprot.readI64(); + struct.setSizeInBytesIsSet(true); + } + if (incoming.get(5)) { + struct.rowCount = iprot.readI64(); + struct.setRowCountIsSet(true); + } + if (incoming.get(6)) { + struct.viewOriginalText = iprot.readString(); + struct.setViewOriginalTextIsSet(true); + } + if (incoming.get(7)) { + struct.viewText = iprot.readString(); + struct.setViewTextIsSet(true); + } + if (incoming.get(8)) { + struct.comment = iprot.readString(); + struct.setCommentIsSet(true); + } + } + } + +} + diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/ClobChunk.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/ClobChunk.java index c8b871557..d2f7fa1a7 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/ClobChunk.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/ClobChunk.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2017-11-17") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-10") public class ClobChunk implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ClobChunk"); diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/ColumnDescriptor.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/ColumnDescriptor.java index fee09a871..7871fe5a9 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/ColumnDescriptor.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/ColumnDescriptor.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2017-11-17") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-10") public class ColumnDescriptor implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ColumnDescriptor"); diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/ColumnValue.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/ColumnValue.java index abe3b2ac3..8636cbaef 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/ColumnValue.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/ColumnValue.java @@ -7,7 +7,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/ConnectionProperties.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/ConnectionProperties.java index 2f72ede4e..bf3724107 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/ConnectionProperties.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/ConnectionProperties.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2017-11-17") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-10") public class ConnectionProperties implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ConnectionProperties"); diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/Decimal.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/Decimal.java index 1ae8ea21b..650739891 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/Decimal.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/Decimal.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2017-11-17") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-10") public class Decimal implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Decimal"); diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/EntityId.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/EntityId.java index 672467eec..3a9241896 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/EntityId.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/EntityId.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2017-11-17") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-10") public class EntityId implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("EntityId"); diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/HostAddress.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/HostAddress.java index dfa34fdd8..f05677b2c 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/HostAddress.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/HostAddress.java @@ -26,7 +26,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/LocatorService.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/LocatorService.java index 8dc5cadbf..bb9e2e7c0 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/LocatorService.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/LocatorService.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2017-11-17") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-10") public class LocatorService { public interface Iface { @@ -705,13 +705,13 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, getPreferredServer_ case 1: // SERVER_TYPES if (schemeField.type == org.apache.thrift.protocol.TType.SET) { { - org.apache.thrift.protocol.TSet _set270 = iprot.readSetBegin(); - struct.serverTypes = new HashSet(2*_set270.size); - ServerType _elem271; - for (int _i272 = 0; _i272 < _set270.size; ++_i272) + org.apache.thrift.protocol.TSet _set480 = iprot.readSetBegin(); + struct.serverTypes = new HashSet(2*_set480.size); + ServerType _elem481; + for (int _i482 = 0; _i482 < _set480.size; ++_i482) { - _elem271 = io.snappydata.thrift.ServerType.findByValue(iprot.readI32()); - struct.serverTypes.add(_elem271); + _elem481 = io.snappydata.thrift.ServerType.findByValue(iprot.readI32()); + struct.serverTypes.add(_elem481); } iprot.readSetEnd(); } @@ -723,13 +723,13 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, getPreferredServer_ case 2: // SERVER_GROUPS if (schemeField.type == org.apache.thrift.protocol.TType.SET) { { - org.apache.thrift.protocol.TSet _set273 = iprot.readSetBegin(); - struct.serverGroups = new HashSet(2*_set273.size); - String _elem274; - for (int _i275 = 0; _i275 < _set273.size; ++_i275) + org.apache.thrift.protocol.TSet _set483 = iprot.readSetBegin(); + struct.serverGroups = new HashSet(2*_set483.size); + String _elem484; + for (int _i485 = 0; _i485 < _set483.size; ++_i485) { - _elem274 = iprot.readString(); - struct.serverGroups.add(_elem274); + _elem484 = iprot.readString(); + struct.serverGroups.add(_elem484); } iprot.readSetEnd(); } @@ -741,14 +741,14 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, getPreferredServer_ case 3: // FAILED_SERVERS if (schemeField.type == org.apache.thrift.protocol.TType.SET) { { - org.apache.thrift.protocol.TSet _set276 = iprot.readSetBegin(); - struct.failedServers = new HashSet(2*_set276.size); - HostAddress _elem277; - for (int _i278 = 0; _i278 < _set276.size; ++_i278) + org.apache.thrift.protocol.TSet _set486 = iprot.readSetBegin(); + struct.failedServers = new HashSet(2*_set486.size); + HostAddress _elem487; + for (int _i488 = 0; _i488 < _set486.size; ++_i488) { - _elem277 = new HostAddress(); - _elem277.read(iprot); - struct.failedServers.add(_elem277); + _elem487 = new HostAddress(); + _elem487.read(iprot); + struct.failedServers.add(_elem487); } iprot.readSetEnd(); } @@ -776,9 +776,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, getPreferredServer oprot.writeFieldBegin(SERVER_TYPES_FIELD_DESC); { oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.I32, struct.serverTypes.size())); - for (ServerType _iter279 : struct.serverTypes) + for (ServerType _iter489 : struct.serverTypes) { - oprot.writeI32(_iter279.getValue()); + oprot.writeI32(_iter489.getValue()); } oprot.writeSetEnd(); } @@ -788,9 +788,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, getPreferredServer oprot.writeFieldBegin(SERVER_GROUPS_FIELD_DESC); { oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, struct.serverGroups.size())); - for (String _iter280 : struct.serverGroups) + for (String _iter490 : struct.serverGroups) { - oprot.writeString(_iter280); + oprot.writeString(_iter490); } oprot.writeSetEnd(); } @@ -800,9 +800,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, getPreferredServer oprot.writeFieldBegin(FAILED_SERVERS_FIELD_DESC); { oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, struct.failedServers.size())); - for (HostAddress _iter281 : struct.failedServers) + for (HostAddress _iter491 : struct.failedServers) { - _iter281.write(oprot); + _iter491.write(oprot); } oprot.writeSetEnd(); } @@ -839,27 +839,27 @@ public void write(org.apache.thrift.protocol.TProtocol prot, getPreferredServer_ if (struct.isSetServerTypes()) { { oprot.writeI32(struct.serverTypes.size()); - for (ServerType _iter282 : struct.serverTypes) + for (ServerType _iter492 : struct.serverTypes) { - oprot.writeI32(_iter282.getValue()); + oprot.writeI32(_iter492.getValue()); } } } if (struct.isSetServerGroups()) { { oprot.writeI32(struct.serverGroups.size()); - for (String _iter283 : struct.serverGroups) + for (String _iter493 : struct.serverGroups) { - oprot.writeString(_iter283); + oprot.writeString(_iter493); } } } if (struct.isSetFailedServers()) { { oprot.writeI32(struct.failedServers.size()); - for (HostAddress _iter284 : struct.failedServers) + for (HostAddress _iter494 : struct.failedServers) { - _iter284.write(oprot); + _iter494.write(oprot); } } } @@ -871,40 +871,40 @@ public void read(org.apache.thrift.protocol.TProtocol prot, getPreferredServer_a BitSet incoming = iprot.readBitSet(3); if (incoming.get(0)) { { - org.apache.thrift.protocol.TSet _set285 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.I32, iprot.readI32()); - struct.serverTypes = new HashSet(2*_set285.size); - ServerType _elem286; - for (int _i287 = 0; _i287 < _set285.size; ++_i287) + org.apache.thrift.protocol.TSet _set495 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.serverTypes = new HashSet(2*_set495.size); + ServerType _elem496; + for (int _i497 = 0; _i497 < _set495.size; ++_i497) { - _elem286 = io.snappydata.thrift.ServerType.findByValue(iprot.readI32()); - struct.serverTypes.add(_elem286); + _elem496 = io.snappydata.thrift.ServerType.findByValue(iprot.readI32()); + struct.serverTypes.add(_elem496); } } struct.setServerTypesIsSet(true); } if (incoming.get(1)) { { - org.apache.thrift.protocol.TSet _set288 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); - struct.serverGroups = new HashSet(2*_set288.size); - String _elem289; - for (int _i290 = 0; _i290 < _set288.size; ++_i290) + org.apache.thrift.protocol.TSet _set498 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.serverGroups = new HashSet(2*_set498.size); + String _elem499; + for (int _i500 = 0; _i500 < _set498.size; ++_i500) { - _elem289 = iprot.readString(); - struct.serverGroups.add(_elem289); + _elem499 = iprot.readString(); + struct.serverGroups.add(_elem499); } } struct.setServerGroupsIsSet(true); } if (incoming.get(2)) { { - org.apache.thrift.protocol.TSet _set291 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.failedServers = new HashSet(2*_set291.size); - HostAddress _elem292; - for (int _i293 = 0; _i293 < _set291.size; ++_i293) + org.apache.thrift.protocol.TSet _set501 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.failedServers = new HashSet(2*_set501.size); + HostAddress _elem502; + for (int _i503 = 0; _i503 < _set501.size; ++_i503) { - _elem292 = new HostAddress(); - _elem292.read(iprot); - struct.failedServers.add(_elem292); + _elem502 = new HostAddress(); + _elem502.read(iprot); + struct.failedServers.add(_elem502); } } struct.setFailedServersIsSet(true); @@ -1904,13 +1904,13 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, getAllServersWithPr case 1: // SERVER_TYPES if (schemeField.type == org.apache.thrift.protocol.TType.SET) { { - org.apache.thrift.protocol.TSet _set294 = iprot.readSetBegin(); - struct.serverTypes = new HashSet(2*_set294.size); - ServerType _elem295; - for (int _i296 = 0; _i296 < _set294.size; ++_i296) + org.apache.thrift.protocol.TSet _set504 = iprot.readSetBegin(); + struct.serverTypes = new HashSet(2*_set504.size); + ServerType _elem505; + for (int _i506 = 0; _i506 < _set504.size; ++_i506) { - _elem295 = io.snappydata.thrift.ServerType.findByValue(iprot.readI32()); - struct.serverTypes.add(_elem295); + _elem505 = io.snappydata.thrift.ServerType.findByValue(iprot.readI32()); + struct.serverTypes.add(_elem505); } iprot.readSetEnd(); } @@ -1922,13 +1922,13 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, getAllServersWithPr case 2: // SERVER_GROUPS if (schemeField.type == org.apache.thrift.protocol.TType.SET) { { - org.apache.thrift.protocol.TSet _set297 = iprot.readSetBegin(); - struct.serverGroups = new HashSet(2*_set297.size); - String _elem298; - for (int _i299 = 0; _i299 < _set297.size; ++_i299) + org.apache.thrift.protocol.TSet _set507 = iprot.readSetBegin(); + struct.serverGroups = new HashSet(2*_set507.size); + String _elem508; + for (int _i509 = 0; _i509 < _set507.size; ++_i509) { - _elem298 = iprot.readString(); - struct.serverGroups.add(_elem298); + _elem508 = iprot.readString(); + struct.serverGroups.add(_elem508); } iprot.readSetEnd(); } @@ -1940,14 +1940,14 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, getAllServersWithPr case 3: // FAILED_SERVERS if (schemeField.type == org.apache.thrift.protocol.TType.SET) { { - org.apache.thrift.protocol.TSet _set300 = iprot.readSetBegin(); - struct.failedServers = new HashSet(2*_set300.size); - HostAddress _elem301; - for (int _i302 = 0; _i302 < _set300.size; ++_i302) + org.apache.thrift.protocol.TSet _set510 = iprot.readSetBegin(); + struct.failedServers = new HashSet(2*_set510.size); + HostAddress _elem511; + for (int _i512 = 0; _i512 < _set510.size; ++_i512) { - _elem301 = new HostAddress(); - _elem301.read(iprot); - struct.failedServers.add(_elem301); + _elem511 = new HostAddress(); + _elem511.read(iprot); + struct.failedServers.add(_elem511); } iprot.readSetEnd(); } @@ -1975,9 +1975,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, getAllServersWithP oprot.writeFieldBegin(SERVER_TYPES_FIELD_DESC); { oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.I32, struct.serverTypes.size())); - for (ServerType _iter303 : struct.serverTypes) + for (ServerType _iter513 : struct.serverTypes) { - oprot.writeI32(_iter303.getValue()); + oprot.writeI32(_iter513.getValue()); } oprot.writeSetEnd(); } @@ -1987,9 +1987,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, getAllServersWithP oprot.writeFieldBegin(SERVER_GROUPS_FIELD_DESC); { oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, struct.serverGroups.size())); - for (String _iter304 : struct.serverGroups) + for (String _iter514 : struct.serverGroups) { - oprot.writeString(_iter304); + oprot.writeString(_iter514); } oprot.writeSetEnd(); } @@ -1999,9 +1999,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, getAllServersWithP oprot.writeFieldBegin(FAILED_SERVERS_FIELD_DESC); { oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, struct.failedServers.size())); - for (HostAddress _iter305 : struct.failedServers) + for (HostAddress _iter515 : struct.failedServers) { - _iter305.write(oprot); + _iter515.write(oprot); } oprot.writeSetEnd(); } @@ -2038,27 +2038,27 @@ public void write(org.apache.thrift.protocol.TProtocol prot, getAllServersWithPr if (struct.isSetServerTypes()) { { oprot.writeI32(struct.serverTypes.size()); - for (ServerType _iter306 : struct.serverTypes) + for (ServerType _iter516 : struct.serverTypes) { - oprot.writeI32(_iter306.getValue()); + oprot.writeI32(_iter516.getValue()); } } } if (struct.isSetServerGroups()) { { oprot.writeI32(struct.serverGroups.size()); - for (String _iter307 : struct.serverGroups) + for (String _iter517 : struct.serverGroups) { - oprot.writeString(_iter307); + oprot.writeString(_iter517); } } } if (struct.isSetFailedServers()) { { oprot.writeI32(struct.failedServers.size()); - for (HostAddress _iter308 : struct.failedServers) + for (HostAddress _iter518 : struct.failedServers) { - _iter308.write(oprot); + _iter518.write(oprot); } } } @@ -2070,40 +2070,40 @@ public void read(org.apache.thrift.protocol.TProtocol prot, getAllServersWithPre BitSet incoming = iprot.readBitSet(3); if (incoming.get(0)) { { - org.apache.thrift.protocol.TSet _set309 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.I32, iprot.readI32()); - struct.serverTypes = new HashSet(2*_set309.size); - ServerType _elem310; - for (int _i311 = 0; _i311 < _set309.size; ++_i311) + org.apache.thrift.protocol.TSet _set519 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.serverTypes = new HashSet(2*_set519.size); + ServerType _elem520; + for (int _i521 = 0; _i521 < _set519.size; ++_i521) { - _elem310 = io.snappydata.thrift.ServerType.findByValue(iprot.readI32()); - struct.serverTypes.add(_elem310); + _elem520 = io.snappydata.thrift.ServerType.findByValue(iprot.readI32()); + struct.serverTypes.add(_elem520); } } struct.setServerTypesIsSet(true); } if (incoming.get(1)) { { - org.apache.thrift.protocol.TSet _set312 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); - struct.serverGroups = new HashSet(2*_set312.size); - String _elem313; - for (int _i314 = 0; _i314 < _set312.size; ++_i314) + org.apache.thrift.protocol.TSet _set522 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.serverGroups = new HashSet(2*_set522.size); + String _elem523; + for (int _i524 = 0; _i524 < _set522.size; ++_i524) { - _elem313 = iprot.readString(); - struct.serverGroups.add(_elem313); + _elem523 = iprot.readString(); + struct.serverGroups.add(_elem523); } } struct.setServerGroupsIsSet(true); } if (incoming.get(2)) { { - org.apache.thrift.protocol.TSet _set315 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.failedServers = new HashSet(2*_set315.size); - HostAddress _elem316; - for (int _i317 = 0; _i317 < _set315.size; ++_i317) + org.apache.thrift.protocol.TSet _set525 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.failedServers = new HashSet(2*_set525.size); + HostAddress _elem526; + for (int _i527 = 0; _i527 < _set525.size; ++_i527) { - _elem316 = new HostAddress(); - _elem316.read(iprot); - struct.failedServers.add(_elem316); + _elem526 = new HostAddress(); + _elem526.read(iprot); + struct.failedServers.add(_elem526); } } struct.setFailedServersIsSet(true); @@ -2511,14 +2511,14 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, getAllServersWithPr case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list318 = iprot.readListBegin(); - struct.success = new ArrayList(_list318.size); - HostAddress _elem319; - for (int _i320 = 0; _i320 < _list318.size; ++_i320) + org.apache.thrift.protocol.TList _list528 = iprot.readListBegin(); + struct.success = new ArrayList(_list528.size); + HostAddress _elem529; + for (int _i530 = 0; _i530 < _list528.size; ++_i530) { - _elem319 = new HostAddress(); - _elem319.read(iprot); - struct.success.add(_elem319); + _elem529 = new HostAddress(); + _elem529.read(iprot); + struct.success.add(_elem529); } iprot.readListEnd(); } @@ -2555,9 +2555,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, getAllServersWithP oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.success.size())); - for (HostAddress _iter321 : struct.success) + for (HostAddress _iter531 : struct.success) { - _iter321.write(oprot); + _iter531.write(oprot); } oprot.writeListEnd(); } @@ -2596,9 +2596,9 @@ public void write(org.apache.thrift.protocol.TProtocol prot, getAllServersWithPr if (struct.isSetSuccess()) { { oprot.writeI32(struct.success.size()); - for (HostAddress _iter322 : struct.success) + for (HostAddress _iter532 : struct.success) { - _iter322.write(oprot); + _iter532.write(oprot); } } } @@ -2613,14 +2613,14 @@ public void read(org.apache.thrift.protocol.TProtocol prot, getAllServersWithPre BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { { - org.apache.thrift.protocol.TList _list323 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.success = new ArrayList(_list323.size); - HostAddress _elem324; - for (int _i325 = 0; _i325 < _list323.size; ++_i325) + org.apache.thrift.protocol.TList _list533 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.success = new ArrayList(_list533.size); + HostAddress _elem534; + for (int _i535 = 0; _i535 < _list533.size; ++_i535) { - _elem324 = new HostAddress(); - _elem324.read(iprot); - struct.success.add(_elem324); + _elem534 = new HostAddress(); + _elem534.read(iprot); + struct.success.add(_elem534); } } struct.setSuccessIsSet(true); diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/OpenConnectionArgs.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/OpenConnectionArgs.java index 6eecf4cbb..3c7b18f39 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/OpenConnectionArgs.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/OpenConnectionArgs.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2017-11-17") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-10") public class OpenConnectionArgs implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("OpenConnectionArgs"); diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/OutputParameter.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/OutputParameter.java index c007022c5..949d8919b 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/OutputParameter.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/OutputParameter.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2017-11-17") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-10") public class OutputParameter implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("OutputParameter"); diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/PrepareResult.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/PrepareResult.java index 9f95d12c2..3b1d40a3b 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/PrepareResult.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/PrepareResult.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2017-11-17") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-10") public class PrepareResult implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("PrepareResult"); diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/Row.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/Row.java index b1b6bb923..1e6da6835 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/Row.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/Row.java @@ -24,7 +24,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/RowSet.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/RowSet.java index 4544196f1..e1e045aa0 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/RowSet.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/RowSet.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2017-11-17") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-10") public class RowSet implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("RowSet"); diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/ServerType.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/ServerType.java index 72f801ec0..2448ff57b 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/ServerType.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/ServerType.java @@ -26,7 +26,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/ServiceMetaData.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/ServiceMetaData.java index e277970e2..b0b36a1e7 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/ServiceMetaData.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/ServiceMetaData.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2017-11-17") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-10") public class ServiceMetaData implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ServiceMetaData"); diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/ServiceMetaDataArgs.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/ServiceMetaDataArgs.java index d46248ca7..5739505de 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/ServiceMetaDataArgs.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/ServiceMetaDataArgs.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2017-11-17") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-10") public class ServiceMetaDataArgs implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ServiceMetaDataArgs"); diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/SnappyDataService.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/SnappyDataService.java index d49deb0f0..a48b38162 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/SnappyDataService.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/SnappyDataService.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2017-11-17") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-10") public class SnappyDataService { public interface Iface { @@ -3013,13 +3013,13 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, getPreferredServer_ case 1: // SERVER_TYPES if (schemeField.type == org.apache.thrift.protocol.TType.SET) { { - org.apache.thrift.protocol.TSet _set326 = iprot.readSetBegin(); - struct.serverTypes = new HashSet(2*_set326.size); - ServerType _elem327; - for (int _i328 = 0; _i328 < _set326.size; ++_i328) + org.apache.thrift.protocol.TSet _set536 = iprot.readSetBegin(); + struct.serverTypes = new HashSet(2*_set536.size); + ServerType _elem537; + for (int _i538 = 0; _i538 < _set536.size; ++_i538) { - _elem327 = io.snappydata.thrift.ServerType.findByValue(iprot.readI32()); - struct.serverTypes.add(_elem327); + _elem537 = io.snappydata.thrift.ServerType.findByValue(iprot.readI32()); + struct.serverTypes.add(_elem537); } iprot.readSetEnd(); } @@ -3031,13 +3031,13 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, getPreferredServer_ case 2: // SERVER_GROUPS if (schemeField.type == org.apache.thrift.protocol.TType.SET) { { - org.apache.thrift.protocol.TSet _set329 = iprot.readSetBegin(); - struct.serverGroups = new HashSet(2*_set329.size); - String _elem330; - for (int _i331 = 0; _i331 < _set329.size; ++_i331) + org.apache.thrift.protocol.TSet _set539 = iprot.readSetBegin(); + struct.serverGroups = new HashSet(2*_set539.size); + String _elem540; + for (int _i541 = 0; _i541 < _set539.size; ++_i541) { - _elem330 = iprot.readString(); - struct.serverGroups.add(_elem330); + _elem540 = iprot.readString(); + struct.serverGroups.add(_elem540); } iprot.readSetEnd(); } @@ -3049,14 +3049,14 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, getPreferredServer_ case 3: // FAILED_SERVERS if (schemeField.type == org.apache.thrift.protocol.TType.SET) { { - org.apache.thrift.protocol.TSet _set332 = iprot.readSetBegin(); - struct.failedServers = new HashSet(2*_set332.size); - HostAddress _elem333; - for (int _i334 = 0; _i334 < _set332.size; ++_i334) + org.apache.thrift.protocol.TSet _set542 = iprot.readSetBegin(); + struct.failedServers = new HashSet(2*_set542.size); + HostAddress _elem543; + for (int _i544 = 0; _i544 < _set542.size; ++_i544) { - _elem333 = new HostAddress(); - _elem333.read(iprot); - struct.failedServers.add(_elem333); + _elem543 = new HostAddress(); + _elem543.read(iprot); + struct.failedServers.add(_elem543); } iprot.readSetEnd(); } @@ -3084,9 +3084,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, getPreferredServer oprot.writeFieldBegin(SERVER_TYPES_FIELD_DESC); { oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.I32, struct.serverTypes.size())); - for (ServerType _iter335 : struct.serverTypes) + for (ServerType _iter545 : struct.serverTypes) { - oprot.writeI32(_iter335.getValue()); + oprot.writeI32(_iter545.getValue()); } oprot.writeSetEnd(); } @@ -3096,9 +3096,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, getPreferredServer oprot.writeFieldBegin(SERVER_GROUPS_FIELD_DESC); { oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, struct.serverGroups.size())); - for (String _iter336 : struct.serverGroups) + for (String _iter546 : struct.serverGroups) { - oprot.writeString(_iter336); + oprot.writeString(_iter546); } oprot.writeSetEnd(); } @@ -3108,9 +3108,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, getPreferredServer oprot.writeFieldBegin(FAILED_SERVERS_FIELD_DESC); { oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, struct.failedServers.size())); - for (HostAddress _iter337 : struct.failedServers) + for (HostAddress _iter547 : struct.failedServers) { - _iter337.write(oprot); + _iter547.write(oprot); } oprot.writeSetEnd(); } @@ -3147,27 +3147,27 @@ public void write(org.apache.thrift.protocol.TProtocol prot, getPreferredServer_ if (struct.isSetServerTypes()) { { oprot.writeI32(struct.serverTypes.size()); - for (ServerType _iter338 : struct.serverTypes) + for (ServerType _iter548 : struct.serverTypes) { - oprot.writeI32(_iter338.getValue()); + oprot.writeI32(_iter548.getValue()); } } } if (struct.isSetServerGroups()) { { oprot.writeI32(struct.serverGroups.size()); - for (String _iter339 : struct.serverGroups) + for (String _iter549 : struct.serverGroups) { - oprot.writeString(_iter339); + oprot.writeString(_iter549); } } } if (struct.isSetFailedServers()) { { oprot.writeI32(struct.failedServers.size()); - for (HostAddress _iter340 : struct.failedServers) + for (HostAddress _iter550 : struct.failedServers) { - _iter340.write(oprot); + _iter550.write(oprot); } } } @@ -3179,40 +3179,40 @@ public void read(org.apache.thrift.protocol.TProtocol prot, getPreferredServer_a BitSet incoming = iprot.readBitSet(3); if (incoming.get(0)) { { - org.apache.thrift.protocol.TSet _set341 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.I32, iprot.readI32()); - struct.serverTypes = new HashSet(2*_set341.size); - ServerType _elem342; - for (int _i343 = 0; _i343 < _set341.size; ++_i343) + org.apache.thrift.protocol.TSet _set551 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.serverTypes = new HashSet(2*_set551.size); + ServerType _elem552; + for (int _i553 = 0; _i553 < _set551.size; ++_i553) { - _elem342 = io.snappydata.thrift.ServerType.findByValue(iprot.readI32()); - struct.serverTypes.add(_elem342); + _elem552 = io.snappydata.thrift.ServerType.findByValue(iprot.readI32()); + struct.serverTypes.add(_elem552); } } struct.setServerTypesIsSet(true); } if (incoming.get(1)) { { - org.apache.thrift.protocol.TSet _set344 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); - struct.serverGroups = new HashSet(2*_set344.size); - String _elem345; - for (int _i346 = 0; _i346 < _set344.size; ++_i346) + org.apache.thrift.protocol.TSet _set554 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.serverGroups = new HashSet(2*_set554.size); + String _elem555; + for (int _i556 = 0; _i556 < _set554.size; ++_i556) { - _elem345 = iprot.readString(); - struct.serverGroups.add(_elem345); + _elem555 = iprot.readString(); + struct.serverGroups.add(_elem555); } } struct.setServerGroupsIsSet(true); } if (incoming.get(2)) { { - org.apache.thrift.protocol.TSet _set347 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.failedServers = new HashSet(2*_set347.size); - HostAddress _elem348; - for (int _i349 = 0; _i349 < _set347.size; ++_i349) + org.apache.thrift.protocol.TSet _set557 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.failedServers = new HashSet(2*_set557.size); + HostAddress _elem558; + for (int _i559 = 0; _i559 < _set557.size; ++_i559) { - _elem348 = new HostAddress(); - _elem348.read(iprot); - struct.failedServers.add(_elem348); + _elem558 = new HostAddress(); + _elem558.read(iprot); + struct.failedServers.add(_elem558); } } struct.setFailedServersIsSet(true); @@ -4212,13 +4212,13 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, getAllServersWithPr case 1: // SERVER_TYPES if (schemeField.type == org.apache.thrift.protocol.TType.SET) { { - org.apache.thrift.protocol.TSet _set350 = iprot.readSetBegin(); - struct.serverTypes = new HashSet(2*_set350.size); - ServerType _elem351; - for (int _i352 = 0; _i352 < _set350.size; ++_i352) + org.apache.thrift.protocol.TSet _set560 = iprot.readSetBegin(); + struct.serverTypes = new HashSet(2*_set560.size); + ServerType _elem561; + for (int _i562 = 0; _i562 < _set560.size; ++_i562) { - _elem351 = io.snappydata.thrift.ServerType.findByValue(iprot.readI32()); - struct.serverTypes.add(_elem351); + _elem561 = io.snappydata.thrift.ServerType.findByValue(iprot.readI32()); + struct.serverTypes.add(_elem561); } iprot.readSetEnd(); } @@ -4230,13 +4230,13 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, getAllServersWithPr case 2: // SERVER_GROUPS if (schemeField.type == org.apache.thrift.protocol.TType.SET) { { - org.apache.thrift.protocol.TSet _set353 = iprot.readSetBegin(); - struct.serverGroups = new HashSet(2*_set353.size); - String _elem354; - for (int _i355 = 0; _i355 < _set353.size; ++_i355) + org.apache.thrift.protocol.TSet _set563 = iprot.readSetBegin(); + struct.serverGroups = new HashSet(2*_set563.size); + String _elem564; + for (int _i565 = 0; _i565 < _set563.size; ++_i565) { - _elem354 = iprot.readString(); - struct.serverGroups.add(_elem354); + _elem564 = iprot.readString(); + struct.serverGroups.add(_elem564); } iprot.readSetEnd(); } @@ -4248,14 +4248,14 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, getAllServersWithPr case 3: // FAILED_SERVERS if (schemeField.type == org.apache.thrift.protocol.TType.SET) { { - org.apache.thrift.protocol.TSet _set356 = iprot.readSetBegin(); - struct.failedServers = new HashSet(2*_set356.size); - HostAddress _elem357; - for (int _i358 = 0; _i358 < _set356.size; ++_i358) + org.apache.thrift.protocol.TSet _set566 = iprot.readSetBegin(); + struct.failedServers = new HashSet(2*_set566.size); + HostAddress _elem567; + for (int _i568 = 0; _i568 < _set566.size; ++_i568) { - _elem357 = new HostAddress(); - _elem357.read(iprot); - struct.failedServers.add(_elem357); + _elem567 = new HostAddress(); + _elem567.read(iprot); + struct.failedServers.add(_elem567); } iprot.readSetEnd(); } @@ -4283,9 +4283,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, getAllServersWithP oprot.writeFieldBegin(SERVER_TYPES_FIELD_DESC); { oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.I32, struct.serverTypes.size())); - for (ServerType _iter359 : struct.serverTypes) + for (ServerType _iter569 : struct.serverTypes) { - oprot.writeI32(_iter359.getValue()); + oprot.writeI32(_iter569.getValue()); } oprot.writeSetEnd(); } @@ -4295,9 +4295,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, getAllServersWithP oprot.writeFieldBegin(SERVER_GROUPS_FIELD_DESC); { oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, struct.serverGroups.size())); - for (String _iter360 : struct.serverGroups) + for (String _iter570 : struct.serverGroups) { - oprot.writeString(_iter360); + oprot.writeString(_iter570); } oprot.writeSetEnd(); } @@ -4307,9 +4307,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, getAllServersWithP oprot.writeFieldBegin(FAILED_SERVERS_FIELD_DESC); { oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, struct.failedServers.size())); - for (HostAddress _iter361 : struct.failedServers) + for (HostAddress _iter571 : struct.failedServers) { - _iter361.write(oprot); + _iter571.write(oprot); } oprot.writeSetEnd(); } @@ -4346,27 +4346,27 @@ public void write(org.apache.thrift.protocol.TProtocol prot, getAllServersWithPr if (struct.isSetServerTypes()) { { oprot.writeI32(struct.serverTypes.size()); - for (ServerType _iter362 : struct.serverTypes) + for (ServerType _iter572 : struct.serverTypes) { - oprot.writeI32(_iter362.getValue()); + oprot.writeI32(_iter572.getValue()); } } } if (struct.isSetServerGroups()) { { oprot.writeI32(struct.serverGroups.size()); - for (String _iter363 : struct.serverGroups) + for (String _iter573 : struct.serverGroups) { - oprot.writeString(_iter363); + oprot.writeString(_iter573); } } } if (struct.isSetFailedServers()) { { oprot.writeI32(struct.failedServers.size()); - for (HostAddress _iter364 : struct.failedServers) + for (HostAddress _iter574 : struct.failedServers) { - _iter364.write(oprot); + _iter574.write(oprot); } } } @@ -4378,40 +4378,40 @@ public void read(org.apache.thrift.protocol.TProtocol prot, getAllServersWithPre BitSet incoming = iprot.readBitSet(3); if (incoming.get(0)) { { - org.apache.thrift.protocol.TSet _set365 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.I32, iprot.readI32()); - struct.serverTypes = new HashSet(2*_set365.size); - ServerType _elem366; - for (int _i367 = 0; _i367 < _set365.size; ++_i367) + org.apache.thrift.protocol.TSet _set575 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.serverTypes = new HashSet(2*_set575.size); + ServerType _elem576; + for (int _i577 = 0; _i577 < _set575.size; ++_i577) { - _elem366 = io.snappydata.thrift.ServerType.findByValue(iprot.readI32()); - struct.serverTypes.add(_elem366); + _elem576 = io.snappydata.thrift.ServerType.findByValue(iprot.readI32()); + struct.serverTypes.add(_elem576); } } struct.setServerTypesIsSet(true); } if (incoming.get(1)) { { - org.apache.thrift.protocol.TSet _set368 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); - struct.serverGroups = new HashSet(2*_set368.size); - String _elem369; - for (int _i370 = 0; _i370 < _set368.size; ++_i370) + org.apache.thrift.protocol.TSet _set578 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.serverGroups = new HashSet(2*_set578.size); + String _elem579; + for (int _i580 = 0; _i580 < _set578.size; ++_i580) { - _elem369 = iprot.readString(); - struct.serverGroups.add(_elem369); + _elem579 = iprot.readString(); + struct.serverGroups.add(_elem579); } } struct.setServerGroupsIsSet(true); } if (incoming.get(2)) { { - org.apache.thrift.protocol.TSet _set371 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.failedServers = new HashSet(2*_set371.size); - HostAddress _elem372; - for (int _i373 = 0; _i373 < _set371.size; ++_i373) + org.apache.thrift.protocol.TSet _set581 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.failedServers = new HashSet(2*_set581.size); + HostAddress _elem582; + for (int _i583 = 0; _i583 < _set581.size; ++_i583) { - _elem372 = new HostAddress(); - _elem372.read(iprot); - struct.failedServers.add(_elem372); + _elem582 = new HostAddress(); + _elem582.read(iprot); + struct.failedServers.add(_elem582); } } struct.setFailedServersIsSet(true); @@ -4819,14 +4819,14 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, getAllServersWithPr case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list374 = iprot.readListBegin(); - struct.success = new ArrayList(_list374.size); - HostAddress _elem375; - for (int _i376 = 0; _i376 < _list374.size; ++_i376) + org.apache.thrift.protocol.TList _list584 = iprot.readListBegin(); + struct.success = new ArrayList(_list584.size); + HostAddress _elem585; + for (int _i586 = 0; _i586 < _list584.size; ++_i586) { - _elem375 = new HostAddress(); - _elem375.read(iprot); - struct.success.add(_elem375); + _elem585 = new HostAddress(); + _elem585.read(iprot); + struct.success.add(_elem585); } iprot.readListEnd(); } @@ -4863,9 +4863,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, getAllServersWithP oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.success.size())); - for (HostAddress _iter377 : struct.success) + for (HostAddress _iter587 : struct.success) { - _iter377.write(oprot); + _iter587.write(oprot); } oprot.writeListEnd(); } @@ -4904,9 +4904,9 @@ public void write(org.apache.thrift.protocol.TProtocol prot, getAllServersWithPr if (struct.isSetSuccess()) { { oprot.writeI32(struct.success.size()); - for (HostAddress _iter378 : struct.success) + for (HostAddress _iter588 : struct.success) { - _iter378.write(oprot); + _iter588.write(oprot); } } } @@ -4921,14 +4921,14 @@ public void read(org.apache.thrift.protocol.TProtocol prot, getAllServersWithPre BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { { - org.apache.thrift.protocol.TList _list379 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.success = new ArrayList(_list379.size); - HostAddress _elem380; - for (int _i381 = 0; _i381 < _list379.size; ++_i381) + org.apache.thrift.protocol.TList _list589 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.success = new ArrayList(_list589.size); + HostAddress _elem590; + for (int _i591 = 0; _i591 < _list589.size; ++_i591) { - _elem380 = new HostAddress(); - _elem380.read(iprot); - struct.success.add(_elem380); + _elem590 = new HostAddress(); + _elem590.read(iprot); + struct.success.add(_elem590); } } struct.setSuccessIsSet(true); @@ -6460,16 +6460,16 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, execute_args struct case 3: // OUTPUT_PARAMS if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { { - org.apache.thrift.protocol.TMap _map382 = iprot.readMapBegin(); - struct.outputParams = new HashMap(2*_map382.size); - int _key383; - OutputParameter _val384; - for (int _i385 = 0; _i385 < _map382.size; ++_i385) + org.apache.thrift.protocol.TMap _map592 = iprot.readMapBegin(); + struct.outputParams = new HashMap(2*_map592.size); + int _key593; + OutputParameter _val594; + for (int _i595 = 0; _i595 < _map592.size; ++_i595) { - _key383 = iprot.readI32(); - _val384 = new OutputParameter(); - _val384.read(iprot); - struct.outputParams.put(_key383, _val384); + _key593 = iprot.readI32(); + _val594 = new OutputParameter(); + _val594.read(iprot); + struct.outputParams.put(_key593, _val594); } iprot.readMapEnd(); } @@ -6522,10 +6522,10 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, execute_args struc oprot.writeFieldBegin(OUTPUT_PARAMS_FIELD_DESC); { oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.STRUCT, struct.outputParams.size())); - for (Map.Entry _iter386 : struct.outputParams.entrySet()) + for (Map.Entry _iter596 : struct.outputParams.entrySet()) { - oprot.writeI32(_iter386.getKey()); - _iter386.getValue().write(oprot); + oprot.writeI32(_iter596.getKey()); + _iter596.getValue().write(oprot); } oprot.writeMapEnd(); } @@ -6584,10 +6584,10 @@ public void write(org.apache.thrift.protocol.TProtocol prot, execute_args struct if (struct.isSetOutputParams()) { { oprot.writeI32(struct.outputParams.size()); - for (Map.Entry _iter387 : struct.outputParams.entrySet()) + for (Map.Entry _iter597 : struct.outputParams.entrySet()) { - oprot.writeI32(_iter387.getKey()); - _iter387.getValue().write(oprot); + oprot.writeI32(_iter597.getKey()); + _iter597.getValue().write(oprot); } } } @@ -6613,16 +6613,16 @@ public void read(org.apache.thrift.protocol.TProtocol prot, execute_args struct) } if (incoming.get(2)) { { - org.apache.thrift.protocol.TMap _map388 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.outputParams = new HashMap(2*_map388.size); - int _key389; - OutputParameter _val390; - for (int _i391 = 0; _i391 < _map388.size; ++_i391) + org.apache.thrift.protocol.TMap _map598 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.outputParams = new HashMap(2*_map598.size); + int _key599; + OutputParameter _val600; + for (int _i601 = 0; _i601 < _map598.size; ++_i601) { - _key389 = iprot.readI32(); - _val390 = new OutputParameter(); - _val390.read(iprot); - struct.outputParams.put(_key389, _val390); + _key599 = iprot.readI32(); + _val600 = new OutputParameter(); + _val600.read(iprot); + struct.outputParams.put(_key599, _val600); } } struct.setOutputParamsIsSet(true); @@ -7694,13 +7694,13 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, executeUpdate_args case 2: // SQLS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list392 = iprot.readListBegin(); - struct.sqls = new ArrayList(_list392.size); - String _elem393; - for (int _i394 = 0; _i394 < _list392.size; ++_i394) + org.apache.thrift.protocol.TList _list602 = iprot.readListBegin(); + struct.sqls = new ArrayList(_list602.size); + String _elem603; + for (int _i604 = 0; _i604 < _list602.size; ++_i604) { - _elem393 = iprot.readString(); - struct.sqls.add(_elem393); + _elem603 = iprot.readString(); + struct.sqls.add(_elem603); } iprot.readListEnd(); } @@ -7748,9 +7748,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, executeUpdate_args oprot.writeFieldBegin(SQLS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.sqls.size())); - for (String _iter395 : struct.sqls) + for (String _iter605 : struct.sqls) { - oprot.writeString(_iter395); + oprot.writeString(_iter605); } oprot.writeListEnd(); } @@ -7803,9 +7803,9 @@ public void write(org.apache.thrift.protocol.TProtocol prot, executeUpdate_args if (struct.isSetSqls()) { { oprot.writeI32(struct.sqls.size()); - for (String _iter396 : struct.sqls) + for (String _iter606 : struct.sqls) { - oprot.writeString(_iter396); + oprot.writeString(_iter606); } } } @@ -7827,13 +7827,13 @@ public void read(org.apache.thrift.protocol.TProtocol prot, executeUpdate_args s } if (incoming.get(1)) { { - org.apache.thrift.protocol.TList _list397 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); - struct.sqls = new ArrayList(_list397.size); - String _elem398; - for (int _i399 = 0; _i399 < _list397.size; ++_i399) + org.apache.thrift.protocol.TList _list607 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.sqls = new ArrayList(_list607.size); + String _elem608; + for (int _i609 = 0; _i609 < _list607.size; ++_i609) { - _elem398 = iprot.readString(); - struct.sqls.add(_elem398); + _elem608 = iprot.readString(); + struct.sqls.add(_elem608); } } struct.setSqlsIsSet(true); @@ -10165,16 +10165,16 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, prepareStatement_ar case 3: // OUTPUT_PARAMS if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { { - org.apache.thrift.protocol.TMap _map400 = iprot.readMapBegin(); - struct.outputParams = new HashMap(2*_map400.size); - int _key401; - OutputParameter _val402; - for (int _i403 = 0; _i403 < _map400.size; ++_i403) + org.apache.thrift.protocol.TMap _map610 = iprot.readMapBegin(); + struct.outputParams = new HashMap(2*_map610.size); + int _key611; + OutputParameter _val612; + for (int _i613 = 0; _i613 < _map610.size; ++_i613) { - _key401 = iprot.readI32(); - _val402 = new OutputParameter(); - _val402.read(iprot); - struct.outputParams.put(_key401, _val402); + _key611 = iprot.readI32(); + _val612 = new OutputParameter(); + _val612.read(iprot); + struct.outputParams.put(_key611, _val612); } iprot.readMapEnd(); } @@ -10227,10 +10227,10 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, prepareStatement_a oprot.writeFieldBegin(OUTPUT_PARAMS_FIELD_DESC); { oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.STRUCT, struct.outputParams.size())); - for (Map.Entry _iter404 : struct.outputParams.entrySet()) + for (Map.Entry _iter614 : struct.outputParams.entrySet()) { - oprot.writeI32(_iter404.getKey()); - _iter404.getValue().write(oprot); + oprot.writeI32(_iter614.getKey()); + _iter614.getValue().write(oprot); } oprot.writeMapEnd(); } @@ -10289,10 +10289,10 @@ public void write(org.apache.thrift.protocol.TProtocol prot, prepareStatement_ar if (struct.isSetOutputParams()) { { oprot.writeI32(struct.outputParams.size()); - for (Map.Entry _iter405 : struct.outputParams.entrySet()) + for (Map.Entry _iter615 : struct.outputParams.entrySet()) { - oprot.writeI32(_iter405.getKey()); - _iter405.getValue().write(oprot); + oprot.writeI32(_iter615.getKey()); + _iter615.getValue().write(oprot); } } } @@ -10318,16 +10318,16 @@ public void read(org.apache.thrift.protocol.TProtocol prot, prepareStatement_arg } if (incoming.get(2)) { { - org.apache.thrift.protocol.TMap _map406 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.outputParams = new HashMap(2*_map406.size); - int _key407; - OutputParameter _val408; - for (int _i409 = 0; _i409 < _map406.size; ++_i409) + org.apache.thrift.protocol.TMap _map616 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.outputParams = new HashMap(2*_map616.size); + int _key617; + OutputParameter _val618; + for (int _i619 = 0; _i619 < _map616.size; ++_i619) { - _key407 = iprot.readI32(); - _val408 = new OutputParameter(); - _val408.read(iprot); - struct.outputParams.put(_key407, _val408); + _key617 = iprot.readI32(); + _val618 = new OutputParameter(); + _val618.read(iprot); + struct.outputParams.put(_key617, _val618); } } struct.setOutputParamsIsSet(true); @@ -11501,16 +11501,16 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, executePrepared_arg case 3: // OUTPUT_PARAMS if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { { - org.apache.thrift.protocol.TMap _map410 = iprot.readMapBegin(); - struct.outputParams = new HashMap(2*_map410.size); - int _key411; - OutputParameter _val412; - for (int _i413 = 0; _i413 < _map410.size; ++_i413) + org.apache.thrift.protocol.TMap _map620 = iprot.readMapBegin(); + struct.outputParams = new HashMap(2*_map620.size); + int _key621; + OutputParameter _val622; + for (int _i623 = 0; _i623 < _map620.size; ++_i623) { - _key411 = iprot.readI32(); - _val412 = new OutputParameter(); - _val412.read(iprot); - struct.outputParams.put(_key411, _val412); + _key621 = iprot.readI32(); + _val622 = new OutputParameter(); + _val622.read(iprot); + struct.outputParams.put(_key621, _val622); } iprot.readMapEnd(); } @@ -11563,10 +11563,10 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, executePrepared_ar oprot.writeFieldBegin(OUTPUT_PARAMS_FIELD_DESC); { oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.STRUCT, struct.outputParams.size())); - for (Map.Entry _iter414 : struct.outputParams.entrySet()) + for (Map.Entry _iter624 : struct.outputParams.entrySet()) { - oprot.writeI32(_iter414.getKey()); - _iter414.getValue().write(oprot); + oprot.writeI32(_iter624.getKey()); + _iter624.getValue().write(oprot); } oprot.writeMapEnd(); } @@ -11625,10 +11625,10 @@ public void write(org.apache.thrift.protocol.TProtocol prot, executePrepared_arg if (struct.isSetOutputParams()) { { oprot.writeI32(struct.outputParams.size()); - for (Map.Entry _iter415 : struct.outputParams.entrySet()) + for (Map.Entry _iter625 : struct.outputParams.entrySet()) { - oprot.writeI32(_iter415.getKey()); - _iter415.getValue().write(oprot); + oprot.writeI32(_iter625.getKey()); + _iter625.getValue().write(oprot); } } } @@ -11655,16 +11655,16 @@ public void read(org.apache.thrift.protocol.TProtocol prot, executePrepared_args } if (incoming.get(2)) { { - org.apache.thrift.protocol.TMap _map416 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.outputParams = new HashMap(2*_map416.size); - int _key417; - OutputParameter _val418; - for (int _i419 = 0; _i419 < _map416.size; ++_i419) + org.apache.thrift.protocol.TMap _map626 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.outputParams = new HashMap(2*_map626.size); + int _key627; + OutputParameter _val628; + for (int _i629 = 0; _i629 < _map626.size; ++_i629) { - _key417 = iprot.readI32(); - _val418 = new OutputParameter(); - _val418.read(iprot); - struct.outputParams.put(_key417, _val418); + _key627 = iprot.readI32(); + _val628 = new OutputParameter(); + _val628.read(iprot); + struct.outputParams.put(_key627, _val628); } } struct.setOutputParamsIsSet(true); @@ -15073,14 +15073,14 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, executePreparedBatc case 2: // PARAMS_BATCH if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list420 = iprot.readListBegin(); - struct.paramsBatch = new ArrayList(_list420.size); - Row _elem421; - for (int _i422 = 0; _i422 < _list420.size; ++_i422) + org.apache.thrift.protocol.TList _list630 = iprot.readListBegin(); + struct.paramsBatch = new ArrayList(_list630.size); + Row _elem631; + for (int _i632 = 0; _i632 < _list630.size; ++_i632) { - _elem421 = new Row(); - _elem421.read(iprot); - struct.paramsBatch.add(_elem421); + _elem631 = new Row(); + _elem631.read(iprot); + struct.paramsBatch.add(_elem631); } iprot.readListEnd(); } @@ -15128,9 +15128,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, executePreparedBat oprot.writeFieldBegin(PARAMS_BATCH_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.paramsBatch.size())); - for (Row _iter423 : struct.paramsBatch) + for (Row _iter633 : struct.paramsBatch) { - _iter423.write(oprot); + _iter633.write(oprot); } oprot.writeListEnd(); } @@ -15183,9 +15183,9 @@ public void write(org.apache.thrift.protocol.TProtocol prot, executePreparedBatc if (struct.isSetParamsBatch()) { { oprot.writeI32(struct.paramsBatch.size()); - for (Row _iter424 : struct.paramsBatch) + for (Row _iter634 : struct.paramsBatch) { - _iter424.write(oprot); + _iter634.write(oprot); } } } @@ -15207,14 +15207,14 @@ public void read(org.apache.thrift.protocol.TProtocol prot, executePreparedBatch } if (incoming.get(1)) { { - org.apache.thrift.protocol.TList _list425 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.paramsBatch = new ArrayList(_list425.size); - Row _elem426; - for (int _i427 = 0; _i427 < _list425.size; ++_i427) + org.apache.thrift.protocol.TList _list635 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.paramsBatch = new ArrayList(_list635.size); + Row _elem636; + for (int _i637 = 0; _i637 < _list635.size; ++_i637) { - _elem426 = new Row(); - _elem426.read(iprot); - struct.paramsBatch.add(_elem426); + _elem636 = new Row(); + _elem636.read(iprot); + struct.paramsBatch.add(_elem636); } } struct.setParamsBatchIsSet(true); @@ -16486,14 +16486,14 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, prepareAndExecute_a case 3: // PARAMS_BATCH if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list428 = iprot.readListBegin(); - struct.paramsBatch = new ArrayList(_list428.size); - Row _elem429; - for (int _i430 = 0; _i430 < _list428.size; ++_i430) + org.apache.thrift.protocol.TList _list638 = iprot.readListBegin(); + struct.paramsBatch = new ArrayList(_list638.size); + Row _elem639; + for (int _i640 = 0; _i640 < _list638.size; ++_i640) { - _elem429 = new Row(); - _elem429.read(iprot); - struct.paramsBatch.add(_elem429); + _elem639 = new Row(); + _elem639.read(iprot); + struct.paramsBatch.add(_elem639); } iprot.readListEnd(); } @@ -16505,16 +16505,16 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, prepareAndExecute_a case 4: // OUTPUT_PARAMS if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { { - org.apache.thrift.protocol.TMap _map431 = iprot.readMapBegin(); - struct.outputParams = new HashMap(2*_map431.size); - int _key432; - OutputParameter _val433; - for (int _i434 = 0; _i434 < _map431.size; ++_i434) + org.apache.thrift.protocol.TMap _map641 = iprot.readMapBegin(); + struct.outputParams = new HashMap(2*_map641.size); + int _key642; + OutputParameter _val643; + for (int _i644 = 0; _i644 < _map641.size; ++_i644) { - _key432 = iprot.readI32(); - _val433 = new OutputParameter(); - _val433.read(iprot); - struct.outputParams.put(_key432, _val433); + _key642 = iprot.readI32(); + _val643 = new OutputParameter(); + _val643.read(iprot); + struct.outputParams.put(_key642, _val643); } iprot.readMapEnd(); } @@ -16567,9 +16567,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, prepareAndExecute_ oprot.writeFieldBegin(PARAMS_BATCH_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.paramsBatch.size())); - for (Row _iter435 : struct.paramsBatch) + for (Row _iter645 : struct.paramsBatch) { - _iter435.write(oprot); + _iter645.write(oprot); } oprot.writeListEnd(); } @@ -16579,10 +16579,10 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, prepareAndExecute_ oprot.writeFieldBegin(OUTPUT_PARAMS_FIELD_DESC); { oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.STRUCT, struct.outputParams.size())); - for (Map.Entry _iter436 : struct.outputParams.entrySet()) + for (Map.Entry _iter646 : struct.outputParams.entrySet()) { - oprot.writeI32(_iter436.getKey()); - _iter436.getValue().write(oprot); + oprot.writeI32(_iter646.getKey()); + _iter646.getValue().write(oprot); } oprot.writeMapEnd(); } @@ -16644,19 +16644,19 @@ public void write(org.apache.thrift.protocol.TProtocol prot, prepareAndExecute_a if (struct.isSetParamsBatch()) { { oprot.writeI32(struct.paramsBatch.size()); - for (Row _iter437 : struct.paramsBatch) + for (Row _iter647 : struct.paramsBatch) { - _iter437.write(oprot); + _iter647.write(oprot); } } } if (struct.isSetOutputParams()) { { oprot.writeI32(struct.outputParams.size()); - for (Map.Entry _iter438 : struct.outputParams.entrySet()) + for (Map.Entry _iter648 : struct.outputParams.entrySet()) { - oprot.writeI32(_iter438.getKey()); - _iter438.getValue().write(oprot); + oprot.writeI32(_iter648.getKey()); + _iter648.getValue().write(oprot); } } } @@ -16682,30 +16682,30 @@ public void read(org.apache.thrift.protocol.TProtocol prot, prepareAndExecute_ar } if (incoming.get(2)) { { - org.apache.thrift.protocol.TList _list439 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.paramsBatch = new ArrayList(_list439.size); - Row _elem440; - for (int _i441 = 0; _i441 < _list439.size; ++_i441) + org.apache.thrift.protocol.TList _list649 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.paramsBatch = new ArrayList(_list649.size); + Row _elem650; + for (int _i651 = 0; _i651 < _list649.size; ++_i651) { - _elem440 = new Row(); - _elem440.read(iprot); - struct.paramsBatch.add(_elem440); + _elem650 = new Row(); + _elem650.read(iprot); + struct.paramsBatch.add(_elem650); } } struct.setParamsBatchIsSet(true); } if (incoming.get(3)) { { - org.apache.thrift.protocol.TMap _map442 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.outputParams = new HashMap(2*_map442.size); - int _key443; - OutputParameter _val444; - for (int _i445 = 0; _i445 < _map442.size; ++_i445) + org.apache.thrift.protocol.TMap _map652 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.outputParams = new HashMap(2*_map652.size); + int _key653; + OutputParameter _val654; + for (int _i655 = 0; _i655 < _map652.size; ++_i655) { - _key443 = iprot.readI32(); - _val444 = new OutputParameter(); - _val444.read(iprot); - struct.outputParams.put(_key443, _val444); + _key653 = iprot.readI32(); + _val654 = new OutputParameter(); + _val654.read(iprot); + struct.outputParams.put(_key653, _val654); } } struct.setOutputParamsIsSet(true); @@ -17786,15 +17786,15 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, beginTransaction_ar case 3: // FLAGS if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { { - org.apache.thrift.protocol.TMap _map446 = iprot.readMapBegin(); - struct.flags = new HashMap(2*_map446.size); - TransactionAttribute _key447; - boolean _val448; - for (int _i449 = 0; _i449 < _map446.size; ++_i449) + org.apache.thrift.protocol.TMap _map656 = iprot.readMapBegin(); + struct.flags = new HashMap(2*_map656.size); + TransactionAttribute _key657; + boolean _val658; + for (int _i659 = 0; _i659 < _map656.size; ++_i659) { - _key447 = io.snappydata.thrift.TransactionAttribute.findByValue(iprot.readI32()); - _val448 = iprot.readBool(); - struct.flags.put(_key447, _val448); + _key657 = io.snappydata.thrift.TransactionAttribute.findByValue(iprot.readI32()); + _val658 = iprot.readBool(); + struct.flags.put(_key657, _val658); } iprot.readMapEnd(); } @@ -17836,10 +17836,10 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, beginTransaction_a oprot.writeFieldBegin(FLAGS_FIELD_DESC); { oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.BOOL, struct.flags.size())); - for (Map.Entry _iter450 : struct.flags.entrySet()) + for (Map.Entry _iter660 : struct.flags.entrySet()) { - oprot.writeI32(_iter450.getKey().getValue()); - oprot.writeBool(_iter450.getValue()); + oprot.writeI32(_iter660.getKey().getValue()); + oprot.writeBool(_iter660.getValue()); } oprot.writeMapEnd(); } @@ -17890,10 +17890,10 @@ public void write(org.apache.thrift.protocol.TProtocol prot, beginTransaction_ar if (struct.isSetFlags()) { { oprot.writeI32(struct.flags.size()); - for (Map.Entry _iter451 : struct.flags.entrySet()) + for (Map.Entry _iter661 : struct.flags.entrySet()) { - oprot.writeI32(_iter451.getKey().getValue()); - oprot.writeBool(_iter451.getValue()); + oprot.writeI32(_iter661.getKey().getValue()); + oprot.writeBool(_iter661.getValue()); } } } @@ -17916,15 +17916,15 @@ public void read(org.apache.thrift.protocol.TProtocol prot, beginTransaction_arg } if (incoming.get(2)) { { - org.apache.thrift.protocol.TMap _map452 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.BOOL, iprot.readI32()); - struct.flags = new HashMap(2*_map452.size); - TransactionAttribute _key453; - boolean _val454; - for (int _i455 = 0; _i455 < _map452.size; ++_i455) + org.apache.thrift.protocol.TMap _map662 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.BOOL, iprot.readI32()); + struct.flags = new HashMap(2*_map662.size); + TransactionAttribute _key663; + boolean _val664; + for (int _i665 = 0; _i665 < _map662.size; ++_i665) { - _key453 = io.snappydata.thrift.TransactionAttribute.findByValue(iprot.readI32()); - _val454 = iprot.readBool(); - struct.flags.put(_key453, _val454); + _key663 = io.snappydata.thrift.TransactionAttribute.findByValue(iprot.readI32()); + _val664 = iprot.readBool(); + struct.flags.put(_key663, _val664); } } struct.setFlagsIsSet(true); @@ -18909,15 +18909,15 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, setTransactionAttri case 2: // FLAGS if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { { - org.apache.thrift.protocol.TMap _map456 = iprot.readMapBegin(); - struct.flags = new HashMap(2*_map456.size); - TransactionAttribute _key457; - boolean _val458; - for (int _i459 = 0; _i459 < _map456.size; ++_i459) + org.apache.thrift.protocol.TMap _map666 = iprot.readMapBegin(); + struct.flags = new HashMap(2*_map666.size); + TransactionAttribute _key667; + boolean _val668; + for (int _i669 = 0; _i669 < _map666.size; ++_i669) { - _key457 = io.snappydata.thrift.TransactionAttribute.findByValue(iprot.readI32()); - _val458 = iprot.readBool(); - struct.flags.put(_key457, _val458); + _key667 = io.snappydata.thrift.TransactionAttribute.findByValue(iprot.readI32()); + _val668 = iprot.readBool(); + struct.flags.put(_key667, _val668); } iprot.readMapEnd(); } @@ -18956,10 +18956,10 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, setTransactionAttr oprot.writeFieldBegin(FLAGS_FIELD_DESC); { oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.BOOL, struct.flags.size())); - for (Map.Entry _iter460 : struct.flags.entrySet()) + for (Map.Entry _iter670 : struct.flags.entrySet()) { - oprot.writeI32(_iter460.getKey().getValue()); - oprot.writeBool(_iter460.getValue()); + oprot.writeI32(_iter670.getKey().getValue()); + oprot.writeBool(_iter670.getValue()); } oprot.writeMapEnd(); } @@ -19004,10 +19004,10 @@ public void write(org.apache.thrift.protocol.TProtocol prot, setTransactionAttri if (struct.isSetFlags()) { { oprot.writeI32(struct.flags.size()); - for (Map.Entry _iter461 : struct.flags.entrySet()) + for (Map.Entry _iter671 : struct.flags.entrySet()) { - oprot.writeI32(_iter461.getKey().getValue()); - oprot.writeBool(_iter461.getValue()); + oprot.writeI32(_iter671.getKey().getValue()); + oprot.writeBool(_iter671.getValue()); } } } @@ -19026,15 +19026,15 @@ public void read(org.apache.thrift.protocol.TProtocol prot, setTransactionAttrib } if (incoming.get(1)) { { - org.apache.thrift.protocol.TMap _map462 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.BOOL, iprot.readI32()); - struct.flags = new HashMap(2*_map462.size); - TransactionAttribute _key463; - boolean _val464; - for (int _i465 = 0; _i465 < _map462.size; ++_i465) + org.apache.thrift.protocol.TMap _map672 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.BOOL, iprot.readI32()); + struct.flags = new HashMap(2*_map672.size); + TransactionAttribute _key673; + boolean _val674; + for (int _i675 = 0; _i675 < _map672.size; ++_i675) { - _key463 = io.snappydata.thrift.TransactionAttribute.findByValue(iprot.readI32()); - _val464 = iprot.readBool(); - struct.flags.put(_key463, _val464); + _key673 = io.snappydata.thrift.TransactionAttribute.findByValue(iprot.readI32()); + _val674 = iprot.readBool(); + struct.flags.put(_key673, _val674); } } struct.setFlagsIsSet(true); @@ -20288,15 +20288,15 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, getTransactionAttri case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { { - org.apache.thrift.protocol.TMap _map466 = iprot.readMapBegin(); - struct.success = new HashMap(2*_map466.size); - TransactionAttribute _key467; - boolean _val468; - for (int _i469 = 0; _i469 < _map466.size; ++_i469) + org.apache.thrift.protocol.TMap _map676 = iprot.readMapBegin(); + struct.success = new HashMap(2*_map676.size); + TransactionAttribute _key677; + boolean _val678; + for (int _i679 = 0; _i679 < _map676.size; ++_i679) { - _key467 = io.snappydata.thrift.TransactionAttribute.findByValue(iprot.readI32()); - _val468 = iprot.readBool(); - struct.success.put(_key467, _val468); + _key677 = io.snappydata.thrift.TransactionAttribute.findByValue(iprot.readI32()); + _val678 = iprot.readBool(); + struct.success.put(_key677, _val678); } iprot.readMapEnd(); } @@ -20333,10 +20333,10 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, getTransactionAttr oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.BOOL, struct.success.size())); - for (Map.Entry _iter470 : struct.success.entrySet()) + for (Map.Entry _iter680 : struct.success.entrySet()) { - oprot.writeI32(_iter470.getKey().getValue()); - oprot.writeBool(_iter470.getValue()); + oprot.writeI32(_iter680.getKey().getValue()); + oprot.writeBool(_iter680.getValue()); } oprot.writeMapEnd(); } @@ -20375,10 +20375,10 @@ public void write(org.apache.thrift.protocol.TProtocol prot, getTransactionAttri if (struct.isSetSuccess()) { { oprot.writeI32(struct.success.size()); - for (Map.Entry _iter471 : struct.success.entrySet()) + for (Map.Entry _iter681 : struct.success.entrySet()) { - oprot.writeI32(_iter471.getKey().getValue()); - oprot.writeBool(_iter471.getValue()); + oprot.writeI32(_iter681.getKey().getValue()); + oprot.writeBool(_iter681.getValue()); } } } @@ -20393,15 +20393,15 @@ public void read(org.apache.thrift.protocol.TProtocol prot, getTransactionAttrib BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { { - org.apache.thrift.protocol.TMap _map472 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.BOOL, iprot.readI32()); - struct.success = new HashMap(2*_map472.size); - TransactionAttribute _key473; - boolean _val474; - for (int _i475 = 0; _i475 < _map472.size; ++_i475) + org.apache.thrift.protocol.TMap _map682 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.BOOL, iprot.readI32()); + struct.success = new HashMap(2*_map682.size); + TransactionAttribute _key683; + boolean _val684; + for (int _i685 = 0; _i685 < _map682.size; ++_i685) { - _key473 = io.snappydata.thrift.TransactionAttribute.findByValue(iprot.readI32()); - _val474 = iprot.readBool(); - struct.success.put(_key473, _val474); + _key683 = io.snappydata.thrift.TransactionAttribute.findByValue(iprot.readI32()); + _val684 = iprot.readBool(); + struct.success.put(_key683, _val684); } } struct.setSuccessIsSet(true); @@ -21005,15 +21005,15 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, commitTransaction_a case 3: // FLAGS if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { { - org.apache.thrift.protocol.TMap _map476 = iprot.readMapBegin(); - struct.flags = new HashMap(2*_map476.size); - TransactionAttribute _key477; - boolean _val478; - for (int _i479 = 0; _i479 < _map476.size; ++_i479) + org.apache.thrift.protocol.TMap _map686 = iprot.readMapBegin(); + struct.flags = new HashMap(2*_map686.size); + TransactionAttribute _key687; + boolean _val688; + for (int _i689 = 0; _i689 < _map686.size; ++_i689) { - _key477 = io.snappydata.thrift.TransactionAttribute.findByValue(iprot.readI32()); - _val478 = iprot.readBool(); - struct.flags.put(_key477, _val478); + _key687 = io.snappydata.thrift.TransactionAttribute.findByValue(iprot.readI32()); + _val688 = iprot.readBool(); + struct.flags.put(_key687, _val688); } iprot.readMapEnd(); } @@ -21055,10 +21055,10 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, commitTransaction_ oprot.writeFieldBegin(FLAGS_FIELD_DESC); { oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.BOOL, struct.flags.size())); - for (Map.Entry _iter480 : struct.flags.entrySet()) + for (Map.Entry _iter690 : struct.flags.entrySet()) { - oprot.writeI32(_iter480.getKey().getValue()); - oprot.writeBool(_iter480.getValue()); + oprot.writeI32(_iter690.getKey().getValue()); + oprot.writeBool(_iter690.getValue()); } oprot.writeMapEnd(); } @@ -21109,10 +21109,10 @@ public void write(org.apache.thrift.protocol.TProtocol prot, commitTransaction_a if (struct.isSetFlags()) { { oprot.writeI32(struct.flags.size()); - for (Map.Entry _iter481 : struct.flags.entrySet()) + for (Map.Entry _iter691 : struct.flags.entrySet()) { - oprot.writeI32(_iter481.getKey().getValue()); - oprot.writeBool(_iter481.getValue()); + oprot.writeI32(_iter691.getKey().getValue()); + oprot.writeBool(_iter691.getValue()); } } } @@ -21135,15 +21135,15 @@ public void read(org.apache.thrift.protocol.TProtocol prot, commitTransaction_ar } if (incoming.get(2)) { { - org.apache.thrift.protocol.TMap _map482 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.BOOL, iprot.readI32()); - struct.flags = new HashMap(2*_map482.size); - TransactionAttribute _key483; - boolean _val484; - for (int _i485 = 0; _i485 < _map482.size; ++_i485) + org.apache.thrift.protocol.TMap _map692 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.BOOL, iprot.readI32()); + struct.flags = new HashMap(2*_map692.size); + TransactionAttribute _key693; + boolean _val694; + for (int _i695 = 0; _i695 < _map692.size; ++_i695) { - _key483 = io.snappydata.thrift.TransactionAttribute.findByValue(iprot.readI32()); - _val484 = iprot.readBool(); - struct.flags.put(_key483, _val484); + _key693 = io.snappydata.thrift.TransactionAttribute.findByValue(iprot.readI32()); + _val694 = iprot.readBool(); + struct.flags.put(_key693, _val694); } } struct.setFlagsIsSet(true); @@ -22109,15 +22109,15 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, rollbackTransaction case 3: // FLAGS if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { { - org.apache.thrift.protocol.TMap _map486 = iprot.readMapBegin(); - struct.flags = new HashMap(2*_map486.size); - TransactionAttribute _key487; - boolean _val488; - for (int _i489 = 0; _i489 < _map486.size; ++_i489) + org.apache.thrift.protocol.TMap _map696 = iprot.readMapBegin(); + struct.flags = new HashMap(2*_map696.size); + TransactionAttribute _key697; + boolean _val698; + for (int _i699 = 0; _i699 < _map696.size; ++_i699) { - _key487 = io.snappydata.thrift.TransactionAttribute.findByValue(iprot.readI32()); - _val488 = iprot.readBool(); - struct.flags.put(_key487, _val488); + _key697 = io.snappydata.thrift.TransactionAttribute.findByValue(iprot.readI32()); + _val698 = iprot.readBool(); + struct.flags.put(_key697, _val698); } iprot.readMapEnd(); } @@ -22159,10 +22159,10 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, rollbackTransactio oprot.writeFieldBegin(FLAGS_FIELD_DESC); { oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.BOOL, struct.flags.size())); - for (Map.Entry _iter490 : struct.flags.entrySet()) + for (Map.Entry _iter700 : struct.flags.entrySet()) { - oprot.writeI32(_iter490.getKey().getValue()); - oprot.writeBool(_iter490.getValue()); + oprot.writeI32(_iter700.getKey().getValue()); + oprot.writeBool(_iter700.getValue()); } oprot.writeMapEnd(); } @@ -22213,10 +22213,10 @@ public void write(org.apache.thrift.protocol.TProtocol prot, rollbackTransaction if (struct.isSetFlags()) { { oprot.writeI32(struct.flags.size()); - for (Map.Entry _iter491 : struct.flags.entrySet()) + for (Map.Entry _iter701 : struct.flags.entrySet()) { - oprot.writeI32(_iter491.getKey().getValue()); - oprot.writeBool(_iter491.getValue()); + oprot.writeI32(_iter701.getKey().getValue()); + oprot.writeBool(_iter701.getValue()); } } } @@ -22239,15 +22239,15 @@ public void read(org.apache.thrift.protocol.TProtocol prot, rollbackTransaction_ } if (incoming.get(2)) { { - org.apache.thrift.protocol.TMap _map492 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.BOOL, iprot.readI32()); - struct.flags = new HashMap(2*_map492.size); - TransactionAttribute _key493; - boolean _val494; - for (int _i495 = 0; _i495 < _map492.size; ++_i495) + org.apache.thrift.protocol.TMap _map702 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I32, org.apache.thrift.protocol.TType.BOOL, iprot.readI32()); + struct.flags = new HashMap(2*_map702.size); + TransactionAttribute _key703; + boolean _val704; + for (int _i705 = 0; _i705 < _map702.size; ++_i705) { - _key493 = io.snappydata.thrift.TransactionAttribute.findByValue(iprot.readI32()); - _val494 = iprot.readBool(); - struct.flags.put(_key493, _val494); + _key703 = io.snappydata.thrift.TransactionAttribute.findByValue(iprot.readI32()); + _val704 = iprot.readBool(); + struct.flags.put(_key703, _val704); } } struct.setFlagsIsSet(true); @@ -31542,13 +31542,13 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, executeCursorUpdate case 2: // OPERATIONS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list496 = iprot.readListBegin(); - struct.operations = new ArrayList(_list496.size); - CursorUpdateOperation _elem497; - for (int _i498 = 0; _i498 < _list496.size; ++_i498) + org.apache.thrift.protocol.TList _list706 = iprot.readListBegin(); + struct.operations = new ArrayList(_list706.size); + CursorUpdateOperation _elem707; + for (int _i708 = 0; _i708 < _list706.size; ++_i708) { - _elem497 = io.snappydata.thrift.CursorUpdateOperation.findByValue(iprot.readI32()); - struct.operations.add(_elem497); + _elem707 = io.snappydata.thrift.CursorUpdateOperation.findByValue(iprot.readI32()); + struct.operations.add(_elem707); } iprot.readListEnd(); } @@ -31560,14 +31560,14 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, executeCursorUpdate case 3: // CHANGED_ROWS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list499 = iprot.readListBegin(); - struct.changedRows = new ArrayList(_list499.size); - Row _elem500; - for (int _i501 = 0; _i501 < _list499.size; ++_i501) + org.apache.thrift.protocol.TList _list709 = iprot.readListBegin(); + struct.changedRows = new ArrayList(_list709.size); + Row _elem710; + for (int _i711 = 0; _i711 < _list709.size; ++_i711) { - _elem500 = new Row(); - _elem500.read(iprot); - struct.changedRows.add(_elem500); + _elem710 = new Row(); + _elem710.read(iprot); + struct.changedRows.add(_elem710); } iprot.readListEnd(); } @@ -31579,23 +31579,23 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, executeCursorUpdate case 4: // CHANGED_COLUMNS_LIST if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list502 = iprot.readListBegin(); - struct.changedColumnsList = new ArrayList>(_list502.size); - List _elem503; - for (int _i504 = 0; _i504 < _list502.size; ++_i504) + org.apache.thrift.protocol.TList _list712 = iprot.readListBegin(); + struct.changedColumnsList = new ArrayList>(_list712.size); + List _elem713; + for (int _i714 = 0; _i714 < _list712.size; ++_i714) { { - org.apache.thrift.protocol.TList _list505 = iprot.readListBegin(); - _elem503 = new ArrayList(_list505.size); - int _elem506; - for (int _i507 = 0; _i507 < _list505.size; ++_i507) + org.apache.thrift.protocol.TList _list715 = iprot.readListBegin(); + _elem713 = new ArrayList(_list715.size); + int _elem716; + for (int _i717 = 0; _i717 < _list715.size; ++_i717) { - _elem506 = iprot.readI32(); - _elem503.add(_elem506); + _elem716 = iprot.readI32(); + _elem713.add(_elem716); } iprot.readListEnd(); } - struct.changedColumnsList.add(_elem503); + struct.changedColumnsList.add(_elem713); } iprot.readListEnd(); } @@ -31607,13 +31607,13 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, executeCursorUpdate case 5: // CHANGED_ROW_INDEXES if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list508 = iprot.readListBegin(); - struct.changedRowIndexes = new ArrayList(_list508.size); - int _elem509; - for (int _i510 = 0; _i510 < _list508.size; ++_i510) + org.apache.thrift.protocol.TList _list718 = iprot.readListBegin(); + struct.changedRowIndexes = new ArrayList(_list718.size); + int _elem719; + for (int _i720 = 0; _i720 < _list718.size; ++_i720) { - _elem509 = iprot.readI32(); - struct.changedRowIndexes.add(_elem509); + _elem719 = iprot.readI32(); + struct.changedRowIndexes.add(_elem719); } iprot.readListEnd(); } @@ -31652,9 +31652,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, executeCursorUpdat oprot.writeFieldBegin(OPERATIONS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, struct.operations.size())); - for (CursorUpdateOperation _iter511 : struct.operations) + for (CursorUpdateOperation _iter721 : struct.operations) { - oprot.writeI32(_iter511.getValue()); + oprot.writeI32(_iter721.getValue()); } oprot.writeListEnd(); } @@ -31664,9 +31664,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, executeCursorUpdat oprot.writeFieldBegin(CHANGED_ROWS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.changedRows.size())); - for (Row _iter512 : struct.changedRows) + for (Row _iter722 : struct.changedRows) { - _iter512.write(oprot); + _iter722.write(oprot); } oprot.writeListEnd(); } @@ -31676,13 +31676,13 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, executeCursorUpdat oprot.writeFieldBegin(CHANGED_COLUMNS_LIST_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.LIST, struct.changedColumnsList.size())); - for (List _iter513 : struct.changedColumnsList) + for (List _iter723 : struct.changedColumnsList) { { - oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, _iter513.size())); - for (int _iter514 : _iter513) + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, _iter723.size())); + for (int _iter724 : _iter723) { - oprot.writeI32(_iter514); + oprot.writeI32(_iter724); } oprot.writeListEnd(); } @@ -31695,9 +31695,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, executeCursorUpdat oprot.writeFieldBegin(CHANGED_ROW_INDEXES_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, struct.changedRowIndexes.size())); - for (int _iter515 : struct.changedRowIndexes) + for (int _iter725 : struct.changedRowIndexes) { - oprot.writeI32(_iter515); + oprot.writeI32(_iter725); } oprot.writeListEnd(); } @@ -31751,31 +31751,31 @@ public void write(org.apache.thrift.protocol.TProtocol prot, executeCursorUpdate if (struct.isSetOperations()) { { oprot.writeI32(struct.operations.size()); - for (CursorUpdateOperation _iter516 : struct.operations) + for (CursorUpdateOperation _iter726 : struct.operations) { - oprot.writeI32(_iter516.getValue()); + oprot.writeI32(_iter726.getValue()); } } } if (struct.isSetChangedRows()) { { oprot.writeI32(struct.changedRows.size()); - for (Row _iter517 : struct.changedRows) + for (Row _iter727 : struct.changedRows) { - _iter517.write(oprot); + _iter727.write(oprot); } } } if (struct.isSetChangedColumnsList()) { { oprot.writeI32(struct.changedColumnsList.size()); - for (List _iter518 : struct.changedColumnsList) + for (List _iter728 : struct.changedColumnsList) { { - oprot.writeI32(_iter518.size()); - for (int _iter519 : _iter518) + oprot.writeI32(_iter728.size()); + for (int _iter729 : _iter728) { - oprot.writeI32(_iter519); + oprot.writeI32(_iter729); } } } @@ -31784,9 +31784,9 @@ public void write(org.apache.thrift.protocol.TProtocol prot, executeCursorUpdate if (struct.isSetChangedRowIndexes()) { { oprot.writeI32(struct.changedRowIndexes.size()); - for (int _iter520 : struct.changedRowIndexes) + for (int _iter730 : struct.changedRowIndexes) { - oprot.writeI32(_iter520); + oprot.writeI32(_iter730); } } } @@ -31805,62 +31805,62 @@ public void read(org.apache.thrift.protocol.TProtocol prot, executeCursorUpdate_ } if (incoming.get(1)) { { - org.apache.thrift.protocol.TList _list521 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); - struct.operations = new ArrayList(_list521.size); - CursorUpdateOperation _elem522; - for (int _i523 = 0; _i523 < _list521.size; ++_i523) + org.apache.thrift.protocol.TList _list731 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.operations = new ArrayList(_list731.size); + CursorUpdateOperation _elem732; + for (int _i733 = 0; _i733 < _list731.size; ++_i733) { - _elem522 = io.snappydata.thrift.CursorUpdateOperation.findByValue(iprot.readI32()); - struct.operations.add(_elem522); + _elem732 = io.snappydata.thrift.CursorUpdateOperation.findByValue(iprot.readI32()); + struct.operations.add(_elem732); } } struct.setOperationsIsSet(true); } if (incoming.get(2)) { { - org.apache.thrift.protocol.TList _list524 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.changedRows = new ArrayList(_list524.size); - Row _elem525; - for (int _i526 = 0; _i526 < _list524.size; ++_i526) + org.apache.thrift.protocol.TList _list734 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.changedRows = new ArrayList(_list734.size); + Row _elem735; + for (int _i736 = 0; _i736 < _list734.size; ++_i736) { - _elem525 = new Row(); - _elem525.read(iprot); - struct.changedRows.add(_elem525); + _elem735 = new Row(); + _elem735.read(iprot); + struct.changedRows.add(_elem735); } } struct.setChangedRowsIsSet(true); } if (incoming.get(3)) { { - org.apache.thrift.protocol.TList _list527 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.LIST, iprot.readI32()); - struct.changedColumnsList = new ArrayList>(_list527.size); - List _elem528; - for (int _i529 = 0; _i529 < _list527.size; ++_i529) + org.apache.thrift.protocol.TList _list737 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.LIST, iprot.readI32()); + struct.changedColumnsList = new ArrayList>(_list737.size); + List _elem738; + for (int _i739 = 0; _i739 < _list737.size; ++_i739) { { - org.apache.thrift.protocol.TList _list530 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); - _elem528 = new ArrayList(_list530.size); - int _elem531; - for (int _i532 = 0; _i532 < _list530.size; ++_i532) + org.apache.thrift.protocol.TList _list740 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + _elem738 = new ArrayList(_list740.size); + int _elem741; + for (int _i742 = 0; _i742 < _list740.size; ++_i742) { - _elem531 = iprot.readI32(); - _elem528.add(_elem531); + _elem741 = iprot.readI32(); + _elem738.add(_elem741); } } - struct.changedColumnsList.add(_elem528); + struct.changedColumnsList.add(_elem738); } } struct.setChangedColumnsListIsSet(true); } if (incoming.get(4)) { { - org.apache.thrift.protocol.TList _list533 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); - struct.changedRowIndexes = new ArrayList(_list533.size); - int _elem534; - for (int _i535 = 0; _i535 < _list533.size; ++_i535) + org.apache.thrift.protocol.TList _list743 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.changedRowIndexes = new ArrayList(_list743.size); + int _elem744; + for (int _i745 = 0; _i745 < _list743.size; ++_i745) { - _elem534 = iprot.readI32(); - struct.changedRowIndexes.add(_elem534); + _elem744 = iprot.readI32(); + struct.changedRowIndexes.add(_elem744); } } struct.setChangedRowIndexesIsSet(true); @@ -39391,14 +39391,14 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, recoverXATransactio case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list536 = iprot.readListBegin(); - struct.success = new ArrayList(_list536.size); - TransactionXid _elem537; - for (int _i538 = 0; _i538 < _list536.size; ++_i538) + org.apache.thrift.protocol.TList _list746 = iprot.readListBegin(); + struct.success = new ArrayList(_list746.size); + TransactionXid _elem747; + for (int _i748 = 0; _i748 < _list746.size; ++_i748) { - _elem537 = new TransactionXid(); - _elem537.read(iprot); - struct.success.add(_elem537); + _elem747 = new TransactionXid(); + _elem747.read(iprot); + struct.success.add(_elem747); } iprot.readListEnd(); } @@ -39435,9 +39435,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, recoverXATransacti oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.success.size())); - for (TransactionXid _iter539 : struct.success) + for (TransactionXid _iter749 : struct.success) { - _iter539.write(oprot); + _iter749.write(oprot); } oprot.writeListEnd(); } @@ -39476,9 +39476,9 @@ public void write(org.apache.thrift.protocol.TProtocol prot, recoverXATransactio if (struct.isSetSuccess()) { { oprot.writeI32(struct.success.size()); - for (TransactionXid _iter540 : struct.success) + for (TransactionXid _iter750 : struct.success) { - _iter540.write(oprot); + _iter750.write(oprot); } } } @@ -39493,14 +39493,14 @@ public void read(org.apache.thrift.protocol.TProtocol prot, recoverXATransaction BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { { - org.apache.thrift.protocol.TList _list541 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.success = new ArrayList(_list541.size); - TransactionXid _elem542; - for (int _i543 = 0; _i543 < _list541.size; ++_i543) + org.apache.thrift.protocol.TList _list751 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.success = new ArrayList(_list751.size); + TransactionXid _elem752; + for (int _i753 = 0; _i753 < _list751.size; ++_i753) { - _elem542 = new TransactionXid(); - _elem542.read(iprot); - struct.success.add(_elem542); + _elem752 = new TransactionXid(); + _elem752.read(iprot); + struct.success.add(_elem752); } } struct.setSuccessIsSet(true); @@ -42873,13 +42873,13 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, getUDTs_args struct case 2: // TYPES if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list544 = iprot.readListBegin(); - struct.types = new ArrayList(_list544.size); - SnappyType _elem545; - for (int _i546 = 0; _i546 < _list544.size; ++_i546) + org.apache.thrift.protocol.TList _list754 = iprot.readListBegin(); + struct.types = new ArrayList(_list754.size); + SnappyType _elem755; + for (int _i756 = 0; _i756 < _list754.size; ++_i756) { - _elem545 = io.snappydata.thrift.SnappyType.findByValue(iprot.readI32()); - struct.types.add(_elem545); + _elem755 = io.snappydata.thrift.SnappyType.findByValue(iprot.readI32()); + struct.types.add(_elem755); } iprot.readListEnd(); } @@ -42912,9 +42912,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, getUDTs_args struc oprot.writeFieldBegin(TYPES_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, struct.types.size())); - for (SnappyType _iter547 : struct.types) + for (SnappyType _iter757 : struct.types) { - oprot.writeI32(_iter547.getValue()); + oprot.writeI32(_iter757.getValue()); } oprot.writeListEnd(); } @@ -42951,9 +42951,9 @@ public void write(org.apache.thrift.protocol.TProtocol prot, getUDTs_args struct if (struct.isSetTypes()) { { oprot.writeI32(struct.types.size()); - for (SnappyType _iter548 : struct.types) + for (SnappyType _iter758 : struct.types) { - oprot.writeI32(_iter548.getValue()); + oprot.writeI32(_iter758.getValue()); } } } @@ -42970,13 +42970,13 @@ public void read(org.apache.thrift.protocol.TProtocol prot, getUDTs_args struct) } if (incoming.get(1)) { { - org.apache.thrift.protocol.TList _list549 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); - struct.types = new ArrayList(_list549.size); - SnappyType _elem550; - for (int _i551 = 0; _i551 < _list549.size; ++_i551) + org.apache.thrift.protocol.TList _list759 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.types = new ArrayList(_list759.size); + SnappyType _elem760; + for (int _i761 = 0; _i761 < _list759.size; ++_i761) { - _elem550 = io.snappydata.thrift.SnappyType.findByValue(iprot.readI32()); - struct.types.add(_elem550); + _elem760 = io.snappydata.thrift.SnappyType.findByValue(iprot.readI32()); + struct.types.add(_elem760); } } struct.setTypesIsSet(true); @@ -45372,14 +45372,14 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, fetchActiveConnecti case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list552 = iprot.readListBegin(); - struct.success = new ArrayList(_list552.size); - ConnectionProperties _elem553; - for (int _i554 = 0; _i554 < _list552.size; ++_i554) + org.apache.thrift.protocol.TList _list762 = iprot.readListBegin(); + struct.success = new ArrayList(_list762.size); + ConnectionProperties _elem763; + for (int _i764 = 0; _i764 < _list762.size; ++_i764) { - _elem553 = new ConnectionProperties(); - _elem553.read(iprot); - struct.success.add(_elem553); + _elem763 = new ConnectionProperties(); + _elem763.read(iprot); + struct.success.add(_elem763); } iprot.readListEnd(); } @@ -45416,9 +45416,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, fetchActiveConnect oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.success.size())); - for (ConnectionProperties _iter555 : struct.success) + for (ConnectionProperties _iter765 : struct.success) { - _iter555.write(oprot); + _iter765.write(oprot); } oprot.writeListEnd(); } @@ -45457,9 +45457,9 @@ public void write(org.apache.thrift.protocol.TProtocol prot, fetchActiveConnecti if (struct.isSetSuccess()) { { oprot.writeI32(struct.success.size()); - for (ConnectionProperties _iter556 : struct.success) + for (ConnectionProperties _iter766 : struct.success) { - _iter556.write(oprot); + _iter766.write(oprot); } } } @@ -45474,14 +45474,14 @@ public void read(org.apache.thrift.protocol.TProtocol prot, fetchActiveConnectio BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { { - org.apache.thrift.protocol.TList _list557 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.success = new ArrayList(_list557.size); - ConnectionProperties _elem558; - for (int _i559 = 0; _i559 < _list557.size; ++_i559) + org.apache.thrift.protocol.TList _list767 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.success = new ArrayList(_list767.size); + ConnectionProperties _elem768; + for (int _i769 = 0; _i769 < _list767.size; ++_i769) { - _elem558 = new ConnectionProperties(); - _elem558.read(iprot); - struct.success.add(_elem558); + _elem768 = new ConnectionProperties(); + _elem768.read(iprot); + struct.success.add(_elem768); } } struct.setSuccessIsSet(true); @@ -46362,15 +46362,15 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, fetchActiveStatemen case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { { - org.apache.thrift.protocol.TMap _map560 = iprot.readMapBegin(); - struct.success = new HashMap(2*_map560.size); - long _key561; - String _val562; - for (int _i563 = 0; _i563 < _map560.size; ++_i563) + org.apache.thrift.protocol.TMap _map770 = iprot.readMapBegin(); + struct.success = new HashMap(2*_map770.size); + long _key771; + String _val772; + for (int _i773 = 0; _i773 < _map770.size; ++_i773) { - _key561 = iprot.readI64(); - _val562 = iprot.readString(); - struct.success.put(_key561, _val562); + _key771 = iprot.readI64(); + _val772 = iprot.readString(); + struct.success.put(_key771, _val772); } iprot.readMapEnd(); } @@ -46407,10 +46407,10 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, fetchActiveStateme oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I64, org.apache.thrift.protocol.TType.STRING, struct.success.size())); - for (Map.Entry _iter564 : struct.success.entrySet()) + for (Map.Entry _iter774 : struct.success.entrySet()) { - oprot.writeI64(_iter564.getKey()); - oprot.writeString(_iter564.getValue()); + oprot.writeI64(_iter774.getKey()); + oprot.writeString(_iter774.getValue()); } oprot.writeMapEnd(); } @@ -46449,10 +46449,10 @@ public void write(org.apache.thrift.protocol.TProtocol prot, fetchActiveStatemen if (struct.isSetSuccess()) { { oprot.writeI32(struct.success.size()); - for (Map.Entry _iter565 : struct.success.entrySet()) + for (Map.Entry _iter775 : struct.success.entrySet()) { - oprot.writeI64(_iter565.getKey()); - oprot.writeString(_iter565.getValue()); + oprot.writeI64(_iter775.getKey()); + oprot.writeString(_iter775.getValue()); } } } @@ -46467,15 +46467,15 @@ public void read(org.apache.thrift.protocol.TProtocol prot, fetchActiveStatement BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { { - org.apache.thrift.protocol.TMap _map566 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I64, org.apache.thrift.protocol.TType.STRING, iprot.readI32()); - struct.success = new HashMap(2*_map566.size); - long _key567; - String _val568; - for (int _i569 = 0; _i569 < _map566.size; ++_i569) + org.apache.thrift.protocol.TMap _map776 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.I64, org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.success = new HashMap(2*_map776.size); + long _key777; + String _val778; + for (int _i779 = 0; _i779 < _map776.size; ++_i779) { - _key567 = iprot.readI64(); - _val568 = iprot.readString(); - struct.success.put(_key567, _val568); + _key777 = iprot.readI64(); + _val778 = iprot.readString(); + struct.success.put(_key777, _val778); } } struct.setSuccessIsSet(true); @@ -50727,14 +50727,14 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, bulkClose_args stru case 1: // ENTITIES if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list570 = iprot.readListBegin(); - struct.entities = new ArrayList(_list570.size); - EntityId _elem571; - for (int _i572 = 0; _i572 < _list570.size; ++_i572) + org.apache.thrift.protocol.TList _list780 = iprot.readListBegin(); + struct.entities = new ArrayList(_list780.size); + EntityId _elem781; + for (int _i782 = 0; _i782 < _list780.size; ++_i782) { - _elem571 = new EntityId(); - _elem571.read(iprot); - struct.entities.add(_elem571); + _elem781 = new EntityId(); + _elem781.read(iprot); + struct.entities.add(_elem781); } iprot.readListEnd(); } @@ -50762,9 +50762,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, bulkClose_args str oprot.writeFieldBegin(ENTITIES_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.entities.size())); - for (EntityId _iter573 : struct.entities) + for (EntityId _iter783 : struct.entities) { - _iter573.write(oprot); + _iter783.write(oprot); } oprot.writeListEnd(); } @@ -50795,9 +50795,9 @@ public void write(org.apache.thrift.protocol.TProtocol prot, bulkClose_args stru if (struct.isSetEntities()) { { oprot.writeI32(struct.entities.size()); - for (EntityId _iter574 : struct.entities) + for (EntityId _iter784 : struct.entities) { - _iter574.write(oprot); + _iter784.write(oprot); } } } @@ -50809,14 +50809,14 @@ public void read(org.apache.thrift.protocol.TProtocol prot, bulkClose_args struc BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { { - org.apache.thrift.protocol.TList _list575 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.entities = new ArrayList(_list575.size); - EntityId _elem576; - for (int _i577 = 0; _i577 < _list575.size; ++_i577) + org.apache.thrift.protocol.TList _list785 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.entities = new ArrayList(_list785.size); + EntityId _elem786; + for (int _i787 = 0; _i787 < _list785.size; ++_i787) { - _elem576 = new EntityId(); - _elem576.read(iprot); - struct.entities.add(_elem576); + _elem786 = new EntityId(); + _elem786.read(iprot); + struct.entities.add(_elem786); } } struct.setEntitiesIsSet(true); diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/SnappyException.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/SnappyException.java index 0d9a75f67..94539c770 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/SnappyException.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/SnappyException.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2017-11-17") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-10") public class SnappyException extends TException implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("SnappyException"); diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/SnappyExceptionData.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/SnappyExceptionData.java index 231aafa43..50139d94e 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/SnappyExceptionData.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/SnappyExceptionData.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2017-11-17") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-10") public class SnappyExceptionData implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("SnappyExceptionData"); diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/StatementAttrs.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/StatementAttrs.java index 9b805e109..21c0de4bb 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/StatementAttrs.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/StatementAttrs.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2017-11-17") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-10") public class StatementAttrs implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("StatementAttrs"); @@ -60,6 +60,7 @@ public class StatementAttrs implements org.apache.thrift.TBase, SchemeFactory> schemes = new HashMap, SchemeFactory>(); static { @@ -89,6 +90,7 @@ public class StatementAttrs implements org.apache.thrift.TBase byName = new HashMap(); @@ -172,6 +175,8 @@ public static _Fields findByThriftId(int fieldId) { return METADATA_VERSION; case 22: // SNAPSHOT_TRANSACTION_ID return SNAPSHOT_TRANSACTION_ID; + case 23: // CATALOG_VERSION + return CATALOG_VERSION; default: return null; } @@ -227,8 +232,9 @@ public String getFieldName() { private static final int __DOESCAPEPROCESSING_ISSET_ID = 12; private static final int __RETAINBUCKETIDS_ISSET_ID = 13; private static final int __METADATAVERSION_ISSET_ID = 14; + private static final int __CATALOGVERSION_ISSET_ID = 15; public short __isset_bitfield = 0; - private static final _Fields optionals[] = {_Fields.RESULT_SET_TYPE,_Fields.UPDATABLE,_Fields.HOLD_CURSORS_OVER_COMMIT,_Fields.REQUIRE_AUTO_INC_COLS,_Fields.AUTO_INC_COLUMNS,_Fields.AUTO_INC_COLUMN_NAMES,_Fields.BATCH_SIZE,_Fields.FETCH_REVERSE,_Fields.LOB_CHUNK_SIZE,_Fields.MAX_ROWS,_Fields.MAX_FIELD_SIZE,_Fields.TIMEOUT,_Fields.CURSOR_NAME,_Fields.POSSIBLE_DUPLICATE,_Fields.POOLABLE,_Fields.DO_ESCAPE_PROCESSING,_Fields.PENDING_TRANSACTION_ATTRS,_Fields.BUCKET_IDS,_Fields.BUCKET_IDS_TABLE,_Fields.RETAIN_BUCKET_IDS,_Fields.METADATA_VERSION,_Fields.SNAPSHOT_TRANSACTION_ID}; + private static final _Fields optionals[] = {_Fields.RESULT_SET_TYPE,_Fields.UPDATABLE,_Fields.HOLD_CURSORS_OVER_COMMIT,_Fields.REQUIRE_AUTO_INC_COLS,_Fields.AUTO_INC_COLUMNS,_Fields.AUTO_INC_COLUMN_NAMES,_Fields.BATCH_SIZE,_Fields.FETCH_REVERSE,_Fields.LOB_CHUNK_SIZE,_Fields.MAX_ROWS,_Fields.MAX_FIELD_SIZE,_Fields.TIMEOUT,_Fields.CURSOR_NAME,_Fields.POSSIBLE_DUPLICATE,_Fields.POOLABLE,_Fields.DO_ESCAPE_PROCESSING,_Fields.PENDING_TRANSACTION_ATTRS,_Fields.BUCKET_IDS,_Fields.BUCKET_IDS_TABLE,_Fields.RETAIN_BUCKET_IDS,_Fields.METADATA_VERSION,_Fields.SNAPSHOT_TRANSACTION_ID,_Fields.CATALOG_VERSION}; public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); @@ -281,6 +287,8 @@ public String getFieldName() { new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); tmpMap.put(_Fields.SNAPSHOT_TRANSACTION_ID, new org.apache.thrift.meta_data.FieldMetaData("snapshotTransactionId", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.CATALOG_VERSION, new org.apache.thrift.meta_data.FieldMetaData("catalogVersion", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(StatementAttrs.class, metaDataMap); } @@ -346,6 +354,7 @@ public StatementAttrs(StatementAttrs other) { if (other.isSetSnapshotTransactionId()) { this.snapshotTransactionId = other.snapshotTransactionId; } + this.catalogVersion = other.catalogVersion; } public StatementAttrs deepCopy() { @@ -391,6 +400,8 @@ public void clear() { setMetadataVersionIsSet(false); this.metadataVersion = 0; this.snapshotTransactionId = null; + setCatalogVersionIsSet(false); + this.catalogVersion = 0; } public byte getResultSetType() { @@ -963,6 +974,29 @@ public void setSnapshotTransactionIdIsSet(boolean value) { } } + public long getCatalogVersion() { + return this.catalogVersion; + } + + public StatementAttrs setCatalogVersion(long catalogVersion) { + this.catalogVersion = catalogVersion; + setCatalogVersionIsSet(true); + return this; + } + + public void unsetCatalogVersion() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __CATALOGVERSION_ISSET_ID); + } + + /** Returns true if field catalogVersion is set (has been assigned a value) and false otherwise */ + public boolean isSetCatalogVersion() { + return EncodingUtils.testBit(__isset_bitfield, __CATALOGVERSION_ISSET_ID); + } + + public void setCatalogVersionIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __CATALOGVERSION_ISSET_ID, value); + } + public void setFieldValue(_Fields field, Object value) { switch (field) { case RESULT_SET_TYPE: @@ -1141,6 +1175,14 @@ public void setFieldValue(_Fields field, Object value) { } break; + case CATALOG_VERSION: + if (value == null) { + unsetCatalogVersion(); + } else { + setCatalogVersion((Long)value); + } + break; + } } @@ -1212,6 +1254,9 @@ public Object getFieldValue(_Fields field) { case SNAPSHOT_TRANSACTION_ID: return getSnapshotTransactionId(); + case CATALOG_VERSION: + return getCatalogVersion(); + } throw new IllegalStateException(); } @@ -1267,6 +1312,8 @@ public boolean isSet(_Fields field) { return isSetMetadataVersion(); case SNAPSHOT_TRANSACTION_ID: return isSetSnapshotTransactionId(); + case CATALOG_VERSION: + return isSetCatalogVersion(); } throw new IllegalStateException(); } @@ -1482,6 +1529,15 @@ public boolean equals(StatementAttrs that) { return false; } + boolean this_present_catalogVersion = true && this.isSetCatalogVersion(); + boolean that_present_catalogVersion = true && that.isSetCatalogVersion(); + if (this_present_catalogVersion || that_present_catalogVersion) { + if (!(this_present_catalogVersion && that_present_catalogVersion)) + return false; + if (this.catalogVersion != that.catalogVersion) + return false; + } + return true; } @@ -1599,6 +1655,11 @@ public int hashCode() { if (present_snapshotTransactionId) list.add(snapshotTransactionId); + boolean present_catalogVersion = true && (isSetCatalogVersion()); + list.add(present_catalogVersion); + if (present_catalogVersion) + list.add(catalogVersion); + return list.hashCode(); } @@ -1830,6 +1891,16 @@ public int compareTo(StatementAttrs other) { return lastComparison; } } + lastComparison = Boolean.valueOf(isSetCatalogVersion()).compareTo(other.isSetCatalogVersion()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetCatalogVersion()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.catalogVersion, other.catalogVersion); + if (lastComparison != 0) { + return lastComparison; + } + } return 0; } @@ -2009,6 +2080,12 @@ public String toString() { } first = false; } + if (isSetCatalogVersion()) { + if (!first) sb.append(", "); + sb.append("catalogVersion:"); + sb.append(this.catalogVersion); + first = false; + } sb.append(")"); return sb.toString(); } @@ -2272,6 +2349,14 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, StatementAttrs stru org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; + case 23: // CATALOG_VERSION + if (schemeField.type == org.apache.thrift.protocol.TType.I64) { + struct.catalogVersion = iprot.readI64(); + struct.setCatalogVersionIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -2440,6 +2525,11 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, StatementAttrs str oprot.writeFieldEnd(); } } + if (struct.isSetCatalogVersion()) { + oprot.writeFieldBegin(CATALOG_VERSION_FIELD_DESC); + oprot.writeI64(struct.catalogVersion); + oprot.writeFieldEnd(); + } oprot.writeFieldStop(); oprot.writeStructEnd(); } @@ -2524,7 +2614,10 @@ public void write(org.apache.thrift.protocol.TProtocol prot, StatementAttrs stru if (struct.isSetSnapshotTransactionId()) { optionals.set(21); } - oprot.writeBitSet(optionals, 22); + if (struct.isSetCatalogVersion()) { + optionals.set(22); + } + oprot.writeBitSet(optionals, 23); if (struct.isSetResultSetType()) { oprot.writeByte(struct.resultSetType); } @@ -2616,12 +2709,15 @@ public void write(org.apache.thrift.protocol.TProtocol prot, StatementAttrs stru if (struct.isSetSnapshotTransactionId()) { oprot.writeString(struct.snapshotTransactionId); } + if (struct.isSetCatalogVersion()) { + oprot.writeI64(struct.catalogVersion); + } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, StatementAttrs struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(22); + BitSet incoming = iprot.readBitSet(23); if (incoming.get(0)) { struct.resultSetType = iprot.readByte(); struct.setResultSetTypeIsSet(true); @@ -2748,6 +2844,10 @@ public void read(org.apache.thrift.protocol.TProtocol prot, StatementAttrs struc struct.snapshotTransactionId = iprot.readString(); struct.setSnapshotTransactionIdIsSet(true); } + if (incoming.get(22)) { + struct.catalogVersion = iprot.readI64(); + struct.setCatalogVersionIsSet(true); + } } } diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/StatementResult.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/StatementResult.java index 484ef87cd..3b1f858c8 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/StatementResult.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/StatementResult.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2017-11-17") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-10") public class StatementResult implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("StatementResult"); diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/TransactionXid.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/TransactionXid.java index b272edc7c..107a0e643 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/TransactionXid.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/TransactionXid.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2017-11-17") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-10") public class TransactionXid implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TransactionXid"); diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/UpdateResult.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/UpdateResult.java index a62492aae..c46b0aad0 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/UpdateResult.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/UpdateResult.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2017-11-17") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-10") public class UpdateResult implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("UpdateResult"); diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/BlobChunk.java.tmpl b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/BlobChunk.java.tmpl index b47d66047..8579507e4 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/BlobChunk.java.tmpl +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/BlobChunk.java.tmpl @@ -7,7 +7,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/BufferedBlob.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/BufferedBlob.java index 3077e8b04..7f367168f 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/BufferedBlob.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/BufferedBlob.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/ColumnValue.java.tmpl b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/ColumnValue.java.tmpl index abe3b2ac3..8636cbaef 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/ColumnValue.java.tmpl +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/ColumnValue.java.tmpl @@ -7,7 +7,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/ColumnValueConverter.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/ColumnValueConverter.java index 4c2fe21c2..3dd5f83cc 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/ColumnValueConverter.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/ColumnValueConverter.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/Converters.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/Converters.java index 6ea03ba38..79491b9db 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/Converters.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/Converters.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/HostAddress.java.tmpl b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/HostAddress.java.tmpl index dfa34fdd8..f05677b2c 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/HostAddress.java.tmpl +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/HostAddress.java.tmpl @@ -26,7 +26,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/LobService.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/LobService.java index 877a66a32..9bb1dcc07 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/LobService.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/LobService.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/OptimizedElementArray.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/OptimizedElementArray.java index 4335ab291..b84d10323 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/OptimizedElementArray.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/OptimizedElementArray.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/PrepareResultHolder.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/PrepareResultHolder.java index 30c4664c0..6a75e5b6c 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/PrepareResultHolder.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/PrepareResultHolder.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/Row.java.tmpl b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/Row.java.tmpl index b1b6bb923..1e6da6835 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/Row.java.tmpl +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/Row.java.tmpl @@ -24,7 +24,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/SSLFactory.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/SSLFactory.java index 09f94f247..f38357e49 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/SSLFactory.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/SSLFactory.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/SSLSocketChannel.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/SSLSocketChannel.java index 4dbd6cfe1..e1af0c685 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/SSLSocketChannel.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/SSLSocketChannel.java @@ -19,7 +19,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/ServerType.java.tmpl b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/ServerType.java.tmpl index 72f801ec0..2448ff57b 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/ServerType.java.tmpl +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/ServerType.java.tmpl @@ -26,7 +26,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/SnappyTSSLSocket.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/SnappyTSSLSocket.java index 2e48064b9..7c931affe 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/SnappyTSSLSocket.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/SnappyTSSLSocket.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/SnappyTSocket.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/SnappyTSocket.java index f43bd1a4e..904ffaf7b 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/SnappyTSocket.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/SnappyTSocket.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -67,9 +67,6 @@ public final class SnappyTSocket extends TNonblockingTransport implements SocketTimeout { - private static final Logger LOGGER = LoggerFactory - .getLogger(SnappyTSocket.class.getName()); - /** * Wrapped SocketChannel object. */ @@ -139,7 +136,6 @@ public SnappyTSocket(SocketChannel srvChannel, boolean useSSL, this.framedWrites = false; this.socketToSameHost = ClientSharedUtils.isSocketToSameHost(dataChannel); } catch (IOException ioe) { - LOGGER.warn("Failed to create or configure socket for client.", ioe); close(); throw new TTransportException(TTransportException.NOT_OPEN, "Failed to create or configure socket for client.", ioe); @@ -180,7 +176,6 @@ public SnappyTSocket(InetAddress srvAddress, int port, String clientId, this.dataChannel = openChannel(clientId, useSSL, params); this.socketToSameHost = ClientSharedUtils.isSocketToSameHost(dataChannel); } catch (IOException ioe) { - LOGGER.warn("Failed to create or configure socket.", ioe); close(); throw new TTransportException(TTransportException.NOT_OPEN, "Failed to create or configure socket.", ioe); diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/SocketParameters.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/SocketParameters.java index c3283687c..b73087097 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/SocketParameters.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/SocketParameters.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/SocketTimeout.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/SocketTimeout.java index 0a4f9ddb5..3826f6184 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/SocketTimeout.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/SocketTimeout.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/TBinaryProtocolDirect.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/TBinaryProtocolDirect.java index 7ad07d0c5..eb133d9d2 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/TBinaryProtocolDirect.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/TBinaryProtocolDirect.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/TCompactProtocolDirect.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/TCompactProtocolDirect.java index f0fca8b99..310ddb5ef 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/TCompactProtocolDirect.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/TCompactProtocolDirect.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/TProtocolDirectBinary.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/TProtocolDirectBinary.java index e0ee00518..98e73c80a 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/TProtocolDirectBinary.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/TProtocolDirectBinary.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/ThriftExceptionUtil.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/ThriftExceptionUtil.java index 5cf17bfde..c8849697e 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/ThriftExceptionUtil.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/ThriftExceptionUtil.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/ThriftRow.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/ThriftRow.java index ff2616bc1..8dd101643 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/ThriftRow.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/ThriftRow.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/ThriftUtils.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/ThriftUtils.java index cfc41aadc..461a6e943 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/ThriftUtils.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/ThriftUtils.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/snappydata.thrift b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/snappydata.thrift index 6aeb74817..105c80b43 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/snappydata.thrift +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/common/snappydata.thrift @@ -18,7 +18,7 @@ // ---------------------------------------------------------------- // Changes for SnappyData data platform. // -// Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. +// Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you // may not use this file except in compliance with the License. You @@ -515,11 +515,13 @@ struct StatementAttrs { 19: optional string bucketIdsTable // retain bucketIds for the connection till an explicit commit/rollback 20: optional bool retainBucketIds - // the last meta-data version recorded by client which will throw exception - // on mismatch so that caller can refresh meta-data (if being cached) + // Deprecated: i64 catalogVersion used now 21: optional i32 metadataVersion // snapshot TXId to be used for current statement (to apply across connections) 22: optional string snapshotTransactionId + // the last catalog meta-data version recorded by client which will throw exception + // on mismatch so that caller can refresh catalog meta-data (if being cached) + 23: optional i64 catalogVersion } union ColumnValue { @@ -689,6 +691,135 @@ struct StatementResult { 8: optional PrepareResult preparedResult } +// for bucket to server mapping +// encapsulates both the mapping for partitioned regions for each bucket +// or for replicated regions bucketId=-1 with secondaries having all owners +struct BucketOwners { + 1: required i32 bucketId + 2: optional string primary + 3: optional list secondaries +} + +// encapsulates Spark's CatalogStorageFormat +struct CatalogStorage { + 1: required map properties + 2: required bool compressed + 3: optional string locationUri + 4: optional string inputFormat + 5: optional string outputFormat + 6: optional string serde +} + +// encapsulates Spark's CatalogDatabase +struct CatalogSchemaObject { + 1: required string name + 2: required string description + 3: required string locationUri + 4: required map properties +} + +// encapsulates Spark's CatalogTable and SnappyData extensions like BucketOwners, indexColumns etc +struct CatalogTableObject { + 1: required string tableName + 2: optional string schemaName + 3: required string tableType + 4: required CatalogStorage storage + 5: required string tableSchema + 6: optional string provider + 7: required list partitionColumns + 8: required list indexColumns + 9: required list primaryKeyColumns + 10: optional i32 numBuckets + 11: optional i32 redundancy + // SnappyData tables have bucketOwners while hive native tables have bucketColumns, sortColumns + 12: required list bucketOwners + 13: required list bucketColumns + 14: required list sortColumns + 15: required string owner + 16: required i64 createTime + 17: required i64 lastAccessTime + 18: required map properties + 19: optional i64 sizeInBytes + 20: optional i64 rowCount + // statistics for each column of the table (or empty if none) + 21: required list> colStats + 22: required bool isBroadcastable + 23: optional string viewOriginalText + 24: optional string viewText + 25: optional string comment + 26: required list unsupportedFeatures + 27: required bool tracksPartitionsInCatalog + 28: required bool schemaPreservesCase +} + +// encapsulates Spark's CatalogFunction +struct CatalogFunctionObject { + 1: required string functionName + 2: optional string schemaName + 3: required string className + 4: required list resources +} + +// encapsulates Spark's CatalogTablePartition +struct CatalogPartitionObject { + 1: required map spec + 2: required CatalogStorage storage + 3: required map parameters +} + +struct CatalogMetadataRequest { + 1: optional string schemaName + 2: optional string nameOrPattern + 3: optional map properties +} + +// encapsulates either the results for different kinds of get operations +// or the input for update operations listed as constants with prefix CATALOG_ +struct CatalogMetadataDetails { + 1: optional list names + 2: optional list> properties + 3: optional list> newProperties + 4: optional i64 catalogSchemaVersion + 5: optional bool exists + 6: optional list otherFlags + 7: optional CatalogSchemaObject catalogSchema + 8: optional CatalogTableObject catalogTable + 9: optional CatalogFunctionObject catalogFunction + 10: optional list catalogPartitions +} + +// different types of get operations returning CatalogMetadataDetails +const i32 CATALOG_GET_SCHEMA = 1 +const i32 CATALOG_SCHEMA_EXISTS = 2 +const i32 CATALOG_LIST_SCHEMAS = 3 +const i32 CATALOG_GET_TABLE = 4 +const i32 CATALOG_TABLE_EXISTS = 5 +const i32 CATALOG_LIST_TABLES = 6 +const i32 CATALOG_GET_FUNCTION = 7 +const i32 CATALOG_FUNCTION_EXISTS = 8 +const i32 CATALOG_LIST_FUNCTIONS = 9 +const i32 CATALOG_GET_PARTITION = 10 +const i32 CATALOG_LIST_PARTITION_NAMES = 11 +const i32 CATALOG_LIST_PARTITIONS = 12 + +// different types of update operations passing CatalogMetadataDetails +const i32 CATALOG_CREATE_SCHEMA = 101 +const i32 CATALOG_DROP_SCHEMA = 102 +const i32 CATALOG_CREATE_TABLE = 103 +const i32 CATALOG_DROP_TABLE = 104 +const i32 CATALOG_ALTER_TABLE = 105 +const i32 CATALOG_RENAME_TABLE = 106 +const i32 CATALOG_LOAD_TABLE = 107 +const i32 CATALOG_CREATE_FUNCTION = 108 +const i32 CATALOG_DROP_FUNCTION = 109 +const i32 CATALOG_RENAME_FUNCTION = 110 +const i32 CATALOG_CREATE_PARTITIONS = 111 +const i32 CATALOG_DROP_PARTITIONS = 112 +const i32 CATALOG_ALTER_PARTITIONS = 113 +const i32 CATALOG_RENAME_PARTITIONS = 114 +const i32 CATALOG_LOAD_PARTITION = 115 +const i32 CATALOG_LOAD_DYNAMIC_PARTITIONS = 116 + // type IDs for EntityId used by bulkClose API const byte BULK_CLOSE_RESULTSET = 1 const byte BULK_CLOSE_LOB = 2 diff --git a/gemfirexd/shared/src/main/java/io/snappydata/thrift/snappydataConstants.java b/gemfirexd/shared/src/main/java/io/snappydata/thrift/snappydataConstants.java index 31573c2a9..eb2193219 100644 --- a/gemfirexd/shared/src/main/java/io/snappydata/thrift/snappydataConstants.java +++ b/gemfirexd/shared/src/main/java/io/snappydata/thrift/snappydataConstants.java @@ -132,6 +132,62 @@ public class snappydataConstants { public static final byte STATEMENT_TYPE_DDL = (byte)5; + public static final int CATALOG_GET_SCHEMA = 1; + + public static final int CATALOG_SCHEMA_EXISTS = 2; + + public static final int CATALOG_LIST_SCHEMAS = 3; + + public static final int CATALOG_GET_TABLE = 4; + + public static final int CATALOG_TABLE_EXISTS = 5; + + public static final int CATALOG_LIST_TABLES = 6; + + public static final int CATALOG_GET_FUNCTION = 7; + + public static final int CATALOG_FUNCTION_EXISTS = 8; + + public static final int CATALOG_LIST_FUNCTIONS = 9; + + public static final int CATALOG_GET_PARTITION = 10; + + public static final int CATALOG_LIST_PARTITION_NAMES = 11; + + public static final int CATALOG_LIST_PARTITIONS = 12; + + public static final int CATALOG_CREATE_SCHEMA = 101; + + public static final int CATALOG_DROP_SCHEMA = 102; + + public static final int CATALOG_CREATE_TABLE = 103; + + public static final int CATALOG_DROP_TABLE = 104; + + public static final int CATALOG_ALTER_TABLE = 105; + + public static final int CATALOG_RENAME_TABLE = 106; + + public static final int CATALOG_LOAD_TABLE = 107; + + public static final int CATALOG_CREATE_FUNCTION = 108; + + public static final int CATALOG_DROP_FUNCTION = 109; + + public static final int CATALOG_RENAME_FUNCTION = 110; + + public static final int CATALOG_CREATE_PARTITIONS = 111; + + public static final int CATALOG_DROP_PARTITIONS = 112; + + public static final int CATALOG_ALTER_PARTITIONS = 113; + + public static final int CATALOG_RENAME_PARTITIONS = 114; + + public static final int CATALOG_LOAD_PARTITION = 115; + + public static final int CATALOG_LOAD_DYNAMIC_PARTITIONS = 116; + public static final byte BULK_CLOSE_RESULTSET = (byte)1; public static final byte BULK_CLOSE_LOB = (byte)2; diff --git a/gemfirexd/shared/src/main/java/org/apache/thrift/protocol/Helper.java b/gemfirexd/shared/src/main/java/org/apache/thrift/protocol/Helper.java index 55ebd2b81..25abd2c6c 100644 --- a/gemfirexd/shared/src/main/java/org/apache/thrift/protocol/Helper.java +++ b/gemfirexd/shared/src/main/java/org/apache/thrift/protocol/Helper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/tools/build.gradle b/gemfirexd/tools/build.gradle index 1e4fc3116..8ced63d48 100644 --- a/gemfirexd/tools/build.gradle +++ b/gemfirexd/tools/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -15,10 +15,7 @@ * LICENSE file. */ -plugins { - id 'ca.coglinc.javacc' version '2.4.0' - id 'com.github.johnrengelman.shadow' version '2.0.4' -} +apply plugin: 'ca.coglinc2.javacc' artifacts { archives packageTests @@ -29,11 +26,11 @@ dependencies { compile project(subprojectBase + 'snappydata-store-hibernate') // ddlutils dependencies - compile 'commons-beanutils:commons-beanutils:1.9.3' - compile 'commons-codec:commons-codec:1.10' - compile 'commons-configuration:commons-configuration:1.10' - compile 'commons-pool:commons-pool:1.6' - compile 'commons-dbcp:commons-dbcp:1.4' + compile "commons-beanutils:commons-beanutils:${commonsBeanutilsVersion}" + compile "commons-codec:commons-codec:${commonsCodecVersion}" + compile "commons-configuration:commons-configuration:${commonsConfigVersion}" + compile "commons-pool:commons-pool:${commonsPoolVersion}" + compile "commons-dbcp:commons-dbcp:${commonsDbcpVersion}" compile "jline:jline:${jlineVersion}" compile("org.apache.thrift:libthrift:${thriftVersion}") { exclude(group: 'org.slf4j', module: 'slf4j-api') @@ -51,8 +48,8 @@ dependencies { testCompile project(subprojectBase + 'gemfire-junit') compileOnly files("${System.getProperty('java.home')}/../lib/tools.jar") - compileOnly 'xalan:xalan:2.7.2' - compileOnly 'xalan:serializer:2.7.2' + compileOnly "xalan:xalan:${xalanVersion}" + compileOnly "xalan:serializer:${xalanVersion}" compileOnly "com.pivotal:pxf-api:${pxfVersion}" compileOnly "org.apache.hadoop:hadoop-annotations:${hadoopVersion}" @@ -82,7 +79,8 @@ dependencies { testCompile "com.sun.jersey:jersey-servlet:${sunJerseyVersion}" testCompile "org.mortbay.jetty:jetty:${hadoopJettyVersion}" testCompile "org.mortbay.jetty:jetty-util:${hadoopJettyVersion}" - testCompile 'org.cloudera.htrace:htrace-core:2.05' + testCompile "org.mortbay.jetty:jetty-sslengine:${hadoopJettyVersion}" + testCompile "org.cloudera.htrace:htrace-core:${clouderaHtraceVersion}" testCompile "org.apache.hadoop:hadoop-common:${hadoopVersion}:tests" testCompile "org.apache.hadoop:hadoop-hdfs:${hadoopVersion}:tests" @@ -92,10 +90,10 @@ dependencies { testCompile "org.apache.derby:derbynet:${derbyVersion}" testRuntime "org.apache.derby:derbytools:${derbyVersion}" testRuntime "org.apache.derby:derbyclient:${derbyVersion}" - testCompile 'oro:oro:2.0.8' - testCompile 'dom4j:dom4j:1.6.1' + testCompile "oro:oro:${oroVersion}" + testCompile "dom4j:dom4j:${dom4jVersion}" // Embedded Apache Directory Server for LDAP tests - testCompile(group: 'org.apache.directory.server', name: 'apacheds-all', version: '1.5.7') { + testCompile(group: 'org.apache.directory.server', name: 'apacheds-all', version: apacheDsVersion) { exclude(group: 'org.apache.directory.shared', module: 'shared-ldap-schema') } @@ -118,9 +116,9 @@ sourceSets.main.java.srcDirs = [ 'src/main/java', javaccOut, 'src/ddlutils/java' sourceSets.test.java.srcDirs = [ 'src/test/java', 'src/dunit/java', 'src/demo/java' ] task generatePropertiesFiles(dependsOn: 'processResources') { - def infoDir = file("${buildDir}/resources/main/com/pivotal/gemfirexd/internal/info") + def infoDir = file("${sourceSets.main.java.outputDir}/com/pivotal/gemfirexd/internal/info") outputs.file "${infoDir}/tools.properties" - inputs.dir compileJava.destinationDir + inputs.dir "${projectDir}/../core/src/main/resources/com/pivotal/gemfirexd/internal/info" doLast { println('Creating tools properties') diff --git a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/ClientServerDUnit.java b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/ClientServerDUnit.java index 3a5a414ea..7f9f054e9 100644 --- a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/ClientServerDUnit.java +++ b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/ClientServerDUnit.java @@ -50,6 +50,7 @@ import com.pivotal.gemfirexd.internal.engine.GfxdConstants; import com.pivotal.gemfirexd.internal.engine.ddl.resolver.GfxdPartitionByExpressionResolver; import com.pivotal.gemfirexd.internal.engine.jdbc.GemFireXDRuntimeException; +import com.pivotal.gemfirexd.internal.engine.store.GemFireStore; import com.pivotal.gemfirexd.internal.engine.store.ServerGroupUtils; import com.pivotal.gemfirexd.internal.iapi.error.PublicAPI; import com.pivotal.gemfirexd.internal.iapi.error.StandardException; @@ -59,9 +60,11 @@ import com.pivotal.gemfirexd.internal.iapi.sql.dictionary.SchemaDescriptor; import com.pivotal.gemfirexd.internal.impl.jdbc.EmbedStatement; import com.pivotal.gemfirexd.internal.impl.jdbc.authentication.AuthenticationServiceBase; +import com.pivotal.gemfirexd.jdbc.ClientAttribute; import io.snappydata.app.TestThrift; import io.snappydata.test.dunit.Host; import io.snappydata.test.dunit.RMIException; +import io.snappydata.test.dunit.SerializableCallable; import io.snappydata.test.dunit.SerializableRunnable; import io.snappydata.test.dunit.VM; import io.snappydata.test.util.TestException; @@ -1223,7 +1226,7 @@ public void testThriftFramedProtocol() throws Exception { public void test44240() throws Exception { /* System.setProperty("gemfirexd.debug.true", "TraceClientHA"); - System.setProperty("gemfirexd.client.traceDirectory", + System.setProperty("snappydata.client.traceDirectory", getSysDirName(getGemFireDescription())); */ @@ -1348,7 +1351,7 @@ public void run() { public void test44240_LOB() throws Exception { /* System.setProperty("gemfirexd.debug.true", "TraceClientHA"); - System.setProperty("gemfirexd.client.traceDirectory", + System.setProperty("snappydata.client.traceDirectory", getSysDirName(getGemFireDescription())); */ @@ -1829,6 +1832,38 @@ public void testNetworkClientFailoverWithCurrentSchemaSetting() throws Exception * multiple servers using GFE's ServerLocator. Also check for the failover. */ public void testNetworkClientLoadBalancing() throws Exception { + // always use thrift for this test + SerializableRunnable setThrift = new SerializableRunnable() { + @Override + public void run() { + System.setProperty("gemfirexd." + + ClientSharedUtils.USE_THRIFT_AS_DEFAULT_PROP, "true"); + ClientSharedUtils.setThriftDefault(true); + } + }; + setThrift.run(); + for (int i = 0; i <= 3; i++) { + Host.getHost(0).getVM(i).invoke(setThrift); + } + try { + runTestNetworkClientLoadBalancing(); + } finally { + SerializableRunnable resetThrift = new SerializableRunnable() { + @Override + public void run() { + System.setProperty("gemfirexd." + + ClientSharedUtils.USE_THRIFT_AS_DEFAULT_PROP, "false"); + ClientSharedUtils.setThriftDefault(false); + } + }; + resetThrift.run(); + for (int i = 0; i <= 3; i++) { + Host.getHost(0).getVM(i).invoke(resetThrift); + } + } + } + + private void runTestNetworkClientLoadBalancing() throws Exception { // start the GemFireXD locator final VM locator = Host.getHost(0).getVM(3); final int netPort = AvailablePort @@ -1848,18 +1883,73 @@ public void testNetworkClientLoadBalancing() throws Exception { startVMs(0, 2, 0, null, props); // Start a couple of network servers final int netPort1 = startNetworkServer(1, null, null); - startNetworkServer(2, null, null); + final int netPort2 = startNetworkServer(2, null, null); attachConnectionListener(1, connListener); attachConnectionListener(2, connListener); attachConnectionListener(locator, connListener); + // check that load-balance is false by default when connecting directly to servers + // and true when connecting to locator + for (int i = 0; i < 10; i++) { + Connection conn = TestUtil.getNetConnection(localHost.getCanonicalHostName(), + netPort, null, new Properties()); + assertEquals("true", + ((ClientConnection)conn).getConnectionProperties().get(ClientAttribute.LOAD_BALANCE)); + assertNumConnections(-1, 0, locator); + conn.close(); + } + // reattach listener to clear the counts + attachConnectionListener(1, connListener); + attachConnectionListener(2, connListener); + attachConnectionListener(locator, connListener); + final SerializableCallable getDSID = new SerializableCallable() { + @Override + public Object call() throws Exception { + return GemFireStore.getMyId().getId(); + } + }; + String dsid1 = (String)serverExecute(1, getDSID); + String dsid2 = (String)serverExecute(2, getDSID); + for (int i = 0; i < 10; i++) { + Connection conn1 = TestUtil.getNetConnection(localHost.getCanonicalHostName(), + netPort1, null, new Properties()); + Statement stmt1 = conn1.createStatement(); + ResultSet rs1 = stmt1.executeQuery("values dsid()"); + assertTrue(rs1.next()); + assertEquals(dsid1, rs1.getString(1)); + assertFalse(rs1.next()); + + Connection conn2 = TestUtil.getNetConnection(localHost.getCanonicalHostName(), + netPort2, null, new Properties()); + Statement stmt2 = conn2.createStatement(); + ResultSet rs2 = stmt2.executeQuery("values dsid()"); + assertTrue(rs2.next()); + assertEquals(dsid2, rs2.getString(1)); + assertFalse(rs2.next()); + + assertEquals("false", + ((ClientConnection)conn1).getConnectionProperties().get(ClientAttribute.LOAD_BALANCE)); + assertEquals("false", + ((ClientConnection)conn2).getConnectionProperties().get(ClientAttribute.LOAD_BALANCE)); + assertNumConnections(0, 0, locator); + stmt1.close(); + stmt2.close(); + conn1.close(); + conn2.close(); + assertNumConnections(0, 0, locator); + } + // reattach listener to clear the counts + attachConnectionListener(1, connListener); + attachConnectionListener(2, connListener); + attachConnectionListener(locator, connListener); + // Use this VM as the network client Connection conn = TestUtil.getNetConnection(localHost.getCanonicalHostName(), netPort, null, new Properties()); // check new connections opened on locator and servers - assertNumConnections(1, 0, locator); + assertNumConnections(-1, 0, locator); assertNumConnections(1, -1, 1, 2); // Create a table @@ -1890,7 +1980,7 @@ public void testNetworkClientLoadBalancing() throws Exception { assertEquals(s, resultStr); assertFalse(rs.next()); - assertNumConnections(1, 0, locator); + assertNumConnections(-1, 0, locator); assertNumConnections(1, -1, 1, 2); // now open another connection with server1 URL @@ -1898,9 +1988,8 @@ public void testNetworkClientLoadBalancing() throws Exception { netPort1, null, new Properties()); // check new connection opened on servers successfully load-balanced - assertNumConnections(1, 0, locator); - assertNumConnections(-2, -1, 1); - assertNumConnections(-2, -1, 2); + assertNumConnections(-1, 0, locator); + assertNumConnections(-3, -1, 1, 2); stmt = conn2.createStatement(); rs = stmt.executeQuery("select * from TESTTABLE"); @@ -1916,15 +2005,14 @@ public void testNetworkClientLoadBalancing() throws Exception { assertEquals(s, resultStr); assertFalse(rs.next()); - assertNumConnections(1, 0, locator); - assertNumConnections(-2, -1, 1); - assertNumConnections(-2, -1, 2); + assertNumConnections(-1, 0, locator); + assertNumConnections(-3, -1, 1, 2); // now a third connection Connection conn3 = TestUtil.getNetConnection(localHost.getCanonicalHostName(), netPort, null, new Properties()); - assertNumConnections(1, 0, locator); + assertNumConnections(-1, 0, locator); assertNumConnections(-4, -1, 1, 2); // add expected exception for server connection failure @@ -1933,20 +2021,29 @@ public void testNetworkClientLoadBalancing() throws Exception { // now stop the first server and check for successful failover to second stopVMNums(-1); - pstmt = conn2.prepareStatement("insert into TESTTABLE values(?,?)"); + pstmt = conn.prepareStatement("insert into TESTTABLE values(?,?)"); final String s2 = "test\u0906"; pstmt.setInt(1, 2); pstmt.setString(2, s2); pstmt.execute(); - // check failover for conn, conn3 too - conn.createStatement().execute("select count(*) from TESTTABLE"); + // check failover for conn3 too conn3.createStatement().execute("select count(ID) from TESTTABLE"); + // conn2 should be invalid now due to load-balance=false by default + try { + conn2.createStatement().execute("select count(ID) from TESTTABLE"); + fail("excepted connection to fail without load balancing"); + } catch (SQLException sqle) { + if (!"X0Z01".equals(sqle.getSQLState())) { + throw sqle; + } + } + // check connections opened on second server - assertNumConnections(1, 0, locator); - assertNumConnections(-4, -1, 2); + assertNumConnections(-1, 0, locator); + assertNumConnections(-4, -2, 2); removeExpectedException(null, new Object[] { java.net.ConnectException.class, DisconnectException.class, @@ -1981,30 +2078,31 @@ public void testNetworkClientLoadBalancing() throws Exception { assertFalse(rs.next()); // check connection opened on second server - assertNumConnections(1, 0, locator); - assertNumConnections(-5, -1, 2); + assertNumConnections(-1, 0, locator); + assertNumConnections(-5, -2, 2); // now drop the table and close the connections + stmt = conn.createStatement(); stmt.execute("drop table TESTTABLE"); stmt.close(); conn.close(); - assertNumConnections(1, 0, locator); - assertNumConnections(-5, -2, 2); + assertNumConnections(-1, 0, locator); + assertNumConnections(-5, -3, 2); conn2.close(); - assertNumConnections(1, 0, locator); + assertNumConnections(-1, 0, locator); assertNumConnections(-5, -3, 2); conn3.close(); - assertNumConnections(1, 0, locator); + assertNumConnections(-1, 0, locator); assertNumConnections(-5, -4, 2); conn4.close(); - assertNumConnections(1, 0, locator); + assertNumConnections(-1, 0, locator); assertNumConnections(-5, -5, 2); } diff --git a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/SingleHopDUnit.java b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/SingleHopDUnit.java index f62e4eefa..bdb19d30c 100644 --- a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/SingleHopDUnit.java +++ b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/SingleHopDUnit.java @@ -30,6 +30,7 @@ import com.gemstone.gemfire.distributed.internal.DistributionManager; import com.gemstone.gemfire.internal.AvailablePort; +import com.gemstone.gemfire.internal.shared.ClientSharedUtils; import com.gemstone.gnu.trove.THashMap; import com.pivotal.gemfirexd.internal.client.am.SingleHopPreparedStatement; @@ -647,14 +648,16 @@ public void testCompareSingleHopVsSimpleClientConnection_allDMLs() final boolean warmup = numTimes > 100 ? true : false; final Properties props = new Properties(); props.put("log-level", "config"); - if (warmup) { - invokeInEveryVM(new SerializableRunnable() { - @Override - public void run() { + invokeInEveryVM(new SerializableRunnable() { + @Override + public void run() { + if (warmup) { DistributionManager.VERBOSE = false; } - }); - } + ClientSharedUtils.setThriftDefault(false); + } + }); + ClientSharedUtils.setThriftDefault(false); // start some servers startVMs(0, 4, 0, null, props); // Start network server on the VMs diff --git a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/ddl/BugsDUnit.java b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/ddl/BugsDUnit.java index f8bb49567..36f9f067f 100644 --- a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/ddl/BugsDUnit.java +++ b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/ddl/BugsDUnit.java @@ -906,8 +906,8 @@ public void testBug48335() throws Exception { } public void testInsertFailoverbug_47407() throws Exception { - // System.setProperty("gemfirexd.client.traceLevel", ""); - // System.setProperty("gemfirexd.client.traceDirectory", + // System.setProperty("snappydata.client.traceLevel", ""); + // System.setProperty("snappydata.client.traceDirectory", // getSysDirName(getGemFireDescription())); // final Properties extraProps = new Properties(); // System.setProperty("gemfirexd.debug.true", "TraceSingleHop,TraceClientHA"); diff --git a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/ddl/CreateDiskStoreDUnit.java b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/ddl/CreateDiskStoreDUnit.java index b67d1b75d..0ad415811 100644 --- a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/ddl/CreateDiskStoreDUnit.java +++ b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/ddl/CreateDiskStoreDUnit.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/ddl/ExpirationDUnit.java b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/ddl/ExpirationDUnit.java index 0057c1ce6..686c37829 100644 --- a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/ddl/ExpirationDUnit.java +++ b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/ddl/ExpirationDUnit.java @@ -37,7 +37,7 @@ public ExpirationDUnit(String name) { private void checkExpiration(Statement st1) throws Exception { st1.execute("truncate table t1"); st1.execute("insert into t1 values (1, 1, 1)"); - Thread.sleep(14000); + Thread.sleep(5000); st1.execute("select col1 from t1"); ResultSet rs1 = st1.getResultSet(); assertFalse(rs1.next()); @@ -48,11 +48,11 @@ private void checkExpiration(Statement st1) throws Exception { private void checkNonPKBasedSelect(Statement st1) throws Exception { st1.execute("truncate table t1"); st1.execute("insert into t1 values (1, 1, 1)"); - Thread.sleep(2000); + Thread.sleep(1000); st1.execute("select col1 from t1"); ResultSet rs1 = st1.getResultSet(); assertTrue(rs1.next()); - Thread.sleep(10000); + Thread.sleep(4000); st1.execute("select col1 from t1"); rs1 = st1.getResultSet(); assertFalse(rs1.next()); @@ -62,18 +62,18 @@ private void checkNonPKBasedSelect(Statement st1) throws Exception { private void checkPKBasedSelect(Statement st1) throws Exception { st1.execute("truncate table t1"); st1.execute("insert into t1 values (1, 1, 1)"); - Thread.sleep(2000); + Thread.sleep(1000); long then = System.currentTimeMillis(); st1.execute("select col1 from t1 where col1 = 1"); ResultSet rs1 = st1.getResultSet(); assertTrue(rs1.next()); assertEquals(1, rs1.getInt(1)); - Thread.sleep(8000); + Thread.sleep(2500); st1.execute("select col1 from t1 where col1 = 1"); rs1 = st1.getResultSet(); boolean result = rs1.next(); long delta = System.currentTimeMillis() - then; - if (delta < 9000) { + if (delta < 3000) { assertTrue(result); assertEquals(1, rs1.getInt(1)); assertFalse(rs1.next()); @@ -86,16 +86,16 @@ private void checkPKBasedSelect(Statement st1) throws Exception { private void checkNonPKBasedUpdate(Statement st1) throws Exception { st1.execute("truncate table t1"); st1.execute("insert into t1 values (1, 1, 1)"); - Thread.sleep(2000); + Thread.sleep(1000); long then = System.currentTimeMillis(); st1.execute("update t1 set col2 = 2"); - Thread.sleep(8000); + Thread.sleep(2500); // after parallel run this can cause issue..3 seconds of wait and row is gone. st1.execute("select col1 from t1"); ResultSet rs1 = st1.getResultSet(); boolean result = rs1.next(); long delta = System.currentTimeMillis() - then; - if (delta < 9000) { + if (delta < 3000) { assertTrue(result); } else { rs1.close(); @@ -106,15 +106,15 @@ private void checkNonPKBasedUpdate(Statement st1) throws Exception { private void checkPKBasedUpdate(Statement st1) throws Exception { st1.execute("truncate table t1"); st1.execute("insert into t1 values (1, 1, 1)"); - Thread.sleep(2000); + Thread.sleep(1000); long then = System.currentTimeMillis(); st1.execute("update t1 set col2 = 2 where col1 = 1"); - Thread.sleep(8000); + Thread.sleep(2500); st1.execute("select col1 from t1 where col1 = 1"); ResultSet rs1 = st1.getResultSet(); boolean result = rs1.next(); long delta = System.currentTimeMillis() - then; - if (delta < 9000) { + if (delta < 3000) { assertTrue(result); assertEquals(1, rs1.getInt(1)); assertFalse(rs1.next()); @@ -134,8 +134,8 @@ private void basicEntryExpirationTest(Connection conn, boolean idletime, "idletime " : "timetolive "; String createTableStr = "create table t1 (col1 int constraint " + - "pk1 primary key, col2 int, col3 int) " + distributionPolicy + - "expire entry with " + expiryPolicy + "10 action destroy" ; + "pk1 primary key, col2 int, col3 int) " + distributionPolicy + + "expire entry with " + expiryPolicy + "3 action destroy" ; if (persistent) { createTableStr = createTableStr + " persistent"; @@ -221,15 +221,15 @@ public void testTimeToLive() throws Exception { clientSQLExecute(1, "create table EMP.TESTTABLE_ONE (ID int not null, " + " DESCRIPTION varchar(1024) not null, primary key (ID))" + "REPLICATE PERSISTENT 'teststore' " - + "EXPIRE ENTRY WITH TIMETOLIVE 10 ACTION DESTROY "); + + "EXPIRE ENTRY WITH TIMETOLIVE 3 ACTION DESTROY "); clientSQLExecute(1, "create table EMP.TESTTABLE_TWO (ID int not null, " + " DESCRIPTION varchar(1024) not null, primary key (ID))" + "PARTITION BY COLUMN (ID) PERSISTENT 'teststore' " - + "EXPIRE ENTRY WITH TIMETOLIVE 10 ACTION DESTROY "); + + "EXPIRE ENTRY WITH TIMETOLIVE 3 ACTION DESTROY "); clientSQLExecute(1, "insert into EMP.TESTTABLE_ONE values (1, 'hello')"); clientSQLExecute(1, "insert into EMP.TESTTABLE_TWO values (1, 'hello')"); - Thread.sleep(5000); + Thread.sleep(1500); clientSQLExecute(1, "insert into EMP.TESTTABLE_ONE values (2, 'goodbye')"); clientSQLExecute(1, "insert into EMP.TESTTABLE_TWO values (2, 'goodbye')"); long start = System.currentTimeMillis(); @@ -241,15 +241,15 @@ public void testTimeToLive() throws Exception { // some slow systems may already have exceeded the time in restart long elapsed = System.currentTimeMillis() - start; - if (elapsed < 6000) { - Thread.sleep(6000 - elapsed); - } else if (elapsed > 10000) { + if (elapsed < 2000) { + Thread.sleep(2000 - elapsed); + } else if (elapsed > 3000) { expected = null; } validateResults("EMP.TESTTABLE_ONE", expected); validateResults("EMP.TESTTABLE_TWO", expected); - Thread.sleep(5000); + Thread.sleep(1500); validateResults("EMP.TESTTABLE_ONE", null); validateResults("EMP.TESTTABLE_TWO", null); @@ -275,14 +275,14 @@ public void testAlterCommandTimeToLive() throws Exception { clientSQLExecute(1, "create table EMP.TESTTABLE (ID int not null, " + " DESCRIPTION varchar(1024) not null, primary key (ID))" + "REPLICATE PERSISTENT 'teststore' " - + "EXPIRE ENTRY WITH TIMETOLIVE 10 ACTION DESTROY "); + + "EXPIRE ENTRY WITH TIMETOLIVE 3 ACTION DESTROY "); clientSQLExecute(1, "insert into EMP.TESTTABLE values (1, 'hello')"); clientSQLExecute(1, "insert into EMP.TESTTABLE values (2, 'goodbye')"); //alter table set expire entry timetolive clientSQLExecute(1, "ALTER TABLE EMP.TESTTABLE " - + "set EXPIRE ENTRY WITH TIMETOLIVE 20 ACTION DESTROY"); + + "set EXPIRE ENTRY WITH TIMETOLIVE 6 ACTION DESTROY"); clientSQLExecute(1, "insert into EMP.TESTTABLE values (3, 'hello1')"); clientSQLExecute(1, "insert into EMP.TESTTABLE values (4, 'goodbye1')"); @@ -294,10 +294,10 @@ public void testAlterCommandTimeToLive() throws Exception { expected.add(3); expected.add(4); - Thread.sleep(11000); + Thread.sleep(4000); validateResults("EMP.TESTTABLE", expected); - Thread.sleep(10000); + Thread.sleep(3000); validateResults("EMP.TESTTABLE", null); clientSQLExecute(1, "drop table EMP.TESTTABLE"); @@ -326,16 +326,16 @@ public void testIdleTime() throws Exception { clientSQLExecute(1, "create table EMP.TESTTABLE_ONE (ID int not null, " + " DESCRIPTION varchar(1024) not null, primary key (ID))" + "REPLICATE PERSISTENT 'teststore' " - + "EXPIRE ENTRY WITH IDLETIME 10 ACTION DESTROY "); + + "EXPIRE ENTRY WITH IDLETIME 3 ACTION DESTROY "); clientSQLExecute(1, "create table EMP.TESTTABLE_TWO (ID int not null, " + " DESCRIPTION varchar(1024) not null, primary key (ID))" + "PARTITION BY COLUMN (ID) PERSISTENT 'teststore' " - + "EXPIRE ENTRY WITH IDLETIME 10 ACTION DESTROY "); + + "EXPIRE ENTRY WITH IDLETIME 3 ACTION DESTROY "); clientSQLExecute(1, "insert into EMP.TESTTABLE_ONE values (1, 'hello')"); clientSQLExecute(1, "insert into EMP.TESTTABLE_TWO values (1, 'hello')"); clientSQLExecute(1, "insert into EMP.TESTTABLE_TWO values (3, 'hello')"); - Thread.sleep(5000); + Thread.sleep(1500); long start = System.currentTimeMillis(); clientSQLExecute(1, "insert into EMP.TESTTABLE_ONE values (2, 'goodbye')"); clientSQLExecute(1, "insert into EMP.TESTTABLE_TWO values (2, 'goodbye')"); @@ -350,9 +350,9 @@ public void testIdleTime() throws Exception { // some slow systems may already have exceeded the time in restart long elapsed = System.currentTimeMillis() - start; - if (elapsed < 6000) { - Thread.sleep(6000 - elapsed); - } else if (elapsed > 10000) { + if (elapsed < 2000) { + Thread.sleep(2000 - elapsed); + } else if (elapsed > 3000) { expected = null; } @@ -361,7 +361,7 @@ public void testIdleTime() throws Exception { expected.add(3); } validateResults("EMP.TESTTABLE_TWO", expected); - Thread.sleep(5000); + Thread.sleep(1500); validateResults("EMP.TESTTABLE_ONE", null); validateResults("EMP.TESTTABLE_TWO", null); diff --git a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/distributed/DistributedLockDUnit.java b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/distributed/DistributedLockDUnit.java index c39c72770..444987852 100644 --- a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/distributed/DistributedLockDUnit.java +++ b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/distributed/DistributedLockDUnit.java @@ -41,13 +41,13 @@ import com.pivotal.gemfirexd.internal.engine.distributed.message.RegionExecutorMessage; import com.pivotal.gemfirexd.internal.engine.distributed.utils.GemFireXDUtils; import com.pivotal.gemfirexd.internal.engine.locks.GfxdDRWLockService; -import io.snappydata.collection.IntObjectHashMap; import io.snappydata.test.dunit.AsyncInvocation; import io.snappydata.test.dunit.SerializableCallable; import io.snappydata.test.dunit.SerializableRunnable; import io.snappydata.test.dunit.VM; import io.snappydata.test.dunit.standalone.DUnitBB; import io.snappydata.test.util.TestException; +import org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap; /** * Tests different scenarios for distributed read-write locks including testing @@ -488,8 +488,7 @@ public void run() { int[][] arrays5 = (int[][])async4.getResult(); System.gc(); - IntObjectHashMap allKeys = IntObjectHashMap.withExpectedSize( - numKeysPerVM * 5); + IntObjectHashMap allKeys = new IntObjectHashMap<>(numKeysPerVM * 5); checkUniqueKeys(allKeys, arrays1, "currentVM"); checkUniqueKeys(allKeys, arrays2, getServerVM(1)); checkUniqueKeys(allKeys, arrays3, getServerVM(2)); @@ -613,7 +612,7 @@ private static void checkUniqueKeys(final IntObjectHashMap allKeys, if (currentKey > lastKey) { oldVM = allKeys.get(key); if (oldVM == null) { - allKeys.justPut(key, vm); + allKeys.put(key, vm); lastKey = currentKey; } else { diff --git a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/internal/engine/distributed/CheckTableDUnit.java b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/internal/engine/distributed/CheckTableDUnit.java index 5fee860e8..e7dd31443 100644 --- a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/internal/engine/distributed/CheckTableDUnit.java +++ b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/internal/engine/distributed/CheckTableDUnit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/internal/engine/distributed/GemFireXDReconnectDUnit.java b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/internal/engine/distributed/GemFireXDReconnectDUnit.java index 1cc63dc33..8b26ce284 100644 --- a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/internal/engine/distributed/GemFireXDReconnectDUnit.java +++ b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/internal/engine/distributed/GemFireXDReconnectDUnit.java @@ -69,6 +69,7 @@ public void testReconnectServer() throws Exception { // set a reconnect-wait that's long enough for failure-detection to clean the view // when the server is crashed props.put(DistributionConfig.MAX_WAIT_TIME_FOR_RECONNECT_NAME, "15000"); + props.put(DistributionConfig.DISABLE_AUTO_RECONNECT_NAME, "false"); startVMs(1, 2, 0, null, props); // #clients, #servers, mcast-port, server-groups, connect props clientSQLExecute(1, "create table Account (" + " id int primary key, name varchar(100), type int )" @@ -133,6 +134,7 @@ public void testReconnectLocator() throws Exception { + locPort2 + "]"; Properties props = new Properties(); + props.put(DistributionConfig.DISABLE_AUTO_RECONNECT_NAME, "false"); props.setProperty(DistributionConfig.LOCATORS_NAME, locators); props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0"); props.put(DistributionConfig.MAX_WAIT_TIME_FOR_RECONNECT_NAME, "15000"); @@ -175,6 +177,7 @@ public void testReconnect_auth_and_netServer() throws Exception { props.setProperty(DistributionConfig.LOCATORS_NAME, locators); props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0"); props.put(DistributionConfig.MAX_WAIT_TIME_FOR_RECONNECT_NAME, "15000"); + props.put(DistributionConfig.DISABLE_AUTO_RECONNECT_NAME, "false"); props.setProperty("auth-provider", "BUILTIN"); props.setProperty("gemfirexd.user.sd", "pwd"); // system user props.setProperty("user", "sd"); diff --git a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/internal/engine/distributed/PreparedStatementDUnit.java b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/internal/engine/distributed/PreparedStatementDUnit.java index 677acba9e..bb3924e8c 100644 --- a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/internal/engine/distributed/PreparedStatementDUnit.java +++ b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/internal/engine/distributed/PreparedStatementDUnit.java @@ -60,10 +60,11 @@ import com.pivotal.gemfirexd.internal.impl.sql.GenericParameter; import com.pivotal.gemfirexd.internal.impl.sql.GenericParameterValueSet; import com.pivotal.gemfirexd.internal.impl.sql.GenericPreparedStatement; -import io.snappydata.collection.LongObjectHashMap; import io.snappydata.test.dunit.SerializableCallable; import io.snappydata.test.dunit.SerializableRunnable; import io.snappydata.test.dunit.VM; +import org.eclipse.collections.api.iterator.LongIterator; +import org.eclipse.collections.impl.map.mutable.primitive.LongObjectHashMap; /** * Tests whether the statementID , connectionID etc are being passed correctly @@ -2805,18 +2806,14 @@ public static int verifyWrapperSize(int expectedSize) throws SQLException { wrapper.getStatementMapForTEST(); // invoke a getStatement to force drain refQueue final GfxdConnectionWrapper connWrapper = wrapper; - stmntMap.forEachWhile((key, stmtRef) -> { - try { - EmbedConnection conn = connWrapper.getConnectionForSynchronization(); - synchronized (conn.getConnectionSynchronization()) { - connWrapper.getStatement(null, key, true, false, false, false, - null, false, 0, 0); - } - return false; - } catch (SQLException sqle) { - throw new RuntimeException(sqle); + LongIterator keys = stmntMap.keySet().longIterator(); + if (keys.hasNext()) { + EmbedConnection conn = connWrapper.getConnectionForSynchronization(); + synchronized (conn.getConnectionSynchronization()) { + connWrapper.getStatement(null, keys.next(), true, false, false, + false, null, false, 0, 0); } - }); + } mapSize = stmntMap.size(); if (mapSize <= expectedSize) { return mapSize; diff --git a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/internal/engine/management/GfxdTableMBeanDUnit.java b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/internal/engine/management/GfxdTableMBeanDUnit.java index 807db38fa..dc22234dd 100644 --- a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/internal/engine/management/GfxdTableMBeanDUnit.java +++ b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/internal/engine/management/GfxdTableMBeanDUnit.java @@ -898,7 +898,6 @@ public void testGetIndexInfo() throws Exception { long rowCount; double entrySize; - Thread.sleep(30*000); logInfo("Validating index info for all indexes "); @@ -908,6 +907,23 @@ public void testGetIndexInfo() throws Exception { indexNames.add("INDEX_TAG"); indexNames.add("INDEX_NAME"); indexNames.add(pkIndexName); + waitForCriterion(new WaitCriterion() { + @Override + public boolean done() { + try { + CompositeData[] data = (CompositeData[])mbsc.invoke(tableMBeanName, + "listIndexInfo", null, null); + return data != null && data.length == 4; + } catch (Exception e) { + throw new AssertionError(e.getMessage(), e); + } + } + + @Override + public String description() { + return "waiting for index information to show up in metadata"; + } + }, 30000, 500, true); CompositeData[] data = (CompositeData[]) mbsc.invoke(tableMBeanName, "listIndexInfo", null, null); assertEquals(4, data.length); for (CompositeData indexInfo : data) { diff --git a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/internal/transactions/OffHeapTransaction2DUnit.java b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/internal/transactions/OffHeapTransaction2DUnit.java index dc62ba1ea..ba3528ff6 100644 --- a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/internal/transactions/OffHeapTransaction2DUnit.java +++ b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/internal/transactions/OffHeapTransaction2DUnit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/internal/transactions/Transaction2DUnit.java b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/internal/transactions/Transaction2DUnit.java index 21948214c..810aea7df 100644 --- a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/internal/transactions/Transaction2DUnit.java +++ b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/internal/transactions/Transaction2DUnit.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData distributed computational and data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/internal/transactions/Transaction2RRDUnit.java b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/internal/transactions/Transaction2RRDUnit.java index 0540c695f..cc5056564 100644 --- a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/internal/transactions/Transaction2RRDUnit.java +++ b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/internal/transactions/Transaction2RRDUnit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/security/SecurityTestUtils.java b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/security/SecurityTestUtils.java index 33cbf79a3..e97efbbd1 100644 --- a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/security/SecurityTestUtils.java +++ b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/security/SecurityTestUtils.java @@ -1250,7 +1250,7 @@ public static Properties startLdapServerAndGetBootProperties( int locatorPort, int mcastPort, String sysUser, String ldifFilePath) throws Exception { return startLdapServerAndGetBootProperties(locatorPort, mcastPort, - sysUser, null, false); + sysUser, ldifFilePath, false); } public static Properties startLdapServerAndGetBootProperties( diff --git a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/transactions/SnapshotTxGIIDUnit.java b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/transactions/SnapshotTxGIIDUnit.java index f18383a71..98623fd50 100644 --- a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/transactions/SnapshotTxGIIDUnit.java +++ b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/transactions/SnapshotTxGIIDUnit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/transactions/TransactionDUnit.java b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/transactions/TransactionDUnit.java index 31937cea3..9c5d4654a 100644 --- a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/transactions/TransactionDUnit.java +++ b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/transactions/TransactionDUnit.java @@ -52,10 +52,12 @@ import com.pivotal.gemfirexd.internal.engine.GemFireXDQueryObserverAdapter; import com.pivotal.gemfirexd.internal.engine.GemFireXDQueryObserverHolder; import com.pivotal.gemfirexd.internal.engine.Misc; +import com.pivotal.gemfirexd.internal.engine.access.index.GfxdIndexManager; import com.pivotal.gemfirexd.internal.engine.distributed.GfxdConnectionHolder; import com.pivotal.gemfirexd.internal.engine.distributed.GfxdConnectionWrapper; import com.pivotal.gemfirexd.internal.engine.distributed.utils.GemFireXDUtils; import com.pivotal.gemfirexd.internal.engine.store.GemFireContainer; +import com.pivotal.gemfirexd.internal.engine.store.ServerGroupUtils; import com.pivotal.gemfirexd.internal.iapi.error.StandardException; import com.pivotal.gemfirexd.internal.impl.jdbc.EmbedConnection; import com.pivotal.gemfirexd.internal.impl.jdbc.EmbedPreparedStatement; diff --git a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/transactions/TransactionUniqIndexesMixDUnit.java b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/transactions/TransactionUniqIndexesMixDUnit.java new file mode 100644 index 000000000..d9c306cd1 --- /dev/null +++ b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/transactions/TransactionUniqIndexesMixDUnit.java @@ -0,0 +1,544 @@ +package com.pivotal.gemfirexd.transactions; + +import com.gemstone.gemfire.cache.Region; +import com.gemstone.gemfire.internal.cache.DistributedRegion; +import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; +import com.gemstone.gemfire.internal.cache.TXManagerImpl; +import com.gemstone.gemfire.internal.cache.TXStateProxy; +import com.pivotal.gemfirexd.DistributedSQLTestBase; +import com.pivotal.gemfirexd.TestUtil; +import com.pivotal.gemfirexd.internal.engine.GemFireXDQueryObserverHolder; +import com.pivotal.gemfirexd.internal.engine.Misc; +import com.pivotal.gemfirexd.internal.engine.access.index.GfxdIndexManager; +import com.pivotal.gemfirexd.internal.engine.distributed.utils.GemFireXDUtils; +import com.pivotal.gemfirexd.internal.engine.store.ServerGroupUtils; +import io.snappydata.test.dunit.SerializableRunnable; +import io.snappydata.test.dunit.VM; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.List; + +public class TransactionUniqIndexesMixDUnit extends DistributedSQLTestBase { + public TransactionUniqIndexesMixDUnit(String name) { + super(name); + } + + protected String reduceLogging() { + return "fine"; + } + + protected int getIsolationLevel() { + return Connection.TRANSACTION_READ_COMMITTED; + } + + private void createDDLs() throws Exception { + java.sql.Connection conn = TestUtil.jdbcConn; + conn.setAutoCommit(false); + Statement st = conn.createStatement(); + st.execute("Create table app.t1 (c1 int not null , c2 int not null," + + " c3 int not null , c4 int not null, " + + "primary key(c4)) replicate"); + st.execute("create index localindex on app.t1(c3)"); + st.execute("create unique index uniqindex on app.t1(c1)"); + } + // In all test create a normal index and a uniq index + // Test Case 1: + // Insert a row + // + // + public void KN_testTransactionalInsertDeleteOnReplicatedTable_1() throws Exception { + createDDLs(); + java.sql.Connection conn = TestUtil.jdbcConn; + conn.commit(); + conn.setTransactionIsolation(getIsolationLevel()); + ResultSet rs = null; + Statement st = conn.createStatement(); + + st.execute("insert into app.t1 values (10, 10, 10, 10)"); + conn.commit(); + + // craete another connection + Connection conn2 = TestUtil.getConnection(); + conn2.setTransactionIsolation(getIsolationLevel()); + Statement st2 = conn2.createStatement(); + // st.execute("insert into app.t1 values (10, 10, 10, 10)"); + st.execute("delete from app.t1 where c4 = 10"); + // Insert on another connection should fail + try { + st2.execute("insert into app.t1 values (10, 10, 10, 10)"); + fail("above should have failed with unique key violation exception"); + } catch (SQLException sqle) { + assertTrue("23505".equalsIgnoreCase(sqle.getSQLState())); + } + // Since an insert is being done after a delete on transaction one + // this should pass + st.execute("insert into app.t1 values (10, 10, 10, 10)"); + + conn.commit(); + invokeInEveryVM(new SerializableRunnable() { + @Override + public void run() { + if (GemFireCacheImpl.getInstance() != null && + ServerGroupUtils.isDataStore()) { + String regionPath = "/APP/T1"; + Region r = Misc.getRegionByPath(regionPath); + DistributedRegion dr = (DistributedRegion) r; + dr.getLogWriterI18n().fine("KN: AFTER FINAL COMMIT"); + //pr.dumpAllBuckets(false, Misc.getI18NLogWriter()); + GfxdIndexManager idxmgr = (GfxdIndexManager)dr.getIndexUpdater(); + idxmgr.dumpAllIndexes(); + } + } + }); + conn.close(); + } + + public void KN_testTransactionalInsertDeleteOnReplicatedTable() throws Exception { + java.sql.Connection conn = TestUtil.jdbcConn; + conn.setAutoCommit(false); + Statement st = conn.createStatement(); + st.execute("Create table app.t1 (c1 int not null , c2 int not null," + + " c3 int not null , c4 int not null, " + + "primary key(c4)) replicate"); + st.execute("create index localindex on app.t1(c3)"); + st.execute("create unique index uniqindex on app.t1(c1)"); + conn.commit(); + conn.setTransactionIsolation(getIsolationLevel()); + ResultSet rs = null; + st.execute("insert into app.t1 values (10, 10, 10, 10)"); + st.execute("insert into app.t1 values (20, 20, 20, 20)"); + conn.commit(); + invokeInEveryVM(new SerializableRunnable() { + @Override + public void run() { + if (GemFireCacheImpl.getInstance() != null && + ServerGroupUtils.isDataStore()) { + String regionPath = "/APP/T1"; + Region r = Misc.getRegionByPath(regionPath); + DistributedRegion dr = (DistributedRegion) r; + dr.getLogWriterI18n().fine("KN: AFTER FIRST TWO INSERT"); + //pr.dumpAllBuckets(false, Misc.getI18NLogWriter()); + GfxdIndexManager idxmgr = (GfxdIndexManager)dr.getIndexUpdater(); + idxmgr.dumpAllIndexes(); + } + } + }); + st.execute("select * from app.t1"); + st.execute("delete from app.t1 where c4 = 10"); + st.execute("insert into app.t1 values (10, 10, 10, 10)"); + // do few updates again + st.execute("update app.t1 set c3=50 where c4=10"); + invokeInEveryVM(new SerializableRunnable() { + @Override + public void run() { + if (GemFireCacheImpl.getInstance() != null && + ServerGroupUtils.isDataStore()) { + String regionPath = "/APP/T1"; + Region r = Misc.getRegionByPath(regionPath); + DistributedRegion dr = (DistributedRegion) r; + dr.getLogWriterI18n().fine("KN: BEFORE UPDATE -- ROLLBACK"); + //pr.dumpAllBuckets(false, Misc.getI18NLogWriter()); + GfxdIndexManager idxmgr = (GfxdIndexManager)dr.getIndexUpdater(); + idxmgr.dumpAllIndexes(); + } + } + }); + st.execute("update app.t1 set c1=50 where c4=10"); + invokeInEveryVM(new SerializableRunnable() { + @Override + public void run() { + if (GemFireCacheImpl.getInstance() != null && + ServerGroupUtils.isDataStore()) { + String regionPath = "/APP/T1"; + Region r = Misc.getRegionByPath(regionPath); + DistributedRegion dr = (DistributedRegion) r; + dr.getLogWriterI18n().fine("KN: AFTER UPDATE -- ROLLBACK"); + //pr.dumpAllBuckets(false, Misc.getI18NLogWriter()); + GfxdIndexManager idxmgr = (GfxdIndexManager)dr.getIndexUpdater(); + idxmgr.dumpAllIndexes(); + } + } + }); + invokeInEveryVM(new SerializableRunnable() { + @Override + public void run() { + if (GemFireCacheImpl.getInstance() != null && + ServerGroupUtils.isDataStore()) { + String regionPath = "/APP/T1"; + Region r = Misc.getRegionByPath(regionPath); + DistributedRegion dr = (DistributedRegion) r; + dr.getLogWriterI18n().fine("KN: JUST BEFORE ROLLBACK"); + //pr.dumpAllBuckets(false, Misc.getI18NLogWriter()); + GfxdIndexManager idxmgr = (GfxdIndexManager)dr.getIndexUpdater(); + idxmgr.dumpAllIndexes(); + } + } + }); + conn.rollback(); + invokeInEveryVM(new SerializableRunnable() { + @Override + public void run() { + if (GemFireCacheImpl.getInstance() != null && + ServerGroupUtils.isDataStore()) { + String regionPath = "/APP/T1"; + Region r = Misc.getRegionByPath(regionPath); + DistributedRegion dr = (DistributedRegion) r; + dr.getLogWriterI18n().fine("KN: AFTER FIRST ROLLBACK"); + //pr.dumpAllBuckets(false, Misc.getI18NLogWriter()); + GfxdIndexManager idxmgr = (GfxdIndexManager)dr.getIndexUpdater(); + idxmgr.dumpAllIndexes(); + } + } + }); + st.execute("delete from app.t1 where c4 = 10"); + st.execute("insert into app.t1 values (10, 10, 10, 10)"); + conn.commit(); + invokeInEveryVM(new SerializableRunnable() { + @Override + public void run() { + if (GemFireCacheImpl.getInstance() != null && + ServerGroupUtils.isDataStore()) { + String regionPath = "/APP/T1"; + Region r = Misc.getRegionByPath(regionPath); + DistributedRegion dr = (DistributedRegion) r; + dr.getLogWriterI18n().fine("KN: AFTER FINAL COMMIT"); + //pr.dumpAllBuckets(false, Misc.getI18NLogWriter()); + GfxdIndexManager idxmgr = (GfxdIndexManager)dr.getIndexUpdater(); + idxmgr.dumpAllIndexes(); + } + } + }); + rs = st.executeQuery("select count(*) from app.t1"); + assertTrue(rs.next()); + assertEquals(rs.getInt(1), 2); + assertFalse(rs.next()); + conn.commit(); + conn.close(); + } + + public void KN_testTransactionalScanWhenUpdateOnNonUniqueIndexedColumn() throws Exception { + java.sql.Connection conn = TestUtil.jdbcConn; + conn.setAutoCommit(false); + Statement st = conn.createStatement(); + st.execute("Create table app.t1 (c1 int not null , c2 int not null," + + " c3 int not null , c4 int not null, " + + "primary key(c4)) replicate"); + st.execute("create index localindex on app.t1(c3)"); + st.execute("create unique index uniqindex on app.t1(c1)"); + conn.commit(); + conn.setTransactionIsolation(getIsolationLevel()); + ResultSet rs = null; + st.execute("insert into app.t1 values (10, 10, 10, 10)"); + st.execute("insert into app.t1 values (20, 20, 20, 20)"); + conn.commit(); + st.execute("update app.t1 set c3=50 where c4=10"); + st.execute("select c3 from app.t1 --GEMFIREXD-PROPERTIES index=uniqindex\n where c1 = 10"); + rs = st.getResultSet(); + assertTrue(rs.next()); + assertEquals(rs.getInt(1), 50); + conn.commit(); + st.execute("select c3 from app.t1 where c1 = 10"); + rs = st.getResultSet(); + assertTrue(rs.next()); + assertEquals(rs.getInt(1), 50); + conn.commit(); + conn.close(); + } + + public void KN_testOtherTxnalScanWhenDelAndInsertOnUniqueIndexedColumnByOtherTxn() throws Exception { + java.sql.Connection conn = TestUtil.jdbcConn; + conn.setAutoCommit(false); + Statement st = conn.createStatement(); + st.execute("Create table app.t1 (c1 int not null , c2 int not null," + + " c3 int not null , c4 int not null, " + + "primary key(c4)) replicate"); + st.execute("create index localindex on app.t1(c3)"); + st.execute("create unique index uniqindex on app.t1(c1)"); + conn.commit(); + conn.setTransactionIsolation(getIsolationLevel()); + ResultSet rs = null; + st.execute("insert into app.t1 values (10, 10, 10, 10)"); + st.execute("insert into app.t1 values (20, 20, 20, 20)"); + conn.commit(); + invokeInEveryVM(new SerializableRunnable() { + @Override + public void run() { + if (GemFireCacheImpl.getInstance() != null && + ServerGroupUtils.isDataStore()) { + String regionPath = "/APP/T1"; + Region r = Misc.getRegionByPath(regionPath); + DistributedRegion dr = (DistributedRegion) r; + dr.getLogWriterI18n().fine("KN: AFTER FIRST TWO INSERT"); + //pr.dumpAllBuckets(false, Misc.getI18NLogWriter()); + GfxdIndexManager idxmgr = (GfxdIndexManager)dr.getIndexUpdater(); + idxmgr.dumpAllIndexes(); + } + } + }); + st.execute("delete from app.t1 where c4=10"); + st.execute("insert into app.t1 values (10, 70, 70, 70)"); + st.execute("select * from app.t1 --GEMFIREXD-PROPERTIES index=uniqindex\n where c1 = 10"); + rs = st.getResultSet(); + assertTrue(rs.next()); + assertEquals(rs.getInt(1), 10); + assertEquals(rs.getInt(2), 70); + assertEquals(rs.getInt(3), 70); + assertEquals(rs.getInt(4), 70); + invokeInEveryVM(new SerializableRunnable() { + @Override + public void run() { + if (GemFireCacheImpl.getInstance() != null && + ServerGroupUtils.isDataStore()) { + String regionPath = "/APP/T1"; + Region r = Misc.getRegionByPath(regionPath); + DistributedRegion dr = (DistributedRegion) r; + dr.getLogWriterI18n().fine("KN: DELETE INSERT BEFORE COMMIT TX 1"); + //pr.dumpAllBuckets(false, Misc.getI18NLogWriter()); + GfxdIndexManager idxmgr = (GfxdIndexManager)dr.getIndexUpdater(); + idxmgr.dumpAllIndexes(); + } + } + }); + // Take another connection and fire the same query ... that should see the + // committed value + Connection conn2 = TestUtil.getConnection(); + conn2.setTransactionIsolation(getIsolationLevel()); + Statement st2 = conn2.createStatement(); + st2.execute("select * from app.t1 --GEMFIREXD-PROPERTIES index=uniqindex\n where c1 = 10"); + rs = st2.getResultSet(); + assertTrue(rs.next()); + assertEquals(rs.getInt(1), 10); + assertEquals(rs.getInt(2), 10); + assertEquals(rs.getInt(3), 10); + assertEquals(rs.getInt(4), 10); + conn2.commit(); + conn.commit(); + invokeInEveryVM(new SerializableRunnable() { + @Override + public void run() { + if (GemFireCacheImpl.getInstance() != null && + ServerGroupUtils.isDataStore()) { + String regionPath = "/APP/T1"; + Region r = Misc.getRegionByPath(regionPath); + DistributedRegion dr = (DistributedRegion) r; + dr.getLogWriterI18n().fine("KN: AFTER COMMIT TX 1"); + //pr.dumpAllBuckets(false, Misc.getI18NLogWriter()); + GfxdIndexManager idxmgr = (GfxdIndexManager)dr.getIndexUpdater(); + idxmgr.dumpAllIndexes(); + } + } + }); + // Now both the connection should see same committed row corresponding to 70 + st.execute("select * from app.t1 --GEMFIREXD-PROPERTIES index=uniqindex\n where c1 = 10"); + rs = st.getResultSet(); + assertTrue(rs.next()); + assertEquals(rs.getInt(1), 10); + assertEquals(rs.getInt(2), 70); + assertEquals(rs.getInt(3), 70); + assertEquals(rs.getInt(4), 70); + conn.commit(); + st2.execute("select * from app.t1 --GEMFIREXD-PROPERTIES index=uniqindex\n where c1 = 10"); + rs = st2.getResultSet(); + assertTrue(rs.next()); + assertEquals(rs.getInt(1), 10); + assertEquals(rs.getInt(2), 70); + assertEquals(rs.getInt(3), 70); + assertEquals(rs.getInt(4), 70); + conn2.commit(); + conn.close(); + conn2.close(); + } + + public void testOtherTxnalScanWhenDelAndInsertOnUpdateOfUniqueIndexedColumn() throws Exception { + java.sql.Connection conn = TestUtil.jdbcConn; + conn.setAutoCommit(false); + Statement st = conn.createStatement(); + st.execute("Create table app.t1 (c1 int not null , c2 int not null," + + " c3 int not null , c4 int not null, " + + "primary key(c4)) replicate"); + st.execute("create index localindex on app.t1(c3)"); + st.execute("create unique index uniqindex on app.t1(c1)"); + conn.commit(); + conn.setTransactionIsolation(getIsolationLevel()); + ResultSet rs = null; + st.execute("insert into app.t1 values (10, 10, 10, 10)"); + st.execute("insert into app.t1 values (20, 20, 20, 20)"); + conn.commit(); + invokeInEveryVM(new SerializableRunnable() { + @Override + public void run() { + if (GemFireCacheImpl.getInstance() != null && + ServerGroupUtils.isDataStore()) { + String regionPath = "/APP/T1"; + Region r = Misc.getRegionByPath(regionPath); + DistributedRegion dr = (DistributedRegion) r; + dr.getLogWriterI18n().fine("KN: AFTER FIRST TWO INSERT"); + //pr.dumpAllBuckets(false, Misc.getI18NLogWriter()); + GfxdIndexManager idxmgr = (GfxdIndexManager)dr.getIndexUpdater(); + idxmgr.dumpAllIndexes(); + } + } + }); + st.execute("delete from app.t1 where c4=10"); + st.execute("insert into app.t1 values (70, 70, 70, 70)"); + st.execute("select * from app.t1 --GEMFIREXD-PROPERTIES index=uniqindex\n where c1 = 70"); + rs = st.getResultSet(); + assertTrue(rs.next()); + assertEquals(rs.getInt(1), 70); + assertEquals(rs.getInt(2), 70); + assertEquals(rs.getInt(3), 70); + assertEquals(rs.getInt(4), 70); + st.execute("select * from app.t1 --GEMFIREXD-PROPERTIES index=uniqindex\n where c1 = 10"); + rs = st.getResultSet(); + assertFalse(rs.next()); + invokeInEveryVM(new SerializableRunnable() { + @Override + public void run() { + if (GemFireCacheImpl.getInstance() != null && + ServerGroupUtils.isDataStore()) { + String regionPath = "/APP/T1"; + Region r = Misc.getRegionByPath(regionPath); + DistributedRegion dr = (DistributedRegion) r; + dr.getLogWriterI18n().fine("KN: DELETE INSERT BEFORE COMMIT TX 1"); + //pr.dumpAllBuckets(false, Misc.getI18NLogWriter()); + GfxdIndexManager idxmgr = (GfxdIndexManager)dr.getIndexUpdater(); + idxmgr.dumpAllIndexes(); + } + } + }); + // Take another connection and fire the same query ... that should see the + // committed value + Connection conn2 = TestUtil.getConnection(); + conn2.setTransactionIsolation(getIsolationLevel()); + Statement st2 = conn2.createStatement(); + st2.execute("select * from app.t1 --GEMFIREXD-PROPERTIES index=uniqindex\n where c1 = 10"); + rs = st2.getResultSet(); + assertTrue(rs.next()); + assertEquals(rs.getInt(1), 10); + assertEquals(rs.getInt(2), 10); + assertEquals(rs.getInt(3), 10); + assertEquals(rs.getInt(4), 10); + conn2.commit(); + conn.commit(); + // Now both the connection should see same committed row corresponding to 70 + st.execute("select * from app.t1 --GEMFIREXD-PROPERTIES index=uniqindex\n where c1 = 10"); + rs = st.getResultSet(); + assertFalse(rs.next()); + st.execute("select * from app.t1 --GEMFIREXD-PROPERTIES index=uniqindex\n where c1 = 70"); + rs = st.getResultSet(); + assertTrue(rs.next()); + assertEquals(rs.getInt(1), 70); + assertEquals(rs.getInt(2), 70); + assertEquals(rs.getInt(3), 70); + assertEquals(rs.getInt(4), 70); + conn.commit(); + st2.execute("select * from app.t1 --GEMFIREXD-PROPERTIES index=uniqindex\n where c1 = 10"); + rs = st2.getResultSet(); + assertFalse(rs.next()); + st2.execute("select * from app.t1 --GEMFIREXD-PROPERTIES index=uniqindex\n where c1 = 70"); + rs = st2.getResultSet(); + assertTrue(rs.next()); + assertEquals(rs.getInt(1), 70); + assertEquals(rs.getInt(2), 70); + assertEquals(rs.getInt(3), 70); + assertEquals(rs.getInt(4), 70); + conn2.commit(); + conn.close(); + conn2.close(); + invokeInEveryVM(new SerializableRunnable() { + @Override + public void run() { + if (GemFireCacheImpl.getInstance() != null && + ServerGroupUtils.isDataStore()) { + String regionPath = "/APP/T1"; + Region r = Misc.getRegionByPath(regionPath); + DistributedRegion dr = (DistributedRegion) r; + dr.getLogWriterI18n().fine("KN: AFTER COMMIT TX 1"); + //pr.dumpAllBuckets(false, Misc.getI18NLogWriter()); + GfxdIndexManager idxmgr = (GfxdIndexManager)dr.getIndexUpdater(); + idxmgr.dumpAllIndexes(); + } + } + }); + } + // static lists to transfer clientVMs/serverVMs between tests since each test + // creates a new test object + private static List globalClientVMs; + private static List globalServerVMs; + + @Override + public void beforeClass() throws Exception { + globalClientVMs = null; + globalServerVMs = null; + super.beforeClass(); + super.baseShutDownAll(); + deleteAllOplogFiles(); + getLogWriter().info(getClass() + ".beforeClass: starting 1+3 VMs"); + startVMs(1, 3); + getLogWriter().info(getClass() + ".beforeClass: started 1+3 VMs: " + + clientVMs + " ; " + serverVMs); + currentUserName = GemFireXDUtils.getRandomString(true); + } + + @Override + public void setUp() throws Exception { + super.commonSetUp(); + super.baseSetUp(); + if (globalClientVMs != null) { + clientVMs.clear(); + clientVMs.addAll(globalClientVMs); + serverVMs.clear(); + serverVMs.addAll(globalServerVMs); + } + resetObservers(); + invokeInEveryVM(TransactionDUnit.class, "resetObservers"); + String userName = currentUserName; + setupConnection(userName); + invokeInEveryVM(TransactionDUnit.class, "setupConnection", + new Object[]{userName}); + getLogWriter().info(getClass() + "." + getTestName() + ".setUp VMs: " + + clientVMs + " ; " + serverVMs); + } + + public static void setupConnection(String userName) throws SQLException { + resetConnection(); + TestUtil.currentUserName = userName; + TestUtil.currentUserPassword = userName; + if (GemFireCacheImpl.getInstance() != null) { + TestUtil.setupConnection(); + } + } + + @Override + protected void baseShutDownAll() throws Exception { + TestUtil.stopNetServer(); + invokeInEveryVM(TestUtil.class, "stopNetServer"); + globalClientVMs = clientVMs; + globalServerVMs = serverVMs; + } + + @Override + public void afterClass() throws Exception { + globalClientVMs = null; + globalServerVMs = null; + super.baseShutDownAll(); + super.afterClass(); + } + + public static void resetObservers() { + final GemFireCacheImpl cache = GemFireCacheImpl.getInstance(); + if (cache != null) { + TXManagerImpl txMgr = cache.getCacheTransactionManager(); + for (TXStateProxy tx : txMgr.getHostedTransactionsInProgress()) { + tx.setObserver(null); + } + txMgr.setObserver(null); + GemFireXDQueryObserverHolder.clearInstance(); + } + } + + protected static String currentUserName; +} diff --git a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/transactions/TransactionUniqIndexesMixRRDUnit.java b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/transactions/TransactionUniqIndexesMixRRDUnit.java new file mode 100644 index 000000000..fb8c9f0c5 --- /dev/null +++ b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/transactions/TransactionUniqIndexesMixRRDUnit.java @@ -0,0 +1,15 @@ +package com.pivotal.gemfirexd.transactions; + +import java.sql.Connection; + +public class TransactionUniqIndexesMixRRDUnit extends TransactionUniqIndexesMixDUnit { + + public TransactionUniqIndexesMixRRDUnit(String name) { + super(name); + } + + @Override + protected int getIsolationLevel() { + return Connection.TRANSACTION_REPEATABLE_READ; + } +} diff --git a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/wan/GfxdWanTestBase.java b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/wan/GfxdWanTestBase.java index b89ec9c7a..5a83269aa 100644 --- a/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/wan/GfxdWanTestBase.java +++ b/gemfirexd/tools/src/dunit/java/com/pivotal/gemfirexd/wan/GfxdWanTestBase.java @@ -81,7 +81,7 @@ public boolean compareSites(String siteOne, String siteTwo, getLogWriter().info("Comparing site results for query:" + query); - String firstUrl = TestUtil.getNetProtocol("localhost", siteOnePort); + String firstUrl = TestUtil.getNetProtocol("localhost", siteOnePort, false); Properties props = new Properties(); Connection conn = DriverManager.getConnection(firstUrl, props); @@ -89,7 +89,7 @@ public boolean compareSites(String siteOne, String siteTwo, st.execute(query); ResultSet result = st.getResultSet(); - String secondUrl = TestUtil.getNetProtocol("localhost", siteTwoPort); + String secondUrl = TestUtil.getNetProtocol("localhost", siteTwoPort, false); Connection conn2 = DriverManager.getConnection(secondUrl, props); Statement st2 = conn2.createStatement(); st2.execute(query); diff --git a/gemfirexd/tools/src/main/java/com/pivotal/gemfirexd/internal/impl/tools/ij/Main.java b/gemfirexd/tools/src/main/java/com/pivotal/gemfirexd/internal/impl/tools/ij/Main.java index 7904c95cd..7f1fed849 100644 --- a/gemfirexd/tools/src/main/java/com/pivotal/gemfirexd/internal/impl/tools/ij/Main.java +++ b/gemfirexd/tools/src/main/java/com/pivotal/gemfirexd/internal/impl/tools/ij/Main.java @@ -223,14 +223,16 @@ public Object run() { File histFile = new File(historyFileName); if (historyFileName.length() > 0) { final FileHistory hist; + // skip doInit in FileHistory to enable setting max-size before load if (histFile.isAbsolute()) { - hist = new FileHistory(new File(historyFileName)); + hist = new FileHistory(new File(historyFileName), false); } else { hist = new FileHistory(new File((System - .getProperty("user.home")), historyFileName)); + .getProperty("user.home")), historyFileName), false); } - hist.setMaxSize(10000); + hist.setMaxSize(50000); + hist.load(); reader.setHistory(hist); } Runtime.getRuntime().addShutdownHook(new Thread() { @@ -254,16 +256,16 @@ public void run() { "autocommit on;", "autocommit off;", "DISCONNECT", "DISCONNECT CURRENT;", "DISCONNECT ALL;", "disconnect", "disconnect current;", "disconnect all;", - "SHOW SCHEMAS;", "show schemas;", - "SHOW TABLES IN", "show tables in", - "SHOW VIEWS IN", "show views in", + "SHOW SCHEMAS", "show schemas", + "SHOW TABLES", "show tables", + "SHOW VIEWS", "show views", "SHOW PROCEDURES IN", "show procedures in", - "SHOW SYNONYMS IN", "show synonyms in", + "SHOW FUNCTIONS", "show functions", "SHOW INDEXES IN", "SHOW INDEXES FROM", "show indexes in", "show indexes from", "SHOW IMPORTEDKEYS IN", "SHOW IMPORTEDKEYS FROM", "show importedkeys in", "show importedkeys from", - "SHOW MEMBERS", "show members", + "SHOW MEMBERS;", "show members;", "DESCRIBE", "describe", "COMMIT;", "commit;", "ROLLBACK;", "rollback;", "PREPARE", "prepare", "EXECUTE", "execute", "REMOVE", "remove", "RUN", "run", diff --git a/gemfirexd/tools/src/main/java/com/pivotal/gemfirexd/internal/impl/tools/ij/utilMain.java b/gemfirexd/tools/src/main/java/com/pivotal/gemfirexd/internal/impl/tools/ij/utilMain.java index 8a23479d1..9f65ce9b0 100644 --- a/gemfirexd/tools/src/main/java/com/pivotal/gemfirexd/internal/impl/tools/ij/utilMain.java +++ b/gemfirexd/tools/src/main/java/com/pivotal/gemfirexd/internal/impl/tools/ij/utilMain.java @@ -43,6 +43,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more import com.gemstone.gemfire.internal.GemFireVersion; import com.gemstone.gemfire.internal.shared.ClientSharedUtils; +import com.pivotal.gemfirexd.internal.GemFireXDVersion; import com.pivotal.gemfirexd.internal.iapi.services.info.ProductGenusNames; import com.pivotal.gemfirexd.internal.iapi.tools.i18n.*; import com.pivotal.gemfirexd.internal.shared.common.SharedUtils; @@ -1077,7 +1078,9 @@ else if (remaining.length() >= hostsConnect.length() public static String convertGfxdMessageToSnappy(String message) { if (basePrompt.contains("snappy")) { - return pattern.matcher(message).replaceAll("SnappyData"); + GemFireVersion.getInstance(GemFireXDVersion.class, SharedUtils.GFXD_VERSION_PROPERTIES); + String productEditionType = GemFireVersion.isEnterpriseEdition() ? "TIBCO ComputeDB" : "SnappyData"; + return pattern.matcher(message).replaceAll(productEditionType); } else { return message; } diff --git a/gemfirexd/tools/src/main/java/com/pivotal/gemfirexd/internal/tools/JDBCDisplayUtil.java b/gemfirexd/tools/src/main/java/com/pivotal/gemfirexd/internal/tools/JDBCDisplayUtil.java index 650f854f1..f749a485e 100644 --- a/gemfirexd/tools/src/main/java/com/pivotal/gemfirexd/internal/tools/JDBCDisplayUtil.java +++ b/gemfirexd/tools/src/main/java/com/pivotal/gemfirexd/internal/tools/JDBCDisplayUtil.java @@ -185,13 +185,13 @@ static public void ShowWarnings(PrintWriter out, Connection theConnection) { @param rs the ResultSet that may have warnings on it */ static public int /* GemStoneChange void */ ShowWarnings(PrintWriter out, ResultSet rs) { + int result = 0; try { // GET RESULTSET WARNINGS SQLWarning warning = null; if (rs != null) { - return // GemStoneAddition - ShowWarnings(out, rs.getWarnings()); + result = ShowWarnings(out, rs.getWarnings()); } if (rs != null) { @@ -200,7 +200,7 @@ static public void ShowWarnings(PrintWriter out, Connection theConnection) { } catch (SQLException e) { ShowSQLException(out, e); } - return 0; // GemStoneAddition + return result; // GemStoneAddition } // ShowResultSetWarnings /** diff --git a/gemfirexd/tools/src/main/java/com/pivotal/gemfirexd/tools/GfxdDistributionLocator.java b/gemfirexd/tools/src/main/java/com/pivotal/gemfirexd/tools/GfxdDistributionLocator.java index aadf26839..b834e43a0 100644 --- a/gemfirexd/tools/src/main/java/com/pivotal/gemfirexd/tools/GfxdDistributionLocator.java +++ b/gemfirexd/tools/src/main/java/com/pivotal/gemfirexd/tools/GfxdDistributionLocator.java @@ -247,6 +247,14 @@ protected Map getServerOptions(String[] args) throws Exception { if (this.bindAddress == null) { this.bindAddress = FabricLocator.LOCATOR_DEFAULT_BIND_ADDRESS; } + + Properties prop = (Properties) options.get(PROPERTIES); + if (prop.getProperty(DistributionConfig.DISABLE_AUTO_RECONNECT_NAME) == null && + prop.getProperty(DistributionConfig.GEMFIRE_PREFIX + + DistributionConfig.DISABLE_AUTO_RECONNECT_NAME) == null) { + prop.put(DistributionConfig.DISABLE_AUTO_RECONNECT_NAME, "false"); + } + final String locPort = (String)options.get(LOC_PORT_ARG); if (locPort != null) { this.port = Integer.parseInt(locPort); diff --git a/gemfirexd/tools/src/main/java/com/pivotal/gemfirexd/tools/GfxdSystemAdmin.java b/gemfirexd/tools/src/main/java/com/pivotal/gemfirexd/tools/GfxdSystemAdmin.java index 3534e12f1..f7966373d 100644 --- a/gemfirexd/tools/src/main/java/com/pivotal/gemfirexd/tools/GfxdSystemAdmin.java +++ b/gemfirexd/tools/src/main/java/com/pivotal/gemfirexd/tools/GfxdSystemAdmin.java @@ -20,15 +20,7 @@ import java.io.Console; import java.io.File; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; +import java.util.*; import com.gemstone.gemfire.distributed.DistributedMember; import com.gemstone.gemfire.distributed.internal.DM; @@ -195,6 +187,16 @@ public void invoke(String[] args) { this.defaultLogFileName = null; try { super.invoke(args); + // close the cache if present + GemFireCacheImpl cache = GemFireCacheImpl.getInstance(); + if (cache != null) { + cache.close(); + } + // disconnect connection to cluster if present + InternalDistributedSystem ds = InternalDistributedSystem.getConnectedInstance(); + if (ds != null) { + ds.disconnect(); + } } finally { // remove zero-sized log-file if (this.defaultLogFileName != null) { diff --git a/gemfirexd/tools/src/main/javacc/com/pivotal/gemfirexd/internal/impl/tools/ij/ij.jj b/gemfirexd/tools/src/main/javacc/com/pivotal/gemfirexd/internal/impl/tools/ij/ij.jj index c691b2eff..f807bd0cd 100644 --- a/gemfirexd/tools/src/main/javacc/com/pivotal/gemfirexd/internal/impl/tools/ij/ij.jj +++ b/gemfirexd/tools/src/main/javacc/com/pivotal/gemfirexd/internal/impl/tools/ij/ij.jj @@ -1064,11 +1064,16 @@ class ij { Outputs the names of all fields of given table. Outputs field names and data type. */ - public ijResult describeTable(String schema, String table) throws SQLException { + public ijResult describeTable(String schema, String table) throws SQLException, ParseException { ResultSet rs = null; try { haveConnection(); - verifyTableExists(schema,table); + try { + verifyTableExists(schema,table); + } catch (ijException ignored) { + // fallback to full parser with routing for statements like DESCRIBE EXTENDED + throw new ParseException(); + } DatabaseMetaData dbmd = theConnection.getMetaData(); rs = dbmd.getColumns(null,schema,table,null); @@ -1622,7 +1627,7 @@ throws SQLException | r=CloseStatement() | r=CommitStatement() | r=ConnectStatement() -| r=DescTableStatement() +// | r=DescTableStatement() | r=DisconnectStatement() | r=DriverStatement() | r=ElapsedTimeStatement() @@ -2485,13 +2490,13 @@ throws SQLException { return showConnectionsMethod(false); } +/* | (t= | v= | | ) [ schema=identifier() ] { if(t!=null) { -// GemStone changes: Addition of "COLUMN TABLE", "EXTERNAL TABLE" etc below - types = new String[] { "ROW TABLE", "SYSTEM TABLE", "COLUMN TABLE", - "EXTERNAL TABLE", "STREAM TABLE", "SAMPLE TABLE", "TOPK TABLE", "VIRTUAL TABLE" }; +// SnappyData changes: Addition of "VIRTUAL TABLE" below + types = new String[] { "TABLE", "SYSTEM TABLE", "VIRTUAL TABLE" }; } else if(v!=null) types = new String[] { "VIEW" }; @@ -2499,6 +2504,7 @@ throws SQLException types = new String[] { "SYNONYM" }; return showTables(schema, types); } +*/ | [ ( schema=identifier()) | ( tblname=identifier() [ str=identifier() ] ) ] @@ -2536,14 +2542,17 @@ throws SQLException { return showProcedures(schema); } +/* | { return showSchemas(); } +*/ | { return showRoles(); } +/* // GemStone changes BEGIN | @@ -2559,7 +2568,8 @@ throws SQLException return showMembers(); } -// GemStone changes END +// GemStone changes END +*/ } /** diff --git a/gemfirexd/tools/src/test/java/codeAnalysis/decode/CompiledClass.java b/gemfirexd/tools/src/test/java/codeAnalysis/decode/CompiledClass.java index b10c60fe2..064ccc620 100644 --- a/gemfirexd/tools/src/test/java/codeAnalysis/decode/CompiledClass.java +++ b/gemfirexd/tools/src/test/java/codeAnalysis/decode/CompiledClass.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/tools/src/test/java/com/pivotal/gemfirexd/TestUtil.java b/gemfirexd/tools/src/test/java/com/pivotal/gemfirexd/TestUtil.java index c4b8b7bf8..2661cdea4 100644 --- a/gemfirexd/tools/src/test/java/com/pivotal/gemfirexd/TestUtil.java +++ b/gemfirexd/tools/src/test/java/com/pivotal/gemfirexd/TestUtil.java @@ -229,7 +229,7 @@ public static final void reduceLogLevel(String logLevel) { if (Misc.getGemFireCacheNoThrow() != null) { // convert logLevel to slf4j name String level = ClientSharedUtils.convertToLog4LogLevel( - java.util.logging.Level.parse(logLevel.toUpperCase(Locale.ENGLISH))); + logLevel).toString(); GfxdSystemProcedureMessage.SysProcMethod.setLogLevel.processMessage( new Object[]{"", level}, Misc.getMyId()); } @@ -320,6 +320,10 @@ public static String getNetProtocol(String hostName, int port) { return TestConfiguration.getNetProtocol(hostName, port); } + public static String getNetProtocol(String hostName, int port, boolean useThrift) { + return TestConfiguration.getNetProtocol(hostName, port, useThrift); + } + protected Class getTestClass() { Class clazz = getClass(); while (clazz.getDeclaringClass() != null) { diff --git a/gemfirexd/tools/src/test/java/com/pivotal/gemfirexd/internal/engine/store/PRandRRViewTest.java b/gemfirexd/tools/src/test/java/com/pivotal/gemfirexd/internal/engine/store/PRandRRViewTest.java index 6c78ce865..2c4263de6 100644 --- a/gemfirexd/tools/src/test/java/com/pivotal/gemfirexd/internal/engine/store/PRandRRViewTest.java +++ b/gemfirexd/tools/src/test/java/com/pivotal/gemfirexd/internal/engine/store/PRandRRViewTest.java @@ -436,7 +436,13 @@ public void testPartitionedViewIteratorForViewTypesPrimaryOnly() } finally { System.out.println("num rows found=" + cnt); } - assertFalse(itr.hasNext()); + while (itr.hasNext()) { + RowLocation rl = (RowLocation)itr.next(); + // locked entries appear as rows with removed token so skip those + if (!rl.getRegionEntry().isRemoved()) { + fail("Unexpected entry in iteration: " + rl); + } + } assertTrue(committedKeys.isEmpty()); // Test tx only data diff --git a/gemfirexd/tools/src/test/java/com/pivotal/gemfirexd/jdbc/BugsTest.java b/gemfirexd/tools/src/test/java/com/pivotal/gemfirexd/jdbc/BugsTest.java index 5448c1b2c..46fda89ee 100644 --- a/gemfirexd/tools/src/test/java/com/pivotal/gemfirexd/jdbc/BugsTest.java +++ b/gemfirexd/tools/src/test/java/com/pivotal/gemfirexd/jdbc/BugsTest.java @@ -32,6 +32,7 @@ import java.util.List; import java.util.Properties; import java.util.StringTokenizer; +import java.util.concurrent.CyclicBarrier; import com.gemstone.gemfire.cache.persistence.PartitionOfflineException; import com.gemstone.gemfire.distributed.internal.DistributionConfig; @@ -448,10 +449,10 @@ public void testOplogPreBlow() throws Exception { hasExportDir = true; remDirName = exportDir + "/preBlow-" + currTime; } else { - exportDir = "/export/shared/users/" + userName; - exportFile = new File(exportDir); - if (exportFile.mkdirs() || - (exportFile.exists() && exportFile.isDirectory())) { + exportDir = "/export/shared/users"; + exportFile = new File(exportDir + "/" + userName); + if (new File(exportDir).exists() && (exportFile.mkdirs() || + (exportFile.exists() && exportFile.isDirectory()))) { hasExportDir = true; remDirName = exportDir + "/preBlow-" + currTime; } else { @@ -1690,4 +1691,61 @@ public void testBugSNAP2627() throws Exception { sm.put(ccik, are); st.execute("insert into t1 values (202, 'a0', 'lse')"); } + + public void testBugSNAP2640ConcurrentCreateDelete() throws Exception { + final int numOps = 10000; + boolean[] anyFailure = new boolean[] { false }; + final int numKeysToOperate = 10; + final int numThreads = 30; + final CyclicBarrier barrier = new CyclicBarrier(numThreads); + Connection conn = getConnection(); + Statement st = conn.createStatement(); + st.execute("create table t1 (col1 int, col2 int not null unique) replicate"); + Runnable task = new Runnable() { + @Override + public void run() { + try { + Connection conn1 = getConnection(); + PreparedStatement insert = conn1.prepareStatement("insert into t1 values(?,?)"); + PreparedStatement delete = conn1.prepareStatement("delete from t1 where col1 = ?"); + barrier.await(); + for (int i = 0; i < numOps; ++i) { + try { + insert.setInt(1, i % numKeysToOperate); + insert.setInt(2, i % numKeysToOperate); + insert.executeUpdate(); + } catch (SQLException sqle) { + if (sqle.toString().toLowerCase().indexOf("violation") != -1 + && sqle.toString().toLowerCase().indexOf("constraint") != -1) { + // ok + } + } + + delete.setInt(1, i % numKeysToOperate); + delete.executeUpdate(); + } + conn1.close(); + } catch (Exception sqle) { + sqle.printStackTrace(); + fail("test failed due to exception = " + sqle); + anyFailure[0] = true; + } + } + }; + + Thread[] threads = new Thread[numThreads]; + for (int i = 0; i < numThreads; ++i) { + threads[i] = new Thread(task); + } + + for (Thread th : threads) { + th.start(); + } + + for (Thread th : threads) { + th.join(); + } + conn.close(); + assertFalse(anyFailure[0]); + } } diff --git a/gemfirexd/tools/src/test/java/com/pivotal/gemfirexd/jdbc/SingleHopTest.java b/gemfirexd/tools/src/test/java/com/pivotal/gemfirexd/jdbc/SingleHopTest.java index c1880a25d..3a2ebd1ba 100644 --- a/gemfirexd/tools/src/test/java/com/pivotal/gemfirexd/jdbc/SingleHopTest.java +++ b/gemfirexd/tools/src/test/java/com/pivotal/gemfirexd/jdbc/SingleHopTest.java @@ -72,7 +72,7 @@ public void afterSingleRowInsert(Object routingObj) { } public void test0MaxConnectionsAndSetSchema() throws Exception { - System.setProperty("gemfirexd.client.single-hop-max-connections", "100"); + System.setProperty("snappydata.client.single-hop-max-connections", "100"); com.pivotal.gemfirexd.internal.client.am.Connection.initialize(); Properties props1 = new Properties(); int mport = AvailablePort.getRandomAvailablePort(AvailablePort.JGROUPS); @@ -95,7 +95,7 @@ public void test0MaxConnectionsAndSetSchema() throws Exception { ResultSet rs = ps.getResultSet(); rs.next(); assertEquals(2, rs.getInt(2)); - System.clearProperty("gemfirexd.client.single-hop-max-connections"); + System.clearProperty("snappydata.client.single-hop-max-connections"); com.pivotal.gemfirexd.internal.client.am.Connection.initialize(); } @@ -119,7 +119,7 @@ public void testexcnIdDebug() throws Exception { ResultSet rs = ps.getResultSet(); rs.next(); assertEquals(2, rs.getInt(2)); - System.clearProperty("gemfirexd.client.single-hop-max-connections"); + System.clearProperty("snappydata.client.single-hop-max-connections"); s.execute("select * from example"); s.execute("update example set c1 = 100 where c2 = 200"); diff --git a/gemfirexd/tools/src/test/java/com/pivotal/gemfirexd/jdbc/transactions/snapshot/SnapshotTransactionTest.java b/gemfirexd/tools/src/test/java/com/pivotal/gemfirexd/jdbc/transactions/snapshot/SnapshotTransactionTest.java index 3eaa352f0..c5c078c40 100644 --- a/gemfirexd/tools/src/test/java/com/pivotal/gemfirexd/jdbc/transactions/snapshot/SnapshotTransactionTest.java +++ b/gemfirexd/tools/src/test/java/com/pivotal/gemfirexd/jdbc/transactions/snapshot/SnapshotTransactionTest.java @@ -5,21 +5,19 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.Map; +import java.util.Set; +import java.util.concurrent.BlockingQueue; -import com.gemstone.gemfire.cache.AttributesFactory; -import com.gemstone.gemfire.cache.Cache; -import com.gemstone.gemfire.cache.ConflictException; -import com.gemstone.gemfire.cache.IsolationLevel; -import com.gemstone.gemfire.cache.PartitionAttributes; -import com.gemstone.gemfire.cache.PartitionAttributesFactory; -import com.gemstone.gemfire.cache.Region; +import com.gemstone.gemfire.cache.*; import com.gemstone.gemfire.internal.cache.*; import com.gemstone.gemfire.internal.cache.persistence.DiskStoreID; import com.gemstone.gemfire.internal.cache.versions.DiskRegionVersionVector; import com.gemstone.gemfire.internal.cache.versions.RegionVersionHolder; import com.gemstone.gemfire.internal.cache.versions.VersionSource; +import com.gemstone.gemfire.internal.i18n.LocalizedStrings; import com.pivotal.gemfirexd.TestUtil; import com.pivotal.gemfirexd.internal.engine.Misc; import com.pivotal.gemfirexd.internal.iapi.types.SQLInteger; @@ -34,6 +32,8 @@ public class SnapshotTransactionTest extends JdbcTestBase { private volatile Throwable threadEx; + private volatile boolean started = false; + public SnapshotTransactionTest(String name) { super(name); } @@ -82,7 +82,7 @@ public void testRVVSnapshotContains() throws Exception { System.out.println("rvv " + rvv.fullToString()); - System.out.println("SKSK Contains " + rvv.contains(id1, 758)); + System.out.println("RVV Contains " + rvv.contains(id1, 758)); rvv.recordVersion(id1, 760); @@ -92,8 +92,7 @@ public void testRVVSnapshotContains() throws Exception { System.out.println("rvv " + rvv.fullToString()); - System.out.println("SKSK Contains " + rvv.contains(id1, 758)); - + System.out.println("RVV Contains " + rvv.contains(id1, 758)); } // Currently autcommit is disabled @@ -303,6 +302,87 @@ public void _testAutoCommitWithIndex() throws Exception { conn.close(); } + public void testSnapshotBulkInsertTableAtomicity() throws Exception { + + Connection conn = getConnection(); + + PartitionAttributesFactory paf = new PartitionAttributesFactory(); + PartitionAttributes prAttr = paf.setTotalNumBuckets(1).create(); + AttributesFactory attr = new AttributesFactory(); + attr.setConcurrencyChecksEnabled(true); + attr.setPartitionAttributes(prAttr); + final Region r = GemFireCacheImpl.getInstance().createRegion("t1", attr.create()); + + final int NUMITR = 100; + + Map map = new HashMap(); + for (int i = 0; i < 500; i++) { + map.put(i, 0); + } + r.getCache().getCacheTransactionManager().begin(IsolationLevel.SNAPSHOT, null); + r.putAll(map); + r.getCache().getCacheTransactionManager().commit(); + + + Object lock = new Object(); + boolean[] signal = { true }; + + Runnable run = new Runnable() { + @Override + public void run() { + for (int k = 0; k < NUMITR; k++) { + Map map = new HashMap(); + for (int i = 0; i < 500; i++) { + map.put(i, k); + } + r.getCache().getCacheTransactionManager().begin(IsolationLevel.SNAPSHOT, null); + r.putAll(map); + r.getCache().getCacheTransactionManager().commit(); + } + synchronized (lock) { + signal[0] = false; + } + } + }; + Thread t = new Thread(run); + t.start(); + + + while (signal[0]) { + synchronized (lock) { + if (signal[0]) { + r.getCache().getCacheTransactionManager().begin(IsolationLevel.SNAPSHOT, null); + TXStateInterface txstate = TXManagerImpl.getCurrentTXState(); + Iterator txitr = txstate.getLocalEntriesIterator(null, + false, false, true, (LocalRegion)r); + + int num = 0; + Set s = new HashSet(); + while (txitr.hasNext()) { + RegionEntry re = (RegionEntry)txitr.next(); + if (!re.isTombstone()) { + //Thread.sleep(10); + s.add(re.getValueInVM(null)); + num++; + } else { + Misc.getGemFireCache().getLoggerI18n().info(LocalizedStrings.DEBUG, "the tombstone is " + re); + } + } + // System.out.println("The num is " + num + " and s is " + s); + assert (num == 500); + if (s.size() > 1) { + fail("FAIL The s is " + s); + } + r.getCache().getCacheTransactionManager().commit(); + } + } + Thread.sleep(5); + } + + t.join(); + + } + public void testSnapshotInsertTableAPI() throws Exception { Connection conn = getConnection(); @@ -378,7 +458,6 @@ public void run() { r.getCache().getCacheTransactionManager().commit(); } - public void testSnapshotInsertAPI() throws Exception { Connection conn = getConnection(); @@ -607,6 +686,194 @@ public void run() { r.getCache().getCacheTransactionManager().commit(); } + public void testTwoSnapshotInsertSameKey() throws Exception { + Connection conn = getConnection(); + PartitionAttributesFactory paf = new PartitionAttributesFactory(); + PartitionAttributes prAttr = paf.setTotalNumBuckets(1).create(); + AttributesFactory attr = new AttributesFactory(); + attr.setConcurrencyChecksEnabled(true); + attr.setPartitionAttributes(prAttr); + + final Region r1 = GemFireCacheImpl.getInstance().createRegion("t1", attr.create()); + + r1.getCache().getCacheTransactionManager().begin(IsolationLevel.SNAPSHOT, null); + r1.put(1, 1); + r1.put(2, 2); + r1.getCache().getCacheTransactionManager().commit(); + + final Object sync1 = new Object(); + Runnable run1 = new Runnable() { + @Override + public void run() { + try { + r1.getCache().getCacheTransactionManager().begin(IsolationLevel.SNAPSHOT, null); + assertEquals(r1.get(1), 1); + assertEquals(r1.get(2), 2); + synchronized (sync1) { + started = true; + try { + sync1.wait(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + assertEquals(r1.get(1), 1); + assertEquals(r1.get(2), 2); + r1.getCache().getCacheTransactionManager().commit(); + } + catch(Exception ex) { + threadEx = ex; + } + } + }; + + Thread t1 = new Thread(run1); + t1.start(); + + while (!started) { + Thread.sleep(10); + } + started = false; + r1.getCache().getCacheTransactionManager().begin(IsolationLevel.SNAPSHOT, null); + r1.put(1, 11); + r1.put(2, 22); + r1.getCache().getCacheTransactionManager().commit(); + + final Object sync2 = new Object(); + Runnable run2 = new Runnable() { + @Override + public void run() { + try { + r1.getCache().getCacheTransactionManager().begin(IsolationLevel.SNAPSHOT, null); + assertEquals(r1.get(1), 11); + assertEquals(r1.get(2), 22); + synchronized (sync2) { + try { + started = true; + sync2.wait(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + assertEquals(r1.get(1), 11); + assertEquals(r1.get(2), 22); + r1.getCache().getCacheTransactionManager().commit(); + } catch (Exception ex) { + threadEx = ex; + } + } + }; + + Thread t2 = new Thread(run2); + t2.start(); + while (!started) { + Thread.sleep(10); + } + started = false; + + GemFireCacheImpl.getInstance().runOldEntriesCleanerThread(); + //verify old entrymap + Map> entryMap = GemFireCacheImpl.getInstance(). + getOldEntriesForRegion("/__PR/_B__t1_0"); + if (entryMap != null) { + for (Map.Entry e : entryMap.entrySet()) { + System.out.println("Key in oldEntriesMap: " + e.getKey()); + System.out.println("Queue in oldEntriesMap " + e.getValue()); + } + } + + // commit one + // verify old entry map + // first one should be removed + + synchronized (sync1) { + sync1.notifyAll(); + } + t1.join(); + GemFireCacheImpl.getInstance().runOldEntriesCleanerThread(); + + entryMap = GemFireCacheImpl.getInstance(). + getOldEntriesForRegion("/__PR/_B__t1_0"); + if (entryMap != null) { + for (Map.Entry e : entryMap.entrySet()) { + System.out.println("Key after first commit " + e.getKey()); + System.out.println("Queue after first commit " + e.getValue()); + } + } + + r1.getCache().getCacheTransactionManager().begin(IsolationLevel.SNAPSHOT, null); + r1.put(1, 111); + r1.put(2, 222); + r1.getCache().getCacheTransactionManager().commit(); + + + final Object sync3 = new Object(); + Runnable run3 = new Runnable() { + @Override + public void run() { + try { + r1.getCache().getCacheTransactionManager().begin(IsolationLevel.SNAPSHOT, null); + assertEquals(r1.get(1), 111); + assertEquals(r1.get(2), 222); + synchronized (sync3) { + try { + started = true; + sync3.wait(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + assertEquals(r1.get(1), 111); + assertEquals(r1.get(2), 222); + r1.getCache().getCacheTransactionManager().commit(); + } catch (Exception ex) { + threadEx = ex; + } + } + }; + + Thread t3 = new Thread(run3); + t3.start(); + + while (!started) { + Thread.sleep(10); + } + synchronized (sync3) { + sync3.notifyAll(); + } + t3.join(); + + + GemFireCacheImpl.getInstance().runOldEntriesCleanerThread(); + + entryMap = GemFireCacheImpl.getInstance(). + getOldEntriesForRegion("/__PR/_B__t1_0"); + if (entryMap != null) { + for (Map.Entry e : entryMap.entrySet()) { + System.out.println("Key after third commit " + e.getKey()); + System.out.println("Queue after third commit " + e.getValue()); + } + } + + synchronized (sync2) { + sync2.notifyAll(); + } + t2.join(); + if (threadEx != null) { + fail("Got exception in thread", threadEx); + } + GemFireCacheImpl.getInstance().runOldEntriesCleanerThread(); + + entryMap = GemFireCacheImpl.getInstance(). + getOldEntriesForRegion("/__PR/_B__t1_0"); + if(entryMap != null) { + for (Map.Entry e : entryMap.entrySet()) { + System.out.println("Key after second commit " + e.getKey()); + System.out.println("Queue after second commit " + e.getValue()); + } + } + } + public void testTwoSnapshotInsertAPI() throws Exception { Connection conn = getConnection(); diff --git a/gemfirexd/tools/src/test/java/com/pivotal/gemfirexd/security/LdapGroupAuthTest.java b/gemfirexd/tools/src/test/java/com/pivotal/gemfirexd/security/LdapGroupAuthTest.java index c5e969f7d..174c2f34b 100644 --- a/gemfirexd/tools/src/test/java/com/pivotal/gemfirexd/security/LdapGroupAuthTest.java +++ b/gemfirexd/tools/src/test/java/com/pivotal/gemfirexd/security/LdapGroupAuthTest.java @@ -140,7 +140,11 @@ public void ldapGroupMembers() throws Exception { * Basic test for the internal method that retrieves LDAP group members as * also recursive group retrieval for Active Directory kind of config. * The loaded sample is "authAD.ldif" similar to "auth.ldif" but using - * "sAMAccountName" instead of "uid". + * "givenName" instead of "uid". This does not use "sAMAccountName" like + * in MS AD since that is not supported in the default schemas in Apache DS + * but that difference will not matter in what is being tested here namely + * custom user search filter. This also has an entry for escape characters (a comma) + * in gemfire11 and corresponding group definition have the user in gemGroup8. */ @Test public void ldapADGroupMembers() throws Exception { @@ -153,20 +157,22 @@ public void ldapADGroupMembers() throws Exception { "(&(objectClass=inetOrgPerson)(givenName=%USERNAME%))"); TestUtil.setupConnection(bootProperties, LdapGroupAuthTest.class); - Set expectedGroup1Members = new HashSet( - Arrays.asList(new String[] { "GEMFIRE1", "GEMFIRE2", "GEMFIRE3" })); - Set expectedGroup2Members = new HashSet( - Arrays.asList(new String[] { "GEMFIRE3", "GEMFIRE4", "GEMFIRE5" })); - Set expectedGroup3Members = new HashSet( - Arrays.asList(new String[] { "GEMFIRE6", "GEMFIRE7", "GEMFIRE8" })); - Set expectedGroup4Members = new HashSet( - Arrays.asList(new String[] { "GEMFIRE1", "GEMFIRE3", "GEMFIRE9" })); - Set expectedGroup5Members = new HashSet(Arrays.asList( - new String[] { "GEMFIRE4", "GEMFIRE6", "GEMFIRE7", "GEMFIRE8" })); - Set expectedGroup6Members = new HashSet( - Arrays.asList(new String[] { "GEMFIRE2", "GEMFIRE6", "GEMFIRE1", - "GEMFIRE3", "GEMFIRE9" })); + Set expectedGroup1Members = new HashSet<>( + Arrays.asList("GEMFIRE1", "GEMFIRE2", "GEMFIRE3")); + Set expectedGroup2Members = new HashSet<>( + Arrays.asList("GEMFIRE3", "GEMFIRE4", "GEMFIRE5")); + Set expectedGroup3Members = new HashSet<>( + Arrays.asList("GEMFIRE6", "GEMFIRE7", "GEMFIRE8")); + Set expectedGroup4Members = new HashSet<>( + Arrays.asList("GEMFIRE1", "GEMFIRE3", "GEMFIRE9")); + Set expectedGroup5Members = new HashSet<>(Arrays.asList( + "GEMFIRE4", "GEMFIRE6", "GEMFIRE7", "GEMFIRE8")); + Set expectedGroup6Members = new HashSet<>( + Arrays.asList("GEMFIRE2", "GEMFIRE6", "GEMFIRE1", + "GEMFIRE3", "GEMFIRE9")); Set expectedGroup7Members = Collections.emptySet(); + Set expectedGroup8Members = new HashSet<>( + Arrays.asList("GEMFIRE6", "GEMFIRE11")); Set group1Members = getLdapGroupMembers("gemGroup1"); Assert.assertEquals(expectedGroup1Members, group1Members); @@ -182,6 +188,8 @@ public void ldapADGroupMembers() throws Exception { Assert.assertEquals(expectedGroup6Members, group6Members); Set group7Members = getLdapGroupMembers("gemgroup7"); Assert.assertEquals(expectedGroup7Members, group7Members); + Set group8Members = getLdapGroupMembers("gemgroup8"); + Assert.assertEquals(expectedGroup8Members, group8Members); classTearDown(); startServer(); diff --git a/gemfirexd/tools/src/test/java/io/snappydata/app/TestThrift.java b/gemfirexd/tools/src/test/java/io/snappydata/app/TestThrift.java index a31c60571..bc1094c36 100644 --- a/gemfirexd/tools/src/test/java/io/snappydata/app/TestThrift.java +++ b/gemfirexd/tools/src/test/java/io/snappydata/app/TestThrift.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/tools/src/test/java/org/apache/derbyTesting/junit/TestConfiguration.java b/gemfirexd/tools/src/test/java/org/apache/derbyTesting/junit/TestConfiguration.java index d63ed2989..64dd6d9a8 100644 --- a/gemfirexd/tools/src/test/java/org/apache/derbyTesting/junit/TestConfiguration.java +++ b/gemfirexd/tools/src/test/java/org/apache/derbyTesting/junit/TestConfiguration.java @@ -32,6 +32,7 @@ import java.util.Hashtable; import java.util.Properties; +import com.gemstone.gemfire.internal.shared.ClientSharedUtils; import com.pivotal.gemfirexd.TestUtil; import com.pivotal.gemfirexd.internal.drda.NetworkServerControl; import junit.extensions.TestSetup; @@ -1174,6 +1175,7 @@ private String createJDBCUrlWithDatabaseName(String name) { .getBoolean(USE_ODBC_BRIDGE_PROP); private static final String netProtocol = "jdbc:gemfirexd://"; + private static final String thriftProtocol = "jdbc:snappydata://"; // assumes ODBC datasource named gemfirexd private static final String odbcProtocol = "jdbc:odbc:gemfirexd"; @@ -1181,6 +1183,10 @@ private String createJDBCUrlWithDatabaseName(String name) { "/odbc/odbc.ini"); public static String getNetProtocol(String hostName, int port) { + return getNetProtocol(hostName, port, ClientSharedUtils.isThriftDefault()); + } + + public static String getNetProtocol(String hostName, int port, boolean useThrift) { if (USE_ODBC_BRIDGE) { // create an odbc.ini with the host/port, if required if (!odbcIni.exists()) { @@ -1202,11 +1208,12 @@ public static String getNetProtocol(String hostName, int port) { return odbcProtocol; } else { - return netProtocol + hostName + '[' + port + "]/"; + return (useThrift ? thriftProtocol : netProtocol) + + hostName + '[' + port + "]/"; } } // GemStone changes END - + /** * Initialize the connection factory. * Defaults to the DriverManager implementation diff --git a/gemfirexd/tools/src/test/java/sql/TestFunctions.java b/gemfirexd/tools/src/test/java/sql/TestFunctions.java index a817d3dcb..5d7de0b9b 100644 --- a/gemfirexd/tools/src/test/java/sql/TestFunctions.java +++ b/gemfirexd/tools/src/test/java/sql/TestFunctions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gemfirexd/tools/src/test/resources/codeAnalysis/sanctionedDataSerializables.txt b/gemfirexd/tools/src/test/resources/codeAnalysis/sanctionedDataSerializables.txt index 3acd541f3..1d1ea837a 100644 --- a/gemfirexd/tools/src/test/resources/codeAnalysis/sanctionedDataSerializables.txt +++ b/gemfirexd/tools/src/test/resources/codeAnalysis/sanctionedDataSerializables.txt @@ -2337,8 +2337,8 @@ fromData,53,2a2bb700112bb9001201003d1c047e99000c2a2bb8001388b500031c057e9900112a toData,71,2a2bb7000d2ab40006412ab4000710bf7e360420140004949900091504058036042b1504b9000e02002ab6000899000c2ab40003852bb8000f20140004949900082b20b80010b1 com/pivotal/gemfirexd/internal/engine/distributed/GfxdDistributionAdvisor$GfxdProfile,2 -fromData,166,2a2bb700492a2bb9004a0100b8004bb500012bb8004c3d1c02a0000b2a01b50012a700262abb004d59b7004eb500121c8402ff9e00142ab400122bb8004fb90050020057a7ffeb2a2bb9004a0100b500102a2bb900510100b500032ab40010057e99000b2a2bb8004fb500132ab4001010087e99000d2a2bb900520100b500072ab7000c2ab6001599000b2a2bb8004fb500082abb000d592bb80053b60054b7000eb5000fb1 -toData,227,2a2bb700392b2ab40001b6003ab9003b02002ab40012c7000b022bb8003ca700352ab40012b9003d01002bb8003c2ab40012b9003e01004d2cb9003101009900152cb900320100c0003f4e2d2bb80040a7ffe82bb800414db200422cb600439b000704a70004033eb200442cb600439e000704a700040336042ab4001036051d99000b150510fd7e913605150499000b150510f77e9136052b1505b9003b02002b2ab40003b9004502001d9a000b2ab400132bb8004015049a000d2b2ab40007b9004602002ab6001599000b2ab400082bb800402ab4000fb60017b800472bb80048b1 +fromData,196,2a2bb700492a2bb9004a0100b8004bb500012bb8004c3d1c02a0000b2a01b50012a700262abb004d59b7004eb500121c8402ff9e00142ab400122bb8004fb90050020057a7ffeb2a2bb9004a0100b500102a2bb900510100b500032ab40010057e99000b2a2bb8004fb500132ab4001010087e99000d2a2bb900520100b500072ab7000f2ab6001599000b2a2bb8004fb500082ab4001010107e9900172abb000b592bb900530100b7000cb5000da700152abb000b592bb90052010085b7000cb5000db1 +toData,226,2a2bb7003a2b2ab40001b6003bb9003c02002ab40012c7000b022bb8003da700352ab40012b9003e01002bb8003d2ab40012b9003f01004d2cb9003201009900152cb900330100c000404e2d2bb80041a7ffe82bb800424db200432cb600449b000704a70004033eb200452cb600449e000704a700040336042ab4001036051d99000b150510fd7e913605150499000b150510f77e9136052b1505b9003c02002b2ab40003b9004602001d9a000b2ab400132bb8004115049a000d2b2ab40007b9004702002ab6001599000b2ab400082bb800412b2ab4000db60016b900480300b1 com/pivotal/gemfirexd/internal/engine/distributed/GfxdDumpLocalResultMessage,2 @@ -2356,8 +2356,8 @@ fromData,25,2a2bb80006b500022a2bb80006b500012a2bb80006b50003b1 toData,25,2b2ab40002b800052b2ab40001b800052b2ab40003b80005b1 com/pivotal/gemfirexd/internal/engine/distributed/ReferencedKeyCheckerMessage,2 -fromData,420,2a2bb700e32a2bb800e4b5000b2a2bb800e4b5000e2bb800e53d2a1cb5001e2bb900e601003e1d99012e2a2bb900e60100b500142ab4001499005a2a1cbc0ab5001503360515051ca200152ab4001515052bb800e7884f840501a7ffeb2ab40015beb800e8bc083a0503360615061905bea20014190515062bb900e9010054840601a7ffea2abb0040591905b700eab500162bb800e536042abb0020591504b70021b5000f03360515051504a200311cbd00313a0603360715071ca20012190615072bb800eb53840701a7ffee2ab4000f1906b6003357840501a7ffce2ab400149900a82bb900e60100360515059900642bb900ec010036062a1506b800edb5006f2ab40016b600eeb800e8360703360815081506a2003d2bb900ec010036091507bc083a0a03360b150b1507a20014190a150b2bb900e9010054840b01a7ffeb2ab4006f1509190ab600ef840801a7ffc2a700372bb800e536042abb0020591504b70021b5001d2a01b5000f03360515051504a200152ab4001d2bb800f0b6003357840501a7ffea2a2bb800f1b500112ab400f299000e2a2ab600f3b800f4b500f5b1 -toData,850,2a2bb700f62a01b5006f2ab400f29900202ab400f509949a000e2a1400f75db500f5a700061400f9b800fba7000409412ab4000b2bb800fc2ab4000e2bb800fc2ab40009b600223a042ab4001499000a2ab40015a700081904b600243a051905be2bb800fd2ab4000fc6018f2b04b900fe02002b2ab40014b900fe02002ab400149900592ab400153a061906be360703360815081507a20017190615082e36091509852bb800ff840801a7ffe82ab40016b601003a061906be360703360815081507a20018190615083336092b1509b901010200840801a7ffe72ab4000fb6001f2bb800fd2ab400149900c5bb0040592ab40015beb700413a0603360715072ab4000fb6001fa200721906b6004d2ab4000f1507b6002fc000ae3a082a190819061507b7004e03360915092ab40015bea200422ab4001515092e360a19061509b6006a360b2a150ab7006b360c1908150c323a0d150b99000e190d2bb901020200a7000b190d2bb901030200840901a7ffba840701a7ff882ab4006fc600282b04b900fe02002b2ab4006fb60104b9010502002ab4006f2bba01060000b6010757a7000a2b03b900fe0200a7019003360615062ab4000fb6001fa2003b2ab4000f1506b6002fc000ae3a071907be360803360915091508a2001819071509323a0a190a2bb901020200840901a7ffe7840601a7ffbfa701462b03b900fe0200b200259a00122ab4001499000bbb002659b7006dbf1904b600233a061904b601083a071904b601093a082ab40002b6001f360915092bb800fd03360d150d1509a200fc2ab40002150db6002fc000af3a0a190a2ab400090303b800b13a0b013a0e190bc600b2190a2ab40009b900b40200593a04c600a1190bb600b33a0f190f1230a60031190bc00030c000303a1019041910b600b53a0c190c19102b190719081906b6010a1906b6010b1906b6010ca70062190f12b7a60033190bc000b7c000b703323a1019041910b600b53a0c190c19102b190719081906b6010a1906b6010b1906b6010ca7002b190bc0010d3a0e1904190eb600ba3a0c190c190e2b190719081906b6010a1906b6010b1906b6010ea70008012bb8010f190ec6001a190eb600bea700123a11190ec60008190eb600be1911bf840d01a7ff032b2ab40011b8011020099499000b2a20b800fbb500f5b1 +fromData,425,2a2bb700e32a2bb800e4b5000b2a2bb800e4b5000e2bb800e53d2a1cb5001e2bb900e601003e1d9901332a2bb900e60100b500142ab4001499005a2a1cbc0ab5001503360515051ca200152ab4001515052bb800e7884f840501a7ffeb2ab40015beb800e8bc083a0503360615061905bea20014190515062bb900e9010054840601a7ffea2abb0040591905b700eab500162bb800e536042abb0020591504b70021b5000f03360515051504a200311cbd00313a0603360715071ca20012190615072bb800eb53840701a7ffee2ab4000f1906b6003357840501a7ffce2ab400149900ad2bb900e60100360515059900692bb900ec010036062abb00ed591506b700eeb5006f2ab40016b600efb800e8360703360815081506a2003e2bb900ec010036091507bc083a0a03360b150b1507a20014190a150b2bb900e9010054840b01a7ffeb2ab4006f1509190ab600f057840801a7ffc1a700372bb800e536042abb0020591504b70021b5001d2a01b5000f03360515051504a200152ab4001d2bb800f1b6003357840501a7ffea2a2bb800f2b500112ab400f399000e2a2ab600f4b800f5b500f6b1 +toData,849,2a2bb700f72a01b5006f2ab400f39900202ab400f609949a000e2a1400f85db500f6a700061400fab800fca7000409412ab4000b2bb800fd2ab4000e2bb800fd2ab40009b600223a042ab4001499000a2ab40015a700081904b600243a051905be2bb800fe2ab4000fc6018e2b04b900ff02002b2ab40014b900ff02002ab400149900592ab400153a061906be360703360815081507a20017190615082e36091509852bb80100840801a7ffe82ab40016b601013a061906be360703360815081507a20018190615083336092b1509b901020200840801a7ffe72ab4000fb6001f2bb800fe2ab400149900c4bb0040592ab40015beb700413a0603360715072ab4000fb6001fa200721906b6004d2ab4000f1507b6002fc000ae3a082a190819061507b7004e03360915092ab40015bea200422ab4001515092e360a19061509b6006a360b2a150ab7006b360c1908150c323a0d150b99000e190d2bb901030200a7000b190d2bb901040200840901a7ffba840701a7ff882ab4006fc600272b04b900ff02002b2ab4006fb60105b9010602002ab4006f2bba01070000b60108a7000a2b03b900ff0200a7019003360615062ab4000fb6001fa2003b2ab4000f1506b6002fc000ae3a071907be360803360915091508a2001819071509323a0a190a2bb901030200840901a7ffe7840601a7ffbfa701462b03b900ff0200b200259a00122ab4001499000bbb002659b7006dbf1904b600233a061904b601093a071904b6010a3a082ab40002b6001f360915092bb800fe03360d150d1509a200fc2ab40002150db6002fc000af3a0a190a2ab400090303b800b13a0b013a0e190bc600b2190a2ab40009b900b40200593a04c600a1190bb600b33a0f190f1230a60031190bc00030c000303a1019041910b600b53a0c190c19102b190719081906b6010b1906b6010c1906b6010da70062190f12b7a60033190bc000b7c000b703323a1019041910b600b53a0c190c19102b190719081906b6010b1906b6010c1906b6010da7002b190bc0010e3a0e1904190eb600ba3a0c190c190e2b190719081906b6010b1906b6010c1906b6010fa70008012bb80110190ec6001a190eb600bea700123a11190ec60008190eb600be1911bf840d01a7ff032b2ab40011b8011120099499000b2a20b800fcb500f6b1 com/pivotal/gemfirexd/internal/engine/distributed/ReferencedKeyCheckerMessage$ReferencedKeyReplyMessage,2 fromData,16,2a2bb7001a2a2bb9001b0100b50002b1 @@ -2708,9 +2708,9 @@ fromData,22,2a2bb80006b500022a2bb900070100b80008b50003b1 toData,17,2ab400022bb800042ab400032bb80005b1 com/pivotal/gemfirexd/internal/engine/ui/SnappyRegionStats,4 -fromData,16,2a2bb6001b2a2bb9001c0100b50008b1 +fromData,26,2a2bb6001d2a2bb9001e0100b500092a2bb9001b0100b50005b1 fromDataPre_STORE_1_6_2_0,59,2a2bb80018b500072a2bb900190100b500052a2bb900190100b500042a2bb900190100b500032a2bb9001a0100b500022a2bb9001a0100b50006b1 -toData,16,2a2bb600162b2ab40008b900170200b1 +toData,26,2a2bb600182b2ab40009b9001902002b2ab40005b900160300b1 toDataPre_STORE_1_6_2_0,59,2ab400072bb800132b2ab40005b9001403002b2ab40004b9001403002b2ab40003b9001403002b2ab40002b9001502002b2ab40006b900150200b1 com/pivotal/gemfirexd/internal/engine/ui/SnappyRegionStatsCollectorResult,4 diff --git a/gemfirexd/tools/src/test/resources/codeAnalysis/sanctionedSerializables.txt b/gemfirexd/tools/src/test/resources/codeAnalysis/sanctionedSerializables.txt index 968a22e40..b8004ad20 100644 --- a/gemfirexd/tools/src/test/resources/codeAnalysis/sanctionedSerializables.txt +++ b/gemfirexd/tools/src/test/resources/codeAnalysis/sanctionedSerializables.txt @@ -60,9 +60,6 @@ com/gemstone/gemfire/cache/CacheLoaderException,true,-3383072059406642140 com/gemstone/gemfire/cache/CacheRuntimeException,false com/gemstone/gemfire/cache/CacheWriterException,true,-2872212342970454458 com/gemstone/gemfire/cache/CacheXmlException,true,-4343870964883131754 -com/gemstone/gemfire/cache/CommitConflictException,true,-1491184174802596675 -com/gemstone/gemfire/cache/CommitDistributionException,true,-3517820638706581823,regionDistributionExceptions:java/util/Set -com/gemstone/gemfire/cache/CommitIncompleteException,true,1017741483744420800 com/gemstone/gemfire/cache/ConflictException,true,7814350685723175624,transactionSeverity:boolean com/gemstone/gemfire/cache/DataPolicy,true,2095573273889467233,ordinal:byte com/gemstone/gemfire/cache/DiskAccessException,true,5799100281147167888 @@ -71,7 +68,6 @@ com/gemstone/gemfire/cache/DuplicatePrimaryPartitionException,true,1 com/gemstone/gemfire/cache/EntryDestroyedException,true,831865939772672542 com/gemstone/gemfire/cache/EntryExistsException,true,2925082493103537925 com/gemstone/gemfire/cache/EntryNotFoundException,true,-2404101631744605659 -com/gemstone/gemfire/cache/EntryNotFoundInRegion,true,5572550909947420405 com/gemstone/gemfire/cache/EvictionAction,true,-98840597493242980 com/gemstone/gemfire/cache/EvictionAlgorithm,true,5778669432033106789 com/gemstone/gemfire/cache/ExpirationAction,true,658925707882047900,ordinal:int @@ -103,7 +99,6 @@ com/gemstone/gemfire/cache/RegionExistsException,true,-5643670216230359426 com/gemstone/gemfire/cache/RegionReinitializedException,true,8532904304288670752 com/gemstone/gemfire/cache/RegionRoleException,false,regionFullPath:java/lang/String com/gemstone/gemfire/cache/RegionShortcut,false -com/gemstone/gemfire/cache/RemoteTransactionException,true,-2217135580436381984 com/gemstone/gemfire/cache/ResourceException,false com/gemstone/gemfire/cache/ResumptionAction,true,6632254151314915610,ordinal:byte com/gemstone/gemfire/cache/RoleException,true,-7521056108445887394 @@ -345,14 +340,7 @@ com/gemstone/gemfire/internal/cache/RegionStatus,true,3442040750396350302,heapSi com/gemstone/gemfire/internal/cache/RemoteOperationException,true,-595988965679204903,hasHash:boolean,keyHash:int com/gemstone/gemfire/internal/cache/RemoteRegionOperation$Operation,false com/gemstone/gemfire/internal/cache/SearchLoadAndWriteProcessor$TryAgainException,false -com/gemstone/gemfire/internal/cache/THashMapWithCreate,true,2440644010877735505 com/gemstone/gemfire/internal/cache/THashMapWithKeyPair,true,6832841924272527019 -com/gemstone/gemfire/internal/cache/TStatelessIntHash,false,_FREE:int,_hashingStrategy:com/gemstone/gnu/trove/TIntHashingStrategy -com/gemstone/gemfire/internal/cache/TStatelessIntHashSet,false -com/gemstone/gemfire/internal/cache/TStatelessIntObjectHashMap,false -com/gemstone/gemfire/internal/cache/TStatelessLongHash,false,_FREE:long,_hashingStrategy:com/gemstone/gnu/trove/TLongHashingStrategy -com/gemstone/gemfire/internal/cache/TStatelessLongHashSet,false -com/gemstone/gemfire/internal/cache/TStatelessLongObjectHashMap,false com/gemstone/gemfire/internal/cache/TXCacheWriterException,true,1885220451811584517 com/gemstone/gemfire/internal/cache/TXManagerImpl$TXFinishedMap$1,false,this$0:com/gemstone/gemfire/internal/cache/TXManagerImpl$TXFinishedMap com/gemstone/gemfire/internal/cache/TXState$1,false @@ -793,7 +781,6 @@ com/gemstone/gemfire/security/AuthenticationFailedException,true,-82028664722790 com/gemstone/gemfire/security/AuthenticationRequiredException,true,4675976651103154919 com/gemstone/gemfire/security/GemFireSecurityException,true,3814254578203076926 com/gemstone/gemfire/security/NotAuthorizedException,true,419215768216387745,principal:java/security/Principal -com/gemstone/gnu/trove/TFloatArrayList,true,4142259042805691586,_data:float[],_pos:int com/gemstone/gnu/trove/THashMap,true,7557893848987411935 com/gemstone/gnu/trove/THashSet,true,2705415913937015662 com/gemstone/gnu/trove/TIntArrayList,true,-6514945712673108507 @@ -805,7 +792,6 @@ com/gemstone/gnu/trove/TLongArrayList,true,-8774302755765699167,_data:long[],_po com/gemstone/gnu/trove/TLongHash,false,_hashingStrategy:com/gemstone/gnu/trove/TLongHashingStrategy com/gemstone/gnu/trove/TLongHashSet,true,-7341114291520670738 com/gemstone/gnu/trove/TLongIntHashMap,true,-823076275246207033 -com/gemstone/gnu/trove/TLongObjectHashMap,true,7524673861954387917 com/gemstone/gnu/trove/TObjectHash,false,_hashingStrategy:com/gemstone/gnu/trove/TObjectHashingStrategy com/gemstone/gnu/trove/TObjectIdentityHashingStrategy,true,-5193908370672076866 com/gemstone/gnu/trove/TObjectIntHashMap,true,309134146652813984 diff --git a/gemfirexd/tools/src/test/resources/lib/ldap/authAD.ldif b/gemfirexd/tools/src/test/resources/lib/ldap/authAD.ldif index f195dfaee..3adf3b968 100644 --- a/gemfirexd/tools/src/test/resources/lib/ldap/authAD.ldif +++ b/gemfirexd/tools/src/test/resources/lib/ldap/authAD.ldif @@ -90,6 +90,16 @@ cn: GEMFIRE10 displayName: GEMFIRE10 userPassword:: e1NTSEF9N0twb05LcVZnY2NDWHIxZG5EM01yRXdrSkxQMUxtbU0= +dn: cn=gemfire1 \, 1,ou=ldapTesting,dc=pune,dc=gemstone,dc=com +objectClass: person +objectClass: inetOrgPerson +givenName: gemfire11 +sn: GEMFIRE11 +givenName: Gemfire11 +cn: gemfire1 , 1 +displayName: GEMFIRE11 +userPassword:: e1NTSEF9N0twb05LcVZnY2NDWHIxZG5EM01yRXdrSkxQMUxtbU0= + # LDAP group entries dn: cn=gemGroup1,ou=ldapTesting,dc=pune,dc=gemstone,dc=com @@ -149,3 +159,10 @@ cn: gemGroup7 gidNumber: 1007 member: member: + +dn: cn=gemGroup8,ou=ldapTesting,dc=pune,dc=gemstone,dc=com +objectClass: groupOfNames +cn: gemGroup8 +gidNumber: 1008 +member: cn=gemfire1 \, 1,ou=ldapTesting,dc=pune,dc=gemstone,dc=com +member: uid=gemfire6,ou=ldapTesting,dc=pune,dc=gemstone,dc=com diff --git a/gemfirexd/tools/src/test/resources/lib/useCase7/DataGenerator_.java b/gemfirexd/tools/src/test/resources/lib/useCase7/DataGenerator_.java index a9bfba946..ed7b9ff3a 100644 --- a/gemfirexd/tools/src/test/resources/lib/useCase7/DataGenerator_.java +++ b/gemfirexd/tools/src/test/resources/lib/useCase7/DataGenerator_.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/gradle.properties b/gradle.properties index 44ee79275..905f38f19 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,5 @@ -org.gradle.daemon = false +org.gradle.daemon=false +org.gradle.warning.mode=none #org.gradle.parallel=true # Set this on the command line with -P or in ~/.gradle/gradle.properties diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index f808147c2..457aad0d9 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 42deefabf..ee671127f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Wed Sep 13 23:36:27 IST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.5.1-all.zip diff --git a/gradlew b/gradlew index 8f0616712..0bad6a51d 100755 --- a/gradlew +++ b/gradlew @@ -28,16 +28,16 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="-Xmx2g -XX:ReservedCodeCacheSize=512m -Djava.net.preferIPv4Stack=true" +DEFAULT_JVM_OPTS="-XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xmx1g -Xms1g -Djava.net.preferIPv4Stack=true" # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -155,7 +155,7 @@ if $cygwin ; then fi # Escape application args -save ( ) { +save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } diff --git a/gradlew.bat b/gradlew.bat index 78bf60415..5ce1db48e 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS=-Xmx2g -XX:ReservedCodeCacheSize=512m -Djava.net.preferIPv4Stack=true +set DEFAULT_JVM_OPTS=-XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xmx1g -Xms1g -Djava.net.preferIPv4Stack=true @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome diff --git a/ldap-test-server/build.gradle b/ldap-test-server/build.gradle index 05af2c992..ccf5522e6 100644 --- a/ldap-test-server/build.gradle +++ b/ldap-test-server/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -16,7 +16,7 @@ */ plugins { - id 'com.github.johnrengelman.shadow' version '2.0.4' + id 'com.github.johnrengelman.shadow' version '4.0.3' } apply plugin: 'java' @@ -32,7 +32,7 @@ repositories { } dependencies { - compile 'commons-io:commons-io:2.5' + compile 'commons-io:commons-io:2.6' compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.5.10' compile (group: 'org.apache.directory.server', name: 'apacheds-server-jndi', version: '1.5.7') { exclude(group: 'org.apache.directory.shared', module: 'shared-ldap-schema') diff --git a/ldap-test-server/gradle.properties b/ldap-test-server/gradle.properties index fc43a2a03..905f38f19 100644 --- a/ldap-test-server/gradle.properties +++ b/ldap-test-server/gradle.properties @@ -1,6 +1,11 @@ org.gradle.daemon=false +org.gradle.warning.mode=none #org.gradle.parallel=true # Set this on the command line with -P or in ~/.gradle/gradle.properties # to change the buildDir location. Use an absolute path. buildRoot= + +# Empty credentials for maven publish on Sonatype +ossrhUsername= +ossrhPassword= diff --git a/ldap-test-server/gradle/wrapper/gradle-wrapper.jar b/ldap-test-server/gradle/wrapper/gradle-wrapper.jar index f808147c2..457aad0d9 100644 Binary files a/ldap-test-server/gradle/wrapper/gradle-wrapper.jar and b/ldap-test-server/gradle/wrapper/gradle-wrapper.jar differ diff --git a/ldap-test-server/gradle/wrapper/gradle-wrapper.properties b/ldap-test-server/gradle/wrapper/gradle-wrapper.properties index 7fe00909d..ee671127f 100644 --- a/ldap-test-server/gradle/wrapper/gradle-wrapper.properties +++ b/ldap-test-server/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Wed Sep 13 23:36:26 IST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.5.1-all.zip diff --git a/ldap-test-server/gradlew b/ldap-test-server/gradlew index 8f0616712..0bad6a51d 100755 --- a/ldap-test-server/gradlew +++ b/ldap-test-server/gradlew @@ -28,16 +28,16 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="-Xmx2g -XX:ReservedCodeCacheSize=512m -Djava.net.preferIPv4Stack=true" +DEFAULT_JVM_OPTS="-XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xmx1g -Xms1g -Djava.net.preferIPv4Stack=true" # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -155,7 +155,7 @@ if $cygwin ; then fi # Escape application args -save ( ) { +save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } diff --git a/ldap-test-server/gradlew.bat b/ldap-test-server/gradlew.bat index 78bf60415..5ce1db48e 100644 --- a/ldap-test-server/gradlew.bat +++ b/ldap-test-server/gradlew.bat @@ -14,7 +14,7 @@ set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS=-Xmx2g -XX:ReservedCodeCacheSize=512m -Djava.net.preferIPv4Stack=true +set DEFAULT_JVM_OPTS=-XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xmx1g -Xms1g -Djava.net.preferIPv4Stack=true @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome diff --git a/ldap-test-server/settings.gradle b/ldap-test-server/settings.gradle index 2cb0eb5db..1ed6ca785 100644 --- a/ldap-test-server/settings.gradle +++ b/ldap-test-server/settings.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/ldap-test-server/src/main/java/io/snappydata/ldap/LdapTestServer.class b/ldap-test-server/src/main/java/io/snappydata/ldap/LdapTestServer.class deleted file mode 100644 index b4b0a2549..000000000 Binary files a/ldap-test-server/src/main/java/io/snappydata/ldap/LdapTestServer.class and /dev/null differ diff --git a/ldap-test-server/src/main/java/io/snappydata/ldap/LdapTestServer.java b/ldap-test-server/src/main/java/io/snappydata/ldap/LdapTestServer.java index 17e793994..5573980ab 100644 --- a/ldap-test-server/src/main/java/io/snappydata/ldap/LdapTestServer.java +++ b/ldap-test-server/src/main/java/io/snappydata/ldap/LdapTestServer.java @@ -60,6 +60,7 @@ import java.util.Collections; import java.util.Properties; import java.util.List; +import java.net.InetAddress; import org.apache.commons.io.FileUtils; import org.apache.directory.server.constants.ServerDNConstants; @@ -125,6 +126,9 @@ public static void main(String[] args) throws Exception { int port = new java.util.Random().nextInt(30000) + 10000; server.startServer("0.0.0.0", port); } + InetAddress myHost = InetAddress.getLocalHost(); + String hostName = myHost.toString().split("/")[0]; + int serverPort = server.getServerPort(); Properties bootProps = new Properties(); bootProps.setProperty("auth-provider", "LDAP"); @@ -133,12 +137,11 @@ public static void main(String[] args) throws Exception { bootProps.setProperty("gemfirexd.group-ldap-search-base", "ou=ldapTesting,dc=pune,dc=gemstone,dc=com"); bootProps.setProperty("gemfirexd.auth-ldap-server", - "ldap://localhost:" + serverPort); - bootProps.setProperty("security-log-level", "finest"); - bootProps.setProperty("Dgemfirexd.debug.true", - "TraceAuthentication,TraceFabricServiceBoot"); - bootProps.setProperty("user", "gemfire10"); - bootProps.setProperty("password", "gemfire10"); + "ldap://"+hostName+":" + serverPort); + //bootProps.setProperty("security-log-level", "finest"); + //bootProps.setProperty("Dgemfirexd.debug.true","TraceAuthentication,TraceFabricServiceBoot"); + bootProps.setProperty("user", "gemfire1"); + bootProps.setProperty("password", "gemfire1"); StringBuilder sb = new StringBuilder(); for (java.util.Map.Entry e : bootProps.entrySet()) { sb.append(" -").append(e.getKey()).append('=').append(e.getValue()); diff --git a/lgpl/gemfire-jgroups/build.gradle b/lgpl/gemfire-jgroups/build.gradle index 217c0be6f..65d088899 100644 --- a/lgpl/gemfire-jgroups/build.gradle +++ b/lgpl/gemfire-jgroups/build.gradle @@ -1,7 +1,7 @@ task jgMagic (type: JavaExec, dependsOn: classes) { description 'Creates the JGroups configuration file jg-magic-map.txt' def magicXml = file 'src/main/resources/com/gemstone/org/jgroups/conf/jg-magic-map.xml' - def magicTxt = file "$buildDir/classes/main/com/gemstone/org/jgroups/conf/jg-magic-map.txt" + def magicTxt = file("${sourceSets.main.java.outputDir}/com/gemstone/org/jgroups/conf/jg-magic-map.txt") inputs.file magicXml outputs.file magicTxt diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/THashMapWithCreate.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/THashMapWithCreate.java deleted file mode 100644 index 4e6d79a1f..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/THashMapWithCreate.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -/* - * Contains code from GNU Trove having the license below. - * - * Copyright (c) 2001, Eric D. Friedman All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package com.gemstone.gemfire.internal.cache; - -import com.gemstone.gnu.trove.THashMap; -import com.gemstone.gnu.trove.TObjectHashingStrategy; - -/** - * Extends THashMap adding putIfAbsent method. - * - * @author swale - * @since 7.0 - */ -public final class THashMapWithCreate extends THashMap { - - private static final long serialVersionUID = 2440644010877735505L; - - /** - * Factory to create value object for - * {@link THashMapWithCreate#create(Object, ValueCreator, Object)}. - */ - public static interface ValueCreator { - Object create(Object key, Object params); - } - - /** - * Creates a new THashMapWithCreate instance with the default - * capacity and load factor. - */ - public THashMapWithCreate() { - super(); - } - - /** - * Creates a new THashMapWithCreate instance with a prime - * capacity equal to or greater than initialCapacity. - * - * @param initialCapacity - * an int value - */ - public THashMapWithCreate(int initialCapacity) { - super(initialCapacity); - } - - /** - * Creates a new THashMapWithCreate instance with a prime - * capacity equal to or greater than initialCapacity and with the - * specified load factor. - * - * @param initialCapacity - * an int value - * @param loadFactor - * a float value - * @param strategy - * used to compute hash codes and to compare objects. - */ - public THashMapWithCreate(int initialCapacity, float loadFactor, - TObjectHashingStrategy strategy) { - super(initialCapacity, loadFactor, strategy); - } - - /** - * Inserts a key/value pair into the map if the key does not already exist. - * - * @param key - * an Object value - * @param value - * an Object value - * @return the previous value associated with key, or null if none - * was found. - */ - public Object putIfAbsent(Object key, Object value) { - if (null != key) { - final Object oldKey; - final int index = insertionIndex(key); - if (index >= 0) { - oldKey = _set[index]; - _set[index] = key; - _values[index] = value; - postInsertHook(oldKey == null); - return null; - } - else { - return _values[-index - 1]; - } - } - else { - throw new NullPointerException("null keys not supported"); - } - } - - /** - * Inserts a key/value pair into the map if the key does not already exist - * creating the value using the provided factory only in that case. - * - * @param key - * an Object value - * @param valueCreator - * an {@link ValueCreator} instance - * @param params - * any parameters to be passed to {@link ValueCreator#create} method - * - * @return the previous value associated with key, or null - */ - public Object putIfAbsent(final Object key, final ValueCreator valueCreator, - final Object params) { - if (key != null) { - final Object oldKey, value; - final int index = insertionIndex(key); - if (index >= 0) { - oldKey = _set[index]; - _set[index] = key; - value = valueCreator.create(key, params); - _values[index] = value; - postInsertHook(oldKey == null); - return null; - } - else { - return _values[-index - 1]; - } - } - else { - throw new NullPointerException("null keys not supported"); - } - } - - /** - * Inserts a key/value pair into the map if the key does not already exist - * creating the value using the provided factory only in that case. - * - * @param key - * an Object value - * @param valueCreator - * an {@link ValueCreator} instance - * @param params - * any parameters to be passed to {@link ValueCreator#create} method - * - * @return the previous value associated with key, or the newly - * created one - */ - public Object create(Object key, ValueCreator valueCreator, Object params) { - if (null != key) { - final Object oldKey, value; - final int index = insertionIndex(key); - if (index >= 0) { - oldKey = _set[index]; - _set[index] = key; - value = valueCreator.create(key, params); - _values[index] = value; - postInsertHook(oldKey == null); - return value; - } - else { - return _values[-index - 1]; - } - } - else { - throw new NullPointerException("null keys not supported"); - } - } -} diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessIntHash.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessIntHash.java deleted file mode 100644 index 6e6fee770..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessIntHash.java +++ /dev/null @@ -1,311 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -/* - * Contains code from GNU Trove having the license below. - * - * Copyright (c) 2001, Eric D. Friedman All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package com.gemstone.gemfire.internal.cache; - -import com.gemstone.gnu.trove.*; -import java.util.Arrays; - -/** - * An open addressed hashing implementation for int primitives. - * - * @author darrel - */ - -abstract public class TStatelessIntHash extends TStatelessPrimitiveHash - implements TIntHashingStrategy { - /** the set of ints */ - protected transient int[] _set; - - protected /*final*/ int _FREE; - - /** strategy used to hash values in this collection */ - protected TIntHashingStrategy _hashingStrategy; - - /** - * Creates a new TStatelessIntHash instance with the default - * capacity and load factor. - */ - public TStatelessIntHash(int freeValue) { - super(); - this._hashingStrategy = this; - this._FREE = freeValue; - } - - /** - * Creates a new TStatelessIntHash instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - */ - public TStatelessIntHash(int freeValue, int initialCapacity) { - super(initialCapacity); - this._hashingStrategy = this; - this._FREE = freeValue; - } - - /** - * Creates a new TStatelessIntHash instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - */ - public TStatelessIntHash(int freeValue, int initialCapacity, float loadFactor) { - super(initialCapacity, loadFactor); - this._hashingStrategy = this; - this._FREE = freeValue; - } - - /** - * Creates a new TStatelessIntHash instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TStatelessIntHash(int freeValue, TIntHashingStrategy strategy) { - super(); - this._hashingStrategy = strategy; - this._FREE = freeValue; - } - - /** - * Creates a new TStatelessIntHash instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TStatelessIntHash(int freeValue, int initialCapacity, TIntHashingStrategy strategy) { - super(initialCapacity); - this._hashingStrategy = strategy; - this._FREE = freeValue; - } - - /** - * Creates a new TStatelessIntHash instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TStatelessIntHash(int freeValue, int initialCapacity, float loadFactor, TIntHashingStrategy strategy) { - super(initialCapacity, loadFactor); - this._hashingStrategy = strategy; - this._FREE = freeValue; - } - - public int getFreeValue() { - return this._FREE; - } - - /** - * @return a deep clone of this collection - */ - @Override - public Object clone() { - TStatelessIntHash h = (TStatelessIntHash)super.clone(); - h._set = this._set.clone(); - h._FREE = this._FREE; - return h; - } - - /** - * Returns the capacity of the hash table. This is the true - * physical capacity, without adjusting for the load factor. - * - * @return the physical capacity of the hash table. - */ - @Override - protected int capacity() { - return _set.length; - } - - /** - * initializes the hashtable to a prime capacity which is at least - * initialCapacity + 1. - * - * @param initialCapacity an int value - * @return the actual capacity chosen - */ - @Override - protected int setUp(int initialCapacity) { - int capacity; - - capacity = super.setUp(initialCapacity); - _set = new int[capacity]; - if (this._FREE != 0) { - Arrays.fill(_set, this._FREE); - } - return capacity; - } - - /** - * Searches the set for val - * - * @param val an int value - * @return a boolean value - */ - public boolean contains(int val) { - return index(val) >= 0; - } - - /** - * Executes procedure for each element in the set. - * - * @param procedure a TObjectProcedure value - * @return false if the loop over the set terminated because - * the procedure returned false for some value. - */ - public boolean forEach(TIntProcedure procedure) { - int[] set = _set; - for (int i = set.length; i-- > 0;) { - if (set[i] != this._FREE && ! procedure.execute(set[i])) { - return false; - } - } - return true; - } - -// /** -// * Releases the element currently stored at index. -// * -// * @param index an int value -// */ -// @Override -// protected void removeAt(int index) { -// super.removeAt(index); -// _set[index] = this._FREE; -// } - - /** - * Locates the index of val. - * - * @param val an int value - * @return the index of val or -1 if it isn't in the set. - */ - protected int index(int val) { - int hash, probe, index, length; - int[] set; - - if (val == this._FREE) { - return -1; - } - set = _set; - length = set.length; - hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff; - index = hash % length; - - if (set[index] != this._FREE && set[index] != val) { - // see Knuth, p. 529 - probe = 1 + (hash % (length - 2)); - - do { - index -= probe; - if (index < 0) { - index += length; - } - } while (set[index] != this._FREE && set[index] != val); - } - - return set[index] == this._FREE ? -1 : index; - } - - /** - * Locates the index at which val can be inserted. if - * there is already a value equal()ing val in the set, - * returns that value as a negative integer. - * - * @param val an int value - * @return an int value - */ - protected int insertionIndex(int val) { - int hash, probe, index, length; - int[] set; - - if (val == this._FREE) { - throw new IllegalArgumentException("can not add the value " + val); - } - set = _set; - length = set.length; - hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff; - index = hash % length; - - if (set[index] == this._FREE) { - return index; // empty, all done - } else if (set[index] == val) { - return -index -1; // already stored - } else { // already FULL or REMOVED, must probe - // compute the double hash - probe = 1 + (hash % (length - 2)); - - // if the slot we landed on is not FREE, probe - // until we find an empty slot or an element - // equal to the one we are trying to insert. - // finding an empty slot means that the value is not present - // and that we should use that slot as the insertion point; - // finding a matching value means that we've found that our desired - // key is already in the table - - // starting at the natural offset, probe until we find an - // offset that isn't full. - do { - index -= probe; - if (index < 0) { - index += length; - } - } while (set[index] != this._FREE && set[index] != val); - - // if it's not free, the key is already stored - return set[index] != this._FREE ? -index -1 : index; - } - } - - /** - * Default implementation of TIntHashingStrategy: - * delegates hashing to HashFunctions.hash(int). - * - * @param val the value to hash - * @return the hashcode. - */ - public final int computeHashCode(int val) { - return HashFunctions.hash(val); - } -} // TStatelessIntHash diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessIntHashSet.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessIntHashSet.java deleted file mode 100644 index fcb052334..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessIntHashSet.java +++ /dev/null @@ -1,341 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -/* - * Contains code from GNU Trove having the license below. - * - * Copyright (c) 2001, Eric D. Friedman All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package com.gemstone.gemfire.internal.cache; - -import com.gemstone.gnu.trove.*; -import java.util.Arrays; - -/** - * An open addressed set implementation for int primitives. - * - * @author darrel - */ -public class TStatelessIntHashSet extends TStatelessIntHash { - /** - * Creates a new TStatelessIntHashSet instance with the default - * capacity and load factor. - */ - public TStatelessIntHashSet(int freeValue) { - super(freeValue); - } - - /** - * Creates a new TStatelessIntHashSet instance with a prime - * capacity equal to or greater than initialCapacity and - * with the default load factor. - * - * @param initialCapacity an int value - */ - public TStatelessIntHashSet(int freeValue, int initialCapacity) { - super(freeValue, initialCapacity); - } - - /** - * Creates a new TStatelessIntHashSet instance with a prime - * capacity equal to or greater than initialCapacity and - * with the specified load factor. - * - * @param initialCapacity an int value - * @param loadFactor a float value - */ - public TStatelessIntHashSet(int freeValue, int initialCapacity, float loadFactor) { - super(freeValue, initialCapacity, loadFactor); - } - - /** - * Creates a new TStatelessIntHashSet instance containing the - * elements of array. - * - * @param array an array of int primitives - */ - public TStatelessIntHashSet(int freeValue, int[] array) { - this(freeValue, array.length); - addAll(array); - } - - /** - * Creates a new TStatelessIntHash instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TStatelessIntHashSet(int freeValue, TIntHashingStrategy strategy) { - super(freeValue, strategy); - } - - /** - * Creates a new TStatelessIntHash instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TStatelessIntHashSet(int freeValue, int initialCapacity, TIntHashingStrategy strategy) { - super(freeValue, initialCapacity, strategy); - } - - /** - * Creates a new TStatelessIntHash instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TStatelessIntHashSet(int freeValue, int initialCapacity, float loadFactor, TIntHashingStrategy strategy) { - super(freeValue, initialCapacity, loadFactor, strategy); - } - - /** - * Creates a new TStatelessIntHashSet instance containing the - * elements of array. - * - * @param array an array of int primitives - * @param strategy used to compute hash codes and to compare keys. - */ - public TStatelessIntHashSet(int freeValue, int[] array, TIntHashingStrategy strategy) { - this(freeValue, array.length, strategy); - addAll(array); - } - - /** - * @return a TIntIterator with access to the values in this set - */ - public TStatelessIntIterator iterator() { - return new TStatelessIntIterator(this); - } - - /** - * Inserts a value into the set. - * - * @param val an int value - * @return true if the set was modified by the add operation - */ - public boolean add(int val) { - int index = insertionIndex(val); - - if (index < 0) { - return false; // already present in set, nothing to add - } - - int previousState = _set[index]; - _set[index] = val; - postInsertHook(previousState == this._FREE); - - return true; // yes, we added something - } - - /** - * Expands the set to accomodate new values. - * - * @param newCapacity an int value - */ - @Override - protected void rehash(int newCapacity) { - int oldCapacity = _set.length; - int oldSet[] = _set; - - _set = new int[newCapacity]; - if (this._FREE != 0) { - Arrays.fill(_set, this._FREE); - } - - for (int i = oldCapacity; i-- > 0;) { - int o = oldSet[i]; - if (o != this._FREE) { - int index = insertionIndex(o); - _set[index] = o; - } - } - } - - /** - * Returns a new array containing the values in the set. - * - * @return an int[] value - */ - public int[] toArray() { - int[] result = new int[size()]; - int[] set = _set; - - for (int i = set.length, j = 0; i-- > 0;) { - int o = set[i]; - if (o != this._FREE) { - result[j++] = o; - } - } - return result; - } - - /** - * Empties the set. - */ - @Override - public void clear() { - super.clear(); - java.util.Arrays.fill(_set, this._FREE); - } - - /** - * Compares this set with another set for equality of their stored - * entries. - * - * @param other an Object value - * @return a boolean value - */ - @Override - public boolean equals(Object other) { - if (! (other instanceof TStatelessIntHashSet)) { - return false; - } - final TStatelessIntHashSet that = (TStatelessIntHashSet)other; - if (that.size() != this.size()) { - return false; - } - return forEach(new TIntProcedure() { - public final boolean execute(int value) { - return that.contains(value); - } - }); - } - - @Override - public int hashCode() { - HashProcedure p = new HashProcedure(); - forEach(p); - return p.getHashCode(); - } - - protected final class HashProcedure implements TIntProcedure { - private int h = 0; - - public int getHashCode() { - return h; - } - - public final boolean execute(int key) { - h += _hashingStrategy.computeHashCode(key); - return true; - } - } - -// /** -// * Removes val from the set. -// * -// * @param val an int value -// * @return true if the set was modified by the remove operation. -// */ -// public boolean remove(int val) { -// int index = index(val); -// if (index >= 0) { -// removeAt(index); -// return true; -// } -// return false; -// } - - /** - * Tests the set to determine if all of the elements in - * array are present. - * - * @param array an array of int primitives. - * @return true if all elements were present in the set. - */ - public boolean containsAll(int[] array) { - for (int i = array.length; i-- > 0;) { - if (! contains(array[i])) { - return false; - } - } - return true; - } - - /** - * Adds all of the elements in array to the set. - * - * @param array an array of int primitives. - * @return true if the set was modified by the add all operation. - */ - public boolean addAll(int[] array) { - boolean changed = false; - for (int i = array.length; i-- > 0;) { - if (add(array[i])) { - changed = true; - } - } - return changed; - } - -// /** -// * Removes all of the elements in array from the set. -// * -// * @param array an array of int primitives. -// * @return true if the set was modified by the remove all operation. -// */ -// public boolean removeAll(int[] array) { -// boolean changed = false; -// for (int i = array.length; i-- > 0;) { -// if (remove(array[i])) { -// changed = true; -// } -// } -// return changed; -// } - -// /** -// * Removes any values in the set which are not contained in -// * array. -// * -// * @param array an array of int primitives. -// * @return true if the set was modified by the retain all operation -// */ -// public boolean retainAll(int[] array) { -// boolean changed = false; -// Arrays.sort(array); -// int[] set = _set; - -// for (int i = set.length; i-- > 0;) { -// if (set[i] != this._FREE && (Arrays.binarySearch(array,set[i]) < 0)) { -// remove(set[i]); -// changed = true; -// } -// } -// return changed; -// } - -} // TStatelessIntHashSet diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessIntIterator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessIntIterator.java deleted file mode 100644 index cdfbc33f5..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessIntIterator.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -/* - * Contains code from GNU Trove having the license below. - * - * Copyright (c) 2001, Eric D. Friedman All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package com.gemstone.gemfire.internal.cache; - -import com.gemstone.gnu.trove.*; -import java.util.ConcurrentModificationException; - -/** - * Iterator for int collections. - * - * @author darrel - */ -public class TStatelessIntIterator extends TIterator { - /** the collection on which the iterator operates */ - private final TStatelessIntHash _hash; - - /** - * Creates a TStatelessIntIterator for the elements in the specified collection. - */ - public TStatelessIntIterator(TStatelessIntHash hash) { - super(hash); - this._hash = hash; - } - - /** - * Advances the iterator to the next element in the underlying collection - * and returns it. - * - * @return the next int in the collection - * @exception java.util.NoSuchElementException if the iterator is already exhausted - */ - public int next() { - moveToNextIndex(); - return _hash._set[_index]; - } - /** - * Returns the index of the next value in the data structure - * or a negative value if the iterator is exhausted. - * - * @return an int value - * @exception ConcurrentModificationException if the underlying collection's - * size has been modified since the iterator was created. - */ - @Override - protected final int nextIndex() { - if (_expectedSize != _hash.size()) { - throw new ConcurrentModificationException(); - } - - int[] set = _hash._set; - int FREE = _hash.getFreeValue(); - int i = _index; - while (i-- > 0 && (set[i] == FREE)) ; - return i; - } -}// TStatelessIntIterator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessIntObjectHashMap.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessIntObjectHashMap.java deleted file mode 100644 index 719dc9f60..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessIntObjectHashMap.java +++ /dev/null @@ -1,480 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -/* - * Contains code from GNU Trove having the license below. - * - * Copyright (c) 2001, Eric D. Friedman All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package com.gemstone.gemfire.internal.cache; - -import com.gemstone.gnu.trove.*; -import java.util.Arrays; - -/** - * An open addressed Map implementation for int keys and Object values. - * - * @author darrel - */ -public class TStatelessIntObjectHashMap extends TStatelessIntHash { - /** the values of the map */ - protected transient Object[] _values; - - /** - * Creates a new TStatelessIntObjectHashMap instance with the default - * capacity and load factor. - */ - public TStatelessIntObjectHashMap(int freeValue) { - super(freeValue); - } - - /** - * Creates a new TStatelessIntObjectHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the default load factor. - * - * @param initialCapacity an int value - */ - public TStatelessIntObjectHashMap(int freeValue, int initialCapacity) { - super(freeValue, initialCapacity); - } - - /** - * Creates a new TStatelessIntObjectHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the specified load factor. - * - * @param initialCapacity an int value - * @param loadFactor a float value - */ - public TStatelessIntObjectHashMap(int freeValue, int initialCapacity, float loadFactor) { - super(freeValue, initialCapacity, loadFactor); - } - - /** - * Creates a new TStatelessIntObjectHashMap instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TStatelessIntObjectHashMap(int freeValue, TIntHashingStrategy strategy) { - super(freeValue, strategy); - } - - /** - * Creates a new TStatelessIntObjectHashMap instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TStatelessIntObjectHashMap(int freeValue, int initialCapacity, TIntHashingStrategy strategy) { - super(freeValue, initialCapacity, strategy); - } - - /** - * Creates a new TStatelessIntObjectHashMap instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TStatelessIntObjectHashMap(int freeValue, int initialCapacity, float loadFactor, TIntHashingStrategy strategy) { - super(freeValue, initialCapacity, loadFactor, strategy); - } - - /** - * @return a deep clone of this collection - */ - @Override - public Object clone() { - TStatelessIntObjectHashMap m = (TStatelessIntObjectHashMap)super.clone(); - m._values = this._values.clone(); - return m; - } - - /** - * @return a TStatelessIntObjectIterator with access to this map's keys and values - */ - public TStatelessIntObjectIterator iterator() { - return new TStatelessIntObjectIterator(this); - } - - /** - * initializes the hashtable to a prime capacity which is at least - * initialCapacity + 1. - * - * @param initialCapacity an int value - * @return the actual capacity chosen - */ - @Override - protected int setUp(int initialCapacity) { - int capacity; - - capacity = super.setUp(initialCapacity); - _values = new Object[capacity]; - return capacity; - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an int value - * @param value an Object value - * @return the previous value associated with key, - * or null if none was found. - */ - public Object put(int key, Object value) { - int previousKey; - Object previous = null; - int index = insertionIndex(key); - boolean isNewMapping = true; - if (index < 0) { - index = -index -1; - previous = _values[index]; - isNewMapping = false; - } - previousKey = _set[index]; - _set[index] = key; - _values[index] = value; - if (isNewMapping) { - postInsertHook(previousKey == this._FREE); - } - - return previous; - } - - /** - * rehashes the map to the new capacity. - * - * @param newCapacity an int value - */ - @Override - protected void rehash(int newCapacity) { - int oldCapacity = _set.length; - int oldKeys[] = _set; - Object oldVals[] = _values; - - _set = new int[newCapacity]; - if (this._FREE != 0) { - Arrays.fill(_set, this._FREE); - } - _values = new Object[newCapacity]; - - for (int i = oldCapacity; i-- > 0;) { - if(oldKeys[i] != this._FREE) { - int o = oldKeys[i]; - int index = insertionIndex(o); - _set[index] = o; - _values[index] = oldVals[i]; - } - } - } - - /** - * retrieves the value for key - * - * @param key an int value - * @return the value of key or null if no such mapping exists. - */ - public Object get(int key) { - int index = index(key); - return index < 0 ? null : _values[index]; - } - - /** - * Empties the map. - * - */ - @Override - public void clear() { - super.clear(); - int[] keys = _set; - Object[] vals = _values; - - for (int i = keys.length; i-- > 0;) { - keys[i] = this._FREE; - vals[i] = null; - } - } - -// /** -// * Deletes a key/value pair from the map. -// * -// * @param key an int value -// * @return an Object value, or null if no mapping for key exists -// */ -// public Object remove(int key) { -// Object prev = null; -// int index = index(key); -// if (index >= 0) { -// prev = _values[index]; -// removeAt(index); // clear key,state; adjust size -// } -// return prev; -// } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return a boolean value - */ - @Override - public boolean equals(Object other) { - if (! (other instanceof TStatelessIntObjectHashMap)) { - return false; - } - TStatelessIntObjectHashMap that = (TStatelessIntObjectHashMap)other; - if (that.size() != this.size()) { - return false; - } - return forEachEntry(new EqProcedure(that)); - } - - @Override - public int hashCode() { - HashProcedure p = new HashProcedure(); - forEachEntry(p); - return p.getHashCode(); - } - - protected final class HashProcedure implements TIntObjectProcedure { - private int h = 0; - - public int getHashCode() { - return h; - } - - public final boolean execute(int key, Object value) { - h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); - return true; - } - } - - private static final class EqProcedure implements TIntObjectProcedure { - private final TStatelessIntObjectHashMap _otherMap; - - EqProcedure(TStatelessIntObjectHashMap otherMap) { - _otherMap = otherMap; - } - - public final boolean execute(int key, Object value) { - int index = _otherMap.index(key); - if (index >= 0 && eq(value, _otherMap.get(key))) { - return true; - } - return false; - } - - /** - * Compare two objects for equality. - */ - private final boolean eq(Object o1, Object o2) { - return o1 == o2 || ((o1 != null) && o1.equals(o2)); - } - - } - -// /** -// * removes the mapping at index from the map. -// * -// * @param index an int value -// */ -// @Override -// protected void removeAt(int index) { -// super.removeAt(index); // clear key, state; adjust size -// _values[index] = null; -// } - - /** - * Returns the values of the map. - * - * @return a Collection value - */ - public Object[] getValues() { - Object[] vals = new Object[size()]; - Object[] v = _values; - int[] keys = _set; - - for (int i = v.length, j = 0; i-- > 0;) { - if (keys[i] != this._FREE) { - vals[j++] = v[i]; - } - } - return vals; - } - - /** - * returns the keys of the map. - * - * @return a Set value - */ - public int[] keys() { - int[] keys = new int[size()]; - int[] k = _set; - - for (int i = k.length, j = 0; i-- > 0;) { - if (k[i] != this._FREE) { - keys[j++] = k[i]; - } - } - return keys; - } - - /** - * checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - public boolean containsValue(Object val) { - int[] keys = _set; - Object[] vals = _values; - - // special case null values so that we don't have to - // perform null checks before every call to equals() - if (null == val) { - for (int i = vals.length; i-- > 0;) { - if (keys[i] != this._FREE && - val == vals[i]) { - return true; - } - } - } else { - for (int i = vals.length; i-- > 0;) { - if (keys[i] != this._FREE && - (val == vals[i] || val.equals(vals[i]))) { - return true; - } - } - } // end of else - return false; - } - - - /** - * checks for the present of key in the keys of the map. - * - * @param key an int value - * @return a boolean value - */ - public boolean containsKey(int key) { - return contains(key); - } - - /** - * Executes procedure for each key in the map. - * - * @param procedure a TIntProcedure value - * @return false if the loop over the keys terminated because - * the procedure returned false for some key. - */ - public boolean forEachKey(TIntProcedure procedure) { - return forEach(procedure); - } - - /** - * Executes procedure for each value in the map. - * - * @param procedure a TObjectProcedure value - * @return false if the loop over the values terminated because - * the procedure returned false for some value. - */ - public boolean forEachValue(TObjectProcedure procedure) { - int[] keys = _set; - Object[] values = _values; - for (int i = values.length; i-- > 0;) { - if (keys[i] != this._FREE && ! procedure.execute(values[i])) { - return false; - } - } - return true; - } - - /** - * Executes procedure for each key/value entry in the - * map. - * - * @param procedure a TOIntObjectProcedure value - * @return false if the loop over the entries terminated because - * the procedure returned false for some entry. - */ - public boolean forEachEntry(TIntObjectProcedure procedure) { - int[] keys = _set; - Object[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (keys[i] != this._FREE && ! procedure.execute(keys[i],values[i])) { - return false; - } - } - return true; - } - -// /** -// * Retains only those entries in the map for which the procedure -// * returns a true value. -// * -// * @param procedure determines which entries to keep -// * @return true if the map was modified. -// */ -// public boolean retainEntries(TIntObjectProcedure procedure) { -// boolean modified = false; -// int[] keys = _set; -// Object[] values = _values; -// for (int i = keys.length; i-- > 0;) { -// if (keys[i] != this._FREE && ! procedure.execute(keys[i],values[i])) { -// removeAt(i); -// modified = true; -// } -// } -// return modified; -// } - - /** - * Transform the values in this map using function. - * - * @param function a TObjectFunction value - */ - public void transformValues(TObjectFunction function) { - int[] keys = _set; - Object[] values = _values; - for (int i = values.length; i-- > 0;) { - if (_set[i] != this._FREE) { - values[i] = function.execute(values[i]); - } - } - } - -} // TStatelessIntObjectHashMap diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessIntObjectIterator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessIntObjectIterator.java deleted file mode 100644 index 3e8d93e3a..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessIntObjectIterator.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -/* - * Contains code from GNU Trove having the license below. - * - * Copyright (c) 2001, Eric D. Friedman All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package com.gemstone.gemfire.internal.cache; - -import com.gemstone.gnu.trove.*; -import java.util.ConcurrentModificationException; - -/** - * Iterator for maps of type int and Object. - * - * @author darrel - */ - -public class TStatelessIntObjectIterator extends TIterator { - /** the collection being iterated over */ - private final TStatelessIntObjectHashMap _map; - - /** - * Creates an iterator over the specified map - */ - public TStatelessIntObjectIterator(TStatelessIntObjectHashMap map) { - super(map); - this._map = map; - } - - /** - * Moves the iterator forward to the next entry in the underlying map. - * - * @exception java.util.NoSuchElementException if the iterator is already exhausted - */ - public void advance() { - moveToNextIndex(); - } - - /** - * Provides access to the key of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the key of the entry at the iterator's current position. - */ - public int key() { - return _map._set[_index]; - } - - /** - * Provides access to the value of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the value of the entry at the iterator's current position. - */ - public Object value() { - return _map._values[_index]; - } - - /** - * Replace the value of the mapping at the iterator's position with the - * specified value. Note that you must advance() the iterator at - * least once before invoking this method. - * - * @param val the value to set in the current entry - * @return the old value of the entry. - */ - public Object setValue(Object val) { - Object old = value(); - _map._values[_index] = val; - return old; - } - /** - * Returns the index of the next value in the data structure - * or a negative value if the iterator is exhausted. - * - * @return an int value - * @exception ConcurrentModificationException if the underlying collection's - * size has been modified since the iterator was created. - */ - @Override - protected final int nextIndex() { - if (_expectedSize != _hash.size()) { - throw new ConcurrentModificationException(); - } - - int[] keys = _map._set; - int FREE = _map.getFreeValue(); - int i = _index; - while (i-- > 0 && (keys[i] == FREE)) ; - return i; - } -}// TStatelessIntObjectIterator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessLongHash.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessLongHash.java deleted file mode 100644 index dc7b6a935..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessLongHash.java +++ /dev/null @@ -1,311 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -/* - * Contains code from GNU Trove having the license below. - * - * Copyright (c) 2001, Eric D. Friedman All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package com.gemstone.gemfire.internal.cache; - -import com.gemstone.gnu.trove.*; -import java.util.Arrays; - -/** - * An open addressed hashing implementation for long primitives. - * - * @author darrel - */ - -abstract public class TStatelessLongHash extends TStatelessPrimitiveHash - implements TLongHashingStrategy { - /** the set of longs */ - protected transient long[] _set; - - protected /*final*/ long _FREE; - - /** strategy used to hash values in this collection */ - protected TLongHashingStrategy _hashingStrategy; - - /** - * Creates a new TStatelessLongHash instance with the default - * capacity and load factor. - */ - public TStatelessLongHash(long freeValue) { - super(); - this._hashingStrategy = this; - this._FREE = freeValue; - } - - /** - * Creates a new TStatelessLongHash instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - */ - public TStatelessLongHash(long freeValue, int initialCapacity) { - super(initialCapacity); - this._hashingStrategy = this; - this._FREE = freeValue; - } - - /** - * Creates a new TStatelessLongHash instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - */ - public TStatelessLongHash(long freeValue, int initialCapacity, float loadFactor) { - super(initialCapacity, loadFactor); - this._hashingStrategy = this; - this._FREE = freeValue; - } - - /** - * Creates a new TStatelessLongHash instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TStatelessLongHash(long freeValue, TLongHashingStrategy strategy) { - super(); - this._hashingStrategy = strategy; - this._FREE = freeValue; - } - - /** - * Creates a new TStatelessLongHash instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TStatelessLongHash(long freeValue, int initialCapacity, TLongHashingStrategy strategy) { - super(initialCapacity); - this._hashingStrategy = strategy; - this._FREE = freeValue; - } - - /** - * Creates a new TStatelessLongHash instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TStatelessLongHash(long freeValue, int initialCapacity, float loadFactor, TLongHashingStrategy strategy) { - super(initialCapacity, loadFactor); - this._hashingStrategy = strategy; - this._FREE = freeValue; - } - - public long getFreeValue() { - return this._FREE; - } - - /** - * @return a deep clone of this collection - */ - @Override - public Object clone() { - TStatelessLongHash h = (TStatelessLongHash)super.clone(); - h._set = this._set.clone(); - h._FREE = this._FREE; - return h; - } - - /** - * Returns the capacity of the hash table. This is the true - * physical capacity, without adjusting for the load factor. - * - * @return the physical capacity of the hash table. - */ - @Override - protected int capacity() { - return _set.length; - } - - /** - * initializes the hashtable to a prime capacity which is at least - * initialCapacity + 1. - * - * @param initialCapacity an int value - * @return the actual capacity chosen - */ - @Override - protected int setUp(int initialCapacity) { - int capacity; - - capacity = super.setUp(initialCapacity); - _set = new long[capacity]; - if (this._FREE != 0) { - Arrays.fill(_set, this._FREE); - } - return capacity; - } - - /** - * Searches the set for val - * - * @param val an long value - * @return a boolean value - */ - public boolean contains(long val) { - return index(val) >= 0; - } - - /** - * Executes procedure for each element in the set. - * - * @param procedure a TObjectProcedure value - * @return false if the loop over the set terminated because - * the procedure returned false for some value. - */ - public boolean forEach(TLongProcedure procedure) { - long[] set = _set; - for (int i = set.length; i-- > 0;) { - if (set[i] != this._FREE && ! procedure.execute(set[i])) { - return false; - } - } - return true; - } - -// /** -// * Releases the element currently stored at index. -// * -// * @param index an int value -// */ -// @Override -// protected void removeAt(int index) { -// super.removeAt(index); -// _set[index] = this._FREE; -// } - - /** - * Locates the index of val. - * - * @param val an long value - * @return the index of val or -1 if it isn't in the set. - */ - protected int index(long val) { - int hash, probe, index, length; - long[] set; - - if (val == this._FREE) { - return -1; - } - set = _set; - length = set.length; - hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff; - index = hash % length; - - if (set[index] != this._FREE && set[index] != val) { - // see Knuth, p. 529 - probe = 1 + (hash % (length - 2)); - - do { - index -= probe; - if (index < 0) { - index += length; - } - } while (set[index] != this._FREE && set[index] != val); - } - - return set[index] == this._FREE ? -1 : index; - } - - /** - * Locates the index at which val can be inserted. if - * there is already a value equal()ing val in the set, - * returns that value as a negative integer. - * - * @param val an long value - * @return an int value - */ - protected int insertionIndex(long val) { - int hash, probe, index, length; - long[] set; - - if (val == this._FREE) { - throw new IllegalArgumentException("can not add the value " + val); - } - set = _set; - length = set.length; - hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff; - index = hash % length; - - if (set[index] == this._FREE) { - return index; // empty, all done - } else if (set[index] == val) { - return -index -1; // already stored - } else { // already FULL or REMOVED, must probe - // compute the double hash - probe = 1 + (hash % (length - 2)); - - // if the slot we landed on is not FREE, probe - // until we find an empty slot or an element - // equal to the one we are trying to insert. - // finding an empty slot means that the value is not present - // and that we should use that slot as the insertion point; - // finding a matching value means that we've found that our desired - // key is already in the table - - // starting at the natural offset, probe until we find an - // offset that isn't full. - do { - index -= probe; - if (index < 0) { - index += length; - } - } while (set[index] != this._FREE && set[index] != val); - - // if it's not free, the key is already stored - return set[index] != this._FREE ? -index -1 : index; - } - } - - /** - * Default implementation of TLongHashingStrategy: - * delegates hashing to HashFunctions.hash(long). - * - * @param val the value to hash - * @return the hashcode. - */ - public final int computeHashCode(long val) { - return HashFunctions.hash(val); - } -} // TStatelessLongHash diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessLongHashSet.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessLongHashSet.java deleted file mode 100644 index 8197002a0..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessLongHashSet.java +++ /dev/null @@ -1,341 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -/* - * Contains code from GNU Trove having the license below. - * - * Copyright (c) 2001, Eric D. Friedman All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package com.gemstone.gemfire.internal.cache; - -import com.gemstone.gnu.trove.*; -import java.util.Arrays; - -/** - * An open addressed set implementation for long primitives. - * - * @author darrel - */ -public class TStatelessLongHashSet extends TStatelessLongHash { - /** - * Creates a new TStatelessLongHashSet instance with the default - * capacity and load factor. - */ - public TStatelessLongHashSet(long freeValue) { - super(freeValue); - } - - /** - * Creates a new TStatelessLongHashSet instance with a prime - * capacity equal to or greater than initialCapacity and - * with the default load factor. - * - * @param initialCapacity an int value - */ - public TStatelessLongHashSet(long freeValue, int initialCapacity) { - super(freeValue, initialCapacity); - } - - /** - * Creates a new TStatelessLongHashSet instance with a prime - * capacity equal to or greater than initialCapacity and - * with the specified load factor. - * - * @param initialCapacity an int value - * @param loadFactor a float value - */ - public TStatelessLongHashSet(long freeValue, int initialCapacity, float loadFactor) { - super(freeValue, initialCapacity, loadFactor); - } - - /** - * Creates a new TStatelessLongHashSet instance containing the - * elements of array. - * - * @param array an array of long primitives - */ - public TStatelessLongHashSet(long freeValue, long[] array) { - this(freeValue, array.length); - addAll(array); - } - - /** - * Creates a new TStatelessLongHash instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TStatelessLongHashSet(long freeValue, TLongHashingStrategy strategy) { - super(freeValue, strategy); - } - - /** - * Creates a new TStatelessLongHash instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TStatelessLongHashSet(long freeValue, int initialCapacity, TLongHashingStrategy strategy) { - super(freeValue, initialCapacity, strategy); - } - - /** - * Creates a new TStatelessLongHash instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TStatelessLongHashSet(long freeValue, int initialCapacity, float loadFactor, TLongHashingStrategy strategy) { - super(freeValue, initialCapacity, loadFactor, strategy); - } - - /** - * Creates a new TStatelessLongHashSet instance containing the - * elements of array. - * - * @param array an array of long primitives - * @param strategy used to compute hash codes and to compare keys. - */ - public TStatelessLongHashSet(long freeValue, long[] array, TLongHashingStrategy strategy) { - this(freeValue, array.length, strategy); - addAll(array); - } - - /** - * @return a TLongIterator with access to the values in this set - */ - public TStatelessLongIterator iterator() { - return new TStatelessLongIterator(this); - } - - /** - * Inserts a value into the set. - * - * @param val an long value - * @return true if the set was modified by the add operation - */ - public boolean add(long val) { - int index = insertionIndex(val); - - if (index < 0) { - return false; // already present in set, nothing to add - } - - long previousState = _set[index]; - _set[index] = val; - postInsertHook(previousState == this._FREE); - - return true; // yes, we added something - } - - /** - * Expands the set to accomodate new values. - * - * @param newCapacity an int value - */ - @Override - protected void rehash(int newCapacity) { - int oldCapacity = _set.length; - long oldSet[] = _set; - - _set = new long[newCapacity]; - if (this._FREE != 0) { - Arrays.fill(_set, this._FREE); - } - - for (int i = oldCapacity; i-- > 0;) { - long o = oldSet[i]; - if (o != this._FREE) { - int index = insertionIndex(o); - _set[index] = o; - } - } - } - - /** - * Returns a new array containing the values in the set. - * - * @return an long[] value - */ - public long[] toArray() { - long[] result = new long[size()]; - long[] set = _set; - - for (int i = set.length, j = 0; i-- > 0;) { - long o = set[i]; - if (o != this._FREE) { - result[j++] = o; - } - } - return result; - } - - /** - * Empties the set. - */ - @Override - public void clear() { - super.clear(); - java.util.Arrays.fill(_set, this._FREE); - } - - /** - * Compares this set with another set for equality of their stored - * entries. - * - * @param other an Object value - * @return a boolean value - */ - @Override - public boolean equals(Object other) { - if (! (other instanceof TStatelessLongHashSet)) { - return false; - } - final TStatelessLongHashSet that = (TStatelessLongHashSet)other; - if (that.size() != this.size()) { - return false; - } - return forEach(new TLongProcedure() { - public final boolean execute(long value) { - return that.contains(value); - } - }); - } - - @Override - public int hashCode() { - HashProcedure p = new HashProcedure(); - forEach(p); - return p.getHashCode(); - } - - protected final class HashProcedure implements TLongProcedure { - private int h = 0; - - public int getHashCode() { - return h; - } - - public final boolean execute(long key) { - h += _hashingStrategy.computeHashCode(key); - return true; - } - } - -// /** -// * Removes val from the set. -// * -// * @param val an long value -// * @return true if the set was modified by the remove operation. -// */ -// public boolean remove(long val) { -// int index = index(val); -// if (index >= 0) { -// removeAt(index); -// return true; -// } -// return false; -// } - - /** - * Tests the set to determine if all of the elements in - * array are present. - * - * @param array an array of long primitives. - * @return true if all elements were present in the set. - */ - public boolean containsAll(long[] array) { - for (int i = array.length; i-- > 0;) { - if (! contains(array[i])) { - return false; - } - } - return true; - } - - /** - * Adds all of the elements in array to the set. - * - * @param array an array of long primitives. - * @return true if the set was modified by the add all operation. - */ - public boolean addAll(long[] array) { - boolean changed = false; - for (int i = array.length; i-- > 0;) { - if (add(array[i])) { - changed = true; - } - } - return changed; - } - -// /** -// * Removes all of the elements in array from the set. -// * -// * @param array an array of long primitives. -// * @return true if the set was modified by the remove all operation. -// */ -// public boolean removeAll(long[] array) { -// boolean changed = false; -// for (int i = array.length; i-- > 0;) { -// if (remove(array[i])) { -// changed = true; -// } -// } -// return changed; -// } - -// /** -// * Removes any values in the set which are not contained in -// * array. -// * -// * @param array an array of long primitives. -// * @return true if the set was modified by the retain all operation -// */ -// public boolean retainAll(long[] array) { -// boolean changed = false; -// Arrays.sort(array); -// long[] set = _set; - -// for (int i = set.length; i-- > 0;) { -// if (set[i] != this._FREE && (Arrays.binarySearch(array,set[i]) < 0)) { -// remove(set[i]); -// changed = true; -// } -// } -// return changed; -// } - -} // TStatelessLongHashSet diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessLongIterator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessLongIterator.java deleted file mode 100644 index c4774111c..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessLongIterator.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -/* - * Contains code from GNU Trove having the license below. - * - * Copyright (c) 2001, Eric D. Friedman All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package com.gemstone.gemfire.internal.cache; - -import com.gemstone.gnu.trove.*; -import java.util.ConcurrentModificationException; - -/** - * Iterator for long collections. - * - * @author darrel - */ -public class TStatelessLongIterator extends TIterator { - /** the collection on which the iterator operates */ - private final TStatelessLongHash _hash; - - /** - * Creates a TStatelessLongIterator for the elements in the specified collection. - */ - public TStatelessLongIterator(TStatelessLongHash hash) { - super(hash); - this._hash = hash; - } - - /** - * Advances the iterator to the next element in the underlying collection - * and returns it. - * - * @return the next long in the collection - * @exception java.util.NoSuchElementException if the iterator is already exhausted - */ - public long next() { - moveToNextIndex(); - return _hash._set[_index]; - } - /** - * Returns the index of the next value in the data structure - * or a negative value if the iterator is exhausted. - * - * @return an int value - * @exception ConcurrentModificationException if the underlying collection's - * size has been modified since the iterator was created. - */ - @Override - protected final int nextIndex() { - if (_expectedSize != _hash.size()) { - throw new ConcurrentModificationException(); - } - - long[] set = _hash._set; - long FREE = _hash.getFreeValue(); - int i = _index; - while (i-- > 0 && (set[i] == FREE)) ; - return i; - } -}// TStatelessLongIterator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessLongObjectHashMap.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessLongObjectHashMap.java deleted file mode 100644 index 4695220bf..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessLongObjectHashMap.java +++ /dev/null @@ -1,480 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -/* - * Contains code from GNU Trove having the license below. - * - * Copyright (c) 2001, Eric D. Friedman All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package com.gemstone.gemfire.internal.cache; - -import com.gemstone.gnu.trove.*; -import java.util.Arrays; - -/** - * An open addressed Map implementation for long keys and Object values. - * - * @author darrel - */ -public class TStatelessLongObjectHashMap extends TStatelessLongHash { - /** the values of the map */ - protected transient Object[] _values; - - /** - * Creates a new TStatelessLongObjectHashMap instance with the default - * capacity and load factor. - */ - public TStatelessLongObjectHashMap(long freeValue) { - super(freeValue); - } - - /** - * Creates a new TStatelessLongObjectHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the default load factor. - * - * @param initialCapacity an int value - */ - public TStatelessLongObjectHashMap(long freeValue, int initialCapacity) { - super(freeValue, initialCapacity); - } - - /** - * Creates a new TStatelessLongObjectHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the specified load factor. - * - * @param initialCapacity an int value - * @param loadFactor a float value - */ - public TStatelessLongObjectHashMap(long freeValue, int initialCapacity, float loadFactor) { - super(freeValue, initialCapacity, loadFactor); - } - - /** - * Creates a new TStatelessLongObjectHashMap instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TStatelessLongObjectHashMap(long freeValue, TLongHashingStrategy strategy) { - super(freeValue, strategy); - } - - /** - * Creates a new TStatelessLongObjectHashMap instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TStatelessLongObjectHashMap(long freeValue, int initialCapacity, TLongHashingStrategy strategy) { - super(freeValue, initialCapacity, strategy); - } - - /** - * Creates a new TStatelessLongObjectHashMap instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TStatelessLongObjectHashMap(long freeValue, int initialCapacity, float loadFactor, TLongHashingStrategy strategy) { - super(freeValue, initialCapacity, loadFactor, strategy); - } - - /** - * @return a deep clone of this collection - */ - @Override - public Object clone() { - TStatelessLongObjectHashMap m = (TStatelessLongObjectHashMap)super.clone(); - m._values = this._values.clone(); - return m; - } - - /** - * @return a TStatelessLongObjectIterator with access to this map's keys and values - */ - public TStatelessLongObjectIterator iterator() { - return new TStatelessLongObjectIterator(this); - } - - /** - * initializes the hashtable to a prime capacity which is at least - * initialCapacity + 1. - * - * @param initialCapacity an int value - * @return the actual capacity chosen - */ - @Override - protected int setUp(int initialCapacity) { - int capacity; - - capacity = super.setUp(initialCapacity); - _values = new Object[capacity]; - return capacity; - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an long value - * @param value an Object value - * @return the previous value associated with key, - * or null if none was found. - */ - public Object put(long key, Object value) { - long previousKey; - Object previous = null; - int index = insertionIndex(key); - boolean isNewMapping = true; - if (index < 0) { - index = -index -1; - previous = _values[index]; - isNewMapping = false; - } - previousKey = _set[index]; - _set[index] = key; - _values[index] = value; - if (isNewMapping) { - postInsertHook(previousKey == this._FREE); - } - - return previous; - } - - /** - * rehashes the map to the new capacity. - * - * @param newCapacity an int value - */ - @Override - protected void rehash(int newCapacity) { - int oldCapacity = _set.length; - long oldKeys[] = _set; - Object oldVals[] = _values; - - _set = new long[newCapacity]; - if (this._FREE != 0) { - Arrays.fill(_set, this._FREE); - } - _values = new Object[newCapacity]; - - for (int i = oldCapacity; i-- > 0;) { - if(oldKeys[i] != this._FREE) { - long o = oldKeys[i]; - int index = insertionIndex(o); - _set[index] = o; - _values[index] = oldVals[i]; - } - } - } - - /** - * retrieves the value for key - * - * @param key an long value - * @return the value of key or null if no such mapping exists. - */ - public Object get(long key) { - int index = index(key); - return index < 0 ? null : _values[index]; - } - - /** - * Empties the map. - * - */ - @Override - public void clear() { - super.clear(); - long[] keys = _set; - Object[] vals = _values; - - for (int i = keys.length; i-- > 0;) { - keys[i] = this._FREE; - vals[i] = null; - } - } - -// /** -// * Deletes a key/value pair from the map. -// * -// * @param key an long value -// * @return an Object value, or null if no mapping for key exists -// */ -// public Object remove(long key) { -// Object prev = null; -// int index = index(key); -// if (index >= 0) { -// prev = _values[index]; -// removeAt(index); // clear key,state; adjust size -// } -// return prev; -// } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return a boolean value - */ - @Override - public boolean equals(Object other) { - if (! (other instanceof TStatelessLongObjectHashMap)) { - return false; - } - TStatelessLongObjectHashMap that = (TStatelessLongObjectHashMap)other; - if (that.size() != this.size()) { - return false; - } - return forEachEntry(new EqProcedure(that)); - } - - @Override - public int hashCode() { - HashProcedure p = new HashProcedure(); - forEachEntry(p); - return p.getHashCode(); - } - - protected final class HashProcedure implements TLongObjectProcedure { - private int h = 0; - - public int getHashCode() { - return h; - } - - public final boolean execute(long key, Object value) { - h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); - return true; - } - } - - private static final class EqProcedure implements TLongObjectProcedure { - private final TStatelessLongObjectHashMap _otherMap; - - EqProcedure(TStatelessLongObjectHashMap otherMap) { - _otherMap = otherMap; - } - - public final boolean execute(long key, Object value) { - int index = _otherMap.index(key); - if (index >= 0 && eq(value, _otherMap.get(key))) { - return true; - } - return false; - } - - /** - * Compare two objects for equality. - */ - private final boolean eq(Object o1, Object o2) { - return o1 == o2 || ((o1 != null) && o1.equals(o2)); - } - - } - -// /** -// * removes the mapping at index from the map. -// * -// * @param index an int value -// */ -// @Override -// protected void removeAt(int index) { -// super.removeAt(index); // clear key, state; adjust size -// _values[index] = null; -// } - - /** - * Returns the values of the map. - * - * @return a Collection value - */ - public Object[] getValues() { - Object[] vals = new Object[size()]; - Object[] v = _values; - long[] keys = _set; - - for (int i = v.length, j = 0; i-- > 0;) { - if (keys[i] != this._FREE) { - vals[j++] = v[i]; - } - } - return vals; - } - - /** - * returns the keys of the map. - * - * @return a Set value - */ - public long[] keys() { - long[] keys = new long[size()]; - long[] k = _set; - - for (int i = k.length, j = 0; i-- > 0;) { - if (k[i] != this._FREE) { - keys[j++] = k[i]; - } - } - return keys; - } - - /** - * checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - public boolean containsValue(Object val) { - long[] keys = _set; - Object[] vals = _values; - - // special case null values so that we don't have to - // perform null checks before every call to equals() - if (null == val) { - for (int i = vals.length; i-- > 0;) { - if (keys[i] != this._FREE && - val == vals[i]) { - return true; - } - } - } else { - for (int i = vals.length; i-- > 0;) { - if (keys[i] != this._FREE && - (val == vals[i] || val.equals(vals[i]))) { - return true; - } - } - } // end of else - return false; - } - - - /** - * checks for the present of key in the keys of the map. - * - * @param key an long value - * @return a boolean value - */ - public boolean containsKey(long key) { - return contains(key); - } - - /** - * Executes procedure for each key in the map. - * - * @param procedure a TLongProcedure value - * @return false if the loop over the keys terminated because - * the procedure returned false for some key. - */ - public boolean forEachKey(TLongProcedure procedure) { - return forEach(procedure); - } - - /** - * Executes procedure for each value in the map. - * - * @param procedure a TObjectProcedure value - * @return false if the loop over the values terminated because - * the procedure returned false for some value. - */ - public boolean forEachValue(TObjectProcedure procedure) { - long[] keys = _set; - Object[] values = _values; - for (int i = values.length; i-- > 0;) { - if (keys[i] != this._FREE && ! procedure.execute(values[i])) { - return false; - } - } - return true; - } - - /** - * Executes procedure for each key/value entry in the - * map. - * - * @param procedure a TOLongObjectProcedure value - * @return false if the loop over the entries terminated because - * the procedure returned false for some entry. - */ - public boolean forEachEntry(TLongObjectProcedure procedure) { - long[] keys = _set; - Object[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (keys[i] != this._FREE && ! procedure.execute(keys[i],values[i])) { - return false; - } - } - return true; - } - -// /** -// * Retains only those entries in the map for which the procedure -// * returns a true value. -// * -// * @param procedure determines which entries to keep -// * @return true if the map was modified. -// */ -// public boolean retainEntries(TLongObjectProcedure procedure) { -// boolean modified = false; -// long[] keys = _set; -// Object[] values = _values; -// for (int i = keys.length; i-- > 0;) { -// if (keys[i] != this._FREE && ! procedure.execute(keys[i],values[i])) { -// removeAt(i); -// modified = true; -// } -// } -// return modified; -// } - - /** - * Transform the values in this map using function. - * - * @param function a TObjectFunction value - */ - public void transformValues(TObjectFunction function) { - long[] keys = _set; - Object[] values = _values; - for (int i = values.length; i-- > 0;) { - if (_set[i] != this._FREE) { - values[i] = function.execute(values[i]); - } - } - } - -} // TStatelessLongObjectHashMap diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessLongObjectIterator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessLongObjectIterator.java deleted file mode 100644 index 4876b3d36..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessLongObjectIterator.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -/* - * Contains code from GNU Trove having the license below. - * - * Copyright (c) 2001, Eric D. Friedman All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package com.gemstone.gemfire.internal.cache; - -import com.gemstone.gnu.trove.*; -import java.util.ConcurrentModificationException; - -/** - * Iterator for maps of type long and Object. - * - * @author darrel - */ - -public class TStatelessLongObjectIterator extends TIterator { - /** the collection being iterated over */ - private final TStatelessLongObjectHashMap _map; - - /** - * Creates an iterator over the specified map - */ - public TStatelessLongObjectIterator(TStatelessLongObjectHashMap map) { - super(map); - this._map = map; - } - - /** - * Moves the iterator forward to the next entry in the underlying map. - * - * @exception java.util.NoSuchElementException if the iterator is already exhausted - */ - public void advance() { - moveToNextIndex(); - } - - /** - * Provides access to the key of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the key of the entry at the iterator's current position. - */ - public long key() { - return _map._set[_index]; - } - - /** - * Provides access to the value of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the value of the entry at the iterator's current position. - */ - public Object value() { - return _map._values[_index]; - } - - /** - * Replace the value of the mapping at the iterator's position with the - * specified value. Note that you must advance() the iterator at - * least once before invoking this method. - * - * @param val the value to set in the current entry - * @return the old value of the entry. - */ - public Object setValue(Object val) { - Object old = value(); - _map._values[_index] = val; - return old; - } - /** - * Returns the index of the next value in the data structure - * or a negative value if the iterator is exhausted. - * - * @return an int value - * @exception ConcurrentModificationException if the underlying collection's - * size has been modified since the iterator was created. - */ - @Override - protected final int nextIndex() { - if (_expectedSize != _hash.size()) { - throw new ConcurrentModificationException(); - } - - long[] keys = _map._set; - long FREE = _map.getFreeValue(); - int i = _index; - while (i-- > 0 && (keys[i] == FREE)) ; - return i; - } -}// TStatelessLongObjectIterator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessPrimitiveHash.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessPrimitiveHash.java deleted file mode 100644 index ff57ce035..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/cache/TStatelessPrimitiveHash.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package com.gemstone.gemfire.internal.cache; - -import com.gemstone.gnu.trove.*; - -/** - * The base class for hashtables of primitive values. - * Each subclass is responsible to reserve a primitive value for - * indicating that a slot is FREE. - * This saves memory compared to TPrimitiveHash that has a byte[]. - * We also lose the distinction of FREE vs REMOVED so remove is not allowed - * on stateless collections. - * If needed remove support can be added by adding another reserved primitive - * value to indicate a REMOVE. - * - * @author darrel - */ - -abstract public class TStatelessPrimitiveHash extends THash { - - /** - * Creates a new THash instance with the default - * capacity and load factor. - */ - public TStatelessPrimitiveHash() { - super(); - } - - /** - * Creates a new TStatelessPrimitiveHash instance with a prime - * capacity at or near the specified capacity and with the default - * load factor. - * - * @param initialCapacity an int value - */ - public TStatelessPrimitiveHash(int initialCapacity) { - this(initialCapacity, DEFAULT_LOAD_FACTOR); - } - - @Override - protected void removeAt(int index) { - throw new IllegalStateException("remove not allowed on stateless classes"); - } - - /** - * Creates a new TStatelessPrimitiveHash instance with a prime - * capacity at or near the minimum needed to hold - * initialCapacity elements with load factor - * loadFactor without triggering a rehash. - * - * @param initialCapacity an int value - * @param loadFactor a float value - */ - public TStatelessPrimitiveHash(int initialCapacity, float loadFactor) { - super(); - _loadFactor = loadFactor; - setUp((int)Math.ceil(initialCapacity / loadFactor)); - } - - @Override - public Object clone() { - TStatelessPrimitiveHash h = (TStatelessPrimitiveHash)super.clone(); - return h; - } -} // TStatelessPrimitiveHash diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/concurrent/ConcurrentTHashSegment.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/concurrent/ConcurrentTHashSegment.java index c3ca64e69..8737ac460 100644 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/concurrent/ConcurrentTHashSegment.java +++ b/lgpl/gemfire-trove/src/main/java/com/gemstone/gemfire/internal/concurrent/ConcurrentTHashSegment.java @@ -217,13 +217,14 @@ public final Object create(final K key, Object old = set[index]; this.newValueInsert = true; Object e = valueCreator.newValue(key, context, createParams, this); - if (this.newValueInsert) { - set[index] = e; + if (e != null) { + if (this.newValueInsert) { + set[index] = e; - postInsertHook(old == null); + postInsertHook(old == null); + } return e; - } - else { + } else { return null; } } finally { diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/SerializationProcedure.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/SerializationProcedure.java index cadb05088..b17c4d6be 100644 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/SerializationProcedure.java +++ b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/SerializationProcedure.java @@ -38,32 +38,11 @@ * @version $Id: SerializationProcedure.java,v 1.3 2002/07/08 23:54:13 ericdf Exp $ */ -class SerializationProcedure implements TDoubleDoubleProcedure, - TDoubleFloatProcedure, - TDoubleIntProcedure, - TDoubleLongProcedure, - TDoubleObjectProcedure, - TDoubleProcedure, - TFloatDoubleProcedure, - TFloatFloatProcedure, - TFloatIntProcedure, - TFloatLongProcedure, - TFloatObjectProcedure, - TFloatProcedure, - TIntDoubleProcedure, - TIntFloatProcedure, +class SerializationProcedure implements TIntIntProcedure, - TIntLongProcedure, TIntObjectProcedure, TIntProcedure, - TLongDoubleProcedure, - TLongFloatProcedure, - TLongIntProcedure, - TLongLongProcedure, - TLongObjectProcedure, TLongProcedure, - TObjectDoubleProcedure, - TObjectFloatProcedure, TObjectIntProcedure, TObjectLongProcedure, TObjectObjectProcedure, @@ -86,16 +65,6 @@ public boolean execute(int val) { return true; } - public boolean execute(double val) { - try { - stream.writeDouble(val); - } catch (IOException e) { - this.exception = e; - return false; - } - return true; - } - public boolean execute(long val) { try { stream.writeLong(val); @@ -106,16 +75,6 @@ public boolean execute(long val) { return true; } - public boolean execute(float val) { - try { - stream.writeFloat(val); - } catch (IOException e) { - this.exception = e; - return false; - } - return true; - } - public boolean execute(Object val) { try { stream.writeObject(val); @@ -159,28 +118,6 @@ public boolean execute(Object key, long val) { return true; } - public boolean execute(Object key, double val) { - try { - stream.writeObject(key); - stream.writeDouble(val); - } catch (IOException e) { - this.exception = e; - return false; - } - return true; - } - - public boolean execute(Object key, float val) { - try { - stream.writeObject(key); - stream.writeFloat(val); - } catch (IOException e) { - this.exception = e; - return false; - } - return true; - } - public boolean execute(int key, Object val) { try { stream.writeInt(key); @@ -202,202 +139,4 @@ public boolean execute(int key, int val) { } return true; } - - public boolean execute(int key, long val) { - try { - stream.writeInt(key); - stream.writeLong(val); - } catch (IOException e) { - this.exception = e; - return false; - } - return true; - } - - public boolean execute(int key, double val) { - try { - stream.writeInt(key); - stream.writeDouble(val); - } catch (IOException e) { - this.exception = e; - return false; - } - return true; - } - - public boolean execute(int key, float val) { - try { - stream.writeInt(key); - stream.writeFloat(val); - } catch (IOException e) { - this.exception = e; - return false; - } - return true; - } - - public boolean execute(long key, Object val) { - try { - stream.writeLong(key); - stream.writeObject(val); - } catch (IOException e) { - this.exception = e; - return false; - } - return true; - } - - public boolean execute(long key, int val) { - try { - stream.writeLong(key); - stream.writeInt(val); - } catch (IOException e) { - this.exception = e; - return false; - } - return true; - } - - public boolean execute(long key, long val) { - try { - stream.writeLong(key); - stream.writeLong(val); - } catch (IOException e) { - this.exception = e; - return false; - } - return true; - } - - public boolean execute(long key, double val) { - try { - stream.writeLong(key); - stream.writeDouble(val); - } catch (IOException e) { - this.exception = e; - return false; - } - return true; - } - - public boolean execute(long key, float val) { - try { - stream.writeLong(key); - stream.writeFloat(val); - } catch (IOException e) { - this.exception = e; - return false; - } - return true; - } - - public boolean execute(double key, Object val) { - try { - stream.writeDouble(key); - stream.writeObject(val); - } catch (IOException e) { - this.exception = e; - return false; - } - return true; - } - - public boolean execute(double key, int val) { - try { - stream.writeDouble(key); - stream.writeInt(val); - } catch (IOException e) { - this.exception = e; - return false; - } - return true; - } - - public boolean execute(double key, long val) { - try { - stream.writeDouble(key); - stream.writeLong(val); - } catch (IOException e) { - this.exception = e; - return false; - } - return true; - } - - public boolean execute(double key, double val) { - try { - stream.writeDouble(key); - stream.writeDouble(val); - } catch (IOException e) { - this.exception = e; - return false; - } - return true; - } - - public boolean execute(double key, float val) { - try { - stream.writeDouble(key); - stream.writeFloat(val); - } catch (IOException e) { - this.exception = e; - return false; - } - return true; - } - - public boolean execute(float key, Object val) { - try { - stream.writeFloat(key); - stream.writeObject(val); - } catch (IOException e) { - this.exception = e; - return false; - } - return true; - } - - public boolean execute(float key, int val) { - try { - stream.writeFloat(key); - stream.writeInt(val); - } catch (IOException e) { - this.exception = e; - return false; - } - return true; - } - - public boolean execute(float key, long val) { - try { - stream.writeFloat(key); - stream.writeLong(val); - } catch (IOException e) { - this.exception = e; - return false; - } - return true; - } - - public boolean execute(float key, double val) { - try { - stream.writeFloat(key); - stream.writeDouble(val); - } catch (IOException e) { - this.exception = e; - return false; - } - return true; - } - - public boolean execute(float key, float val) { - try { - stream.writeFloat(key); - stream.writeFloat(val); - } catch (IOException e) { - this.exception = e; - return false; - } - return true; - } }// SerializationProcedure diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleArrayList.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleArrayList.java deleted file mode 100644 index 7d20cc4b4..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleArrayList.java +++ /dev/null @@ -1,886 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove; - -import java.io.Serializable; -import java.util.Arrays; -import java.util.Random; - -/** - * A resizable, array-backed list of double primitives. - * - * Created: Sat Dec 29 14:21:12 2001 - * - * @author Eric D. Friedman - * @version $Id: TDoubleArrayList.java,v 1.15 2003/11/09 09:22:22 ericdf Exp $ - */ - -public class TDoubleArrayList implements Serializable, Cloneable { - - private static final long serialVersionUID = 7370405796750074843L; - - /** the data of the list */ - protected double[] _data; - - /** the index after the last entry in the list */ - protected int _pos; - - /** the default capacity for new lists */ - protected static final int DEFAULT_CAPACITY = 10; - - /** - * Creates a new TDoubleArrayList instance with the - * default capacity. - */ - public TDoubleArrayList() { - this(DEFAULT_CAPACITY); - } - - /** - * Creates a new TDoubleArrayList instance with the - * specified capacity. - * - * @param capacity an int value - */ - public TDoubleArrayList(int capacity) { - _data = new double[capacity]; - _pos = 0; - } - - /** - * Creates a new TDoubleArrayList instance whose - * capacity is the greater of the length of values and - * DEFAULT_CAPACITY and whose initial contents are the specified - * values. - * - * @param values an double[] value - */ - public TDoubleArrayList(double[] values) { - this(Math.max(values.length, DEFAULT_CAPACITY)); - add(values); - } - - // sizing - - /** - * Grow the internal array as needed to accomodate the specified - * number of elements. The size of the array doubles on each - * resize unless capacity requires more than twice the - * current capacity. - * - * @param capacity an int value - */ - public void ensureCapacity(int capacity) { - if (capacity > _data.length) { - int newCap = Math.max(_data.length << 1, capacity); - double[] tmp = new double[newCap]; - System.arraycopy(_data, 0, tmp, 0, _data.length); - _data = tmp; - } - } - - /** - * Returns the number of values in the list. - * - * @return the number of values in the list. - */ - public int size() { - return _pos; - } - - /** - * Tests whether this list contains any values. - * - * @return true if the list is empty. - */ - public boolean isEmpty() { - return _pos == 0; - } - - /** - * Sheds any excess capacity above and beyond the current size of - * the list. - */ - public void trimToSize() { - if (_data.length > size()) { - double[] tmp = new double[size()]; - toNativeArray(tmp, 0, tmp.length); - _data = tmp; - } - } - - // modifying - - /** - * Adds val to the end of the list, growing as needed. - * - * @param val an double value - */ - public void add(double val) { - ensureCapacity(_pos + 1); - _data[_pos++] = val; - } - - /** - * Adds the values in the array vals to the end of the - * list, in order. - * - * @param vals an double[] value - */ - public void add(double[] vals) { - add(vals, 0, vals.length); - } - - /** - * Adds a subset of the values in the array vals to the - * end of the list, in order. - * - * @param vals an double[] value - * @param offset the offset at which to start copying - * @param length the number of values to copy. - */ - public void add(double[] vals, int offset, int length) { - ensureCapacity(_pos + length); - System.arraycopy(vals, offset, _data, _pos, length); - _pos += length; - } - - /** - * Inserts value into the list at offset. All - * values including and to the right of offset are shifted - * to the right. - * - * @param offset an int value - * @param value an double value - */ - public void insert(int offset, double value) { - if (offset == _pos) { - add(value); - return; - } - ensureCapacity(_pos + 1); - // shift right - System.arraycopy(_data, offset, _data, offset + 1, _pos - offset); - // insert - _data[offset] = value; - _pos++; - } - - /** - * Inserts the array of values into the list at - * offset. All values including and to the right of - * offset are shifted to the right. - * - * @param offset an int value - * @param values an double[] value - */ - public void insert(int offset, double[] values) { - insert(offset, values, 0, values.length); - } - - /** - * Inserts a slice of the array of values into the list - * at offset. All values including and to the right of - * offset are shifted to the right. - * - * @param offset an int value - * @param values an double[] value - * @param valOffset the offset in the values array at which to - * start copying. - * @param len the number of values to copy from the values array - */ - public void insert(int offset, double[] values, int valOffset, int len) { - if (offset == _pos) { - add(values, valOffset, len); - return; - } - - ensureCapacity(_pos + len); - // shift right - System.arraycopy(_data, offset, _data, offset + len, _pos - offset); - // insert - System.arraycopy(values, valOffset, _data, offset, len); - _pos += len; - } - - /** - * Returns the value at the specified offset. - * - * @param offset an int value - * @return an double value - */ - public double get(int offset) { - if (offset >= _pos) { - throw new ArrayIndexOutOfBoundsException(offset); - } - return _data[offset]; - } - - /** - * Returns the value at the specified offset without doing any - * bounds checking. - * - * @param offset an int value - * @return an double value - */ - public double getQuick(int offset) { - return _data[offset]; - } - - /** - * Sets the value at the specified offset. - * - * @param offset an int value - * @param val an double value - */ - public void set(int offset, double val) { - if (offset >= _pos) { - throw new ArrayIndexOutOfBoundsException(offset); - } - _data[offset] = val; - } - - /** - * Sets the value at the specified offset and returns the - * previously stored value. - * - * @param offset an int value - * @param val an double value - * @return the value previously stored at offset. - */ - public double getSet(int offset, double val) { - if (offset >= _pos) { - throw new ArrayIndexOutOfBoundsException(offset); - } - double old = _data[offset]; - _data[offset] = val; - return old; - } - - /** - * Replace the values in the list starting at offset with - * the contents of the values array. - * - * @param offset the first offset to replace - * @param values the source of the new values - */ - public void set(int offset, double[] values) { - set(offset, values, 0, values.length); - } - - /** - * Replace the values in the list starting at offset with - * length values from the values array, starting - * at valOffset. - * - * @param offset the first offset to replace - * @param values the source of the new values - * @param valOffset the first value to copy from the values array - * @param length the number of values to copy - */ - public void set(int offset, double[] values, int valOffset, int length) { - if (offset < 0 || offset + length >= _pos) { - throw new ArrayIndexOutOfBoundsException(offset); - } - System.arraycopy(values, valOffset, _data, offset, length); - } - - /** - * Sets the value at the specified offset without doing any bounds - * checking. - * - * @param offset an int value - * @param val an double value - */ - public void setQuick(int offset, double val) { - _data[offset] = val; - } - - /** - * Flushes the internal state of the list, resetting the capacity - * to the default. - */ - public void clear() { - clear(DEFAULT_CAPACITY); - } - - /** - * Flushes the internal state of the list, setting the capacity of - * the empty list to capacity. - * - * @param capacity an int value - */ - public void clear(int capacity) { - _data = new double[capacity]; - _pos = 0; - } - - /** - * Sets the size of the list to 0, but does not change its - * capacity. This method can be used as an alternative to the - * {@link #clear() clear} method if you want to recyle a list without - * allocating new backing arrays. - * - * @see #clear() - */ - public void reset() { - _pos = 0; - fill(0); - } - - /** - * Sets the size of the list to 0, but does not change its - * capacity. This method can be used as an alternative to the - * {@link #clear() clear} method if you want to recyle a list - * without allocating new backing arrays. This method differs - * from {@link #reset reset} in that it does not clear the old - * values in the backing array. Thus, it is possible for {@link - * #getQuick getQuick} to return stale data if this method is used - * and the caller is careless about bounds checking. - * - * @see #reset - * @see #clear() - * @see #getQuick - */ - public void resetQuick() { - _pos = 0; - } - - /** - * Removes the value at offset from the list. - * - * @param offset an int value - * @return the value previously stored at offset. - */ - public double remove(int offset) { - double old = get(offset); - remove(offset, 1); - return old; - } - - /** - * Removes length values from the list, starting at - * offset - * - * @param offset an int value - * @param length an int value - */ - public void remove(int offset, int length) { - if (offset < 0 || offset >= _pos) { - throw new ArrayIndexOutOfBoundsException(offset); - } - - if (offset == 0) { - // data at the front - System.arraycopy(_data, length, _data, 0, _pos - length); - } else if (_pos - length == offset) { - // no copy to make, decrementing pos "deletes" values at - // the end - } else { - // data in the middle - System.arraycopy(_data, offset + length, - _data, offset, _pos - (offset + length)); - } - _pos -= length; - // no need to clear old values beyond _pos, because this is a - // primitive collection and 0 takes as much room as any other - // value - } - - /** - * Transform each value in the list using the specified function. - * - * @param function a TDoubleFunction value - */ - public void transformValues(TDoubleFunction function) { - for (int i = _pos; i-- > 0;) { - _data[i] = function.execute(_data[i]); - } - } - - /** - * Reverse the order of the elements in the list. - */ - public void reverse() { - reverse(0, _pos); - } - - /** - * Reverse the order of the elements in the range of the list. - * - * @param from the inclusive index at which to start reversing - * @param to the exclusive index at which to stop reversing - */ - public void reverse(int from, int to) { - if (from == to) { - return; // nothing to do - } - if (from > to) { - throw new IllegalArgumentException("from cannot be greater than to"); - } - for (int i = from, j = to - 1; i < j; i++, j--) { - swap(i, j); - } - } - - /** - * Shuffle the elements of the list using the specified random - * number generator. - * - * @param rand a Random value - */ - public void shuffle(Random rand) { - for (int i = _pos; i-- > 1;) { - swap(i, rand.nextInt(i)); - } - } - - /** - * Swap the values at offsets i and j. - * - * @param i an offset into the data array - * @param j an offset into the data array - */ - private final void swap(int i, int j) { - double tmp = _data[i]; - _data[i] = _data[j]; - _data[j] = tmp; - } - - // copying - - /** - * Returns a clone of this list. Since this is a primitive - * collection, this will be a deep clone. - * - * @return a deep clone of the list. - */ - @Override // GemStoneAddition - public Object clone() { - Object o = null; - try { - o = super.clone(); - } catch (CloneNotSupportedException e) { - // it's supported - } // end of try-catch - return o; - } - - /** - * Copies the contents of the list into a native array. - * - * @return an double[] value - */ - public double[] toNativeArray() { - return toNativeArray(0, _pos); - } - - /** - * Copies a slice of the list into a native array. - * - * @param offset the offset at which to start copying - * @param len the number of values to copy. - * @return an double[] value - */ - public double[] toNativeArray(int offset, int len) { - double[] rv = new double[len]; - toNativeArray(rv, offset, len); - return rv; - } - - /** - * Copies a slice of the list into a native array. - * - * @param dest the array to copy into. - * @param offset the offset of the first value to copy - * @param len the number of values to copy. - */ - public void toNativeArray(double[] dest, int offset, int len) { - if (len == 0) { - return; // nothing to copy - } - if (offset < 0 || offset >= _pos) { - throw new ArrayIndexOutOfBoundsException(offset); - } - System.arraycopy(_data, 0, dest, offset, len); - } - - // comparing - - /** - * Compares this list to another list, value by value. - * - * @param other the object to compare against - * @return true if other is a TDoubleArrayList and has exactly the - * same values. - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (other == this) { - return true; - } else if (other instanceof TDoubleArrayList) { - TDoubleArrayList that = (TDoubleArrayList)other; - if (that.size() != this.size()) { - return false; - } else { - for (int i = _pos; i-- > 0;) { - if (this._data[i] != that._data[i]) { - return false; - } - } - return true; - } - } else { - return false; - } - } - - @Override // GemStoneAddition - public int hashCode() { - int h = 0; - for (int i = _pos; i-- > 0;) { - h += HashFunctions.hash(_data[i]); - } - return h; - } - - // procedures - - /** - * Applies the procedure to each value in the list in ascending - * (front to back) order. - * - * @param procedure a TDoubleProcedure value - * @return true if the procedure did not terminate prematurely. - */ - public boolean forEach(TDoubleProcedure procedure) { - for (int i = 0; i < _pos; i++) { - if (! procedure.execute(_data[i])) { - return false; - } - } - return true; - } - - /** - * Applies the procedure to each value in the list in descending - * (back to front) order. - * - * @param procedure a TDoubleProcedure value - * @return true if the procedure did not terminate prematurely. - */ - public boolean forEachDescending(TDoubleProcedure procedure) { - for (int i = _pos; i-- > 0;) { - if (! procedure.execute(_data[i])) { - return false; - } - } - return true; - } - - // sorting - - /** - * Sort the values in the list (ascending) using the Sun quicksort - * implementation. - * - * @see java.util.Arrays#sort(double[]) - */ - public void sort() { - Arrays.sort(_data, 0, _pos); - } - - /** - * Sort a slice of the list (ascending) using the Sun quicksort - * implementation. - * - * @param fromIndex the index at which to start sorting (inclusive) - * @param toIndex the index at which to stop sorting (exclusive) - * @see java.util.Arrays#sort(double[], int, int) - */ - public void sort(int fromIndex, int toIndex) { - Arrays.sort(_data, fromIndex, toIndex); - } - - // filling - - /** - * Fills every slot in the list with the specified value. - * - * @param val the value to use when filling - */ - public void fill(double val) { - Arrays.fill(_data, 0, _pos, val); - } - - /** - * Fills a range in the list with the specified value. - * - * @param fromIndex the offset at which to start filling (inclusive) - * @param toIndex the offset at which to stop filling (exclusive) - * @param val the value to use when filling - */ - public void fill(int fromIndex, int toIndex, double val) { - if (toIndex > _pos) { - ensureCapacity(toIndex); - _pos = toIndex; - } - Arrays.fill(_data, fromIndex, toIndex, val); - } - - // searching - - /** - * Performs a binary search for value in the entire list. - * Note that you must @{link #sort sort} the list before - * doing a search. - * - * @param value the value to search for - * @return the absolute offset in the list of the value, or its - * negative insertion point into the sorted list. - */ - public int binarySearch(double value) { - return binarySearch(value, 0, _pos); - } - - /** - * Performs a binary search for value in the specified - * range. Note that you must @{link #sort sort} the list - * or the range before doing a search. - * - * @param value the value to search for - * @param fromIndex the lower boundary of the range (inclusive) - * @param toIndex the upper boundary of the range (exclusive) - * @return the absolute offset in the list of the value, or its - * negative insertion point into the sorted list. - */ - public int binarySearch(double value, int fromIndex, int toIndex) { - if (fromIndex < 0) { - throw new ArrayIndexOutOfBoundsException(fromIndex); - } - if (toIndex > _pos) { - throw new ArrayIndexOutOfBoundsException(toIndex); - } - - int low = fromIndex; - int high = toIndex - 1; - - while (low <= high) { - int mid = (int)(((long)low + high) >> 1); // GemStoneAddition avoid overflow - double midVal = _data[mid]; - - if (midVal < value) { - low = mid + 1; - } else if (midVal > value) { - high = mid - 1; - } else { - return mid; // value found - } - } - return -(low + 1); // value not found. - } - - /** - * Searches the list front to back for the index of - * value. - * - * @param value an double value - * @return the first offset of the value, or -1 if it is not in - * the list. - * @see #binarySearch(double) for faster searches on sorted lists - */ - public int indexOf(double value) { - return indexOf(0, value); - } - - /** - * Searches the list front to back for the index of - * value, starting at offset. - * - * @param offset the offset at which to start the linear search - * (inclusive) - * @param value an double value - * @return the first offset of the value, or -1 if it is not in - * the list. - * @see #binarySearch(double, int, int) for faster searches on sorted lists - */ - public int indexOf(int offset, double value) { - for (int i = offset; i < _pos; i++) { - if (_data[i] == value) { - return i; - } - } - return -1; - } - - /** - * Searches the list back to front for the last index of - * value. - * - * @param value an double value - * @return the last offset of the value, or -1 if it is not in - * the list. - * @see #binarySearch(double) for faster searches on sorted lists - */ - public int lastIndexOf(double value) { - return lastIndexOf(_pos, value); - } - - /** - * Searches the list back to front for the last index of - * value, starting at offset. - * - * @param offset the offset at which to start the linear search - * (exclusive) - * @param value an double value - * @return the last offset of the value, or -1 if it is not in - * the list. - * @see #binarySearch(double, int, int) for faster searches on sorted lists - */ - public int lastIndexOf(int offset, double value) { - for (int i = offset; i-- > 0;) { - if (_data[i] == value) { - return i; - } - } - return -1; - } - - /** - * Searches the list for value - * - * @param value an double value - * @return true if value is in the list. - */ - public boolean contains(double value) { - return lastIndexOf(value) >= 0; - } - - /** - * Searches the list for values satisfying condition in - * the manner of the *nix grep utility. - * - * @param condition a condition to apply to each element in the list - * @return a list of values which match the condition. - */ - public TDoubleArrayList grep(TDoubleProcedure condition) { - TDoubleArrayList list = new TDoubleArrayList(); - for (int i = 0; i < _pos; i++) { - if (condition.execute(_data[i])) { - list.add(_data[i]); - } - } - return list; - } - - /** - * Searches the list for values which do not satisfy - * condition. This is akin to *nix grep -v. - * - * @param condition a condition to apply to each element in the list - * @return a list of values which do not match the condition. - */ - public TDoubleArrayList inverseGrep(TDoubleProcedure condition) { - TDoubleArrayList list = new TDoubleArrayList(); - for (int i = 0; i < _pos; i++) { - if (! condition.execute(_data[i])) { - list.add(_data[i]); - } - } - return list; - } - - /** - * Finds the maximum value in the list. - * - * @return the largest value in the list. - * @exception IllegalStateException if the list is empty - */ - public double max() { - if (size() == 0) { - throw new IllegalStateException("cannot find maximum of an empty list"); - } - double max = _data[_pos - 1]; - for (int i = _pos - 1; i-- > 0;) { - if (_data[i] > max) { - max = _data[i]; - } - } - return max; - } - - /** - * Finds the minimum value in the list. - * - * @return the smallest value in the list. - * @exception IllegalStateException if the list is empty - */ - public double min() { - if (size() == 0) { - throw new IllegalStateException("cannot find minimum of an empty list"); - } - double min = _data[_pos - 1]; - for (int i = _pos - 1; i-- > 0;) { - if (_data[i] < min) { - min = _data[i]; - } - } - return min; - } - - // stringification - - /** - * Returns a String representation of the list, front to back. - * - * @return a String value - */ - @Override // GemStoneAddition - public String toString() { - StringBuffer buf = new StringBuffer("{"); - for (int i = 0, end = _pos - 1; i < end; i++) { - buf.append(_data[i]); - buf.append(", "); - } - if (size() > 0) { - buf.append(_data[_pos - 1]); - } - buf.append("}"); - return buf.toString(); - } -} // TDoubleArrayList diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleDoubleHashMap.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleDoubleHashMap.java deleted file mode 100644 index b937a633f..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleDoubleHashMap.java +++ /dev/null @@ -1,535 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - -/** - * An open addressed Map implementation for double keys and double values. - * - * Created: Sun Nov 4 08:52:45 2001 - * - * @author Eric D. Friedman - * @version $Id: TDoubleDoubleHashMap.java,v 1.15 2003/11/21 17:32:30 ericdf Exp $ - */ -public class TDoubleDoubleHashMap extends TDoubleHash implements Serializable { - - private static final long serialVersionUID = -7133512819442877511L; - /** the values of the map */ - protected transient double[] _values; - - /** - * Creates a new TDoubleDoubleHashMap instance with the default - * capacity and load factor. - */ - public TDoubleDoubleHashMap() { - super(); - } - - /** - * Creates a new TDoubleDoubleHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the default load factor. - * - * @param initialCapacity an int value - */ - public TDoubleDoubleHashMap(int initialCapacity) { - super(initialCapacity); - } - - /** - * Creates a new TDoubleDoubleHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the specified load factor. - * - * @param initialCapacity an int value - * @param loadFactor a float value - */ - public TDoubleDoubleHashMap(int initialCapacity, float loadFactor) { - super(initialCapacity, loadFactor); - } - - /** - * Creates a new TDoubleDoubleHashMap instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TDoubleDoubleHashMap(TDoubleHashingStrategy strategy) { - super(strategy); - } - - /** - * Creates a new TDoubleDoubleHashMap instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TDoubleDoubleHashMap(int initialCapacity, TDoubleHashingStrategy strategy) { - super(initialCapacity, strategy); - } - - /** - * Creates a new TDoubleDoubleHashMap instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TDoubleDoubleHashMap(int initialCapacity, float loadFactor, TDoubleHashingStrategy strategy) { - super(initialCapacity, loadFactor, strategy); - } - - /** - * @return a deep clone of this collection - */ - @Override // GemStoneAddition - public Object clone() { - TDoubleDoubleHashMap m = (TDoubleDoubleHashMap)super.clone(); - m._values = this._values.clone(); - return m; - } - - /** - * @return a TDoubleDoubleIterator with access to this map's keys and values - */ - public TDoubleDoubleIterator iterator() { - return new TDoubleDoubleIterator(this); - } - - /** - * initializes the hashtable to a prime capacity which is at least - * initialCapacity + 1. - * - * @param initialCapacity an int value - * @return the actual capacity chosen - */ - @Override // GemStoneAddition - protected int setUp(int initialCapacity) { - int capacity; - - capacity = super.setUp(initialCapacity); - _values = new double[capacity]; - return capacity; - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an double value - * @param value an double value - * @return the previous value associated with key, - * or (double)0 if none was found. - */ - public double put(double key, double value) { - byte previousState; - double previous = 0; - int index = insertionIndex(key); - boolean isNewMapping = true; - if (index < 0) { - index = -index -1; - previous = _values[index]; - isNewMapping = false; - } - previousState = _states[index]; - _set[index] = key; - _states[index] = FULL; - _values[index] = value; - if (isNewMapping) { - postInsertHook(previousState == FREE); - } - - return previous; - } - - /** - * rehashes the map to the new capacity. - * - * @param newCapacity an int value - */ - @Override // GemStoneAddition - protected void rehash(int newCapacity) { - int oldCapacity = _set.length; - double oldKeys[] = _set; - double oldVals[] = _values; - byte oldStates[] = _states; - - _set = new double[newCapacity]; - _values = new double[newCapacity]; - _states = new byte[newCapacity]; - - for (int i = oldCapacity; i-- > 0;) { - if(oldStates[i] == FULL) { - double o = oldKeys[i]; - int index = insertionIndex(o); - _set[index] = o; - _values[index] = oldVals[i]; - _states[index] = FULL; - } - } - } - - /** - * retrieves the value for key - * - * @param key an double value - * @return the value of key or (double)0 if no such mapping exists. - */ - public double get(double key) { - int index = index(key); - return index < 0 ? (double)0 : _values[index]; - } - - /** - * Empties the map. - * - */ - @Override // GemStoneAddition - public void clear() { - super.clear(); - double[] keys = _set; - double[] vals = _values; - byte[] states = _states; - - for (int i = keys.length; i-- > 0;) { - keys[i] = 0; - vals[i] = 0; - states[i] = FREE; - } - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an double value - * @return an double value, or (double)0 if no mapping for key exists - */ - public double remove(double key) { - double prev = 0; - int index = index(key); - if (index >= 0) { - prev = _values[index]; - removeAt(index); // clear key,state; adjust size - } - return prev; - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (! (other instanceof TDoubleDoubleHashMap)) { - return false; - } - TDoubleDoubleHashMap that = (TDoubleDoubleHashMap)other; - if (that.size() != this.size()) { - return false; - } - return forEachEntry(new EqProcedure(that)); - } - - @Override // GemStoneAddition - public int hashCode() { - HashProcedure p = new HashProcedure(); - forEachEntry(p); - return p.getHashCode(); - } - - protected/*GemStoneAddition*/ final class HashProcedure implements TDoubleDoubleProcedure { - private int h = 0; - - public int getHashCode() { - return h; - } - - public final boolean execute(double key, double value) { - h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); - return true; - } - } - - private static final class EqProcedure implements TDoubleDoubleProcedure { - private final TDoubleDoubleHashMap _otherMap; - - EqProcedure(TDoubleDoubleHashMap otherMap) { - _otherMap = otherMap; - } - - public final boolean execute(double key, double value) { - int index = _otherMap.index(key); - if (index >= 0 && eq(value, _otherMap.get(key))) { - return true; - } - return false; - } - - /** - * Compare two doubles for equality. - */ - private final boolean eq(double v1, double v2) { - return v1 == v2; - } - - } - - /** - * removes the mapping at index from the map. - * - * @param index an int value - */ - @Override // GemStoneAddition - protected void removeAt(int index) { - super.removeAt(index); // clear key, state; adjust size - _values[index] = 0; - } - - /** - * Returns the values of the map. - * - * @return a Collection value - */ - public double[] getValues() { - double[] vals = new double[size()]; - double[] v = _values; - byte[] states = _states; - - for (int i = v.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - vals[j++] = v[i]; - } - } - return vals; - } - - /** - * returns the keys of the map. - * - * @return a Set value - */ - public double[] keys() { - double[] keys = new double[size()]; - double[] k = _set; - byte[] states = _states; - - for (int i = k.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - keys[j++] = k[i]; - } - } - return keys; - } - - /** - * checks for the presence of val in the values of the map. - * - * @param val an double value - * @return a boolean value - */ - public boolean containsValue(double val) { - byte[] states = _states; - double[] vals = _values; - - for (int i = vals.length; i-- > 0;) { - if (states[i] == FULL && val == vals[i]) { - return true; - } - } - return false; - } - - - /** - * checks for the present of key in the keys of the map. - * - * @param key an double value - * @return a boolean value - */ - public boolean containsKey(double key) { - return contains(key); - } - - /** - * Executes procedure for each key in the map. - * - * @param procedure a TDoubleProcedure value - * @return false if the loop over the keys terminated because - * the procedure returned false for some key. - */ - public boolean forEachKey(TDoubleProcedure procedure) { - return forEach(procedure); - } - - /** - * Executes procedure for each value in the map. - * - * @param procedure a TDoubleProcedure value - * @return false if the loop over the values terminated because - * the procedure returned false for some value. - */ - public boolean forEachValue(TDoubleProcedure procedure) { - byte[] states = _states; - double[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(values[i])) { - return false; - } - } - return true; - } - - /** - * Executes procedure for each key/value entry in the - * map. - * - * @param procedure a TODoubleDoubleProcedure value - * @return false if the loop over the entries terminated because - * the procedure returned false for some entry. - */ - public boolean forEachEntry(TDoubleDoubleProcedure procedure) { - byte[] states = _states; - double[] keys = _set; - double[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - return false; - } - } - return true; - } - - /** - * Retains only those entries in the map for which the procedure - * returns a true value. - * - * @param procedure determines which entries to keep - * @return true if the map was modified. - */ - public boolean retainEntries(TDoubleDoubleProcedure procedure) { - boolean modified = false; - byte[] states = _states; - double[] keys = _set; - double[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - removeAt(i); - modified = true; - } - } - return modified; - } - - /** - * Transform the values in this map using function. - * - * @param function a TDoubleFunction value - */ - public void transformValues(TDoubleFunction function) { - byte[] states = _states; - double[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL) { - values[i] = function.execute(values[i]); - } - } - } - - /** - * Increments the primitive value mapped to key by 1 - * - * @param key the key of the value to increment - * @return true if a mapping was found and modified. - */ - public boolean increment(double key) { - return adjustValue(key, 1); - } - - /** - * Adjusts the primitive value mapped to key. - * - * @param key the key of the value to increment - * @param amount the amount to adjust the value by. - * @return true if a mapping was found and modified. - */ - public boolean adjustValue(double key, double amount) { - int index = index(key); - if (index < 0) { - return false; - } else { - _values[index] += amount; - return true; - } - } - - - private void writeObject(ObjectOutputStream stream) - throws IOException { - stream.defaultWriteObject(); - - // number of entries - stream.writeInt(_size); - - SerializationProcedure writeProcedure = new SerializationProcedure(stream); - if (! forEachEntry(writeProcedure)) { - throw writeProcedure.exception; - } - } - - private void readObject(ObjectInputStream stream) - throws IOException, ClassNotFoundException { - stream.defaultReadObject(); - - int size = stream.readInt(); - setUp(size); - while (size-- > 0) { - double key = stream.readDouble(); - double val = stream.readDouble(); - put(key, val); - } - } -} // TDoubleDoubleHashMap diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleDoubleIterator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleDoubleIterator.java deleted file mode 100644 index 30864a6b6..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleDoubleIterator.java +++ /dev/null @@ -1,145 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Iterator for maps of type double and double. - * - *

The iterator semantics for Trove's primitive maps is slightly different - * from those defined in java.util.Iterator, but still well within - * the scope of the pattern, as defined by Gamma, et al.

- * - *

This iterator does not implicitly advance to the next entry when - * the value at the current position is retrieved. Rather, you must explicitly - * ask the iterator to advance() and then retrieve either the key(), - * the value() or both. This is done so that you have the option, but not - * the obligation, to retrieve keys and/or values as your application requires, and - * without introducing wrapper objects that would carry both. As the iteration is - * stateful, access to the key/value parts of the current map entry happens in - * constant time.

- * - *

In practice, the iterator is akin to a "search finger" that you move from - * position to position. Read or write operations affect the current entry only and - * do not assume responsibility for moving the finger.

- * - *

Here are some sample scenarios for this class of iterator:

- * - *
- * // accessing keys/values through an iterator:
- * for (TDoubleDoubleIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     doSomethingWithValue(it.value());
- *   }
- * }
- * 
- * - *
- * // modifying values in-place through iteration:
- * for (TDoubleDoubleIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.setValue(newValueForKey(it.key()));
- *   }
- * }
- * 
- * - *
- * // deleting entries during iteration:
- * for (TDoubleDoubleIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.remove();
- *   }
- * }
- * 
- * - *
- * // faster iteration by avoiding hasNext():
- * TDoubleDoubleIterator iterator = map.iterator();
- * for (int i = map.size(); i-- > 0;) {    
- *   iterator.advance();     
- *   doSomethingWithKeyAndValue(iterator.key(), iterator.value());
- * }   
- * 
- * - * @author Eric D. Friedman - * @version $Id: TDoubleDoubleIterator.java,v 1.1 2002/09/22 21:53:39 ericdf Exp $ - */ - -public class TDoubleDoubleIterator extends TPrimitiveIterator { - /** the collection being iterated over */ - private final TDoubleDoubleHashMap _map; - - /** - * Creates an iterator over the specified map - */ - public TDoubleDoubleIterator(TDoubleDoubleHashMap map) { - super(map); - this._map = map; - } - - /** - * Moves the iterator forward to the next entry in the underlying map. - * - * @exception java.util.NoSuchElementException if the iterator is already exhausted - */ - public void advance() { - moveToNextIndex(); - } - - /** - * Provides access to the key of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the key of the entry at the iterator's current position. - */ - public double key() { - return _map._set[_index]; - } - - /** - * Provides access to the value of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the value of the entry at the iterator's current position. - */ - public double value() { - return _map._values[_index]; - } - - /** - * Replace the value of the mapping at the iterator's position with the - * specified value. Note that you must advance() the iterator at - * least once before invoking this method. - * - * @param val the value to set in the current entry - * @return the old value of the entry. - */ - public double setValue(double val) { - double old = value(); - _map._values[_index] = val; - return old; - } -}// TDoubleDoubleIterator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleDoubleProcedure.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleDoubleProcedure.java deleted file mode 100644 index a5c4701f9..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleDoubleProcedure.java +++ /dev/null @@ -1,43 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Interface for procedures that take two parameters of type double and double. - * - * Created: Mon Nov 5 22:03:30 2001 - * - * @author Eric D. Friedman - * @version $Id: TDoubleDoubleProcedure.java,v 1.7 2002/09/22 21:53:39 ericdf Exp $ - */ - -public interface TDoubleDoubleProcedure { - - /** - * Executes this procedure. A false return value indicates that - * the application executing this procedure should not invoke this - * procedure again. - * - * @param a an double value - * @param b an double value - * @return true if additional invocations of the procedure are - * allowed. - */ - public boolean execute(double a, double b); -}// TDoubleDoubleProcedure diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleFloatHashMap.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleFloatHashMap.java deleted file mode 100644 index 65e47818a..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleFloatHashMap.java +++ /dev/null @@ -1,535 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - -/** - * An open addressed Map implementation for double keys and float values. - * - * Created: Sun Nov 4 08:52:45 2001 - * - * @author Eric D. Friedman - * @version $Id: TDoubleFloatHashMap.java,v 1.15 2003/11/21 17:32:30 ericdf Exp $ - */ -public class TDoubleFloatHashMap extends TDoubleHash implements Serializable { - - private static final long serialVersionUID = 8218621267291192445L; - /** the values of the map */ - protected transient float[] _values; - - /** - * Creates a new TDoubleFloatHashMap instance with the default - * capacity and load factor. - */ - public TDoubleFloatHashMap() { - super(); - } - - /** - * Creates a new TDoubleFloatHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the default load factor. - * - * @param initialCapacity an int value - */ - public TDoubleFloatHashMap(int initialCapacity) { - super(initialCapacity); - } - - /** - * Creates a new TDoubleFloatHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the specified load factor. - * - * @param initialCapacity an int value - * @param loadFactor a float value - */ - public TDoubleFloatHashMap(int initialCapacity, float loadFactor) { - super(initialCapacity, loadFactor); - } - - /** - * Creates a new TDoubleFloatHashMap instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TDoubleFloatHashMap(TDoubleHashingStrategy strategy) { - super(strategy); - } - - /** - * Creates a new TDoubleFloatHashMap instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TDoubleFloatHashMap(int initialCapacity, TDoubleHashingStrategy strategy) { - super(initialCapacity, strategy); - } - - /** - * Creates a new TDoubleFloatHashMap instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TDoubleFloatHashMap(int initialCapacity, float loadFactor, TDoubleHashingStrategy strategy) { - super(initialCapacity, loadFactor, strategy); - } - - /** - * @return a deep clone of this collection - */ - @Override // GemStoneAddition - public Object clone() { - TDoubleFloatHashMap m = (TDoubleFloatHashMap)super.clone(); - m._values = this._values.clone(); - return m; - } - - /** - * @return a TDoubleFloatIterator with access to this map's keys and values - */ - public TDoubleFloatIterator iterator() { - return new TDoubleFloatIterator(this); - } - - /** - * initializes the hashtable to a prime capacity which is at least - * initialCapacity + 1. - * - * @param initialCapacity an int value - * @return the actual capacity chosen - */ - @Override // GemStoneAddition - protected int setUp(int initialCapacity) { - int capacity; - - capacity = super.setUp(initialCapacity); - _values = new float[capacity]; - return capacity; - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an double value - * @param value an float value - * @return the previous value associated with key, - * or (float)0 if none was found. - */ - public float put(double key, float value) { - byte previousState; - float previous = 0; - int index = insertionIndex(key); - boolean isNewMapping = true; - if (index < 0) { - index = -index -1; - previous = _values[index]; - isNewMapping = false; - } - previousState = _states[index]; - _set[index] = key; - _states[index] = FULL; - _values[index] = value; - if (isNewMapping) { - postInsertHook(previousState == FREE); - } - - return previous; - } - - /** - * rehashes the map to the new capacity. - * - * @param newCapacity an int value - */ - @Override // GemStoneAddition - protected void rehash(int newCapacity) { - int oldCapacity = _set.length; - double oldKeys[] = _set; - float oldVals[] = _values; - byte oldStates[] = _states; - - _set = new double[newCapacity]; - _values = new float[newCapacity]; - _states = new byte[newCapacity]; - - for (int i = oldCapacity; i-- > 0;) { - if(oldStates[i] == FULL) { - double o = oldKeys[i]; - int index = insertionIndex(o); - _set[index] = o; - _values[index] = oldVals[i]; - _states[index] = FULL; - } - } - } - - /** - * retrieves the value for key - * - * @param key an double value - * @return the value of key or (float)0 if no such mapping exists. - */ - public float get(double key) { - int index = index(key); - return index < 0 ? (float)0 : _values[index]; - } - - /** - * Empties the map. - * - */ - @Override // GemStoneAddition - public void clear() { - super.clear(); - double[] keys = _set; - float[] vals = _values; - byte[] states = _states; - - for (int i = keys.length; i-- > 0;) { - keys[i] = 0; - vals[i] = 0; - states[i] = FREE; - } - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an double value - * @return an float value, or (float)0 if no mapping for key exists - */ - public float remove(double key) { - float prev = 0; - int index = index(key); - if (index >= 0) { - prev = _values[index]; - removeAt(index); // clear key,state; adjust size - } - return prev; - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (! (other instanceof TDoubleFloatHashMap)) { - return false; - } - TDoubleFloatHashMap that = (TDoubleFloatHashMap)other; - if (that.size() != this.size()) { - return false; - } - return forEachEntry(new EqProcedure(that)); - } - - @Override // GemStoneAddition - public int hashCode() { - HashProcedure p = new HashProcedure(); - forEachEntry(p); - return p.getHashCode(); - } - - protected/*GemStoneAddition*/ final class HashProcedure implements TDoubleFloatProcedure { - private int h = 0; - - public int getHashCode() { - return h; - } - - public final boolean execute(double key, float value) { - h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); - return true; - } - } - - private static final class EqProcedure implements TDoubleFloatProcedure { - private final TDoubleFloatHashMap _otherMap; - - EqProcedure(TDoubleFloatHashMap otherMap) { - _otherMap = otherMap; - } - - public final boolean execute(double key, float value) { - int index = _otherMap.index(key); - if (index >= 0 && eq(value, _otherMap.get(key))) { - return true; - } - return false; - } - - /** - * Compare two floats for equality. - */ - private final boolean eq(float v1, float v2) { - return v1 == v2; - } - - } - - /** - * removes the mapping at index from the map. - * - * @param index an int value - */ - @Override // GemStoneAddition - protected void removeAt(int index) { - super.removeAt(index); // clear key, state; adjust size - _values[index] = 0; - } - - /** - * Returns the values of the map. - * - * @return a Collection value - */ - public float[] getValues() { - float[] vals = new float[size()]; - float[] v = _values; - byte[] states = _states; - - for (int i = v.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - vals[j++] = v[i]; - } - } - return vals; - } - - /** - * returns the keys of the map. - * - * @return a Set value - */ - public double[] keys() { - double[] keys = new double[size()]; - double[] k = _set; - byte[] states = _states; - - for (int i = k.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - keys[j++] = k[i]; - } - } - return keys; - } - - /** - * checks for the presence of val in the values of the map. - * - * @param val an float value - * @return a boolean value - */ - public boolean containsValue(float val) { - byte[] states = _states; - float[] vals = _values; - - for (int i = vals.length; i-- > 0;) { - if (states[i] == FULL && val == vals[i]) { - return true; - } - } - return false; - } - - - /** - * checks for the present of key in the keys of the map. - * - * @param key an double value - * @return a boolean value - */ - public boolean containsKey(double key) { - return contains(key); - } - - /** - * Executes procedure for each key in the map. - * - * @param procedure a TDoubleProcedure value - * @return false if the loop over the keys terminated because - * the procedure returned false for some key. - */ - public boolean forEachKey(TDoubleProcedure procedure) { - return forEach(procedure); - } - - /** - * Executes procedure for each value in the map. - * - * @param procedure a TFloatProcedure value - * @return false if the loop over the values terminated because - * the procedure returned false for some value. - */ - public boolean forEachValue(TFloatProcedure procedure) { - byte[] states = _states; - float[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(values[i])) { - return false; - } - } - return true; - } - - /** - * Executes procedure for each key/value entry in the - * map. - * - * @param procedure a TODoubleFloatProcedure value - * @return false if the loop over the entries terminated because - * the procedure returned false for some entry. - */ - public boolean forEachEntry(TDoubleFloatProcedure procedure) { - byte[] states = _states; - double[] keys = _set; - float[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - return false; - } - } - return true; - } - - /** - * Retains only those entries in the map for which the procedure - * returns a true value. - * - * @param procedure determines which entries to keep - * @return true if the map was modified. - */ - public boolean retainEntries(TDoubleFloatProcedure procedure) { - boolean modified = false; - byte[] states = _states; - double[] keys = _set; - float[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - removeAt(i); - modified = true; - } - } - return modified; - } - - /** - * Transform the values in this map using function. - * - * @param function a TFloatFunction value - */ - public void transformValues(TFloatFunction function) { - byte[] states = _states; - float[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL) { - values[i] = function.execute(values[i]); - } - } - } - - /** - * Increments the primitive value mapped to key by 1 - * - * @param key the key of the value to increment - * @return true if a mapping was found and modified. - */ - public boolean increment(double key) { - return adjustValue(key, 1); - } - - /** - * Adjusts the primitive value mapped to key. - * - * @param key the key of the value to increment - * @param amount the amount to adjust the value by. - * @return true if a mapping was found and modified. - */ - public boolean adjustValue(double key, float amount) { - int index = index(key); - if (index < 0) { - return false; - } else { - _values[index] += amount; - return true; - } - } - - - private void writeObject(ObjectOutputStream stream) - throws IOException { - stream.defaultWriteObject(); - - // number of entries - stream.writeInt(_size); - - SerializationProcedure writeProcedure = new SerializationProcedure(stream); - if (! forEachEntry(writeProcedure)) { - throw writeProcedure.exception; - } - } - - private void readObject(ObjectInputStream stream) - throws IOException, ClassNotFoundException { - stream.defaultReadObject(); - - int size = stream.readInt(); - setUp(size); - while (size-- > 0) { - double key = stream.readDouble(); - float val = stream.readFloat(); - put(key, val); - } - } -} // TDoubleFloatHashMap diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleFloatIterator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleFloatIterator.java deleted file mode 100644 index 99d74f192..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleFloatIterator.java +++ /dev/null @@ -1,145 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Iterator for maps of type double and float. - * - *

The iterator semantics for Trove's primitive maps is slightly different - * from those defined in java.util.Iterator, but still well within - * the scope of the pattern, as defined by Gamma, et al.

- * - *

This iterator does not implicitly advance to the next entry when - * the value at the current position is retrieved. Rather, you must explicitly - * ask the iterator to advance() and then retrieve either the key(), - * the value() or both. This is done so that you have the option, but not - * the obligation, to retrieve keys and/or values as your application requires, and - * without introducing wrapper objects that would carry both. As the iteration is - * stateful, access to the key/value parts of the current map entry happens in - * constant time.

- * - *

In practice, the iterator is akin to a "search finger" that you move from - * position to position. Read or write operations affect the current entry only and - * do not assume responsibility for moving the finger.

- * - *

Here are some sample scenarios for this class of iterator:

- * - *
- * // accessing keys/values through an iterator:
- * for (TDoubleFloatIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     doSomethingWithValue(it.value());
- *   }
- * }
- * 
- * - *
- * // modifying values in-place through iteration:
- * for (TDoubleFloatIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.setValue(newValueForKey(it.key()));
- *   }
- * }
- * 
- * - *
- * // deleting entries during iteration:
- * for (TDoubleFloatIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.remove();
- *   }
- * }
- * 
- * - *
- * // faster iteration by avoiding hasNext():
- * TDoubleFloatIterator iterator = map.iterator();
- * for (int i = map.size(); i-- > 0;) {    
- *   iterator.advance();     
- *   doSomethingWithKeyAndValue(iterator.key(), iterator.value());
- * }   
- * 
- * - * @author Eric D. Friedman - * @version $Id: TDoubleFloatIterator.java,v 1.1 2002/09/22 21:53:40 ericdf Exp $ - */ - -public class TDoubleFloatIterator extends TPrimitiveIterator { - /** the collection being iterated over */ - private final TDoubleFloatHashMap _map; - - /** - * Creates an iterator over the specified map - */ - public TDoubleFloatIterator(TDoubleFloatHashMap map) { - super(map); - this._map = map; - } - - /** - * Moves the iterator forward to the next entry in the underlying map. - * - * @exception java.util.NoSuchElementException if the iterator is already exhausted - */ - public void advance() { - moveToNextIndex(); - } - - /** - * Provides access to the key of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the key of the entry at the iterator's current position. - */ - public double key() { - return _map._set[_index]; - } - - /** - * Provides access to the value of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the value of the entry at the iterator's current position. - */ - public float value() { - return _map._values[_index]; - } - - /** - * Replace the value of the mapping at the iterator's position with the - * specified value. Note that you must advance() the iterator at - * least once before invoking this method. - * - * @param val the value to set in the current entry - * @return the old value of the entry. - */ - public float setValue(float val) { - float old = value(); - _map._values[_index] = val; - return old; - } -}// TDoubleFloatIterator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleFloatProcedure.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleFloatProcedure.java deleted file mode 100644 index 850a0ccd4..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleFloatProcedure.java +++ /dev/null @@ -1,43 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Interface for procedures that take two parameters of type double and float. - * - * Created: Mon Nov 5 22:03:30 2001 - * - * @author Eric D. Friedman - * @version $Id: TDoubleFloatProcedure.java,v 1.7 2002/09/22 21:53:40 ericdf Exp $ - */ - -public interface TDoubleFloatProcedure { - - /** - * Executes this procedure. A false return value indicates that - * the application executing this procedure should not invoke this - * procedure again. - * - * @param a an double value - * @param b an float value - * @return true if additional invocations of the procedure are - * allowed. - */ - public boolean execute(double a, float b); -}// TDoubleFloatProcedure diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleFunction.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleFunction.java deleted file mode 100644 index 15bd5bcff..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleFunction.java +++ /dev/null @@ -1,38 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Interface for functions that accept and return one double primitive. - * - * Created: Mon Nov 5 22:19:36 2001 - * - * @author Eric D. Friedman - * @version $Id: TDoubleFunction.java,v 1.8 2002/09/22 21:53:40 ericdf Exp $ - */ - -public interface TDoubleFunction { - /** - * Execute this function with value - * - * @param value an double input - * @return an double result - */ - public double execute(double value); -}// TDoubleFunction diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleHash.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleHash.java deleted file mode 100644 index eceedca54..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleHash.java +++ /dev/null @@ -1,309 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove; - -import java.io.Serializable; - -/** - * An open addressed hashing implementation for double primitives. - * - * Created: Sun Nov 4 08:56:06 2001 - * - * @author Eric D. Friedman - * @version $Id: TDoubleHash.java,v 1.14 2004/02/25 14:05:29 ericdf Exp $ - */ - -abstract public class TDoubleHash extends TPrimitiveHash - implements Serializable, TDoubleHashingStrategy { - - /** the set of doubles */ - protected transient double[] _set; - - /** strategy used to hash values in this collection */ - protected TDoubleHashingStrategy _hashingStrategy; - - /** - * Creates a new TDoubleHash instance with the default - * capacity and load factor. - */ - public TDoubleHash() { - super(); - this._hashingStrategy = this; - } - - /** - * Creates a new TDoubleHash instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - */ - public TDoubleHash(int initialCapacity) { - super(initialCapacity); - this._hashingStrategy = this; - } - - /** - * Creates a new TDoubleHash instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - */ - public TDoubleHash(int initialCapacity, float loadFactor) { - super(initialCapacity, loadFactor); - this._hashingStrategy = this; - } - - /** - * Creates a new TDoubleHash instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TDoubleHash(TDoubleHashingStrategy strategy) { - super(); - this._hashingStrategy = strategy; - } - - /** - * Creates a new TDoubleHash instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TDoubleHash(int initialCapacity, TDoubleHashingStrategy strategy) { - super(initialCapacity); - this._hashingStrategy = strategy; - } - - /** - * Creates a new TDoubleHash instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TDoubleHash(int initialCapacity, float loadFactor, TDoubleHashingStrategy strategy) { - super(initialCapacity, loadFactor); - this._hashingStrategy = strategy; - } - - /** - * @return a deep clone of this collection - */ - @Override // GemStoneAddition - public Object clone() { - TDoubleHash h = (TDoubleHash)super.clone(); - h._set = this._set.clone(); - return h; - } - - /** - * initializes the hashtable to a prime capacity which is at least - * initialCapacity + 1. - * - * @param initialCapacity an int value - * @return the actual capacity chosen - */ - @Override // GemStoneAddition - protected int setUp(int initialCapacity) { - int capacity; - - capacity = super.setUp(initialCapacity); - _set = new double[capacity]; - return capacity; - } - - /** - * Searches the set for val - * - * @param val an double value - * @return a boolean value - */ - public boolean contains(double val) { - return index(val) >= 0; - } - - /** - * Executes procedure for each element in the set. - * - * @param procedure a TObjectProcedure value - * @return false if the loop over the set terminated because - * the procedure returned false for some value. - */ - public boolean forEach(TDoubleProcedure procedure) { - byte[] states = _states; - double[] set = _set; - for (int i = set.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(set[i])) { - return false; - } - } - return true; - } - - /** - * Releases the element currently stored at index. - * - * @param index an int value - */ - @Override // GemStoneAddition - protected void removeAt(int index) { - super.removeAt(index); - _set[index] = 0; - } - - /** - * Locates the index of val. - * - * @param val an double value - * @return the index of val or -1 if it isn't in the set. - */ - protected int index(double val) { - int hash, probe, index, length; - double[] set; - byte[] states; - - states = _states; - set = _set; - length = states.length; - hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff; - index = hash % length; - - if (states[index] != FREE && - (states[index] == REMOVED || set[index] != val)) { - // see Knuth, p. 529 - probe = 1 + (hash % (length - 2)); - - do { - index -= probe; - if (index < 0) { - index += length; - } - } while (states[index] != FREE && - (states[index] == REMOVED || set[index] != val)); - } - - return states[index] == FREE ? -1 : index; - } - - /** - * Locates the index at which val can be inserted. if - * there is already a value equal()ing val in the set, - * returns that value as a negative integer. - * - * @param val an double value - * @return an int value - */ - protected int insertionIndex(double val) { - int hash, probe, index, length; - double[] set; - byte[] states; - - states = _states; - set = _set; - length = states.length; - hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff; - index = hash % length; - - if (states[index] == FREE) { - return index; // empty, all done - } else if (states[index] == FULL && set[index] == val) { - return -index -1; // already stored - } else { // already FULL or REMOVED, must probe - // compute the double hash - probe = 1 + (hash % (length - 2)); - - // if the slot we landed on is FULL (but not removed), probe - // until we find an empty slot, a REMOVED slot, or an element - // equal to the one we are trying to insert. - // finding an empty slot means that the value is not present - // and that we should use that slot as the insertion point; - // finding a REMOVED slot means that we need to keep searching, - // however we want to remember the offset of that REMOVED slot - // so we can reuse it in case a "new" insertion (i.e. not an update) - // is possible. - // finding a matching value means that we've found that our desired - // key is already in the table - - if (states[index] != REMOVED) { - // starting at the natural offset, probe until we find an - // offset that isn't full. - do { - index -= probe; - if (index < 0) { - index += length; - } - } while (states[index] == FULL && set[index] != val); - } - - // if the index we found was removed: continue probing until we - // locate a free location or an element which equal()s the - // one we have. - if (states[index] == REMOVED) { - int firstRemoved = index; - while (states[index] != FREE && - (states[index] == REMOVED || set[index] != val)) { - index -= probe; - if (index < 0) { - index += length; - } - } - return states[index] == FULL ? -index -1 : firstRemoved; - } - // if it's full, the key is already stored - return states[index] == FULL ? -index -1 : index; - } - } - - /** - * Default implementation of TDoubleHashingStrategy: - * delegates hashing to HashFunctions.hash(double). - * - * @param val the value to hash - * @return the hashcode. - */ - public final int computeHashCode(double val) { - return HashFunctions.hash(val); - } -} // TDoubleHash diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleHashSet.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleHashSet.java deleted file mode 100644 index a7f6661ba..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleHashSet.java +++ /dev/null @@ -1,385 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; -//import java.io.Serializable; -import java.util.Arrays; - -/** - * An open addressed set implementation for double primitives. - * - * Created: Sat Nov 3 10:38:17 2001 - * - * @author Eric D. Friedman - * @version $Id: TDoubleHashSet.java,v 1.11 2003/03/19 04:17:03 ericdf Exp $ - */ - -public class TDoubleHashSet extends TDoubleHash implements Serializable { - - private static final long serialVersionUID = -2687756142873789773L; - - /** - * Creates a new TDoubleHashSet instance with the default - * capacity and load factor. - */ - public TDoubleHashSet() { - super(); - } - - /** - * Creates a new TDoubleHashSet instance with a prime - * capacity equal to or greater than initialCapacity and - * with the default load factor. - * - * @param initialCapacity an int value - */ - public TDoubleHashSet(int initialCapacity) { - super(initialCapacity); - } - - /** - * Creates a new TDoubleHashSet instance with a prime - * capacity equal to or greater than initialCapacity and - * with the specified load factor. - * - * @param initialCapacity an int value - * @param loadFactor a float value - */ - public TDoubleHashSet(int initialCapacity, float loadFactor) { - super(initialCapacity, loadFactor); - } - - /** - * Creates a new TDoubleHashSet instance containing the - * elements of array. - * - * @param array an array of double primitives - */ - public TDoubleHashSet(double[] array) { - this(array.length); - addAll(array); - } - - /** - * Creates a new TDoubleHash instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TDoubleHashSet(TDoubleHashingStrategy strategy) { - super(strategy); - } - - /** - * Creates a new TDoubleHash instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TDoubleHashSet(int initialCapacity, TDoubleHashingStrategy strategy) { - super(initialCapacity, strategy); - } - - /** - * Creates a new TDoubleHash instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TDoubleHashSet(int initialCapacity, float loadFactor, TDoubleHashingStrategy strategy) { - super(initialCapacity, loadFactor, strategy); - } - - /** - * Creates a new TDoubleHashSet instance containing the - * elements of array. - * - * @param array an array of double primitives - * @param strategy used to compute hash codes and to compare keys. - */ - public TDoubleHashSet(double[] array, TDoubleHashingStrategy strategy) { - this(array.length, strategy); - addAll(array); - } - - /** - * @return a TDoubleIterator with access to the values in this set - */ - public TDoubleIterator iterator() { - return new TDoubleIterator(this); - } - - /** - * Inserts a value into the set. - * - * @param val an double value - * @return true if the set was modified by the add operation - */ - public boolean add(double val) { - int index = insertionIndex(val); - - if (index < 0) { - return false; // already present in set, nothing to add - } - - byte previousState = _states[index]; - _set[index] = val; - _states[index] = FULL; - postInsertHook(previousState == FREE); - - return true; // yes, we added something - } - - /** - * Expands the set to accomodate new values. - * - * @param newCapacity an int value - */ - @Override // GemStoneAddition - protected void rehash(int newCapacity) { - int oldCapacity = _set.length; - double oldSet[] = _set; - byte oldStates[] = _states; - - _set = new double[newCapacity]; - _states = new byte[newCapacity]; - - for (int i = oldCapacity; i-- > 0;) { - if(oldStates[i] == FULL) { - double o = oldSet[i]; - int index = insertionIndex(o); - _set[index] = o; - _states[index] = FULL; - } - } - } - - /** - * Returns a new array containing the values in the set. - * - * @return an double[] value - */ - public double[] toArray() { - double[] result = new double[size()]; - double[] set = _set; - byte[] states = _states; - - for (int i = states.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - result[j++] = set[i]; - } - } - return result; - } - - /** - * Empties the set. - */ - @Override // GemStoneAddition - public void clear() { - super.clear(); - double[] set = _set; - byte[] states = _states; - - for (int i = set.length; i-- > 0;) { - set[i] = 0; - states[i] = FREE; - } - } - - /** - * Compares this set with another set for equality of their stored - * entries. - * - * @param other an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (! (other instanceof TDoubleHashSet)) { - return false; - } - final TDoubleHashSet that = (TDoubleHashSet)other; - if (that.size() != this.size()) { - return false; - } - return forEach(new TDoubleProcedure() { - public final boolean execute(double value) { - return that.contains(value); - } - }); - } - - @Override // GemStoneAddition - public int hashCode() { - HashProcedure p = new HashProcedure(); - forEach(p); - return p.getHashCode(); - } - - protected/*GemStoneAddition*/ final class HashProcedure implements TDoubleProcedure { - private int h = 0; - - public int getHashCode() { - return h; - } - - public final boolean execute(double key) { - h += _hashingStrategy.computeHashCode(key); - return true; - } - } - - /** - * Removes val from the set. - * - * @param val an double value - * @return true if the set was modified by the remove operation. - */ - public boolean remove(double val) { - int index = index(val); - if (index >= 0) { - removeAt(index); - return true; - } - return false; - } - - /** - * Tests the set to determine if all of the elements in - * array are present. - * - * @param array an array of double primitives. - * @return true if all elements were present in the set. - */ - public boolean containsAll(double[] array) { - for (int i = array.length; i-- > 0;) { - if (! contains(array[i])) { - return false; - } - } - return true; - } - - /** - * Adds all of the elements in array to the set. - * - * @param array an array of double primitives. - * @return true if the set was modified by the add all operation. - */ - public boolean addAll(double[] array) { - boolean changed = false; - for (int i = array.length; i-- > 0;) { - if (add(array[i])) { - changed = true; - } - } - return changed; - } - - /** - * Removes all of the elements in array from the set. - * - * @param array an array of double primitives. - * @return true if the set was modified by the remove all operation. - */ - public boolean removeAll(double[] array) { - boolean changed = false; - for (int i = array.length; i-- > 0;) { - if (remove(array[i])) { - changed = true; - } - } - return changed; - } - - /** - * Removes any values in the set which are not contained in - * array. - * - * @param array an array of double primitives. - * @return true if the set was modified by the retain all operation - */ - public boolean retainAll(double[] array) { - boolean changed = false; - Arrays.sort(array); - double[] set = _set; - byte[] states = _states; - - for (int i = set.length; i-- > 0;) { - if (states[i] == FULL && (Arrays.binarySearch(array,set[i]) < 0)) { - remove(set[i]); - changed = true; - } - } - return changed; - } - - private void writeObject(ObjectOutputStream stream) - throws IOException { - stream.defaultWriteObject(); - - // number of entries - stream.writeInt(_size); - - SerializationProcedure writeProcedure = new SerializationProcedure(stream); - if (! forEach(writeProcedure)) { - throw writeProcedure.exception; - } - } - - private void readObject(ObjectInputStream stream) - throws IOException, ClassNotFoundException { - stream.defaultReadObject(); - - int size = stream.readInt(); - setUp(size); - while (size-- > 0) { - double val = stream.readDouble(); - add(val); - } - } -} // TDoubleHashSet diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleHashingStrategy.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleHashingStrategy.java deleted file mode 100644 index 59e994a4a..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleHashingStrategy.java +++ /dev/null @@ -1,44 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -import java.io.Serializable; - -/** - * Interface to support pluggable hashing strategies in maps and sets. - * Implementors can use this interface to make the trove hashing - * algorithms use an optimal strategy when computing hashcodes. - * - * Created: Sun Nov 4 08:56:06 2001 - * - * @author Eric D. Friedman - * @version $Id: TDoubleHashingStrategy.java,v 1.3 2002/09/22 21:53:40 ericdf Exp $ - */ - -public interface TDoubleHashingStrategy extends Serializable { - /** - * Computes a hash code for the specified double. Implementors - * can use the double's own value or a custom scheme designed to - * minimize collisions for a known set of input. - * - * @param val double for which the hashcode is to be computed - * @return the hashCode - */ - public int computeHashCode(double val); -} // TDoubleHashingStrategy diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleIntHashMap.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleIntHashMap.java deleted file mode 100644 index 57d999b20..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleIntHashMap.java +++ /dev/null @@ -1,535 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - -/** - * An open addressed Map implementation for double keys and int values. - * - * Created: Sun Nov 4 08:52:45 2001 - * - * @author Eric D. Friedman - * @version $Id: TDoubleIntHashMap.java,v 1.15 2003/11/21 17:32:30 ericdf Exp $ - */ -public class TDoubleIntHashMap extends TDoubleHash implements Serializable { - - private static final long serialVersionUID = -8023670238937380686L; - /** the values of the map */ - protected transient int[] _values; - - /** - * Creates a new TDoubleIntHashMap instance with the default - * capacity and load factor. - */ - public TDoubleIntHashMap() { - super(); - } - - /** - * Creates a new TDoubleIntHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the default load factor. - * - * @param initialCapacity an int value - */ - public TDoubleIntHashMap(int initialCapacity) { - super(initialCapacity); - } - - /** - * Creates a new TDoubleIntHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the specified load factor. - * - * @param initialCapacity an int value - * @param loadFactor a float value - */ - public TDoubleIntHashMap(int initialCapacity, float loadFactor) { - super(initialCapacity, loadFactor); - } - - /** - * Creates a new TDoubleIntHashMap instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TDoubleIntHashMap(TDoubleHashingStrategy strategy) { - super(strategy); - } - - /** - * Creates a new TDoubleIntHashMap instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TDoubleIntHashMap(int initialCapacity, TDoubleHashingStrategy strategy) { - super(initialCapacity, strategy); - } - - /** - * Creates a new TDoubleIntHashMap instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TDoubleIntHashMap(int initialCapacity, float loadFactor, TDoubleHashingStrategy strategy) { - super(initialCapacity, loadFactor, strategy); - } - - /** - * @return a deep clone of this collection - */ - @Override // GemStoneAddition - public Object clone() { - TDoubleIntHashMap m = (TDoubleIntHashMap)super.clone(); - m._values = this._values.clone(); - return m; - } - - /** - * @return a TDoubleIntIterator with access to this map's keys and values - */ - public TDoubleIntIterator iterator() { - return new TDoubleIntIterator(this); - } - - /** - * initializes the hashtable to a prime capacity which is at least - * initialCapacity + 1. - * - * @param initialCapacity an int value - * @return the actual capacity chosen - */ - @Override // GemStoneAddition - protected int setUp(int initialCapacity) { - int capacity; - - capacity = super.setUp(initialCapacity); - _values = new int[capacity]; - return capacity; - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an double value - * @param value an int value - * @return the previous value associated with key, - * or (int)0 if none was found. - */ - public int put(double key, int value) { - byte previousState; - int previous = 0; - int index = insertionIndex(key); - boolean isNewMapping = true; - if (index < 0) { - index = -index -1; - previous = _values[index]; - isNewMapping = false; - } - previousState = _states[index]; - _set[index] = key; - _states[index] = FULL; - _values[index] = value; - if (isNewMapping) { - postInsertHook(previousState == FREE); - } - - return previous; - } - - /** - * rehashes the map to the new capacity. - * - * @param newCapacity an int value - */ - @Override // GemStoneAddition - protected void rehash(int newCapacity) { - int oldCapacity = _set.length; - double oldKeys[] = _set; - int oldVals[] = _values; - byte oldStates[] = _states; - - _set = new double[newCapacity]; - _values = new int[newCapacity]; - _states = new byte[newCapacity]; - - for (int i = oldCapacity; i-- > 0;) { - if(oldStates[i] == FULL) { - double o = oldKeys[i]; - int index = insertionIndex(o); - _set[index] = o; - _values[index] = oldVals[i]; - _states[index] = FULL; - } - } - } - - /** - * retrieves the value for key - * - * @param key an double value - * @return the value of key or (int)0 if no such mapping exists. - */ - public int get(double key) { - int index = index(key); - return index < 0 ? (int)0 : _values[index]; - } - - /** - * Empties the map. - * - */ - @Override // GemStoneAddition - public void clear() { - super.clear(); - double[] keys = _set; - int[] vals = _values; - byte[] states = _states; - - for (int i = keys.length; i-- > 0;) { - keys[i] = 0; - vals[i] = 0; - states[i] = FREE; - } - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an double value - * @return an int value, or (int)0 if no mapping for key exists - */ - public int remove(double key) { - int prev = 0; - int index = index(key); - if (index >= 0) { - prev = _values[index]; - removeAt(index); // clear key,state; adjust size - } - return prev; - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (! (other instanceof TDoubleIntHashMap)) { - return false; - } - TDoubleIntHashMap that = (TDoubleIntHashMap)other; - if (that.size() != this.size()) { - return false; - } - return forEachEntry(new EqProcedure(that)); - } - - @Override // GemStoneAddition - public int hashCode() { - HashProcedure p = new HashProcedure(); - forEachEntry(p); - return p.getHashCode(); - } - - protected/*GemStoneAddition*/ final class HashProcedure implements TDoubleIntProcedure { - private int h = 0; - - public int getHashCode() { - return h; - } - - public final boolean execute(double key, int value) { - h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); - return true; - } - } - - private static final class EqProcedure implements TDoubleIntProcedure { - private final TDoubleIntHashMap _otherMap; - - EqProcedure(TDoubleIntHashMap otherMap) { - _otherMap = otherMap; - } - - public final boolean execute(double key, int value) { - int index = _otherMap.index(key); - if (index >= 0 && eq(value, _otherMap.get(key))) { - return true; - } - return false; - } - - /** - * Compare two ints for equality. - */ - private final boolean eq(int v1, int v2) { - return v1 == v2; - } - - } - - /** - * removes the mapping at index from the map. - * - * @param index an int value - */ - @Override // GemStoneAddition - protected void removeAt(int index) { - super.removeAt(index); // clear key, state; adjust size - _values[index] = 0; - } - - /** - * Returns the values of the map. - * - * @return a Collection value - */ - public int[] getValues() { - int[] vals = new int[size()]; - int[] v = _values; - byte[] states = _states; - - for (int i = v.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - vals[j++] = v[i]; - } - } - return vals; - } - - /** - * returns the keys of the map. - * - * @return a Set value - */ - public double[] keys() { - double[] keys = new double[size()]; - double[] k = _set; - byte[] states = _states; - - for (int i = k.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - keys[j++] = k[i]; - } - } - return keys; - } - - /** - * checks for the presence of val in the values of the map. - * - * @param val an int value - * @return a boolean value - */ - public boolean containsValue(int val) { - byte[] states = _states; - int[] vals = _values; - - for (int i = vals.length; i-- > 0;) { - if (states[i] == FULL && val == vals[i]) { - return true; - } - } - return false; - } - - - /** - * checks for the present of key in the keys of the map. - * - * @param key an double value - * @return a boolean value - */ - public boolean containsKey(double key) { - return contains(key); - } - - /** - * Executes procedure for each key in the map. - * - * @param procedure a TDoubleProcedure value - * @return false if the loop over the keys terminated because - * the procedure returned false for some key. - */ - public boolean forEachKey(TDoubleProcedure procedure) { - return forEach(procedure); - } - - /** - * Executes procedure for each value in the map. - * - * @param procedure a TIntProcedure value - * @return false if the loop over the values terminated because - * the procedure returned false for some value. - */ - public boolean forEachValue(TIntProcedure procedure) { - byte[] states = _states; - int[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(values[i])) { - return false; - } - } - return true; - } - - /** - * Executes procedure for each key/value entry in the - * map. - * - * @param procedure a TODoubleIntProcedure value - * @return false if the loop over the entries terminated because - * the procedure returned false for some entry. - */ - public boolean forEachEntry(TDoubleIntProcedure procedure) { - byte[] states = _states; - double[] keys = _set; - int[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - return false; - } - } - return true; - } - - /** - * Retains only those entries in the map for which the procedure - * returns a true value. - * - * @param procedure determines which entries to keep - * @return true if the map was modified. - */ - public boolean retainEntries(TDoubleIntProcedure procedure) { - boolean modified = false; - byte[] states = _states; - double[] keys = _set; - int[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - removeAt(i); - modified = true; - } - } - return modified; - } - - /** - * Transform the values in this map using function. - * - * @param function a TIntFunction value - */ - public void transformValues(TIntFunction function) { - byte[] states = _states; - int[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL) { - values[i] = function.execute(values[i]); - } - } - } - - /** - * Increments the primitive value mapped to key by 1 - * - * @param key the key of the value to increment - * @return true if a mapping was found and modified. - */ - public boolean increment(double key) { - return adjustValue(key, 1); - } - - /** - * Adjusts the primitive value mapped to key. - * - * @param key the key of the value to increment - * @param amount the amount to adjust the value by. - * @return true if a mapping was found and modified. - */ - public boolean adjustValue(double key, int amount) { - int index = index(key); - if (index < 0) { - return false; - } else { - _values[index] += amount; - return true; - } - } - - - private void writeObject(ObjectOutputStream stream) - throws IOException { - stream.defaultWriteObject(); - - // number of entries - stream.writeInt(_size); - - SerializationProcedure writeProcedure = new SerializationProcedure(stream); - if (! forEachEntry(writeProcedure)) { - throw writeProcedure.exception; - } - } - - private void readObject(ObjectInputStream stream) - throws IOException, ClassNotFoundException { - stream.defaultReadObject(); - - int size = stream.readInt(); - setUp(size); - while (size-- > 0) { - double key = stream.readDouble(); - int val = stream.readInt(); - put(key, val); - } - } -} // TDoubleIntHashMap diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleIntIterator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleIntIterator.java deleted file mode 100644 index 7c0ba6c56..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleIntIterator.java +++ /dev/null @@ -1,145 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Iterator for maps of type double and int. - * - *

The iterator semantics for Trove's primitive maps is slightly different - * from those defined in java.util.Iterator, but still well within - * the scope of the pattern, as defined by Gamma, et al.

- * - *

This iterator does not implicitly advance to the next entry when - * the value at the current position is retrieved. Rather, you must explicitly - * ask the iterator to advance() and then retrieve either the key(), - * the value() or both. This is done so that you have the option, but not - * the obligation, to retrieve keys and/or values as your application requires, and - * without introducing wrapper objects that would carry both. As the iteration is - * stateful, access to the key/value parts of the current map entry happens in - * constant time.

- * - *

In practice, the iterator is akin to a "search finger" that you move from - * position to position. Read or write operations affect the current entry only and - * do not assume responsibility for moving the finger.

- * - *

Here are some sample scenarios for this class of iterator:

- * - *
- * // accessing keys/values through an iterator:
- * for (TDoubleIntIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     doSomethingWithValue(it.value());
- *   }
- * }
- * 
- * - *
- * // modifying values in-place through iteration:
- * for (TDoubleIntIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.setValue(newValueForKey(it.key()));
- *   }
- * }
- * 
- * - *
- * // deleting entries during iteration:
- * for (TDoubleIntIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.remove();
- *   }
- * }
- * 
- * - *
- * // faster iteration by avoiding hasNext():
- * TDoubleIntIterator iterator = map.iterator();
- * for (int i = map.size(); i-- > 0;) {    
- *   iterator.advance();     
- *   doSomethingWithKeyAndValue(iterator.key(), iterator.value());
- * }   
- * 
- * - * @author Eric D. Friedman - * @version $Id: TDoubleIntIterator.java,v 1.1 2002/09/22 21:53:40 ericdf Exp $ - */ - -public class TDoubleIntIterator extends TPrimitiveIterator { - /** the collection being iterated over */ - private final TDoubleIntHashMap _map; - - /** - * Creates an iterator over the specified map - */ - public TDoubleIntIterator(TDoubleIntHashMap map) { - super(map); - this._map = map; - } - - /** - * Moves the iterator forward to the next entry in the underlying map. - * - * @exception java.util.NoSuchElementException if the iterator is already exhausted - */ - public void advance() { - moveToNextIndex(); - } - - /** - * Provides access to the key of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the key of the entry at the iterator's current position. - */ - public double key() { - return _map._set[_index]; - } - - /** - * Provides access to the value of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the value of the entry at the iterator's current position. - */ - public int value() { - return _map._values[_index]; - } - - /** - * Replace the value of the mapping at the iterator's position with the - * specified value. Note that you must advance() the iterator at - * least once before invoking this method. - * - * @param val the value to set in the current entry - * @return the old value of the entry. - */ - public int setValue(int val) { - int old = value(); - _map._values[_index] = val; - return old; - } -}// TDoubleIntIterator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleIntProcedure.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleIntProcedure.java deleted file mode 100644 index 79ef3ac5a..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleIntProcedure.java +++ /dev/null @@ -1,43 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Interface for procedures that take two parameters of type double and int. - * - * Created: Mon Nov 5 22:03:30 2001 - * - * @author Eric D. Friedman - * @version $Id: TDoubleIntProcedure.java,v 1.7 2002/09/22 21:53:40 ericdf Exp $ - */ - -public interface TDoubleIntProcedure { - - /** - * Executes this procedure. A false return value indicates that - * the application executing this procedure should not invoke this - * procedure again. - * - * @param a an double value - * @param b an int value - * @return true if additional invocations of the procedure are - * allowed. - */ - public boolean execute(double a, int b); -}// TDoubleIntProcedure diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleIterator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleIterator.java deleted file mode 100644 index 8d6f8c1da..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleIterator.java +++ /dev/null @@ -1,51 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Iterator for double collections. - * - * @author Eric D. Friedman - * @version $Id: TDoubleIterator.java,v 1.2 2003/03/19 04:41:29 ericdf Exp $ - */ - -public class TDoubleIterator extends TPrimitiveIterator { - /** the collection on which the iterator operates */ - private final TDoubleHash _hash; - - /** - * Creates a TDoubleIterator for the elements in the specified collection. - */ - public TDoubleIterator(TDoubleHash hash) { - super(hash); - this._hash = hash; - } - - /** - * Advances the iterator to the next element in the underlying collection - * and returns it. - * - * @return the next double in the collection - * @exception java.util.NoSuchElementException if the iterator is already exhausted - */ - public double next() { - moveToNextIndex(); - return _hash._set[_index]; - } -}// TDoubleIterator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleLongHashMap.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleLongHashMap.java deleted file mode 100644 index 7d22b194c..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleLongHashMap.java +++ /dev/null @@ -1,536 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - -/** - * An open addressed Map implementation for double keys and long values. - * - * Created: Sun Nov 4 08:52:45 2001 - * - * @author Eric D. Friedman - * @version $Id: TDoubleLongHashMap.java,v 1.15 2003/11/21 17:32:30 ericdf Exp $ - */ -public class TDoubleLongHashMap extends TDoubleHash implements Serializable { - - private static final long serialVersionUID = 607240961309467222L; - - /** the values of the map */ - protected transient long[] _values; - - /** - * Creates a new TDoubleLongHashMap instance with the default - * capacity and load factor. - */ - public TDoubleLongHashMap() { - super(); - } - - /** - * Creates a new TDoubleLongHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the default load factor. - * - * @param initialCapacity an int value - */ - public TDoubleLongHashMap(int initialCapacity) { - super(initialCapacity); - } - - /** - * Creates a new TDoubleLongHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the specified load factor. - * - * @param initialCapacity an int value - * @param loadFactor a float value - */ - public TDoubleLongHashMap(int initialCapacity, float loadFactor) { - super(initialCapacity, loadFactor); - } - - /** - * Creates a new TDoubleLongHashMap instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TDoubleLongHashMap(TDoubleHashingStrategy strategy) { - super(strategy); - } - - /** - * Creates a new TDoubleLongHashMap instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TDoubleLongHashMap(int initialCapacity, TDoubleHashingStrategy strategy) { - super(initialCapacity, strategy); - } - - /** - * Creates a new TDoubleLongHashMap instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TDoubleLongHashMap(int initialCapacity, float loadFactor, TDoubleHashingStrategy strategy) { - super(initialCapacity, loadFactor, strategy); - } - - /** - * @return a deep clone of this collection - */ - @Override // GemStoneAddition - public Object clone() { - TDoubleLongHashMap m = (TDoubleLongHashMap)super.clone(); - m._values = this._values.clone(); - return m; - } - - /** - * @return a TDoubleLongIterator with access to this map's keys and values - */ - public TDoubleLongIterator iterator() { - return new TDoubleLongIterator(this); - } - - /** - * initializes the hashtable to a prime capacity which is at least - * initialCapacity + 1. - * - * @param initialCapacity an int value - * @return the actual capacity chosen - */ - @Override // GemStoneAddition - protected int setUp(int initialCapacity) { - int capacity; - - capacity = super.setUp(initialCapacity); - _values = new long[capacity]; - return capacity; - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an double value - * @param value an long value - * @return the previous value associated with key, - * or (long)0 if none was found. - */ - public long put(double key, long value) { - byte previousState; - long previous = 0; - int index = insertionIndex(key); - boolean isNewMapping = true; - if (index < 0) { - index = -index -1; - previous = _values[index]; - isNewMapping = false; - } - previousState = _states[index]; - _set[index] = key; - _states[index] = FULL; - _values[index] = value; - if (isNewMapping) { - postInsertHook(previousState == FREE); - } - - return previous; - } - - /** - * rehashes the map to the new capacity. - * - * @param newCapacity an int value - */ - @Override // GemStoneAddition - protected void rehash(int newCapacity) { - int oldCapacity = _set.length; - double oldKeys[] = _set; - long oldVals[] = _values; - byte oldStates[] = _states; - - _set = new double[newCapacity]; - _values = new long[newCapacity]; - _states = new byte[newCapacity]; - - for (int i = oldCapacity; i-- > 0;) { - if(oldStates[i] == FULL) { - double o = oldKeys[i]; - int index = insertionIndex(o); - _set[index] = o; - _values[index] = oldVals[i]; - _states[index] = FULL; - } - } - } - - /** - * retrieves the value for key - * - * @param key an double value - * @return the value of key or (long)0 if no such mapping exists. - */ - public long get(double key) { - int index = index(key); - return index < 0 ? (long)0 : _values[index]; - } - - /** - * Empties the map. - * - */ - @Override // GemStoneAddition - public void clear() { - super.clear(); - double[] keys = _set; - long[] vals = _values; - byte[] states = _states; - - for (int i = keys.length; i-- > 0;) { - keys[i] = 0; - vals[i] = 0; - states[i] = FREE; - } - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an double value - * @return an long value, or (long)0 if no mapping for key exists - */ - public long remove(double key) { - long prev = 0; - int index = index(key); - if (index >= 0) { - prev = _values[index]; - removeAt(index); // clear key,state; adjust size - } - return prev; - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (! (other instanceof TDoubleLongHashMap)) { - return false; - } - TDoubleLongHashMap that = (TDoubleLongHashMap)other; - if (that.size() != this.size()) { - return false; - } - return forEachEntry(new EqProcedure(that)); - } - - @Override // GemStoneAddition - public int hashCode() { - HashProcedure p = new HashProcedure(); - forEachEntry(p); - return p.getHashCode(); - } - - protected/*GemStoneAddition*/ final class HashProcedure implements TDoubleLongProcedure { - private int h = 0; - - public int getHashCode() { - return h; - } - - public final boolean execute(double key, long value) { - h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); - return true; - } - } - - private static final class EqProcedure implements TDoubleLongProcedure { - private final TDoubleLongHashMap _otherMap; - - EqProcedure(TDoubleLongHashMap otherMap) { - _otherMap = otherMap; - } - - public final boolean execute(double key, long value) { - int index = _otherMap.index(key); - if (index >= 0 && eq(value, _otherMap.get(key))) { - return true; - } - return false; - } - - /** - * Compare two longs for equality. - */ - private final boolean eq(long v1, long v2) { - return v1 == v2; - } - - } - - /** - * removes the mapping at index from the map. - * - * @param index an int value - */ - @Override // GemStoneAddition - protected void removeAt(int index) { - super.removeAt(index); // clear key, state; adjust size - _values[index] = 0; - } - - /** - * Returns the values of the map. - * - * @return a Collection value - */ - public long[] getValues() { - long[] vals = new long[size()]; - long[] v = _values; - byte[] states = _states; - - for (int i = v.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - vals[j++] = v[i]; - } - } - return vals; - } - - /** - * returns the keys of the map. - * - * @return a Set value - */ - public double[] keys() { - double[] keys = new double[size()]; - double[] k = _set; - byte[] states = _states; - - for (int i = k.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - keys[j++] = k[i]; - } - } - return keys; - } - - /** - * checks for the presence of val in the values of the map. - * - * @param val an long value - * @return a boolean value - */ - public boolean containsValue(long val) { - byte[] states = _states; - long[] vals = _values; - - for (int i = vals.length; i-- > 0;) { - if (states[i] == FULL && val == vals[i]) { - return true; - } - } - return false; - } - - - /** - * checks for the present of key in the keys of the map. - * - * @param key an double value - * @return a boolean value - */ - public boolean containsKey(double key) { - return contains(key); - } - - /** - * Executes procedure for each key in the map. - * - * @param procedure a TDoubleProcedure value - * @return false if the loop over the keys terminated because - * the procedure returned false for some key. - */ - public boolean forEachKey(TDoubleProcedure procedure) { - return forEach(procedure); - } - - /** - * Executes procedure for each value in the map. - * - * @param procedure a TLongProcedure value - * @return false if the loop over the values terminated because - * the procedure returned false for some value. - */ - public boolean forEachValue(TLongProcedure procedure) { - byte[] states = _states; - long[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(values[i])) { - return false; - } - } - return true; - } - - /** - * Executes procedure for each key/value entry in the - * map. - * - * @param procedure a TODoubleLongProcedure value - * @return false if the loop over the entries terminated because - * the procedure returned false for some entry. - */ - public boolean forEachEntry(TDoubleLongProcedure procedure) { - byte[] states = _states; - double[] keys = _set; - long[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - return false; - } - } - return true; - } - - /** - * Retains only those entries in the map for which the procedure - * returns a true value. - * - * @param procedure determines which entries to keep - * @return true if the map was modified. - */ - public boolean retainEntries(TDoubleLongProcedure procedure) { - boolean modified = false; - byte[] states = _states; - double[] keys = _set; - long[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - removeAt(i); - modified = true; - } - } - return modified; - } - - /** - * Transform the values in this map using function. - * - * @param function a TLongFunction value - */ - public void transformValues(TLongFunction function) { - byte[] states = _states; - long[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL) { - values[i] = function.execute(values[i]); - } - } - } - - /** - * Increments the primitive value mapped to key by 1 - * - * @param key the key of the value to increment - * @return true if a mapping was found and modified. - */ - public boolean increment(double key) { - return adjustValue(key, 1); - } - - /** - * Adjusts the primitive value mapped to key. - * - * @param key the key of the value to increment - * @param amount the amount to adjust the value by. - * @return true if a mapping was found and modified. - */ - public boolean adjustValue(double key, long amount) { - int index = index(key); - if (index < 0) { - return false; - } else { - _values[index] += amount; - return true; - } - } - - - private void writeObject(ObjectOutputStream stream) - throws IOException { - stream.defaultWriteObject(); - - // number of entries - stream.writeInt(_size); - - SerializationProcedure writeProcedure = new SerializationProcedure(stream); - if (! forEachEntry(writeProcedure)) { - throw writeProcedure.exception; - } - } - - private void readObject(ObjectInputStream stream) - throws IOException, ClassNotFoundException { - stream.defaultReadObject(); - - int size = stream.readInt(); - setUp(size); - while (size-- > 0) { - double key = stream.readDouble(); - long val = stream.readLong(); - put(key, val); - } - } -} // TDoubleLongHashMap diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleLongIterator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleLongIterator.java deleted file mode 100644 index 8e0b6785d..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleLongIterator.java +++ /dev/null @@ -1,145 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Iterator for maps of type double and long. - * - *

The iterator semantics for Trove's primitive maps is slightly different - * from those defined in java.util.Iterator, but still well within - * the scope of the pattern, as defined by Gamma, et al.

- * - *

This iterator does not implicitly advance to the next entry when - * the value at the current position is retrieved. Rather, you must explicitly - * ask the iterator to advance() and then retrieve either the key(), - * the value() or both. This is done so that you have the option, but not - * the obligation, to retrieve keys and/or values as your application requires, and - * without introducing wrapper objects that would carry both. As the iteration is - * stateful, access to the key/value parts of the current map entry happens in - * constant time.

- * - *

In practice, the iterator is akin to a "search finger" that you move from - * position to position. Read or write operations affect the current entry only and - * do not assume responsibility for moving the finger.

- * - *

Here are some sample scenarios for this class of iterator:

- * - *
- * // accessing keys/values through an iterator:
- * for (TDoubleLongIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     doSomethingWithValue(it.value());
- *   }
- * }
- * 
- * - *
- * // modifying values in-place through iteration:
- * for (TDoubleLongIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.setValue(newValueForKey(it.key()));
- *   }
- * }
- * 
- * - *
- * // deleting entries during iteration:
- * for (TDoubleLongIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.remove();
- *   }
- * }
- * 
- * - *
- * // faster iteration by avoiding hasNext():
- * TDoubleLongIterator iterator = map.iterator();
- * for (int i = map.size(); i-- > 0;) {    
- *   iterator.advance();     
- *   doSomethingWithKeyAndValue(iterator.key(), iterator.value());
- * }   
- * 
- * - * @author Eric D. Friedman - * @version $Id: TDoubleLongIterator.java,v 1.1 2002/09/22 21:53:40 ericdf Exp $ - */ - -public class TDoubleLongIterator extends TPrimitiveIterator { - /** the collection being iterated over */ - private final TDoubleLongHashMap _map; - - /** - * Creates an iterator over the specified map - */ - public TDoubleLongIterator(TDoubleLongHashMap map) { - super(map); - this._map = map; - } - - /** - * Moves the iterator forward to the next entry in the underlying map. - * - * @exception java.util.NoSuchElementException if the iterator is already exhausted - */ - public void advance() { - moveToNextIndex(); - } - - /** - * Provides access to the key of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the key of the entry at the iterator's current position. - */ - public double key() { - return _map._set[_index]; - } - - /** - * Provides access to the value of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the value of the entry at the iterator's current position. - */ - public long value() { - return _map._values[_index]; - } - - /** - * Replace the value of the mapping at the iterator's position with the - * specified value. Note that you must advance() the iterator at - * least once before invoking this method. - * - * @param val the value to set in the current entry - * @return the old value of the entry. - */ - public long setValue(long val) { - long old = value(); - _map._values[_index] = val; - return old; - } -}// TDoubleLongIterator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleLongProcedure.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleLongProcedure.java deleted file mode 100644 index e495be13a..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleLongProcedure.java +++ /dev/null @@ -1,43 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Interface for procedures that take two parameters of type double and long. - * - * Created: Mon Nov 5 22:03:30 2001 - * - * @author Eric D. Friedman - * @version $Id: TDoubleLongProcedure.java,v 1.7 2002/09/22 21:53:40 ericdf Exp $ - */ - -public interface TDoubleLongProcedure { - - /** - * Executes this procedure. A false return value indicates that - * the application executing this procedure should not invoke this - * procedure again. - * - * @param a an double value - * @param b an long value - * @return true if additional invocations of the procedure are - * allowed. - */ - public boolean execute(double a, long b); -}// TDoubleLongProcedure diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleObjectHashMap.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleObjectHashMap.java deleted file mode 100644 index c4198f5b5..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleObjectHashMap.java +++ /dev/null @@ -1,521 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - -/** - * An open addressed Map implementation for double keys and Object values. - * - * Created: Sun Nov 4 08:52:45 2001 - * - * @author Eric D. Friedman - * @version $Id: TDoubleObjectHashMap.java,v 1.15 2003/11/21 17:32:30 ericdf Exp $ - */ -public class TDoubleObjectHashMap extends TDoubleHash implements Serializable { - - private static final long serialVersionUID = -8985075183003294357L; - /** the values of the map */ - protected transient Object[] _values; - - /** - * Creates a new TDoubleObjectHashMap instance with the default - * capacity and load factor. - */ - public TDoubleObjectHashMap() { - super(); - } - - /** - * Creates a new TDoubleObjectHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the default load factor. - * - * @param initialCapacity an int value - */ - public TDoubleObjectHashMap(int initialCapacity) { - super(initialCapacity); - } - - /** - * Creates a new TDoubleObjectHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the specified load factor. - * - * @param initialCapacity an int value - * @param loadFactor a float value - */ - public TDoubleObjectHashMap(int initialCapacity, float loadFactor) { - super(initialCapacity, loadFactor); - } - - /** - * Creates a new TDoubleObjectHashMap instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TDoubleObjectHashMap(TDoubleHashingStrategy strategy) { - super(strategy); - } - - /** - * Creates a new TDoubleObjectHashMap instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TDoubleObjectHashMap(int initialCapacity, TDoubleHashingStrategy strategy) { - super(initialCapacity, strategy); - } - - /** - * Creates a new TDoubleObjectHashMap instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TDoubleObjectHashMap(int initialCapacity, float loadFactor, TDoubleHashingStrategy strategy) { - super(initialCapacity, loadFactor, strategy); - } - - /** - * @return a deep clone of this collection - */ - @Override // GemStoneAddition - public Object clone() { - TDoubleObjectHashMap m = (TDoubleObjectHashMap)super.clone(); - m._values = this._values.clone(); - return m; - } - - /** - * @return a TDoubleObjectIterator with access to this map's keys and values - */ - public TDoubleObjectIterator iterator() { - return new TDoubleObjectIterator(this); - } - - /** - * initializes the hashtable to a prime capacity which is at least - * initialCapacity + 1. - * - * @param initialCapacity an int value - * @return the actual capacity chosen - */ - @Override // GemStoneAddition - protected int setUp(int initialCapacity) { - int capacity; - - capacity = super.setUp(initialCapacity); - _values = new Object[capacity]; - return capacity; - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an double value - * @param value an Object value - * @return the previous value associated with key, - * or null if none was found. - */ - public Object put(double key, Object value) { - byte previousState; - Object previous = null; - int index = insertionIndex(key); - boolean isNewMapping = true; - if (index < 0) { - index = -index -1; - previous = _values[index]; - isNewMapping = false; - } - previousState = _states[index]; - _set[index] = key; - _states[index] = FULL; - _values[index] = value; - if (isNewMapping) { - postInsertHook(previousState == FREE); - } - - return previous; - } - - /** - * rehashes the map to the new capacity. - * - * @param newCapacity an int value - */ - @Override // GemStoneAddition - protected void rehash(int newCapacity) { - int oldCapacity = _set.length; - double oldKeys[] = _set; - Object oldVals[] = _values; - byte oldStates[] = _states; - - _set = new double[newCapacity]; - _values = new Object[newCapacity]; - _states = new byte[newCapacity]; - - for (int i = oldCapacity; i-- > 0;) { - if(oldStates[i] == FULL) { - double o = oldKeys[i]; - int index = insertionIndex(o); - _set[index] = o; - _values[index] = oldVals[i]; - _states[index] = FULL; - } - } - } - - /** - * retrieves the value for key - * - * @param key an double value - * @return the value of key or null if no such mapping exists. - */ - public Object get(double key) { - int index = index(key); - return index < 0 ? null : _values[index]; - } - - /** - * Empties the map. - * - */ - @Override // GemStoneAddition - public void clear() { - super.clear(); - double[] keys = _set; - Object[] vals = _values; - byte[] states = _states; - - for (int i = keys.length; i-- > 0;) { - keys[i] = 0; - vals[i] = null; - states[i] = FREE; - } - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an double value - * @return an Object value, or null if no mapping for key exists - */ - public Object remove(double key) { - Object prev = null; - int index = index(key); - if (index >= 0) { - prev = _values[index]; - removeAt(index); // clear key,state; adjust size - } - return prev; - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (! (other instanceof TDoubleObjectHashMap)) { - return false; - } - TDoubleObjectHashMap that = (TDoubleObjectHashMap)other; - if (that.size() != this.size()) { - return false; - } - return forEachEntry(new EqProcedure(that)); - } - - @Override // GemStoneAddition - public int hashCode() { - HashProcedure p = new HashProcedure(); - forEachEntry(p); - return p.getHashCode(); - } - - protected/*GemStoneAddition*/ final class HashProcedure implements TDoubleObjectProcedure { - private int h = 0; - - public int getHashCode() { - return h; - } - - public final boolean execute(double key, Object value) { - h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); - return true; - } - } - - private static final class EqProcedure implements TDoubleObjectProcedure { - private final TDoubleObjectHashMap _otherMap; - - EqProcedure(TDoubleObjectHashMap otherMap) { - _otherMap = otherMap; - } - - public final boolean execute(double key, Object value) { - int index = _otherMap.index(key); - if (index >= 0 && eq(value, _otherMap.get(key))) { - return true; - } - return false; - } - - /** - * Compare two objects for equality. - */ - private final boolean eq(Object o1, Object o2) { - return o1 == o2 || ((o1 != null) && o1.equals(o2)); - } - - } - - /** - * removes the mapping at index from the map. - * - * @param index an int value - */ - @Override // GemStoneAddition - protected void removeAt(int index) { - super.removeAt(index); // clear key, state; adjust size - _values[index] = null; - } - - /** - * Returns the values of the map. - * - * @return a Collection value - */ - public Object[] getValues() { - Object[] vals = new Object[size()]; - Object[] v = _values; - byte[] states = _states; - - for (int i = v.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - vals[j++] = v[i]; - } - } - return vals; - } - - /** - * returns the keys of the map. - * - * @return a Set value - */ - public double[] keys() { - double[] keys = new double[size()]; - double[] k = _set; - byte[] states = _states; - - for (int i = k.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - keys[j++] = k[i]; - } - } - return keys; - } - - /** - * checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - public boolean containsValue(Object val) { - byte[] states = _states; - Object[] vals = _values; - - // special case null values so that we don't have to - // perform null checks before every call to equals() - if (null == val) { - for (int i = vals.length; i-- > 0;) { - if (states[i] == FULL && - val == vals[i]) { - return true; - } - } - } else { - for (int i = vals.length; i-- > 0;) { - if (states[i] == FULL && - (val == vals[i] || val.equals(vals[i]))) { - return true; - } - } - } // end of else - return false; - } - - - /** - * checks for the present of key in the keys of the map. - * - * @param key an double value - * @return a boolean value - */ - public boolean containsKey(double key) { - return contains(key); - } - - /** - * Executes procedure for each key in the map. - * - * @param procedure a TDoubleProcedure value - * @return false if the loop over the keys terminated because - * the procedure returned false for some key. - */ - public boolean forEachKey(TDoubleProcedure procedure) { - return forEach(procedure); - } - - /** - * Executes procedure for each value in the map. - * - * @param procedure a TObjectProcedure value - * @return false if the loop over the values terminated because - * the procedure returned false for some value. - */ - public boolean forEachValue(TObjectProcedure procedure) { - byte[] states = _states; - Object[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(values[i])) { - return false; - } - } - return true; - } - - /** - * Executes procedure for each key/value entry in the - * map. - * - * @param procedure a TODoubleObjectProcedure value - * @return false if the loop over the entries terminated because - * the procedure returned false for some entry. - */ - public boolean forEachEntry(TDoubleObjectProcedure procedure) { - byte[] states = _states; - double[] keys = _set; - Object[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - return false; - } - } - return true; - } - - /** - * Retains only those entries in the map for which the procedure - * returns a true value. - * - * @param procedure determines which entries to keep - * @return true if the map was modified. - */ - public boolean retainEntries(TDoubleObjectProcedure procedure) { - boolean modified = false; - byte[] states = _states; - double[] keys = _set; - Object[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - removeAt(i); - modified = true; - } - } - return modified; - } - - /** - * Transform the values in this map using function. - * - * @param function a TObjectFunction value - */ - public void transformValues(TObjectFunction function) { - byte[] states = _states; - Object[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL) { - values[i] = function.execute(values[i]); - } - } - } - - - - private void writeObject(ObjectOutputStream stream) - throws IOException { - stream.defaultWriteObject(); - - // number of entries - stream.writeInt(_size); - - SerializationProcedure writeProcedure = new SerializationProcedure(stream); - if (! forEachEntry(writeProcedure)) { - throw writeProcedure.exception; - } - } - - private void readObject(ObjectInputStream stream) - throws IOException, ClassNotFoundException { - stream.defaultReadObject(); - - int size = stream.readInt(); - setUp(size); - while (size-- > 0) { - double key = stream.readDouble(); - Object val = stream.readObject(); - put(key, val); - } - } -} // TDoubleObjectHashMap diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleObjectIterator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleObjectIterator.java deleted file mode 100644 index 70471d540..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleObjectIterator.java +++ /dev/null @@ -1,145 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Iterator for maps of type double and Object. - * - *

The iterator semantics for Trove's primitive maps is slightly different - * from those defined in java.util.Iterator, but still well within - * the scope of the pattern, as defined by Gamma, et al.

- * - *

This iterator does not implicitly advance to the next entry when - * the value at the current position is retrieved. Rather, you must explicitly - * ask the iterator to advance() and then retrieve either the key(), - * the value() or both. This is done so that you have the option, but not - * the obligation, to retrieve keys and/or values as your application requires, and - * without introducing wrapper objects that would carry both. As the iteration is - * stateful, access to the key/value parts of the current map entry happens in - * constant time.

- * - *

In practice, the iterator is akin to a "search finger" that you move from - * position to position. Read or write operations affect the current entry only and - * do not assume responsibility for moving the finger.

- * - *

Here are some sample scenarios for this class of iterator:

- * - *
- * // accessing keys/values through an iterator:
- * for (TDoubleObjectIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     doSomethingWithValue(it.value());
- *   }
- * }
- * 
- * - *
- * // modifying values in-place through iteration:
- * for (TDoubleObjectIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.setValue(newValueForKey(it.key()));
- *   }
- * }
- * 
- * - *
- * // deleting entries during iteration:
- * for (TDoubleObjectIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.remove();
- *   }
- * }
- * 
- * - *
- * // faster iteration by avoiding hasNext():
- * TDoubleObjectIterator iterator = map.iterator();
- * for (int i = map.size(); i-- > 0;) {    
- *   iterator.advance();     
- *   doSomethingWithKeyAndValue(iterator.key(), iterator.value());
- * }   
- * 
- * - * @author Eric D. Friedman - * @version $Id: TDoubleObjectIterator.java,v 1.1 2002/09/22 21:53:40 ericdf Exp $ - */ - -public class TDoubleObjectIterator extends TPrimitiveIterator { - /** the collection being iterated over */ - private final TDoubleObjectHashMap _map; - - /** - * Creates an iterator over the specified map - */ - public TDoubleObjectIterator(TDoubleObjectHashMap map) { - super(map); - this._map = map; - } - - /** - * Moves the iterator forward to the next entry in the underlying map. - * - * @exception java.util.NoSuchElementException if the iterator is already exhausted - */ - public void advance() { - moveToNextIndex(); - } - - /** - * Provides access to the key of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the key of the entry at the iterator's current position. - */ - public double key() { - return _map._set[_index]; - } - - /** - * Provides access to the value of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the value of the entry at the iterator's current position. - */ - public Object value() { - return _map._values[_index]; - } - - /** - * Replace the value of the mapping at the iterator's position with the - * specified value. Note that you must advance() the iterator at - * least once before invoking this method. - * - * @param val the value to set in the current entry - * @return the old value of the entry. - */ - public Object setValue(Object val) { - Object old = value(); - _map._values[_index] = val; - return old; - } -}// TDoubleObjectIterator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleObjectProcedure.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleObjectProcedure.java deleted file mode 100644 index 290409729..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleObjectProcedure.java +++ /dev/null @@ -1,43 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Interface for procedures that take two parameters of type double and Object. - * - * Created: Mon Nov 5 22:03:30 2001 - * - * @author Eric D. Friedman - * @version $Id: TDoubleObjectProcedure.java,v 1.7 2002/09/22 21:53:40 ericdf Exp $ - */ - -public interface TDoubleObjectProcedure { - - /** - * Executes this procedure. A false return value indicates that - * the application executing this procedure should not invoke this - * procedure again. - * - * @param a an double value - * @param b an Object value - * @return true if additional invocations of the procedure are - * allowed. - */ - public boolean execute(double a, Object b); -}// TDoubleObjectProcedure diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleProcedure.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleProcedure.java deleted file mode 100644 index 6a6819ccf..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TDoubleProcedure.java +++ /dev/null @@ -1,41 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Interface for procedures with one double paramater. - * - * Created: Mon Nov 5 21:45:49 2001 - * - * @author Eric D. Friedman - * @version $Id: TDoubleProcedure.java,v 1.5 2002/09/22 21:53:40 ericdf Exp $ - */ - -public interface TDoubleProcedure { - /** - * Executes this procedure. A false return value indicates that - * the application executing this procedure should not invoke this - * procedure again. - * - * @param value a value of type double - * @return true if additional invocations of the procedure are - * allowed. - */ - public boolean execute(double value); -}// TDoubleProcedure diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatArrayList.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatArrayList.java deleted file mode 100644 index 687b5caef..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatArrayList.java +++ /dev/null @@ -1,885 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove; - -import java.io.Serializable; -import java.util.Arrays; -import java.util.Random; - -/** - * A resizable, array-backed list of float primitives. - * - * Created: Sat Dec 29 14:21:12 2001 - * - * @author Eric D. Friedman - * @version $Id: TFloatArrayList.java,v 1.15 2003/11/09 09:22:22 ericdf Exp $ - */ - -public class TFloatArrayList implements Serializable, Cloneable { -private static final long serialVersionUID = 4142259042805691586L; - - /** the data of the list */ - protected float[] _data; - - /** the index after the last entry in the list */ - protected int _pos; - - /** the default capacity for new lists */ - protected static final int DEFAULT_CAPACITY = 10; - - /** - * Creates a new TFloatArrayList instance with the - * default capacity. - */ - public TFloatArrayList() { - this(DEFAULT_CAPACITY); - } - - /** - * Creates a new TFloatArrayList instance with the - * specified capacity. - * - * @param capacity an int value - */ - public TFloatArrayList(int capacity) { - _data = new float[capacity]; - _pos = 0; - } - - /** - * Creates a new TFloatArrayList instance whose - * capacity is the greater of the length of values and - * DEFAULT_CAPACITY and whose initial contents are the specified - * values. - * - * @param values an float[] value - */ - public TFloatArrayList(float[] values) { - this(Math.max(values.length, DEFAULT_CAPACITY)); - add(values); - } - - // sizing - - /** - * Grow the internal array as needed to accomodate the specified - * number of elements. The size of the array doubles on each - * resize unless capacity requires more than twice the - * current capacity. - * - * @param capacity an int value - */ - public void ensureCapacity(int capacity) { - if (capacity > _data.length) { - int newCap = Math.max(_data.length << 1, capacity); - float[] tmp = new float[newCap]; - System.arraycopy(_data, 0, tmp, 0, _data.length); - _data = tmp; - } - } - - /** - * Returns the number of values in the list. - * - * @return the number of values in the list. - */ - public int size() { - return _pos; - } - - /** - * Tests whether this list contains any values. - * - * @return true if the list is empty. - */ - public boolean isEmpty() { - return _pos == 0; - } - - /** - * Sheds any excess capacity above and beyond the current size of - * the list. - */ - public void trimToSize() { - if (_data.length > size()) { - float[] tmp = new float[size()]; - toNativeArray(tmp, 0, tmp.length); - _data = tmp; - } - } - - // modifying - - /** - * Adds val to the end of the list, growing as needed. - * - * @param val an float value - */ - public void add(float val) { - ensureCapacity(_pos + 1); - _data[_pos++] = val; - } - - /** - * Adds the values in the array vals to the end of the - * list, in order. - * - * @param vals an float[] value - */ - public void add(float[] vals) { - add(vals, 0, vals.length); - } - - /** - * Adds a subset of the values in the array vals to the - * end of the list, in order. - * - * @param vals an float[] value - * @param offset the offset at which to start copying - * @param length the number of values to copy. - */ - public void add(float[] vals, int offset, int length) { - ensureCapacity(_pos + length); - System.arraycopy(vals, offset, _data, _pos, length); - _pos += length; - } - - /** - * Inserts value into the list at offset. All - * values including and to the right of offset are shifted - * to the right. - * - * @param offset an int value - * @param value an float value - */ - public void insert(int offset, float value) { - if (offset == _pos) { - add(value); - return; - } - ensureCapacity(_pos + 1); - // shift right - System.arraycopy(_data, offset, _data, offset + 1, _pos - offset); - // insert - _data[offset] = value; - _pos++; - } - - /** - * Inserts the array of values into the list at - * offset. All values including and to the right of - * offset are shifted to the right. - * - * @param offset an int value - * @param values an float[] value - */ - public void insert(int offset, float[] values) { - insert(offset, values, 0, values.length); - } - - /** - * Inserts a slice of the array of values into the list - * at offset. All values including and to the right of - * offset are shifted to the right. - * - * @param offset an int value - * @param values an float[] value - * @param valOffset the offset in the values array at which to - * start copying. - * @param len the number of values to copy from the values array - */ - public void insert(int offset, float[] values, int valOffset, int len) { - if (offset == _pos) { - add(values, valOffset, len); - return; - } - - ensureCapacity(_pos + len); - // shift right - System.arraycopy(_data, offset, _data, offset + len, _pos - offset); - // insert - System.arraycopy(values, valOffset, _data, offset, len); - _pos += len; - } - - /** - * Returns the value at the specified offset. - * - * @param offset an int value - * @return an float value - */ - public float get(int offset) { - if (offset >= _pos) { - throw new ArrayIndexOutOfBoundsException(offset); - } - return _data[offset]; - } - - /** - * Returns the value at the specified offset without doing any - * bounds checking. - * - * @param offset an int value - * @return an float value - */ - public float getQuick(int offset) { - return _data[offset]; - } - - /** - * Sets the value at the specified offset. - * - * @param offset an int value - * @param val an float value - */ - public void set(int offset, float val) { - if (offset >= _pos) { - throw new ArrayIndexOutOfBoundsException(offset); - } - _data[offset] = val; - } - - /** - * Sets the value at the specified offset and returns the - * previously stored value. - * - * @param offset an int value - * @param val an float value - * @return the value previously stored at offset. - */ - public float getSet(int offset, float val) { - if (offset >= _pos) { - throw new ArrayIndexOutOfBoundsException(offset); - } - float old = _data[offset]; - _data[offset] = val; - return old; - } - - /** - * Replace the values in the list starting at offset with - * the contents of the values array. - * - * @param offset the first offset to replace - * @param values the source of the new values - */ - public void set(int offset, float[] values) { - set(offset, values, 0, values.length); - } - - /** - * Replace the values in the list starting at offset with - * length values from the values array, starting - * at valOffset. - * - * @param offset the first offset to replace - * @param values the source of the new values - * @param valOffset the first value to copy from the values array - * @param length the number of values to copy - */ - public void set(int offset, float[] values, int valOffset, int length) { - if (offset < 0 || offset + length >= _pos) { - throw new ArrayIndexOutOfBoundsException(offset); - } - System.arraycopy(values, valOffset, _data, offset, length); - } - - /** - * Sets the value at the specified offset without doing any bounds - * checking. - * - * @param offset an int value - * @param val an float value - */ - public void setQuick(int offset, float val) { - _data[offset] = val; - } - - /** - * Flushes the internal state of the list, resetting the capacity - * to the default. - */ - public void clear() { - clear(DEFAULT_CAPACITY); - } - - /** - * Flushes the internal state of the list, setting the capacity of - * the empty list to capacity. - * - * @param capacity an int value - */ - public void clear(int capacity) { - _data = new float[capacity]; - _pos = 0; - } - - /** - * Sets the size of the list to 0, but does not change its - * capacity. This method can be used as an alternative to the - * {@link #clear() clear} method if you want to recyle a list without - * allocating new backing arrays. - * - * @see #clear() - */ - public void reset() { - _pos = 0; - fill(0); - } - - /** - * Sets the size of the list to 0, but does not change its - * capacity. This method can be used as an alternative to the - * {@link #clear() clear} method if you want to recyle a list - * without allocating new backing arrays. This method differs - * from {@link #reset reset} in that it does not clear the old - * values in the backing array. Thus, it is possible for {@link - * #getQuick getQuick} to return stale data if this method is used - * and the caller is careless about bounds checking. - * - * @see #reset - * @see #clear() - * @see #getQuick - */ - public void resetQuick() { - _pos = 0; - } - - /** - * Removes the value at offset from the list. - * - * @param offset an int value - * @return the value previously stored at offset. - */ - public float remove(int offset) { - float old = get(offset); - remove(offset, 1); - return old; - } - - /** - * Removes length values from the list, starting at - * offset - * - * @param offset an int value - * @param length an int value - */ - public void remove(int offset, int length) { - if (offset < 0 || offset >= _pos) { - throw new ArrayIndexOutOfBoundsException(offset); - } - - if (offset == 0) { - // data at the front - System.arraycopy(_data, length, _data, 0, _pos - length); - } else if (_pos - length == offset) { - // no copy to make, decrementing pos "deletes" values at - // the end - } else { - // data in the middle - System.arraycopy(_data, offset + length, - _data, offset, _pos - (offset + length)); - } - _pos -= length; - // no need to clear old values beyond _pos, because this is a - // primitive collection and 0 takes as much room as any other - // value - } - - /** - * Transform each value in the list using the specified function. - * - * @param function a TFloatFunction value - */ - public void transformValues(TFloatFunction function) { - for (int i = _pos; i-- > 0;) { - _data[i] = function.execute(_data[i]); - } - } - - /** - * Reverse the order of the elements in the list. - */ - public void reverse() { - reverse(0, _pos); - } - - /** - * Reverse the order of the elements in the range of the list. - * - * @param from the inclusive index at which to start reversing - * @param to the exclusive index at which to stop reversing - */ - public void reverse(int from, int to) { - if (from == to) { - return; // nothing to do - } - if (from > to) { - throw new IllegalArgumentException("from cannot be greater than to"); - } - for (int i = from, j = to - 1; i < j; i++, j--) { - swap(i, j); - } - } - - /** - * Shuffle the elements of the list using the specified random - * number generator. - * - * @param rand a Random value - */ - public void shuffle(Random rand) { - for (int i = _pos; i-- > 1;) { - swap(i, rand.nextInt(i)); - } - } - - /** - * Swap the values at offsets i and j. - * - * @param i an offset into the data array - * @param j an offset into the data array - */ - private final void swap(int i, int j) { - float tmp = _data[i]; - _data[i] = _data[j]; - _data[j] = tmp; - } - - // copying - - /** - * Returns a clone of this list. Since this is a primitive - * collection, this will be a deep clone. - * - * @return a deep clone of the list. - */ - @Override // GemStoneAddition - public Object clone() { - Object o = null; - try { - o = super.clone(); - } catch (CloneNotSupportedException e) { - // it's supported - } // end of try-catch - return o; - } - - /** - * Copies the contents of the list into a native array. - * - * @return an float[] value - */ - public float[] toNativeArray() { - return toNativeArray(0, _pos); - } - - /** - * Copies a slice of the list into a native array. - * - * @param offset the offset at which to start copying - * @param len the number of values to copy. - * @return an float[] value - */ - public float[] toNativeArray(int offset, int len) { - float[] rv = new float[len]; - toNativeArray(rv, offset, len); - return rv; - } - - /** - * Copies a slice of the list into a native array. - * - * @param dest the array to copy into. - * @param offset the offset of the first value to copy - * @param len the number of values to copy. - */ - public void toNativeArray(float[] dest, int offset, int len) { - if (len == 0) { - return; // nothing to copy - } - if (offset < 0 || offset >= _pos) { - throw new ArrayIndexOutOfBoundsException(offset); - } - System.arraycopy(_data, 0, dest, offset, len); - } - - // comparing - - /** - * Compares this list to another list, value by value. - * - * @param other the object to compare against - * @return true if other is a TFloatArrayList and has exactly the - * same values. - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (other == this) { - return true; - } else if (other instanceof TFloatArrayList) { - TFloatArrayList that = (TFloatArrayList)other; - if (that.size() != this.size()) { - return false; - } else { - for (int i = _pos; i-- > 0;) { - if (this._data[i] != that._data[i]) { - return false; - } - } - return true; - } - } else { - return false; - } - } - - @Override // GemStoneAddition - public int hashCode() { - int h = 0; - for (int i = _pos; i-- > 0;) { - h += HashFunctions.hash(_data[i]); - } - return h; - } - - // procedures - - /** - * Applies the procedure to each value in the list in ascending - * (front to back) order. - * - * @param procedure a TFloatProcedure value - * @return true if the procedure did not terminate prematurely. - */ - public boolean forEach(TFloatProcedure procedure) { - for (int i = 0; i < _pos; i++) { - if (! procedure.execute(_data[i])) { - return false; - } - } - return true; - } - - /** - * Applies the procedure to each value in the list in descending - * (back to front) order. - * - * @param procedure a TFloatProcedure value - * @return true if the procedure did not terminate prematurely. - */ - public boolean forEachDescending(TFloatProcedure procedure) { - for (int i = _pos; i-- > 0;) { - if (! procedure.execute(_data[i])) { - return false; - } - } - return true; - } - - // sorting - - /** - * Sort the values in the list (ascending) using the Sun quicksort - * implementation. - * - * @see java.util.Arrays#sort(float[]) - */ - public void sort() { - Arrays.sort(_data, 0, _pos); - } - - /** - * Sort a slice of the list (ascending) using the Sun quicksort - * implementation. - * - * @param fromIndex the index at which to start sorting (inclusive) - * @param toIndex the index at which to stop sorting (exclusive) - * @see java.util.Arrays#sort(float[], int, int) - */ - public void sort(int fromIndex, int toIndex) { - Arrays.sort(_data, fromIndex, toIndex); - } - - // filling - - /** - * Fills every slot in the list with the specified value. - * - * @param val the value to use when filling - */ - public void fill(float val) { - Arrays.fill(_data, 0, _pos, val); - } - - /** - * Fills a range in the list with the specified value. - * - * @param fromIndex the offset at which to start filling (inclusive) - * @param toIndex the offset at which to stop filling (exclusive) - * @param val the value to use when filling - */ - public void fill(int fromIndex, int toIndex, float val) { - if (toIndex > _pos) { - ensureCapacity(toIndex); - _pos = toIndex; - } - Arrays.fill(_data, fromIndex, toIndex, val); - } - - // searching - - /** - * Performs a binary search for value in the entire list. - * Note that you must @{link #sort sort} the list before - * doing a search. - * - * @param value the value to search for - * @return the absolute offset in the list of the value, or its - * negative insertion point into the sorted list. - */ - public int binarySearch(float value) { - return binarySearch(value, 0, _pos); - } - - /** - * Performs a binary search for value in the specified - * range. Note that you must @{link #sort sort} the list - * or the range before doing a search. - * - * @param value the value to search for - * @param fromIndex the lower boundary of the range (inclusive) - * @param toIndex the upper boundary of the range (exclusive) - * @return the absolute offset in the list of the value, or its - * negative insertion point into the sorted list. - */ - public int binarySearch(float value, int fromIndex, int toIndex) { - if (fromIndex < 0) { - throw new ArrayIndexOutOfBoundsException(fromIndex); - } - if (toIndex > _pos) { - throw new ArrayIndexOutOfBoundsException(toIndex); - } - - int low = fromIndex; - int high = toIndex - 1; - - while (low <= high) { - int mid = (int)(((long)low + high) >> 1); // GemStoneAddition avoid overflow - float midVal = _data[mid]; - - if (midVal < value) { - low = mid + 1; - } else if (midVal > value) { - high = mid - 1; - } else { - return mid; // value found - } - } - return -(low + 1); // value not found. - } - - /** - * Searches the list front to back for the index of - * value. - * - * @param value an float value - * @return the first offset of the value, or -1 if it is not in - * the list. - * @see #binarySearch(float) for faster searches on sorted lists - */ - public int indexOf(float value) { - return indexOf(0, value); - } - - /** - * Searches the list front to back for the index of - * value, starting at offset. - * - * @param offset the offset at which to start the linear search - * (inclusive) - * @param value an float value - * @return the first offset of the value, or -1 if it is not in - * the list. - * @see #binarySearch(float, int, int) for faster searches on sorted lists - */ - public int indexOf(int offset, float value) { - for (int i = offset; i < _pos; i++) { - if (_data[i] == value) { - return i; - } - } - return -1; - } - - /** - * Searches the list back to front for the last index of - * value. - * - * @param value an float value - * @return the last offset of the value, or -1 if it is not in - * the list. - * @see #binarySearch(float) for faster searches on sorted lists - */ - public int lastIndexOf(float value) { - return lastIndexOf(_pos, value); - } - - /** - * Searches the list back to front for the last index of - * value, starting at offset. - * - * @param offset the offset at which to start the linear search - * (exclusive) - * @param value an float value - * @return the last offset of the value, or -1 if it is not in - * the list. - * @see #binarySearch(float, int, int) for faster searches on sorted lists - */ - public int lastIndexOf(int offset, float value) { - for (int i = offset; i-- > 0;) { - if (_data[i] == value) { - return i; - } - } - return -1; - } - - /** - * Searches the list for value - * - * @param value an float value - * @return true if value is in the list. - */ - public boolean contains(float value) { - return lastIndexOf(value) >= 0; - } - - /** - * Searches the list for values satisfying condition in - * the manner of the *nix grep utility. - * - * @param condition a condition to apply to each element in the list - * @return a list of values which match the condition. - */ - public TFloatArrayList grep(TFloatProcedure condition) { - TFloatArrayList list = new TFloatArrayList(); - for (int i = 0; i < _pos; i++) { - if (condition.execute(_data[i])) { - list.add(_data[i]); - } - } - return list; - } - - /** - * Searches the list for values which do not satisfy - * condition. This is akin to *nix grep -v. - * - * @param condition a condition to apply to each element in the list - * @return a list of values which do not match the condition. - */ - public TFloatArrayList inverseGrep(TFloatProcedure condition) { - TFloatArrayList list = new TFloatArrayList(); - for (int i = 0; i < _pos; i++) { - if (! condition.execute(_data[i])) { - list.add(_data[i]); - } - } - return list; - } - - /** - * Finds the maximum value in the list. - * - * @return the largest value in the list. - * @exception IllegalStateException if the list is empty - */ - public float max() { - if (size() == 0) { - throw new IllegalStateException("cannot find maximum of an empty list"); - } - float max = _data[_pos - 1]; - for (int i = _pos - 1; i-- > 0;) { - if (_data[i] > max) { - max = _data[i]; - } - } - return max; - } - - /** - * Finds the minimum value in the list. - * - * @return the smallest value in the list. - * @exception IllegalStateException if the list is empty - */ - public float min() { - if (size() == 0) { - throw new IllegalStateException("cannot find minimum of an empty list"); - } - float min = _data[_pos - 1]; - for (int i = _pos - 1; i-- > 0;) { - if (_data[i] < min) { - min = _data[i]; - } - } - return min; - } - - // stringification - - /** - * Returns a String representation of the list, front to back. - * - * @return a String value - */ - @Override // GemStoneAddition - public String toString() { - StringBuffer buf = new StringBuffer("{"); - for (int i = 0, end = _pos - 1; i < end; i++) { - buf.append(_data[i]); - buf.append(", "); - } - if (size() > 0) { - buf.append(_data[_pos - 1]); - } - buf.append("}"); - return buf.toString(); - } -} // TFloatArrayList diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatDoubleHashMap.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatDoubleHashMap.java deleted file mode 100644 index 7371c4f29..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatDoubleHashMap.java +++ /dev/null @@ -1,535 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - -/** - * An open addressed Map implementation for float keys and double values. - * - * Created: Sun Nov 4 08:52:45 2001 - * - * @author Eric D. Friedman - * @version $Id: TFloatDoubleHashMap.java,v 1.15 2003/11/21 17:32:30 ericdf Exp $ - */ -public class TFloatDoubleHashMap extends TFloatHash implements Serializable { - - private static final long serialVersionUID = -4515820268049843292L; - /** the values of the map */ - protected transient double[] _values; - - /** - * Creates a new TFloatDoubleHashMap instance with the default - * capacity and load factor. - */ - public TFloatDoubleHashMap() { - super(); - } - - /** - * Creates a new TFloatDoubleHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the default load factor. - * - * @param initialCapacity an int value - */ - public TFloatDoubleHashMap(int initialCapacity) { - super(initialCapacity); - } - - /** - * Creates a new TFloatDoubleHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the specified load factor. - * - * @param initialCapacity an int value - * @param loadFactor a float value - */ - public TFloatDoubleHashMap(int initialCapacity, float loadFactor) { - super(initialCapacity, loadFactor); - } - - /** - * Creates a new TFloatDoubleHashMap instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TFloatDoubleHashMap(TFloatHashingStrategy strategy) { - super(strategy); - } - - /** - * Creates a new TFloatDoubleHashMap instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TFloatDoubleHashMap(int initialCapacity, TFloatHashingStrategy strategy) { - super(initialCapacity, strategy); - } - - /** - * Creates a new TFloatDoubleHashMap instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TFloatDoubleHashMap(int initialCapacity, float loadFactor, TFloatHashingStrategy strategy) { - super(initialCapacity, loadFactor, strategy); - } - - /** - * @return a deep clone of this collection - */ - @Override // GemStoneAddition - public Object clone() { - TFloatDoubleHashMap m = (TFloatDoubleHashMap)super.clone(); - m._values = this._values.clone(); - return m; - } - - /** - * @return a TFloatDoubleIterator with access to this map's keys and values - */ - public TFloatDoubleIterator iterator() { - return new TFloatDoubleIterator(this); - } - - /** - * initializes the hashtable to a prime capacity which is at least - * initialCapacity + 1. - * - * @param initialCapacity an int value - * @return the actual capacity chosen - */ - @Override // GemStoneAddition - protected int setUp(int initialCapacity) { - int capacity; - - capacity = super.setUp(initialCapacity); - _values = new double[capacity]; - return capacity; - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an float value - * @param value an double value - * @return the previous value associated with key, - * or (double)0 if none was found. - */ - public double put(float key, double value) { - byte previousState; - double previous = 0; - int index = insertionIndex(key); - boolean isNewMapping = true; - if (index < 0) { - index = -index -1; - previous = _values[index]; - isNewMapping = false; - } - previousState = _states[index]; - _set[index] = key; - _states[index] = FULL; - _values[index] = value; - if (isNewMapping) { - postInsertHook(previousState == FREE); - } - - return previous; - } - - /** - * rehashes the map to the new capacity. - * - * @param newCapacity an int value - */ - @Override // GemStoneAddition - protected void rehash(int newCapacity) { - int oldCapacity = _set.length; - float oldKeys[] = _set; - double oldVals[] = _values; - byte oldStates[] = _states; - - _set = new float[newCapacity]; - _values = new double[newCapacity]; - _states = new byte[newCapacity]; - - for (int i = oldCapacity; i-- > 0;) { - if(oldStates[i] == FULL) { - float o = oldKeys[i]; - int index = insertionIndex(o); - _set[index] = o; - _values[index] = oldVals[i]; - _states[index] = FULL; - } - } - } - - /** - * retrieves the value for key - * - * @param key an float value - * @return the value of key or (double)0 if no such mapping exists. - */ - public double get(float key) { - int index = index(key); - return index < 0 ? (double)0 : _values[index]; - } - - /** - * Empties the map. - * - */ - @Override // GemStoneAddition - public void clear() { - super.clear(); - float[] keys = _set; - double[] vals = _values; - byte[] states = _states; - - for (int i = keys.length; i-- > 0;) { - keys[i] = 0; - vals[i] = 0; - states[i] = FREE; - } - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an float value - * @return an double value, or (double)0 if no mapping for key exists - */ - public double remove(float key) { - double prev = 0; - int index = index(key); - if (index >= 0) { - prev = _values[index]; - removeAt(index); // clear key,state; adjust size - } - return prev; - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (! (other instanceof TFloatDoubleHashMap)) { - return false; - } - TFloatDoubleHashMap that = (TFloatDoubleHashMap)other; - if (that.size() != this.size()) { - return false; - } - return forEachEntry(new EqProcedure(that)); - } - - @Override // GemStoneAddition - public int hashCode() { - HashProcedure p = new HashProcedure(); - forEachEntry(p); - return p.getHashCode(); - } - - protected/*GemStoneAddition*/ final class HashProcedure implements TFloatDoubleProcedure { - private int h = 0; - - public int getHashCode() { - return h; - } - - public final boolean execute(float key, double value) { - h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); - return true; - } - } - - private static final class EqProcedure implements TFloatDoubleProcedure { - private final TFloatDoubleHashMap _otherMap; - - EqProcedure(TFloatDoubleHashMap otherMap) { - _otherMap = otherMap; - } - - public final boolean execute(float key, double value) { - int index = _otherMap.index(key); - if (index >= 0 && eq(value, _otherMap.get(key))) { - return true; - } - return false; - } - - /** - * Compare two doubles for equality. - */ - private final boolean eq(double v1, double v2) { - return v1 == v2; - } - - } - - /** - * removes the mapping at index from the map. - * - * @param index an int value - */ - @Override // GemStoneAddition - protected void removeAt(int index) { - super.removeAt(index); // clear key, state; adjust size - _values[index] = 0; - } - - /** - * Returns the values of the map. - * - * @return a Collection value - */ - public double[] getValues() { - double[] vals = new double[size()]; - double[] v = _values; - byte[] states = _states; - - for (int i = v.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - vals[j++] = v[i]; - } - } - return vals; - } - - /** - * returns the keys of the map. - * - * @return a Set value - */ - public float[] keys() { - float[] keys = new float[size()]; - float[] k = _set; - byte[] states = _states; - - for (int i = k.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - keys[j++] = k[i]; - } - } - return keys; - } - - /** - * checks for the presence of val in the values of the map. - * - * @param val an double value - * @return a boolean value - */ - public boolean containsValue(double val) { - byte[] states = _states; - double[] vals = _values; - - for (int i = vals.length; i-- > 0;) { - if (states[i] == FULL && val == vals[i]) { - return true; - } - } - return false; - } - - - /** - * checks for the present of key in the keys of the map. - * - * @param key an float value - * @return a boolean value - */ - public boolean containsKey(float key) { - return contains(key); - } - - /** - * Executes procedure for each key in the map. - * - * @param procedure a TFloatProcedure value - * @return false if the loop over the keys terminated because - * the procedure returned false for some key. - */ - public boolean forEachKey(TFloatProcedure procedure) { - return forEach(procedure); - } - - /** - * Executes procedure for each value in the map. - * - * @param procedure a TDoubleProcedure value - * @return false if the loop over the values terminated because - * the procedure returned false for some value. - */ - public boolean forEachValue(TDoubleProcedure procedure) { - byte[] states = _states; - double[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(values[i])) { - return false; - } - } - return true; - } - - /** - * Executes procedure for each key/value entry in the - * map. - * - * @param procedure a TOFloatDoubleProcedure value - * @return false if the loop over the entries terminated because - * the procedure returned false for some entry. - */ - public boolean forEachEntry(TFloatDoubleProcedure procedure) { - byte[] states = _states; - float[] keys = _set; - double[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - return false; - } - } - return true; - } - - /** - * Retains only those entries in the map for which the procedure - * returns a true value. - * - * @param procedure determines which entries to keep - * @return true if the map was modified. - */ - public boolean retainEntries(TFloatDoubleProcedure procedure) { - boolean modified = false; - byte[] states = _states; - float[] keys = _set; - double[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - removeAt(i); - modified = true; - } - } - return modified; - } - - /** - * Transform the values in this map using function. - * - * @param function a TDoubleFunction value - */ - public void transformValues(TDoubleFunction function) { - byte[] states = _states; - double[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL) { - values[i] = function.execute(values[i]); - } - } - } - - /** - * Increments the primitive value mapped to key by 1 - * - * @param key the key of the value to increment - * @return true if a mapping was found and modified. - */ - public boolean increment(float key) { - return adjustValue(key, 1); - } - - /** - * Adjusts the primitive value mapped to key. - * - * @param key the key of the value to increment - * @param amount the amount to adjust the value by. - * @return true if a mapping was found and modified. - */ - public boolean adjustValue(float key, double amount) { - int index = index(key); - if (index < 0) { - return false; - } else { - _values[index] += amount; - return true; - } - } - - - private void writeObject(ObjectOutputStream stream) - throws IOException { - stream.defaultWriteObject(); - - // number of entries - stream.writeInt(_size); - - SerializationProcedure writeProcedure = new SerializationProcedure(stream); - if (! forEachEntry(writeProcedure)) { - throw writeProcedure.exception; - } - } - - private void readObject(ObjectInputStream stream) - throws IOException, ClassNotFoundException { - stream.defaultReadObject(); - - int size = stream.readInt(); - setUp(size); - while (size-- > 0) { - float key = stream.readFloat(); - double val = stream.readDouble(); - put(key, val); - } - } -} // TFloatDoubleHashMap diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatDoubleIterator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatDoubleIterator.java deleted file mode 100644 index 50e9edfc1..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatDoubleIterator.java +++ /dev/null @@ -1,145 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Iterator for maps of type float and double. - * - *

The iterator semantics for Trove's primitive maps is slightly different - * from those defined in java.util.Iterator, but still well within - * the scope of the pattern, as defined by Gamma, et al.

- * - *

This iterator does not implicitly advance to the next entry when - * the value at the current position is retrieved. Rather, you must explicitly - * ask the iterator to advance() and then retrieve either the key(), - * the value() or both. This is done so that you have the option, but not - * the obligation, to retrieve keys and/or values as your application requires, and - * without introducing wrapper objects that would carry both. As the iteration is - * stateful, access to the key/value parts of the current map entry happens in - * constant time.

- * - *

In practice, the iterator is akin to a "search finger" that you move from - * position to position. Read or write operations affect the current entry only and - * do not assume responsibility for moving the finger.

- * - *

Here are some sample scenarios for this class of iterator:

- * - *
- * // accessing keys/values through an iterator:
- * for (TFloatDoubleIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     doSomethingWithValue(it.value());
- *   }
- * }
- * 
- * - *
- * // modifying values in-place through iteration:
- * for (TFloatDoubleIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.setValue(newValueForKey(it.key()));
- *   }
- * }
- * 
- * - *
- * // deleting entries during iteration:
- * for (TFloatDoubleIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.remove();
- *   }
- * }
- * 
- * - *
- * // faster iteration by avoiding hasNext():
- * TFloatDoubleIterator iterator = map.iterator();
- * for (int i = map.size(); i-- > 0;) {    
- *   iterator.advance();     
- *   doSomethingWithKeyAndValue(iterator.key(), iterator.value());
- * }   
- * 
- * - * @author Eric D. Friedman - * @version $Id: TFloatDoubleIterator.java,v 1.1 2002/09/22 21:53:40 ericdf Exp $ - */ - -public class TFloatDoubleIterator extends TPrimitiveIterator { - /** the collection being iterated over */ - private final TFloatDoubleHashMap _map; - - /** - * Creates an iterator over the specified map - */ - public TFloatDoubleIterator(TFloatDoubleHashMap map) { - super(map); - this._map = map; - } - - /** - * Moves the iterator forward to the next entry in the underlying map. - * - * @exception java.util.NoSuchElementException if the iterator is already exhausted - */ - public void advance() { - moveToNextIndex(); - } - - /** - * Provides access to the key of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the key of the entry at the iterator's current position. - */ - public float key() { - return _map._set[_index]; - } - - /** - * Provides access to the value of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the value of the entry at the iterator's current position. - */ - public double value() { - return _map._values[_index]; - } - - /** - * Replace the value of the mapping at the iterator's position with the - * specified value. Note that you must advance() the iterator at - * least once before invoking this method. - * - * @param val the value to set in the current entry - * @return the old value of the entry. - */ - public double setValue(double val) { - double old = value(); - _map._values[_index] = val; - return old; - } -}// TFloatDoubleIterator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatDoubleProcedure.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatDoubleProcedure.java deleted file mode 100644 index 5e473ae13..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatDoubleProcedure.java +++ /dev/null @@ -1,43 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Interface for procedures that take two parameters of type float and double. - * - * Created: Mon Nov 5 22:03:30 2001 - * - * @author Eric D. Friedman - * @version $Id: TFloatDoubleProcedure.java,v 1.7 2002/09/22 21:53:40 ericdf Exp $ - */ - -public interface TFloatDoubleProcedure { - - /** - * Executes this procedure. A false return value indicates that - * the application executing this procedure should not invoke this - * procedure again. - * - * @param a an float value - * @param b an double value - * @return true if additional invocations of the procedure are - * allowed. - */ - public boolean execute(float a, double b); -}// TFloatDoubleProcedure diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatFloatHashMap.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatFloatHashMap.java deleted file mode 100644 index 9f44b0dc7..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatFloatHashMap.java +++ /dev/null @@ -1,535 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - -/** - * An open addressed Map implementation for float keys and float values. - * - * Created: Sun Nov 4 08:52:45 2001 - * - * @author Eric D. Friedman - * @version $Id: TFloatFloatHashMap.java,v 1.15 2003/11/21 17:32:30 ericdf Exp $ - */ -public class TFloatFloatHashMap extends TFloatHash implements Serializable { - - private static final long serialVersionUID = 2442317511947632708L; - /** the values of the map */ - protected transient float[] _values; - - /** - * Creates a new TFloatFloatHashMap instance with the default - * capacity and load factor. - */ - public TFloatFloatHashMap() { - super(); - } - - /** - * Creates a new TFloatFloatHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the default load factor. - * - * @param initialCapacity an int value - */ - public TFloatFloatHashMap(int initialCapacity) { - super(initialCapacity); - } - - /** - * Creates a new TFloatFloatHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the specified load factor. - * - * @param initialCapacity an int value - * @param loadFactor a float value - */ - public TFloatFloatHashMap(int initialCapacity, float loadFactor) { - super(initialCapacity, loadFactor); - } - - /** - * Creates a new TFloatFloatHashMap instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TFloatFloatHashMap(TFloatHashingStrategy strategy) { - super(strategy); - } - - /** - * Creates a new TFloatFloatHashMap instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TFloatFloatHashMap(int initialCapacity, TFloatHashingStrategy strategy) { - super(initialCapacity, strategy); - } - - /** - * Creates a new TFloatFloatHashMap instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TFloatFloatHashMap(int initialCapacity, float loadFactor, TFloatHashingStrategy strategy) { - super(initialCapacity, loadFactor, strategy); - } - - /** - * @return a deep clone of this collection - */ - @Override // GemStoneAddition - public Object clone() { - TFloatFloatHashMap m = (TFloatFloatHashMap)super.clone(); - m._values = this._values.clone(); - return m; - } - - /** - * @return a TFloatFloatIterator with access to this map's keys and values - */ - public TFloatFloatIterator iterator() { - return new TFloatFloatIterator(this); - } - - /** - * initializes the hashtable to a prime capacity which is at least - * initialCapacity + 1. - * - * @param initialCapacity an int value - * @return the actual capacity chosen - */ - @Override // GemStoneAddition - protected int setUp(int initialCapacity) { - int capacity; - - capacity = super.setUp(initialCapacity); - _values = new float[capacity]; - return capacity; - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an float value - * @param value an float value - * @return the previous value associated with key, - * or (float)0 if none was found. - */ - public float put(float key, float value) { - byte previousState; - float previous = 0; - int index = insertionIndex(key); - boolean isNewMapping = true; - if (index < 0) { - index = -index -1; - previous = _values[index]; - isNewMapping = false; - } - previousState = _states[index]; - _set[index] = key; - _states[index] = FULL; - _values[index] = value; - if (isNewMapping) { - postInsertHook(previousState == FREE); - } - - return previous; - } - - /** - * rehashes the map to the new capacity. - * - * @param newCapacity an int value - */ - @Override // GemStoneAddition - protected void rehash(int newCapacity) { - int oldCapacity = _set.length; - float oldKeys[] = _set; - float oldVals[] = _values; - byte oldStates[] = _states; - - _set = new float[newCapacity]; - _values = new float[newCapacity]; - _states = new byte[newCapacity]; - - for (int i = oldCapacity; i-- > 0;) { - if(oldStates[i] == FULL) { - float o = oldKeys[i]; - int index = insertionIndex(o); - _set[index] = o; - _values[index] = oldVals[i]; - _states[index] = FULL; - } - } - } - - /** - * retrieves the value for key - * - * @param key an float value - * @return the value of key or (float)0 if no such mapping exists. - */ - public float get(float key) { - int index = index(key); - return index < 0 ? (float)0 : _values[index]; - } - - /** - * Empties the map. - * - */ - @Override // GemStoneAddition - public void clear() { - super.clear(); - float[] keys = _set; - float[] vals = _values; - byte[] states = _states; - - for (int i = keys.length; i-- > 0;) { - keys[i] = 0; - vals[i] = 0; - states[i] = FREE; - } - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an float value - * @return an float value, or (float)0 if no mapping for key exists - */ - public float remove(float key) { - float prev = 0; - int index = index(key); - if (index >= 0) { - prev = _values[index]; - removeAt(index); // clear key,state; adjust size - } - return prev; - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (! (other instanceof TFloatFloatHashMap)) { - return false; - } - TFloatFloatHashMap that = (TFloatFloatHashMap)other; - if (that.size() != this.size()) { - return false; - } - return forEachEntry(new EqProcedure(that)); - } - - @Override // GemStoneAddition - public int hashCode() { - HashProcedure p = new HashProcedure(); - forEachEntry(p); - return p.getHashCode(); - } - - protected/*GemStoneAddition*/ final class HashProcedure implements TFloatFloatProcedure { - private int h = 0; - - public int getHashCode() { - return h; - } - - public final boolean execute(float key, float value) { - h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); - return true; - } - } - - private static final class EqProcedure implements TFloatFloatProcedure { - private final TFloatFloatHashMap _otherMap; - - EqProcedure(TFloatFloatHashMap otherMap) { - _otherMap = otherMap; - } - - public final boolean execute(float key, float value) { - int index = _otherMap.index(key); - if (index >= 0 && eq(value, _otherMap.get(key))) { - return true; - } - return false; - } - - /** - * Compare two floats for equality. - */ - private final boolean eq(float v1, float v2) { - return v1 == v2; - } - - } - - /** - * removes the mapping at index from the map. - * - * @param index an int value - */ - @Override // GemStoneAddition - protected void removeAt(int index) { - super.removeAt(index); // clear key, state; adjust size - _values[index] = 0; - } - - /** - * Returns the values of the map. - * - * @return a Collection value - */ - public float[] getValues() { - float[] vals = new float[size()]; - float[] v = _values; - byte[] states = _states; - - for (int i = v.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - vals[j++] = v[i]; - } - } - return vals; - } - - /** - * returns the keys of the map. - * - * @return a Set value - */ - public float[] keys() { - float[] keys = new float[size()]; - float[] k = _set; - byte[] states = _states; - - for (int i = k.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - keys[j++] = k[i]; - } - } - return keys; - } - - /** - * checks for the presence of val in the values of the map. - * - * @param val an float value - * @return a boolean value - */ - public boolean containsValue(float val) { - byte[] states = _states; - float[] vals = _values; - - for (int i = vals.length; i-- > 0;) { - if (states[i] == FULL && val == vals[i]) { - return true; - } - } - return false; - } - - - /** - * checks for the present of key in the keys of the map. - * - * @param key an float value - * @return a boolean value - */ - public boolean containsKey(float key) { - return contains(key); - } - - /** - * Executes procedure for each key in the map. - * - * @param procedure a TFloatProcedure value - * @return false if the loop over the keys terminated because - * the procedure returned false for some key. - */ - public boolean forEachKey(TFloatProcedure procedure) { - return forEach(procedure); - } - - /** - * Executes procedure for each value in the map. - * - * @param procedure a TFloatProcedure value - * @return false if the loop over the values terminated because - * the procedure returned false for some value. - */ - public boolean forEachValue(TFloatProcedure procedure) { - byte[] states = _states; - float[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(values[i])) { - return false; - } - } - return true; - } - - /** - * Executes procedure for each key/value entry in the - * map. - * - * @param procedure a TOFloatFloatProcedure value - * @return false if the loop over the entries terminated because - * the procedure returned false for some entry. - */ - public boolean forEachEntry(TFloatFloatProcedure procedure) { - byte[] states = _states; - float[] keys = _set; - float[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - return false; - } - } - return true; - } - - /** - * Retains only those entries in the map for which the procedure - * returns a true value. - * - * @param procedure determines which entries to keep - * @return true if the map was modified. - */ - public boolean retainEntries(TFloatFloatProcedure procedure) { - boolean modified = false; - byte[] states = _states; - float[] keys = _set; - float[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - removeAt(i); - modified = true; - } - } - return modified; - } - - /** - * Transform the values in this map using function. - * - * @param function a TFloatFunction value - */ - public void transformValues(TFloatFunction function) { - byte[] states = _states; - float[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL) { - values[i] = function.execute(values[i]); - } - } - } - - /** - * Increments the primitive value mapped to key by 1 - * - * @param key the key of the value to increment - * @return true if a mapping was found and modified. - */ - public boolean increment(float key) { - return adjustValue(key, 1); - } - - /** - * Adjusts the primitive value mapped to key. - * - * @param key the key of the value to increment - * @param amount the amount to adjust the value by. - * @return true if a mapping was found and modified. - */ - public boolean adjustValue(float key, float amount) { - int index = index(key); - if (index < 0) { - return false; - } else { - _values[index] += amount; - return true; - } - } - - - private void writeObject(ObjectOutputStream stream) - throws IOException { - stream.defaultWriteObject(); - - // number of entries - stream.writeInt(_size); - - SerializationProcedure writeProcedure = new SerializationProcedure(stream); - if (! forEachEntry(writeProcedure)) { - throw writeProcedure.exception; - } - } - - private void readObject(ObjectInputStream stream) - throws IOException, ClassNotFoundException { - stream.defaultReadObject(); - - int size = stream.readInt(); - setUp(size); - while (size-- > 0) { - float key = stream.readFloat(); - float val = stream.readFloat(); - put(key, val); - } - } -} // TFloatFloatHashMap diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatFloatIterator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatFloatIterator.java deleted file mode 100644 index 5af2fa6fc..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatFloatIterator.java +++ /dev/null @@ -1,145 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Iterator for maps of type float and float. - * - *

The iterator semantics for Trove's primitive maps is slightly different - * from those defined in java.util.Iterator, but still well within - * the scope of the pattern, as defined by Gamma, et al.

- * - *

This iterator does not implicitly advance to the next entry when - * the value at the current position is retrieved. Rather, you must explicitly - * ask the iterator to advance() and then retrieve either the key(), - * the value() or both. This is done so that you have the option, but not - * the obligation, to retrieve keys and/or values as your application requires, and - * without introducing wrapper objects that would carry both. As the iteration is - * stateful, access to the key/value parts of the current map entry happens in - * constant time.

- * - *

In practice, the iterator is akin to a "search finger" that you move from - * position to position. Read or write operations affect the current entry only and - * do not assume responsibility for moving the finger.

- * - *

Here are some sample scenarios for this class of iterator:

- * - *
- * // accessing keys/values through an iterator:
- * for (TFloatFloatIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     doSomethingWithValue(it.value());
- *   }
- * }
- * 
- * - *
- * // modifying values in-place through iteration:
- * for (TFloatFloatIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.setValue(newValueForKey(it.key()));
- *   }
- * }
- * 
- * - *
- * // deleting entries during iteration:
- * for (TFloatFloatIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.remove();
- *   }
- * }
- * 
- * - *
- * // faster iteration by avoiding hasNext():
- * TFloatFloatIterator iterator = map.iterator();
- * for (int i = map.size(); i-- > 0;) {    
- *   iterator.advance();     
- *   doSomethingWithKeyAndValue(iterator.key(), iterator.value());
- * }   
- * 
- * - * @author Eric D. Friedman - * @version $Id: TFloatFloatIterator.java,v 1.1 2002/09/22 21:53:40 ericdf Exp $ - */ - -public class TFloatFloatIterator extends TPrimitiveIterator { - /** the collection being iterated over */ - private final TFloatFloatHashMap _map; - - /** - * Creates an iterator over the specified map - */ - public TFloatFloatIterator(TFloatFloatHashMap map) { - super(map); - this._map = map; - } - - /** - * Moves the iterator forward to the next entry in the underlying map. - * - * @exception java.util.NoSuchElementException if the iterator is already exhausted - */ - public void advance() { - moveToNextIndex(); - } - - /** - * Provides access to the key of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the key of the entry at the iterator's current position. - */ - public float key() { - return _map._set[_index]; - } - - /** - * Provides access to the value of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the value of the entry at the iterator's current position. - */ - public float value() { - return _map._values[_index]; - } - - /** - * Replace the value of the mapping at the iterator's position with the - * specified value. Note that you must advance() the iterator at - * least once before invoking this method. - * - * @param val the value to set in the current entry - * @return the old value of the entry. - */ - public float setValue(float val) { - float old = value(); - _map._values[_index] = val; - return old; - } -}// TFloatFloatIterator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatFloatProcedure.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatFloatProcedure.java deleted file mode 100644 index 0f162afab..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatFloatProcedure.java +++ /dev/null @@ -1,43 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Interface for procedures that take two parameters of type float and float. - * - * Created: Mon Nov 5 22:03:30 2001 - * - * @author Eric D. Friedman - * @version $Id: TFloatFloatProcedure.java,v 1.7 2002/09/22 21:53:40 ericdf Exp $ - */ - -public interface TFloatFloatProcedure { - - /** - * Executes this procedure. A false return value indicates that - * the application executing this procedure should not invoke this - * procedure again. - * - * @param a an float value - * @param b an float value - * @return true if additional invocations of the procedure are - * allowed. - */ - public boolean execute(float a, float b); -}// TFloatFloatProcedure diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatFunction.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatFunction.java deleted file mode 100644 index ed9e41447..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatFunction.java +++ /dev/null @@ -1,38 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Interface for functions that accept and return one float primitive. - * - * Created: Mon Nov 5 22:19:36 2001 - * - * @author Eric D. Friedman - * @version $Id: TFloatFunction.java,v 1.8 2002/09/22 21:53:40 ericdf Exp $ - */ - -public interface TFloatFunction { - /** - * Execute this function with value - * - * @param value an float input - * @return an float result - */ - public float execute(float value); -}// TFloatFunction diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatHash.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatHash.java deleted file mode 100644 index 3582bf3e9..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatHash.java +++ /dev/null @@ -1,309 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove; - -import java.io.Serializable; - -/** - * An open addressed hashing implementation for float primitives. - * - * Created: Sun Nov 4 08:56:06 2001 - * - * @author Eric D. Friedman - * @version $Id: TFloatHash.java,v 1.14 2004/02/25 14:05:29 ericdf Exp $ - */ - -abstract public class TFloatHash extends TPrimitiveHash - implements Serializable, TFloatHashingStrategy { - - /** the set of floats */ - protected transient float[] _set; - - /** strategy used to hash values in this collection */ - protected TFloatHashingStrategy _hashingStrategy; - - /** - * Creates a new TFloatHash instance with the default - * capacity and load factor. - */ - public TFloatHash() { - super(); - this._hashingStrategy = this; - } - - /** - * Creates a new TFloatHash instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - */ - public TFloatHash(int initialCapacity) { - super(initialCapacity); - this._hashingStrategy = this; - } - - /** - * Creates a new TFloatHash instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - */ - public TFloatHash(int initialCapacity, float loadFactor) { - super(initialCapacity, loadFactor); - this._hashingStrategy = this; - } - - /** - * Creates a new TFloatHash instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TFloatHash(TFloatHashingStrategy strategy) { - super(); - this._hashingStrategy = strategy; - } - - /** - * Creates a new TFloatHash instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TFloatHash(int initialCapacity, TFloatHashingStrategy strategy) { - super(initialCapacity); - this._hashingStrategy = strategy; - } - - /** - * Creates a new TFloatHash instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TFloatHash(int initialCapacity, float loadFactor, TFloatHashingStrategy strategy) { - super(initialCapacity, loadFactor); - this._hashingStrategy = strategy; - } - - /** - * @return a deep clone of this collection - */ - @Override // GemStoneAddition - public Object clone() { - TFloatHash h = (TFloatHash)super.clone(); - h._set = this._set.clone(); - return h; - } - - /** - * initializes the hashtable to a prime capacity which is at least - * initialCapacity + 1. - * - * @param initialCapacity an int value - * @return the actual capacity chosen - */ - @Override // GemStoneAddition - protected int setUp(int initialCapacity) { - int capacity; - - capacity = super.setUp(initialCapacity); - _set = new float[capacity]; - return capacity; - } - - /** - * Searches the set for val - * - * @param val an float value - * @return a boolean value - */ - public boolean contains(float val) { - return index(val) >= 0; - } - - /** - * Executes procedure for each element in the set. - * - * @param procedure a TObjectProcedure value - * @return false if the loop over the set terminated because - * the procedure returned false for some value. - */ - public boolean forEach(TFloatProcedure procedure) { - byte[] states = _states; - float[] set = _set; - for (int i = set.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(set[i])) { - return false; - } - } - return true; - } - - /** - * Releases the element currently stored at index. - * - * @param index an int value - */ - @Override // GemStoneAddition - protected void removeAt(int index) { - super.removeAt(index); - _set[index] = 0; - } - - /** - * Locates the index of val. - * - * @param val an float value - * @return the index of val or -1 if it isn't in the set. - */ - protected int index(float val) { - int hash, probe, index, length; - float[] set; - byte[] states; - - states = _states; - set = _set; - length = states.length; - hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff; - index = hash % length; - - if (states[index] != FREE && - (states[index] == REMOVED || set[index] != val)) { - // see Knuth, p. 529 - probe = 1 + (hash % (length - 2)); - - do { - index -= probe; - if (index < 0) { - index += length; - } - } while (states[index] != FREE && - (states[index] == REMOVED || set[index] != val)); - } - - return states[index] == FREE ? -1 : index; - } - - /** - * Locates the index at which val can be inserted. if - * there is already a value equal()ing val in the set, - * returns that value as a negative integer. - * - * @param val an float value - * @return an int value - */ - protected int insertionIndex(float val) { - int hash, probe, index, length; - float[] set; - byte[] states; - - states = _states; - set = _set; - length = states.length; - hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff; - index = hash % length; - - if (states[index] == FREE) { - return index; // empty, all done - } else if (states[index] == FULL && set[index] == val) { - return -index -1; // already stored - } else { // already FULL or REMOVED, must probe - // compute the double hash - probe = 1 + (hash % (length - 2)); - - // if the slot we landed on is FULL (but not removed), probe - // until we find an empty slot, a REMOVED slot, or an element - // equal to the one we are trying to insert. - // finding an empty slot means that the value is not present - // and that we should use that slot as the insertion point; - // finding a REMOVED slot means that we need to keep searching, - // however we want to remember the offset of that REMOVED slot - // so we can reuse it in case a "new" insertion (i.e. not an update) - // is possible. - // finding a matching value means that we've found that our desired - // key is already in the table - - if (states[index] != REMOVED) { - // starting at the natural offset, probe until we find an - // offset that isn't full. - do { - index -= probe; - if (index < 0) { - index += length; - } - } while (states[index] == FULL && set[index] != val); - } - - // if the index we found was removed: continue probing until we - // locate a free location or an element which equal()s the - // one we have. - if (states[index] == REMOVED) { - int firstRemoved = index; - while (states[index] != FREE && - (states[index] == REMOVED || set[index] != val)) { - index -= probe; - if (index < 0) { - index += length; - } - } - return states[index] == FULL ? -index -1 : firstRemoved; - } - // if it's full, the key is already stored - return states[index] == FULL ? -index -1 : index; - } - } - - /** - * Default implementation of TFloatHashingStrategy: - * delegates hashing to HashFunctions.hash(float). - * - * @param val the value to hash - * @return the hashcode. - */ - public final int computeHashCode(float val) { - return HashFunctions.hash(val); - } -} // TFloatHash diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatHashSet.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatHashSet.java deleted file mode 100644 index d2a21ae8d..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatHashSet.java +++ /dev/null @@ -1,385 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; -//import java.io.Serializable; -import java.util.Arrays; - -/** - * An open addressed set implementation for float primitives. - * - * Created: Sat Nov 3 10:38:17 2001 - * - * @author Eric D. Friedman - * @version $Id: TFloatHashSet.java,v 1.11 2003/03/19 04:17:03 ericdf Exp $ - */ - -public class TFloatHashSet extends TFloatHash implements Serializable { - - private static final long serialVersionUID = -2621338101966411198L; - - /** - * Creates a new TFloatHashSet instance with the default - * capacity and load factor. - */ - public TFloatHashSet() { - super(); - } - - /** - * Creates a new TFloatHashSet instance with a prime - * capacity equal to or greater than initialCapacity and - * with the default load factor. - * - * @param initialCapacity an int value - */ - public TFloatHashSet(int initialCapacity) { - super(initialCapacity); - } - - /** - * Creates a new TFloatHashSet instance with a prime - * capacity equal to or greater than initialCapacity and - * with the specified load factor. - * - * @param initialCapacity an int value - * @param loadFactor a float value - */ - public TFloatHashSet(int initialCapacity, float loadFactor) { - super(initialCapacity, loadFactor); - } - - /** - * Creates a new TFloatHashSet instance containing the - * elements of array. - * - * @param array an array of float primitives - */ - public TFloatHashSet(float[] array) { - this(array.length); - addAll(array); - } - - /** - * Creates a new TFloatHash instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TFloatHashSet(TFloatHashingStrategy strategy) { - super(strategy); - } - - /** - * Creates a new TFloatHash instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TFloatHashSet(int initialCapacity, TFloatHashingStrategy strategy) { - super(initialCapacity, strategy); - } - - /** - * Creates a new TFloatHash instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TFloatHashSet(int initialCapacity, float loadFactor, TFloatHashingStrategy strategy) { - super(initialCapacity, loadFactor, strategy); - } - - /** - * Creates a new TFloatHashSet instance containing the - * elements of array. - * - * @param array an array of float primitives - * @param strategy used to compute hash codes and to compare keys. - */ - public TFloatHashSet(float[] array, TFloatHashingStrategy strategy) { - this(array.length, strategy); - addAll(array); - } - - /** - * @return a TFloatIterator with access to the values in this set - */ - public TFloatIterator iterator() { - return new TFloatIterator(this); - } - - /** - * Inserts a value into the set. - * - * @param val an float value - * @return true if the set was modified by the add operation - */ - public boolean add(float val) { - int index = insertionIndex(val); - - if (index < 0) { - return false; // already present in set, nothing to add - } - - byte previousState = _states[index]; - _set[index] = val; - _states[index] = FULL; - postInsertHook(previousState == FREE); - - return true; // yes, we added something - } - - /** - * Expands the set to accomodate new values. - * - * @param newCapacity an int value - */ - @Override // GemStoneAddition - protected void rehash(int newCapacity) { - int oldCapacity = _set.length; - float oldSet[] = _set; - byte oldStates[] = _states; - - _set = new float[newCapacity]; - _states = new byte[newCapacity]; - - for (int i = oldCapacity; i-- > 0;) { - if(oldStates[i] == FULL) { - float o = oldSet[i]; - int index = insertionIndex(o); - _set[index] = o; - _states[index] = FULL; - } - } - } - - /** - * Returns a new array containing the values in the set. - * - * @return an float[] value - */ - public float[] toArray() { - float[] result = new float[size()]; - float[] set = _set; - byte[] states = _states; - - for (int i = states.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - result[j++] = set[i]; - } - } - return result; - } - - /** - * Empties the set. - */ - @Override // GemStoneAddition - public void clear() { - super.clear(); - float[] set = _set; - byte[] states = _states; - - for (int i = set.length; i-- > 0;) { - set[i] = 0; - states[i] = FREE; - } - } - - /** - * Compares this set with another set for equality of their stored - * entries. - * - * @param other an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (! (other instanceof TFloatHashSet)) { - return false; - } - final TFloatHashSet that = (TFloatHashSet)other; - if (that.size() != this.size()) { - return false; - } - return forEach(new TFloatProcedure() { - public final boolean execute(float value) { - return that.contains(value); - } - }); - } - - @Override // GemStoneAddition - public int hashCode() { - HashProcedure p = new HashProcedure(); - forEach(p); - return p.getHashCode(); - } - - protected/*GemStoneAddition*/ final class HashProcedure implements TFloatProcedure { - private int h = 0; - - public int getHashCode() { - return h; - } - - public final boolean execute(float key) { - h += _hashingStrategy.computeHashCode(key); - return true; - } - } - - /** - * Removes val from the set. - * - * @param val an float value - * @return true if the set was modified by the remove operation. - */ - public boolean remove(float val) { - int index = index(val); - if (index >= 0) { - removeAt(index); - return true; - } - return false; - } - - /** - * Tests the set to determine if all of the elements in - * array are present. - * - * @param array an array of float primitives. - * @return true if all elements were present in the set. - */ - public boolean containsAll(float[] array) { - for (int i = array.length; i-- > 0;) { - if (! contains(array[i])) { - return false; - } - } - return true; - } - - /** - * Adds all of the elements in array to the set. - * - * @param array an array of float primitives. - * @return true if the set was modified by the add all operation. - */ - public boolean addAll(float[] array) { - boolean changed = false; - for (int i = array.length; i-- > 0;) { - if (add(array[i])) { - changed = true; - } - } - return changed; - } - - /** - * Removes all of the elements in array from the set. - * - * @param array an array of float primitives. - * @return true if the set was modified by the remove all operation. - */ - public boolean removeAll(float[] array) { - boolean changed = false; - for (int i = array.length; i-- > 0;) { - if (remove(array[i])) { - changed = true; - } - } - return changed; - } - - /** - * Removes any values in the set which are not contained in - * array. - * - * @param array an array of float primitives. - * @return true if the set was modified by the retain all operation - */ - public boolean retainAll(float[] array) { - boolean changed = false; - Arrays.sort(array); - float[] set = _set; - byte[] states = _states; - - for (int i = set.length; i-- > 0;) { - if (states[i] == FULL && (Arrays.binarySearch(array,set[i]) < 0)) { - remove(set[i]); - changed = true; - } - } - return changed; - } - - private void writeObject(ObjectOutputStream stream) - throws IOException { - stream.defaultWriteObject(); - - // number of entries - stream.writeInt(_size); - - SerializationProcedure writeProcedure = new SerializationProcedure(stream); - if (! forEach(writeProcedure)) { - throw writeProcedure.exception; - } - } - - private void readObject(ObjectInputStream stream) - throws IOException, ClassNotFoundException { - stream.defaultReadObject(); - - int size = stream.readInt(); - setUp(size); - while (size-- > 0) { - float val = stream.readFloat(); - add(val); - } - } -} // TFloatHashSet diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatHashingStrategy.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatHashingStrategy.java deleted file mode 100644 index 3fcbf3fa6..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatHashingStrategy.java +++ /dev/null @@ -1,44 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -import java.io.Serializable; - -/** - * Interface to support pluggable hashing strategies in maps and sets. - * Implementors can use this interface to make the trove hashing - * algorithms use an optimal strategy when computing hashcodes. - * - * Created: Sun Nov 4 08:56:06 2001 - * - * @author Eric D. Friedman - * @version $Id: TFloatHashingStrategy.java,v 1.3 2002/09/22 21:53:40 ericdf Exp $ - */ - -public interface TFloatHashingStrategy extends Serializable { - /** - * Computes a hash code for the specified float. Implementors - * can use the float's own value or a custom scheme designed to - * minimize collisions for a known set of input. - * - * @param val float for which the hashcode is to be computed - * @return the hashCode - */ - public int computeHashCode(float val); -} // TFloatHashingStrategy diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatIntHashMap.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatIntHashMap.java deleted file mode 100644 index 117a5276a..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatIntHashMap.java +++ /dev/null @@ -1,535 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - -/** - * An open addressed Map implementation for float keys and int values. - * - * Created: Sun Nov 4 08:52:45 2001 - * - * @author Eric D. Friedman - * @version $Id: TFloatIntHashMap.java,v 1.15 2003/11/21 17:32:30 ericdf Exp $ - */ -public class TFloatIntHashMap extends TFloatHash implements Serializable { - - private static final long serialVersionUID = 7646740668793937150L; - /** the values of the map */ - protected transient int[] _values; - - /** - * Creates a new TFloatIntHashMap instance with the default - * capacity and load factor. - */ - public TFloatIntHashMap() { - super(); - } - - /** - * Creates a new TFloatIntHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the default load factor. - * - * @param initialCapacity an int value - */ - public TFloatIntHashMap(int initialCapacity) { - super(initialCapacity); - } - - /** - * Creates a new TFloatIntHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the specified load factor. - * - * @param initialCapacity an int value - * @param loadFactor a float value - */ - public TFloatIntHashMap(int initialCapacity, float loadFactor) { - super(initialCapacity, loadFactor); - } - - /** - * Creates a new TFloatIntHashMap instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TFloatIntHashMap(TFloatHashingStrategy strategy) { - super(strategy); - } - - /** - * Creates a new TFloatIntHashMap instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TFloatIntHashMap(int initialCapacity, TFloatHashingStrategy strategy) { - super(initialCapacity, strategy); - } - - /** - * Creates a new TFloatIntHashMap instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TFloatIntHashMap(int initialCapacity, float loadFactor, TFloatHashingStrategy strategy) { - super(initialCapacity, loadFactor, strategy); - } - - /** - * @return a deep clone of this collection - */ - @Override // GemStoneAddition - public Object clone() { - TFloatIntHashMap m = (TFloatIntHashMap)super.clone(); - m._values = this._values.clone(); - return m; - } - - /** - * @return a TFloatIntIterator with access to this map's keys and values - */ - public TFloatIntIterator iterator() { - return new TFloatIntIterator(this); - } - - /** - * initializes the hashtable to a prime capacity which is at least - * initialCapacity + 1. - * - * @param initialCapacity an int value - * @return the actual capacity chosen - */ - @Override // GemStoneAddition - protected int setUp(int initialCapacity) { - int capacity; - - capacity = super.setUp(initialCapacity); - _values = new int[capacity]; - return capacity; - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an float value - * @param value an int value - * @return the previous value associated with key, - * or (int)0 if none was found. - */ - public int put(float key, int value) { - byte previousState; - int previous = 0; - int index = insertionIndex(key); - boolean isNewMapping = true; - if (index < 0) { - index = -index -1; - previous = _values[index]; - isNewMapping = false; - } - previousState = _states[index]; - _set[index] = key; - _states[index] = FULL; - _values[index] = value; - if (isNewMapping) { - postInsertHook(previousState == FREE); - } - - return previous; - } - - /** - * rehashes the map to the new capacity. - * - * @param newCapacity an int value - */ - @Override // GemStoneAddition - protected void rehash(int newCapacity) { - int oldCapacity = _set.length; - float oldKeys[] = _set; - int oldVals[] = _values; - byte oldStates[] = _states; - - _set = new float[newCapacity]; - _values = new int[newCapacity]; - _states = new byte[newCapacity]; - - for (int i = oldCapacity; i-- > 0;) { - if(oldStates[i] == FULL) { - float o = oldKeys[i]; - int index = insertionIndex(o); - _set[index] = o; - _values[index] = oldVals[i]; - _states[index] = FULL; - } - } - } - - /** - * retrieves the value for key - * - * @param key an float value - * @return the value of key or (int)0 if no such mapping exists. - */ - public int get(float key) { - int index = index(key); - return index < 0 ? (int)0 : _values[index]; - } - - /** - * Empties the map. - * - */ - @Override // GemStoneAddition - public void clear() { - super.clear(); - float[] keys = _set; - int[] vals = _values; - byte[] states = _states; - - for (int i = keys.length; i-- > 0;) { - keys[i] = 0; - vals[i] = 0; - states[i] = FREE; - } - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an float value - * @return an int value, or (int)0 if no mapping for key exists - */ - public int remove(float key) { - int prev = 0; - int index = index(key); - if (index >= 0) { - prev = _values[index]; - removeAt(index); // clear key,state; adjust size - } - return prev; - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (! (other instanceof TFloatIntHashMap)) { - return false; - } - TFloatIntHashMap that = (TFloatIntHashMap)other; - if (that.size() != this.size()) { - return false; - } - return forEachEntry(new EqProcedure(that)); - } - - @Override // GemStoneAddition - public int hashCode() { - HashProcedure p = new HashProcedure(); - forEachEntry(p); - return p.getHashCode(); - } - - protected/*GemStoneAddition*/ final class HashProcedure implements TFloatIntProcedure { - private int h = 0; - - public int getHashCode() { - return h; - } - - public final boolean execute(float key, int value) { - h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); - return true; - } - } - - private static final class EqProcedure implements TFloatIntProcedure { - private final TFloatIntHashMap _otherMap; - - EqProcedure(TFloatIntHashMap otherMap) { - _otherMap = otherMap; - } - - public final boolean execute(float key, int value) { - int index = _otherMap.index(key); - if (index >= 0 && eq(value, _otherMap.get(key))) { - return true; - } - return false; - } - - /** - * Compare two ints for equality. - */ - private final boolean eq(int v1, int v2) { - return v1 == v2; - } - - } - - /** - * removes the mapping at index from the map. - * - * @param index an int value - */ - @Override // GemStoneAddition - protected void removeAt(int index) { - super.removeAt(index); // clear key, state; adjust size - _values[index] = 0; - } - - /** - * Returns the values of the map. - * - * @return a Collection value - */ - public int[] getValues() { - int[] vals = new int[size()]; - int[] v = _values; - byte[] states = _states; - - for (int i = v.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - vals[j++] = v[i]; - } - } - return vals; - } - - /** - * returns the keys of the map. - * - * @return a Set value - */ - public float[] keys() { - float[] keys = new float[size()]; - float[] k = _set; - byte[] states = _states; - - for (int i = k.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - keys[j++] = k[i]; - } - } - return keys; - } - - /** - * checks for the presence of val in the values of the map. - * - * @param val an int value - * @return a boolean value - */ - public boolean containsValue(int val) { - byte[] states = _states; - int[] vals = _values; - - for (int i = vals.length; i-- > 0;) { - if (states[i] == FULL && val == vals[i]) { - return true; - } - } - return false; - } - - - /** - * checks for the present of key in the keys of the map. - * - * @param key an float value - * @return a boolean value - */ - public boolean containsKey(float key) { - return contains(key); - } - - /** - * Executes procedure for each key in the map. - * - * @param procedure a TFloatProcedure value - * @return false if the loop over the keys terminated because - * the procedure returned false for some key. - */ - public boolean forEachKey(TFloatProcedure procedure) { - return forEach(procedure); - } - - /** - * Executes procedure for each value in the map. - * - * @param procedure a TIntProcedure value - * @return false if the loop over the values terminated because - * the procedure returned false for some value. - */ - public boolean forEachValue(TIntProcedure procedure) { - byte[] states = _states; - int[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(values[i])) { - return false; - } - } - return true; - } - - /** - * Executes procedure for each key/value entry in the - * map. - * - * @param procedure a TOFloatIntProcedure value - * @return false if the loop over the entries terminated because - * the procedure returned false for some entry. - */ - public boolean forEachEntry(TFloatIntProcedure procedure) { - byte[] states = _states; - float[] keys = _set; - int[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - return false; - } - } - return true; - } - - /** - * Retains only those entries in the map for which the procedure - * returns a true value. - * - * @param procedure determines which entries to keep - * @return true if the map was modified. - */ - public boolean retainEntries(TFloatIntProcedure procedure) { - boolean modified = false; - byte[] states = _states; - float[] keys = _set; - int[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - removeAt(i); - modified = true; - } - } - return modified; - } - - /** - * Transform the values in this map using function. - * - * @param function a TIntFunction value - */ - public void transformValues(TIntFunction function) { - byte[] states = _states; - int[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL) { - values[i] = function.execute(values[i]); - } - } - } - - /** - * Increments the primitive value mapped to key by 1 - * - * @param key the key of the value to increment - * @return true if a mapping was found and modified. - */ - public boolean increment(float key) { - return adjustValue(key, 1); - } - - /** - * Adjusts the primitive value mapped to key. - * - * @param key the key of the value to increment - * @param amount the amount to adjust the value by. - * @return true if a mapping was found and modified. - */ - public boolean adjustValue(float key, int amount) { - int index = index(key); - if (index < 0) { - return false; - } else { - _values[index] += amount; - return true; - } - } - - - private void writeObject(ObjectOutputStream stream) - throws IOException { - stream.defaultWriteObject(); - - // number of entries - stream.writeInt(_size); - - SerializationProcedure writeProcedure = new SerializationProcedure(stream); - if (! forEachEntry(writeProcedure)) { - throw writeProcedure.exception; - } - } - - private void readObject(ObjectInputStream stream) - throws IOException, ClassNotFoundException { - stream.defaultReadObject(); - - int size = stream.readInt(); - setUp(size); - while (size-- > 0) { - float key = stream.readFloat(); - int val = stream.readInt(); - put(key, val); - } - } -} // TFloatIntHashMap diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatIntIterator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatIntIterator.java deleted file mode 100644 index ff1f0f71e..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatIntIterator.java +++ /dev/null @@ -1,145 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Iterator for maps of type float and int. - * - *

The iterator semantics for Trove's primitive maps is slightly different - * from those defined in java.util.Iterator, but still well within - * the scope of the pattern, as defined by Gamma, et al.

- * - *

This iterator does not implicitly advance to the next entry when - * the value at the current position is retrieved. Rather, you must explicitly - * ask the iterator to advance() and then retrieve either the key(), - * the value() or both. This is done so that you have the option, but not - * the obligation, to retrieve keys and/or values as your application requires, and - * without introducing wrapper objects that would carry both. As the iteration is - * stateful, access to the key/value parts of the current map entry happens in - * constant time.

- * - *

In practice, the iterator is akin to a "search finger" that you move from - * position to position. Read or write operations affect the current entry only and - * do not assume responsibility for moving the finger.

- * - *

Here are some sample scenarios for this class of iterator:

- * - *
- * // accessing keys/values through an iterator:
- * for (TFloatIntIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     doSomethingWithValue(it.value());
- *   }
- * }
- * 
- * - *
- * // modifying values in-place through iteration:
- * for (TFloatIntIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.setValue(newValueForKey(it.key()));
- *   }
- * }
- * 
- * - *
- * // deleting entries during iteration:
- * for (TFloatIntIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.remove();
- *   }
- * }
- * 
- * - *
- * // faster iteration by avoiding hasNext():
- * TFloatIntIterator iterator = map.iterator();
- * for (int i = map.size(); i-- > 0;) {    
- *   iterator.advance();     
- *   doSomethingWithKeyAndValue(iterator.key(), iterator.value());
- * }   
- * 
- * - * @author Eric D. Friedman - * @version $Id: TFloatIntIterator.java,v 1.1 2002/09/22 21:53:41 ericdf Exp $ - */ - -public class TFloatIntIterator extends TPrimitiveIterator { - /** the collection being iterated over */ - private final TFloatIntHashMap _map; - - /** - * Creates an iterator over the specified map - */ - public TFloatIntIterator(TFloatIntHashMap map) { - super(map); - this._map = map; - } - - /** - * Moves the iterator forward to the next entry in the underlying map. - * - * @exception java.util.NoSuchElementException if the iterator is already exhausted - */ - public void advance() { - moveToNextIndex(); - } - - /** - * Provides access to the key of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the key of the entry at the iterator's current position. - */ - public float key() { - return _map._set[_index]; - } - - /** - * Provides access to the value of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the value of the entry at the iterator's current position. - */ - public int value() { - return _map._values[_index]; - } - - /** - * Replace the value of the mapping at the iterator's position with the - * specified value. Note that you must advance() the iterator at - * least once before invoking this method. - * - * @param val the value to set in the current entry - * @return the old value of the entry. - */ - public int setValue(int val) { - int old = value(); - _map._values[_index] = val; - return old; - } -}// TFloatIntIterator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatIntProcedure.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatIntProcedure.java deleted file mode 100644 index e71d1776b..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatIntProcedure.java +++ /dev/null @@ -1,43 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Interface for procedures that take two parameters of type float and int. - * - * Created: Mon Nov 5 22:03:30 2001 - * - * @author Eric D. Friedman - * @version $Id: TFloatIntProcedure.java,v 1.7 2002/09/22 21:53:41 ericdf Exp $ - */ - -public interface TFloatIntProcedure { - - /** - * Executes this procedure. A false return value indicates that - * the application executing this procedure should not invoke this - * procedure again. - * - * @param a an float value - * @param b an int value - * @return true if additional invocations of the procedure are - * allowed. - */ - public boolean execute(float a, int b); -}// TFloatIntProcedure diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatIterator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatIterator.java deleted file mode 100644 index 0f72f6818..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatIterator.java +++ /dev/null @@ -1,51 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Iterator for float collections. - * - * @author Eric D. Friedman - * @version $Id: TFloatIterator.java,v 1.2 2003/03/19 04:41:29 ericdf Exp $ - */ - -public class TFloatIterator extends TPrimitiveIterator { - /** the collection on which the iterator operates */ - private final TFloatHash _hash; - - /** - * Creates a TFloatIterator for the elements in the specified collection. - */ - public TFloatIterator(TFloatHash hash) { - super(hash); - this._hash = hash; - } - - /** - * Advances the iterator to the next element in the underlying collection - * and returns it. - * - * @return the next float in the collection - * @exception java.util.NoSuchElementException if the iterator is already exhausted - */ - public float next() { - moveToNextIndex(); - return _hash._set[_index]; - } -}// TFloatIterator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatLongHashMap.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatLongHashMap.java deleted file mode 100644 index eed4cb4d7..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatLongHashMap.java +++ /dev/null @@ -1,535 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - -/** - * An open addressed Map implementation for float keys and long values. - * - * Created: Sun Nov 4 08:52:45 2001 - * - * @author Eric D. Friedman - * @version $Id: TFloatLongHashMap.java,v 1.15 2003/11/21 17:32:30 ericdf Exp $ - */ -public class TFloatLongHashMap extends TFloatHash implements Serializable { - - private static final long serialVersionUID = -5756501237589872730L; - /** the values of the map */ - protected transient long[] _values; - - /** - * Creates a new TFloatLongHashMap instance with the default - * capacity and load factor. - */ - public TFloatLongHashMap() { - super(); - } - - /** - * Creates a new TFloatLongHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the default load factor. - * - * @param initialCapacity an int value - */ - public TFloatLongHashMap(int initialCapacity) { - super(initialCapacity); - } - - /** - * Creates a new TFloatLongHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the specified load factor. - * - * @param initialCapacity an int value - * @param loadFactor a float value - */ - public TFloatLongHashMap(int initialCapacity, float loadFactor) { - super(initialCapacity, loadFactor); - } - - /** - * Creates a new TFloatLongHashMap instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TFloatLongHashMap(TFloatHashingStrategy strategy) { - super(strategy); - } - - /** - * Creates a new TFloatLongHashMap instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TFloatLongHashMap(int initialCapacity, TFloatHashingStrategy strategy) { - super(initialCapacity, strategy); - } - - /** - * Creates a new TFloatLongHashMap instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TFloatLongHashMap(int initialCapacity, float loadFactor, TFloatHashingStrategy strategy) { - super(initialCapacity, loadFactor, strategy); - } - - /** - * @return a deep clone of this collection - */ - @Override // GemStoneAddition - public Object clone() { - TFloatLongHashMap m = (TFloatLongHashMap)super.clone(); - m._values = this._values.clone(); - return m; - } - - /** - * @return a TFloatLongIterator with access to this map's keys and values - */ - public TFloatLongIterator iterator() { - return new TFloatLongIterator(this); - } - - /** - * initializes the hashtable to a prime capacity which is at least - * initialCapacity + 1. - * - * @param initialCapacity an int value - * @return the actual capacity chosen - */ - @Override // GemStoneAddition - protected int setUp(int initialCapacity) { - int capacity; - - capacity = super.setUp(initialCapacity); - _values = new long[capacity]; - return capacity; - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an float value - * @param value an long value - * @return the previous value associated with key, - * or (long)0 if none was found. - */ - public long put(float key, long value) { - byte previousState; - long previous = 0; - int index = insertionIndex(key); - boolean isNewMapping = true; - if (index < 0) { - index = -index -1; - previous = _values[index]; - isNewMapping = false; - } - previousState = _states[index]; - _set[index] = key; - _states[index] = FULL; - _values[index] = value; - if (isNewMapping) { - postInsertHook(previousState == FREE); - } - - return previous; - } - - /** - * rehashes the map to the new capacity. - * - * @param newCapacity an int value - */ - @Override // GemStoneAddition - protected void rehash(int newCapacity) { - int oldCapacity = _set.length; - float oldKeys[] = _set; - long oldVals[] = _values; - byte oldStates[] = _states; - - _set = new float[newCapacity]; - _values = new long[newCapacity]; - _states = new byte[newCapacity]; - - for (int i = oldCapacity; i-- > 0;) { - if(oldStates[i] == FULL) { - float o = oldKeys[i]; - int index = insertionIndex(o); - _set[index] = o; - _values[index] = oldVals[i]; - _states[index] = FULL; - } - } - } - - /** - * retrieves the value for key - * - * @param key an float value - * @return the value of key or (long)0 if no such mapping exists. - */ - public long get(float key) { - int index = index(key); - return index < 0 ? (long)0 : _values[index]; - } - - /** - * Empties the map. - * - */ - @Override // GemStoneAddition - public void clear() { - super.clear(); - float[] keys = _set; - long[] vals = _values; - byte[] states = _states; - - for (int i = keys.length; i-- > 0;) { - keys[i] = 0; - vals[i] = 0; - states[i] = FREE; - } - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an float value - * @return an long value, or (long)0 if no mapping for key exists - */ - public long remove(float key) { - long prev = 0; - int index = index(key); - if (index >= 0) { - prev = _values[index]; - removeAt(index); // clear key,state; adjust size - } - return prev; - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (! (other instanceof TFloatLongHashMap)) { - return false; - } - TFloatLongHashMap that = (TFloatLongHashMap)other; - if (that.size() != this.size()) { - return false; - } - return forEachEntry(new EqProcedure(that)); - } - - @Override // GemStoneAddition - public int hashCode() { - HashProcedure p = new HashProcedure(); - forEachEntry(p); - return p.getHashCode(); - } - - protected/*GemStoneAddition*/ final class HashProcedure implements TFloatLongProcedure { - private int h = 0; - - public int getHashCode() { - return h; - } - - public final boolean execute(float key, long value) { - h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); - return true; - } - } - - private static final class EqProcedure implements TFloatLongProcedure { - private final TFloatLongHashMap _otherMap; - - EqProcedure(TFloatLongHashMap otherMap) { - _otherMap = otherMap; - } - - public final boolean execute(float key, long value) { - int index = _otherMap.index(key); - if (index >= 0 && eq(value, _otherMap.get(key))) { - return true; - } - return false; - } - - /** - * Compare two longs for equality. - */ - private final boolean eq(long v1, long v2) { - return v1 == v2; - } - - } - - /** - * removes the mapping at index from the map. - * - * @param index an int value - */ - @Override // GemStoneAddition - protected void removeAt(int index) { - super.removeAt(index); // clear key, state; adjust size - _values[index] = 0; - } - - /** - * Returns the values of the map. - * - * @return a Collection value - */ - public long[] getValues() { - long[] vals = new long[size()]; - long[] v = _values; - byte[] states = _states; - - for (int i = v.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - vals[j++] = v[i]; - } - } - return vals; - } - - /** - * returns the keys of the map. - * - * @return a Set value - */ - public float[] keys() { - float[] keys = new float[size()]; - float[] k = _set; - byte[] states = _states; - - for (int i = k.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - keys[j++] = k[i]; - } - } - return keys; - } - - /** - * checks for the presence of val in the values of the map. - * - * @param val an long value - * @return a boolean value - */ - public boolean containsValue(long val) { - byte[] states = _states; - long[] vals = _values; - - for (int i = vals.length; i-- > 0;) { - if (states[i] == FULL && val == vals[i]) { - return true; - } - } - return false; - } - - - /** - * checks for the present of key in the keys of the map. - * - * @param key an float value - * @return a boolean value - */ - public boolean containsKey(float key) { - return contains(key); - } - - /** - * Executes procedure for each key in the map. - * - * @param procedure a TFloatProcedure value - * @return false if the loop over the keys terminated because - * the procedure returned false for some key. - */ - public boolean forEachKey(TFloatProcedure procedure) { - return forEach(procedure); - } - - /** - * Executes procedure for each value in the map. - * - * @param procedure a TLongProcedure value - * @return false if the loop over the values terminated because - * the procedure returned false for some value. - */ - public boolean forEachValue(TLongProcedure procedure) { - byte[] states = _states; - long[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(values[i])) { - return false; - } - } - return true; - } - - /** - * Executes procedure for each key/value entry in the - * map. - * - * @param procedure a TOFloatLongProcedure value - * @return false if the loop over the entries terminated because - * the procedure returned false for some entry. - */ - public boolean forEachEntry(TFloatLongProcedure procedure) { - byte[] states = _states; - float[] keys = _set; - long[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - return false; - } - } - return true; - } - - /** - * Retains only those entries in the map for which the procedure - * returns a true value. - * - * @param procedure determines which entries to keep - * @return true if the map was modified. - */ - public boolean retainEntries(TFloatLongProcedure procedure) { - boolean modified = false; - byte[] states = _states; - float[] keys = _set; - long[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - removeAt(i); - modified = true; - } - } - return modified; - } - - /** - * Transform the values in this map using function. - * - * @param function a TLongFunction value - */ - public void transformValues(TLongFunction function) { - byte[] states = _states; - long[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL) { - values[i] = function.execute(values[i]); - } - } - } - - /** - * Increments the primitive value mapped to key by 1 - * - * @param key the key of the value to increment - * @return true if a mapping was found and modified. - */ - public boolean increment(float key) { - return adjustValue(key, 1); - } - - /** - * Adjusts the primitive value mapped to key. - * - * @param key the key of the value to increment - * @param amount the amount to adjust the value by. - * @return true if a mapping was found and modified. - */ - public boolean adjustValue(float key, long amount) { - int index = index(key); - if (index < 0) { - return false; - } else { - _values[index] += amount; - return true; - } - } - - - private void writeObject(ObjectOutputStream stream) - throws IOException { - stream.defaultWriteObject(); - - // number of entries - stream.writeInt(_size); - - SerializationProcedure writeProcedure = new SerializationProcedure(stream); - if (! forEachEntry(writeProcedure)) { - throw writeProcedure.exception; - } - } - - private void readObject(ObjectInputStream stream) - throws IOException, ClassNotFoundException { - stream.defaultReadObject(); - - int size = stream.readInt(); - setUp(size); - while (size-- > 0) { - float key = stream.readFloat(); - long val = stream.readLong(); - put(key, val); - } - } -} // TFloatLongHashMap diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatLongIterator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatLongIterator.java deleted file mode 100644 index 45e63a302..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatLongIterator.java +++ /dev/null @@ -1,145 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Iterator for maps of type float and long. - * - *

The iterator semantics for Trove's primitive maps is slightly different - * from those defined in java.util.Iterator, but still well within - * the scope of the pattern, as defined by Gamma, et al.

- * - *

This iterator does not implicitly advance to the next entry when - * the value at the current position is retrieved. Rather, you must explicitly - * ask the iterator to advance() and then retrieve either the key(), - * the value() or both. This is done so that you have the option, but not - * the obligation, to retrieve keys and/or values as your application requires, and - * without introducing wrapper objects that would carry both. As the iteration is - * stateful, access to the key/value parts of the current map entry happens in - * constant time.

- * - *

In practice, the iterator is akin to a "search finger" that you move from - * position to position. Read or write operations affect the current entry only and - * do not assume responsibility for moving the finger.

- * - *

Here are some sample scenarios for this class of iterator:

- * - *
- * // accessing keys/values through an iterator:
- * for (TFloatLongIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     doSomethingWithValue(it.value());
- *   }
- * }
- * 
- * - *
- * // modifying values in-place through iteration:
- * for (TFloatLongIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.setValue(newValueForKey(it.key()));
- *   }
- * }
- * 
- * - *
- * // deleting entries during iteration:
- * for (TFloatLongIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.remove();
- *   }
- * }
- * 
- * - *
- * // faster iteration by avoiding hasNext():
- * TFloatLongIterator iterator = map.iterator();
- * for (int i = map.size(); i-- > 0;) {    
- *   iterator.advance();     
- *   doSomethingWithKeyAndValue(iterator.key(), iterator.value());
- * }   
- * 
- * - * @author Eric D. Friedman - * @version $Id: TFloatLongIterator.java,v 1.1 2002/09/22 21:53:41 ericdf Exp $ - */ - -public class TFloatLongIterator extends TPrimitiveIterator { - /** the collection being iterated over */ - private final TFloatLongHashMap _map; - - /** - * Creates an iterator over the specified map - */ - public TFloatLongIterator(TFloatLongHashMap map) { - super(map); - this._map = map; - } - - /** - * Moves the iterator forward to the next entry in the underlying map. - * - * @exception java.util.NoSuchElementException if the iterator is already exhausted - */ - public void advance() { - moveToNextIndex(); - } - - /** - * Provides access to the key of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the key of the entry at the iterator's current position. - */ - public float key() { - return _map._set[_index]; - } - - /** - * Provides access to the value of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the value of the entry at the iterator's current position. - */ - public long value() { - return _map._values[_index]; - } - - /** - * Replace the value of the mapping at the iterator's position with the - * specified value. Note that you must advance() the iterator at - * least once before invoking this method. - * - * @param val the value to set in the current entry - * @return the old value of the entry. - */ - public long setValue(long val) { - long old = value(); - _map._values[_index] = val; - return old; - } -}// TFloatLongIterator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatLongProcedure.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatLongProcedure.java deleted file mode 100644 index d2b350af4..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatLongProcedure.java +++ /dev/null @@ -1,43 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Interface for procedures that take two parameters of type float and long. - * - * Created: Mon Nov 5 22:03:30 2001 - * - * @author Eric D. Friedman - * @version $Id: TFloatLongProcedure.java,v 1.7 2002/09/22 21:53:41 ericdf Exp $ - */ - -public interface TFloatLongProcedure { - - /** - * Executes this procedure. A false return value indicates that - * the application executing this procedure should not invoke this - * procedure again. - * - * @param a an float value - * @param b an long value - * @return true if additional invocations of the procedure are - * allowed. - */ - public boolean execute(float a, long b); -}// TFloatLongProcedure diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatObjectHashMap.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatObjectHashMap.java deleted file mode 100644 index b12d6c5e2..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatObjectHashMap.java +++ /dev/null @@ -1,521 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - -/** - * An open addressed Map implementation for float keys and Object values. - * - * Created: Sun Nov 4 08:52:45 2001 - * - * @author Eric D. Friedman - * @version $Id: TFloatObjectHashMap.java,v 1.15 2003/11/21 17:32:30 ericdf Exp $ - */ -public class TFloatObjectHashMap extends TFloatHash implements Serializable { - - private static final long serialVersionUID = -8015680103361869228L; - /** the values of the map */ - protected transient Object[] _values; - - /** - * Creates a new TFloatObjectHashMap instance with the default - * capacity and load factor. - */ - public TFloatObjectHashMap() { - super(); - } - - /** - * Creates a new TFloatObjectHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the default load factor. - * - * @param initialCapacity an int value - */ - public TFloatObjectHashMap(int initialCapacity) { - super(initialCapacity); - } - - /** - * Creates a new TFloatObjectHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the specified load factor. - * - * @param initialCapacity an int value - * @param loadFactor a float value - */ - public TFloatObjectHashMap(int initialCapacity, float loadFactor) { - super(initialCapacity, loadFactor); - } - - /** - * Creates a new TFloatObjectHashMap instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TFloatObjectHashMap(TFloatHashingStrategy strategy) { - super(strategy); - } - - /** - * Creates a new TFloatObjectHashMap instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TFloatObjectHashMap(int initialCapacity, TFloatHashingStrategy strategy) { - super(initialCapacity, strategy); - } - - /** - * Creates a new TFloatObjectHashMap instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TFloatObjectHashMap(int initialCapacity, float loadFactor, TFloatHashingStrategy strategy) { - super(initialCapacity, loadFactor, strategy); - } - - /** - * @return a deep clone of this collection - */ - @Override // GemStoneAddition - public Object clone() { - TFloatObjectHashMap m = (TFloatObjectHashMap)super.clone(); - m._values = this._values.clone(); - return m; - } - - /** - * @return a TFloatObjectIterator with access to this map's keys and values - */ - public TFloatObjectIterator iterator() { - return new TFloatObjectIterator(this); - } - - /** - * initializes the hashtable to a prime capacity which is at least - * initialCapacity + 1. - * - * @param initialCapacity an int value - * @return the actual capacity chosen - */ - @Override // GemStoneAddition - protected int setUp(int initialCapacity) { - int capacity; - - capacity = super.setUp(initialCapacity); - _values = new Object[capacity]; - return capacity; - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an float value - * @param value an Object value - * @return the previous value associated with key, - * or null if none was found. - */ - public Object put(float key, Object value) { - byte previousState; - Object previous = null; - int index = insertionIndex(key); - boolean isNewMapping = true; - if (index < 0) { - index = -index -1; - previous = _values[index]; - isNewMapping = false; - } - previousState = _states[index]; - _set[index] = key; - _states[index] = FULL; - _values[index] = value; - if (isNewMapping) { - postInsertHook(previousState == FREE); - } - - return previous; - } - - /** - * rehashes the map to the new capacity. - * - * @param newCapacity an int value - */ - @Override // GemStoneAddition - protected void rehash(int newCapacity) { - int oldCapacity = _set.length; - float oldKeys[] = _set; - Object oldVals[] = _values; - byte oldStates[] = _states; - - _set = new float[newCapacity]; - _values = new Object[newCapacity]; - _states = new byte[newCapacity]; - - for (int i = oldCapacity; i-- > 0;) { - if(oldStates[i] == FULL) { - float o = oldKeys[i]; - int index = insertionIndex(o); - _set[index] = o; - _values[index] = oldVals[i]; - _states[index] = FULL; - } - } - } - - /** - * retrieves the value for key - * - * @param key an float value - * @return the value of key or null if no such mapping exists. - */ - public Object get(float key) { - int index = index(key); - return index < 0 ? null : _values[index]; - } - - /** - * Empties the map. - * - */ - @Override // GemStoneAddition - public void clear() { - super.clear(); - float[] keys = _set; - Object[] vals = _values; - byte[] states = _states; - - for (int i = keys.length; i-- > 0;) { - keys[i] = 0; - vals[i] = null; - states[i] = FREE; - } - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an float value - * @return an Object value, or null if no mapping for key exists - */ - public Object remove(float key) { - Object prev = null; - int index = index(key); - if (index >= 0) { - prev = _values[index]; - removeAt(index); // clear key,state; adjust size - } - return prev; - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (! (other instanceof TFloatObjectHashMap)) { - return false; - } - TFloatObjectHashMap that = (TFloatObjectHashMap)other; - if (that.size() != this.size()) { - return false; - } - return forEachEntry(new EqProcedure(that)); - } - - @Override // GemStoneAddition - public int hashCode() { - HashProcedure p = new HashProcedure(); - forEachEntry(p); - return p.getHashCode(); - } - - protected/*GemStoneAddition*/ final class HashProcedure implements TFloatObjectProcedure { - private int h = 0; - - public int getHashCode() { - return h; - } - - public final boolean execute(float key, Object value) { - h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); - return true; - } - } - - private static final class EqProcedure implements TFloatObjectProcedure { - private final TFloatObjectHashMap _otherMap; - - EqProcedure(TFloatObjectHashMap otherMap) { - _otherMap = otherMap; - } - - public final boolean execute(float key, Object value) { - int index = _otherMap.index(key); - if (index >= 0 && eq(value, _otherMap.get(key))) { - return true; - } - return false; - } - - /** - * Compare two objects for equality. - */ - private final boolean eq(Object o1, Object o2) { - return o1 == o2 || ((o1 != null) && o1.equals(o2)); - } - - } - - /** - * removes the mapping at index from the map. - * - * @param index an int value - */ - @Override // GemStoneAddition - protected void removeAt(int index) { - super.removeAt(index); // clear key, state; adjust size - _values[index] = null; - } - - /** - * Returns the values of the map. - * - * @return a Collection value - */ - public Object[] getValues() { - Object[] vals = new Object[size()]; - Object[] v = _values; - byte[] states = _states; - - for (int i = v.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - vals[j++] = v[i]; - } - } - return vals; - } - - /** - * returns the keys of the map. - * - * @return a Set value - */ - public float[] keys() { - float[] keys = new float[size()]; - float[] k = _set; - byte[] states = _states; - - for (int i = k.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - keys[j++] = k[i]; - } - } - return keys; - } - - /** - * checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - public boolean containsValue(Object val) { - byte[] states = _states; - Object[] vals = _values; - - // special case null values so that we don't have to - // perform null checks before every call to equals() - if (null == val) { - for (int i = vals.length; i-- > 0;) { - if (states[i] == FULL && - val == vals[i]) { - return true; - } - } - } else { - for (int i = vals.length; i-- > 0;) { - if (states[i] == FULL && - (val == vals[i] || val.equals(vals[i]))) { - return true; - } - } - } // end of else - return false; - } - - - /** - * checks for the present of key in the keys of the map. - * - * @param key an float value - * @return a boolean value - */ - public boolean containsKey(float key) { - return contains(key); - } - - /** - * Executes procedure for each key in the map. - * - * @param procedure a TFloatProcedure value - * @return false if the loop over the keys terminated because - * the procedure returned false for some key. - */ - public boolean forEachKey(TFloatProcedure procedure) { - return forEach(procedure); - } - - /** - * Executes procedure for each value in the map. - * - * @param procedure a TObjectProcedure value - * @return false if the loop over the values terminated because - * the procedure returned false for some value. - */ - public boolean forEachValue(TObjectProcedure procedure) { - byte[] states = _states; - Object[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(values[i])) { - return false; - } - } - return true; - } - - /** - * Executes procedure for each key/value entry in the - * map. - * - * @param procedure a TOFloatObjectProcedure value - * @return false if the loop over the entries terminated because - * the procedure returned false for some entry. - */ - public boolean forEachEntry(TFloatObjectProcedure procedure) { - byte[] states = _states; - float[] keys = _set; - Object[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - return false; - } - } - return true; - } - - /** - * Retains only those entries in the map for which the procedure - * returns a true value. - * - * @param procedure determines which entries to keep - * @return true if the map was modified. - */ - public boolean retainEntries(TFloatObjectProcedure procedure) { - boolean modified = false; - byte[] states = _states; - float[] keys = _set; - Object[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - removeAt(i); - modified = true; - } - } - return modified; - } - - /** - * Transform the values in this map using function. - * - * @param function a TObjectFunction value - */ - public void transformValues(TObjectFunction function) { - byte[] states = _states; - Object[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL) { - values[i] = function.execute(values[i]); - } - } - } - - - - private void writeObject(ObjectOutputStream stream) - throws IOException { - stream.defaultWriteObject(); - - // number of entries - stream.writeInt(_size); - - SerializationProcedure writeProcedure = new SerializationProcedure(stream); - if (! forEachEntry(writeProcedure)) { - throw writeProcedure.exception; - } - } - - private void readObject(ObjectInputStream stream) - throws IOException, ClassNotFoundException { - stream.defaultReadObject(); - - int size = stream.readInt(); - setUp(size); - while (size-- > 0) { - float key = stream.readFloat(); - Object val = stream.readObject(); - put(key, val); - } - } -} // TFloatObjectHashMap diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatObjectIterator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatObjectIterator.java deleted file mode 100644 index b5aafac67..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatObjectIterator.java +++ /dev/null @@ -1,145 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Iterator for maps of type float and Object. - * - *

The iterator semantics for Trove's primitive maps is slightly different - * from those defined in java.util.Iterator, but still well within - * the scope of the pattern, as defined by Gamma, et al.

- * - *

This iterator does not implicitly advance to the next entry when - * the value at the current position is retrieved. Rather, you must explicitly - * ask the iterator to advance() and then retrieve either the key(), - * the value() or both. This is done so that you have the option, but not - * the obligation, to retrieve keys and/or values as your application requires, and - * without introducing wrapper objects that would carry both. As the iteration is - * stateful, access to the key/value parts of the current map entry happens in - * constant time.

- * - *

In practice, the iterator is akin to a "search finger" that you move from - * position to position. Read or write operations affect the current entry only and - * do not assume responsibility for moving the finger.

- * - *

Here are some sample scenarios for this class of iterator:

- * - *
- * // accessing keys/values through an iterator:
- * for (TFloatObjectIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     doSomethingWithValue(it.value());
- *   }
- * }
- * 
- * - *
- * // modifying values in-place through iteration:
- * for (TFloatObjectIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.setValue(newValueForKey(it.key()));
- *   }
- * }
- * 
- * - *
- * // deleting entries during iteration:
- * for (TFloatObjectIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.remove();
- *   }
- * }
- * 
- * - *
- * // faster iteration by avoiding hasNext():
- * TFloatObjectIterator iterator = map.iterator();
- * for (int i = map.size(); i-- > 0;) {    
- *   iterator.advance();     
- *   doSomethingWithKeyAndValue(iterator.key(), iterator.value());
- * }   
- * 
- * - * @author Eric D. Friedman - * @version $Id: TFloatObjectIterator.java,v 1.1 2002/09/22 21:53:41 ericdf Exp $ - */ - -public class TFloatObjectIterator extends TPrimitiveIterator { - /** the collection being iterated over */ - private final TFloatObjectHashMap _map; - - /** - * Creates an iterator over the specified map - */ - public TFloatObjectIterator(TFloatObjectHashMap map) { - super(map); - this._map = map; - } - - /** - * Moves the iterator forward to the next entry in the underlying map. - * - * @exception java.util.NoSuchElementException if the iterator is already exhausted - */ - public void advance() { - moveToNextIndex(); - } - - /** - * Provides access to the key of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the key of the entry at the iterator's current position. - */ - public float key() { - return _map._set[_index]; - } - - /** - * Provides access to the value of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the value of the entry at the iterator's current position. - */ - public Object value() { - return _map._values[_index]; - } - - /** - * Replace the value of the mapping at the iterator's position with the - * specified value. Note that you must advance() the iterator at - * least once before invoking this method. - * - * @param val the value to set in the current entry - * @return the old value of the entry. - */ - public Object setValue(Object val) { - Object old = value(); - _map._values[_index] = val; - return old; - } -}// TFloatObjectIterator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatObjectProcedure.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatObjectProcedure.java deleted file mode 100644 index 7a75ac77e..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatObjectProcedure.java +++ /dev/null @@ -1,43 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Interface for procedures that take two parameters of type float and Object. - * - * Created: Mon Nov 5 22:03:30 2001 - * - * @author Eric D. Friedman - * @version $Id: TFloatObjectProcedure.java,v 1.7 2002/09/22 21:53:41 ericdf Exp $ - */ - -public interface TFloatObjectProcedure { - - /** - * Executes this procedure. A false return value indicates that - * the application executing this procedure should not invoke this - * procedure again. - * - * @param a an float value - * @param b an Object value - * @return true if additional invocations of the procedure are - * allowed. - */ - public boolean execute(float a, Object b); -}// TFloatObjectProcedure diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatProcedure.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatProcedure.java deleted file mode 100644 index ffb840e06..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TFloatProcedure.java +++ /dev/null @@ -1,41 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Interface for procedures with one float paramater. - * - * Created: Mon Nov 5 21:45:49 2001 - * - * @author Eric D. Friedman - * @version $Id: TFloatProcedure.java,v 1.5 2002/09/22 21:53:41 ericdf Exp $ - */ - -public interface TFloatProcedure { - /** - * Executes this procedure. A false return value indicates that - * the application executing this procedure should not invoke this - * procedure again. - * - * @param value a value of type float - * @return true if additional invocations of the procedure are - * allowed. - */ - public boolean execute(float value); -}// TFloatProcedure diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntDoubleHashMap.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntDoubleHashMap.java deleted file mode 100644 index 7e7406ef9..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntDoubleHashMap.java +++ /dev/null @@ -1,535 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - -/** - * An open addressed Map implementation for int keys and double values. - * - * Created: Sun Nov 4 08:52:45 2001 - * - * @author Eric D. Friedman - * @version $Id: TIntDoubleHashMap.java,v 1.15 2003/11/21 17:32:30 ericdf Exp $ - */ -public class TIntDoubleHashMap extends TIntHash implements Serializable { - - private static final long serialVersionUID = 8860450223626197569L; - /** the values of the map */ - protected transient double[] _values; - - /** - * Creates a new TIntDoubleHashMap instance with the default - * capacity and load factor. - */ - public TIntDoubleHashMap() { - super(); - } - - /** - * Creates a new TIntDoubleHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the default load factor. - * - * @param initialCapacity an int value - */ - public TIntDoubleHashMap(int initialCapacity) { - super(initialCapacity); - } - - /** - * Creates a new TIntDoubleHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the specified load factor. - * - * @param initialCapacity an int value - * @param loadFactor a float value - */ - public TIntDoubleHashMap(int initialCapacity, float loadFactor) { - super(initialCapacity, loadFactor); - } - - /** - * Creates a new TIntDoubleHashMap instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TIntDoubleHashMap(TIntHashingStrategy strategy) { - super(strategy); - } - - /** - * Creates a new TIntDoubleHashMap instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TIntDoubleHashMap(int initialCapacity, TIntHashingStrategy strategy) { - super(initialCapacity, strategy); - } - - /** - * Creates a new TIntDoubleHashMap instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TIntDoubleHashMap(int initialCapacity, float loadFactor, TIntHashingStrategy strategy) { - super(initialCapacity, loadFactor, strategy); - } - - /** - * @return a deep clone of this collection - */ - @Override // GemStoneAddition - public Object clone() { - TIntDoubleHashMap m = (TIntDoubleHashMap)super.clone(); - m._values = this._values.clone(); - return m; - } - - /** - * @return a TIntDoubleIterator with access to this map's keys and values - */ - public TIntDoubleIterator iterator() { - return new TIntDoubleIterator(this); - } - - /** - * initializes the hashtable to a prime capacity which is at least - * initialCapacity + 1. - * - * @param initialCapacity an int value - * @return the actual capacity chosen - */ - @Override // GemStoneAddition - protected int setUp(int initialCapacity) { - int capacity; - - capacity = super.setUp(initialCapacity); - _values = new double[capacity]; - return capacity; - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an int value - * @param value an double value - * @return the previous value associated with key, - * or (double)0 if none was found. - */ - public double put(int key, double value) { - byte previousState; - double previous = 0; - int index = insertionIndex(key); - boolean isNewMapping = true; - if (index < 0) { - index = -index -1; - previous = _values[index]; - isNewMapping = false; - } - previousState = _states[index]; - _set[index] = key; - _states[index] = FULL; - _values[index] = value; - if (isNewMapping) { - postInsertHook(previousState == FREE); - } - - return previous; - } - - /** - * rehashes the map to the new capacity. - * - * @param newCapacity an int value - */ - @Override // GemStoneAddition - protected void rehash(int newCapacity) { - int oldCapacity = _set.length; - int oldKeys[] = _set; - double oldVals[] = _values; - byte oldStates[] = _states; - - _set = new int[newCapacity]; - _values = new double[newCapacity]; - _states = new byte[newCapacity]; - - for (int i = oldCapacity; i-- > 0;) { - if(oldStates[i] == FULL) { - int o = oldKeys[i]; - int index = insertionIndex(o); - _set[index] = o; - _values[index] = oldVals[i]; - _states[index] = FULL; - } - } - } - - /** - * retrieves the value for key - * - * @param key an int value - * @return the value of key or (double)0 if no such mapping exists. - */ - public double get(int key) { - int index = index(key); - return index < 0 ? (double)0 : _values[index]; - } - - /** - * Empties the map. - * - */ - @Override // GemStoneAddition - public void clear() { - super.clear(); - int[] keys = _set; - double[] vals = _values; - byte[] states = _states; - - for (int i = keys.length; i-- > 0;) { - keys[i] = 0; - vals[i] = 0; - states[i] = FREE; - } - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an int value - * @return an double value, or (double)0 if no mapping for key exists - */ - public double remove(int key) { - double prev = 0; - int index = index(key); - if (index >= 0) { - prev = _values[index]; - removeAt(index); // clear key,state; adjust size - } - return prev; - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (! (other instanceof TIntDoubleHashMap)) { - return false; - } - TIntDoubleHashMap that = (TIntDoubleHashMap)other; - if (that.size() != this.size()) { - return false; - } - return forEachEntry(new EqProcedure(that)); - } - - @Override // GemStoneAddition - public int hashCode() { - HashProcedure p = new HashProcedure(); - forEachEntry(p); - return p.getHashCode(); - } - - protected/*GemStoneAddition*/ final class HashProcedure implements TIntDoubleProcedure { - private int h = 0; - - public int getHashCode() { - return h; - } - - public final boolean execute(int key, double value) { - h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); - return true; - } - } - - private static final class EqProcedure implements TIntDoubleProcedure { - private final TIntDoubleHashMap _otherMap; - - EqProcedure(TIntDoubleHashMap otherMap) { - _otherMap = otherMap; - } - - public final boolean execute(int key, double value) { - int index = _otherMap.index(key); - if (index >= 0 && eq(value, _otherMap.get(key))) { - return true; - } - return false; - } - - /** - * Compare two doubles for equality. - */ - private final boolean eq(double v1, double v2) { - return v1 == v2; - } - - } - - /** - * removes the mapping at index from the map. - * - * @param index an int value - */ - @Override // GemStoneAddition - protected void removeAt(int index) { - super.removeAt(index); // clear key, state; adjust size - _values[index] = 0; - } - - /** - * Returns the values of the map. - * - * @return a Collection value - */ - public double[] getValues() { - double[] vals = new double[size()]; - double[] v = _values; - byte[] states = _states; - - for (int i = v.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - vals[j++] = v[i]; - } - } - return vals; - } - - /** - * returns the keys of the map. - * - * @return a Set value - */ - public int[] keys() { - int[] keys = new int[size()]; - int[] k = _set; - byte[] states = _states; - - for (int i = k.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - keys[j++] = k[i]; - } - } - return keys; - } - - /** - * checks for the presence of val in the values of the map. - * - * @param val an double value - * @return a boolean value - */ - public boolean containsValue(double val) { - byte[] states = _states; - double[] vals = _values; - - for (int i = vals.length; i-- > 0;) { - if (states[i] == FULL && val == vals[i]) { - return true; - } - } - return false; - } - - - /** - * checks for the present of key in the keys of the map. - * - * @param key an int value - * @return a boolean value - */ - public boolean containsKey(int key) { - return contains(key); - } - - /** - * Executes procedure for each key in the map. - * - * @param procedure a TIntProcedure value - * @return false if the loop over the keys terminated because - * the procedure returned false for some key. - */ - public boolean forEachKey(TIntProcedure procedure) { - return forEach(procedure); - } - - /** - * Executes procedure for each value in the map. - * - * @param procedure a TDoubleProcedure value - * @return false if the loop over the values terminated because - * the procedure returned false for some value. - */ - public boolean forEachValue(TDoubleProcedure procedure) { - byte[] states = _states; - double[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(values[i])) { - return false; - } - } - return true; - } - - /** - * Executes procedure for each key/value entry in the - * map. - * - * @param procedure a TOIntDoubleProcedure value - * @return false if the loop over the entries terminated because - * the procedure returned false for some entry. - */ - public boolean forEachEntry(TIntDoubleProcedure procedure) { - byte[] states = _states; - int[] keys = _set; - double[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - return false; - } - } - return true; - } - - /** - * Retains only those entries in the map for which the procedure - * returns a true value. - * - * @param procedure determines which entries to keep - * @return true if the map was modified. - */ - public boolean retainEntries(TIntDoubleProcedure procedure) { - boolean modified = false; - byte[] states = _states; - int[] keys = _set; - double[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - removeAt(i); - modified = true; - } - } - return modified; - } - - /** - * Transform the values in this map using function. - * - * @param function a TDoubleFunction value - */ - public void transformValues(TDoubleFunction function) { - byte[] states = _states; - double[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL) { - values[i] = function.execute(values[i]); - } - } - } - - /** - * Increments the primitive value mapped to key by 1 - * - * @param key the key of the value to increment - * @return true if a mapping was found and modified. - */ - public boolean increment(int key) { - return adjustValue(key, 1); - } - - /** - * Adjusts the primitive value mapped to key. - * - * @param key the key of the value to increment - * @param amount the amount to adjust the value by. - * @return true if a mapping was found and modified. - */ - public boolean adjustValue(int key, double amount) { - int index = index(key); - if (index < 0) { - return false; - } else { - _values[index] += amount; - return true; - } - } - - - private void writeObject(ObjectOutputStream stream) - throws IOException { - stream.defaultWriteObject(); - - // number of entries - stream.writeInt(_size); - - SerializationProcedure writeProcedure = new SerializationProcedure(stream); - if (! forEachEntry(writeProcedure)) { - throw writeProcedure.exception; - } - } - - private void readObject(ObjectInputStream stream) - throws IOException, ClassNotFoundException { - stream.defaultReadObject(); - - int size = stream.readInt(); - setUp(size); - while (size-- > 0) { - int key = stream.readInt(); - double val = stream.readDouble(); - put(key, val); - } - } -} // TIntDoubleHashMap diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntDoubleIterator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntDoubleIterator.java deleted file mode 100644 index 1f06f6630..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntDoubleIterator.java +++ /dev/null @@ -1,145 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Iterator for maps of type int and double. - * - *

The iterator semantics for Trove's primitive maps is slightly different - * from those defined in java.util.Iterator, but still well within - * the scope of the pattern, as defined by Gamma, et al.

- * - *

This iterator does not implicitly advance to the next entry when - * the value at the current position is retrieved. Rather, you must explicitly - * ask the iterator to advance() and then retrieve either the key(), - * the value() or both. This is done so that you have the option, but not - * the obligation, to retrieve keys and/or values as your application requires, and - * without introducing wrapper objects that would carry both. As the iteration is - * stateful, access to the key/value parts of the current map entry happens in - * constant time.

- * - *

In practice, the iterator is akin to a "search finger" that you move from - * position to position. Read or write operations affect the current entry only and - * do not assume responsibility for moving the finger.

- * - *

Here are some sample scenarios for this class of iterator:

- * - *
- * // accessing keys/values through an iterator:
- * for (TIntDoubleIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     doSomethingWithValue(it.value());
- *   }
- * }
- * 
- * - *
- * // modifying values in-place through iteration:
- * for (TIntDoubleIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.setValue(newValueForKey(it.key()));
- *   }
- * }
- * 
- * - *
- * // deleting entries during iteration:
- * for (TIntDoubleIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.remove();
- *   }
- * }
- * 
- * - *
- * // faster iteration by avoiding hasNext():
- * TIntDoubleIterator iterator = map.iterator();
- * for (int i = map.size(); i-- > 0;) {    
- *   iterator.advance();     
- *   doSomethingWithKeyAndValue(iterator.key(), iterator.value());
- * }   
- * 
- * - * @author Eric D. Friedman - * @version $Id: TIntDoubleIterator.java,v 1.1 2002/09/22 21:53:41 ericdf Exp $ - */ - -public class TIntDoubleIterator extends TPrimitiveIterator { - /** the collection being iterated over */ - private final TIntDoubleHashMap _map; - - /** - * Creates an iterator over the specified map - */ - public TIntDoubleIterator(TIntDoubleHashMap map) { - super(map); - this._map = map; - } - - /** - * Moves the iterator forward to the next entry in the underlying map. - * - * @exception java.util.NoSuchElementException if the iterator is already exhausted - */ - public void advance() { - moveToNextIndex(); - } - - /** - * Provides access to the key of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the key of the entry at the iterator's current position. - */ - public int key() { - return _map._set[_index]; - } - - /** - * Provides access to the value of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the value of the entry at the iterator's current position. - */ - public double value() { - return _map._values[_index]; - } - - /** - * Replace the value of the mapping at the iterator's position with the - * specified value. Note that you must advance() the iterator at - * least once before invoking this method. - * - * @param val the value to set in the current entry - * @return the old value of the entry. - */ - public double setValue(double val) { - double old = value(); - _map._values[_index] = val; - return old; - } -}// TIntDoubleIterator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntDoubleProcedure.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntDoubleProcedure.java deleted file mode 100644 index 137a51459..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntDoubleProcedure.java +++ /dev/null @@ -1,43 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Interface for procedures that take two parameters of type int and double. - * - * Created: Mon Nov 5 22:03:30 2001 - * - * @author Eric D. Friedman - * @version $Id: TIntDoubleProcedure.java,v 1.7 2002/09/22 21:53:41 ericdf Exp $ - */ - -public interface TIntDoubleProcedure { - - /** - * Executes this procedure. A false return value indicates that - * the application executing this procedure should not invoke this - * procedure again. - * - * @param a an int value - * @param b an double value - * @return true if additional invocations of the procedure are - * allowed. - */ - public boolean execute(int a, double b); -}// TIntDoubleProcedure diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntFloatHashMap.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntFloatHashMap.java deleted file mode 100644 index e4c018f88..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntFloatHashMap.java +++ /dev/null @@ -1,535 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - -/** - * An open addressed Map implementation for int keys and float values. - * - * Created: Sun Nov 4 08:52:45 2001 - * - * @author Eric D. Friedman - * @version $Id: TIntFloatHashMap.java,v 1.15 2003/11/21 17:32:30 ericdf Exp $ - */ -public class TIntFloatHashMap extends TIntHash implements Serializable { - - private static final long serialVersionUID = 5336806044065912894L; - /** the values of the map */ - protected transient float[] _values; - - /** - * Creates a new TIntFloatHashMap instance with the default - * capacity and load factor. - */ - public TIntFloatHashMap() { - super(); - } - - /** - * Creates a new TIntFloatHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the default load factor. - * - * @param initialCapacity an int value - */ - public TIntFloatHashMap(int initialCapacity) { - super(initialCapacity); - } - - /** - * Creates a new TIntFloatHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the specified load factor. - * - * @param initialCapacity an int value - * @param loadFactor a float value - */ - public TIntFloatHashMap(int initialCapacity, float loadFactor) { - super(initialCapacity, loadFactor); - } - - /** - * Creates a new TIntFloatHashMap instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TIntFloatHashMap(TIntHashingStrategy strategy) { - super(strategy); - } - - /** - * Creates a new TIntFloatHashMap instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TIntFloatHashMap(int initialCapacity, TIntHashingStrategy strategy) { - super(initialCapacity, strategy); - } - - /** - * Creates a new TIntFloatHashMap instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TIntFloatHashMap(int initialCapacity, float loadFactor, TIntHashingStrategy strategy) { - super(initialCapacity, loadFactor, strategy); - } - - /** - * @return a deep clone of this collection - */ - @Override // GemStoneAddition - public Object clone() { - TIntFloatHashMap m = (TIntFloatHashMap)super.clone(); - m._values = this._values.clone(); - return m; - } - - /** - * @return a TIntFloatIterator with access to this map's keys and values - */ - public TIntFloatIterator iterator() { - return new TIntFloatIterator(this); - } - - /** - * initializes the hashtable to a prime capacity which is at least - * initialCapacity + 1. - * - * @param initialCapacity an int value - * @return the actual capacity chosen - */ - @Override // GemStoneAddition - protected int setUp(int initialCapacity) { - int capacity; - - capacity = super.setUp(initialCapacity); - _values = new float[capacity]; - return capacity; - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an int value - * @param value an float value - * @return the previous value associated with key, - * or (float)0 if none was found. - */ - public float put(int key, float value) { - byte previousState; - float previous = 0; - int index = insertionIndex(key); - boolean isNewMapping = true; - if (index < 0) { - index = -index -1; - previous = _values[index]; - isNewMapping = false; - } - previousState = _states[index]; - _set[index] = key; - _states[index] = FULL; - _values[index] = value; - if (isNewMapping) { - postInsertHook(previousState == FREE); - } - - return previous; - } - - /** - * rehashes the map to the new capacity. - * - * @param newCapacity an int value - */ - @Override // GemStoneAddition - protected void rehash(int newCapacity) { - int oldCapacity = _set.length; - int oldKeys[] = _set; - float oldVals[] = _values; - byte oldStates[] = _states; - - _set = new int[newCapacity]; - _values = new float[newCapacity]; - _states = new byte[newCapacity]; - - for (int i = oldCapacity; i-- > 0;) { - if(oldStates[i] == FULL) { - int o = oldKeys[i]; - int index = insertionIndex(o); - _set[index] = o; - _values[index] = oldVals[i]; - _states[index] = FULL; - } - } - } - - /** - * retrieves the value for key - * - * @param key an int value - * @return the value of key or (float)0 if no such mapping exists. - */ - public float get(int key) { - int index = index(key); - return index < 0 ? (float)0 : _values[index]; - } - - /** - * Empties the map. - * - */ - @Override // GemStoneAddition - public void clear() { - super.clear(); - int[] keys = _set; - float[] vals = _values; - byte[] states = _states; - - for (int i = keys.length; i-- > 0;) { - keys[i] = 0; - vals[i] = 0; - states[i] = FREE; - } - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an int value - * @return an float value, or (float)0 if no mapping for key exists - */ - public float remove(int key) { - float prev = 0; - int index = index(key); - if (index >= 0) { - prev = _values[index]; - removeAt(index); // clear key,state; adjust size - } - return prev; - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (! (other instanceof TIntFloatHashMap)) { - return false; - } - TIntFloatHashMap that = (TIntFloatHashMap)other; - if (that.size() != this.size()) { - return false; - } - return forEachEntry(new EqProcedure(that)); - } - - @Override // GemStoneAddition - public int hashCode() { - HashProcedure p = new HashProcedure(); - forEachEntry(p); - return p.getHashCode(); - } - - protected/*GemStoneAddition*/ final class HashProcedure implements TIntFloatProcedure { - private int h = 0; - - public int getHashCode() { - return h; - } - - public final boolean execute(int key, float value) { - h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); - return true; - } - } - - private static final class EqProcedure implements TIntFloatProcedure { - private final TIntFloatHashMap _otherMap; - - EqProcedure(TIntFloatHashMap otherMap) { - _otherMap = otherMap; - } - - public final boolean execute(int key, float value) { - int index = _otherMap.index(key); - if (index >= 0 && eq(value, _otherMap.get(key))) { - return true; - } - return false; - } - - /** - * Compare two floats for equality. - */ - private final boolean eq(float v1, float v2) { - return v1 == v2; - } - - } - - /** - * removes the mapping at index from the map. - * - * @param index an int value - */ - @Override // GemStoneAddition - protected void removeAt(int index) { - super.removeAt(index); // clear key, state; adjust size - _values[index] = 0; - } - - /** - * Returns the values of the map. - * - * @return a Collection value - */ - public float[] getValues() { - float[] vals = new float[size()]; - float[] v = _values; - byte[] states = _states; - - for (int i = v.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - vals[j++] = v[i]; - } - } - return vals; - } - - /** - * returns the keys of the map. - * - * @return a Set value - */ - public int[] keys() { - int[] keys = new int[size()]; - int[] k = _set; - byte[] states = _states; - - for (int i = k.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - keys[j++] = k[i]; - } - } - return keys; - } - - /** - * checks for the presence of val in the values of the map. - * - * @param val an float value - * @return a boolean value - */ - public boolean containsValue(float val) { - byte[] states = _states; - float[] vals = _values; - - for (int i = vals.length; i-- > 0;) { - if (states[i] == FULL && val == vals[i]) { - return true; - } - } - return false; - } - - - /** - * checks for the present of key in the keys of the map. - * - * @param key an int value - * @return a boolean value - */ - public boolean containsKey(int key) { - return contains(key); - } - - /** - * Executes procedure for each key in the map. - * - * @param procedure a TIntProcedure value - * @return false if the loop over the keys terminated because - * the procedure returned false for some key. - */ - public boolean forEachKey(TIntProcedure procedure) { - return forEach(procedure); - } - - /** - * Executes procedure for each value in the map. - * - * @param procedure a TFloatProcedure value - * @return false if the loop over the values terminated because - * the procedure returned false for some value. - */ - public boolean forEachValue(TFloatProcedure procedure) { - byte[] states = _states; - float[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(values[i])) { - return false; - } - } - return true; - } - - /** - * Executes procedure for each key/value entry in the - * map. - * - * @param procedure a TOIntFloatProcedure value - * @return false if the loop over the entries terminated because - * the procedure returned false for some entry. - */ - public boolean forEachEntry(TIntFloatProcedure procedure) { - byte[] states = _states; - int[] keys = _set; - float[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - return false; - } - } - return true; - } - - /** - * Retains only those entries in the map for which the procedure - * returns a true value. - * - * @param procedure determines which entries to keep - * @return true if the map was modified. - */ - public boolean retainEntries(TIntFloatProcedure procedure) { - boolean modified = false; - byte[] states = _states; - int[] keys = _set; - float[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - removeAt(i); - modified = true; - } - } - return modified; - } - - /** - * Transform the values in this map using function. - * - * @param function a TFloatFunction value - */ - public void transformValues(TFloatFunction function) { - byte[] states = _states; - float[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL) { - values[i] = function.execute(values[i]); - } - } - } - - /** - * Increments the primitive value mapped to key by 1 - * - * @param key the key of the value to increment - * @return true if a mapping was found and modified. - */ - public boolean increment(int key) { - return adjustValue(key, 1); - } - - /** - * Adjusts the primitive value mapped to key. - * - * @param key the key of the value to increment - * @param amount the amount to adjust the value by. - * @return true if a mapping was found and modified. - */ - public boolean adjustValue(int key, float amount) { - int index = index(key); - if (index < 0) { - return false; - } else { - _values[index] += amount; - return true; - } - } - - - private void writeObject(ObjectOutputStream stream) - throws IOException { - stream.defaultWriteObject(); - - // number of entries - stream.writeInt(_size); - - SerializationProcedure writeProcedure = new SerializationProcedure(stream); - if (! forEachEntry(writeProcedure)) { - throw writeProcedure.exception; - } - } - - private void readObject(ObjectInputStream stream) - throws IOException, ClassNotFoundException { - stream.defaultReadObject(); - - int size = stream.readInt(); - setUp(size); - while (size-- > 0) { - int key = stream.readInt(); - float val = stream.readFloat(); - put(key, val); - } - } -} // TIntFloatHashMap diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntFloatIterator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntFloatIterator.java deleted file mode 100644 index 1f574f3dd..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntFloatIterator.java +++ /dev/null @@ -1,145 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Iterator for maps of type int and float. - * - *

The iterator semantics for Trove's primitive maps is slightly different - * from those defined in java.util.Iterator, but still well within - * the scope of the pattern, as defined by Gamma, et al.

- * - *

This iterator does not implicitly advance to the next entry when - * the value at the current position is retrieved. Rather, you must explicitly - * ask the iterator to advance() and then retrieve either the key(), - * the value() or both. This is done so that you have the option, but not - * the obligation, to retrieve keys and/or values as your application requires, and - * without introducing wrapper objects that would carry both. As the iteration is - * stateful, access to the key/value parts of the current map entry happens in - * constant time.

- * - *

In practice, the iterator is akin to a "search finger" that you move from - * position to position. Read or write operations affect the current entry only and - * do not assume responsibility for moving the finger.

- * - *

Here are some sample scenarios for this class of iterator:

- * - *
- * // accessing keys/values through an iterator:
- * for (TIntFloatIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     doSomethingWithValue(it.value());
- *   }
- * }
- * 
- * - *
- * // modifying values in-place through iteration:
- * for (TIntFloatIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.setValue(newValueForKey(it.key()));
- *   }
- * }
- * 
- * - *
- * // deleting entries during iteration:
- * for (TIntFloatIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.remove();
- *   }
- * }
- * 
- * - *
- * // faster iteration by avoiding hasNext():
- * TIntFloatIterator iterator = map.iterator();
- * for (int i = map.size(); i-- > 0;) {    
- *   iterator.advance();     
- *   doSomethingWithKeyAndValue(iterator.key(), iterator.value());
- * }   
- * 
- * - * @author Eric D. Friedman - * @version $Id: TIntFloatIterator.java,v 1.1 2002/09/22 21:53:41 ericdf Exp $ - */ - -public class TIntFloatIterator extends TPrimitiveIterator { - /** the collection being iterated over */ - private final TIntFloatHashMap _map; - - /** - * Creates an iterator over the specified map - */ - public TIntFloatIterator(TIntFloatHashMap map) { - super(map); - this._map = map; - } - - /** - * Moves the iterator forward to the next entry in the underlying map. - * - * @exception java.util.NoSuchElementException if the iterator is already exhausted - */ - public void advance() { - moveToNextIndex(); - } - - /** - * Provides access to the key of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the key of the entry at the iterator's current position. - */ - public int key() { - return _map._set[_index]; - } - - /** - * Provides access to the value of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the value of the entry at the iterator's current position. - */ - public float value() { - return _map._values[_index]; - } - - /** - * Replace the value of the mapping at the iterator's position with the - * specified value. Note that you must advance() the iterator at - * least once before invoking this method. - * - * @param val the value to set in the current entry - * @return the old value of the entry. - */ - public float setValue(float val) { - float old = value(); - _map._values[_index] = val; - return old; - } -}// TIntFloatIterator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntFloatProcedure.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntFloatProcedure.java deleted file mode 100644 index c88123200..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntFloatProcedure.java +++ /dev/null @@ -1,43 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Interface for procedures that take two parameters of type int and float. - * - * Created: Mon Nov 5 22:03:30 2001 - * - * @author Eric D. Friedman - * @version $Id: TIntFloatProcedure.java,v 1.7 2002/09/22 21:53:41 ericdf Exp $ - */ - -public interface TIntFloatProcedure { - - /** - * Executes this procedure. A false return value indicates that - * the application executing this procedure should not invoke this - * procedure again. - * - * @param a an int value - * @param b an float value - * @return true if additional invocations of the procedure are - * allowed. - */ - public boolean execute(int a, float b); -}// TIntFloatProcedure diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntLongHashMap.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntLongHashMap.java deleted file mode 100644 index a50d7287c..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntLongHashMap.java +++ /dev/null @@ -1,535 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - -/** - * An open addressed Map implementation for int keys and long values. - * - * Created: Sun Nov 4 08:52:45 2001 - * - * @author Eric D. Friedman - * @version $Id: TIntLongHashMap.java,v 1.15 2003/11/21 17:32:30 ericdf Exp $ - */ -public class TIntLongHashMap extends TIntHash implements Serializable { - - private static final long serialVersionUID = 8567798970734975106L; - /** the values of the map */ - protected transient long[] _values; - - /** - * Creates a new TIntLongHashMap instance with the default - * capacity and load factor. - */ - public TIntLongHashMap() { - super(); - } - - /** - * Creates a new TIntLongHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the default load factor. - * - * @param initialCapacity an int value - */ - public TIntLongHashMap(int initialCapacity) { - super(initialCapacity); - } - - /** - * Creates a new TIntLongHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the specified load factor. - * - * @param initialCapacity an int value - * @param loadFactor a float value - */ - public TIntLongHashMap(int initialCapacity, float loadFactor) { - super(initialCapacity, loadFactor); - } - - /** - * Creates a new TIntLongHashMap instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TIntLongHashMap(TIntHashingStrategy strategy) { - super(strategy); - } - - /** - * Creates a new TIntLongHashMap instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TIntLongHashMap(int initialCapacity, TIntHashingStrategy strategy) { - super(initialCapacity, strategy); - } - - /** - * Creates a new TIntLongHashMap instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TIntLongHashMap(int initialCapacity, float loadFactor, TIntHashingStrategy strategy) { - super(initialCapacity, loadFactor, strategy); - } - - /** - * @return a deep clone of this collection - */ - @Override // GemStoneAddition - public Object clone() { - TIntLongHashMap m = (TIntLongHashMap)super.clone(); - m._values = this._values.clone(); - return m; - } - - /** - * @return a TIntLongIterator with access to this map's keys and values - */ - public TIntLongIterator iterator() { - return new TIntLongIterator(this); - } - - /** - * initializes the hashtable to a prime capacity which is at least - * initialCapacity + 1. - * - * @param initialCapacity an int value - * @return the actual capacity chosen - */ - @Override // GemStoneAddition - protected int setUp(int initialCapacity) { - int capacity; - - capacity = super.setUp(initialCapacity); - _values = new long[capacity]; - return capacity; - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an int value - * @param value an long value - * @return the previous value associated with key, - * or (long)0 if none was found. - */ - public long put(int key, long value) { - byte previousState; - long previous = 0; - int index = insertionIndex(key); - boolean isNewMapping = true; - if (index < 0) { - index = -index -1; - previous = _values[index]; - isNewMapping = false; - } - previousState = _states[index]; - _set[index] = key; - _states[index] = FULL; - _values[index] = value; - if (isNewMapping) { - postInsertHook(previousState == FREE); - } - - return previous; - } - - /** - * rehashes the map to the new capacity. - * - * @param newCapacity an int value - */ - @Override // GemStoneAddition - protected void rehash(int newCapacity) { - int oldCapacity = _set.length; - int oldKeys[] = _set; - long oldVals[] = _values; - byte oldStates[] = _states; - - _set = new int[newCapacity]; - _values = new long[newCapacity]; - _states = new byte[newCapacity]; - - for (int i = oldCapacity; i-- > 0;) { - if(oldStates[i] == FULL) { - int o = oldKeys[i]; - int index = insertionIndex(o); - _set[index] = o; - _values[index] = oldVals[i]; - _states[index] = FULL; - } - } - } - - /** - * retrieves the value for key - * - * @param key an int value - * @return the value of key or (long)0 if no such mapping exists. - */ - public long get(int key) { - int index = index(key); - return index < 0 ? (long)0 : _values[index]; - } - - /** - * Empties the map. - * - */ - @Override // GemStoneAddition - public void clear() { - super.clear(); - int[] keys = _set; - long[] vals = _values; - byte[] states = _states; - - for (int i = keys.length; i-- > 0;) { - keys[i] = 0; - vals[i] = 0; - states[i] = FREE; - } - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an int value - * @return an long value, or (long)0 if no mapping for key exists - */ - public long remove(int key) { - long prev = 0; - int index = index(key); - if (index >= 0) { - prev = _values[index]; - removeAt(index); // clear key,state; adjust size - } - return prev; - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (! (other instanceof TIntLongHashMap)) { - return false; - } - TIntLongHashMap that = (TIntLongHashMap)other; - if (that.size() != this.size()) { - return false; - } - return forEachEntry(new EqProcedure(that)); - } - - @Override // GemStoneAddition - public int hashCode() { - HashProcedure p = new HashProcedure(); - forEachEntry(p); - return p.getHashCode(); - } - - protected/*GemStoneAddition*/ final class HashProcedure implements TIntLongProcedure { - private int h = 0; - - public int getHashCode() { - return h; - } - - public final boolean execute(int key, long value) { - h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); - return true; - } - } - - private static final class EqProcedure implements TIntLongProcedure { - private final TIntLongHashMap _otherMap; - - EqProcedure(TIntLongHashMap otherMap) { - _otherMap = otherMap; - } - - public final boolean execute(int key, long value) { - int index = _otherMap.index(key); - if (index >= 0 && eq(value, _otherMap.get(key))) { - return true; - } - return false; - } - - /** - * Compare two longs for equality. - */ - private final boolean eq(long v1, long v2) { - return v1 == v2; - } - - } - - /** - * removes the mapping at index from the map. - * - * @param index an int value - */ - @Override // GemStoneAddition - protected void removeAt(int index) { - super.removeAt(index); // clear key, state; adjust size - _values[index] = 0; - } - - /** - * Returns the values of the map. - * - * @return a Collection value - */ - public long[] getValues() { - long[] vals = new long[size()]; - long[] v = _values; - byte[] states = _states; - - for (int i = v.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - vals[j++] = v[i]; - } - } - return vals; - } - - /** - * returns the keys of the map. - * - * @return a Set value - */ - public int[] keys() { - int[] keys = new int[size()]; - int[] k = _set; - byte[] states = _states; - - for (int i = k.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - keys[j++] = k[i]; - } - } - return keys; - } - - /** - * checks for the presence of val in the values of the map. - * - * @param val an long value - * @return a boolean value - */ - public boolean containsValue(long val) { - byte[] states = _states; - long[] vals = _values; - - for (int i = vals.length; i-- > 0;) { - if (states[i] == FULL && val == vals[i]) { - return true; - } - } - return false; - } - - - /** - * checks for the present of key in the keys of the map. - * - * @param key an int value - * @return a boolean value - */ - public boolean containsKey(int key) { - return contains(key); - } - - /** - * Executes procedure for each key in the map. - * - * @param procedure a TIntProcedure value - * @return false if the loop over the keys terminated because - * the procedure returned false for some key. - */ - public boolean forEachKey(TIntProcedure procedure) { - return forEach(procedure); - } - - /** - * Executes procedure for each value in the map. - * - * @param procedure a TLongProcedure value - * @return false if the loop over the values terminated because - * the procedure returned false for some value. - */ - public boolean forEachValue(TLongProcedure procedure) { - byte[] states = _states; - long[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(values[i])) { - return false; - } - } - return true; - } - - /** - * Executes procedure for each key/value entry in the - * map. - * - * @param procedure a TOIntLongProcedure value - * @return false if the loop over the entries terminated because - * the procedure returned false for some entry. - */ - public boolean forEachEntry(TIntLongProcedure procedure) { - byte[] states = _states; - int[] keys = _set; - long[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - return false; - } - } - return true; - } - - /** - * Retains only those entries in the map for which the procedure - * returns a true value. - * - * @param procedure determines which entries to keep - * @return true if the map was modified. - */ - public boolean retainEntries(TIntLongProcedure procedure) { - boolean modified = false; - byte[] states = _states; - int[] keys = _set; - long[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - removeAt(i); - modified = true; - } - } - return modified; - } - - /** - * Transform the values in this map using function. - * - * @param function a TLongFunction value - */ - public void transformValues(TLongFunction function) { - byte[] states = _states; - long[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL) { - values[i] = function.execute(values[i]); - } - } - } - - /** - * Increments the primitive value mapped to key by 1 - * - * @param key the key of the value to increment - * @return true if a mapping was found and modified. - */ - public boolean increment(int key) { - return adjustValue(key, 1); - } - - /** - * Adjusts the primitive value mapped to key. - * - * @param key the key of the value to increment - * @param amount the amount to adjust the value by. - * @return true if a mapping was found and modified. - */ - public boolean adjustValue(int key, long amount) { - int index = index(key); - if (index < 0) { - return false; - } else { - _values[index] += amount; - return true; - } - } - - - private void writeObject(ObjectOutputStream stream) - throws IOException { - stream.defaultWriteObject(); - - // number of entries - stream.writeInt(_size); - - SerializationProcedure writeProcedure = new SerializationProcedure(stream); - if (! forEachEntry(writeProcedure)) { - throw writeProcedure.exception; - } - } - - private void readObject(ObjectInputStream stream) - throws IOException, ClassNotFoundException { - stream.defaultReadObject(); - - int size = stream.readInt(); - setUp(size); - while (size-- > 0) { - int key = stream.readInt(); - long val = stream.readLong(); - put(key, val); - } - } -} // TIntLongHashMap diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntLongIterator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntLongIterator.java deleted file mode 100644 index aff2512dc..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntLongIterator.java +++ /dev/null @@ -1,145 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Iterator for maps of type int and long. - * - *

The iterator semantics for Trove's primitive maps is slightly different - * from those defined in java.util.Iterator, but still well within - * the scope of the pattern, as defined by Gamma, et al.

- * - *

This iterator does not implicitly advance to the next entry when - * the value at the current position is retrieved. Rather, you must explicitly - * ask the iterator to advance() and then retrieve either the key(), - * the value() or both. This is done so that you have the option, but not - * the obligation, to retrieve keys and/or values as your application requires, and - * without introducing wrapper objects that would carry both. As the iteration is - * stateful, access to the key/value parts of the current map entry happens in - * constant time.

- * - *

In practice, the iterator is akin to a "search finger" that you move from - * position to position. Read or write operations affect the current entry only and - * do not assume responsibility for moving the finger.

- * - *

Here are some sample scenarios for this class of iterator:

- * - *
- * // accessing keys/values through an iterator:
- * for (TIntLongIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     doSomethingWithValue(it.value());
- *   }
- * }
- * 
- * - *
- * // modifying values in-place through iteration:
- * for (TIntLongIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.setValue(newValueForKey(it.key()));
- *   }
- * }
- * 
- * - *
- * // deleting entries during iteration:
- * for (TIntLongIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.remove();
- *   }
- * }
- * 
- * - *
- * // faster iteration by avoiding hasNext():
- * TIntLongIterator iterator = map.iterator();
- * for (int i = map.size(); i-- > 0;) {    
- *   iterator.advance();     
- *   doSomethingWithKeyAndValue(iterator.key(), iterator.value());
- * }   
- * 
- * - * @author Eric D. Friedman - * @version $Id: TIntLongIterator.java,v 1.1 2002/09/22 21:53:42 ericdf Exp $ - */ - -public class TIntLongIterator extends TPrimitiveIterator { - /** the collection being iterated over */ - private final TIntLongHashMap _map; - - /** - * Creates an iterator over the specified map - */ - public TIntLongIterator(TIntLongHashMap map) { - super(map); - this._map = map; - } - - /** - * Moves the iterator forward to the next entry in the underlying map. - * - * @exception java.util.NoSuchElementException if the iterator is already exhausted - */ - public void advance() { - moveToNextIndex(); - } - - /** - * Provides access to the key of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the key of the entry at the iterator's current position. - */ - public int key() { - return _map._set[_index]; - } - - /** - * Provides access to the value of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the value of the entry at the iterator's current position. - */ - public long value() { - return _map._values[_index]; - } - - /** - * Replace the value of the mapping at the iterator's position with the - * specified value. Note that you must advance() the iterator at - * least once before invoking this method. - * - * @param val the value to set in the current entry - * @return the old value of the entry. - */ - public long setValue(long val) { - long old = value(); - _map._values[_index] = val; - return old; - } -}// TIntLongIterator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntLongProcedure.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntLongProcedure.java deleted file mode 100644 index ecf84469d..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntLongProcedure.java +++ /dev/null @@ -1,43 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Interface for procedures that take two parameters of type int and long. - * - * Created: Mon Nov 5 22:03:30 2001 - * - * @author Eric D. Friedman - * @version $Id: TIntLongProcedure.java,v 1.7 2002/09/22 21:53:42 ericdf Exp $ - */ - -public interface TIntLongProcedure { - - /** - * Executes this procedure. A false return value indicates that - * the application executing this procedure should not invoke this - * procedure again. - * - * @param a an int value - * @param b an long value - * @return true if additional invocations of the procedure are - * allowed. - */ - public boolean execute(int a, long b); -}// TIntLongProcedure diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntStack.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntStack.java deleted file mode 100644 index de72d775f..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TIntStack.java +++ /dev/null @@ -1,105 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - - -package com.gemstone.gnu.trove; - -/** - * A stack of int primitives, backed by a TIntArrayList. - * - * Created: Tue Jan 1 10:30:35 2002 - * - * @author Eric D. Friedman - * @version $Id: TIntStack.java,v 1.1 2002/01/01 18:51:23 ericdf Exp $ - */ - -public class TIntStack { - - /** the list used to hold the stack values. */ - protected TIntArrayList _list; - - public static final int DEFAULT_CAPACITY = TIntArrayList.DEFAULT_CAPACITY; - - /** - * Creates a new TIntStack instance with the default - * capacity. - */ - public TIntStack() { - this(DEFAULT_CAPACITY); - } - - /** - * Creates a new TIntStack instance with the - * specified capacity. - * - * @param capacity the initial depth of the stack - */ - public TIntStack(int capacity) { - _list = new TIntArrayList(capacity); - } - - /** - * Pushes the value onto the top of the stack. - * - * @param val an int value - */ - public void push(int val) { - _list.add(val); - } - - /** - * Removes and returns the value at the top of the stack. - * - * @return an int value - */ - public int pop() { - return _list.remove(_list.size() - 1); - } - - /** - * Returns the value at the top of the stack. - * - * @return an int value - */ - public int peek() { - return _list.get(_list.size() - 1); - } - - /** - * Returns the current depth of the stack. - * - * @return an int value - */ - public int size() { - return _list.size(); - } - - /** - * Clears the stack, reseting its capacity to the default. - */ - public void clear() { - _list.clear(DEFAULT_CAPACITY); - } - - /** - * Clears the stack without releasing its internal capacity allocation. - */ - public void reset() { - _list.reset(); - } -} // TIntStack diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongDoubleHashMap.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongDoubleHashMap.java deleted file mode 100644 index bb1a1a633..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongDoubleHashMap.java +++ /dev/null @@ -1,536 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - -/** - * An open addressed Map implementation for long keys and double values. - * - * Created: Sun Nov 4 08:52:45 2001 - * - * @author Eric D. Friedman - * @version $Id: TLongDoubleHashMap.java,v 1.15 2003/11/21 17:32:30 ericdf Exp $ - */ -public class TLongDoubleHashMap extends TLongHash implements Serializable { - - private static final long serialVersionUID = -3962746692470961560L; - - /** the values of the map */ - protected transient double[] _values; - - /** - * Creates a new TLongDoubleHashMap instance with the default - * capacity and load factor. - */ - public TLongDoubleHashMap() { - super(); - } - - /** - * Creates a new TLongDoubleHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the default load factor. - * - * @param initialCapacity an int value - */ - public TLongDoubleHashMap(int initialCapacity) { - super(initialCapacity); - } - - /** - * Creates a new TLongDoubleHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the specified load factor. - * - * @param initialCapacity an int value - * @param loadFactor a float value - */ - public TLongDoubleHashMap(int initialCapacity, float loadFactor) { - super(initialCapacity, loadFactor); - } - - /** - * Creates a new TLongDoubleHashMap instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TLongDoubleHashMap(TLongHashingStrategy strategy) { - super(strategy); - } - - /** - * Creates a new TLongDoubleHashMap instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TLongDoubleHashMap(int initialCapacity, TLongHashingStrategy strategy) { - super(initialCapacity, strategy); - } - - /** - * Creates a new TLongDoubleHashMap instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TLongDoubleHashMap(int initialCapacity, float loadFactor, TLongHashingStrategy strategy) { - super(initialCapacity, loadFactor, strategy); - } - - /** - * @return a deep clone of this collection - */ - @Override // GemStoneAddition - public Object clone() { - TLongDoubleHashMap m = (TLongDoubleHashMap)super.clone(); - m._values = this._values.clone(); - return m; - } - - /** - * @return a TLongDoubleIterator with access to this map's keys and values - */ - public TLongDoubleIterator iterator() { - return new TLongDoubleIterator(this); - } - - /** - * initializes the hashtable to a prime capacity which is at least - * initialCapacity + 1. - * - * @param initialCapacity an int value - * @return the actual capacity chosen - */ - @Override // GemStoneAddition - protected int setUp(int initialCapacity) { - int capacity; - - capacity = super.setUp(initialCapacity); - _values = new double[capacity]; - return capacity; - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an long value - * @param value an double value - * @return the previous value associated with key, - * or (double)0 if none was found. - */ - public double put(long key, double value) { - byte previousState; - double previous = 0; - int index = insertionIndex(key); - boolean isNewMapping = true; - if (index < 0) { - index = -index -1; - previous = _values[index]; - isNewMapping = false; - } - previousState = _states[index]; - _set[index] = key; - _states[index] = FULL; - _values[index] = value; - if (isNewMapping) { - postInsertHook(previousState == FREE); - } - - return previous; - } - - /** - * rehashes the map to the new capacity. - * - * @param newCapacity an int value - */ - @Override // GemStoneAddition - protected void rehash(int newCapacity) { - int oldCapacity = _set.length; - long oldKeys[] = _set; - double oldVals[] = _values; - byte oldStates[] = _states; - - _set = new long[newCapacity]; - _values = new double[newCapacity]; - _states = new byte[newCapacity]; - - for (int i = oldCapacity; i-- > 0;) { - if(oldStates[i] == FULL) { - long o = oldKeys[i]; - int index = insertionIndex(o); - _set[index] = o; - _values[index] = oldVals[i]; - _states[index] = FULL; - } - } - } - - /** - * retrieves the value for key - * - * @param key an long value - * @return the value of key or (double)0 if no such mapping exists. - */ - public double get(long key) { - int index = index(key); - return index < 0 ? (double)0 : _values[index]; - } - - /** - * Empties the map. - * - */ - @Override // GemStoneAddition - public void clear() { - super.clear(); - long[] keys = _set; - double[] vals = _values; - byte[] states = _states; - - for (int i = keys.length; i-- > 0;) { - keys[i] = 0; - vals[i] = 0; - states[i] = FREE; - } - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an long value - * @return an double value, or (double)0 if no mapping for key exists - */ - public double remove(long key) { - double prev = 0; - int index = index(key); - if (index >= 0) { - prev = _values[index]; - removeAt(index); // clear key,state; adjust size - } - return prev; - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (! (other instanceof TLongDoubleHashMap)) { - return false; - } - TLongDoubleHashMap that = (TLongDoubleHashMap)other; - if (that.size() != this.size()) { - return false; - } - return forEachEntry(new EqProcedure(that)); - } - - @Override // GemStoneAddition - public int hashCode() { - HashProcedure p = new HashProcedure(); - forEachEntry(p); - return p.getHashCode(); - } - - protected/*GemStoneAddition*/ final class HashProcedure implements TLongDoubleProcedure { - private int h = 0; - - public int getHashCode() { - return h; - } - - public final boolean execute(long key, double value) { - h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); - return true; - } - } - - private static final class EqProcedure implements TLongDoubleProcedure { - private final TLongDoubleHashMap _otherMap; - - EqProcedure(TLongDoubleHashMap otherMap) { - _otherMap = otherMap; - } - - public final boolean execute(long key, double value) { - int index = _otherMap.index(key); - if (index >= 0 && eq(value, _otherMap.get(key))) { - return true; - } - return false; - } - - /** - * Compare two doubles for equality. - */ - private final boolean eq(double v1, double v2) { - return v1 == v2; - } - - } - - /** - * removes the mapping at index from the map. - * - * @param index an int value - */ - @Override // GemStoneAddition - protected void removeAt(int index) { - super.removeAt(index); // clear key, state; adjust size - _values[index] = 0; - } - - /** - * Returns the values of the map. - * - * @return a Collection value - */ - public double[] getValues() { - double[] vals = new double[size()]; - double[] v = _values; - byte[] states = _states; - - for (int i = v.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - vals[j++] = v[i]; - } - } - return vals; - } - - /** - * returns the keys of the map. - * - * @return a Set value - */ - public long[] keys() { - long[] keys = new long[size()]; - long[] k = _set; - byte[] states = _states; - - for (int i = k.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - keys[j++] = k[i]; - } - } - return keys; - } - - /** - * checks for the presence of val in the values of the map. - * - * @param val an double value - * @return a boolean value - */ - public boolean containsValue(double val) { - byte[] states = _states; - double[] vals = _values; - - for (int i = vals.length; i-- > 0;) { - if (states[i] == FULL && val == vals[i]) { - return true; - } - } - return false; - } - - - /** - * checks for the present of key in the keys of the map. - * - * @param key an long value - * @return a boolean value - */ - public boolean containsKey(long key) { - return contains(key); - } - - /** - * Executes procedure for each key in the map. - * - * @param procedure a TLongProcedure value - * @return false if the loop over the keys terminated because - * the procedure returned false for some key. - */ - public boolean forEachKey(TLongProcedure procedure) { - return forEach(procedure); - } - - /** - * Executes procedure for each value in the map. - * - * @param procedure a TDoubleProcedure value - * @return false if the loop over the values terminated because - * the procedure returned false for some value. - */ - public boolean forEachValue(TDoubleProcedure procedure) { - byte[] states = _states; - double[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(values[i])) { - return false; - } - } - return true; - } - - /** - * Executes procedure for each key/value entry in the - * map. - * - * @param procedure a TOLongDoubleProcedure value - * @return false if the loop over the entries terminated because - * the procedure returned false for some entry. - */ - public boolean forEachEntry(TLongDoubleProcedure procedure) { - byte[] states = _states; - long[] keys = _set; - double[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - return false; - } - } - return true; - } - - /** - * Retains only those entries in the map for which the procedure - * returns a true value. - * - * @param procedure determines which entries to keep - * @return true if the map was modified. - */ - public boolean retainEntries(TLongDoubleProcedure procedure) { - boolean modified = false; - byte[] states = _states; - long[] keys = _set; - double[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - removeAt(i); - modified = true; - } - } - return modified; - } - - /** - * Transform the values in this map using function. - * - * @param function a TDoubleFunction value - */ - public void transformValues(TDoubleFunction function) { - byte[] states = _states; - double[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL) { - values[i] = function.execute(values[i]); - } - } - } - - /** - * Increments the primitive value mapped to key by 1 - * - * @param key the key of the value to increment - * @return true if a mapping was found and modified. - */ - public boolean increment(long key) { - return adjustValue(key, 1); - } - - /** - * Adjusts the primitive value mapped to key. - * - * @param key the key of the value to increment - * @param amount the amount to adjust the value by. - * @return true if a mapping was found and modified. - */ - public boolean adjustValue(long key, double amount) { - int index = index(key); - if (index < 0) { - return false; - } else { - _values[index] += amount; - return true; - } - } - - - private void writeObject(ObjectOutputStream stream) - throws IOException { - stream.defaultWriteObject(); - - // number of entries - stream.writeInt(_size); - - SerializationProcedure writeProcedure = new SerializationProcedure(stream); - if (! forEachEntry(writeProcedure)) { - throw writeProcedure.exception; - } - } - - private void readObject(ObjectInputStream stream) - throws IOException, ClassNotFoundException { - stream.defaultReadObject(); - - int size = stream.readInt(); - setUp(size); - while (size-- > 0) { - long key = stream.readLong(); - double val = stream.readDouble(); - put(key, val); - } - } -} // TLongDoubleHashMap diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongDoubleIterator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongDoubleIterator.java deleted file mode 100644 index ed7598ad2..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongDoubleIterator.java +++ /dev/null @@ -1,145 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Iterator for maps of type long and double. - * - *

The iterator semantics for Trove's primitive maps is slightly different - * from those defined in java.util.Iterator, but still well within - * the scope of the pattern, as defined by Gamma, et al.

- * - *

This iterator does not implicitly advance to the next entry when - * the value at the current position is retrieved. Rather, you must explicitly - * ask the iterator to advance() and then retrieve either the key(), - * the value() or both. This is done so that you have the option, but not - * the obligation, to retrieve keys and/or values as your application requires, and - * without introducing wrapper objects that would carry both. As the iteration is - * stateful, access to the key/value parts of the current map entry happens in - * constant time.

- * - *

In practice, the iterator is akin to a "search finger" that you move from - * position to position. Read or write operations affect the current entry only and - * do not assume responsibility for moving the finger.

- * - *

Here are some sample scenarios for this class of iterator:

- * - *
- * // accessing keys/values through an iterator:
- * for (TLongDoubleIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     doSomethingWithValue(it.value());
- *   }
- * }
- * 
- * - *
- * // modifying values in-place through iteration:
- * for (TLongDoubleIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.setValue(newValueForKey(it.key()));
- *   }
- * }
- * 
- * - *
- * // deleting entries during iteration:
- * for (TLongDoubleIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.remove();
- *   }
- * }
- * 
- * - *
- * // faster iteration by avoiding hasNext():
- * TLongDoubleIterator iterator = map.iterator();
- * for (int i = map.size(); i-- > 0;) {    
- *   iterator.advance();     
- *   doSomethingWithKeyAndValue(iterator.key(), iterator.value());
- * }   
- * 
- * - * @author Eric D. Friedman - * @version $Id: TLongDoubleIterator.java,v 1.1 2002/09/22 21:53:42 ericdf Exp $ - */ - -public class TLongDoubleIterator extends TPrimitiveIterator { - /** the collection being iterated over */ - private final TLongDoubleHashMap _map; - - /** - * Creates an iterator over the specified map - */ - public TLongDoubleIterator(TLongDoubleHashMap map) { - super(map); - this._map = map; - } - - /** - * Moves the iterator forward to the next entry in the underlying map. - * - * @exception java.util.NoSuchElementException if the iterator is already exhausted - */ - public void advance() { - moveToNextIndex(); - } - - /** - * Provides access to the key of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the key of the entry at the iterator's current position. - */ - public long key() { - return _map._set[_index]; - } - - /** - * Provides access to the value of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the value of the entry at the iterator's current position. - */ - public double value() { - return _map._values[_index]; - } - - /** - * Replace the value of the mapping at the iterator's position with the - * specified value. Note that you must advance() the iterator at - * least once before invoking this method. - * - * @param val the value to set in the current entry - * @return the old value of the entry. - */ - public double setValue(double val) { - double old = value(); - _map._values[_index] = val; - return old; - } -}// TLongDoubleIterator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongDoubleProcedure.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongDoubleProcedure.java deleted file mode 100644 index d5133acbd..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongDoubleProcedure.java +++ /dev/null @@ -1,43 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Interface for procedures that take two parameters of type long and double. - * - * Created: Mon Nov 5 22:03:30 2001 - * - * @author Eric D. Friedman - * @version $Id: TLongDoubleProcedure.java,v 1.7 2002/09/22 21:53:42 ericdf Exp $ - */ - -public interface TLongDoubleProcedure { - - /** - * Executes this procedure. A false return value indicates that - * the application executing this procedure should not invoke this - * procedure again. - * - * @param a an long value - * @param b an double value - * @return true if additional invocations of the procedure are - * allowed. - */ - public boolean execute(long a, double b); -}// TLongDoubleProcedure diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongFloatHashMap.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongFloatHashMap.java deleted file mode 100644 index 6bc5eb8d1..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongFloatHashMap.java +++ /dev/null @@ -1,535 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - -/** - * An open addressed Map implementation for long keys and float values. - * - * Created: Sun Nov 4 08:52:45 2001 - * - * @author Eric D. Friedman - * @version $Id: TLongFloatHashMap.java,v 1.15 2003/11/21 17:32:30 ericdf Exp $ - */ -public class TLongFloatHashMap extends TLongHash implements Serializable { - - private static final long serialVersionUID = 2786417028044156902L; - /** the values of the map */ - protected transient float[] _values; - - /** - * Creates a new TLongFloatHashMap instance with the default - * capacity and load factor. - */ - public TLongFloatHashMap() { - super(); - } - - /** - * Creates a new TLongFloatHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the default load factor. - * - * @param initialCapacity an int value - */ - public TLongFloatHashMap(int initialCapacity) { - super(initialCapacity); - } - - /** - * Creates a new TLongFloatHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the specified load factor. - * - * @param initialCapacity an int value - * @param loadFactor a float value - */ - public TLongFloatHashMap(int initialCapacity, float loadFactor) { - super(initialCapacity, loadFactor); - } - - /** - * Creates a new TLongFloatHashMap instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TLongFloatHashMap(TLongHashingStrategy strategy) { - super(strategy); - } - - /** - * Creates a new TLongFloatHashMap instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TLongFloatHashMap(int initialCapacity, TLongHashingStrategy strategy) { - super(initialCapacity, strategy); - } - - /** - * Creates a new TLongFloatHashMap instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TLongFloatHashMap(int initialCapacity, float loadFactor, TLongHashingStrategy strategy) { - super(initialCapacity, loadFactor, strategy); - } - - /** - * @return a deep clone of this collection - */ - @Override // GemStoneAddition - public Object clone() { - TLongFloatHashMap m = (TLongFloatHashMap)super.clone(); - m._values = this._values.clone(); - return m; - } - - /** - * @return a TLongFloatIterator with access to this map's keys and values - */ - public TLongFloatIterator iterator() { - return new TLongFloatIterator(this); - } - - /** - * initializes the hashtable to a prime capacity which is at least - * initialCapacity + 1. - * - * @param initialCapacity an int value - * @return the actual capacity chosen - */ - @Override // GemStoneAddition - protected int setUp(int initialCapacity) { - int capacity; - - capacity = super.setUp(initialCapacity); - _values = new float[capacity]; - return capacity; - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an long value - * @param value an float value - * @return the previous value associated with key, - * or (float)0 if none was found. - */ - public float put(long key, float value) { - byte previousState; - float previous = 0; - int index = insertionIndex(key); - boolean isNewMapping = true; - if (index < 0) { - index = -index -1; - previous = _values[index]; - isNewMapping = false; - } - previousState = _states[index]; - _set[index] = key; - _states[index] = FULL; - _values[index] = value; - if (isNewMapping) { - postInsertHook(previousState == FREE); - } - - return previous; - } - - /** - * rehashes the map to the new capacity. - * - * @param newCapacity an int value - */ - @Override // GemStoneAddition - protected void rehash(int newCapacity) { - int oldCapacity = _set.length; - long oldKeys[] = _set; - float oldVals[] = _values; - byte oldStates[] = _states; - - _set = new long[newCapacity]; - _values = new float[newCapacity]; - _states = new byte[newCapacity]; - - for (int i = oldCapacity; i-- > 0;) { - if(oldStates[i] == FULL) { - long o = oldKeys[i]; - int index = insertionIndex(o); - _set[index] = o; - _values[index] = oldVals[i]; - _states[index] = FULL; - } - } - } - - /** - * retrieves the value for key - * - * @param key an long value - * @return the value of key or (float)0 if no such mapping exists. - */ - public float get(long key) { - int index = index(key); - return index < 0 ? (float)0 : _values[index]; - } - - /** - * Empties the map. - * - */ - @Override // GemStoneAddition - public void clear() { - super.clear(); - long[] keys = _set; - float[] vals = _values; - byte[] states = _states; - - for (int i = keys.length; i-- > 0;) { - keys[i] = 0; - vals[i] = 0; - states[i] = FREE; - } - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an long value - * @return an float value, or (float)0 if no mapping for key exists - */ - public float remove(long key) { - float prev = 0; - int index = index(key); - if (index >= 0) { - prev = _values[index]; - removeAt(index); // clear key,state; adjust size - } - return prev; - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (! (other instanceof TLongFloatHashMap)) { - return false; - } - TLongFloatHashMap that = (TLongFloatHashMap)other; - if (that.size() != this.size()) { - return false; - } - return forEachEntry(new EqProcedure(that)); - } - - @Override // GemStoneAddition - public int hashCode() { - HashProcedure p = new HashProcedure(); - forEachEntry(p); - return p.getHashCode(); - } - - protected/*GemStoneAddition*/ final class HashProcedure implements TLongFloatProcedure { - private int h = 0; - - public int getHashCode() { - return h; - } - - public final boolean execute(long key, float value) { - h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); - return true; - } - } - - private static final class EqProcedure implements TLongFloatProcedure { - private final TLongFloatHashMap _otherMap; - - EqProcedure(TLongFloatHashMap otherMap) { - _otherMap = otherMap; - } - - public final boolean execute(long key, float value) { - int index = _otherMap.index(key); - if (index >= 0 && eq(value, _otherMap.get(key))) { - return true; - } - return false; - } - - /** - * Compare two floats for equality. - */ - private final boolean eq(float v1, float v2) { - return v1 == v2; - } - - } - - /** - * removes the mapping at index from the map. - * - * @param index an int value - */ - @Override // GemStoneAddition - protected void removeAt(int index) { - super.removeAt(index); // clear key, state; adjust size - _values[index] = 0; - } - - /** - * Returns the values of the map. - * - * @return a Collection value - */ - public float[] getValues() { - float[] vals = new float[size()]; - float[] v = _values; - byte[] states = _states; - - for (int i = v.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - vals[j++] = v[i]; - } - } - return vals; - } - - /** - * returns the keys of the map. - * - * @return a Set value - */ - public long[] keys() { - long[] keys = new long[size()]; - long[] k = _set; - byte[] states = _states; - - for (int i = k.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - keys[j++] = k[i]; - } - } - return keys; - } - - /** - * checks for the presence of val in the values of the map. - * - * @param val an float value - * @return a boolean value - */ - public boolean containsValue(float val) { - byte[] states = _states; - float[] vals = _values; - - for (int i = vals.length; i-- > 0;) { - if (states[i] == FULL && val == vals[i]) { - return true; - } - } - return false; - } - - - /** - * checks for the present of key in the keys of the map. - * - * @param key an long value - * @return a boolean value - */ - public boolean containsKey(long key) { - return contains(key); - } - - /** - * Executes procedure for each key in the map. - * - * @param procedure a TLongProcedure value - * @return false if the loop over the keys terminated because - * the procedure returned false for some key. - */ - public boolean forEachKey(TLongProcedure procedure) { - return forEach(procedure); - } - - /** - * Executes procedure for each value in the map. - * - * @param procedure a TFloatProcedure value - * @return false if the loop over the values terminated because - * the procedure returned false for some value. - */ - public boolean forEachValue(TFloatProcedure procedure) { - byte[] states = _states; - float[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(values[i])) { - return false; - } - } - return true; - } - - /** - * Executes procedure for each key/value entry in the - * map. - * - * @param procedure a TOLongFloatProcedure value - * @return false if the loop over the entries terminated because - * the procedure returned false for some entry. - */ - public boolean forEachEntry(TLongFloatProcedure procedure) { - byte[] states = _states; - long[] keys = _set; - float[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - return false; - } - } - return true; - } - - /** - * Retains only those entries in the map for which the procedure - * returns a true value. - * - * @param procedure determines which entries to keep - * @return true if the map was modified. - */ - public boolean retainEntries(TLongFloatProcedure procedure) { - boolean modified = false; - byte[] states = _states; - long[] keys = _set; - float[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - removeAt(i); - modified = true; - } - } - return modified; - } - - /** - * Transform the values in this map using function. - * - * @param function a TFloatFunction value - */ - public void transformValues(TFloatFunction function) { - byte[] states = _states; - float[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL) { - values[i] = function.execute(values[i]); - } - } - } - - /** - * Increments the primitive value mapped to key by 1 - * - * @param key the key of the value to increment - * @return true if a mapping was found and modified. - */ - public boolean increment(long key) { - return adjustValue(key, 1); - } - - /** - * Adjusts the primitive value mapped to key. - * - * @param key the key of the value to increment - * @param amount the amount to adjust the value by. - * @return true if a mapping was found and modified. - */ - public boolean adjustValue(long key, float amount) { - int index = index(key); - if (index < 0) { - return false; - } else { - _values[index] += amount; - return true; - } - } - - - private void writeObject(ObjectOutputStream stream) - throws IOException { - stream.defaultWriteObject(); - - // number of entries - stream.writeInt(_size); - - SerializationProcedure writeProcedure = new SerializationProcedure(stream); - if (! forEachEntry(writeProcedure)) { - throw writeProcedure.exception; - } - } - - private void readObject(ObjectInputStream stream) - throws IOException, ClassNotFoundException { - stream.defaultReadObject(); - - int size = stream.readInt(); - setUp(size); - while (size-- > 0) { - long key = stream.readLong(); - float val = stream.readFloat(); - put(key, val); - } - } -} // TLongFloatHashMap diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongFloatIterator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongFloatIterator.java deleted file mode 100644 index 7da972d6b..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongFloatIterator.java +++ /dev/null @@ -1,145 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Iterator for maps of type long and float. - * - *

The iterator semantics for Trove's primitive maps is slightly different - * from those defined in java.util.Iterator, but still well within - * the scope of the pattern, as defined by Gamma, et al.

- * - *

This iterator does not implicitly advance to the next entry when - * the value at the current position is retrieved. Rather, you must explicitly - * ask the iterator to advance() and then retrieve either the key(), - * the value() or both. This is done so that you have the option, but not - * the obligation, to retrieve keys and/or values as your application requires, and - * without introducing wrapper objects that would carry both. As the iteration is - * stateful, access to the key/value parts of the current map entry happens in - * constant time.

- * - *

In practice, the iterator is akin to a "search finger" that you move from - * position to position. Read or write operations affect the current entry only and - * do not assume responsibility for moving the finger.

- * - *

Here are some sample scenarios for this class of iterator:

- * - *
- * // accessing keys/values through an iterator:
- * for (TLongFloatIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     doSomethingWithValue(it.value());
- *   }
- * }
- * 
- * - *
- * // modifying values in-place through iteration:
- * for (TLongFloatIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.setValue(newValueForKey(it.key()));
- *   }
- * }
- * 
- * - *
- * // deleting entries during iteration:
- * for (TLongFloatIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.remove();
- *   }
- * }
- * 
- * - *
- * // faster iteration by avoiding hasNext():
- * TLongFloatIterator iterator = map.iterator();
- * for (int i = map.size(); i-- > 0;) {    
- *   iterator.advance();     
- *   doSomethingWithKeyAndValue(iterator.key(), iterator.value());
- * }   
- * 
- * - * @author Eric D. Friedman - * @version $Id: TLongFloatIterator.java,v 1.1 2002/09/22 21:53:42 ericdf Exp $ - */ - -public class TLongFloatIterator extends TPrimitiveIterator { - /** the collection being iterated over */ - private final TLongFloatHashMap _map; - - /** - * Creates an iterator over the specified map - */ - public TLongFloatIterator(TLongFloatHashMap map) { - super(map); - this._map = map; - } - - /** - * Moves the iterator forward to the next entry in the underlying map. - * - * @exception java.util.NoSuchElementException if the iterator is already exhausted - */ - public void advance() { - moveToNextIndex(); - } - - /** - * Provides access to the key of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the key of the entry at the iterator's current position. - */ - public long key() { - return _map._set[_index]; - } - - /** - * Provides access to the value of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the value of the entry at the iterator's current position. - */ - public float value() { - return _map._values[_index]; - } - - /** - * Replace the value of the mapping at the iterator's position with the - * specified value. Note that you must advance() the iterator at - * least once before invoking this method. - * - * @param val the value to set in the current entry - * @return the old value of the entry. - */ - public float setValue(float val) { - float old = value(); - _map._values[_index] = val; - return old; - } -}// TLongFloatIterator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongFloatProcedure.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongFloatProcedure.java deleted file mode 100644 index e9a469c2a..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongFloatProcedure.java +++ /dev/null @@ -1,43 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Interface for procedures that take two parameters of type long and float. - * - * Created: Mon Nov 5 22:03:30 2001 - * - * @author Eric D. Friedman - * @version $Id: TLongFloatProcedure.java,v 1.7 2002/09/22 21:53:42 ericdf Exp $ - */ - -public interface TLongFloatProcedure { - - /** - * Executes this procedure. A false return value indicates that - * the application executing this procedure should not invoke this - * procedure again. - * - * @param a an long value - * @param b an float value - * @return true if additional invocations of the procedure are - * allowed. - */ - public boolean execute(long a, float b); -}// TLongFloatProcedure diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongIntHashMap.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongIntHashMap.java deleted file mode 100644 index 10f31b49a..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongIntHashMap.java +++ /dev/null @@ -1,535 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - -/** - * An open addressed Map implementation for long keys and int values. - * - * Created: Sun Nov 4 08:52:45 2001 - * - * @author Eric D. Friedman - * @version $Id: TLongIntHashMap.java,v 1.15 2003/11/21 17:32:30 ericdf Exp $ - */ -public class TLongIntHashMap extends TLongHash implements Serializable { - - private static final long serialVersionUID = -823076275246207033L; - /** the values of the map */ - protected transient int[] _values; - - /** - * Creates a new TLongIntHashMap instance with the default - * capacity and load factor. - */ - public TLongIntHashMap() { - super(); - } - - /** - * Creates a new TLongIntHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the default load factor. - * - * @param initialCapacity an int value - */ - public TLongIntHashMap(int initialCapacity) { - super(initialCapacity); - } - - /** - * Creates a new TLongIntHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the specified load factor. - * - * @param initialCapacity an int value - * @param loadFactor a float value - */ - public TLongIntHashMap(int initialCapacity, float loadFactor) { - super(initialCapacity, loadFactor); - } - - /** - * Creates a new TLongIntHashMap instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TLongIntHashMap(TLongHashingStrategy strategy) { - super(strategy); - } - - /** - * Creates a new TLongIntHashMap instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TLongIntHashMap(int initialCapacity, TLongHashingStrategy strategy) { - super(initialCapacity, strategy); - } - - /** - * Creates a new TLongIntHashMap instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TLongIntHashMap(int initialCapacity, float loadFactor, TLongHashingStrategy strategy) { - super(initialCapacity, loadFactor, strategy); - } - - /** - * @return a deep clone of this collection - */ - @Override // GemStoneAddition - public Object clone() { - TLongIntHashMap m = (TLongIntHashMap)super.clone(); - m._values = this._values.clone(); - return m; - } - - /** - * @return a TLongIntIterator with access to this map's keys and values - */ - public TLongIntIterator iterator() { - return new TLongIntIterator(this); - } - - /** - * initializes the hashtable to a prime capacity which is at least - * initialCapacity + 1. - * - * @param initialCapacity an int value - * @return the actual capacity chosen - */ - @Override // GemStoneAddition - protected int setUp(int initialCapacity) { - int capacity; - - capacity = super.setUp(initialCapacity); - _values = new int[capacity]; - return capacity; - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an long value - * @param value an int value - * @return the previous value associated with key, - * or (int)0 if none was found. - */ - public int put(long key, int value) { - byte previousState; - int previous = 0; - int index = insertionIndex(key); - boolean isNewMapping = true; - if (index < 0) { - index = -index -1; - previous = _values[index]; - isNewMapping = false; - } - previousState = _states[index]; - _set[index] = key; - _states[index] = FULL; - _values[index] = value; - if (isNewMapping) { - postInsertHook(previousState == FREE); - } - - return previous; - } - - /** - * rehashes the map to the new capacity. - * - * @param newCapacity an int value - */ - @Override // GemStoneAddition - protected void rehash(int newCapacity) { - int oldCapacity = _set.length; - long oldKeys[] = _set; - int oldVals[] = _values; - byte oldStates[] = _states; - - _set = new long[newCapacity]; - _values = new int[newCapacity]; - _states = new byte[newCapacity]; - - for (int i = oldCapacity; i-- > 0;) { - if(oldStates[i] == FULL) { - long o = oldKeys[i]; - int index = insertionIndex(o); - _set[index] = o; - _values[index] = oldVals[i]; - _states[index] = FULL; - } - } - } - - /** - * retrieves the value for key - * - * @param key an long value - * @return the value of key or (int)0 if no such mapping exists. - */ - public int get(long key) { - int index = index(key); - return index < 0 ? (int)0 : _values[index]; - } - - /** - * Empties the map. - * - */ - @Override // GemStoneAddition - public void clear() { - super.clear(); - long[] keys = _set; - int[] vals = _values; - byte[] states = _states; - - for (int i = keys.length; i-- > 0;) { - keys[i] = 0; - vals[i] = 0; - states[i] = FREE; - } - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an long value - * @return an int value, or (int)0 if no mapping for key exists - */ - public int remove(long key) { - int prev = 0; - int index = index(key); - if (index >= 0) { - prev = _values[index]; - removeAt(index); // clear key,state; adjust size - } - return prev; - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (! (other instanceof TLongIntHashMap)) { - return false; - } - TLongIntHashMap that = (TLongIntHashMap)other; - if (that.size() != this.size()) { - return false; - } - return forEachEntry(new EqProcedure(that)); - } - - @Override // GemStoneAddition - public int hashCode() { - HashProcedure p = new HashProcedure(); - forEachEntry(p); - return p.getHashCode(); - } - - protected/*GemStoneAddition*/ final class HashProcedure implements TLongIntProcedure { - private int h = 0; - - public int getHashCode() { - return h; - } - - public final boolean execute(long key, int value) { - h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); - return true; - } - } - - private static final class EqProcedure implements TLongIntProcedure { - private final TLongIntHashMap _otherMap; - - EqProcedure(TLongIntHashMap otherMap) { - _otherMap = otherMap; - } - - public final boolean execute(long key, int value) { - int index = _otherMap.index(key); - if (index >= 0 && eq(value, _otherMap.get(key))) { - return true; - } - return false; - } - - /** - * Compare two ints for equality. - */ - private final boolean eq(int v1, int v2) { - return v1 == v2; - } - - } - - /** - * removes the mapping at index from the map. - * - * @param index an int value - */ - @Override // GemStoneAddition - protected void removeAt(int index) { - super.removeAt(index); // clear key, state; adjust size - _values[index] = 0; - } - - /** - * Returns the values of the map. - * - * @return a Collection value - */ - public int[] getValues() { - int[] vals = new int[size()]; - int[] v = _values; - byte[] states = _states; - - for (int i = v.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - vals[j++] = v[i]; - } - } - return vals; - } - - /** - * returns the keys of the map. - * - * @return a Set value - */ - public long[] keys() { - long[] keys = new long[size()]; - long[] k = _set; - byte[] states = _states; - - for (int i = k.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - keys[j++] = k[i]; - } - } - return keys; - } - - /** - * checks for the presence of val in the values of the map. - * - * @param val an int value - * @return a boolean value - */ - public boolean containsValue(int val) { - byte[] states = _states; - int[] vals = _values; - - for (int i = vals.length; i-- > 0;) { - if (states[i] == FULL && val == vals[i]) { - return true; - } - } - return false; - } - - - /** - * checks for the present of key in the keys of the map. - * - * @param key an long value - * @return a boolean value - */ - public boolean containsKey(long key) { - return contains(key); - } - - /** - * Executes procedure for each key in the map. - * - * @param procedure a TLongProcedure value - * @return false if the loop over the keys terminated because - * the procedure returned false for some key. - */ - public boolean forEachKey(TLongProcedure procedure) { - return forEach(procedure); - } - - /** - * Executes procedure for each value in the map. - * - * @param procedure a TIntProcedure value - * @return false if the loop over the values terminated because - * the procedure returned false for some value. - */ - public boolean forEachValue(TIntProcedure procedure) { - byte[] states = _states; - int[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(values[i])) { - return false; - } - } - return true; - } - - /** - * Executes procedure for each key/value entry in the - * map. - * - * @param procedure a TOLongIntProcedure value - * @return false if the loop over the entries terminated because - * the procedure returned false for some entry. - */ - public boolean forEachEntry(TLongIntProcedure procedure) { - byte[] states = _states; - long[] keys = _set; - int[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - return false; - } - } - return true; - } - - /** - * Retains only those entries in the map for which the procedure - * returns a true value. - * - * @param procedure determines which entries to keep - * @return true if the map was modified. - */ - public boolean retainEntries(TLongIntProcedure procedure) { - boolean modified = false; - byte[] states = _states; - long[] keys = _set; - int[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - removeAt(i); - modified = true; - } - } - return modified; - } - - /** - * Transform the values in this map using function. - * - * @param function a TIntFunction value - */ - public void transformValues(TIntFunction function) { - byte[] states = _states; - int[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL) { - values[i] = function.execute(values[i]); - } - } - } - - /** - * Increments the primitive value mapped to key by 1 - * - * @param key the key of the value to increment - * @return true if a mapping was found and modified. - */ - public boolean increment(long key) { - return adjustValue(key, 1); - } - - /** - * Adjusts the primitive value mapped to key. - * - * @param key the key of the value to increment - * @param amount the amount to adjust the value by. - * @return true if a mapping was found and modified. - */ - public boolean adjustValue(long key, int amount) { - int index = index(key); - if (index < 0) { - return false; - } else { - _values[index] += amount; - return true; - } - } - - - private void writeObject(ObjectOutputStream stream) - throws IOException { - stream.defaultWriteObject(); - - // number of entries - stream.writeInt(_size); - - SerializationProcedure writeProcedure = new SerializationProcedure(stream); - if (! forEachEntry(writeProcedure)) { - throw writeProcedure.exception; - } - } - - private void readObject(ObjectInputStream stream) - throws IOException, ClassNotFoundException { - stream.defaultReadObject(); - - int size = stream.readInt(); - setUp(size); - while (size-- > 0) { - long key = stream.readLong(); - int val = stream.readInt(); - put(key, val); - } - } -} // TLongIntHashMap diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongIntIterator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongIntIterator.java deleted file mode 100644 index dede0bc27..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongIntIterator.java +++ /dev/null @@ -1,145 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Iterator for maps of type long and int. - * - *

The iterator semantics for Trove's primitive maps is slightly different - * from those defined in java.util.Iterator, but still well within - * the scope of the pattern, as defined by Gamma, et al.

- * - *

This iterator does not implicitly advance to the next entry when - * the value at the current position is retrieved. Rather, you must explicitly - * ask the iterator to advance() and then retrieve either the key(), - * the value() or both. This is done so that you have the option, but not - * the obligation, to retrieve keys and/or values as your application requires, and - * without introducing wrapper objects that would carry both. As the iteration is - * stateful, access to the key/value parts of the current map entry happens in - * constant time.

- * - *

In practice, the iterator is akin to a "search finger" that you move from - * position to position. Read or write operations affect the current entry only and - * do not assume responsibility for moving the finger.

- * - *

Here are some sample scenarios for this class of iterator:

- * - *
- * // accessing keys/values through an iterator:
- * for (TLongIntIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     doSomethingWithValue(it.value());
- *   }
- * }
- * 
- * - *
- * // modifying values in-place through iteration:
- * for (TLongIntIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.setValue(newValueForKey(it.key()));
- *   }
- * }
- * 
- * - *
- * // deleting entries during iteration:
- * for (TLongIntIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.remove();
- *   }
- * }
- * 
- * - *
- * // faster iteration by avoiding hasNext():
- * TLongIntIterator iterator = map.iterator();
- * for (int i = map.size(); i-- > 0;) {    
- *   iterator.advance();     
- *   doSomethingWithKeyAndValue(iterator.key(), iterator.value());
- * }   
- * 
- * - * @author Eric D. Friedman - * @version $Id: TLongIntIterator.java,v 1.1 2002/09/22 21:53:42 ericdf Exp $ - */ - -public class TLongIntIterator extends TPrimitiveIterator { - /** the collection being iterated over */ - private final TLongIntHashMap _map; - - /** - * Creates an iterator over the specified map - */ - public TLongIntIterator(TLongIntHashMap map) { - super(map); - this._map = map; - } - - /** - * Moves the iterator forward to the next entry in the underlying map. - * - * @exception java.util.NoSuchElementException if the iterator is already exhausted - */ - public void advance() { - moveToNextIndex(); - } - - /** - * Provides access to the key of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the key of the entry at the iterator's current position. - */ - public long key() { - return _map._set[_index]; - } - - /** - * Provides access to the value of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the value of the entry at the iterator's current position. - */ - public int value() { - return _map._values[_index]; - } - - /** - * Replace the value of the mapping at the iterator's position with the - * specified value. Note that you must advance() the iterator at - * least once before invoking this method. - * - * @param val the value to set in the current entry - * @return the old value of the entry. - */ - public int setValue(int val) { - int old = value(); - _map._values[_index] = val; - return old; - } -}// TLongIntIterator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongIntProcedure.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongIntProcedure.java deleted file mode 100644 index 364168958..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongIntProcedure.java +++ /dev/null @@ -1,43 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Interface for procedures that take two parameters of type long and int. - * - * Created: Mon Nov 5 22:03:30 2001 - * - * @author Eric D. Friedman - * @version $Id: TLongIntProcedure.java,v 1.7 2002/09/22 21:53:42 ericdf Exp $ - */ - -public interface TLongIntProcedure { - - /** - * Executes this procedure. A false return value indicates that - * the application executing this procedure should not invoke this - * procedure again. - * - * @param a an long value - * @param b an int value - * @return true if additional invocations of the procedure are - * allowed. - */ - public boolean execute(long a, int b); -}// TLongIntProcedure diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongLongHashMap.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongLongHashMap.java deleted file mode 100644 index a144160d4..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongLongHashMap.java +++ /dev/null @@ -1,535 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - -/** - * An open addressed Map implementation for long keys and long values. - * - * Created: Sun Nov 4 08:52:45 2001 - * - * @author Eric D. Friedman - * @version $Id: TLongLongHashMap.java,v 1.15 2003/11/21 17:32:30 ericdf Exp $ - */ -public class TLongLongHashMap extends TLongHash implements Serializable { - - private static final long serialVersionUID = -3782292179592827791L; - /** the values of the map */ - protected transient long[] _values; - - /** - * Creates a new TLongLongHashMap instance with the default - * capacity and load factor. - */ - public TLongLongHashMap() { - super(); - } - - /** - * Creates a new TLongLongHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the default load factor. - * - * @param initialCapacity an int value - */ - public TLongLongHashMap(int initialCapacity) { - super(initialCapacity); - } - - /** - * Creates a new TLongLongHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the specified load factor. - * - * @param initialCapacity an int value - * @param loadFactor a float value - */ - public TLongLongHashMap(int initialCapacity, float loadFactor) { - super(initialCapacity, loadFactor); - } - - /** - * Creates a new TLongLongHashMap instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TLongLongHashMap(TLongHashingStrategy strategy) { - super(strategy); - } - - /** - * Creates a new TLongLongHashMap instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TLongLongHashMap(int initialCapacity, TLongHashingStrategy strategy) { - super(initialCapacity, strategy); - } - - /** - * Creates a new TLongLongHashMap instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TLongLongHashMap(int initialCapacity, float loadFactor, TLongHashingStrategy strategy) { - super(initialCapacity, loadFactor, strategy); - } - - /** - * @return a deep clone of this collection - */ - @Override // GemStoneAddition - public Object clone() { - TLongLongHashMap m = (TLongLongHashMap)super.clone(); - m._values = this._values.clone(); - return m; - } - - /** - * @return a TLongLongIterator with access to this map's keys and values - */ - public TLongLongIterator iterator() { - return new TLongLongIterator(this); - } - - /** - * initializes the hashtable to a prime capacity which is at least - * initialCapacity + 1. - * - * @param initialCapacity an int value - * @return the actual capacity chosen - */ - @Override // GemStoneAddition - protected int setUp(int initialCapacity) { - int capacity; - - capacity = super.setUp(initialCapacity); - _values = new long[capacity]; - return capacity; - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an long value - * @param value an long value - * @return the previous value associated with key, - * or (long)0 if none was found. - */ - public long put(long key, long value) { - byte previousState; - long previous = 0; - int index = insertionIndex(key); - boolean isNewMapping = true; - if (index < 0) { - index = -index -1; - previous = _values[index]; - isNewMapping = false; - } - previousState = _states[index]; - _set[index] = key; - _states[index] = FULL; - _values[index] = value; - if (isNewMapping) { - postInsertHook(previousState == FREE); - } - - return previous; - } - - /** - * rehashes the map to the new capacity. - * - * @param newCapacity an int value - */ - @Override // GemStoneAddition - protected void rehash(int newCapacity) { - int oldCapacity = _set.length; - long oldKeys[] = _set; - long oldVals[] = _values; - byte oldStates[] = _states; - - _set = new long[newCapacity]; - _values = new long[newCapacity]; - _states = new byte[newCapacity]; - - for (int i = oldCapacity; i-- > 0;) { - if(oldStates[i] == FULL) { - long o = oldKeys[i]; - int index = insertionIndex(o); - _set[index] = o; - _values[index] = oldVals[i]; - _states[index] = FULL; - } - } - } - - /** - * retrieves the value for key - * - * @param key an long value - * @return the value of key or (long)0 if no such mapping exists. - */ - public long get(long key) { - int index = index(key); - return index < 0 ? (long)0 : _values[index]; - } - - /** - * Empties the map. - * - */ - @Override // GemStoneAddition - public void clear() { - super.clear(); - long[] keys = _set; - long[] vals = _values; - byte[] states = _states; - - for (int i = keys.length; i-- > 0;) { - keys[i] = 0; - vals[i] = 0; - states[i] = FREE; - } - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an long value - * @return an long value, or (long)0 if no mapping for key exists - */ - public long remove(long key) { - long prev = 0; - int index = index(key); - if (index >= 0) { - prev = _values[index]; - removeAt(index); // clear key,state; adjust size - } - return prev; - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (! (other instanceof TLongLongHashMap)) { - return false; - } - TLongLongHashMap that = (TLongLongHashMap)other; - if (that.size() != this.size()) { - return false; - } - return forEachEntry(new EqProcedure(that)); - } - - @Override // GemStoneAddition - public int hashCode() { - HashProcedure p = new HashProcedure(); - forEachEntry(p); - return p.getHashCode(); - } - - protected/*GemStoneAddition*/ final class HashProcedure implements TLongLongProcedure { - private int h = 0; - - public int getHashCode() { - return h; - } - - public final boolean execute(long key, long value) { - h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); - return true; - } - } - - private static final class EqProcedure implements TLongLongProcedure { - private final TLongLongHashMap _otherMap; - - EqProcedure(TLongLongHashMap otherMap) { - _otherMap = otherMap; - } - - public final boolean execute(long key, long value) { - int index = _otherMap.index(key); - if (index >= 0 && eq(value, _otherMap.get(key))) { - return true; - } - return false; - } - - /** - * Compare two longs for equality. - */ - private final boolean eq(long v1, long v2) { - return v1 == v2; - } - - } - - /** - * removes the mapping at index from the map. - * - * @param index an int value - */ - @Override // GemStoneAddition - protected void removeAt(int index) { - super.removeAt(index); // clear key, state; adjust size - _values[index] = 0; - } - - /** - * Returns the values of the map. - * - * @return a Collection value - */ - public long[] getValues() { - long[] vals = new long[size()]; - long[] v = _values; - byte[] states = _states; - - for (int i = v.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - vals[j++] = v[i]; - } - } - return vals; - } - - /** - * returns the keys of the map. - * - * @return a Set value - */ - public long[] keys() { - long[] keys = new long[size()]; - long[] k = _set; - byte[] states = _states; - - for (int i = k.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - keys[j++] = k[i]; - } - } - return keys; - } - - /** - * checks for the presence of val in the values of the map. - * - * @param val an long value - * @return a boolean value - */ - public boolean containsValue(long val) { - byte[] states = _states; - long[] vals = _values; - - for (int i = vals.length; i-- > 0;) { - if (states[i] == FULL && val == vals[i]) { - return true; - } - } - return false; - } - - - /** - * checks for the present of key in the keys of the map. - * - * @param key an long value - * @return a boolean value - */ - public boolean containsKey(long key) { - return contains(key); - } - - /** - * Executes procedure for each key in the map. - * - * @param procedure a TLongProcedure value - * @return false if the loop over the keys terminated because - * the procedure returned false for some key. - */ - public boolean forEachKey(TLongProcedure procedure) { - return forEach(procedure); - } - - /** - * Executes procedure for each value in the map. - * - * @param procedure a TLongProcedure value - * @return false if the loop over the values terminated because - * the procedure returned false for some value. - */ - public boolean forEachValue(TLongProcedure procedure) { - byte[] states = _states; - long[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(values[i])) { - return false; - } - } - return true; - } - - /** - * Executes procedure for each key/value entry in the - * map. - * - * @param procedure a TOLongLongProcedure value - * @return false if the loop over the entries terminated because - * the procedure returned false for some entry. - */ - public boolean forEachEntry(TLongLongProcedure procedure) { - byte[] states = _states; - long[] keys = _set; - long[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - return false; - } - } - return true; - } - - /** - * Retains only those entries in the map for which the procedure - * returns a true value. - * - * @param procedure determines which entries to keep - * @return true if the map was modified. - */ - public boolean retainEntries(TLongLongProcedure procedure) { - boolean modified = false; - byte[] states = _states; - long[] keys = _set; - long[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - removeAt(i); - modified = true; - } - } - return modified; - } - - /** - * Transform the values in this map using function. - * - * @param function a TLongFunction value - */ - public void transformValues(TLongFunction function) { - byte[] states = _states; - long[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL) { - values[i] = function.execute(values[i]); - } - } - } - - /** - * Increments the primitive value mapped to key by 1 - * - * @param key the key of the value to increment - * @return true if a mapping was found and modified. - */ - public boolean increment(long key) { - return adjustValue(key, 1); - } - - /** - * Adjusts the primitive value mapped to key. - * - * @param key the key of the value to increment - * @param amount the amount to adjust the value by. - * @return true if a mapping was found and modified. - */ - public boolean adjustValue(long key, long amount) { - int index = index(key); - if (index < 0) { - return false; - } else { - _values[index] += amount; - return true; - } - } - - - private void writeObject(ObjectOutputStream stream) - throws IOException { - stream.defaultWriteObject(); - - // number of entries - stream.writeInt(_size); - - SerializationProcedure writeProcedure = new SerializationProcedure(stream); - if (! forEachEntry(writeProcedure)) { - throw writeProcedure.exception; - } - } - - private void readObject(ObjectInputStream stream) - throws IOException, ClassNotFoundException { - stream.defaultReadObject(); - - int size = stream.readInt(); - setUp(size); - while (size-- > 0) { - long key = stream.readLong(); - long val = stream.readLong(); - put(key, val); - } - } -} // TLongLongHashMap diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongLongIterator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongLongIterator.java deleted file mode 100644 index 69f75c5ae..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongLongIterator.java +++ /dev/null @@ -1,145 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Iterator for maps of type long and long. - * - *

The iterator semantics for Trove's primitive maps is slightly different - * from those defined in java.util.Iterator, but still well within - * the scope of the pattern, as defined by Gamma, et al.

- * - *

This iterator does not implicitly advance to the next entry when - * the value at the current position is retrieved. Rather, you must explicitly - * ask the iterator to advance() and then retrieve either the key(), - * the value() or both. This is done so that you have the option, but not - * the obligation, to retrieve keys and/or values as your application requires, and - * without introducing wrapper objects that would carry both. As the iteration is - * stateful, access to the key/value parts of the current map entry happens in - * constant time.

- * - *

In practice, the iterator is akin to a "search finger" that you move from - * position to position. Read or write operations affect the current entry only and - * do not assume responsibility for moving the finger.

- * - *

Here are some sample scenarios for this class of iterator:

- * - *
- * // accessing keys/values through an iterator:
- * for (TLongLongIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     doSomethingWithValue(it.value());
- *   }
- * }
- * 
- * - *
- * // modifying values in-place through iteration:
- * for (TLongLongIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.setValue(newValueForKey(it.key()));
- *   }
- * }
- * 
- * - *
- * // deleting entries during iteration:
- * for (TLongLongIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.remove();
- *   }
- * }
- * 
- * - *
- * // faster iteration by avoiding hasNext():
- * TLongLongIterator iterator = map.iterator();
- * for (int i = map.size(); i-- > 0;) {    
- *   iterator.advance();     
- *   doSomethingWithKeyAndValue(iterator.key(), iterator.value());
- * }   
- * 
- * - * @author Eric D. Friedman - * @version $Id: TLongLongIterator.java,v 1.1 2002/09/22 21:53:42 ericdf Exp $ - */ - -public class TLongLongIterator extends TPrimitiveIterator { - /** the collection being iterated over */ - private final TLongLongHashMap _map; - - /** - * Creates an iterator over the specified map - */ - public TLongLongIterator(TLongLongHashMap map) { - super(map); - this._map = map; - } - - /** - * Moves the iterator forward to the next entry in the underlying map. - * - * @exception java.util.NoSuchElementException if the iterator is already exhausted - */ - public void advance() { - moveToNextIndex(); - } - - /** - * Provides access to the key of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the key of the entry at the iterator's current position. - */ - public long key() { - return _map._set[_index]; - } - - /** - * Provides access to the value of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the value of the entry at the iterator's current position. - */ - public long value() { - return _map._values[_index]; - } - - /** - * Replace the value of the mapping at the iterator's position with the - * specified value. Note that you must advance() the iterator at - * least once before invoking this method. - * - * @param val the value to set in the current entry - * @return the old value of the entry. - */ - public long setValue(long val) { - long old = value(); - _map._values[_index] = val; - return old; - } -}// TLongLongIterator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongLongProcedure.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongLongProcedure.java deleted file mode 100644 index 9f47a37e8..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongLongProcedure.java +++ /dev/null @@ -1,43 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Interface for procedures that take two parameters of type long and long. - * - * Created: Mon Nov 5 22:03:30 2001 - * - * @author Eric D. Friedman - * @version $Id: TLongLongProcedure.java,v 1.7 2002/09/22 21:53:42 ericdf Exp $ - */ - -public interface TLongLongProcedure { - - /** - * Executes this procedure. A false return value indicates that - * the application executing this procedure should not invoke this - * procedure again. - * - * @param a an long value - * @param b an long value - * @return true if additional invocations of the procedure are - * allowed. - */ - public boolean execute(long a, long b); -}// TLongLongProcedure diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongObjectHashMap.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongObjectHashMap.java deleted file mode 100644 index 6bd0fe7c0..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongObjectHashMap.java +++ /dev/null @@ -1,521 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - -/** - * An open addressed Map implementation for long keys and Object values. - * - * Created: Sun Nov 4 08:52:45 2001 - * - * @author Eric D. Friedman - * @version $Id: TLongObjectHashMap.java,v 1.15 2003/11/21 17:32:31 ericdf Exp $ - */ -public class TLongObjectHashMap extends TLongHash implements Serializable { -private static final long serialVersionUID = 7524673861954387917L; - - /** the values of the map */ - protected transient Object[] _values; - - /** - * Creates a new TLongObjectHashMap instance with the default - * capacity and load factor. - */ - public TLongObjectHashMap() { - super(); - } - - /** - * Creates a new TLongObjectHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the default load factor. - * - * @param initialCapacity an int value - */ - public TLongObjectHashMap(int initialCapacity) { - super(initialCapacity); - } - - /** - * Creates a new TLongObjectHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the specified load factor. - * - * @param initialCapacity an int value - * @param loadFactor a float value - */ - public TLongObjectHashMap(int initialCapacity, float loadFactor) { - super(initialCapacity, loadFactor); - } - - /** - * Creates a new TLongObjectHashMap instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TLongObjectHashMap(TLongHashingStrategy strategy) { - super(strategy); - } - - /** - * Creates a new TLongObjectHashMap instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TLongObjectHashMap(int initialCapacity, TLongHashingStrategy strategy) { - super(initialCapacity, strategy); - } - - /** - * Creates a new TLongObjectHashMap instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TLongObjectHashMap(int initialCapacity, float loadFactor, TLongHashingStrategy strategy) { - super(initialCapacity, loadFactor, strategy); - } - - /** - * @return a deep clone of this collection - */ - @Override // GemStoneAddition - public Object clone() { - TLongObjectHashMap m = (TLongObjectHashMap)super.clone(); - m._values = this._values.clone(); - return m; - } - - /** - * @return a TLongObjectIterator with access to this map's keys and values - */ - public TLongObjectIterator iterator() { - return new TLongObjectIterator(this); - } - - /** - * initializes the hashtable to a prime capacity which is at least - * initialCapacity + 1. - * - * @param initialCapacity an int value - * @return the actual capacity chosen - */ - @Override // GemStoneAddition - protected int setUp(int initialCapacity) { - int capacity; - - capacity = super.setUp(initialCapacity); - _values = new Object[capacity]; - return capacity; - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an long value - * @param value an Object value - * @return the previous value associated with key, - * or null if none was found. - */ - public Object put(long key, Object value) { - byte previousState; - Object previous = null; - int index = insertionIndex(key); - boolean isNewMapping = true; - if (index < 0) { - index = -index -1; - previous = _values[index]; - isNewMapping = false; - } - previousState = _states[index]; - _set[index] = key; - _states[index] = FULL; - _values[index] = value; - if (isNewMapping) { - postInsertHook(previousState == FREE); - } - - return previous; - } - - /** - * rehashes the map to the new capacity. - * - * @param newCapacity an int value - */ - @Override // GemStoneAddition - protected void rehash(int newCapacity) { - int oldCapacity = _set.length; - long oldKeys[] = _set; - Object oldVals[] = _values; - byte oldStates[] = _states; - - _set = new long[newCapacity]; - _values = new Object[newCapacity]; - _states = new byte[newCapacity]; - - for (int i = oldCapacity; i-- > 0;) { - if(oldStates[i] == FULL) { - long o = oldKeys[i]; - int index = insertionIndex(o); - _set[index] = o; - _values[index] = oldVals[i]; - _states[index] = FULL; - } - } - } - - /** - * retrieves the value for key - * - * @param key an long value - * @return the value of key or null if no such mapping exists. - */ - public Object get(long key) { - int index = index(key); - return index < 0 ? null : _values[index]; - } - - /** - * Empties the map. - * - */ - @Override // GemStoneAddition - public void clear() { - super.clear(); - long[] keys = _set; - Object[] vals = _values; - byte[] states = _states; - - for (int i = keys.length; i-- > 0;) { - keys[i] = 0; - vals[i] = null; - states[i] = FREE; - } - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an long value - * @return an Object value, or null if no mapping for key exists - */ - public Object remove(long key) { - Object prev = null; - int index = index(key); - if (index >= 0) { - prev = _values[index]; - removeAt(index); // clear key,state; adjust size - } - return prev; - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (! (other instanceof TLongObjectHashMap)) { - return false; - } - TLongObjectHashMap that = (TLongObjectHashMap)other; - if (that.size() != this.size()) { - return false; - } - return forEachEntry(new EqProcedure(that)); - } - - @Override // GemStoneAddition - public int hashCode() { - HashProcedure p = new HashProcedure(); - forEachEntry(p); - return p.getHashCode(); - } - - protected/*GemStoneAddition*/ final class HashProcedure implements TLongObjectProcedure { - private int h = 0; - - public int getHashCode() { - return h; - } - - public final boolean execute(long key, Object value) { - h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); - return true; - } - } - - private static final class EqProcedure implements TLongObjectProcedure { - private final TLongObjectHashMap _otherMap; - - EqProcedure(TLongObjectHashMap otherMap) { - _otherMap = otherMap; - } - - public final boolean execute(long key, Object value) { - int index = _otherMap.index(key); - if (index >= 0 && eq(value, _otherMap.get(key))) { - return true; - } - return false; - } - - /** - * Compare two objects for equality. - */ - private final boolean eq(Object o1, Object o2) { - return o1 == o2 || ((o1 != null) && o1.equals(o2)); - } - - } - - /** - * removes the mapping at index from the map. - * - * @param index an int value - */ - @Override // GemStoneAddition - protected void removeAt(int index) { - super.removeAt(index); // clear key, state; adjust size - _values[index] = null; - } - - /** - * Returns the values of the map. - * - * @return a Collection value - */ - public Object[] getValues() { - Object[] vals = new Object[size()]; - Object[] v = _values; - byte[] states = _states; - - for (int i = v.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - vals[j++] = v[i]; - } - } - return vals; - } - - /** - * returns the keys of the map. - * - * @return a Set value - */ - public long[] keys() { - long[] keys = new long[size()]; - long[] k = _set; - byte[] states = _states; - - for (int i = k.length, j = 0; i-- > 0;) { - if (states[i] == FULL) { - keys[j++] = k[i]; - } - } - return keys; - } - - /** - * checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - public boolean containsValue(Object val) { - byte[] states = _states; - Object[] vals = _values; - - // special case null values so that we don't have to - // perform null checks before every call to equals() - if (null == val) { - for (int i = vals.length; i-- > 0;) { - if (states[i] == FULL && - val == vals[i]) { - return true; - } - } - } else { - for (int i = vals.length; i-- > 0;) { - if (states[i] == FULL && - (val == vals[i] || val.equals(vals[i]))) { - return true; - } - } - } // end of else - return false; - } - - - /** - * checks for the present of key in the keys of the map. - * - * @param key an long value - * @return a boolean value - */ - public boolean containsKey(long key) { - return contains(key); - } - - /** - * Executes procedure for each key in the map. - * - * @param procedure a TLongProcedure value - * @return false if the loop over the keys terminated because - * the procedure returned false for some key. - */ - public boolean forEachKey(TLongProcedure procedure) { - return forEach(procedure); - } - - /** - * Executes procedure for each value in the map. - * - * @param procedure a TObjectProcedure value - * @return false if the loop over the values terminated because - * the procedure returned false for some value. - */ - public boolean forEachValue(TObjectProcedure procedure) { - byte[] states = _states; - Object[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(values[i])) { - return false; - } - } - return true; - } - - /** - * Executes procedure for each key/value entry in the - * map. - * - * @param procedure a TOLongObjectProcedure value - * @return false if the loop over the entries terminated because - * the procedure returned false for some entry. - */ - public boolean forEachEntry(TLongObjectProcedure procedure) { - byte[] states = _states; - long[] keys = _set; - Object[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - return false; - } - } - return true; - } - - /** - * Retains only those entries in the map for which the procedure - * returns a true value. - * - * @param procedure determines which entries to keep - * @return true if the map was modified. - */ - public boolean retainEntries(TLongObjectProcedure procedure) { - boolean modified = false; - byte[] states = _states; - long[] keys = _set; - Object[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { - removeAt(i); - modified = true; - } - } - return modified; - } - - /** - * Transform the values in this map using function. - * - * @param function a TObjectFunction value - */ - public void transformValues(TObjectFunction function) { - byte[] states = _states; - Object[] values = _values; - for (int i = values.length; i-- > 0;) { - if (states[i] == FULL) { - values[i] = function.execute(values[i]); - } - } - } - - - - private void writeObject(ObjectOutputStream stream) - throws IOException { - stream.defaultWriteObject(); - - // number of entries - stream.writeInt(_size); - - SerializationProcedure writeProcedure = new SerializationProcedure(stream); - if (! forEachEntry(writeProcedure)) { - throw writeProcedure.exception; - } - } - - private void readObject(ObjectInputStream stream) - throws IOException, ClassNotFoundException { - stream.defaultReadObject(); - - int size = stream.readInt(); - setUp(size); - while (size-- > 0) { - long key = stream.readLong(); - Object val = stream.readObject(); - put(key, val); - } - } -} // TLongObjectHashMap diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongObjectIterator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongObjectIterator.java deleted file mode 100644 index 7d89939a9..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TLongObjectIterator.java +++ /dev/null @@ -1,145 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Iterator for maps of type long and Object. - * - *

The iterator semantics for Trove's primitive maps is slightly different - * from those defined in java.util.Iterator, but still well within - * the scope of the pattern, as defined by Gamma, et al.

- * - *

This iterator does not implicitly advance to the next entry when - * the value at the current position is retrieved. Rather, you must explicitly - * ask the iterator to advance() and then retrieve either the key(), - * the value() or both. This is done so that you have the option, but not - * the obligation, to retrieve keys and/or values as your application requires, and - * without introducing wrapper objects that would carry both. As the iteration is - * stateful, access to the key/value parts of the current map entry happens in - * constant time.

- * - *

In practice, the iterator is akin to a "search finger" that you move from - * position to position. Read or write operations affect the current entry only and - * do not assume responsibility for moving the finger.

- * - *

Here are some sample scenarios for this class of iterator:

- * - *
- * // accessing keys/values through an iterator:
- * for (TLongObjectIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     doSomethingWithValue(it.value());
- *   }
- * }
- * 
- * - *
- * // modifying values in-place through iteration:
- * for (TLongObjectIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.setValue(newValueForKey(it.key()));
- *   }
- * }
- * 
- * - *
- * // deleting entries during iteration:
- * for (TLongObjectIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.remove();
- *   }
- * }
- * 
- * - *
- * // faster iteration by avoiding hasNext():
- * TLongObjectIterator iterator = map.iterator();
- * for (int i = map.size(); i-- > 0;) {    
- *   iterator.advance();     
- *   doSomethingWithKeyAndValue(iterator.key(), iterator.value());
- * }   
- * 
- * - * @author Eric D. Friedman - * @version $Id: TLongObjectIterator.java,v 1.1 2002/09/22 21:53:42 ericdf Exp $ - */ - -public class TLongObjectIterator extends TPrimitiveIterator { - /** the collection being iterated over */ - private final TLongObjectHashMap _map; - - /** - * Creates an iterator over the specified map - */ - public TLongObjectIterator(TLongObjectHashMap map) { - super(map); - this._map = map; - } - - /** - * Moves the iterator forward to the next entry in the underlying map. - * - * @exception java.util.NoSuchElementException if the iterator is already exhausted - */ - public void advance() { - moveToNextIndex(); - } - - /** - * Provides access to the key of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the key of the entry at the iterator's current position. - */ - public long key() { - return _map._set[_index]; - } - - /** - * Provides access to the value of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the value of the entry at the iterator's current position. - */ - public Object value() { - return _map._values[_index]; - } - - /** - * Replace the value of the mapping at the iterator's position with the - * specified value. Note that you must advance() the iterator at - * least once before invoking this method. - * - * @param val the value to set in the current entry - * @return the old value of the entry. - */ - public Object setValue(Object val) { - Object old = value(); - _map._values[_index] = val; - return old; - } -}// TLongObjectIterator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TObjectDoubleHashMap.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TObjectDoubleHashMap.java deleted file mode 100644 index 36b61af93..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TObjectDoubleHashMap.java +++ /dev/null @@ -1,515 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - -/** - * An open addressed Map implementation for Object keys and double values. - * - * Created: Sun Nov 4 08:52:45 2001 - * - * @author Eric D. Friedman - * @version $Id: TObjectDoubleHashMap.java,v 1.13 2003/03/23 04:06:59 ericdf Exp $ - */ -public class TObjectDoubleHashMap extends TObjectHash implements Serializable { - - private static final long serialVersionUID = 3715274969856866852L; - /** the values of the map */ - protected transient double[] _values; - - /** - * Creates a new TObjectDoubleHashMap instance with the default - * capacity and load factor. - */ - public TObjectDoubleHashMap() { - super(); - } - - /** - * Creates a new TObjectDoubleHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the default load factor. - * - * @param initialCapacity an int value - */ - public TObjectDoubleHashMap(int initialCapacity) { - super(initialCapacity); - } - - /** - * Creates a new TObjectDoubleHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the specified load factor. - * - * @param initialCapacity an int value - * @param loadFactor a float value - */ - public TObjectDoubleHashMap(int initialCapacity, float loadFactor) { - super(initialCapacity, loadFactor); - } - - /** - * Creates a new TObjectDoubleHashMap instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TObjectDoubleHashMap(TObjectHashingStrategy strategy) { - super(strategy); - } - - /** - * Creates a new TObjectDoubleHashMap instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TObjectDoubleHashMap(int initialCapacity, TObjectHashingStrategy strategy) { - super(initialCapacity, strategy); - } - - /** - * Creates a new TObjectDoubleHashMap instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TObjectDoubleHashMap(int initialCapacity, float loadFactor, TObjectHashingStrategy strategy) { - super(initialCapacity, loadFactor, strategy); - } - - /** - * @return an iterator over the entries in this map - */ - public TObjectDoubleIterator iterator() { - return new TObjectDoubleIterator(this); - } - - /** - * initializes the hashtable to a prime capacity which is at least - * initialCapacity + 1. - * - * @param initialCapacity an int value - * @return the actual capacity chosen - */ - @Override // GemStoneAddition - protected int setUp(int initialCapacity) { - int capacity; - - capacity = super.setUp(initialCapacity); - _values = new double[capacity]; - return capacity; - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an Object value - * @param value an double value - * @return the previous value associated with key, - * or null if none was found. - */ - public double put(Object key, double value) { - double previous = 0; - int index = insertionIndex(key); - boolean isNewMapping = true; - if (index < 0) { - index = -index -1; - previous = _values[index]; - isNewMapping = false; - } - Object oldKey = _set[index]; - _set[index] = key; - _values[index] = value; - - if (isNewMapping) { - postInsertHook(oldKey == null); - } - return previous; - } - - /** - * rehashes the map to the new capacity. - * - * @param newCapacity an int value - */ - @Override // GemStoneAddition - protected void rehash(int newCapacity) { - int oldCapacity = _set.length; - Object oldKeys[] = _set; - double oldVals[] = _values; - - _set = new Object[newCapacity]; - _values = new double[newCapacity]; - - for (int i = oldCapacity; i-- > 0;) { - if(oldKeys[i] != null && oldKeys[i] != REMOVED) { - Object o = oldKeys[i]; - int index = insertionIndex(o); - if (index < 0) { - throwObjectContractViolation(_set[(-index -1)], o); - } - _set[index] = o; - _values[index] = oldVals[i]; - } - } - } - - /** - * retrieves the value for key - * - * @param key an Object value - * @return the value of key or null if no such mapping exists. - */ - public double get(Object key) { - int index = index(key); - return index < 0 ? (double)0 : _values[index]; - } - - /** - * Empties the map. - * - */ - @Override // GemStoneAddition - public void clear() { - super.clear(); - Object[] keys = _set; - double[] vals = _values; - - for (int i = keys.length; i-- > 0;) { - keys[i] = null; - vals[i] = 0; - } - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an Object value - * @return an double value - */ - public double remove(Object key) { - double prev = 0; - int index = index(key); - if (index >= 0) { - prev = _values[index]; - removeAt(index); // clear key,state; adjust size - } - return prev; - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (! (other instanceof TObjectDoubleHashMap)) { - return false; - } - TObjectDoubleHashMap that = (TObjectDoubleHashMap)other; - if (that.size() != this.size()) { - return false; - } - return forEachEntry(new EqProcedure(that)); - } - - /* - * (non-Javadoc) - * @see java.lang.Object#hashCode() - * - * Note that we just need to make sure that equal objects return equal - * hashcodes; nothing really elaborate is done here. - */ - @Override // GemStoneAddition - public int hashCode() { // GemStoneAddition - return 0; // TODO could make this more efficient :-) - } - - private static final class EqProcedure implements TObjectDoubleProcedure { - private final TObjectDoubleHashMap _otherMap; - - EqProcedure(TObjectDoubleHashMap otherMap) { - _otherMap = otherMap; - } - - public final boolean execute(Object key, double value) { - int index = _otherMap.index(key); - if (index >= 0 && eq(value, _otherMap.get(key))) { - return true; - } - return false; - } - - /** - * Compare two doubles for equality. - */ - private final boolean eq(double v1, double v2) { - return v1 == v2; - } - - } - - /** - * removes the mapping at index from the map. - * - * @param index an int value - */ - @Override // GemStoneAddition - protected void removeAt(int index) { - super.removeAt(index); // clear key, state; adjust size - _values[index] = 0; - } - - /** - * Returns the values of the map. - * - * @return a Collection value - */ - public double[] getValues() { - double[] vals = new double[size()]; - double[] v = _values; - Object[] keys = _set; - - for (int i = v.length, j = 0; i-- > 0;) { - if (keys[i] != null && keys[i] != REMOVED) { - vals[j++] = v[i]; - } - } - return vals; - } - - /** - * returns the keys of the map. - * - * @return a Set value - */ - public Object[] keys() { - Object[] keys = new Object[size()]; - Object[] k = _set; - - for (int i = k.length, j = 0; i-- > 0;) { - if (k[i] != null && k[i] != REMOVED) { - keys[j++] = k[i]; - } - } - return keys; - } - - /** - * checks for the presence of val in the values of the map. - * - * @param val an double value - * @return a boolean value - */ - public boolean containsValue(double val) { - Object[] keys = _set; - double[] vals = _values; - - for (int i = vals.length; i-- > 0;) { - if (keys[i] != null && keys[i] != REMOVED && val == vals[i]) { - return true; - } - } - return false; - } - - - /** - * checks for the present of key in the keys of the map. - * - * @param key an Object value - * @return a boolean value - */ - public boolean containsKey(Object key) { - return contains(key); - } - - /** - * Executes procedure for each key in the map. - * - * @param procedure a TObjectProcedure value - * @return false if the loop over the keys terminated because - * the procedure returned false for some key. - */ - public boolean forEachKey(TObjectProcedure procedure) { - return forEach(procedure); - } - - /** - * Executes procedure for each value in the map. - * - * @param procedure a TDoubleProcedure value - * @return false if the loop over the values terminated because - * the procedure returned false for some value. - */ - public boolean forEachValue(TDoubleProcedure procedure) { - Object[] keys = _set; - double[] values = _values; - for (int i = values.length; i-- > 0;) { - if (keys[i] != null && keys[i] != REMOVED - && ! procedure.execute(values[i])) { - return false; - } - } - return true; - } - - /** - * Executes procedure for each key/value entry in the - * map. - * - * @param procedure a TOObjectDoubleProcedure value - * @return false if the loop over the entries terminated because - * the procedure returned false for some entry. - */ - public boolean forEachEntry(TObjectDoubleProcedure procedure) { - Object[] keys = _set; - double[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (keys[i] != null - && keys[i] != REMOVED - && ! procedure.execute(keys[i],values[i])) { - return false; - } - } - return true; - } - - /** - * Retains only those entries in the map for which the procedure - * returns a true value. - * - * @param procedure determines which entries to keep - * @return true if the map was modified. - */ - public boolean retainEntries(TObjectDoubleProcedure procedure) { - boolean modified = false; - Object[] keys = _set; - double[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (keys[i] != null - && keys[i] != REMOVED - && ! procedure.execute(keys[i],values[i])) { - removeAt(i); - modified = true; - } - } - return modified; - } - - /** - * Transform the values in this map using function. - * - * @param function a TDoubleFunction value - */ - public void transformValues(TDoubleFunction function) { - Object[] keys = _set; - double[] values = _values; - for (int i = values.length; i-- > 0;) { - if (keys[i] != null && keys[i] != REMOVED) { - values[i] = function.execute(values[i]); - } - } - } - - /** - * Increments the primitive value mapped to key by 1 - * - * @param key the key of the value to increment - * @return true if a mapping was found and modified. - */ - public boolean increment(Object key) { - return adjustValue(key, 1); - } - - /** - * Adjusts the primitive value mapped to key. - * - * @param key the key of the value to increment - * @param amount the amount to adjust the value by. - * @return true if a mapping was found and modified. - */ - public boolean adjustValue(Object key, double amount) { - int index = index(key); - if (index < 0) { - return false; - } else { - _values[index] += amount; - return true; - } - } - - - private void writeObject(ObjectOutputStream stream) - throws IOException { - stream.defaultWriteObject(); - - // number of entries - stream.writeInt(_size); - - SerializationProcedure writeProcedure = new SerializationProcedure(stream); - if (! forEachEntry(writeProcedure)) { - throw writeProcedure.exception; - } - } - - private void readObject(ObjectInputStream stream) - throws IOException, ClassNotFoundException { - stream.defaultReadObject(); - - int size = stream.readInt(); - setUp(size); - while (size-- > 0) { - Object key = stream.readObject(); - double val = stream.readDouble(); - put(key, val); - } - } -} // TObjectDoubleHashMap diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TObjectDoubleIterator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TObjectDoubleIterator.java deleted file mode 100644 index ed581e635..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TObjectDoubleIterator.java +++ /dev/null @@ -1,161 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -import java.util.ConcurrentModificationException; - -/** - * Iterator for maps of type Object and double. - * - *

The iterator semantics for Trove's primitive maps is slightly different - * from those defined in java.util.Iterator, but still well within - * the scope of the pattern, as defined by Gamma, et al.

- * - *

This iterator does not implicitly advance to the next entry when - * the value at the current position is retrieved. Rather, you must explicitly - * ask the iterator to advance() and then retrieve either the key(), - * the value() or both. This is done so that you have the option, but not - * the obligation, to retrieve keys and/or values as your application requires, and - * without introducing wrapper objects that would carry both. As the iteration is - * stateful, access to the key/value parts of the current map entry happens in - * constant time.

- * - *

In practice, the iterator is akin to a "search finger" that you move from - * position to position. Read or write operations affect the current entry only and - * do not assume responsibility for moving the finger.

- * - *

Here are some sample scenarios for this class of iterator:

- * - *
- * // accessing keys/values through an iterator:
- * for (TObjectDoubleIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     doSomethingWithValue(it.value());
- *   }
- * }
- * 
- * - *
- * // modifying values in-place through iteration:
- * for (TObjectDoubleIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.setValue(newValueForKey(it.key()));
- *   }
- * }
- * 
- * - *
- * // deleting entries during iteration:
- * for (TObjectDoubleIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.remove();
- *   }
- * }
- * 
- * - *
- * // faster iteration by avoiding hasNext():
- * TObjectDoubleIterator iterator = map.iterator();
- * for (int i = map.size(); i-- > 0;) {
- *   iterator.advance();
- *   doSomethingWithKeyAndValue(iterator.key(), iterator.value());
- * }
- * 
- * - * @author Eric D. Friedman - * @version $Id: TObjectDoubleIterator.java,v 1.1 2002/09/22 21:53:42 ericdf Exp $ - */ - -public class TObjectDoubleIterator extends TIterator { - private final TObjectDoubleHashMap _map; - - public TObjectDoubleIterator(TObjectDoubleHashMap map) { - super(map); - this._map = map; - } - - /** - * Returns the index of the next value in the data structure - * or a negative value if the iterator is exhausted. - * - * @return an int value - */ - @Override // GemStoneAddition - protected final int nextIndex() { - if (_expectedSize != _hash.size()) { - throw new ConcurrentModificationException(); - } - - Object[] set = _map._set; - int i = _index; - while (i-- > 0 && (set[i] == null || set[i] == TObjectHash.REMOVED)) ; - return i; - } - - /** - * Moves the iterator forward to the next entry in the underlying map. - * - * @exception java.util.NoSuchElementException if the iterator is already exhausted - */ - public void advance() { - moveToNextIndex(); - } - - /** - * Provides access to the key of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the key of the entry at the iterator's current position. - */ - public Object key() { - return _map._set[_index]; - } - - /** - * Provides access to the value of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the value of the entry at the iterator's current position. - */ - public double value() { - return _map._values[_index]; - } - - /** - * Replace the value of the mapping at the iterator's position with the - * specified value. Note that you must advance() the iterator at - * least once before invoking this method. - * - * @param val the value to set in the current entry - * @return the old value of the entry. - */ - public double setValue(double val) { - double old = value(); - _map._values[_index] = val; - return old; - } -}// TObjectDoubleIterator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TObjectDoubleProcedure.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TObjectDoubleProcedure.java deleted file mode 100644 index b14720ed0..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TObjectDoubleProcedure.java +++ /dev/null @@ -1,43 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Interface for procedures that take two parameters of type Object and double. - * - * Created: Mon Nov 5 22:03:30 2001 - * - * @author Eric D. Friedman - * @version $Id: TObjectDoubleProcedure.java,v 1.7 2002/09/22 21:53:42 ericdf Exp $ - */ - -public interface TObjectDoubleProcedure { - - /** - * Executes this procedure. A false return value indicates that - * the application executing this procedure should not invoke this - * procedure again. - * - * @param a an Object value - * @param b an double value - * @return true if additional invocations of the procedure are - * allowed. - */ - public boolean execute(Object a, double b); -}// TObjectDoubleProcedure diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TObjectFloatHashMap.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TObjectFloatHashMap.java deleted file mode 100644 index d9183c52a..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TObjectFloatHashMap.java +++ /dev/null @@ -1,516 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - -/** - * An open addressed Map implementation for Object keys and float values. - * - * Created: Sun Nov 4 08:52:45 2001 - * - * @author Eric D. Friedman - * @version $Id: TObjectFloatHashMap.java,v 1.13 2003/03/23 04:06:59 ericdf Exp $ - */ -public class TObjectFloatHashMap extends TObjectHash implements Serializable { - - private static final long serialVersionUID = 5492119167114151413L; - - /** the values of the map */ - protected transient float[] _values; - - /** - * Creates a new TObjectFloatHashMap instance with the default - * capacity and load factor. - */ - public TObjectFloatHashMap() { - super(); - } - - /** - * Creates a new TObjectFloatHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the default load factor. - * - * @param initialCapacity an int value - */ - public TObjectFloatHashMap(int initialCapacity) { - super(initialCapacity); - } - - /** - * Creates a new TObjectFloatHashMap instance with a prime - * capacity equal to or greater than initialCapacity and - * with the specified load factor. - * - * @param initialCapacity an int value - * @param loadFactor a float value - */ - public TObjectFloatHashMap(int initialCapacity, float loadFactor) { - super(initialCapacity, loadFactor); - } - - /** - * Creates a new TObjectFloatHashMap instance with the default - * capacity and load factor. - * @param strategy used to compute hash codes and to compare keys. - */ - public TObjectFloatHashMap(TObjectHashingStrategy strategy) { - super(strategy); - } - - /** - * Creates a new TObjectFloatHashMap instance whose capacity - * is the next highest prime above initialCapacity + 1 - * unless that value is already prime. - * - * @param initialCapacity an int value - * @param strategy used to compute hash codes and to compare keys. - */ - public TObjectFloatHashMap(int initialCapacity, TObjectHashingStrategy strategy) { - super(initialCapacity, strategy); - } - - /** - * Creates a new TObjectFloatHashMap instance with a prime - * value at or near the specified capacity and load factor. - * - * @param initialCapacity used to find a prime capacity for the table. - * @param loadFactor used to calculate the threshold over which - * rehashing takes place. - * @param strategy used to compute hash codes and to compare keys. - */ - public TObjectFloatHashMap(int initialCapacity, float loadFactor, TObjectHashingStrategy strategy) { - super(initialCapacity, loadFactor, strategy); - } - - /** - * @return an iterator over the entries in this map - */ - public TObjectFloatIterator iterator() { - return new TObjectFloatIterator(this); - } - - /** - * initializes the hashtable to a prime capacity which is at least - * initialCapacity + 1. - * - * @param initialCapacity an int value - * @return the actual capacity chosen - */ - @Override // GemStoneAddition - protected int setUp(int initialCapacity) { - int capacity; - - capacity = super.setUp(initialCapacity); - _values = new float[capacity]; - return capacity; - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an Object value - * @param value an float value - * @return the previous value associated with key, - * or null if none was found. - */ - public float put(Object key, float value) { - float previous = 0; - int index = insertionIndex(key); - boolean isNewMapping = true; - if (index < 0) { - index = -index -1; - previous = _values[index]; - isNewMapping = false; - } - Object oldKey = _set[index]; - _set[index] = key; - _values[index] = value; - - if (isNewMapping) { - postInsertHook(oldKey == null); - } - return previous; - } - - /** - * rehashes the map to the new capacity. - * - * @param newCapacity an int value - */ - @Override // GemStoneAddition - protected void rehash(int newCapacity) { - int oldCapacity = _set.length; - Object oldKeys[] = _set; - float oldVals[] = _values; - - _set = new Object[newCapacity]; - _values = new float[newCapacity]; - - for (int i = oldCapacity; i-- > 0;) { - if(oldKeys[i] != null && oldKeys[i] != REMOVED) { - Object o = oldKeys[i]; - int index = insertionIndex(o); - if (index < 0) { - throwObjectContractViolation(_set[(-index -1)], o); - } - _set[index] = o; - _values[index] = oldVals[i]; - } - } - } - - /** - * retrieves the value for key - * - * @param key an Object value - * @return the value of key or null if no such mapping exists. - */ - public float get(Object key) { - int index = index(key); - return index < 0 ? (float)0 : _values[index]; - } - - /** - * Empties the map. - * - */ - @Override // GemStoneAddition - public void clear() { - super.clear(); - Object[] keys = _set; - float[] vals = _values; - - for (int i = keys.length; i-- > 0;) { - keys[i] = null; - vals[i] = 0; - } - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an Object value - * @return an float value - */ - public float remove(Object key) { - float prev = 0; - int index = index(key); - if (index >= 0) { - prev = _values[index]; - removeAt(index); // clear key,state; adjust size - } - return prev; - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (! (other instanceof TObjectFloatHashMap)) { - return false; - } - TObjectFloatHashMap that = (TObjectFloatHashMap)other; - if (that.size() != this.size()) { - return false; - } - return forEachEntry(new EqProcedure(that)); - } - - /* - * (non-Javadoc) - * @see java.lang.Object#hashCode() - * - * Note that we just need to make sure that equal objects return equal - * hashcodes; nothing really elaborate is done here. - */ - @Override // GemStoneAddition - public int hashCode() { // GemStoneAddition - return 0; // TODO could make this more efficient :-) - } - - private static final class EqProcedure implements TObjectFloatProcedure { - private final TObjectFloatHashMap _otherMap; - - EqProcedure(TObjectFloatHashMap otherMap) { - _otherMap = otherMap; - } - - public final boolean execute(Object key, float value) { - int index = _otherMap.index(key); - if (index >= 0 && eq(value, _otherMap.get(key))) { - return true; - } - return false; - } - - /** - * Compare two floats for equality. - */ - private final boolean eq(float v1, float v2) { - return v1 == v2; - } - - } - - /** - * removes the mapping at index from the map. - * - * @param index an int value - */ - @Override // GemStoneAddition - protected void removeAt(int index) { - super.removeAt(index); // clear key, state; adjust size - _values[index] = 0; - } - - /** - * Returns the values of the map. - * - * @return a Collection value - */ - public float[] getValues() { - float[] vals = new float[size()]; - float[] v = _values; - Object[] keys = _set; - - for (int i = v.length, j = 0; i-- > 0;) { - if (keys[i] != null && keys[i] != REMOVED) { - vals[j++] = v[i]; - } - } - return vals; - } - - /** - * returns the keys of the map. - * - * @return a Set value - */ - public Object[] keys() { - Object[] keys = new Object[size()]; - Object[] k = _set; - - for (int i = k.length, j = 0; i-- > 0;) { - if (k[i] != null && k[i] != REMOVED) { - keys[j++] = k[i]; - } - } - return keys; - } - - /** - * checks for the presence of val in the values of the map. - * - * @param val an float value - * @return a boolean value - */ - public boolean containsValue(float val) { - Object[] keys = _set; - float[] vals = _values; - - for (int i = vals.length; i-- > 0;) { - if (keys[i] != null && keys[i] != REMOVED && val == vals[i]) { - return true; - } - } - return false; - } - - - /** - * checks for the present of key in the keys of the map. - * - * @param key an Object value - * @return a boolean value - */ - public boolean containsKey(Object key) { - return contains(key); - } - - /** - * Executes procedure for each key in the map. - * - * @param procedure a TObjectProcedure value - * @return false if the loop over the keys terminated because - * the procedure returned false for some key. - */ - public boolean forEachKey(TObjectProcedure procedure) { - return forEach(procedure); - } - - /** - * Executes procedure for each value in the map. - * - * @param procedure a TFloatProcedure value - * @return false if the loop over the values terminated because - * the procedure returned false for some value. - */ - public boolean forEachValue(TFloatProcedure procedure) { - Object[] keys = _set; - float[] values = _values; - for (int i = values.length; i-- > 0;) { - if (keys[i] != null && keys[i] != REMOVED - && ! procedure.execute(values[i])) { - return false; - } - } - return true; - } - - /** - * Executes procedure for each key/value entry in the - * map. - * - * @param procedure a TOObjectFloatProcedure value - * @return false if the loop over the entries terminated because - * the procedure returned false for some entry. - */ - public boolean forEachEntry(TObjectFloatProcedure procedure) { - Object[] keys = _set; - float[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (keys[i] != null - && keys[i] != REMOVED - && ! procedure.execute(keys[i],values[i])) { - return false; - } - } - return true; - } - - /** - * Retains only those entries in the map for which the procedure - * returns a true value. - * - * @param procedure determines which entries to keep - * @return true if the map was modified. - */ - public boolean retainEntries(TObjectFloatProcedure procedure) { - boolean modified = false; - Object[] keys = _set; - float[] values = _values; - for (int i = keys.length; i-- > 0;) { - if (keys[i] != null - && keys[i] != REMOVED - && ! procedure.execute(keys[i],values[i])) { - removeAt(i); - modified = true; - } - } - return modified; - } - - /** - * Transform the values in this map using function. - * - * @param function a TFloatFunction value - */ - public void transformValues(TFloatFunction function) { - Object[] keys = _set; - float[] values = _values; - for (int i = values.length; i-- > 0;) { - if (keys[i] != null && keys[i] != REMOVED) { - values[i] = function.execute(values[i]); - } - } - } - - /** - * Increments the primitive value mapped to key by 1 - * - * @param key the key of the value to increment - * @return true if a mapping was found and modified. - */ - public boolean increment(Object key) { - return adjustValue(key, 1); - } - - /** - * Adjusts the primitive value mapped to key. - * - * @param key the key of the value to increment - * @param amount the amount to adjust the value by. - * @return true if a mapping was found and modified. - */ - public boolean adjustValue(Object key, float amount) { - int index = index(key); - if (index < 0) { - return false; - } else { - _values[index] += amount; - return true; - } - } - - - private void writeObject(ObjectOutputStream stream) - throws IOException { - stream.defaultWriteObject(); - - // number of entries - stream.writeInt(_size); - - SerializationProcedure writeProcedure = new SerializationProcedure(stream); - if (! forEachEntry(writeProcedure)) { - throw writeProcedure.exception; - } - } - - private void readObject(ObjectInputStream stream) - throws IOException, ClassNotFoundException { - stream.defaultReadObject(); - - int size = stream.readInt(); - setUp(size); - while (size-- > 0) { - Object key = stream.readObject(); - float val = stream.readFloat(); - put(key, val); - } - } -} // TObjectFloatHashMap diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TObjectFloatIterator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TObjectFloatIterator.java deleted file mode 100644 index d08bc7974..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TObjectFloatIterator.java +++ /dev/null @@ -1,160 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -import java.util.ConcurrentModificationException; - -/** - * Iterator for maps of type Object and float. - * - *

The iterator semantics for Trove's primitive maps is slightly different - * from those defined in java.util.Iterator, but still well within - * the scope of the pattern, as defined by Gamma, et al.

- * - *

This iterator does not implicitly advance to the next entry when - * the value at the current position is retrieved. Rather, you must explicitly - * ask the iterator to advance() and then retrieve either the key(), - * the value() or both. This is done so that you have the option, but not - * the obligation, to retrieve keys and/or values as your application requires, and - * without introducing wrapper objects that would carry both. As the iteration is - * stateful, access to the key/value parts of the current map entry happens in - * constant time.

- * - *

In practice, the iterator is akin to a "search finger" that you move from - * position to position. Read or write operations affect the current entry only and - * do not assume responsibility for moving the finger.

- * - *

Here are some sample scenarios for this class of iterator:

- * - *
- * // accessing keys/values through an iterator:
- * for (TObjectFloatIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     doSomethingWithValue(it.value());
- *   }
- * }
- * 
- * - *
- * // modifying values in-place through iteration:
- * for (TObjectFloatIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.setValue(newValueForKey(it.key()));
- *   }
- * }
- * 
- * - *
- * // deleting entries during iteration:
- * for (TObjectFloatIterator it = map.iterator();
- *      it.hasNext();) {
- *   it.forward();
- *   if (satisfiesCondition(it.key()) {
- *     it.remove();
- *   }
- * }
- * 
- * - *
- * // faster iteration by avoiding hasNext():
- * TObjectFloatIterator iterator = map.iterator();
- * for (int i = map.size(); i-- > 0;) {
- *   iterator.advance();
- *   doSomethingWithKeyAndValue(iterator.key(), iterator.value());
- * }
- * 
- * - * @author Eric D. Friedman - * @version $Id: TObjectFloatIterator.java,v 1.1 2002/09/22 21:53:42 ericdf Exp $ - */ - -public class TObjectFloatIterator extends TIterator { - private final TObjectFloatHashMap _map; - - public TObjectFloatIterator(TObjectFloatHashMap map) { - super(map); - this._map = map; - } - - /** - * Returns the index of the next value in the data structure - * or a negative value if the iterator is exhausted. - * - * @return an int value - */ - protected final int nextIndex() { - if (_expectedSize != _hash.size()) { - throw new ConcurrentModificationException(); - } - - Object[] set = _map._set; - int i = _index; - while (i-- > 0 && (set[i] == null || set[i] == TObjectHash.REMOVED)) ; - return i; - } - - /** - * Moves the iterator forward to the next entry in the underlying map. - * - * @exception java.util.NoSuchElementException if the iterator is already exhausted - */ - public void advance() { - moveToNextIndex(); - } - - /** - * Provides access to the key of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the key of the entry at the iterator's current position. - */ - public Object key() { - return _map._set[_index]; - } - - /** - * Provides access to the value of the mapping at the iterator's position. - * Note that you must advance() the iterator at least once - * before invoking this method. - * - * @return the value of the entry at the iterator's current position. - */ - public float value() { - return _map._values[_index]; - } - - /** - * Replace the value of the mapping at the iterator's position with the - * specified value. Note that you must advance() the iterator at - * least once before invoking this method. - * - * @param val the value to set in the current entry - * @return the old value of the entry. - */ - public float setValue(float val) { - float old = value(); - _map._values[_index] = val; - return old; - } -}// TObjectFloatIterator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TObjectFloatProcedure.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TObjectFloatProcedure.java deleted file mode 100644 index aff9d2822..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/TObjectFloatProcedure.java +++ /dev/null @@ -1,43 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove; - -/** - * Interface for procedures that take two parameters of type Object and float. - * - * Created: Mon Nov 5 22:03:30 2001 - * - * @author Eric D. Friedman - * @version $Id: TObjectFloatProcedure.java,v 1.7 2002/09/22 21:53:42 ericdf Exp $ - */ - -public interface TObjectFloatProcedure { - - /** - * Executes this procedure. A false return value indicates that - * the application executing this procedure should not invoke this - * procedure again. - * - * @param a an Object value - * @param b an float value - * @return true if additional invocations of the procedure are - * allowed. - */ - public boolean execute(Object a, float b); -}// TObjectFloatProcedure diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/benchmark/Main.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/benchmark/Main.java deleted file mode 100644 index 26cdbb0a8..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/benchmark/Main.java +++ /dev/null @@ -1,411 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.benchmark; - -import com.gemstone.gnu.trove.*; -import java.util.*; - -/** - * - * Created: Sat Nov 3 18:17:56 2001 - * - * @author Eric D. Friedman - * @version $Id: Main.java,v 1.2 2001/12/28 20:04:39 ericdf Exp $ - */ - -public class Main { - - static final int SET_SIZE = 100000; - static final List dataset = new ArrayList(SET_SIZE); - static { - for (int i = 0; i < SET_SIZE; i++) { - dataset.add(Integer.valueOf(i)); - } - } - - public static Operation getSetOperation() { - - return new Operation() { - public void theirs() { - Set s = new HashSet(SET_SIZE); - for (Iterator i = dataset.iterator(); i.hasNext();) { - s.add(i.next()); - } - } - - public void ours() { - Set s = new THashSet(SET_SIZE); - for (Iterator i = dataset.iterator(); i.hasNext();) { - s.add(i.next()); - } - } - - @Override // GemStoneAddition - public String toString() { - return "compares " + dataset.size() + " Set.add() operations"; - } - - public int getIterationCount() { - return 10; - } - }; - } - - public static Operation getLinkedListAddOp() { - - final List data = new ArrayList(100000); - for (int i = 0; i < 100000; i++) { - data.add(new TLinkableAdaptor()); - } - - - return new Operation() { - - public void theirs() { - List l = new LinkedList(); - for (Iterator i = data.iterator(); i.hasNext();) { - l.add(i.next()); - } - } - - public void ours() { - List l = new TLinkedList(); - for (Iterator i = data.iterator(); i.hasNext();) { - l.add(i.next()); - } - } - - @Override // GemStoneAddition - public String toString() { - return "compares " + dataset.size() + " LinkedList.add() operations"; - } - - public int getIterationCount() { - return 10; - } - }; - } - - static Operation getContainsOp() { - final Set theirs = new HashSet(dataset.size()); - theirs.addAll(dataset); - final Set ours = new THashSet(dataset.size()); - ours.addAll(dataset); - - return new Operation() { - public void theirs() { - for (int i = 0; i < dataset.size(); i += 5) { - theirs.contains(dataset.get(i)); - } - } - - public void ours() { - for (int i = 0; i < dataset.size(); i += 5) { - ours.contains(dataset.get(i)); - } - } - - @Override // GemStoneAddition - public String toString() { - return "compares " + dataset.size() / 5 + " Set.contains() operations"; - } - - public int getIterationCount() { - return 10; - } - }; - } - - static Operation getRandomSetContainsOp() { - final Set theirs = new HashSet(SET_SIZE); - final Set ours = new THashSet(SET_SIZE); - Random rand = new Random(9999L); - - for (int i = 0; i < SET_SIZE; i++) { - Integer x = Integer.valueOf(rand.nextInt()); - theirs.add(x); - ours.add(x); - } - -// Random rand2 = new Random(9998L); - final List query = new ArrayList(SET_SIZE); - int match = 0; - for (int i = 0; i < SET_SIZE; i++) { - Integer x = Integer.valueOf(rand.nextInt()); - query.add(x); - if (theirs.contains(x)) { - match++; - } - } - - final int success = match; - - return new Operation() { - public void theirs() { - for (Iterator i = query.iterator(); i.hasNext();) { - theirs.contains(i.next()); - } - } - - public void ours() { - for (Iterator i = query.iterator(); i.hasNext();) { - ours.contains(i.next()); - } - } - - @Override // GemStoneAddition - public String toString() { - return "compares " + SET_SIZE + " Set.contains() operations. " - + success + " are actually present in set"; - } - - public int getIterationCount() { - return 10; - } - }; - } - - static Operation getMapPutOp() { - return new Operation() { - public void theirs() { - Map theirs = new HashMap(dataset.size()); - for (Iterator i = dataset.iterator();i.hasNext();) { - Object o = i.next(); - theirs.put(o,o); - } - } - - public void ours() { - Map ours = new THashMap(dataset.size()); - for (Iterator i = dataset.iterator();i.hasNext();) { - Object o = i.next(); - ours.put(o,o); - } - } - - @Override // GemStoneAddition - public String toString() { - return "compares " + dataset.size() + " Map.put() operations"; - } - - public int getIterationCount() { - return 10; - } - }; - } - - static Operation getIterationOp() { - final Map theirMap = new HashMap(dataset.size()); - final Map ourMap = new THashMap(dataset.size()); - for (Iterator i = dataset.iterator();i.hasNext();) { - Object o = i.next(); - theirMap.put(o,o); - ourMap.put(o,o); - } - - return new Operation() { - public void theirs() { - Map m = theirMap; - Iterator i = m.keySet().iterator(); - for (int size = m.size(); size-- > 0;) { - /*Object o = GemStoneAddition*/ i.next(); - } - } - - public void ours() { - Map m = ourMap; - Iterator i = m.keySet().iterator(); - for (int size = m.size(); size-- > 0;) { - /*Object o = GemStoneAddition*/i.next(); - } - } - - @Override // GemStoneAddition - public String toString() { - return "compares Iterator.next() over " + dataset.size() + " map keys"; - } - - public int getIterationCount() { - return 10; - } - }; - } - - static Operation getIterationWithHasNextOp() { - final Map theirMap = new HashMap(dataset.size()); - final Map ourMap = new THashMap(dataset.size()); - for (Iterator i = dataset.iterator();i.hasNext();) { - Object o = i.next(); - theirMap.put(o,o); - ourMap.put(o,o); - } - - return new Operation() { - public void theirs() { - Map m = theirMap; - Iterator i = m.keySet().iterator(); - while (i.hasNext()) { - /*Object o = GemStoneAddition*/ i.next(); - } - } - - public void ours() { - Map m = ourMap; - Iterator i = m.keySet().iterator(); - while (i.hasNext()) { - /*Object o = GemStoneAddition*/i.next(); - } - } - - @Override // GemStoneAddition - public String toString() { - return "compares Iterator.hasNext()/ Iterator.next() over " + theirMap.size() + " keys"; - } - - public int getIterationCount() { - return 10; - } - }; - } - - static Operation getIntMapPut() { - return new Operation() { - public void theirs() { - } - - public void ours() { - TIntIntHashMap ours = new TIntIntHashMap(SET_SIZE); - for (int i = dataset.size(); i-- > 0;) { - ours.put(i,i); - } - } - - @Override // GemStoneAddition - public String toString() { - return dataset.size() + " entry primitive int map.put timing run; no basis for comparison"; - } - - public int getIterationCount() { - return 10; - } - }; - } - - static Operation getSumSetOperation() { - final Set theirSet = new HashSet(dataset.size()); - final THashSet ourSet = new THashSet(dataset.size()); - theirSet.addAll(dataset); - ourSet.addAll(dataset); - final TObjectProcedure proc = new TObjectProcedure() { - int sum = 0; - public boolean execute(Object o) { - sum += ((Integer)o).intValue(); - return true; - } - }; - return new Operation() { - public void theirs() { - int sum = 0; - for (Iterator i = theirSet.iterator(); i.hasNext();) { - sum += ((Integer)i.next()).intValue(); - } - } - - public void ours() { - ourSet.forEach(proc); - } - - @Override // GemStoneAddition - public String toString() { - return "sums a " + theirSet.size() + " element Set of Integer objects. Their approach uses Iterator.hasNext()/next(); ours uses THashSet.forEach(TObjectProcedure)"; - } - - public int getIterationCount() { - return 10; - } - }; - } - - - public static void main (String[] args) { - Operation op; - Timer t; - Reporter reporter; - - reporter = new TextReporter(); - reporter.start(); - - op = getRandomSetContainsOp(); // 10 times - t = new Repeater(op); - reporter.report(t.run()); - - op = getSumSetOperation(); // 10 times - t = new Repeater(op); - reporter.report(t.run()); - - op = getIterationWithHasNextOp(); // 10 times - t = new Repeater(op); - reporter.report(t.run()); - - op = getIterationOp(); // 10 times - t = new Repeater(op); - reporter.report(t.run()); - - op = getLinkedListAddOp(); // 10 times - t = new Repeater(op); - reporter.report(t.run()); - - op = getIntMapPut(); // 10 times - t = new Repeater(op); - reporter.report(t.run()); - - op = getMapPutOp(); // 10 times - t = new Repeater(op); - reporter.report(t.run()); - - op = getContainsOp(); // 10 times - t = new Repeater(op); - reporter.report(t.run()); - - op = getSetOperation(); // 10 times - t = new Repeater(op); - reporter.report(t.run()); - - reporter.finish(); - } -} // Main diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/benchmark/MemoryUsage.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/benchmark/MemoryUsage.java deleted file mode 100644 index b163f6b3b..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/benchmark/MemoryUsage.java +++ /dev/null @@ -1,238 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.benchmark; - -import java.util.*; -import com.gemstone.gnu.trove.*; - -public class MemoryUsage { - public static long sizeOf(Creator c) { - long size= 0; - Object[] objects = new Object[100]; - try { - /* Object primer = GemStoneAddition */ c.create(); - long startingMemoryUse = getUsedMemory(); - for (int i = 0; i < objects.length; i++) { - objects[i] = c.create(); - } - long endingMemoryUse = getUsedMemory(); - float approxSize = (endingMemoryUse - - startingMemoryUse) / 100f; - size = Math.round(approxSize); - } catch (Exception e) { - e.printStackTrace(); - } - return size; - } - - private static long getUsedMemory() { - gc(); - long totalMemory = Runtime.getRuntime().totalMemory(); - gc(); - long freeMemory = Runtime.getRuntime().freeMemory(); - long usedMemory = totalMemory - freeMemory; - return usedMemory; - } - - protected static void gc() { - try { - System.gc(); - Thread.sleep(100); - System.runFinalization(); - Thread.sleep(100); - System.gc(); - Thread.sleep(100); - System.runFinalization(); - Thread.sleep(100); - } catch (Exception e) { - e.printStackTrace(); - } - } - - public static void main(String[] args) { - try { - MemoryComparator set = - new MemoryComparator(new TroveSetCreator(), - new JavasoftSetCreator(), - "Compare size of Set implementation: 1,000 Integer objects measured in bytes"); - set.compare(); - set = null; - MemoryComparator list = - new MemoryComparator(new TroveListCreator(), - new JavasoftListCreator(), - "Compare size of LinkedList implementation: 1,000 TLinkableAdaptor objects measured in bytes"); - list.compare(); - list = null; - MemoryComparator list2 = - new MemoryComparator(new TroveIntArrayListCreator(), - new JavasoftIntegerArrayListCreator(), - "Compare size of int/IntegerArrayList implementation: 1,000 ints measured in bytes"); - list2.compare(); - list2 = null; - - MemoryComparator map = - new MemoryComparator(new TroveMapCreator(), - new JavasoftMapCreator(), - "Compare size of Map implementation: 1,000 Integer->Integer mappings measured in bytes"); - map.compare(); - } catch (Exception e) { - e.printStackTrace(); - } - System.exit(0); - } - - static class MemoryComparator { - Creator trove, javasoft; - String description; - MemoryComparator(Creator trove, - Creator javasoft, - String description) { - this.trove = trove; - this.javasoft = javasoft; - this.description = description; - } - - public void compare() { - gc(); - long j = sizeOf(javasoft); - gc(); - long t = sizeOf(trove); - - long p = Math.round((double)/*GemStoneAddition*/t * 100 / j * 100) / 100; - - System.out.println("--------------------------"); - System.out.println(description); - System.out.println("javasoft: " + j); - System.out.println("trove: " + t); - System.out.println("trove's collection requires " + p + "% of the memory needed by javasoft's collection"); - } - } - - interface Creator { - Object create(); - } - - static class TroveIntArrayListCreator implements Creator { - public Object create() { - TIntArrayList list = new TIntArrayList(); - for (int i = 0; i < 1000; i++) { - list.add(i); - } - list.trimToSize(); - return list; - } - } - - static class JavasoftIntegerArrayListCreator implements Creator { - public Object create() { - ArrayList list = new ArrayList(); - for (int i = 0; i < 1000; i++) { - Integer x = Integer.valueOf(i); - list.add(x); - } - list.trimToSize(); - return list; - } - } - - static class TroveMapCreator implements Creator { - public Object create() { - THashMap map = new THashMap(); - for (int i = 0; i < 1000; i++) { - Integer x = Integer.valueOf(i); - map.put(x,x); - } - return map; - } - } - - static class JavasoftMapCreator implements Creator { - public Object create() { - HashMap map = new HashMap(); - for (int i = 0; i < 1000; i++) { - Integer x = Integer.valueOf(i); - map.put(x,x); - } - return map; - } - } - - static class TroveSetCreator implements Creator { - public Object create() { - THashSet map = new THashSet(); - for (int i = 0; i < 1000; i++) { - Integer x = Integer.valueOf(i); - map.add(x); - } - return map; - } - } - - static class JavasoftSetCreator implements Creator { - public Object create() { - HashSet map = new HashSet(); - for (int i = 0; i < 1000; i++) { - Integer x = Integer.valueOf(i); - map.add(x); - } - return map; - } - } - - static class TroveListCreator implements Creator { - public Object create() { - TLinkedList list = new TLinkedList(); - for (int i = 0; i < 1000; i++) { - TLinkableAdaptor a = new TLinkableAdaptor(); - list.add(a); - } - return list; - } - } - - static class JavasoftListCreator implements Creator { - public Object create() { - LinkedList list = new LinkedList(); - for (int i = 0; i < 1000; i++) { - TLinkableAdaptor a = new TLinkableAdaptor(); - list.add(a); - } - return list; - } - } -} diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/benchmark/Operation.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/benchmark/Operation.java deleted file mode 100644 index 6ddc916ca..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/benchmark/Operation.java +++ /dev/null @@ -1,25 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove.benchmark; - -public interface Operation { - public void theirs(); - public void ours(); - public int getIterationCount(); -} diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/benchmark/Repeater.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/benchmark/Repeater.java deleted file mode 100644 index f837cb851..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/benchmark/Repeater.java +++ /dev/null @@ -1,62 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove.benchmark; - -class Repeater implements Timer { - int _count; - Operation _operation; - - Repeater(Operation o) { - _count = o.getIterationCount(); - _operation = o; - } - - public Result run() { - long theirs = theirs(); - long ours = ours(); - Result r = new Result(); - r.setTheirs(theirs); - r.setOurs(ours); - r.setIterations(_count); - r.setDescription(_operation.toString()); - return r; - } - - public long theirs() { - long then = System.currentTimeMillis(); - for (int i = 0; i < _count; i++) { - _operation.theirs(); - } - long now = System.currentTimeMillis(); - return (now -then); - } - - public long ours() { - long then = System.currentTimeMillis(); - for (int i = 0; i < _count; i++) { - _operation.ours(); - } - long now = System.currentTimeMillis(); - return (now -then); - } - - public Operation getOperation() { - return _operation; - } -} diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/benchmark/Reporter.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/benchmark/Reporter.java deleted file mode 100644 index ac7fc5888..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/benchmark/Reporter.java +++ /dev/null @@ -1,32 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove.benchmark; - -interface Reporter { - void report(Result result); - void start(); - void finish(); - public static final String[] ENV_PROPS = { - "java.vm.name", - "java.runtime.version", - "os.name", - "os.arch", - "os.version" - }; -} diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/benchmark/Result.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/benchmark/Result.java deleted file mode 100644 index 7b50c39e1..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/benchmark/Result.java +++ /dev/null @@ -1,134 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove.benchmark; - -/** - * - * Created: Thu Nov 22 20:47:16 2001 - * - * @author Eric D. Friedman - * @version $Id: Result.java,v 1.1 2001/11/23 20:33:15 ericdf Exp $ - */ -class Result { - long theirs; - long ours; - int iterations; - String description; - - /** - * Gets the value of theirs - * - * @return the value of theirs - */ - public long getTheirs() { - return this.theirs; - } - - /** - * Sets the value of theirs - * - * @param argTheirs Value to assign to this.theirs - */ - public void setTheirs(long argTheirs){ - this.theirs = argTheirs; - } - - /** - * Gets the value of ours - * - * @return the value of ours - */ - public long getOurs() { - return this.ours; - } - - /** - * Sets the value of ours - * - * @param argOurs Value to assign to this.ours - */ - public void setOurs(long argOurs){ - this.ours = argOurs; - } - - /** - * Gets the value of theirAvg - * - * @return the value of theirAvg - */ - public long getTheirAvg() { - return theirs / iterations; - } - - /** - * Gets the value of ourAvg - * - * @return the value of ourAvg - */ - public long getOurAvg() { - return ours / iterations; - } - - /** - * Gets the value of iterations - * - * @return the value of iterations - */ - public int getIterations() { - return this.iterations; - } - - /** - * Sets the value of iterations - * - * @param argIterations Value to assign to this.iterations - */ - public void setIterations(int argIterations){ - this.iterations = argIterations; - } - - /** - * Gets the value of description - * - * @return the value of description - */ - public String getDescription() { - return this.description; - } - - /** - * Sets the value of description - * - * @param argDescription Value to assign to this.description - */ - public void setDescription(String argDescription){ - this.description = argDescription; - } - - public String toString() { - StringBuffer b = new StringBuffer(); - b.append(getDescription() + "\n"); - b.append("Iterations: " + getIterations() + "\n"); - b.append("Their total (msec): " + getTheirs() + "\n"); - b.append("Our total (msec): " + getOurs() + "\n"); - b.append("Their average (msec): " + getTheirAvg() + "\n"); - b.append("Our average (msec): " + getOurAvg() + "\n"); - return b.toString(); - } -} diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/benchmark/TextReporter.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/benchmark/TextReporter.java deleted file mode 100644 index d064824b9..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/benchmark/TextReporter.java +++ /dev/null @@ -1,53 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove.benchmark; - -import java.io.*; - -class TextReporter implements Reporter { - PrintWriter out; - - TextReporter() { - this(new PrintWriter(new OutputStreamWriter(System.out),true)); - } - - TextReporter(PrintWriter out) { - this.out = out; - } - - public void report(Result result) { - out.print(result); - out.println("--------------------------------"); - } - - public void start() { - out.println("--------------------------------"); - out.println("GNU Trove Benchmark suite"); - out.println("--------------------------------"); - for (int i = 0; i < ENV_PROPS.length; i++) { - String key = ENV_PROPS[i]; - out.println(key + "=" + System.getProperty(key)); - } - out.println("--------------------------------"); - } - - public void finish() { - out.println("done"); - } -} diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/benchmark/Timer.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/benchmark/Timer.java deleted file mode 100644 index a49f2b1b1..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/benchmark/Timer.java +++ /dev/null @@ -1,26 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove.benchmark; - -public interface Timer { - public Operation getOperation(); - public long theirs(); - public long ours(); - public Result run(); -} diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/benchmark/XMLReporter.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/benchmark/XMLReporter.java deleted file mode 100644 index 5bcc64702..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/benchmark/XMLReporter.java +++ /dev/null @@ -1,87 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2001, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// - -package com.gemstone.gnu.trove.benchmark; - -import java.io.*; - -/** - * - * Created: Thu Nov 22 20:49:24 2001 - * - * @author Eric D. Friedman - * @version $Id: XMLReporter.java,v 1.1 2001/11/23 20:33:15 ericdf Exp $ - */ - -class XMLReporter implements Reporter { - PrintWriter out; - - XMLReporter() { - this.out = new PrintWriter(new OutputStreamWriter(System.out), - true); - } - - XMLReporter(PrintWriter out) { - this.out = out; - } - - public void report(Result result) { - out.println(""); - out.print(""); - out.print(result.getDescription()); - out.println(""); - - out.print(""); - out.print(result.getIterations()); - out.println(""); - - out.print(""); - out.print(result.getTheirs()); - out.println(""); - - out.print(""); - out.print(result.getTheirAvg()); - out.println(""); - - out.print(""); - out.print(result.getOurs()); - out.println(""); - - out.print(""); - out.print(result.getOurAvg()); - out.println(""); - - out.println(""); - } - - public void start() { - out.println(""); - out.println(""); - out.print(""); - for (int i = 0; i < ENV_PROPS.length; i++) { - String key = ENV_PROPS[i]; - out.print(System.getProperty(key)); - out.print(" "); - } - out.println(""); - } - - public void finish() { - out.println(""); - } -} diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TDoubleDoubleHashMapDecorator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TDoubleDoubleHashMapDecorator.java deleted file mode 100644 index 78646f107..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TDoubleDoubleHashMapDecorator.java +++ /dev/null @@ -1,383 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.decorator; - -import com.gemstone.gnu.trove.TDoubleDoubleHashMap; -import com.gemstone.gnu.trove.TDoubleDoubleIterator; -import java.util.AbstractMap; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -//import java.util.Map.Entry; -import java.util.Map; -import java.util.Set; - -/** - * Wrapper class to make a TDoubleDoubleHashMap conform to the java.util.Map API. - * This class simply decorates an underlying TDoubleDoubleHashMap and translates the Object-based - * APIs into their Trove primitive analogs. - * - *

- * Note that wrapping and unwrapping primitive values is extremely inefficient. If - * possible, users of this class should override the appropriate methods in this class - * and use a table of canonical values. - *

- * - * Created: Mon Sep 23 22:07:40 PDT 2002 - * - * @author Eric D. Friedman - * @version $Id: TDoubleDoubleHashMapDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $ - * @since trove 0.1.8 - */ -public class TDoubleDoubleHashMapDecorator extends AbstractMap implements Map, Cloneable { - /** the wrapped primitive map */ - protected TDoubleDoubleHashMap _map; - - /** - * Creates a wrapper that decorates the specified primitive map. - */ - public TDoubleDoubleHashMapDecorator(TDoubleDoubleHashMap map) { - super(); - this._map = map; - } - - /** - * Clones the underlying trove collection and returns the clone wrapped in a new - * decorator instance. This is a shallow clone except where primitives are - * concerned. - * - * @return a copy of the receiver - */ - @Override // GemStoneAddition - public Object clone() { - try { - TDoubleDoubleHashMapDecorator copy = (TDoubleDoubleHashMapDecorator) super.clone(); - copy._map = (TDoubleDoubleHashMap)_map.clone(); - return copy; - } catch (CloneNotSupportedException e) { - // assert(false); - throw new InternalError(); // we are cloneable, so this does not happen - } - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an Object value - * @param value an Object value - * @return the previous value associated with key, - * or Integer(0) if none was found. - */ - @Override // GemStoneAddition - public Object put(Object key, Object value) { - return wrapValue(_map.put(unwrapKey(key), unwrapValue(value))); - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return true if the maps are identical - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (_map.equals(other)) { - return true; // comparing two trove maps - } else if (other instanceof Map) { - Map that = (Map)other; - if (that.size() != _map.size()) { - return false; // different sizes, no need to compare - } else { // now we have to do it the hard way - Iterator it = that.entrySet().iterator(); - for (int i = that.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - Object key = e.getKey(); - Object val = e.getValue(); - if (key instanceof Double && val instanceof Double) { - double k = unwrapKey(key); - double v = unwrapValue(val); - if (_map.containsKey(k) && v == _map.get(k)) { - // match, ok to continue - } else { - return false; // no match: we're done - } - } else { - return false; // different type in other map - } - } - return true; // all entries match - } - } else { - return false; - } - } - - /** - * Retrieves the value for key - * - * @param key an Object value - * @return the value of key or null if no such mapping exists. - */ - @Override // GemStoneAddition - public Object get(Object key) { - double k = unwrapKey(key); - double v = _map.get(k); - // 0 may be a false positive since primitive maps - // cannot return null, so we have to do an extra - // check here. - if (v == 0) { - return _map.containsKey(k) ? wrapValue(v) : null; - } else { - return wrapValue(v); - } - } - - - /** - * Empties the map. - */ - @Override // GemStoneAddition - public void clear() { - this._map.clear(); - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an Object value - * @return the removed value, or Integer(0) if it was not found in the map - */ - @Override // GemStoneAddition - public Object remove(Object key) { - return wrapValue(_map.remove(unwrapKey(key))); - } - - /** - * Returns a Set view on the entries of the map. - * - * @return a Set value - */ - @Override // GemStoneAddition - public Set entrySet() { - return new AbstractSet() { - @Override // GemStoneAddition - public int size() { - return _map.size(); - } - @Override // GemStoneAddition - public boolean isEmpty() { - return TDoubleDoubleHashMapDecorator.this.isEmpty(); - } - @Override // GemStoneAddition - public boolean contains(Object o) { - if (o instanceof Map.Entry) { - Object k = ((Map.Entry)o).getKey(); - Object v = ((Map.Entry)o).getValue(); - return (TDoubleDoubleHashMapDecorator.this.containsKey(k) && - TDoubleDoubleHashMapDecorator.this.get(k).equals(v)); - } else { - return false; - } - } - @Override // GemStoneAddition - public Iterator iterator() { - return new Iterator() { - private final TDoubleDoubleIterator it = _map.iterator(); - - public Object next() { - it.advance(); - final Object key = wrapKey(it.key()); - final Object v = wrapValue(it.value()); - return new Map.Entry() { - private Object val = v; - @Override // GemStoneAddition - public boolean equals(Object o) { - return ((o instanceof Map.Entry) && - ((Map.Entry)o).getKey().equals(key) && - ((Map.Entry)o).getValue().equals(val)); - } - public Object getKey() { - return key; - } - public Object getValue() { - return val; - } - @Override // GemStoneAddition - public int hashCode() { - return key.hashCode() + val.hashCode(); - } - public Object setValue(Object value) { - val = value; - return put(key, value); - } - }; - } - - public boolean hasNext() { - return it.hasNext(); - } - - public void remove() { - it.remove(); - } - }; - } - @Override // GemStoneAddition - public boolean add(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean addAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean retainAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean removeAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public void clear() { - TDoubleDoubleHashMapDecorator.this.clear(); - } - }; - } - - /** - * Checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsValue(Object val) { - return _map.containsValue(unwrapValue(val)); - } - - /** - * Checks for the present of key in the keys of the map. - * - * @param key an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsKey(Object key) { - return _map.containsKey(unwrapKey(key)); - } - - /** - * Returns the number of entries in the map. - * @return the map's size. - */ - @Override // GemStoneAddition - public int size() { - return this._map.size(); - } - - /** - * Indicates whether map has any entries. - * @return true if the map is empty - */ - @Override // GemStoneAddition - public boolean isEmpty() { - return (size() == 0); - } - - /** - * Copies the key/value mappings in map into this map. - * Note that this will be a deep copy, as storage is by - * primitive value. - * - * @param map a Map value - */ - @Override // GemStoneAddition - public void putAll(Map map) { - Iterator it = map.entrySet().iterator(); - for (int i = map.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - this.put(e.getKey(), e.getValue()); - } - } - - /** - * Wraps a key - * - * @param k a key in the underlying map - * @return an Object representation of the key - */ - protected Double wrapKey(double k) { - return Double.valueOf(k); - } - - /** - * Unwraps a key - * - * @param key a wrapped key - * @return an unwrapped representation of the key - */ - protected double unwrapKey(Object key) { - return ((Double)key).doubleValue(); - } - /** - * Wraps a value - * - * @param k a value in the underlying map - * @return an Object representation of the value - */ - protected Double wrapValue(double k) { - return Double.valueOf(k); - } - - /** - * Unwraps a value - * - * @param value a wrapped value - * @return an unwrapped representation of the value - */ - protected double unwrapValue(Object value) { - return ((Double)value).doubleValue(); - } - -} // TDoubleDoubleHashMapDecorator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TDoubleFloatHashMapDecorator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TDoubleFloatHashMapDecorator.java deleted file mode 100644 index 342f0b2d9..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TDoubleFloatHashMapDecorator.java +++ /dev/null @@ -1,383 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.decorator; - -import com.gemstone.gnu.trove.TDoubleFloatHashMap; -import com.gemstone.gnu.trove.TDoubleFloatIterator; -import java.util.AbstractMap; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -//import java.util.Map.Entry; -import java.util.Map; -import java.util.Set; - -/** - * Wrapper class to make a TDoubleFloatHashMap conform to the java.util.Map API. - * This class simply decorates an underlying TDoubleFloatHashMap and translates the Object-based - * APIs into their Trove primitive analogs. - * - *

- * Note that wrapping and unwrapping primitive values is extremely inefficient. If - * possible, users of this class should override the appropriate methods in this class - * and use a table of canonical values. - *

- * - * Created: Mon Sep 23 22:07:40 PDT 2002 - * - * @author Eric D. Friedman - * @version $Id: TDoubleFloatHashMapDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $ - * @since trove 0.1.8 - */ -public class TDoubleFloatHashMapDecorator extends AbstractMap implements Map, Cloneable { - /** the wrapped primitive map */ - protected TDoubleFloatHashMap _map; - - /** - * Creates a wrapper that decorates the specified primitive map. - */ - public TDoubleFloatHashMapDecorator(TDoubleFloatHashMap map) { - super(); - this._map = map; - } - - /** - * Clones the underlying trove collection and returns the clone wrapped in a new - * decorator instance. This is a shallow clone except where primitives are - * concerned. - * - * @return a copy of the receiver - */ - @Override // GemStoneAddition - public Object clone() { - try { - TDoubleFloatHashMapDecorator copy = (TDoubleFloatHashMapDecorator) super.clone(); - copy._map = (TDoubleFloatHashMap)_map.clone(); - return copy; - } catch (CloneNotSupportedException e) { - // assert(false); - throw new InternalError(); // we are cloneable, so this does not happen - } - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an Object value - * @param value an Object value - * @return the previous value associated with key, - * or Integer(0) if none was found. - */ - @Override // GemStoneAddition - public Object put(Object key, Object value) { - return wrapValue(_map.put(unwrapKey(key), unwrapValue(value))); - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return true if the maps are identical - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (_map.equals(other)) { - return true; // comparing two trove maps - } else if (other instanceof Map) { - Map that = (Map)other; - if (that.size() != _map.size()) { - return false; // different sizes, no need to compare - } else { // now we have to do it the hard way - Iterator it = that.entrySet().iterator(); - for (int i = that.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - Object key = e.getKey(); - Object val = e.getValue(); - if (key instanceof Double && val instanceof Float) { - double k = unwrapKey(key); - float v = unwrapValue(val); - if (_map.containsKey(k) && v == _map.get(k)) { - // match, ok to continue - } else { - return false; // no match: we're done - } - } else { - return false; // different type in other map - } - } - return true; // all entries match - } - } else { - return false; - } - } - - /** - * Retrieves the value for key - * - * @param key an Object value - * @return the value of key or null if no such mapping exists. - */ - @Override // GemStoneAddition - public Object get(Object key) { - double k = unwrapKey(key); - float v = _map.get(k); - // 0 may be a false positive since primitive maps - // cannot return null, so we have to do an extra - // check here. - if (v == 0) { - return _map.containsKey(k) ? wrapValue(v) : null; - } else { - return wrapValue(v); - } - } - - - /** - * Empties the map. - */ - @Override // GemStoneAddition - public void clear() { - this._map.clear(); - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an Object value - * @return the removed value, or Integer(0) if it was not found in the map - */ - @Override // GemStoneAddition - public Object remove(Object key) { - return wrapValue(_map.remove(unwrapKey(key))); - } - - /** - * Returns a Set view on the entries of the map. - * - * @return a Set value - */ - @Override // GemStoneAddition - public Set entrySet() { - return new AbstractSet() { - @Override // GemStoneAddition - public int size() { - return _map.size(); - } - @Override // GemStoneAddition - public boolean isEmpty() { - return TDoubleFloatHashMapDecorator.this.isEmpty(); - } - @Override // GemStoneAddition - public boolean contains(Object o) { - if (o instanceof Map.Entry) { - Object k = ((Map.Entry)o).getKey(); - Object v = ((Map.Entry)o).getValue(); - return (TDoubleFloatHashMapDecorator.this.containsKey(k) && - TDoubleFloatHashMapDecorator.this.get(k).equals(v)); - } else { - return false; - } - } - @Override // GemStoneAddition - public Iterator iterator() { - return new Iterator() { - private final TDoubleFloatIterator it = _map.iterator(); - - public Object next() { - it.advance(); - final Object key = wrapKey(it.key()); - final Object v = wrapValue(it.value()); - return new Map.Entry() { - private Object val = v; - @Override // GemStoneAddition - public boolean equals(Object o) { - return ((o instanceof Map.Entry) && - ((Map.Entry)o).getKey().equals(key) && - ((Map.Entry)o).getValue().equals(val)); - } - public Object getKey() { - return key; - } - public Object getValue() { - return val; - } - @Override // GemStoneAddition - public int hashCode() { - return key.hashCode() + val.hashCode(); - } - public Object setValue(Object value) { - val = value; - return put(key, value); - } - }; - } - - public boolean hasNext() { - return it.hasNext(); - } - - public void remove() { - it.remove(); - } - }; - } - @Override // GemStoneAddition - public boolean add(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean addAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean retainAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean removeAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public void clear() { - TDoubleFloatHashMapDecorator.this.clear(); - } - }; - } - - /** - * Checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsValue(Object val) { - return _map.containsValue(unwrapValue(val)); - } - - /** - * Checks for the present of key in the keys of the map. - * - * @param key an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsKey(Object key) { - return _map.containsKey(unwrapKey(key)); - } - - /** - * Returns the number of entries in the map. - * @return the map's size. - */ - @Override // GemStoneAddition - public int size() { - return this._map.size(); - } - - /** - * Indicates whether map has any entries. - * @return true if the map is empty - */ - @Override // GemStoneAddition - public boolean isEmpty() { - return (size() == 0); - } - - /** - * Copies the key/value mappings in map into this map. - * Note that this will be a deep copy, as storage is by - * primitive value. - * - * @param map a Map value - */ - @Override // GemStoneAddition - public void putAll(Map map) { - Iterator it = map.entrySet().iterator(); - for (int i = map.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - this.put(e.getKey(), e.getValue()); - } - } - - /** - * Wraps a key - * - * @param k a key in the underlying map - * @return an Object representation of the key - */ - protected Double wrapKey(double k) { - return Double.valueOf(k); - } - - /** - * Unwraps a key - * - * @param key a wrapped key - * @return an unwrapped representation of the key - */ - protected double unwrapKey(Object key) { - return ((Double)key).doubleValue(); - } - /** - * Wraps a value - * - * @param k a value in the underlying map - * @return an Object representation of the value - */ - protected Float wrapValue(float k) { - return new Float(k); - } - - /** - * Unwraps a value - * - * @param value a wrapped value - * @return an unwrapped representation of the value - */ - protected float unwrapValue(Object value) { - return ((Float)value).floatValue(); - } - -} // TDoubleFloatHashMapDecorator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TDoubleHashSetDecorator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TDoubleHashSetDecorator.java deleted file mode 100644 index c8a043194..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TDoubleHashSetDecorator.java +++ /dev/null @@ -1,222 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.decorator; - -import com.gemstone.gnu.trove.TDoubleHashSet; -import com.gemstone.gnu.trove.TDoubleIterator; -import java.util.AbstractSet; -//import java.util.Collection; -import java.util.Iterator; -import java.util.Set; - -/** - * Wrapper class to make a TDoubleHashSet conform to the java.util.Set API. - * This class simply decorates an underlying TDoubleHashSet and translates the Object-based - * APIs into their Trove primitive analogs. - * - *

- * Note that wrapping and unwrapping primitive values is extremely inefficient. If - * possible, users of this class should override the appropriate methods in this class - * and use a table of canonical values. - *

- * - * Created: Tue Sep 24 22:08:17 PDT 2002 - * - * @author Eric D. Friedman - * @version $Id: TDoubleHashSetDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $ - * @since trove 0.1.8 - */ -public class TDoubleHashSetDecorator extends AbstractSet implements Set, Cloneable { - /** the wrapped primitive set */ - protected TDoubleHashSet _set; - - /** - * Creates a wrapper that decorates the specified primitive set. - */ - public TDoubleHashSetDecorator(TDoubleHashSet set) { - super(); - this._set = set; - } - - /** - * Clones the underlying trove collection and returns the clone wrapped in a new - * decorator instance. This is a shallow clone except where primitives are - * concerned. - * - * @return a copy of the receiver - */ - @Override // GemStoneAddition - public Object clone() { - try { - TDoubleHashSetDecorator copy = (TDoubleHashSetDecorator) super.clone(); - copy._set = (TDoubleHashSet) _set.clone(); - return copy; - } catch (CloneNotSupportedException e) { - // assert(false); - throw new InternalError(); // we are cloneable - } - } - - /** - * Inserts a value into the set. - * - * @return true if the set was modified by the insertion - */ - @Override // GemStoneAddition - public boolean add(Object value) { - return _set.add(unwrap(value)); - } - - /** - * Compares this set with another set for equality of their stored - * entries. - * - * @param other an Object value - * @return true if the sets are identical - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (_set.equals(other)) { - return true; // comparing two trove sets - } else if (other instanceof Set) { - Set that = (Set)other; - if (that.size() != _set.size()) { - return false; // different sizes, no need to compare - } else { // now we have to do it the hard way - Iterator it = that.iterator(); - for (int i = that.size(); i-- > 0;) { - Object val = it.next(); - if (val instanceof Double) { - double v = unwrap(val); - if (_set.contains(v)) { - // match, ok to continue - } else { - return false; // no match: we're done - } - } else { - return false; // different type in other set - } - } - return true; // all entries match - } - } else { - return false; - } - } - - /** - * Empties the set. - */ - @Override // GemStoneAddition - public void clear() { - this._set.clear(); - } - - /** - * Deletes a value from the set. - * - * @param value an Object value - * @return true if the set was modified - */ - @Override // GemStoneAddition - public boolean remove(Object value) { - return _set.remove(unwrap(value)); - } - - /** - * Creates an iterator over the values of the set. - * - * @return an iterator with support for removals in the underlying set - */ - @Override // GemStoneAddition - public Iterator iterator() { - return new Iterator() { - private final TDoubleIterator it = _set.iterator(); - - public Object next() { - return wrap(it.next()); - } - - public boolean hasNext() { - return it.hasNext(); - } - - public void remove() { - it.remove(); - } - }; - } - - /** - * Returns the number of entries in the set. - * @return the set's size. - */ - @Override // GemStoneAddition - public int size() { - return this._set.size(); - } - - /** - * Indicates whether set has any entries. - * @return true if the set is empty - */ - @Override // GemStoneAddition - public boolean isEmpty() { - return (size() == 0); - } - - /** - * Wraps a value - * - * @param k a value in the underlying set - * @return an Object representation of the value - */ - protected Double wrap(double k) { - return Double.valueOf(k); - } - - /** - * Unwraps a value - * - * @param value a wrapped value - * @return an unwrapped representation of the value - */ - protected double unwrap(Object value) { - return ((Double)value).doubleValue(); - } -} // TDoubleHashSetDecorator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TDoubleIntHashMapDecorator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TDoubleIntHashMapDecorator.java deleted file mode 100644 index def1c35a5..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TDoubleIntHashMapDecorator.java +++ /dev/null @@ -1,383 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.decorator; - -import com.gemstone.gnu.trove.TDoubleIntHashMap; -import com.gemstone.gnu.trove.TDoubleIntIterator; -import java.util.AbstractMap; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -//import java.util.Map.Entry; -import java.util.Map; -import java.util.Set; - -/** - * Wrapper class to make a TDoubleIntHashMap conform to the java.util.Map API. - * This class simply decorates an underlying TDoubleIntHashMap and translates the Object-based - * APIs into their Trove primitive analogs. - * - *

- * Note that wrapping and unwrapping primitive values is extremely inefficient. If - * possible, users of this class should override the appropriate methods in this class - * and use a table of canonical values. - *

- * - * Created: Mon Sep 23 22:07:40 PDT 2002 - * - * @author Eric D. Friedman - * @version $Id: TDoubleIntHashMapDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $ - * @since trove 0.1.8 - */ -public class TDoubleIntHashMapDecorator extends AbstractMap implements Map, Cloneable { - /** the wrapped primitive map */ - protected TDoubleIntHashMap _map; - - /** - * Creates a wrapper that decorates the specified primitive map. - */ - public TDoubleIntHashMapDecorator(TDoubleIntHashMap map) { - super(); - this._map = map; - } - - /** - * Clones the underlying trove collection and returns the clone wrapped in a new - * decorator instance. This is a shallow clone except where primitives are - * concerned. - * - * @return a copy of the receiver - */ - @Override // GemStoneAddition - public Object clone() { - try { - TDoubleIntHashMapDecorator copy = (TDoubleIntHashMapDecorator) super.clone(); - copy._map = (TDoubleIntHashMap)_map.clone(); - return copy; - } catch (CloneNotSupportedException e) { - // assert(false); - throw new InternalError(); // we are cloneable, so this does not happen - } - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an Object value - * @param value an Object value - * @return the previous value associated with key, - * or Integer(0) if none was found. - */ - @Override // GemStoneAddition - public Object put(Object key, Object value) { - return wrapValue(_map.put(unwrapKey(key), unwrapValue(value))); - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return true if the maps are identical - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (_map.equals(other)) { - return true; // comparing two trove maps - } else if (other instanceof Map) { - Map that = (Map)other; - if (that.size() != _map.size()) { - return false; // different sizes, no need to compare - } else { // now we have to do it the hard way - Iterator it = that.entrySet().iterator(); - for (int i = that.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - Object key = e.getKey(); - Object val = e.getValue(); - if (key instanceof Double && val instanceof Integer) { - double k = unwrapKey(key); - int v = unwrapValue(val); - if (_map.containsKey(k) && v == _map.get(k)) { - // match, ok to continue - } else { - return false; // no match: we're done - } - } else { - return false; // different type in other map - } - } - return true; // all entries match - } - } else { - return false; - } - } - - /** - * Retrieves the value for key - * - * @param key an Object value - * @return the value of key or null if no such mapping exists. - */ - @Override // GemStoneAddition - public Object get(Object key) { - double k = unwrapKey(key); - int v = _map.get(k); - // 0 may be a false positive since primitive maps - // cannot return null, so we have to do an extra - // check here. - if (v == 0) { - return _map.containsKey(k) ? wrapValue(v) : null; - } else { - return wrapValue(v); - } - } - - - /** - * Empties the map. - */ - @Override // GemStoneAddition - public void clear() { - this._map.clear(); - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an Object value - * @return the removed value, or Integer(0) if it was not found in the map - */ - @Override // GemStoneAddition - public Object remove(Object key) { - return wrapValue(_map.remove(unwrapKey(key))); - } - - /** - * Returns a Set view on the entries of the map. - * - * @return a Set value - */ - @Override // GemStoneAddition - public Set entrySet() { - return new AbstractSet() { - @Override // GemStoneAddition - public int size() { - return _map.size(); - } - @Override // GemStoneAddition - public boolean isEmpty() { - return TDoubleIntHashMapDecorator.this.isEmpty(); - } - @Override // GemStoneAddition - public boolean contains(Object o) { - if (o instanceof Map.Entry) { - Object k = ((Map.Entry)o).getKey(); - Object v = ((Map.Entry)o).getValue(); - return (TDoubleIntHashMapDecorator.this.containsKey(k) && - TDoubleIntHashMapDecorator.this.get(k).equals(v)); - } else { - return false; - } - } - @Override // GemStoneAddition - public Iterator iterator() { - return new Iterator() { - private final TDoubleIntIterator it = _map.iterator(); - - public Object next() { - it.advance(); - final Object key = wrapKey(it.key()); - final Object v = wrapValue(it.value()); - return new Map.Entry() { - private Object val = v; - @Override // GemStoneAddition - public boolean equals(Object o) { - return ((o instanceof Map.Entry) && - ((Map.Entry)o).getKey().equals(key) && - ((Map.Entry)o).getValue().equals(val)); - } - public Object getKey() { - return key; - } - public Object getValue() { - return val; - } - @Override // GemStoneAddition - public int hashCode() { - return key.hashCode() + val.hashCode(); - } - public Object setValue(Object value) { - val = value; - return put(key, value); - } - }; - } - - public boolean hasNext() { - return it.hasNext(); - } - - public void remove() { - it.remove(); - } - }; - } - @Override // GemStoneAddition - public boolean add(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean addAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean retainAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean removeAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public void clear() { - TDoubleIntHashMapDecorator.this.clear(); - } - }; - } - - /** - * Checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsValue(Object val) { - return _map.containsValue(unwrapValue(val)); - } - - /** - * Checks for the present of key in the keys of the map. - * - * @param key an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsKey(Object key) { - return _map.containsKey(unwrapKey(key)); - } - - /** - * Returns the number of entries in the map. - * @return the map's size. - */ - @Override // GemStoneAddition - public int size() { - return this._map.size(); - } - - /** - * Indicates whether map has any entries. - * @return true if the map is empty - */ - @Override // GemStoneAddition - public boolean isEmpty() { - return (size() == 0); - } - - /** - * Copies the key/value mappings in map into this map. - * Note that this will be a deep copy, as storage is by - * primitive value. - * - * @param map a Map value - */ - @Override // GemStoneAddition - public void putAll(Map map) { - Iterator it = map.entrySet().iterator(); - for (int i = map.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - this.put(e.getKey(), e.getValue()); - } - } - - /** - * Wraps a key - * - * @param k a key in the underlying map - * @return an Object representation of the key - */ - protected Double wrapKey(double k) { - return Double.valueOf(k); - } - - /** - * Unwraps a key - * - * @param key a wrapped key - * @return an unwrapped representation of the key - */ - protected double unwrapKey(Object key) { - return ((Double)key).doubleValue(); - } - /** - * Wraps a value - * - * @param k a value in the underlying map - * @return an Object representation of the value - */ - protected Integer wrapValue(int k) { - return Integer.valueOf(k); - } - - /** - * Unwraps a value - * - * @param value a wrapped value - * @return an unwrapped representation of the value - */ - protected int unwrapValue(Object value) { - return ((Integer)value).intValue(); - } - -} // TDoubleIntHashMapDecorator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TDoubleLongHashMapDecorator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TDoubleLongHashMapDecorator.java deleted file mode 100644 index f18c24f35..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TDoubleLongHashMapDecorator.java +++ /dev/null @@ -1,383 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.decorator; - -import com.gemstone.gnu.trove.TDoubleLongHashMap; -import com.gemstone.gnu.trove.TDoubleLongIterator; -import java.util.AbstractMap; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -//import java.util.Map.Entry; -import java.util.Map; -import java.util.Set; - -/** - * Wrapper class to make a TDoubleLongHashMap conform to the java.util.Map API. - * This class simply decorates an underlying TDoubleLongHashMap and translates the Object-based - * APIs into their Trove primitive analogs. - * - *

- * Note that wrapping and unwrapping primitive values is extremely inefficient. If - * possible, users of this class should override the appropriate methods in this class - * and use a table of canonical values. - *

- * - * Created: Mon Sep 23 22:07:40 PDT 2002 - * - * @author Eric D. Friedman - * @version $Id: TDoubleLongHashMapDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $ - * @since trove 0.1.8 - */ -public class TDoubleLongHashMapDecorator extends AbstractMap implements Map, Cloneable { - /** the wrapped primitive map */ - protected TDoubleLongHashMap _map; - - /** - * Creates a wrapper that decorates the specified primitive map. - */ - public TDoubleLongHashMapDecorator(TDoubleLongHashMap map) { - super(); - this._map = map; - } - - /** - * Clones the underlying trove collection and returns the clone wrapped in a new - * decorator instance. This is a shallow clone except where primitives are - * concerned. - * - * @return a copy of the receiver - */ - @Override // GemStoneAddition - public Object clone() { - try { - TDoubleLongHashMapDecorator copy = (TDoubleLongHashMapDecorator) super.clone(); - copy._map = (TDoubleLongHashMap)_map.clone(); - return copy; - } catch (CloneNotSupportedException e) { - // assert(false); - throw new InternalError(); // we are cloneable, so this does not happen - } - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an Object value - * @param value an Object value - * @return the previous value associated with key, - * or Integer(0) if none was found. - */ - @Override // GemStoneAddition - public Object put(Object key, Object value) { - return wrapValue(_map.put(unwrapKey(key), unwrapValue(value))); - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return true if the maps are identical - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (_map.equals(other)) { - return true; // comparing two trove maps - } else if (other instanceof Map) { - Map that = (Map)other; - if (that.size() != _map.size()) { - return false; // different sizes, no need to compare - } else { // now we have to do it the hard way - Iterator it = that.entrySet().iterator(); - for (int i = that.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - Object key = e.getKey(); - Object val = e.getValue(); - if (key instanceof Double && val instanceof Long) { - double k = unwrapKey(key); - long v = unwrapValue(val); - if (_map.containsKey(k) && v == _map.get(k)) { - // match, ok to continue - } else { - return false; // no match: we're done - } - } else { - return false; // different type in other map - } - } - return true; // all entries match - } - } else { - return false; - } - } - - /** - * Retrieves the value for key - * - * @param key an Object value - * @return the value of key or null if no such mapping exists. - */ - @Override // GemStoneAddition - public Object get(Object key) { - double k = unwrapKey(key); - long v = _map.get(k); - // 0 may be a false positive since primitive maps - // cannot return null, so we have to do an extra - // check here. - if (v == 0) { - return _map.containsKey(k) ? wrapValue(v) : null; - } else { - return wrapValue(v); - } - } - - - /** - * Empties the map. - */ - @Override // GemStoneAddition - public void clear() { - this._map.clear(); - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an Object value - * @return the removed value, or Integer(0) if it was not found in the map - */ - @Override // GemStoneAddition - public Object remove(Object key) { - return wrapValue(_map.remove(unwrapKey(key))); - } - - /** - * Returns a Set view on the entries of the map. - * - * @return a Set value - */ - @Override // GemStoneAddition - public Set entrySet() { - return new AbstractSet() { - @Override // GemStoneAddition - public int size() { - return _map.size(); - } - @Override // GemStoneAddition - public boolean isEmpty() { - return TDoubleLongHashMapDecorator.this.isEmpty(); - } - @Override // GemStoneAddition - public boolean contains(Object o) { - if (o instanceof Map.Entry) { - Object k = ((Map.Entry)o).getKey(); - Object v = ((Map.Entry)o).getValue(); - return (TDoubleLongHashMapDecorator.this.containsKey(k) && - TDoubleLongHashMapDecorator.this.get(k).equals(v)); - } else { - return false; - } - } - @Override // GemStoneAddition - public Iterator iterator() { - return new Iterator() { - private final TDoubleLongIterator it = _map.iterator(); - - public Object next() { - it.advance(); - final Object key = wrapKey(it.key()); - final Object v = wrapValue(it.value()); - return new Map.Entry() { - private Object val = v; - @Override // GemStoneAddition - public boolean equals(Object o) { - return ((o instanceof Map.Entry) && - ((Map.Entry)o).getKey().equals(key) && - ((Map.Entry)o).getValue().equals(val)); - } - public Object getKey() { - return key; - } - public Object getValue() { - return val; - } - @Override // GemStoneAddition - public int hashCode() { - return key.hashCode() + val.hashCode(); - } - public Object setValue(Object value) { - val = value; - return put(key, value); - } - }; - } - - public boolean hasNext() { - return it.hasNext(); - } - - public void remove() { - it.remove(); - } - }; - } - @Override // GemStoneAddition - public boolean add(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean addAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean retainAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean removeAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public void clear() { - TDoubleLongHashMapDecorator.this.clear(); - } - }; - } - - /** - * Checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsValue(Object val) { - return _map.containsValue(unwrapValue(val)); - } - - /** - * Checks for the present of key in the keys of the map. - * - * @param key an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsKey(Object key) { - return _map.containsKey(unwrapKey(key)); - } - - /** - * Returns the number of entries in the map. - * @return the map's size. - */ - @Override // GemStoneAddition - public int size() { - return this._map.size(); - } - - /** - * Indicates whether map has any entries. - * @return true if the map is empty - */ - @Override // GemStoneAddition - public boolean isEmpty() { - return (size() == 0); - } - - /** - * Copies the key/value mappings in map into this map. - * Note that this will be a deep copy, as storage is by - * primitive value. - * - * @param map a Map value - */ - @Override // GemStoneAddition - public void putAll(Map map) { - Iterator it = map.entrySet().iterator(); - for (int i = map.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - this.put(e.getKey(), e.getValue()); - } - } - - /** - * Wraps a key - * - * @param k a key in the underlying map - * @return an Object representation of the key - */ - protected Double wrapKey(double k) { - return Double.valueOf(k); - } - - /** - * Unwraps a key - * - * @param key a wrapped key - * @return an unwrapped representation of the key - */ - protected double unwrapKey(Object key) { - return ((Double)key).doubleValue(); - } - /** - * Wraps a value - * - * @param k a value in the underlying map - * @return an Object representation of the value - */ - protected Long wrapValue(long k) { - return Long.valueOf(k); - } - - /** - * Unwraps a value - * - * @param value a wrapped value - * @return an unwrapped representation of the value - */ - protected long unwrapValue(Object value) { - return ((Long)value).longValue(); - } - -} // TDoubleLongHashMapDecorator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TDoubleObjectHashMapDecorator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TDoubleObjectHashMapDecorator.java deleted file mode 100644 index 9b614e7a0..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TDoubleObjectHashMapDecorator.java +++ /dev/null @@ -1,374 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.decorator; - -import com.gemstone.gnu.trove.TDoubleObjectHashMap; -import com.gemstone.gnu.trove.TDoubleObjectIterator; -import java.util.AbstractMap; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -//import java.util.Map.Entry; -import java.util.Map; -import java.util.Set; - -/** - * Wrapper class to make a TDoubleObjectHashMap conform to the java.util.Map API. - * This class simply decorates an underlying TDoubleObjectHashMap and translates the Object-based - * APIs into their Trove primitive analogs. - * - *

- * Note that wrapping and unwrapping primitive values is extremely inefficient. If - * possible, users of this class should override the appropriate methods in this class - * and use a table of canonical values. - *

- * - * Created: Mon Sep 23 22:07:40 PDT 2002 - * - * @author Eric D. Friedman - * @version $Id: TDoubleObjectHashMapDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $ - * @since trove 0.1.8 - */ -public class TDoubleObjectHashMapDecorator extends AbstractMap implements Map, Cloneable { - /** the wrapped primitive map */ - protected TDoubleObjectHashMap _map; - - /** - * Creates a wrapper that decorates the specified primitive map. - */ - public TDoubleObjectHashMapDecorator(TDoubleObjectHashMap map) { - super(); - this._map = map; - } - - /** - * Clones the underlying trove collection and returns the clone wrapped in a new - * decorator instance. This is a shallow clone except where primitives are - * concerned. - * - * @return a copy of the receiver - */ - @Override // GemStoneAddition - public Object clone() { - try { - TDoubleObjectHashMapDecorator copy = (TDoubleObjectHashMapDecorator) super.clone(); - copy._map = (TDoubleObjectHashMap)_map.clone(); - return copy; - } catch (CloneNotSupportedException e) { - // assert(false); - throw new InternalError(); // we are cloneable, so this does not happen - } - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an Object value - * @param value an Object value - * @return the previous value associated with key, - * or Integer(0) if none was found. - */ - @Override // GemStoneAddition - public Object put(Object key, Object value) { - return wrapValue(_map.put(unwrapKey(key), unwrapValue(value))); - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return true if the maps are identical - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (_map.equals(other)) { - return true; // comparing two trove maps - } else if (other instanceof Map) { - Map that = (Map)other; - if (that.size() != _map.size()) { - return false; // different sizes, no need to compare - } else { // now we have to do it the hard way - Iterator it = that.entrySet().iterator(); - for (int i = that.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - Object key = e.getKey(); - Object val = e.getValue(); - if (key instanceof Double) { - double k = unwrapKey(key); - Object v = unwrapValue(val); - if (_map.containsKey(k) && v == _map.get(k)) { - // match, ok to continue - } else { - return false; // no match: we're done - } - } else { - return false; // different type in other map - } - } - return true; // all entries match - } - } else { - return false; - } - } - - /** - * Retrieves the value for key - * - * @param key an Object value - * @return the value of key or null if no such mapping exists. - */ - @Override // GemStoneAddition - public Object get(Object key) { - return _map.get(unwrapKey(key)); - } - - - /** - * Empties the map. - */ - @Override // GemStoneAddition - public void clear() { - this._map.clear(); - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an Object value - * @return the removed value, or Integer(0) if it was not found in the map - */ - @Override // GemStoneAddition - public Object remove(Object key) { - return wrapValue(_map.remove(unwrapKey(key))); - } - - /** - * Returns a Set view on the entries of the map. - * - * @return a Set value - */ - @Override // GemStoneAddition - public Set entrySet() { - return new AbstractSet() { - @Override // GemStoneAddition - public int size() { - return _map.size(); - } - @Override // GemStoneAddition - public boolean isEmpty() { - return TDoubleObjectHashMapDecorator.this.isEmpty(); - } - @Override // GemStoneAddition - public boolean contains(Object o) { - if (o instanceof Map.Entry) { - Object k = ((Map.Entry)o).getKey(); - Object v = ((Map.Entry)o).getValue(); - return (TDoubleObjectHashMapDecorator.this.containsKey(k) && - TDoubleObjectHashMapDecorator.this.get(k).equals(v)); - } else { - return false; - } - } - @Override // GemStoneAddition - public Iterator iterator() { - return new Iterator() { - private final TDoubleObjectIterator it = _map.iterator(); - - public Object next() { - it.advance(); - final Object key = wrapKey(it.key()); - final Object v = wrapValue(it.value()); - return new Map.Entry() { - private Object val = v; - @Override // GemStoneAddition - public boolean equals(Object o) { - return ((o instanceof Map.Entry) && - ((Map.Entry)o).getKey().equals(key) && - ((Map.Entry)o).getValue().equals(val)); - } - public Object getKey() { - return key; - } - public Object getValue() { - return val; - } - @Override // GemStoneAddition - public int hashCode() { - return key.hashCode() + val.hashCode(); - } - public Object setValue(Object value) { - val = value; - return put(key, value); - } - }; - } - - public boolean hasNext() { - return it.hasNext(); - } - - public void remove() { - it.remove(); - } - }; - } - @Override // GemStoneAddition - public boolean add(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean addAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean retainAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean removeAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public void clear() { - TDoubleObjectHashMapDecorator.this.clear(); - } - }; - } - - /** - * Checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsValue(Object val) { - return _map.containsValue(unwrapValue(val)); - } - - /** - * Checks for the present of key in the keys of the map. - * - * @param key an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsKey(Object key) { - return _map.containsKey(unwrapKey(key)); - } - - /** - * Returns the number of entries in the map. - * @return the map's size. - */ - @Override // GemStoneAddition - public int size() { - return this._map.size(); - } - - /** - * Indicates whether map has any entries. - * @return true if the map is empty - */ - @Override // GemStoneAddition - public boolean isEmpty() { - return (size() == 0); - } - - /** - * Copies the key/value mappings in map into this map. - * Note that this will be a deep copy, as storage is by - * primitive value. - * - * @param map a Map value - */ - @Override // GemStoneAddition - public void putAll(Map map) { - Iterator it = map.entrySet().iterator(); - for (int i = map.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - this.put(e.getKey(), e.getValue()); - } - } - - /** - * Wraps a key - * - * @param k a key in the underlying map - * @return an Object representation of the key - */ - protected Double wrapKey(double k) { - return Double.valueOf(k); - } - - /** - * Unwraps a key - * - * @param key a wrapped key - * @return an unwrapped representation of the key - */ - protected double unwrapKey(Object key) { - return ((Double)key).doubleValue(); - } - /** - * Wraps a value - * - * @param o a value in the underlying map - * @return an Object representation of the value - */ - protected final Object wrapValue(Object o) { - return o; - } - - /** - * Unwraps a value - * - * @param value a wrapped value - * @return an unwrapped representation of the value - */ - protected final Object unwrapValue(Object value) { - return value; - } - -} // TDoubleObjectHashMapDecorator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TFloatDoubleHashMapDecorator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TFloatDoubleHashMapDecorator.java deleted file mode 100644 index a10c8542d..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TFloatDoubleHashMapDecorator.java +++ /dev/null @@ -1,383 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.decorator; - -import com.gemstone.gnu.trove.TFloatDoubleHashMap; -import com.gemstone.gnu.trove.TFloatDoubleIterator; -import java.util.AbstractMap; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -//import java.util.Map.Entry; -import java.util.Map; -import java.util.Set; - -/** - * Wrapper class to make a TFloatDoubleHashMap conform to the java.util.Map API. - * This class simply decorates an underlying TFloatDoubleHashMap and translates the Object-based - * APIs into their Trove primitive analogs. - * - *

- * Note that wrapping and unwrapping primitive values is extremely inefficient. If - * possible, users of this class should override the appropriate methods in this class - * and use a table of canonical values. - *

- * - * Created: Mon Sep 23 22:07:40 PDT 2002 - * - * @author Eric D. Friedman - * @version $Id: TFloatDoubleHashMapDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $ - * @since trove 0.1.8 - */ -public class TFloatDoubleHashMapDecorator extends AbstractMap implements Map, Cloneable { - /** the wrapped primitive map */ - protected TFloatDoubleHashMap _map; - - /** - * Creates a wrapper that decorates the specified primitive map. - */ - public TFloatDoubleHashMapDecorator(TFloatDoubleHashMap map) { - super(); - this._map = map; - } - - /** - * Clones the underlying trove collection and returns the clone wrapped in a new - * decorator instance. This is a shallow clone except where primitives are - * concerned. - * - * @return a copy of the receiver - */ - @Override // GemStoneAddition - public Object clone() { - try { - TFloatDoubleHashMapDecorator copy = (TFloatDoubleHashMapDecorator) super.clone(); - copy._map = (TFloatDoubleHashMap)_map.clone(); - return copy; - } catch (CloneNotSupportedException e) { - // assert(false); - throw new InternalError(); // we are cloneable, so this does not happen - } - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an Object value - * @param value an Object value - * @return the previous value associated with key, - * or Integer(0) if none was found. - */ - @Override // GemStoneAddition - public Object put(Object key, Object value) { - return wrapValue(_map.put(unwrapKey(key), unwrapValue(value))); - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return true if the maps are identical - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (_map.equals(other)) { - return true; // comparing two trove maps - } else if (other instanceof Map) { - Map that = (Map)other; - if (that.size() != _map.size()) { - return false; // different sizes, no need to compare - } else { // now we have to do it the hard way - Iterator it = that.entrySet().iterator(); - for (int i = that.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - Object key = e.getKey(); - Object val = e.getValue(); - if (key instanceof Float && val instanceof Double) { - float k = unwrapKey(key); - double v = unwrapValue(val); - if (_map.containsKey(k) && v == _map.get(k)) { - // match, ok to continue - } else { - return false; // no match: we're done - } - } else { - return false; // different type in other map - } - } - return true; // all entries match - } - } else { - return false; - } - } - - /** - * Retrieves the value for key - * - * @param key an Object value - * @return the value of key or null if no such mapping exists. - */ - @Override // GemStoneAddition - public Object get(Object key) { - float k = unwrapKey(key); - double v = _map.get(k); - // 0 may be a false positive since primitive maps - // cannot return null, so we have to do an extra - // check here. - if (v == 0) { - return _map.containsKey(k) ? wrapValue(v) : null; - } else { - return wrapValue(v); - } - } - - - /** - * Empties the map. - */ - @Override // GemStoneAddition - public void clear() { - this._map.clear(); - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an Object value - * @return the removed value, or Integer(0) if it was not found in the map - */ - @Override // GemStoneAddition - public Object remove(Object key) { - return wrapValue(_map.remove(unwrapKey(key))); - } - - /** - * Returns a Set view on the entries of the map. - * - * @return a Set value - */ - @Override // GemStoneAddition - public Set entrySet() { - return new AbstractSet() { - @Override // GemStoneAddition - public int size() { - return _map.size(); - } - @Override // GemStoneAddition - public boolean isEmpty() { - return TFloatDoubleHashMapDecorator.this.isEmpty(); - } - @Override // GemStoneAddition - public boolean contains(Object o) { - if (o instanceof Map.Entry) { - Object k = ((Map.Entry)o).getKey(); - Object v = ((Map.Entry)o).getValue(); - return (TFloatDoubleHashMapDecorator.this.containsKey(k) && - TFloatDoubleHashMapDecorator.this.get(k).equals(v)); - } else { - return false; - } - } - @Override // GemStoneAddition - public Iterator iterator() { - return new Iterator() { - private final TFloatDoubleIterator it = _map.iterator(); - - public Object next() { - it.advance(); - final Object key = wrapKey(it.key()); - final Object v = wrapValue(it.value()); - return new Map.Entry() { - private Object val = v; - @Override // GemStoneAddition - public boolean equals(Object o) { - return ((o instanceof Map.Entry) && - ((Map.Entry)o).getKey().equals(key) && - ((Map.Entry)o).getValue().equals(val)); - } - public Object getKey() { - return key; - } - public Object getValue() { - return val; - } - @Override // GemStoneAddition - public int hashCode() { - return key.hashCode() + val.hashCode(); - } - public Object setValue(Object value) { - val = value; - return put(key, value); - } - }; - } - - public boolean hasNext() { - return it.hasNext(); - } - - public void remove() { - it.remove(); - } - }; - } - @Override // GemStoneAddition - public boolean add(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean addAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean retainAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean removeAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public void clear() { - TFloatDoubleHashMapDecorator.this.clear(); - } - }; - } - - /** - * Checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsValue(Object val) { - return _map.containsValue(unwrapValue(val)); - } - - /** - * Checks for the present of key in the keys of the map. - * - * @param key an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsKey(Object key) { - return _map.containsKey(unwrapKey(key)); - } - - /** - * Returns the number of entries in the map. - * @return the map's size. - */ - @Override // GemStoneAddition - public int size() { - return this._map.size(); - } - - /** - * Indicates whether map has any entries. - * @return true if the map is empty - */ - @Override // GemStoneAddition - public boolean isEmpty() { - return (size() == 0); - } - - /** - * Copies the key/value mappings in map into this map. - * Note that this will be a deep copy, as storage is by - * primitive value. - * - * @param map a Map value - */ - @Override // GemStoneAddition - public void putAll(Map map) { - Iterator it = map.entrySet().iterator(); - for (int i = map.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - this.put(e.getKey(), e.getValue()); - } - } - - /** - * Wraps a key - * - * @param k a key in the underlying map - * @return an Object representation of the key - */ - protected Float wrapKey(float k) { - return new Float(k); - } - - /** - * Unwraps a key - * - * @param key a wrapped key - * @return an unwrapped representation of the key - */ - protected float unwrapKey(Object key) { - return ((Float)key).floatValue(); - } - /** - * Wraps a value - * - * @param k a value in the underlying map - * @return an Object representation of the value - */ - protected Double wrapValue(double k) { - return Double.valueOf(k); - } - - /** - * Unwraps a value - * - * @param value a wrapped value - * @return an unwrapped representation of the value - */ - protected double unwrapValue(Object value) { - return ((Double)value).doubleValue(); - } - -} // TFloatDoubleHashMapDecorator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TFloatFloatHashMapDecorator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TFloatFloatHashMapDecorator.java deleted file mode 100644 index 85c817cb5..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TFloatFloatHashMapDecorator.java +++ /dev/null @@ -1,383 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.decorator; - -import com.gemstone.gnu.trove.TFloatFloatHashMap; -import com.gemstone.gnu.trove.TFloatFloatIterator; -import java.util.AbstractMap; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -//import java.util.Map.Entry; -import java.util.Map; -import java.util.Set; - -/** - * Wrapper class to make a TFloatFloatHashMap conform to the java.util.Map API. - * This class simply decorates an underlying TFloatFloatHashMap and translates the Object-based - * APIs into their Trove primitive analogs. - * - *

- * Note that wrapping and unwrapping primitive values is extremely inefficient. If - * possible, users of this class should override the appropriate methods in this class - * and use a table of canonical values. - *

- * - * Created: Mon Sep 23 22:07:40 PDT 2002 - * - * @author Eric D. Friedman - * @version $Id: TFloatFloatHashMapDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $ - * @since trove 0.1.8 - */ -public class TFloatFloatHashMapDecorator extends AbstractMap implements Map, Cloneable { - /** the wrapped primitive map */ - protected TFloatFloatHashMap _map; - - /** - * Creates a wrapper that decorates the specified primitive map. - */ - public TFloatFloatHashMapDecorator(TFloatFloatHashMap map) { - super(); - this._map = map; - } - - /** - * Clones the underlying trove collection and returns the clone wrapped in a new - * decorator instance. This is a shallow clone except where primitives are - * concerned. - * - * @return a copy of the receiver - */ - @Override // GemStoneAddition - public Object clone() { - try { - TFloatFloatHashMapDecorator copy = (TFloatFloatHashMapDecorator) super.clone(); - copy._map = (TFloatFloatHashMap)_map.clone(); - return copy; - } catch (CloneNotSupportedException e) { - // assert(false); - throw new InternalError(); // we are cloneable, so this does not happen - } - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an Object value - * @param value an Object value - * @return the previous value associated with key, - * or Integer(0) if none was found. - */ - @Override // GemStoneAddition - public Object put(Object key, Object value) { - return wrapValue(_map.put(unwrapKey(key), unwrapValue(value))); - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return true if the maps are identical - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (_map.equals(other)) { - return true; // comparing two trove maps - } else if (other instanceof Map) { - Map that = (Map)other; - if (that.size() != _map.size()) { - return false; // different sizes, no need to compare - } else { // now we have to do it the hard way - Iterator it = that.entrySet().iterator(); - for (int i = that.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - Object key = e.getKey(); - Object val = e.getValue(); - if (key instanceof Float && val instanceof Float) { - float k = unwrapKey(key); - float v = unwrapValue(val); - if (_map.containsKey(k) && v == _map.get(k)) { - // match, ok to continue - } else { - return false; // no match: we're done - } - } else { - return false; // different type in other map - } - } - return true; // all entries match - } - } else { - return false; - } - } - - /** - * Retrieves the value for key - * - * @param key an Object value - * @return the value of key or null if no such mapping exists. - */ - @Override // GemStoneAddition - public Object get(Object key) { - float k = unwrapKey(key); - float v = _map.get(k); - // 0 may be a false positive since primitive maps - // cannot return null, so we have to do an extra - // check here. - if (v == 0) { - return _map.containsKey(k) ? wrapValue(v) : null; - } else { - return wrapValue(v); - } - } - - - /** - * Empties the map. - */ - @Override // GemStoneAddition - public void clear() { - this._map.clear(); - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an Object value - * @return the removed value, or Integer(0) if it was not found in the map - */ - @Override // GemStoneAddition - public Object remove(Object key) { - return wrapValue(_map.remove(unwrapKey(key))); - } - - /** - * Returns a Set view on the entries of the map. - * - * @return a Set value - */ - @Override // GemStoneAddition - public Set entrySet() { - return new AbstractSet() { - @Override // GemStoneAddition - public int size() { - return _map.size(); - } - @Override // GemStoneAddition - public boolean isEmpty() { - return TFloatFloatHashMapDecorator.this.isEmpty(); - } - @Override // GemStoneAddition - public boolean contains(Object o) { - if (o instanceof Map.Entry) { - Object k = ((Map.Entry)o).getKey(); - Object v = ((Map.Entry)o).getValue(); - return (TFloatFloatHashMapDecorator.this.containsKey(k) && - TFloatFloatHashMapDecorator.this.get(k).equals(v)); - } else { - return false; - } - } - @Override // GemStoneAddition - public Iterator iterator() { - return new Iterator() { - private final TFloatFloatIterator it = _map.iterator(); - - public Object next() { - it.advance(); - final Object key = wrapKey(it.key()); - final Object v = wrapValue(it.value()); - return new Map.Entry() { - private Object val = v; - @Override // GemStoneAddition - public boolean equals(Object o) { - return ((o instanceof Map.Entry) && - ((Map.Entry)o).getKey().equals(key) && - ((Map.Entry)o).getValue().equals(val)); - } - public Object getKey() { - return key; - } - public Object getValue() { - return val; - } - @Override // GemStoneAddition - public int hashCode() { - return key.hashCode() + val.hashCode(); - } - public Object setValue(Object value) { - val = value; - return put(key, value); - } - }; - } - - public boolean hasNext() { - return it.hasNext(); - } - - public void remove() { - it.remove(); - } - }; - } - @Override // GemStoneAddition - public boolean add(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean addAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean retainAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean removeAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public void clear() { - TFloatFloatHashMapDecorator.this.clear(); - } - }; - } - - /** - * Checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsValue(Object val) { - return _map.containsValue(unwrapValue(val)); - } - - /** - * Checks for the present of key in the keys of the map. - * - * @param key an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsKey(Object key) { - return _map.containsKey(unwrapKey(key)); - } - - /** - * Returns the number of entries in the map. - * @return the map's size. - */ - @Override // GemStoneAddition - public int size() { - return this._map.size(); - } - - /** - * Indicates whether map has any entries. - * @return true if the map is empty - */ - @Override // GemStoneAddition - public boolean isEmpty() { - return (size() == 0); - } - - /** - * Copies the key/value mappings in map into this map. - * Note that this will be a deep copy, as storage is by - * primitive value. - * - * @param map a Map value - */ - @Override // GemStoneAddition - public void putAll(Map map) { - Iterator it = map.entrySet().iterator(); - for (int i = map.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - this.put(e.getKey(), e.getValue()); - } - } - - /** - * Wraps a key - * - * @param k a key in the underlying map - * @return an Object representation of the key - */ - protected Float wrapKey(float k) { - return new Float(k); - } - - /** - * Unwraps a key - * - * @param key a wrapped key - * @return an unwrapped representation of the key - */ - protected float unwrapKey(Object key) { - return ((Float)key).floatValue(); - } - /** - * Wraps a value - * - * @param k a value in the underlying map - * @return an Object representation of the value - */ - protected Float wrapValue(float k) { - return new Float(k); - } - - /** - * Unwraps a value - * - * @param value a wrapped value - * @return an unwrapped representation of the value - */ - protected float unwrapValue(Object value) { - return ((Float)value).floatValue(); - } - -} // TFloatFloatHashMapDecorator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TFloatHashSetDecorator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TFloatHashSetDecorator.java deleted file mode 100644 index b8812396c..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TFloatHashSetDecorator.java +++ /dev/null @@ -1,222 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.decorator; - -import com.gemstone.gnu.trove.TFloatHashSet; -import com.gemstone.gnu.trove.TFloatIterator; -import java.util.AbstractSet; -//import java.util.Collection; -import java.util.Iterator; -import java.util.Set; - -/** - * Wrapper class to make a TFloatHashSet conform to the java.util.Set API. - * This class simply decorates an underlying TFloatHashSet and translates the Object-based - * APIs into their Trove primitive analogs. - * - *

- * Note that wrapping and unwrapping primitive values is extremely inefficient. If - * possible, users of this class should override the appropriate methods in this class - * and use a table of canonical values. - *

- * - * Created: Tue Sep 24 22:08:17 PDT 2002 - * - * @author Eric D. Friedman - * @version $Id: TFloatHashSetDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $ - * @since trove 0.1.8 - */ -public class TFloatHashSetDecorator extends AbstractSet implements Set, Cloneable { - /** the wrapped primitive set */ - protected TFloatHashSet _set; - - /** - * Creates a wrapper that decorates the specified primitive set. - */ - public TFloatHashSetDecorator(TFloatHashSet set) { - super(); - this._set = set; - } - - /** - * Clones the underlying trove collection and returns the clone wrapped in a new - * decorator instance. This is a shallow clone except where primitives are - * concerned. - * - * @return a copy of the receiver - */ - @Override // GemStoneAddition - public Object clone() { - try { - TFloatHashSetDecorator copy = (TFloatHashSetDecorator) super.clone(); - copy._set = (TFloatHashSet) _set.clone(); - return copy; - } catch (CloneNotSupportedException e) { - // assert(false); - throw new InternalError(); // we are cloneable - } - } - - /** - * Inserts a value into the set. - * - * @return true if the set was modified by the insertion - */ - @Override // GemStoneAddition - public boolean add(Object value) { - return _set.add(unwrap(value)); - } - - /** - * Compares this set with another set for equality of their stored - * entries. - * - * @param other an Object value - * @return true if the sets are identical - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (_set.equals(other)) { - return true; // comparing two trove sets - } else if (other instanceof Set) { - Set that = (Set)other; - if (that.size() != _set.size()) { - return false; // different sizes, no need to compare - } else { // now we have to do it the hard way - Iterator it = that.iterator(); - for (int i = that.size(); i-- > 0;) { - Object val = it.next(); - if (val instanceof Float) { - float v = unwrap(val); - if (_set.contains(v)) { - // match, ok to continue - } else { - return false; // no match: we're done - } - } else { - return false; // different type in other set - } - } - return true; // all entries match - } - } else { - return false; - } - } - - /** - * Empties the set. - */ - @Override // GemStoneAddition - public void clear() { - this._set.clear(); - } - - /** - * Deletes a value from the set. - * - * @param value an Object value - * @return true if the set was modified - */ - @Override // GemStoneAddition - public boolean remove(Object value) { - return _set.remove(unwrap(value)); - } - - /** - * Creates an iterator over the values of the set. - * - * @return an iterator with support for removals in the underlying set - */ - @Override // GemStoneAddition - public Iterator iterator() { - return new Iterator() { - private final TFloatIterator it = _set.iterator(); - - public Object next() { - return wrap(it.next()); - } - - public boolean hasNext() { - return it.hasNext(); - } - - public void remove() { - it.remove(); - } - }; - } - - /** - * Returns the number of entries in the set. - * @return the set's size. - */ - @Override // GemStoneAddition - public int size() { - return this._set.size(); - } - - /** - * Indicates whether set has any entries. - * @return true if the set is empty - */ - @Override // GemStoneAddition - public boolean isEmpty() { - return (size() == 0); - } - - /** - * Wraps a value - * - * @param k a value in the underlying set - * @return an Object representation of the value - */ - protected Float wrap(float k) { - return new Float(k); - } - - /** - * Unwraps a value - * - * @param value a wrapped value - * @return an unwrapped representation of the value - */ - protected float unwrap(Object value) { - return ((Float)value).floatValue(); - } -} // TFloatHashSetDecorator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TFloatIntHashMapDecorator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TFloatIntHashMapDecorator.java deleted file mode 100644 index 0bc78e248..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TFloatIntHashMapDecorator.java +++ /dev/null @@ -1,383 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.decorator; - -import com.gemstone.gnu.trove.TFloatIntHashMap; -import com.gemstone.gnu.trove.TFloatIntIterator; -import java.util.AbstractMap; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -//import java.util.Map.Entry; -import java.util.Map; -import java.util.Set; - -/** - * Wrapper class to make a TFloatIntHashMap conform to the java.util.Map API. - * This class simply decorates an underlying TFloatIntHashMap and translates the Object-based - * APIs into their Trove primitive analogs. - * - *

- * Note that wrapping and unwrapping primitive values is extremely inefficient. If - * possible, users of this class should override the appropriate methods in this class - * and use a table of canonical values. - *

- * - * Created: Mon Sep 23 22:07:40 PDT 2002 - * - * @author Eric D. Friedman - * @version $Id: TFloatIntHashMapDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $ - * @since trove 0.1.8 - */ -public class TFloatIntHashMapDecorator extends AbstractMap implements Map, Cloneable { - /** the wrapped primitive map */ - protected TFloatIntHashMap _map; - - /** - * Creates a wrapper that decorates the specified primitive map. - */ - public TFloatIntHashMapDecorator(TFloatIntHashMap map) { - super(); - this._map = map; - } - - /** - * Clones the underlying trove collection and returns the clone wrapped in a new - * decorator instance. This is a shallow clone except where primitives are - * concerned. - * - * @return a copy of the receiver - */ - @Override // GemStoneAddition - public Object clone() { - try { - TFloatIntHashMapDecorator copy = (TFloatIntHashMapDecorator) super.clone(); - copy._map = (TFloatIntHashMap)_map.clone(); - return copy; - } catch (CloneNotSupportedException e) { - // assert(false); - throw new InternalError(); // we are cloneable, so this does not happen - } - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an Object value - * @param value an Object value - * @return the previous value associated with key, - * or Integer(0) if none was found. - */ - @Override // GemStoneAddition - public Object put(Object key, Object value) { - return wrapValue(_map.put(unwrapKey(key), unwrapValue(value))); - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return true if the maps are identical - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (_map.equals(other)) { - return true; // comparing two trove maps - } else if (other instanceof Map) { - Map that = (Map)other; - if (that.size() != _map.size()) { - return false; // different sizes, no need to compare - } else { // now we have to do it the hard way - Iterator it = that.entrySet().iterator(); - for (int i = that.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - Object key = e.getKey(); - Object val = e.getValue(); - if (key instanceof Float && val instanceof Integer) { - float k = unwrapKey(key); - int v = unwrapValue(val); - if (_map.containsKey(k) && v == _map.get(k)) { - // match, ok to continue - } else { - return false; // no match: we're done - } - } else { - return false; // different type in other map - } - } - return true; // all entries match - } - } else { - return false; - } - } - - /** - * Retrieves the value for key - * - * @param key an Object value - * @return the value of key or null if no such mapping exists. - */ - @Override // GemStoneAddition - public Object get(Object key) { - float k = unwrapKey(key); - int v = _map.get(k); - // 0 may be a false positive since primitive maps - // cannot return null, so we have to do an extra - // check here. - if (v == 0) { - return _map.containsKey(k) ? wrapValue(v) : null; - } else { - return wrapValue(v); - } - } - - - /** - * Empties the map. - */ - @Override // GemStoneAddition - public void clear() { - this._map.clear(); - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an Object value - * @return the removed value, or Integer(0) if it was not found in the map - */ - @Override // GemStoneAddition - public Object remove(Object key) { - return wrapValue(_map.remove(unwrapKey(key))); - } - - /** - * Returns a Set view on the entries of the map. - * - * @return a Set value - */ - @Override // GemStoneAddition - public Set entrySet() { - return new AbstractSet() { - @Override // GemStoneAddition - public int size() { - return _map.size(); - } - @Override // GemStoneAddition - public boolean isEmpty() { - return TFloatIntHashMapDecorator.this.isEmpty(); - } - @Override // GemStoneAddition - public boolean contains(Object o) { - if (o instanceof Map.Entry) { - Object k = ((Map.Entry)o).getKey(); - Object v = ((Map.Entry)o).getValue(); - return (TFloatIntHashMapDecorator.this.containsKey(k) && - TFloatIntHashMapDecorator.this.get(k).equals(v)); - } else { - return false; - } - } - @Override // GemStoneAddition - public Iterator iterator() { - return new Iterator() { - private final TFloatIntIterator it = _map.iterator(); - - public Object next() { - it.advance(); - final Object key = wrapKey(it.key()); - final Object v = wrapValue(it.value()); - return new Map.Entry() { - private Object val = v; - @Override // GemStoneAddition - public boolean equals(Object o) { - return ((o instanceof Map.Entry) && - ((Map.Entry)o).getKey().equals(key) && - ((Map.Entry)o).getValue().equals(val)); - } - public Object getKey() { - return key; - } - public Object getValue() { - return val; - } - @Override // GemStoneAddition - public int hashCode() { - return key.hashCode() + val.hashCode(); - } - public Object setValue(Object value) { - val = value; - return put(key, value); - } - }; - } - - public boolean hasNext() { - return it.hasNext(); - } - - public void remove() { - it.remove(); - } - }; - } - @Override // GemStoneAddition - public boolean add(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean addAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean retainAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean removeAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public void clear() { - TFloatIntHashMapDecorator.this.clear(); - } - }; - } - - /** - * Checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsValue(Object val) { - return _map.containsValue(unwrapValue(val)); - } - - /** - * Checks for the present of key in the keys of the map. - * - * @param key an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsKey(Object key) { - return _map.containsKey(unwrapKey(key)); - } - - /** - * Returns the number of entries in the map. - * @return the map's size. - */ - @Override // GemStoneAddition - public int size() { - return this._map.size(); - } - - /** - * Indicates whether map has any entries. - * @return true if the map is empty - */ - @Override // GemStoneAddition - public boolean isEmpty() { - return (size() == 0); - } - - /** - * Copies the key/value mappings in map into this map. - * Note that this will be a deep copy, as storage is by - * primitive value. - * - * @param map a Map value - */ - @Override // GemStoneAddition - public void putAll(Map map) { - Iterator it = map.entrySet().iterator(); - for (int i = map.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - this.put(e.getKey(), e.getValue()); - } - } - - /** - * Wraps a key - * - * @param k a key in the underlying map - * @return an Object representation of the key - */ - protected Float wrapKey(float k) { - return new Float(k); - } - - /** - * Unwraps a key - * - * @param key a wrapped key - * @return an unwrapped representation of the key - */ - protected float unwrapKey(Object key) { - return ((Float)key).floatValue(); - } - /** - * Wraps a value - * - * @param k a value in the underlying map - * @return an Object representation of the value - */ - protected Integer wrapValue(int k) { - return Integer.valueOf(k); - } - - /** - * Unwraps a value - * - * @param value a wrapped value - * @return an unwrapped representation of the value - */ - protected int unwrapValue(Object value) { - return ((Integer)value).intValue(); - } - -} // TFloatIntHashMapDecorator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TFloatLongHashMapDecorator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TFloatLongHashMapDecorator.java deleted file mode 100644 index c0d661c1a..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TFloatLongHashMapDecorator.java +++ /dev/null @@ -1,383 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.decorator; - -import com.gemstone.gnu.trove.TFloatLongHashMap; -import com.gemstone.gnu.trove.TFloatLongIterator; -import java.util.AbstractMap; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -//import java.util.Map.Entry; -import java.util.Map; -import java.util.Set; - -/** - * Wrapper class to make a TFloatLongHashMap conform to the java.util.Map API. - * This class simply decorates an underlying TFloatLongHashMap and translates the Object-based - * APIs into their Trove primitive analogs. - * - *

- * Note that wrapping and unwrapping primitive values is extremely inefficient. If - * possible, users of this class should override the appropriate methods in this class - * and use a table of canonical values. - *

- * - * Created: Mon Sep 23 22:07:40 PDT 2002 - * - * @author Eric D. Friedman - * @version $Id: TFloatLongHashMapDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $ - * @since trove 0.1.8 - */ -public class TFloatLongHashMapDecorator extends AbstractMap implements Map, Cloneable { - /** the wrapped primitive map */ - protected TFloatLongHashMap _map; - - /** - * Creates a wrapper that decorates the specified primitive map. - */ - public TFloatLongHashMapDecorator(TFloatLongHashMap map) { - super(); - this._map = map; - } - - /** - * Clones the underlying trove collection and returns the clone wrapped in a new - * decorator instance. This is a shallow clone except where primitives are - * concerned. - * - * @return a copy of the receiver - */ - @Override // GemStoneAddition - public Object clone() { - try { - TFloatLongHashMapDecorator copy = (TFloatLongHashMapDecorator) super.clone(); - copy._map = (TFloatLongHashMap)_map.clone(); - return copy; - } catch (CloneNotSupportedException e) { - // assert(false); - throw new InternalError(); // we are cloneable, so this does not happen - } - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an Object value - * @param value an Object value - * @return the previous value associated with key, - * or Integer(0) if none was found. - */ - @Override // GemStoneAddition - public Object put(Object key, Object value) { - return wrapValue(_map.put(unwrapKey(key), unwrapValue(value))); - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return true if the maps are identical - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (_map.equals(other)) { - return true; // comparing two trove maps - } else if (other instanceof Map) { - Map that = (Map)other; - if (that.size() != _map.size()) { - return false; // different sizes, no need to compare - } else { // now we have to do it the hard way - Iterator it = that.entrySet().iterator(); - for (int i = that.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - Object key = e.getKey(); - Object val = e.getValue(); - if (key instanceof Float && val instanceof Long) { - float k = unwrapKey(key); - long v = unwrapValue(val); - if (_map.containsKey(k) && v == _map.get(k)) { - // match, ok to continue - } else { - return false; // no match: we're done - } - } else { - return false; // different type in other map - } - } - return true; // all entries match - } - } else { - return false; - } - } - - /** - * Retrieves the value for key - * - * @param key an Object value - * @return the value of key or null if no such mapping exists. - */ - @Override // GemStoneAddition - public Object get(Object key) { - float k = unwrapKey(key); - long v = _map.get(k); - // 0 may be a false positive since primitive maps - // cannot return null, so we have to do an extra - // check here. - if (v == 0) { - return _map.containsKey(k) ? wrapValue(v) : null; - } else { - return wrapValue(v); - } - } - - - /** - * Empties the map. - */ - @Override // GemStoneAddition - public void clear() { - this._map.clear(); - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an Object value - * @return the removed value, or Integer(0) if it was not found in the map - */ - @Override // GemStoneAddition - public Object remove(Object key) { - return wrapValue(_map.remove(unwrapKey(key))); - } - - /** - * Returns a Set view on the entries of the map. - * - * @return a Set value - */ - @Override // GemStoneAddition - public Set entrySet() { - return new AbstractSet() { - @Override // GemStoneAddition - public int size() { - return _map.size(); - } - @Override // GemStoneAddition - public boolean isEmpty() { - return TFloatLongHashMapDecorator.this.isEmpty(); - } - @Override // GemStoneAddition - public boolean contains(Object o) { - if (o instanceof Map.Entry) { - Object k = ((Map.Entry)o).getKey(); - Object v = ((Map.Entry)o).getValue(); - return (TFloatLongHashMapDecorator.this.containsKey(k) && - TFloatLongHashMapDecorator.this.get(k).equals(v)); - } else { - return false; - } - } - @Override // GemStoneAddition - public Iterator iterator() { - return new Iterator() { - private final TFloatLongIterator it = _map.iterator(); - - public Object next() { - it.advance(); - final Object key = wrapKey(it.key()); - final Object v = wrapValue(it.value()); - return new Map.Entry() { - private Object val = v; - @Override // GemStoneAddition - public boolean equals(Object o) { - return ((o instanceof Map.Entry) && - ((Map.Entry)o).getKey().equals(key) && - ((Map.Entry)o).getValue().equals(val)); - } - public Object getKey() { - return key; - } - public Object getValue() { - return val; - } - @Override // GemStoneAddition - public int hashCode() { - return key.hashCode() + val.hashCode(); - } - public Object setValue(Object value) { - val = value; - return put(key, value); - } - }; - } - - public boolean hasNext() { - return it.hasNext(); - } - - public void remove() { - it.remove(); - } - }; - } - @Override // GemStoneAddition - public boolean add(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean addAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean retainAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean removeAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public void clear() { - TFloatLongHashMapDecorator.this.clear(); - } - }; - } - - /** - * Checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsValue(Object val) { - return _map.containsValue(unwrapValue(val)); - } - - /** - * Checks for the present of key in the keys of the map. - * - * @param key an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsKey(Object key) { - return _map.containsKey(unwrapKey(key)); - } - - /** - * Returns the number of entries in the map. - * @return the map's size. - */ - @Override // GemStoneAddition - public int size() { - return this._map.size(); - } - - /** - * Indicates whether map has any entries. - * @return true if the map is empty - */ - @Override // GemStoneAddition - public boolean isEmpty() { - return (size() == 0); - } - - /** - * Copies the key/value mappings in map into this map. - * Note that this will be a deep copy, as storage is by - * primitive value. - * - * @param map a Map value - */ - @Override // GemStoneAddition - public void putAll(Map map) { - Iterator it = map.entrySet().iterator(); - for (int i = map.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - this.put(e.getKey(), e.getValue()); - } - } - - /** - * Wraps a key - * - * @param k a key in the underlying map - * @return an Object representation of the key - */ - protected Float wrapKey(float k) { - return new Float(k); - } - - /** - * Unwraps a key - * - * @param key a wrapped key - * @return an unwrapped representation of the key - */ - protected float unwrapKey(Object key) { - return ((Float)key).floatValue(); - } - /** - * Wraps a value - * - * @param k a value in the underlying map - * @return an Object representation of the value - */ - protected Long wrapValue(long k) { - return Long.valueOf(k); - } - - /** - * Unwraps a value - * - * @param value a wrapped value - * @return an unwrapped representation of the value - */ - protected long unwrapValue(Object value) { - return ((Long)value).longValue(); - } - -} // TFloatLongHashMapDecorator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TFloatObjectHashMapDecorator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TFloatObjectHashMapDecorator.java deleted file mode 100644 index 33313fb56..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TFloatObjectHashMapDecorator.java +++ /dev/null @@ -1,374 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.decorator; - -import com.gemstone.gnu.trove.TFloatObjectHashMap; -import com.gemstone.gnu.trove.TFloatObjectIterator; -import java.util.AbstractMap; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -//import java.util.Map.Entry; -import java.util.Map; -import java.util.Set; - -/** - * Wrapper class to make a TFloatObjectHashMap conform to the java.util.Map API. - * This class simply decorates an underlying TFloatObjectHashMap and translates the Object-based - * APIs into their Trove primitive analogs. - * - *

- * Note that wrapping and unwrapping primitive values is extremely inefficient. If - * possible, users of this class should override the appropriate methods in this class - * and use a table of canonical values. - *

- * - * Created: Mon Sep 23 22:07:40 PDT 2002 - * - * @author Eric D. Friedman - * @version $Id: TFloatObjectHashMapDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $ - * @since trove 0.1.8 - */ -public class TFloatObjectHashMapDecorator extends AbstractMap implements Map, Cloneable { - /** the wrapped primitive map */ - protected TFloatObjectHashMap _map; - - /** - * Creates a wrapper that decorates the specified primitive map. - */ - public TFloatObjectHashMapDecorator(TFloatObjectHashMap map) { - super(); - this._map = map; - } - - /** - * Clones the underlying trove collection and returns the clone wrapped in a new - * decorator instance. This is a shallow clone except where primitives are - * concerned. - * - * @return a copy of the receiver - */ - @Override // GemStoneAddition - public Object clone() { - try { - TFloatObjectHashMapDecorator copy = (TFloatObjectHashMapDecorator) super.clone(); - copy._map = (TFloatObjectHashMap)_map.clone(); - return copy; - } catch (CloneNotSupportedException e) { - // assert(false); - throw new InternalError(); // we are cloneable, so this does not happen - } - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an Object value - * @param value an Object value - * @return the previous value associated with key, - * or Integer(0) if none was found. - */ - @Override // GemStoneAddition - public Object put(Object key, Object value) { - return wrapValue(_map.put(unwrapKey(key), unwrapValue(value))); - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return true if the maps are identical - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (_map.equals(other)) { - return true; // comparing two trove maps - } else if (other instanceof Map) { - Map that = (Map)other; - if (that.size() != _map.size()) { - return false; // different sizes, no need to compare - } else { // now we have to do it the hard way - Iterator it = that.entrySet().iterator(); - for (int i = that.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - Object key = e.getKey(); - Object val = e.getValue(); - if (key instanceof Float) { - float k = unwrapKey(key); - Object v = unwrapValue(val); - if (_map.containsKey(k) && v == _map.get(k)) { - // match, ok to continue - } else { - return false; // no match: we're done - } - } else { - return false; // different type in other map - } - } - return true; // all entries match - } - } else { - return false; - } - } - - /** - * Retrieves the value for key - * - * @param key an Object value - * @return the value of key or null if no such mapping exists. - */ - @Override // GemStoneAddition - public Object get(Object key) { - return _map.get(unwrapKey(key)); - } - - - /** - * Empties the map. - */ - @Override // GemStoneAddition - public void clear() { - this._map.clear(); - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an Object value - * @return the removed value, or Integer(0) if it was not found in the map - */ - @Override // GemStoneAddition - public Object remove(Object key) { - return wrapValue(_map.remove(unwrapKey(key))); - } - - /** - * Returns a Set view on the entries of the map. - * - * @return a Set value - */ - @Override // GemStoneAddition - public Set entrySet() { - return new AbstractSet() { - @Override // GemStoneAddition - public int size() { - return _map.size(); - } - @Override // GemStoneAddition - public boolean isEmpty() { - return TFloatObjectHashMapDecorator.this.isEmpty(); - } - @Override // GemStoneAddition - public boolean contains(Object o) { - if (o instanceof Map.Entry) { - Object k = ((Map.Entry)o).getKey(); - Object v = ((Map.Entry)o).getValue(); - return (TFloatObjectHashMapDecorator.this.containsKey(k) && - TFloatObjectHashMapDecorator.this.get(k).equals(v)); - } else { - return false; - } - } - @Override // GemStoneAddition - public Iterator iterator() { - return new Iterator() { - private final TFloatObjectIterator it = _map.iterator(); - - public Object next() { - it.advance(); - final Object key = wrapKey(it.key()); - final Object v = wrapValue(it.value()); - return new Map.Entry() { - private Object val = v; - @Override // GemStoneAddition - public boolean equals(Object o) { - return ((o instanceof Map.Entry) && - ((Map.Entry)o).getKey().equals(key) && - ((Map.Entry)o).getValue().equals(val)); - } - public Object getKey() { - return key; - } - public Object getValue() { - return val; - } - @Override // GemStoneAddition - public int hashCode() { - return key.hashCode() + val.hashCode(); - } - public Object setValue(Object value) { - val = value; - return put(key, value); - } - }; - } - - public boolean hasNext() { - return it.hasNext(); - } - - public void remove() { - it.remove(); - } - }; - } - @Override // GemStoneAddition - public boolean add(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean addAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean retainAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean removeAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public void clear() { - TFloatObjectHashMapDecorator.this.clear(); - } - }; - } - - /** - * Checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsValue(Object val) { - return _map.containsValue(unwrapValue(val)); - } - - /** - * Checks for the present of key in the keys of the map. - * - * @param key an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsKey(Object key) { - return _map.containsKey(unwrapKey(key)); - } - - /** - * Returns the number of entries in the map. - * @return the map's size. - */ - @Override // GemStoneAddition - public int size() { - return this._map.size(); - } - - /** - * Indicates whether map has any entries. - * @return true if the map is empty - */ - @Override // GemStoneAddition - public boolean isEmpty() { - return (size() == 0); - } - - /** - * Copies the key/value mappings in map into this map. - * Note that this will be a deep copy, as storage is by - * primitive value. - * - * @param map a Map value - */ - @Override // GemStoneAddition - public void putAll(Map map) { - Iterator it = map.entrySet().iterator(); - for (int i = map.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - this.put(e.getKey(), e.getValue()); - } - } - - /** - * Wraps a key - * - * @param k a key in the underlying map - * @return an Object representation of the key - */ - protected Float wrapKey(float k) { - return new Float(k); - } - - /** - * Unwraps a key - * - * @param key a wrapped key - * @return an unwrapped representation of the key - */ - protected float unwrapKey(Object key) { - return ((Float)key).floatValue(); - } - /** - * Wraps a value - * - * @param o a value in the underlying map - * @return an Object representation of the value - */ - protected final Object wrapValue(Object o) { - return o; - } - - /** - * Unwraps a value - * - * @param value a wrapped value - * @return an unwrapped representation of the value - */ - protected final Object unwrapValue(Object value) { - return value; - } - -} // TFloatObjectHashMapDecorator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TIntDoubleHashMapDecorator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TIntDoubleHashMapDecorator.java deleted file mode 100644 index 23361760b..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TIntDoubleHashMapDecorator.java +++ /dev/null @@ -1,383 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.decorator; - -import com.gemstone.gnu.trove.TIntDoubleHashMap; -import com.gemstone.gnu.trove.TIntDoubleIterator; -import java.util.AbstractMap; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -//import java.util.Map.Entry; -import java.util.Map; -import java.util.Set; - -/** - * Wrapper class to make a TIntDoubleHashMap conform to the java.util.Map API. - * This class simply decorates an underlying TIntDoubleHashMap and translates the Object-based - * APIs into their Trove primitive analogs. - * - *

- * Note that wrapping and unwrapping primitive values is extremely inefficient. If - * possible, users of this class should override the appropriate methods in this class - * and use a table of canonical values. - *

- * - * Created: Mon Sep 23 22:07:40 PDT 2002 - * - * @author Eric D. Friedman - * @version $Id: TIntDoubleHashMapDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $ - * @since trove 0.1.8 - */ -public class TIntDoubleHashMapDecorator extends AbstractMap implements Map, Cloneable { - /** the wrapped primitive map */ - protected TIntDoubleHashMap _map; - - /** - * Creates a wrapper that decorates the specified primitive map. - */ - public TIntDoubleHashMapDecorator(TIntDoubleHashMap map) { - super(); - this._map = map; - } - - /** - * Clones the underlying trove collection and returns the clone wrapped in a new - * decorator instance. This is a shallow clone except where primitives are - * concerned. - * - * @return a copy of the receiver - */ - @Override // GemStoneAddition - public Object clone() { - try { - TIntDoubleHashMapDecorator copy = (TIntDoubleHashMapDecorator) super.clone(); - copy._map = (TIntDoubleHashMap)_map.clone(); - return copy; - } catch (CloneNotSupportedException e) { - // assert(false); - throw new InternalError(); // we are cloneable, so this does not happen - } - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an Object value - * @param value an Object value - * @return the previous value associated with key, - * or Integer(0) if none was found. - */ - @Override // GemStoneAddition - public Object put(Object key, Object value) { - return wrapValue(_map.put(unwrapKey(key), unwrapValue(value))); - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return true if the maps are identical - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (_map.equals(other)) { - return true; // comparing two trove maps - } else if (other instanceof Map) { - Map that = (Map)other; - if (that.size() != _map.size()) { - return false; // different sizes, no need to compare - } else { // now we have to do it the hard way - Iterator it = that.entrySet().iterator(); - for (int i = that.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - Object key = e.getKey(); - Object val = e.getValue(); - if (key instanceof Integer && val instanceof Double) { - int k = unwrapKey(key); - double v = unwrapValue(val); - if (_map.containsKey(k) && v == _map.get(k)) { - // match, ok to continue - } else { - return false; // no match: we're done - } - } else { - return false; // different type in other map - } - } - return true; // all entries match - } - } else { - return false; - } - } - - /** - * Retrieves the value for key - * - * @param key an Object value - * @return the value of key or null if no such mapping exists. - */ - @Override // GemStoneAddition - public Object get(Object key) { - int k = unwrapKey(key); - double v = _map.get(k); - // 0 may be a false positive since primitive maps - // cannot return null, so we have to do an extra - // check here. - if (v == 0) { - return _map.containsKey(k) ? wrapValue(v) : null; - } else { - return wrapValue(v); - } - } - - - /** - * Empties the map. - */ - @Override // GemStoneAddition - public void clear() { - this._map.clear(); - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an Object value - * @return the removed value, or Integer(0) if it was not found in the map - */ - @Override // GemStoneAddition - public Object remove(Object key) { - return wrapValue(_map.remove(unwrapKey(key))); - } - - /** - * Returns a Set view on the entries of the map. - * - * @return a Set value - */ - @Override // GemStoneAddition - public Set entrySet() { - return new AbstractSet() { - @Override // GemStoneAddition - public int size() { - return _map.size(); - } - @Override // GemStoneAddition - public boolean isEmpty() { - return TIntDoubleHashMapDecorator.this.isEmpty(); - } - @Override // GemStoneAddition - public boolean contains(Object o) { - if (o instanceof Map.Entry) { - Object k = ((Map.Entry)o).getKey(); - Object v = ((Map.Entry)o).getValue(); - return (TIntDoubleHashMapDecorator.this.containsKey(k) && - TIntDoubleHashMapDecorator.this.get(k).equals(v)); - } else { - return false; - } - } - @Override // GemStoneAddition - public Iterator iterator() { - return new Iterator() { - private final TIntDoubleIterator it = _map.iterator(); - - public Object next() { - it.advance(); - final Object key = wrapKey(it.key()); - final Object v = wrapValue(it.value()); - return new Map.Entry() { - private Object val = v; - @Override // GemStoneAddition - public boolean equals(Object o) { - return ((o instanceof Map.Entry) && - ((Map.Entry)o).getKey().equals(key) && - ((Map.Entry)o).getValue().equals(val)); - } - public Object getKey() { - return key; - } - public Object getValue() { - return val; - } - @Override // GemStoneAddition - public int hashCode() { - return key.hashCode() + val.hashCode(); - } - public Object setValue(Object value) { - val = value; - return put(key, value); - } - }; - } - - public boolean hasNext() { - return it.hasNext(); - } - - public void remove() { - it.remove(); - } - }; - } - @Override // GemStoneAddition - public boolean add(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean addAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean retainAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean removeAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public void clear() { - TIntDoubleHashMapDecorator.this.clear(); - } - }; - } - - /** - * Checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsValue(Object val) { - return _map.containsValue(unwrapValue(val)); - } - - /** - * Checks for the present of key in the keys of the map. - * - * @param key an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsKey(Object key) { - return _map.containsKey(unwrapKey(key)); - } - - /** - * Returns the number of entries in the map. - * @return the map's size. - */ - @Override // GemStoneAddition - public int size() { - return this._map.size(); - } - - /** - * Indicates whether map has any entries. - * @return true if the map is empty - */ - @Override // GemStoneAddition - public boolean isEmpty() { - return (size() == 0); - } - - /** - * Copies the key/value mappings in map into this map. - * Note that this will be a deep copy, as storage is by - * primitive value. - * - * @param map a Map value - */ - @Override // GemStoneAddition - public void putAll(Map map) { - Iterator it = map.entrySet().iterator(); - for (int i = map.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - this.put(e.getKey(), e.getValue()); - } - } - - /** - * Wraps a key - * - * @param k a key in the underlying map - * @return an Object representation of the key - */ - protected Integer wrapKey(int k) { - return Integer.valueOf(k); - } - - /** - * Unwraps a key - * - * @param key a wrapped key - * @return an unwrapped representation of the key - */ - protected int unwrapKey(Object key) { - return ((Integer)key).intValue(); - } - /** - * Wraps a value - * - * @param k a value in the underlying map - * @return an Object representation of the value - */ - protected Double wrapValue(double k) { - return Double.valueOf(k); - } - - /** - * Unwraps a value - * - * @param value a wrapped value - * @return an unwrapped representation of the value - */ - protected double unwrapValue(Object value) { - return ((Double)value).doubleValue(); - } - -} // TIntDoubleHashMapDecorator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TIntFloatHashMapDecorator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TIntFloatHashMapDecorator.java deleted file mode 100644 index e2b27cc77..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TIntFloatHashMapDecorator.java +++ /dev/null @@ -1,383 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.decorator; - -import com.gemstone.gnu.trove.TIntFloatHashMap; -import com.gemstone.gnu.trove.TIntFloatIterator; -import java.util.AbstractMap; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -//import java.util.Map.Entry; -import java.util.Map; -import java.util.Set; - -/** - * Wrapper class to make a TIntFloatHashMap conform to the java.util.Map API. - * This class simply decorates an underlying TIntFloatHashMap and translates the Object-based - * APIs into their Trove primitive analogs. - * - *

- * Note that wrapping and unwrapping primitive values is extremely inefficient. If - * possible, users of this class should override the appropriate methods in this class - * and use a table of canonical values. - *

- * - * Created: Mon Sep 23 22:07:40 PDT 2002 - * - * @author Eric D. Friedman - * @version $Id: TIntFloatHashMapDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $ - * @since trove 0.1.8 - */ -public class TIntFloatHashMapDecorator extends AbstractMap implements Map, Cloneable { - /** the wrapped primitive map */ - protected TIntFloatHashMap _map; - - /** - * Creates a wrapper that decorates the specified primitive map. - */ - public TIntFloatHashMapDecorator(TIntFloatHashMap map) { - super(); - this._map = map; - } - - /** - * Clones the underlying trove collection and returns the clone wrapped in a new - * decorator instance. This is a shallow clone except where primitives are - * concerned. - * - * @return a copy of the receiver - */ - @Override // GemStoneAddition - public Object clone() { - try { - TIntFloatHashMapDecorator copy = (TIntFloatHashMapDecorator) super.clone(); - copy._map = (TIntFloatHashMap)_map.clone(); - return copy; - } catch (CloneNotSupportedException e) { - // assert(false); - throw new InternalError(); // we are cloneable, so this does not happen - } - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an Object value - * @param value an Object value - * @return the previous value associated with key, - * or Integer(0) if none was found. - */ - @Override // GemStoneAddition - public Object put(Object key, Object value) { - return wrapValue(_map.put(unwrapKey(key), unwrapValue(value))); - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return true if the maps are identical - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (_map.equals(other)) { - return true; // comparing two trove maps - } else if (other instanceof Map) { - Map that = (Map)other; - if (that.size() != _map.size()) { - return false; // different sizes, no need to compare - } else { // now we have to do it the hard way - Iterator it = that.entrySet().iterator(); - for (int i = that.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - Object key = e.getKey(); - Object val = e.getValue(); - if (key instanceof Integer && val instanceof Float) { - int k = unwrapKey(key); - float v = unwrapValue(val); - if (_map.containsKey(k) && v == _map.get(k)) { - // match, ok to continue - } else { - return false; // no match: we're done - } - } else { - return false; // different type in other map - } - } - return true; // all entries match - } - } else { - return false; - } - } - - /** - * Retrieves the value for key - * - * @param key an Object value - * @return the value of key or null if no such mapping exists. - */ - @Override // GemStoneAddition - public Object get(Object key) { - int k = unwrapKey(key); - float v = _map.get(k); - // 0 may be a false positive since primitive maps - // cannot return null, so we have to do an extra - // check here. - if (v == 0) { - return _map.containsKey(k) ? wrapValue(v) : null; - } else { - return wrapValue(v); - } - } - - - /** - * Empties the map. - */ - @Override // GemStoneAddition - public void clear() { - this._map.clear(); - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an Object value - * @return the removed value, or Integer(0) if it was not found in the map - */ - @Override // GemStoneAddition - public Object remove(Object key) { - return wrapValue(_map.remove(unwrapKey(key))); - } - - /** - * Returns a Set view on the entries of the map. - * - * @return a Set value - */ - @Override // GemStoneAddition - public Set entrySet() { - return new AbstractSet() { - @Override // GemStoneAddition - public int size() { - return _map.size(); - } - @Override // GemStoneAddition - public boolean isEmpty() { - return TIntFloatHashMapDecorator.this.isEmpty(); - } - @Override // GemStoneAddition - public boolean contains(Object o) { - if (o instanceof Map.Entry) { - Object k = ((Map.Entry)o).getKey(); - Object v = ((Map.Entry)o).getValue(); - return (TIntFloatHashMapDecorator.this.containsKey(k) && - TIntFloatHashMapDecorator.this.get(k).equals(v)); - } else { - return false; - } - } - @Override // GemStoneAddition - public Iterator iterator() { - return new Iterator() { - private final TIntFloatIterator it = _map.iterator(); - - public Object next() { - it.advance(); - final Object key = wrapKey(it.key()); - final Object v = wrapValue(it.value()); - return new Map.Entry() { - private Object val = v; - @Override // GemStoneAddition - public boolean equals(Object o) { - return ((o instanceof Map.Entry) && - ((Map.Entry)o).getKey().equals(key) && - ((Map.Entry)o).getValue().equals(val)); - } - public Object getKey() { - return key; - } - public Object getValue() { - return val; - } - @Override // GemStoneAddition - public int hashCode() { - return key.hashCode() + val.hashCode(); - } - public Object setValue(Object value) { - val = value; - return put(key, value); - } - }; - } - - public boolean hasNext() { - return it.hasNext(); - } - - public void remove() { - it.remove(); - } - }; - } - @Override // GemStoneAddition - public boolean add(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean addAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean retainAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean removeAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public void clear() { - TIntFloatHashMapDecorator.this.clear(); - } - }; - } - - /** - * Checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsValue(Object val) { - return _map.containsValue(unwrapValue(val)); - } - - /** - * Checks for the present of key in the keys of the map. - * - * @param key an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsKey(Object key) { - return _map.containsKey(unwrapKey(key)); - } - - /** - * Returns the number of entries in the map. - * @return the map's size. - */ - @Override // GemStoneAddition - public int size() { - return this._map.size(); - } - - /** - * Indicates whether map has any entries. - * @return true if the map is empty - */ - @Override // GemStoneAddition - public boolean isEmpty() { - return (size() == 0); - } - - /** - * Copies the key/value mappings in map into this map. - * Note that this will be a deep copy, as storage is by - * primitive value. - * - * @param map a Map value - */ - @Override // GemStoneAddition - public void putAll(Map map) { - Iterator it = map.entrySet().iterator(); - for (int i = map.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - this.put(e.getKey(), e.getValue()); - } - } - - /** - * Wraps a key - * - * @param k a key in the underlying map - * @return an Object representation of the key - */ - protected Integer wrapKey(int k) { - return Integer.valueOf(k); - } - - /** - * Unwraps a key - * - * @param key a wrapped key - * @return an unwrapped representation of the key - */ - protected int unwrapKey(Object key) { - return ((Integer)key).intValue(); - } - /** - * Wraps a value - * - * @param k a value in the underlying map - * @return an Object representation of the value - */ - protected Float wrapValue(float k) { - return new Float(k); - } - - /** - * Unwraps a value - * - * @param value a wrapped value - * @return an unwrapped representation of the value - */ - protected float unwrapValue(Object value) { - return ((Float)value).floatValue(); - } - -} // TIntFloatHashMapDecorator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TIntHashSetDecorator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TIntHashSetDecorator.java deleted file mode 100644 index c48ef1fc3..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TIntHashSetDecorator.java +++ /dev/null @@ -1,222 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.decorator; - -import com.gemstone.gnu.trove.TIntHashSet; -import com.gemstone.gnu.trove.TIntIterator; -import java.util.AbstractSet; -//import java.util.Collection; -import java.util.Iterator; -import java.util.Set; - -/** - * Wrapper class to make a TIntHashSet conform to the java.util.Set API. - * This class simply decorates an underlying TIntHashSet and translates the Object-based - * APIs into their Trove primitive analogs. - * - *

- * Note that wrapping and unwrapping primitive values is extremely inefficient. If - * possible, users of this class should override the appropriate methods in this class - * and use a table of canonical values. - *

- * - * Created: Tue Sep 24 22:08:17 PDT 2002 - * - * @author Eric D. Friedman - * @version $Id: TIntHashSetDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $ - * @since trove 0.1.8 - */ -public class TIntHashSetDecorator extends AbstractSet implements Set, Cloneable { - /** the wrapped primitive set */ - protected TIntHashSet _set; - - /** - * Creates a wrapper that decorates the specified primitive set. - */ - public TIntHashSetDecorator(TIntHashSet set) { - super(); - this._set = set; - } - - /** - * Clones the underlying trove collection and returns the clone wrapped in a new - * decorator instance. This is a shallow clone except where primitives are - * concerned. - * - * @return a copy of the receiver - */ - @Override // GemStoneAddition - public Object clone() { - try { - TIntHashSetDecorator copy = (TIntHashSetDecorator) super.clone(); - copy._set = (TIntHashSet) _set.clone(); - return copy; - } catch (CloneNotSupportedException e) { - // assert(false); - throw new InternalError(); // we are cloneable - } - } - - /** - * Inserts a value into the set. - * - * @return true if the set was modified by the insertion - */ - @Override // GemStoneAddition - public boolean add(Object value) { - return _set.add(unwrap(value)); - } - - /** - * Compares this set with another set for equality of their stored - * entries. - * - * @param other an Object value - * @return true if the sets are identical - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (_set.equals(other)) { - return true; // comparing two trove sets - } else if (other instanceof Set) { - Set that = (Set)other; - if (that.size() != _set.size()) { - return false; // different sizes, no need to compare - } else { // now we have to do it the hard way - Iterator it = that.iterator(); - for (int i = that.size(); i-- > 0;) { - Object val = it.next(); - if (val instanceof Integer) { - int v = unwrap(val); - if (_set.contains(v)) { - // match, ok to continue - } else { - return false; // no match: we're done - } - } else { - return false; // different type in other set - } - } - return true; // all entries match - } - } else { - return false; - } - } - - /** - * Empties the set. - */ - @Override // GemStoneAddition - public void clear() { - this._set.clear(); - } - - /** - * Deletes a value from the set. - * - * @param value an Object value - * @return true if the set was modified - */ - @Override // GemStoneAddition - public boolean remove(Object value) { - return _set.remove(unwrap(value)); - } - - /** - * Creates an iterator over the values of the set. - * - * @return an iterator with support for removals in the underlying set - */ - @Override // GemStoneAddition - public Iterator iterator() { - return new Iterator() { - private final TIntIterator it = _set.iterator(); - - public Object next() { - return wrap(it.next()); - } - - public boolean hasNext() { - return it.hasNext(); - } - - public void remove() { - it.remove(); - } - }; - } - - /** - * Returns the number of entries in the set. - * @return the set's size. - */ - @Override // GemStoneAddition - public int size() { - return this._set.size(); - } - - /** - * Indicates whether set has any entries. - * @return true if the set is empty - */ - @Override // GemStoneAddition - public boolean isEmpty() { - return (size() == 0); - } - - /** - * Wraps a value - * - * @param k a value in the underlying set - * @return an Object representation of the value - */ - protected Integer wrap(int k) { - return Integer.valueOf(k); - } - - /** - * Unwraps a value - * - * @param value a wrapped value - * @return an unwrapped representation of the value - */ - protected int unwrap(Object value) { - return ((Integer)value).intValue(); - } -} // TIntHashSetDecorator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TIntIntHashMapDecorator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TIntIntHashMapDecorator.java deleted file mode 100644 index 9156cb03d..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TIntIntHashMapDecorator.java +++ /dev/null @@ -1,383 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.decorator; - -import com.gemstone.gnu.trove.TIntIntHashMap; -import com.gemstone.gnu.trove.TIntIntIterator; -import java.util.AbstractMap; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -//import java.util.Map.Entry; -import java.util.Map; -import java.util.Set; - -/** - * Wrapper class to make a TIntIntHashMap conform to the java.util.Map API. - * This class simply decorates an underlying TIntIntHashMap and translates the Object-based - * APIs into their Trove primitive analogs. - * - *

- * Note that wrapping and unwrapping primitive values is extremely inefficient. If - * possible, users of this class should override the appropriate methods in this class - * and use a table of canonical values. - *

- * - * Created: Mon Sep 23 22:07:40 PDT 2002 - * - * @author Eric D. Friedman - * @version $Id: TIntIntHashMapDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $ - * @since trove 0.1.8 - */ -public class TIntIntHashMapDecorator extends AbstractMap implements Map, Cloneable { - /** the wrapped primitive map */ - protected TIntIntHashMap _map; - - /** - * Creates a wrapper that decorates the specified primitive map. - */ - public TIntIntHashMapDecorator(TIntIntHashMap map) { - super(); - this._map = map; - } - - /** - * Clones the underlying trove collection and returns the clone wrapped in a new - * decorator instance. This is a shallow clone except where primitives are - * concerned. - * - * @return a copy of the receiver - */ - @Override // GemStoneAddition - public Object clone() { - try { - TIntIntHashMapDecorator copy = (TIntIntHashMapDecorator) super.clone(); - copy._map = (TIntIntHashMap)_map.clone(); - return copy; - } catch (CloneNotSupportedException e) { - // assert(false); - throw new InternalError(); // we are cloneable, so this does not happen - } - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an Object value - * @param value an Object value - * @return the previous value associated with key, - * or Integer(0) if none was found. - */ - @Override // GemStoneAddition - public Object put(Object key, Object value) { - return wrapValue(_map.put(unwrapKey(key), unwrapValue(value))); - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return true if the maps are identical - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (_map.equals(other)) { - return true; // comparing two trove maps - } else if (other instanceof Map) { - Map that = (Map)other; - if (that.size() != _map.size()) { - return false; // different sizes, no need to compare - } else { // now we have to do it the hard way - Iterator it = that.entrySet().iterator(); - for (int i = that.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - Object key = e.getKey(); - Object val = e.getValue(); - if (key instanceof Integer && val instanceof Integer) { - int k = unwrapKey(key); - int v = unwrapValue(val); - if (_map.containsKey(k) && v == _map.get(k)) { - // match, ok to continue - } else { - return false; // no match: we're done - } - } else { - return false; // different type in other map - } - } - return true; // all entries match - } - } else { - return false; - } - } - - /** - * Retrieves the value for key - * - * @param key an Object value - * @return the value of key or null if no such mapping exists. - */ - @Override // GemStoneAddition - public Object get(Object key) { - int k = unwrapKey(key); - int v = _map.get(k); - // 0 may be a false positive since primitive maps - // cannot return null, so we have to do an extra - // check here. - if (v == 0) { - return _map.containsKey(k) ? wrapValue(v) : null; - } else { - return wrapValue(v); - } - } - - - /** - * Empties the map. - */ - @Override // GemStoneAddition - public void clear() { - this._map.clear(); - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an Object value - * @return the removed value, or Integer(0) if it was not found in the map - */ - @Override // GemStoneAddition - public Object remove(Object key) { - return wrapValue(_map.remove(unwrapKey(key))); - } - - /** - * Returns a Set view on the entries of the map. - * - * @return a Set value - */ - @Override // GemStoneAddition - public Set entrySet() { - return new AbstractSet() { - @Override // GemStoneAddition - public int size() { - return _map.size(); - } - @Override // GemStoneAddition - public boolean isEmpty() { - return TIntIntHashMapDecorator.this.isEmpty(); - } - @Override // GemStoneAddition - public boolean contains(Object o) { - if (o instanceof Map.Entry) { - Object k = ((Map.Entry)o).getKey(); - Object v = ((Map.Entry)o).getValue(); - return (TIntIntHashMapDecorator.this.containsKey(k) && - TIntIntHashMapDecorator.this.get(k).equals(v)); - } else { - return false; - } - } - @Override // GemStoneAddition - public Iterator iterator() { - return new Iterator() { - private final TIntIntIterator it = _map.iterator(); - - public Object next() { - it.advance(); - final Object key = wrapKey(it.key()); - final Object v = wrapValue(it.value()); - return new Map.Entry() { - private Object val = v; - @Override // GemStoneAddition - public boolean equals(Object o) { - return ((o instanceof Map.Entry) && - ((Map.Entry)o).getKey().equals(key) && - ((Map.Entry)o).getValue().equals(val)); - } - public Object getKey() { - return key; - } - public Object getValue() { - return val; - } - @Override // GemStoneAddition - public int hashCode() { - return key.hashCode() + val.hashCode(); - } - public Object setValue(Object value) { - val = value; - return put(key, value); - } - }; - } - - public boolean hasNext() { - return it.hasNext(); - } - - public void remove() { - it.remove(); - } - }; - } - @Override // GemStoneAddition - public boolean add(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean addAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean retainAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean removeAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public void clear() { - TIntIntHashMapDecorator.this.clear(); - } - }; - } - - /** - * Checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsValue(Object val) { - return _map.containsValue(unwrapValue(val)); - } - - /** - * Checks for the present of key in the keys of the map. - * - * @param key an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsKey(Object key) { - return _map.containsKey(unwrapKey(key)); - } - - /** - * Returns the number of entries in the map. - * @return the map's size. - */ - @Override // GemStoneAddition - public int size() { - return this._map.size(); - } - - /** - * Indicates whether map has any entries. - * @return true if the map is empty - */ - @Override // GemStoneAddition - public boolean isEmpty() { - return (size() == 0); - } - - /** - * Copies the key/value mappings in map into this map. - * Note that this will be a deep copy, as storage is by - * primitive value. - * - * @param map a Map value - */ - @Override // GemStoneAddition - public void putAll(Map map) { - Iterator it = map.entrySet().iterator(); - for (int i = map.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - this.put(e.getKey(), e.getValue()); - } - } - - /** - * Wraps a key - * - * @param k a key in the underlying map - * @return an Object representation of the key - */ - protected Integer wrapKey(int k) { - return Integer.valueOf(k); - } - - /** - * Unwraps a key - * - * @param key a wrapped key - * @return an unwrapped representation of the key - */ - protected int unwrapKey(Object key) { - return ((Integer)key).intValue(); - } - /** - * Wraps a value - * - * @param k a value in the underlying map - * @return an Object representation of the value - */ - protected Integer wrapValue(int k) { - return Integer.valueOf(k); - } - - /** - * Unwraps a value - * - * @param value a wrapped value - * @return an unwrapped representation of the value - */ - protected int unwrapValue(Object value) { - return ((Integer)value).intValue(); - } - -} // TIntIntHashMapDecorator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TIntLongHashMapDecorator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TIntLongHashMapDecorator.java deleted file mode 100644 index aabdb9124..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TIntLongHashMapDecorator.java +++ /dev/null @@ -1,383 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.decorator; - -import com.gemstone.gnu.trove.TIntLongHashMap; -import com.gemstone.gnu.trove.TIntLongIterator; -import java.util.AbstractMap; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -//import java.util.Map.Entry; -import java.util.Map; -import java.util.Set; - -/** - * Wrapper class to make a TIntLongHashMap conform to the java.util.Map API. - * This class simply decorates an underlying TIntLongHashMap and translates the Object-based - * APIs into their Trove primitive analogs. - * - *

- * Note that wrapping and unwrapping primitive values is extremely inefficient. If - * possible, users of this class should override the appropriate methods in this class - * and use a table of canonical values. - *

- * - * Created: Mon Sep 23 22:07:40 PDT 2002 - * - * @author Eric D. Friedman - * @version $Id: TIntLongHashMapDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $ - * @since trove 0.1.8 - */ -public class TIntLongHashMapDecorator extends AbstractMap implements Map, Cloneable { - /** the wrapped primitive map */ - protected TIntLongHashMap _map; - - /** - * Creates a wrapper that decorates the specified primitive map. - */ - public TIntLongHashMapDecorator(TIntLongHashMap map) { - super(); - this._map = map; - } - - /** - * Clones the underlying trove collection and returns the clone wrapped in a new - * decorator instance. This is a shallow clone except where primitives are - * concerned. - * - * @return a copy of the receiver - */ - @Override // GemStoneAddition - public Object clone() { - try { - TIntLongHashMapDecorator copy = (TIntLongHashMapDecorator) super.clone(); - copy._map = (TIntLongHashMap)_map.clone(); - return copy; - } catch (CloneNotSupportedException e) { - // assert(false); - throw new InternalError(); // we are cloneable, so this does not happen - } - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an Object value - * @param value an Object value - * @return the previous value associated with key, - * or Integer(0) if none was found. - */ - @Override // GemStoneAddition - public Object put(Object key, Object value) { - return wrapValue(_map.put(unwrapKey(key), unwrapValue(value))); - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return true if the maps are identical - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (_map.equals(other)) { - return true; // comparing two trove maps - } else if (other instanceof Map) { - Map that = (Map)other; - if (that.size() != _map.size()) { - return false; // different sizes, no need to compare - } else { // now we have to do it the hard way - Iterator it = that.entrySet().iterator(); - for (int i = that.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - Object key = e.getKey(); - Object val = e.getValue(); - if (key instanceof Integer && val instanceof Long) { - int k = unwrapKey(key); - long v = unwrapValue(val); - if (_map.containsKey(k) && v == _map.get(k)) { - // match, ok to continue - } else { - return false; // no match: we're done - } - } else { - return false; // different type in other map - } - } - return true; // all entries match - } - } else { - return false; - } - } - - /** - * Retrieves the value for key - * - * @param key an Object value - * @return the value of key or null if no such mapping exists. - */ - @Override // GemStoneAddition - public Object get(Object key) { - int k = unwrapKey(key); - long v = _map.get(k); - // 0 may be a false positive since primitive maps - // cannot return null, so we have to do an extra - // check here. - if (v == 0) { - return _map.containsKey(k) ? wrapValue(v) : null; - } else { - return wrapValue(v); - } - } - - - /** - * Empties the map. - */ - @Override // GemStoneAddition - public void clear() { - this._map.clear(); - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an Object value - * @return the removed value, or Integer(0) if it was not found in the map - */ - @Override // GemStoneAddition - public Object remove(Object key) { - return wrapValue(_map.remove(unwrapKey(key))); - } - - /** - * Returns a Set view on the entries of the map. - * - * @return a Set value - */ - @Override // GemStoneAddition - public Set entrySet() { - return new AbstractSet() { - @Override // GemStoneAddition - public int size() { - return _map.size(); - } - @Override // GemStoneAddition - public boolean isEmpty() { - return TIntLongHashMapDecorator.this.isEmpty(); - } - @Override // GemStoneAddition - public boolean contains(Object o) { - if (o instanceof Map.Entry) { - Object k = ((Map.Entry)o).getKey(); - Object v = ((Map.Entry)o).getValue(); - return (TIntLongHashMapDecorator.this.containsKey(k) && - TIntLongHashMapDecorator.this.get(k).equals(v)); - } else { - return false; - } - } - @Override // GemStoneAddition - public Iterator iterator() { - return new Iterator() { - private final TIntLongIterator it = _map.iterator(); - - public Object next() { - it.advance(); - final Object key = wrapKey(it.key()); - final Object v = wrapValue(it.value()); - return new Map.Entry() { - private Object val = v; - @Override // GemStoneAddition - public boolean equals(Object o) { - return ((o instanceof Map.Entry) && - ((Map.Entry)o).getKey().equals(key) && - ((Map.Entry)o).getValue().equals(val)); - } - public Object getKey() { - return key; - } - public Object getValue() { - return val; - } - @Override // GemStoneAddition - public int hashCode() { - return key.hashCode() + val.hashCode(); - } - public Object setValue(Object value) { - val = value; - return put(key, value); - } - }; - } - - public boolean hasNext() { - return it.hasNext(); - } - - public void remove() { - it.remove(); - } - }; - } - @Override // GemStoneAddition - public boolean add(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean addAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean retainAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean removeAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public void clear() { - TIntLongHashMapDecorator.this.clear(); - } - }; - } - - /** - * Checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsValue(Object val) { - return _map.containsValue(unwrapValue(val)); - } - - /** - * Checks for the present of key in the keys of the map. - * - * @param key an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsKey(Object key) { - return _map.containsKey(unwrapKey(key)); - } - - /** - * Returns the number of entries in the map. - * @return the map's size. - */ - @Override // GemStoneAddition - public int size() { - return this._map.size(); - } - - /** - * Indicates whether map has any entries. - * @return true if the map is empty - */ - @Override // GemStoneAddition - public boolean isEmpty() { - return (size() == 0); - } - - /** - * Copies the key/value mappings in map into this map. - * Note that this will be a deep copy, as storage is by - * primitive value. - * - * @param map a Map value - */ - @Override // GemStoneAddition - public void putAll(Map map) { - Iterator it = map.entrySet().iterator(); - for (int i = map.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - this.put(e.getKey(), e.getValue()); - } - } - - /** - * Wraps a key - * - * @param k a key in the underlying map - * @return an Object representation of the key - */ - protected Integer wrapKey(int k) { - return Integer.valueOf(k); - } - - /** - * Unwraps a key - * - * @param key a wrapped key - * @return an unwrapped representation of the key - */ - protected int unwrapKey(Object key) { - return ((Integer)key).intValue(); - } - /** - * Wraps a value - * - * @param k a value in the underlying map - * @return an Object representation of the value - */ - protected Long wrapValue(long k) { - return Long.valueOf(k); - } - - /** - * Unwraps a value - * - * @param value a wrapped value - * @return an unwrapped representation of the value - */ - protected long unwrapValue(Object value) { - return ((Long)value).longValue(); - } - -} // TIntLongHashMapDecorator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TIntObjectHashMapDecorator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TIntObjectHashMapDecorator.java deleted file mode 100644 index 63875f9d8..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TIntObjectHashMapDecorator.java +++ /dev/null @@ -1,374 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.decorator; - -import com.gemstone.gnu.trove.TIntObjectHashMap; -import com.gemstone.gnu.trove.TIntObjectIterator; -import java.util.AbstractMap; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -//import java.util.Map.Entry; -import java.util.Map; -import java.util.Set; - -/** - * Wrapper class to make a TIntObjectHashMap conform to the java.util.Map API. - * This class simply decorates an underlying TIntObjectHashMap and translates the Object-based - * APIs into their Trove primitive analogs. - * - *

- * Note that wrapping and unwrapping primitive values is extremely inefficient. If - * possible, users of this class should override the appropriate methods in this class - * and use a table of canonical values. - *

- * - * Created: Mon Sep 23 22:07:40 PDT 2002 - * - * @author Eric D. Friedman - * @version $Id: TIntObjectHashMapDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $ - * @since trove 0.1.8 - */ -public class TIntObjectHashMapDecorator extends AbstractMap implements Map, Cloneable { - /** the wrapped primitive map */ - protected TIntObjectHashMap _map; - - /** - * Creates a wrapper that decorates the specified primitive map. - */ - public TIntObjectHashMapDecorator(TIntObjectHashMap map) { - super(); - this._map = map; - } - - /** - * Clones the underlying trove collection and returns the clone wrapped in a new - * decorator instance. This is a shallow clone except where primitives are - * concerned. - * - * @return a copy of the receiver - */ - @Override // GemStoneAddition - public Object clone() { - try { - TIntObjectHashMapDecorator copy = (TIntObjectHashMapDecorator) super.clone(); - copy._map = (TIntObjectHashMap)_map.clone(); - return copy; - } catch (CloneNotSupportedException e) { - // assert(false); - throw new InternalError(); // we are cloneable, so this does not happen - } - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an Object value - * @param value an Object value - * @return the previous value associated with key, - * or Integer(0) if none was found. - */ - @Override // GemStoneAddition - public Object put(Object key, Object value) { - return wrapValue(_map.put(unwrapKey(key), unwrapValue(value))); - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return true if the maps are identical - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (_map.equals(other)) { - return true; // comparing two trove maps - } else if (other instanceof Map) { - Map that = (Map)other; - if (that.size() != _map.size()) { - return false; // different sizes, no need to compare - } else { // now we have to do it the hard way - Iterator it = that.entrySet().iterator(); - for (int i = that.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - Object key = e.getKey(); - Object val = e.getValue(); - if (key instanceof Integer) { - int k = unwrapKey(key); - Object v = unwrapValue(val); - if (_map.containsKey(k) && v == _map.get(k)) { - // match, ok to continue - } else { - return false; // no match: we're done - } - } else { - return false; // different type in other map - } - } - return true; // all entries match - } - } else { - return false; - } - } - - /** - * Retrieves the value for key - * - * @param key an Object value - * @return the value of key or null if no such mapping exists. - */ - @Override // GemStoneAddition - public Object get(Object key) { - return _map.get(unwrapKey(key)); - } - - - /** - * Empties the map. - */ - @Override // GemStoneAddition - public void clear() { - this._map.clear(); - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an Object value - * @return the removed value, or Integer(0) if it was not found in the map - */ - @Override // GemStoneAddition - public Object remove(Object key) { - return wrapValue(_map.remove(unwrapKey(key))); - } - - /** - * Returns a Set view on the entries of the map. - * - * @return a Set value - */ - @Override // GemStoneAddition - public Set entrySet() { - return new AbstractSet() { - @Override // GemStoneAddition - public int size() { - return _map.size(); - } - @Override // GemStoneAddition - public boolean isEmpty() { - return TIntObjectHashMapDecorator.this.isEmpty(); - } - @Override // GemStoneAddition - public boolean contains(Object o) { - if (o instanceof Map.Entry) { - Object k = ((Map.Entry)o).getKey(); - Object v = ((Map.Entry)o).getValue(); - return (TIntObjectHashMapDecorator.this.containsKey(k) && - TIntObjectHashMapDecorator.this.get(k).equals(v)); - } else { - return false; - } - } - @Override // GemStoneAddition - public Iterator iterator() { - return new Iterator() { - private final TIntObjectIterator it = _map.iterator(); - - public Object next() { - it.advance(); - final Object key = wrapKey(it.key()); - final Object v = wrapValue(it.value()); - return new Map.Entry() { - private Object val = v; - @Override // GemStoneAddition - public boolean equals(Object o) { - return ((o instanceof Map.Entry) && - ((Map.Entry)o).getKey().equals(key) && - ((Map.Entry)o).getValue().equals(val)); - } - public Object getKey() { - return key; - } - public Object getValue() { - return val; - } - @Override // GemStoneAddition - public int hashCode() { - return key.hashCode() + val.hashCode(); - } - public Object setValue(Object value) { - val = value; - return put(key, value); - } - }; - } - - public boolean hasNext() { - return it.hasNext(); - } - - public void remove() { - it.remove(); - } - }; - } - @Override // GemStoneAddition - public boolean add(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean addAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean retainAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean removeAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public void clear() { - TIntObjectHashMapDecorator.this.clear(); - } - }; - } - - /** - * Checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsValue(Object val) { - return _map.containsValue(unwrapValue(val)); - } - - /** - * Checks for the present of key in the keys of the map. - * - * @param key an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsKey(Object key) { - return _map.containsKey(unwrapKey(key)); - } - - /** - * Returns the number of entries in the map. - * @return the map's size. - */ - @Override // GemStoneAddition - public int size() { - return this._map.size(); - } - - /** - * Indicates whether map has any entries. - * @return true if the map is empty - */ - @Override // GemStoneAddition - public boolean isEmpty() { - return (size() == 0); - } - - /** - * Copies the key/value mappings in map into this map. - * Note that this will be a deep copy, as storage is by - * primitive value. - * - * @param map a Map value - */ - @Override // GemStoneAddition - public void putAll(Map map) { - Iterator it = map.entrySet().iterator(); - for (int i = map.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - this.put(e.getKey(), e.getValue()); - } - } - - /** - * Wraps a key - * - * @param k a key in the underlying map - * @return an Object representation of the key - */ - protected Integer wrapKey(int k) { - return Integer.valueOf(k); - } - - /** - * Unwraps a key - * - * @param key a wrapped key - * @return an unwrapped representation of the key - */ - protected int unwrapKey(Object key) { - return ((Integer)key).intValue(); - } - /** - * Wraps a value - * - * @param o a value in the underlying map - * @return an Object representation of the value - */ - protected final Object wrapValue(Object o) { - return o; - } - - /** - * Unwraps a value - * - * @param value a wrapped value - * @return an unwrapped representation of the value - */ - protected final Object unwrapValue(Object value) { - return value; - } - -} // TIntObjectHashMapDecorator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TLongDoubleHashMapDecorator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TLongDoubleHashMapDecorator.java deleted file mode 100644 index b74e523cd..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TLongDoubleHashMapDecorator.java +++ /dev/null @@ -1,383 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.decorator; - -import com.gemstone.gnu.trove.TLongDoubleHashMap; -import com.gemstone.gnu.trove.TLongDoubleIterator; -import java.util.AbstractMap; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -//import java.util.Map.Entry; -import java.util.Map; -import java.util.Set; - -/** - * Wrapper class to make a TLongDoubleHashMap conform to the java.util.Map API. - * This class simply decorates an underlying TLongDoubleHashMap and translates the Object-based - * APIs into their Trove primitive analogs. - * - *

- * Note that wrapping and unwrapping primitive values is extremely inefficient. If - * possible, users of this class should override the appropriate methods in this class - * and use a table of canonical values. - *

- * - * Created: Mon Sep 23 22:07:40 PDT 2002 - * - * @author Eric D. Friedman - * @version $Id: TLongDoubleHashMapDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $ - * @since trove 0.1.8 - */ -public class TLongDoubleHashMapDecorator extends AbstractMap implements Map, Cloneable { - /** the wrapped primitive map */ - protected TLongDoubleHashMap _map; - - /** - * Creates a wrapper that decorates the specified primitive map. - */ - public TLongDoubleHashMapDecorator(TLongDoubleHashMap map) { - super(); - this._map = map; - } - - /** - * Clones the underlying trove collection and returns the clone wrapped in a new - * decorator instance. This is a shallow clone except where primitives are - * concerned. - * - * @return a copy of the receiver - */ - @Override // GemStoneAddition - public Object clone() { - try { - TLongDoubleHashMapDecorator copy = (TLongDoubleHashMapDecorator) super.clone(); - copy._map = (TLongDoubleHashMap)_map.clone(); - return copy; - } catch (CloneNotSupportedException e) { - // assert(false); - throw new InternalError(); // we are cloneable, so this does not happen - } - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an Object value - * @param value an Object value - * @return the previous value associated with key, - * or Integer(0) if none was found. - */ - @Override // GemStoneAddition - public Object put(Object key, Object value) { - return wrapValue(_map.put(unwrapKey(key), unwrapValue(value))); - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return true if the maps are identical - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (_map.equals(other)) { - return true; // comparing two trove maps - } else if (other instanceof Map) { - Map that = (Map)other; - if (that.size() != _map.size()) { - return false; // different sizes, no need to compare - } else { // now we have to do it the hard way - Iterator it = that.entrySet().iterator(); - for (int i = that.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - Object key = e.getKey(); - Object val = e.getValue(); - if (key instanceof Long && val instanceof Double) { - long k = unwrapKey(key); - double v = unwrapValue(val); - if (_map.containsKey(k) && v == _map.get(k)) { - // match, ok to continue - } else { - return false; // no match: we're done - } - } else { - return false; // different type in other map - } - } - return true; // all entries match - } - } else { - return false; - } - } - - /** - * Retrieves the value for key - * - * @param key an Object value - * @return the value of key or null if no such mapping exists. - */ - @Override // GemStoneAddition - public Object get(Object key) { - long k = unwrapKey(key); - double v = _map.get(k); - // 0 may be a false positive since primitive maps - // cannot return null, so we have to do an extra - // check here. - if (v == 0) { - return _map.containsKey(k) ? wrapValue(v) : null; - } else { - return wrapValue(v); - } - } - - - /** - * Empties the map. - */ - @Override // GemStoneAddition - public void clear() { - this._map.clear(); - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an Object value - * @return the removed value, or Integer(0) if it was not found in the map - */ - @Override // GemStoneAddition - public Object remove(Object key) { - return wrapValue(_map.remove(unwrapKey(key))); - } - - /** - * Returns a Set view on the entries of the map. - * - * @return a Set value - */ - @Override // GemStoneAddition - public Set entrySet() { - return new AbstractSet() { - @Override // GemStoneAddition - public int size() { - return _map.size(); - } - @Override // GemStoneAddition - public boolean isEmpty() { - return TLongDoubleHashMapDecorator.this.isEmpty(); - } - @Override // GemStoneAddition - public boolean contains(Object o) { - if (o instanceof Map.Entry) { - Object k = ((Map.Entry)o).getKey(); - Object v = ((Map.Entry)o).getValue(); - return (TLongDoubleHashMapDecorator.this.containsKey(k) && - TLongDoubleHashMapDecorator.this.get(k).equals(v)); - } else { - return false; - } - } - @Override // GemStoneAddition - public Iterator iterator() { - return new Iterator() { - private final TLongDoubleIterator it = _map.iterator(); - - public Object next() { - it.advance(); - final Object key = wrapKey(it.key()); - final Object v = wrapValue(it.value()); - return new Map.Entry() { - private Object val = v; - @Override // GemStoneAddition - public boolean equals(Object o) { - return ((o instanceof Map.Entry) && - ((Map.Entry)o).getKey().equals(key) && - ((Map.Entry)o).getValue().equals(val)); - } - public Object getKey() { - return key; - } - public Object getValue() { - return val; - } - @Override // GemStoneAddition - public int hashCode() { - return key.hashCode() + val.hashCode(); - } - public Object setValue(Object value) { - val = value; - return put(key, value); - } - }; - } - - public boolean hasNext() { - return it.hasNext(); - } - - public void remove() { - it.remove(); - } - }; - } - @Override // GemStoneAddition - public boolean add(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean addAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean retainAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean removeAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public void clear() { - TLongDoubleHashMapDecorator.this.clear(); - } - }; - } - - /** - * Checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsValue(Object val) { - return _map.containsValue(unwrapValue(val)); - } - - /** - * Checks for the present of key in the keys of the map. - * - * @param key an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsKey(Object key) { - return _map.containsKey(unwrapKey(key)); - } - - /** - * Returns the number of entries in the map. - * @return the map's size. - */ - @Override // GemStoneAddition - public int size() { - return this._map.size(); - } - - /** - * Indicates whether map has any entries. - * @return true if the map is empty - */ - @Override // GemStoneAddition - public boolean isEmpty() { - return (size() == 0); - } - - /** - * Copies the key/value mappings in map into this map. - * Note that this will be a deep copy, as storage is by - * primitive value. - * - * @param map a Map value - */ - @Override // GemStoneAddition - public void putAll(Map map) { - Iterator it = map.entrySet().iterator(); - for (int i = map.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - this.put(e.getKey(), e.getValue()); - } - } - - /** - * Wraps a key - * - * @param k a key in the underlying map - * @return an Object representation of the key - */ - protected Long wrapKey(long k) { - return Long.valueOf(k); - } - - /** - * Unwraps a key - * - * @param key a wrapped key - * @return an unwrapped representation of the key - */ - protected long unwrapKey(Object key) { - return ((Long)key).longValue(); - } - /** - * Wraps a value - * - * @param k a value in the underlying map - * @return an Object representation of the value - */ - protected Double wrapValue(double k) { - return Double.valueOf(k); - } - - /** - * Unwraps a value - * - * @param value a wrapped value - * @return an unwrapped representation of the value - */ - protected double unwrapValue(Object value) { - return ((Double)value).doubleValue(); - } - -} // TLongDoubleHashMapDecorator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TLongFloatHashMapDecorator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TLongFloatHashMapDecorator.java deleted file mode 100644 index 5e102fd36..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TLongFloatHashMapDecorator.java +++ /dev/null @@ -1,383 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.decorator; - -import com.gemstone.gnu.trove.TLongFloatHashMap; -import com.gemstone.gnu.trove.TLongFloatIterator; -import java.util.AbstractMap; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -//import java.util.Map.Entry; -import java.util.Map; -import java.util.Set; - -/** - * Wrapper class to make a TLongFloatHashMap conform to the java.util.Map API. - * This class simply decorates an underlying TLongFloatHashMap and translates the Object-based - * APIs into their Trove primitive analogs. - * - *

- * Note that wrapping and unwrapping primitive values is extremely inefficient. If - * possible, users of this class should override the appropriate methods in this class - * and use a table of canonical values. - *

- * - * Created: Mon Sep 23 22:07:40 PDT 2002 - * - * @author Eric D. Friedman - * @version $Id: TLongFloatHashMapDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $ - * @since trove 0.1.8 - */ -public class TLongFloatHashMapDecorator extends AbstractMap implements Map, Cloneable { - /** the wrapped primitive map */ - protected TLongFloatHashMap _map; - - /** - * Creates a wrapper that decorates the specified primitive map. - */ - public TLongFloatHashMapDecorator(TLongFloatHashMap map) { - super(); - this._map = map; - } - - /** - * Clones the underlying trove collection and returns the clone wrapped in a new - * decorator instance. This is a shallow clone except where primitives are - * concerned. - * - * @return a copy of the receiver - */ - @Override // GemStoneAddition - public Object clone() { - try { - TLongFloatHashMapDecorator copy = (TLongFloatHashMapDecorator) super.clone(); - copy._map = (TLongFloatHashMap)_map.clone(); - return copy; - } catch (CloneNotSupportedException e) { - // assert(false); - throw new InternalError(); // we are cloneable, so this does not happen - } - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an Object value - * @param value an Object value - * @return the previous value associated with key, - * or Integer(0) if none was found. - */ - @Override // GemStoneAddition - public Object put(Object key, Object value) { - return wrapValue(_map.put(unwrapKey(key), unwrapValue(value))); - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return true if the maps are identical - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (_map.equals(other)) { - return true; // comparing two trove maps - } else if (other instanceof Map) { - Map that = (Map)other; - if (that.size() != _map.size()) { - return false; // different sizes, no need to compare - } else { // now we have to do it the hard way - Iterator it = that.entrySet().iterator(); - for (int i = that.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - Object key = e.getKey(); - Object val = e.getValue(); - if (key instanceof Long && val instanceof Float) { - long k = unwrapKey(key); - float v = unwrapValue(val); - if (_map.containsKey(k) && v == _map.get(k)) { - // match, ok to continue - } else { - return false; // no match: we're done - } - } else { - return false; // different type in other map - } - } - return true; // all entries match - } - } else { - return false; - } - } - - /** - * Retrieves the value for key - * - * @param key an Object value - * @return the value of key or null if no such mapping exists. - */ - @Override // GemStoneAddition - public Object get(Object key) { - long k = unwrapKey(key); - float v = _map.get(k); - // 0 may be a false positive since primitive maps - // cannot return null, so we have to do an extra - // check here. - if (v == 0) { - return _map.containsKey(k) ? wrapValue(v) : null; - } else { - return wrapValue(v); - } - } - - - /** - * Empties the map. - */ - @Override // GemStoneAddition - public void clear() { - this._map.clear(); - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an Object value - * @return the removed value, or Integer(0) if it was not found in the map - */ - @Override // GemStoneAddition - public Object remove(Object key) { - return wrapValue(_map.remove(unwrapKey(key))); - } - - /** - * Returns a Set view on the entries of the map. - * - * @return a Set value - */ - @Override // GemStoneAddition - public Set entrySet() { - return new AbstractSet() { - @Override // GemStoneAddition - public int size() { - return _map.size(); - } - @Override // GemStoneAddition - public boolean isEmpty() { - return TLongFloatHashMapDecorator.this.isEmpty(); - } - @Override // GemStoneAddition - public boolean contains(Object o) { - if (o instanceof Map.Entry) { - Object k = ((Map.Entry)o).getKey(); - Object v = ((Map.Entry)o).getValue(); - return (TLongFloatHashMapDecorator.this.containsKey(k) && - TLongFloatHashMapDecorator.this.get(k).equals(v)); - } else { - return false; - } - } - @Override // GemStoneAddition - public Iterator iterator() { - return new Iterator() { - private final TLongFloatIterator it = _map.iterator(); - - public Object next() { - it.advance(); - final Object key = wrapKey(it.key()); - final Object v = wrapValue(it.value()); - return new Map.Entry() { - private Object val = v; - @Override // GemStoneAddition - public boolean equals(Object o) { - return ((o instanceof Map.Entry) && - ((Map.Entry)o).getKey().equals(key) && - ((Map.Entry)o).getValue().equals(val)); - } - public Object getKey() { - return key; - } - public Object getValue() { - return val; - } - @Override // GemStoneAddition - public int hashCode() { - return key.hashCode() + val.hashCode(); - } - public Object setValue(Object value) { - val = value; - return put(key, value); - } - }; - } - - public boolean hasNext() { - return it.hasNext(); - } - - public void remove() { - it.remove(); - } - }; - } - @Override // GemStoneAddition - public boolean add(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean addAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean retainAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean removeAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public void clear() { - TLongFloatHashMapDecorator.this.clear(); - } - }; - } - - /** - * Checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsValue(Object val) { - return _map.containsValue(unwrapValue(val)); - } - - /** - * Checks for the present of key in the keys of the map. - * - * @param key an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsKey(Object key) { - return _map.containsKey(unwrapKey(key)); - } - - /** - * Returns the number of entries in the map. - * @return the map's size. - */ - @Override // GemStoneAddition - public int size() { - return this._map.size(); - } - - /** - * Indicates whether map has any entries. - * @return true if the map is empty - */ - @Override // GemStoneAddition - public boolean isEmpty() { - return (size() == 0); - } - - /** - * Copies the key/value mappings in map into this map. - * Note that this will be a deep copy, as storage is by - * primitive value. - * - * @param map a Map value - */ - @Override // GemStoneAddition - public void putAll(Map map) { - Iterator it = map.entrySet().iterator(); - for (int i = map.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - this.put(e.getKey(), e.getValue()); - } - } - - /** - * Wraps a key - * - * @param k a key in the underlying map - * @return an Object representation of the key - */ - protected Long wrapKey(long k) { - return Long.valueOf(k); - } - - /** - * Unwraps a key - * - * @param key a wrapped key - * @return an unwrapped representation of the key - */ - protected long unwrapKey(Object key) { - return ((Long)key).longValue(); - } - /** - * Wraps a value - * - * @param k a value in the underlying map - * @return an Object representation of the value - */ - protected Float wrapValue(float k) { - return new Float(k); - } - - /** - * Unwraps a value - * - * @param value a wrapped value - * @return an unwrapped representation of the value - */ - protected float unwrapValue(Object value) { - return ((Float)value).floatValue(); - } - -} // TLongFloatHashMapDecorator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TLongHashSetDecorator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TLongHashSetDecorator.java deleted file mode 100644 index 7e2494dd8..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TLongHashSetDecorator.java +++ /dev/null @@ -1,222 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.decorator; - -import com.gemstone.gnu.trove.TLongHashSet; -import com.gemstone.gnu.trove.TLongIterator; -import java.util.AbstractSet; -//import java.util.Collection; -import java.util.Iterator; -import java.util.Set; - -/** - * Wrapper class to make a TLongHashSet conform to the java.util.Set API. - * This class simply decorates an underlying TLongHashSet and translates the Object-based - * APIs into their Trove primitive analogs. - * - *

- * Note that wrapping and unwrapping primitive values is extremely inefficient. If - * possible, users of this class should override the appropriate methods in this class - * and use a table of canonical values. - *

- * - * Created: Tue Sep 24 22:08:17 PDT 2002 - * - * @author Eric D. Friedman - * @version $Id: TLongHashSetDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $ - * @since trove 0.1.8 - */ -public class TLongHashSetDecorator extends AbstractSet implements Set, Cloneable { - /** the wrapped primitive set */ - protected TLongHashSet _set; - - /** - * Creates a wrapper that decorates the specified primitive set. - */ - public TLongHashSetDecorator(TLongHashSet set) { - super(); - this._set = set; - } - - /** - * Clones the underlying trove collection and returns the clone wrapped in a new - * decorator instance. This is a shallow clone except where primitives are - * concerned. - * - * @return a copy of the receiver - */ - @Override // GemStoneAddition - public Object clone() { - try { - TLongHashSetDecorator copy = (TLongHashSetDecorator) super.clone(); - copy._set = (TLongHashSet) _set.clone(); - return copy; - } catch (CloneNotSupportedException e) { - // assert(false); - throw new InternalError(); // we are cloneable - } - } - - /** - * Inserts a value into the set. - * - * @return true if the set was modified by the insertion - */ - @Override // GemStoneAddition - public boolean add(Object value) { - return _set.add(unwrap(value)); - } - - /** - * Compares this set with another set for equality of their stored - * entries. - * - * @param other an Object value - * @return true if the sets are identical - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (_set.equals(other)) { - return true; // comparing two trove sets - } else if (other instanceof Set) { - Set that = (Set)other; - if (that.size() != _set.size()) { - return false; // different sizes, no need to compare - } else { // now we have to do it the hard way - Iterator it = that.iterator(); - for (int i = that.size(); i-- > 0;) { - Object val = it.next(); - if (val instanceof Long) { - long v = unwrap(val); - if (_set.contains(v)) { - // match, ok to continue - } else { - return false; // no match: we're done - } - } else { - return false; // different type in other set - } - } - return true; // all entries match - } - } else { - return false; - } - } - - /** - * Empties the set. - */ - @Override // GemStoneAddition - public void clear() { - this._set.clear(); - } - - /** - * Deletes a value from the set. - * - * @param value an Object value - * @return true if the set was modified - */ - @Override // GemStoneAddition - public boolean remove(Object value) { - return _set.remove(unwrap(value)); - } - - /** - * Creates an iterator over the values of the set. - * - * @return an iterator with support for removals in the underlying set - */ - @Override // GemStoneAddition - public Iterator iterator() { - return new Iterator() { - private final TLongIterator it = _set.iterator(); - - public Object next() { - return wrap(it.next()); - } - - public boolean hasNext() { - return it.hasNext(); - } - - public void remove() { - it.remove(); - } - }; - } - - /** - * Returns the number of entries in the set. - * @return the set's size. - */ - @Override // GemStoneAddition - public int size() { - return this._set.size(); - } - - /** - * Indicates whether set has any entries. - * @return true if the set is empty - */ - @Override // GemStoneAddition - public boolean isEmpty() { - return (size() == 0); - } - - /** - * Wraps a value - * - * @param k a value in the underlying set - * @return an Object representation of the value - */ - protected Long wrap(long k) { - return Long.valueOf(k); - } - - /** - * Unwraps a value - * - * @param value a wrapped value - * @return an unwrapped representation of the value - */ - protected long unwrap(Object value) { - return ((Long)value).longValue(); - } -} // TLongHashSetDecorator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TLongIntHashMapDecorator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TLongIntHashMapDecorator.java deleted file mode 100644 index 5b29e600a..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TLongIntHashMapDecorator.java +++ /dev/null @@ -1,383 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.decorator; - -import com.gemstone.gnu.trove.TLongIntHashMap; -import com.gemstone.gnu.trove.TLongIntIterator; -import java.util.AbstractMap; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -//import java.util.Map.Entry; -import java.util.Map; -import java.util.Set; - -/** - * Wrapper class to make a TLongIntHashMap conform to the java.util.Map API. - * This class simply decorates an underlying TLongIntHashMap and translates the Object-based - * APIs into their Trove primitive analogs. - * - *

- * Note that wrapping and unwrapping primitive values is extremely inefficient. If - * possible, users of this class should override the appropriate methods in this class - * and use a table of canonical values. - *

- * - * Created: Mon Sep 23 22:07:40 PDT 2002 - * - * @author Eric D. Friedman - * @version $Id: TLongIntHashMapDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $ - * @since trove 0.1.8 - */ -public class TLongIntHashMapDecorator extends AbstractMap implements Map, Cloneable { - /** the wrapped primitive map */ - protected TLongIntHashMap _map; - - /** - * Creates a wrapper that decorates the specified primitive map. - */ - public TLongIntHashMapDecorator(TLongIntHashMap map) { - super(); - this._map = map; - } - - /** - * Clones the underlying trove collection and returns the clone wrapped in a new - * decorator instance. This is a shallow clone except where primitives are - * concerned. - * - * @return a copy of the receiver - */ - @Override // GemStoneAddition - public Object clone() { - try { - TLongIntHashMapDecorator copy = (TLongIntHashMapDecorator) super.clone(); - copy._map = (TLongIntHashMap)_map.clone(); - return copy; - } catch (CloneNotSupportedException e) { - // assert(false); - throw new InternalError(); // we are cloneable, so this does not happen - } - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an Object value - * @param value an Object value - * @return the previous value associated with key, - * or Integer(0) if none was found. - */ - @Override // GemStoneAddition - public Object put(Object key, Object value) { - return wrapValue(_map.put(unwrapKey(key), unwrapValue(value))); - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return true if the maps are identical - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (_map.equals(other)) { - return true; // comparing two trove maps - } else if (other instanceof Map) { - Map that = (Map)other; - if (that.size() != _map.size()) { - return false; // different sizes, no need to compare - } else { // now we have to do it the hard way - Iterator it = that.entrySet().iterator(); - for (int i = that.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - Object key = e.getKey(); - Object val = e.getValue(); - if (key instanceof Long && val instanceof Integer) { - long k = unwrapKey(key); - int v = unwrapValue(val); - if (_map.containsKey(k) && v == _map.get(k)) { - // match, ok to continue - } else { - return false; // no match: we're done - } - } else { - return false; // different type in other map - } - } - return true; // all entries match - } - } else { - return false; - } - } - - /** - * Retrieves the value for key - * - * @param key an Object value - * @return the value of key or null if no such mapping exists. - */ - @Override // GemStoneAddition - public Object get(Object key) { - long k = unwrapKey(key); - int v = _map.get(k); - // 0 may be a false positive since primitive maps - // cannot return null, so we have to do an extra - // check here. - if (v == 0) { - return _map.containsKey(k) ? wrapValue(v) : null; - } else { - return wrapValue(v); - } - } - - - /** - * Empties the map. - */ - @Override // GemStoneAddition - public void clear() { - this._map.clear(); - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an Object value - * @return the removed value, or Integer(0) if it was not found in the map - */ - @Override // GemStoneAddition - public Object remove(Object key) { - return wrapValue(_map.remove(unwrapKey(key))); - } - - /** - * Returns a Set view on the entries of the map. - * - * @return a Set value - */ - @Override // GemStoneAddition - public Set entrySet() { - return new AbstractSet() { - @Override // GemStoneAddition - public int size() { - return _map.size(); - } - @Override // GemStoneAddition - public boolean isEmpty() { - return TLongIntHashMapDecorator.this.isEmpty(); - } - @Override // GemStoneAddition - public boolean contains(Object o) { - if (o instanceof Map.Entry) { - Object k = ((Map.Entry)o).getKey(); - Object v = ((Map.Entry)o).getValue(); - return (TLongIntHashMapDecorator.this.containsKey(k) && - TLongIntHashMapDecorator.this.get(k).equals(v)); - } else { - return false; - } - } - @Override // GemStoneAddition - public Iterator iterator() { - return new Iterator() { - private final TLongIntIterator it = _map.iterator(); - - public Object next() { - it.advance(); - final Object key = wrapKey(it.key()); - final Object v = wrapValue(it.value()); - return new Map.Entry() { - private Object val = v; - @Override // GemStoneAddition - public boolean equals(Object o) { - return ((o instanceof Map.Entry) && - ((Map.Entry)o).getKey().equals(key) && - ((Map.Entry)o).getValue().equals(val)); - } - public Object getKey() { - return key; - } - public Object getValue() { - return val; - } - @Override // GemStoneAddition - public int hashCode() { - return key.hashCode() + val.hashCode(); - } - public Object setValue(Object value) { - val = value; - return put(key, value); - } - }; - } - - public boolean hasNext() { - return it.hasNext(); - } - - public void remove() { - it.remove(); - } - }; - } - @Override // GemStoneAddition - public boolean add(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean addAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean retainAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean removeAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public void clear() { - TLongIntHashMapDecorator.this.clear(); - } - }; - } - - /** - * Checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsValue(Object val) { - return _map.containsValue(unwrapValue(val)); - } - - /** - * Checks for the present of key in the keys of the map. - * - * @param key an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsKey(Object key) { - return _map.containsKey(unwrapKey(key)); - } - - /** - * Returns the number of entries in the map. - * @return the map's size. - */ - @Override // GemStoneAddition - public int size() { - return this._map.size(); - } - - /** - * Indicates whether map has any entries. - * @return true if the map is empty - */ - @Override // GemStoneAddition - public boolean isEmpty() { - return (size() == 0); - } - - /** - * Copies the key/value mappings in map into this map. - * Note that this will be a deep copy, as storage is by - * primitive value. - * - * @param map a Map value - */ - @Override // GemStoneAddition - public void putAll(Map map) { - Iterator it = map.entrySet().iterator(); - for (int i = map.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - this.put(e.getKey(), e.getValue()); - } - } - - /** - * Wraps a key - * - * @param k a key in the underlying map - * @return an Object representation of the key - */ - protected Long wrapKey(long k) { - return Long.valueOf(k); - } - - /** - * Unwraps a key - * - * @param key a wrapped key - * @return an unwrapped representation of the key - */ - protected long unwrapKey(Object key) { - return ((Long)key).longValue(); - } - /** - * Wraps a value - * - * @param k a value in the underlying map - * @return an Object representation of the value - */ - protected Integer wrapValue(int k) { - return Integer.valueOf(k); - } - - /** - * Unwraps a value - * - * @param value a wrapped value - * @return an unwrapped representation of the value - */ - protected int unwrapValue(Object value) { - return ((Integer)value).intValue(); - } - -} // TLongIntHashMapDecorator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TLongLongHashMapDecorator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TLongLongHashMapDecorator.java deleted file mode 100644 index 9f3f2761e..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TLongLongHashMapDecorator.java +++ /dev/null @@ -1,383 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.decorator; - -import com.gemstone.gnu.trove.TLongLongHashMap; -import com.gemstone.gnu.trove.TLongLongIterator; -import java.util.AbstractMap; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -//import java.util.Map.Entry; -import java.util.Map; -import java.util.Set; - -/** - * Wrapper class to make a TLongLongHashMap conform to the java.util.Map API. - * This class simply decorates an underlying TLongLongHashMap and translates the Object-based - * APIs into their Trove primitive analogs. - * - *

- * Note that wrapping and unwrapping primitive values is extremely inefficient. If - * possible, users of this class should override the appropriate methods in this class - * and use a table of canonical values. - *

- * - * Created: Mon Sep 23 22:07:40 PDT 2002 - * - * @author Eric D. Friedman - * @version $Id: TLongLongHashMapDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $ - * @since trove 0.1.8 - */ -public class TLongLongHashMapDecorator extends AbstractMap implements Map, Cloneable { - /** the wrapped primitive map */ - protected TLongLongHashMap _map; - - /** - * Creates a wrapper that decorates the specified primitive map. - */ - public TLongLongHashMapDecorator(TLongLongHashMap map) { - super(); - this._map = map; - } - - /** - * Clones the underlying trove collection and returns the clone wrapped in a new - * decorator instance. This is a shallow clone except where primitives are - * concerned. - * - * @return a copy of the receiver - */ - @Override // GemStoneAddition - public Object clone() { - try { - TLongLongHashMapDecorator copy = (TLongLongHashMapDecorator) super.clone(); - copy._map = (TLongLongHashMap)_map.clone(); - return copy; - } catch (CloneNotSupportedException e) { - // assert(false); - throw new InternalError(); // we are cloneable, so this does not happen - } - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an Object value - * @param value an Object value - * @return the previous value associated with key, - * or Integer(0) if none was found. - */ - @Override // GemStoneAddition - public Object put(Object key, Object value) { - return wrapValue(_map.put(unwrapKey(key), unwrapValue(value))); - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return true if the maps are identical - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (_map.equals(other)) { - return true; // comparing two trove maps - } else if (other instanceof Map) { - Map that = (Map)other; - if (that.size() != _map.size()) { - return false; // different sizes, no need to compare - } else { // now we have to do it the hard way - Iterator it = that.entrySet().iterator(); - for (int i = that.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - Object key = e.getKey(); - Object val = e.getValue(); - if (key instanceof Long && val instanceof Long) { - long k = unwrapKey(key); - long v = unwrapValue(val); - if (_map.containsKey(k) && v == _map.get(k)) { - // match, ok to continue - } else { - return false; // no match: we're done - } - } else { - return false; // different type in other map - } - } - return true; // all entries match - } - } else { - return false; - } - } - - /** - * Retrieves the value for key - * - * @param key an Object value - * @return the value of key or null if no such mapping exists. - */ - @Override // GemStoneAddition - public Object get(Object key) { - long k = unwrapKey(key); - long v = _map.get(k); - // 0 may be a false positive since primitive maps - // cannot return null, so we have to do an extra - // check here. - if (v == 0) { - return _map.containsKey(k) ? wrapValue(v) : null; - } else { - return wrapValue(v); - } - } - - - /** - * Empties the map. - */ - @Override // GemStoneAddition - public void clear() { - this._map.clear(); - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an Object value - * @return the removed value, or Integer(0) if it was not found in the map - */ - @Override // GemStoneAddition - public Object remove(Object key) { - return wrapValue(_map.remove(unwrapKey(key))); - } - - /** - * Returns a Set view on the entries of the map. - * - * @return a Set value - */ - @Override // GemStoneAddition - public Set entrySet() { - return new AbstractSet() { - @Override // GemStoneAddition - public int size() { - return _map.size(); - } - @Override // GemStoneAddition - public boolean isEmpty() { - return TLongLongHashMapDecorator.this.isEmpty(); - } - @Override // GemStoneAddition - public boolean contains(Object o) { - if (o instanceof Map.Entry) { - Object k = ((Map.Entry)o).getKey(); - Object v = ((Map.Entry)o).getValue(); - return (TLongLongHashMapDecorator.this.containsKey(k) && - TLongLongHashMapDecorator.this.get(k).equals(v)); - } else { - return false; - } - } - @Override // GemStoneAddition - public Iterator iterator() { - return new Iterator() { - private final TLongLongIterator it = _map.iterator(); - - public Object next() { - it.advance(); - final Object key = wrapKey(it.key()); - final Object v = wrapValue(it.value()); - return new Map.Entry() { - private Object val = v; - @Override // GemStoneAddition - public boolean equals(Object o) { - return ((o instanceof Map.Entry) && - ((Map.Entry)o).getKey().equals(key) && - ((Map.Entry)o).getValue().equals(val)); - } - public Object getKey() { - return key; - } - public Object getValue() { - return val; - } - @Override // GemStoneAddition - public int hashCode() { - return key.hashCode() + val.hashCode(); - } - public Object setValue(Object value) { - val = value; - return put(key, value); - } - }; - } - - public boolean hasNext() { - return it.hasNext(); - } - - public void remove() { - it.remove(); - } - }; - } - @Override // GemStoneAddition - public boolean add(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean addAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean retainAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean removeAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public void clear() { - TLongLongHashMapDecorator.this.clear(); - } - }; - } - - /** - * Checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsValue(Object val) { - return _map.containsValue(unwrapValue(val)); - } - - /** - * Checks for the present of key in the keys of the map. - * - * @param key an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsKey(Object key) { - return _map.containsKey(unwrapKey(key)); - } - - /** - * Returns the number of entries in the map. - * @return the map's size. - */ - @Override // GemStoneAddition - public int size() { - return this._map.size(); - } - - /** - * Indicates whether map has any entries. - * @return true if the map is empty - */ - @Override // GemStoneAddition - public boolean isEmpty() { - return (size() == 0); - } - - /** - * Copies the key/value mappings in map into this map. - * Note that this will be a deep copy, as storage is by - * primitive value. - * - * @param map a Map value - */ - @Override // GemStoneAddition - public void putAll(Map map) { - Iterator it = map.entrySet().iterator(); - for (int i = map.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - this.put(e.getKey(), e.getValue()); - } - } - - /** - * Wraps a key - * - * @param k a key in the underlying map - * @return an Object representation of the key - */ - protected Long wrapKey(long k) { - return Long.valueOf(k); - } - - /** - * Unwraps a key - * - * @param key a wrapped key - * @return an unwrapped representation of the key - */ - protected long unwrapKey(Object key) { - return ((Long)key).longValue(); - } - /** - * Wraps a value - * - * @param k a value in the underlying map - * @return an Object representation of the value - */ - protected Long wrapValue(long k) { - return Long.valueOf(k); - } - - /** - * Unwraps a value - * - * @param value a wrapped value - * @return an unwrapped representation of the value - */ - protected long unwrapValue(Object value) { - return ((Long)value).longValue(); - } - -} // TLongLongHashMapDecorator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TLongObjectHashMapDecorator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TLongObjectHashMapDecorator.java deleted file mode 100644 index 7adbbbd76..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TLongObjectHashMapDecorator.java +++ /dev/null @@ -1,374 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.decorator; - -import com.gemstone.gnu.trove.TLongObjectHashMap; -import com.gemstone.gnu.trove.TLongObjectIterator; -import java.util.AbstractMap; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -//import java.util.Map.Entry; -import java.util.Map; -import java.util.Set; - -/** - * Wrapper class to make a TLongObjectHashMap conform to the java.util.Map API. - * This class simply decorates an underlying TLongObjectHashMap and translates the Object-based - * APIs into their Trove primitive analogs. - * - *

- * Note that wrapping and unwrapping primitive values is extremely inefficient. If - * possible, users of this class should override the appropriate methods in this class - * and use a table of canonical values. - *

- * - * Created: Mon Sep 23 22:07:40 PDT 2002 - * - * @author Eric D. Friedman - * @version $Id: TLongObjectHashMapDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $ - * @since trove 0.1.8 - */ -public class TLongObjectHashMapDecorator extends AbstractMap implements Map, Cloneable { - /** the wrapped primitive map */ - protected TLongObjectHashMap _map; - - /** - * Creates a wrapper that decorates the specified primitive map. - */ - public TLongObjectHashMapDecorator(TLongObjectHashMap map) { - super(); - this._map = map; - } - - /** - * Clones the underlying trove collection and returns the clone wrapped in a new - * decorator instance. This is a shallow clone except where primitives are - * concerned. - * - * @return a copy of the receiver - */ - @Override // GemStoneAddition - public Object clone() { - try { - TLongObjectHashMapDecorator copy = (TLongObjectHashMapDecorator) super.clone(); - copy._map = (TLongObjectHashMap)_map.clone(); - return copy; - } catch (CloneNotSupportedException e) { - // assert(false); - throw new InternalError(); // we are cloneable, so this does not happen - } - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an Object value - * @param value an Object value - * @return the previous value associated with key, - * or Integer(0) if none was found. - */ - @Override // GemStoneAddition - public Object put(Object key, Object value) { - return wrapValue(_map.put(unwrapKey(key), unwrapValue(value))); - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return true if the maps are identical - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (_map.equals(other)) { - return true; // comparing two trove maps - } else if (other instanceof Map) { - Map that = (Map)other; - if (that.size() != _map.size()) { - return false; // different sizes, no need to compare - } else { // now we have to do it the hard way - Iterator it = that.entrySet().iterator(); - for (int i = that.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - Object key = e.getKey(); - Object val = e.getValue(); - if (key instanceof Long) { - long k = unwrapKey(key); - Object v = unwrapValue(val); - if (_map.containsKey(k) && v == _map.get(k)) { - // match, ok to continue - } else { - return false; // no match: we're done - } - } else { - return false; // different type in other map - } - } - return true; // all entries match - } - } else { - return false; - } - } - - /** - * Retrieves the value for key - * - * @param key an Object value - * @return the value of key or null if no such mapping exists. - */ - @Override // GemStoneAddition - public Object get(Object key) { - return _map.get(unwrapKey(key)); - } - - - /** - * Empties the map. - */ - @Override // GemStoneAddition - public void clear() { - this._map.clear(); - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an Object value - * @return the removed value, or Integer(0) if it was not found in the map - */ - @Override // GemStoneAddition - public Object remove(Object key) { - return wrapValue(_map.remove(unwrapKey(key))); - } - - /** - * Returns a Set view on the entries of the map. - * - * @return a Set value - */ - @Override // GemStoneAddition - public Set entrySet() { - return new AbstractSet() { - @Override // GemStoneAddition - public int size() { - return _map.size(); - } - @Override // GemStoneAddition - public boolean isEmpty() { - return TLongObjectHashMapDecorator.this.isEmpty(); - } - @Override // GemStoneAddition - public boolean contains(Object o) { - if (o instanceof Map.Entry) { - Object k = ((Map.Entry)o).getKey(); - Object v = ((Map.Entry)o).getValue(); - return (TLongObjectHashMapDecorator.this.containsKey(k) && - TLongObjectHashMapDecorator.this.get(k).equals(v)); - } else { - return false; - } - } - @Override // GemStoneAddition - public Iterator iterator() { - return new Iterator() { - private final TLongObjectIterator it = _map.iterator(); - - public Object next() { - it.advance(); - final Object key = wrapKey(it.key()); - final Object v = wrapValue(it.value()); - return new Map.Entry() { - private Object val = v; - @Override // GemStoneAddition - public boolean equals(Object o) { - return ((o instanceof Map.Entry) && - ((Map.Entry)o).getKey().equals(key) && - ((Map.Entry)o).getValue().equals(val)); - } - public Object getKey() { - return key; - } - public Object getValue() { - return val; - } - @Override // GemStoneAddition - public int hashCode() { - return key.hashCode() + val.hashCode(); - } - public Object setValue(Object value) { - val = value; - return put(key, value); - } - }; - } - - public boolean hasNext() { - return it.hasNext(); - } - - public void remove() { - it.remove(); - } - }; - } - @Override // GemStoneAddition - public boolean add(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean addAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean retainAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean removeAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public void clear() { - TLongObjectHashMapDecorator.this.clear(); - } - }; - } - - /** - * Checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsValue(Object val) { - return _map.containsValue(unwrapValue(val)); - } - - /** - * Checks for the present of key in the keys of the map. - * - * @param key an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsKey(Object key) { - return _map.containsKey(unwrapKey(key)); - } - - /** - * Returns the number of entries in the map. - * @return the map's size. - */ - @Override // GemStoneAddition - public int size() { - return this._map.size(); - } - - /** - * Indicates whether map has any entries. - * @return true if the map is empty - */ - @Override // GemStoneAddition - public boolean isEmpty() { - return (size() == 0); - } - - /** - * Copies the key/value mappings in map into this map. - * Note that this will be a deep copy, as storage is by - * primitive value. - * - * @param map a Map value - */ - @Override // GemStoneAddition - public void putAll(Map map) { - Iterator it = map.entrySet().iterator(); - for (int i = map.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - this.put(e.getKey(), e.getValue()); - } - } - - /** - * Wraps a key - * - * @param k a key in the underlying map - * @return an Object representation of the key - */ - protected Long wrapKey(long k) { - return Long.valueOf(k); - } - - /** - * Unwraps a key - * - * @param key a wrapped key - * @return an unwrapped representation of the key - */ - protected long unwrapKey(Object key) { - return ((Long)key).longValue(); - } - /** - * Wraps a value - * - * @param o a value in the underlying map - * @return an Object representation of the value - */ - protected final Object wrapValue(Object o) { - return o; - } - - /** - * Unwraps a value - * - * @param value a wrapped value - * @return an unwrapped representation of the value - */ - protected final Object unwrapValue(Object value) { - return value; - } - -} // TLongObjectHashMapDecorator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TObjectDoubleHashMapDecorator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TObjectDoubleHashMapDecorator.java deleted file mode 100644 index b577fcb1d..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TObjectDoubleHashMapDecorator.java +++ /dev/null @@ -1,380 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.decorator; - -import com.gemstone.gnu.trove.TObjectDoubleHashMap; -import com.gemstone.gnu.trove.TObjectDoubleIterator; -import java.util.AbstractMap; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -//import java.util.Map.Entry; -import java.util.Map; -import java.util.Set; - -/** - * Wrapper class to make a TObjectDoubleHashMap conform to the java.util.Map API. - * This class simply decorates an underlying TObjectDoubleHashMap and translates the Object-based - * APIs into their Trove primitive analogs. - * - *

- * Note that wrapping and unwrapping primitive values is extremely inefficient. If - * possible, users of this class should override the appropriate methods in this class - * and use a table of canonical values. - *

- * - * Created: Mon Sep 23 22:07:40 PDT 2002 - * - * @author Eric D. Friedman - * @version $Id: TObjectDoubleHashMapDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $ - * @since trove 0.1.8 - */ -public class TObjectDoubleHashMapDecorator extends AbstractMap implements Map, Cloneable { - /** the wrapped primitive map */ - protected TObjectDoubleHashMap _map; - - /** - * Creates a wrapper that decorates the specified primitive map. - */ - public TObjectDoubleHashMapDecorator(TObjectDoubleHashMap map) { - super(); - this._map = map; - } - - /** - * Clones the underlying trove collection and returns the clone wrapped in a new - * decorator instance. This is a shallow clone except where primitives are - * concerned. - * - * @return a copy of the receiver - */ - @Override // GemStoneAddition - public Object clone() { - try { - TObjectDoubleHashMapDecorator copy = (TObjectDoubleHashMapDecorator) super.clone(); - copy._map = (TObjectDoubleHashMap)_map.clone(); - return copy; - } catch (CloneNotSupportedException e) { - // assert(false); - throw new InternalError(); // we are cloneable, so this does not happen - } - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an Object value - * @param value an Object value - * @return the previous value associated with key, - * or Integer(0) if none was found. - */ - @Override // GemStoneAddition - public Object put(Object key, Object value) { - return wrapValue(_map.put(unwrapKey(key), unwrapValue(value))); - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return true if the maps are identical - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (_map.equals(other)) { - return true; // comparing two trove maps - } else if (other instanceof Map) { - Map that = (Map)other; - if (that.size() != _map.size()) { - return false; // different sizes, no need to compare - } else { // now we have to do it the hard way - Iterator it = that.entrySet().iterator(); - for (int i = that.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - Object key = e.getKey(); - Object val = e.getValue(); - - Object k = unwrapKey(key); - double v = unwrapValue(val); - if (_map.containsKey(k) && v == _map.get(k)) { - // match, ok to continue - } else { - return false; // no match: we're done - } - } - return true; // all entries match - } - } else { - return false; - } - } - - /** - * Retrieves the value for key - * - * @param key an Object value - * @return the value of key or null if no such mapping exists. - */ - @Override // GemStoneAddition - public Object get(Object key) { - Object k = unwrapKey(key); - double v = _map.get(k); - // 0 may be a false positive since primitive maps - // cannot return null, so we have to do an extra - // check here. - if (v == 0) { - return _map.containsKey(k) ? wrapValue(v) : null; - } else { - return wrapValue(v); - } - } - - - /** - * Empties the map. - */ - @Override // GemStoneAddition - public void clear() { - this._map.clear(); - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an Object value - * @return the removed value, or Integer(0) if it was not found in the map - */ - @Override // GemStoneAddition - public Object remove(Object key) { - return wrapValue(_map.remove(unwrapKey(key))); - } - - /** - * Returns a Set view on the entries of the map. - * - * @return a Set value - */ - @Override // GemStoneAddition - public Set entrySet() { - return new AbstractSet() { - @Override // GemStoneAddition - public int size() { - return _map.size(); - } - @Override // GemStoneAddition - public boolean isEmpty() { - return TObjectDoubleHashMapDecorator.this.isEmpty(); - } - @Override // GemStoneAddition - public boolean contains(Object o) { - if (o instanceof Map.Entry) { - Object k = ((Map.Entry)o).getKey(); - Object v = ((Map.Entry)o).getValue(); - return (TObjectDoubleHashMapDecorator.this.containsKey(k) && - TObjectDoubleHashMapDecorator.this.get(k).equals(v)); - } else { - return false; - } - } - @Override // GemStoneAddition - public Iterator iterator() { - return new Iterator() { - private final TObjectDoubleIterator it = _map.iterator(); - - public Object next() { - it.advance(); - final Object key = wrapKey(it.key()); - final Object v = wrapValue(it.value()); - return new Map.Entry() { - private Object val = v; - @Override // GemStoneAddition - public boolean equals(Object o) { - return ((o instanceof Map.Entry) && - ((Map.Entry)o).getKey().equals(key) && - ((Map.Entry)o).getValue().equals(val)); - } - public Object getKey() { - return key; - } - public Object getValue() { - return val; - } - @Override // GemStoneAddition - public int hashCode() { - return key.hashCode() + val.hashCode(); - } - public Object setValue(Object value) { - val = value; - return put(key, value); - } - }; - } - - public boolean hasNext() { - return it.hasNext(); - } - - public void remove() { - it.remove(); - } - }; - } - @Override // GemStoneAddition - public boolean add(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean addAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean retainAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean removeAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public void clear() { - TObjectDoubleHashMapDecorator.this.clear(); - } - }; - } - - /** - * Checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsValue(Object val) { - return _map.containsValue(unwrapValue(val)); - } - - /** - * Checks for the present of key in the keys of the map. - * - * @param key an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsKey(Object key) { - return _map.containsKey(unwrapKey(key)); - } - - /** - * Returns the number of entries in the map. - * @return the map's size. - */ - @Override // GemStoneAddition - public int size() { - return this._map.size(); - } - - /** - * Indicates whether map has any entries. - * @return true if the map is empty - */ - @Override // GemStoneAddition - public boolean isEmpty() { - return (size() == 0); - } - - /** - * Copies the key/value mappings in map into this map. - * Note that this will be a deep copy, as storage is by - * primitive value. - * - * @param map a Map value - */ - @Override // GemStoneAddition - public void putAll(Map map) { - Iterator it = map.entrySet().iterator(); - for (int i = map.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - this.put(e.getKey(), e.getValue()); - } - } - - /** - * Wraps a key - * - * @param o a key in the underlying map - * @return an Object representation of the key - */ - protected final Object wrapKey(Object o) { - return o; - } - - /** - * Unwraps a key - * - * @param key a wrapped key - * @return an unwrapped representation of the key - */ - protected final Object unwrapKey(Object key) { - return key; - } - /** - * Wraps a value - * - * @param k a value in the underlying map - * @return an Object representation of the value - */ - protected Double wrapValue(double k) { - return Double.valueOf(k); - } - - /** - * Unwraps a value - * - * @param value a wrapped value - * @return an unwrapped representation of the value - */ - protected double unwrapValue(Object value) { - return ((Double)value).doubleValue(); - } - -} // TObjectDoubleHashMapDecorator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TObjectFloatHashMapDecorator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TObjectFloatHashMapDecorator.java deleted file mode 100644 index 67e0370ca..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TObjectFloatHashMapDecorator.java +++ /dev/null @@ -1,380 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.decorator; - -import com.gemstone.gnu.trove.TObjectFloatHashMap; -import com.gemstone.gnu.trove.TObjectFloatIterator; -import java.util.AbstractMap; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -//import java.util.Map.Entry; -import java.util.Map; -import java.util.Set; - -/** - * Wrapper class to make a TObjectFloatHashMap conform to the java.util.Map API. - * This class simply decorates an underlying TObjectFloatHashMap and translates the Object-based - * APIs into their Trove primitive analogs. - * - *

- * Note that wrapping and unwrapping primitive values is extremely inefficient. If - * possible, users of this class should override the appropriate methods in this class - * and use a table of canonical values. - *

- * - * Created: Mon Sep 23 22:07:40 PDT 2002 - * - * @author Eric D. Friedman - * @version $Id: TObjectFloatHashMapDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $ - * @since trove 0.1.8 - */ -public class TObjectFloatHashMapDecorator extends AbstractMap implements Map, Cloneable { - /** the wrapped primitive map */ - protected TObjectFloatHashMap _map; - - /** - * Creates a wrapper that decorates the specified primitive map. - */ - public TObjectFloatHashMapDecorator(TObjectFloatHashMap map) { - super(); - this._map = map; - } - - /** - * Clones the underlying trove collection and returns the clone wrapped in a new - * decorator instance. This is a shallow clone except where primitives are - * concerned. - * - * @return a copy of the receiver - */ - @Override // GemStoneAddition - public Object clone() { - try { - TObjectFloatHashMapDecorator copy = (TObjectFloatHashMapDecorator) super.clone(); - copy._map = (TObjectFloatHashMap)_map.clone(); - return copy; - } catch (CloneNotSupportedException e) { - // assert(false); - throw new InternalError(); // we are cloneable, so this does not happen - } - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an Object value - * @param value an Object value - * @return the previous value associated with key, - * or Integer(0) if none was found. - */ - @Override // GemStoneAddition - public Object put(Object key, Object value) { - return wrapValue(_map.put(unwrapKey(key), unwrapValue(value))); - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return true if the maps are identical - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (_map.equals(other)) { - return true; // comparing two trove maps - } else if (other instanceof Map) { - Map that = (Map)other; - if (that.size() != _map.size()) { - return false; // different sizes, no need to compare - } else { // now we have to do it the hard way - Iterator it = that.entrySet().iterator(); - for (int i = that.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - Object key = e.getKey(); - Object val = e.getValue(); - - Object k = unwrapKey(key); - float v = unwrapValue(val); - if (_map.containsKey(k) && v == _map.get(k)) { - // match, ok to continue - } else { - return false; // no match: we're done - } - } - return true; // all entries match - } - } else { - return false; - } - } - - /** - * Retrieves the value for key - * - * @param key an Object value - * @return the value of key or null if no such mapping exists. - */ - @Override // GemStoneAddition - public Object get(Object key) { - Object k = unwrapKey(key); - float v = _map.get(k); - // 0 may be a false positive since primitive maps - // cannot return null, so we have to do an extra - // check here. - if (v == 0) { - return _map.containsKey(k) ? wrapValue(v) : null; - } else { - return wrapValue(v); - } - } - - - /** - * Empties the map. - */ - @Override // GemStoneAddition - public void clear() { - this._map.clear(); - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an Object value - * @return the removed value, or Integer(0) if it was not found in the map - */ - @Override // GemStoneAddition - public Object remove(Object key) { - return wrapValue(_map.remove(unwrapKey(key))); - } - - /** - * Returns a Set view on the entries of the map. - * - * @return a Set value - */ - @Override // GemStoneAddition - public Set entrySet() { - return new AbstractSet() { - @Override // GemStoneAddition - public int size() { - return _map.size(); - } - @Override // GemStoneAddition - public boolean isEmpty() { - return TObjectFloatHashMapDecorator.this.isEmpty(); - } - @Override // GemStoneAddition - public boolean contains(Object o) { - if (o instanceof Map.Entry) { - Object k = ((Map.Entry)o).getKey(); - Object v = ((Map.Entry)o).getValue(); - return (TObjectFloatHashMapDecorator.this.containsKey(k) && - TObjectFloatHashMapDecorator.this.get(k).equals(v)); - } else { - return false; - } - } - @Override // GemStoneAddition - public Iterator iterator() { - return new Iterator() { - private final TObjectFloatIterator it = _map.iterator(); - - public Object next() { - it.advance(); - final Object key = wrapKey(it.key()); - final Object v = wrapValue(it.value()); - return new Map.Entry() { - private Object val = v; - @Override // GemStoneAddition - public boolean equals(Object o) { - return ((o instanceof Map.Entry) && - ((Map.Entry)o).getKey().equals(key) && - ((Map.Entry)o).getValue().equals(val)); - } - public Object getKey() { - return key; - } - public Object getValue() { - return val; - } - @Override // GemStoneAddition - public int hashCode() { - return key.hashCode() + val.hashCode(); - } - public Object setValue(Object value) { - val = value; - return put(key, value); - } - }; - } - - public boolean hasNext() { - return it.hasNext(); - } - - public void remove() { - it.remove(); - } - }; - } - @Override // GemStoneAddition - public boolean add(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean addAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean retainAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean removeAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public void clear() { - TObjectFloatHashMapDecorator.this.clear(); - } - }; - } - - /** - * Checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsValue(Object val) { - return _map.containsValue(unwrapValue(val)); - } - - /** - * Checks for the present of key in the keys of the map. - * - * @param key an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsKey(Object key) { - return _map.containsKey(unwrapKey(key)); - } - - /** - * Returns the number of entries in the map. - * @return the map's size. - */ - @Override // GemStoneAddition - public int size() { - return this._map.size(); - } - - /** - * Indicates whether map has any entries. - * @return true if the map is empty - */ - @Override // GemStoneAddition - public boolean isEmpty() { - return (size() == 0); - } - - /** - * Copies the key/value mappings in map into this map. - * Note that this will be a deep copy, as storage is by - * primitive value. - * - * @param map a Map value - */ - @Override // GemStoneAddition - public void putAll(Map map) { - Iterator it = map.entrySet().iterator(); - for (int i = map.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - this.put(e.getKey(), e.getValue()); - } - } - - /** - * Wraps a key - * - * @param o a key in the underlying map - * @return an Object representation of the key - */ - protected final Object wrapKey(Object o) { - return o; - } - - /** - * Unwraps a key - * - * @param key a wrapped key - * @return an unwrapped representation of the key - */ - protected final Object unwrapKey(Object key) { - return key; - } - /** - * Wraps a value - * - * @param k a value in the underlying map - * @return an Object representation of the value - */ - protected Float wrapValue(float k) { - return new Float(k); - } - - /** - * Unwraps a value - * - * @param value a wrapped value - * @return an unwrapped representation of the value - */ - protected float unwrapValue(Object value) { - return ((Float)value).floatValue(); - } - -} // TObjectFloatHashMapDecorator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TObjectIntHashMapDecorator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TObjectIntHashMapDecorator.java deleted file mode 100644 index 578e03df4..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TObjectIntHashMapDecorator.java +++ /dev/null @@ -1,383 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.decorator; - -import com.gemstone.gnu.trove.TObjectIntHashMap; -import com.gemstone.gnu.trove.TObjectIntIterator; -import java.util.AbstractMap; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -//import java.util.Map.Entry; -import java.util.Map; -import java.util.Set; - -/** - * Wrapper class to make a TObjectIntHashMap conform to the java.util.Map API. - * This class simply decorates an underlying TObjectIntHashMap and translates the Object-based - * APIs into their Trove primitive analogs. - * - *

- * Note that wrapping and unwrapping primitive values is extremely inefficient. If - * possible, users of this class should override the appropriate methods in this class - * and use a table of canonical values. - *

- * - * Created: Mon Sep 23 22:07:40 PDT 2002 - * - * @author Eric D. Friedman - * @version $Id: TObjectIntHashMapDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $ - * @since trove 0.1.8 - */ -public class TObjectIntHashMapDecorator extends AbstractMap implements Map, Cloneable { - /** the wrapped primitive map */ - protected TObjectIntHashMap _map; - - /** - * Creates a wrapper that decorates the specified primitive map. - */ - public TObjectIntHashMapDecorator(TObjectIntHashMap map) { - super(); - this._map = map; - } - - /** - * Clones the underlying trove collection and returns the clone wrapped in a new - * decorator instance. This is a shallow clone except where primitives are - * concerned. - * - * @return a copy of the receiver - */ - @Override // GemStoneAddition - public Object clone() { - try { - TObjectIntHashMapDecorator copy = (TObjectIntHashMapDecorator) super.clone(); - copy._map = (TObjectIntHashMap)_map.clone(); - return copy; - } catch (CloneNotSupportedException e) { - // assert(false); - throw new InternalError(); // we are cloneable, so this does not happen - } - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an Object value - * @param value an Object value - * @return the previous value associated with key, - * or Integer(0) if none was found. - */ - @Override // GemStoneAddition - public Object put(Object key, Object value) { - return wrapValue(_map.put(unwrapKey(key), unwrapValue(value))); - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return true if the maps are identical - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (_map.equals(other)) { - return true; // comparing two trove maps - } else if (other instanceof Map) { - Map that = (Map)other; - if (that.size() != _map.size()) { - return false; // different sizes, no need to compare - } else { // now we have to do it the hard way - Iterator it = that.entrySet().iterator(); - for (int i = that.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - Object key = e.getKey(); - Object val = e.getValue(); - if (val instanceof Integer) { - Object k = unwrapKey(key); - int v = unwrapValue(val); - if (_map.containsKey(k) && v == _map.get(k)) { - // match, ok to continue - } else { - return false; // no match: we're done - } - } else { - return false; // different type in other map - } - } - return true; // all entries match - } - } else { - return false; - } - } - - /** - * Retrieves the value for key - * - * @param key an Object value - * @return the value of key or null if no such mapping exists. - */ - @Override // GemStoneAddition - public Object get(Object key) { - Object k = unwrapKey(key); - int v = _map.get(k); - // 0 may be a false positive since primitive maps - // cannot return null, so we have to do an extra - // check here. - if (v == 0) { - return _map.containsKey(k) ? wrapValue(v) : null; - } else { - return wrapValue(v); - } - } - - - /** - * Empties the map. - */ - @Override // GemStoneAddition - public void clear() { - this._map.clear(); - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an Object value - * @return the removed value, or Integer(0) if it was not found in the map - */ - @Override // GemStoneAddition - public Object remove(Object key) { - return wrapValue(_map.remove(unwrapKey(key))); - } - - /** - * Returns a Set view on the entries of the map. - * - * @return a Set value - */ - @Override // GemStoneAddition - public Set entrySet() { - return new AbstractSet() { - @Override // GemStoneAddition - public int size() { - return _map.size(); - } - @Override // GemStoneAddition - public boolean isEmpty() { - return TObjectIntHashMapDecorator.this.isEmpty(); - } - @Override // GemStoneAddition - public boolean contains(Object o) { - if (o instanceof Map.Entry) { - Object k = ((Map.Entry)o).getKey(); - Object v = ((Map.Entry)o).getValue(); - return (TObjectIntHashMapDecorator.this.containsKey(k) && - TObjectIntHashMapDecorator.this.get(k).equals(v)); - } else { - return false; - } - } - @Override // GemStoneAddition - public Iterator iterator() { - return new Iterator() { - private final TObjectIntIterator it = _map.iterator(); - - public Object next() { - it.advance(); - final Object key = wrapKey(it.key()); - final Object v = wrapValue(it.value()); - return new Map.Entry() { - private Object val = v; - @Override // GemStoneAddition - public boolean equals(Object o) { - return ((o instanceof Map.Entry) && - ((Map.Entry)o).getKey().equals(key) && - ((Map.Entry)o).getValue().equals(val)); - } - public Object getKey() { - return key; - } - public Object getValue() { - return val; - } - @Override // GemStoneAddition - public int hashCode() { - return key.hashCode() + val.hashCode(); - } - public Object setValue(Object value) { - val = value; - return put(key, value); - } - }; - } - - public boolean hasNext() { - return it.hasNext(); - } - - public void remove() { - it.remove(); - } - }; - } - @Override // GemStoneAddition - public boolean add(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean addAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean retainAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean removeAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public void clear() { - TObjectIntHashMapDecorator.this.clear(); - } - }; - } - - /** - * Checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsValue(Object val) { - return _map.containsValue(unwrapValue(val)); - } - - /** - * Checks for the present of key in the keys of the map. - * - * @param key an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsKey(Object key) { - return _map.containsKey(unwrapKey(key)); - } - - /** - * Returns the number of entries in the map. - * @return the map's size. - */ - @Override // GemStoneAddition - public int size() { - return this._map.size(); - } - - /** - * Indicates whether map has any entries. - * @return true if the map is empty - */ - @Override // GemStoneAddition - public boolean isEmpty() { - return (size() == 0); - } - - /** - * Copies the key/value mappings in map into this map. - * Note that this will be a deep copy, as storage is by - * primitive value. - * - * @param map a Map value - */ - @Override // GemStoneAddition - public void putAll(Map map) { - Iterator it = map.entrySet().iterator(); - for (int i = map.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - this.put(e.getKey(), e.getValue()); - } - } - - /** - * Wraps a key - * - * @param o a key in the underlying map - * @return an Object representation of the key - */ - protected final Object wrapKey(Object o) { - return o; - } - - /** - * Unwraps a key - * - * @param key a wrapped key - * @return an unwrapped representation of the key - */ - protected final Object unwrapKey(Object key) { - return key; - } - /** - * Wraps a value - * - * @param k a value in the underlying map - * @return an Object representation of the value - */ - protected Integer wrapValue(int k) { - return Integer.valueOf(k); - } - - /** - * Unwraps a value - * - * @param value a wrapped value - * @return an unwrapped representation of the value - */ - protected int unwrapValue(Object value) { - return ((Integer)value).intValue(); - } - -} // TObjectIntHashMapDecorator diff --git a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TObjectLongHashMapDecorator.java b/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TObjectLongHashMapDecorator.java deleted file mode 100644 index cc9230ace..000000000 --- a/lgpl/gemfire-trove/src/main/java/com/gemstone/gnu/trove/decorator/TObjectLongHashMapDecorator.java +++ /dev/null @@ -1,383 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2002, Eric D. Friedman All Rights Reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/////////////////////////////////////////////////////////////////////////////// -/* - * Contains changes for GemFireXD distributed data platform. - * - * Portions Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package com.gemstone.gnu.trove.decorator; - -import com.gemstone.gnu.trove.TObjectLongHashMap; -import com.gemstone.gnu.trove.TObjectLongIterator; -import java.util.AbstractMap; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -//import java.util.Map.Entry; -import java.util.Map; -import java.util.Set; - -/** - * Wrapper class to make a TObjectLongHashMap conform to the java.util.Map API. - * This class simply decorates an underlying TObjectLongHashMap and translates the Object-based - * APIs into their Trove primitive analogs. - * - *

- * Note that wrapping and unwrapping primitive values is extremely inefficient. If - * possible, users of this class should override the appropriate methods in this class - * and use a table of canonical values. - *

- * - * Created: Mon Sep 23 22:07:40 PDT 2002 - * - * @author Eric D. Friedman - * @version $Id: TObjectLongHashMapDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $ - * @since trove 0.1.8 - */ -public class TObjectLongHashMapDecorator extends AbstractMap implements Map, Cloneable { - /** the wrapped primitive map */ - protected TObjectLongHashMap _map; - - /** - * Creates a wrapper that decorates the specified primitive map. - */ - public TObjectLongHashMapDecorator(TObjectLongHashMap map) { - super(); - this._map = map; - } - - /** - * Clones the underlying trove collection and returns the clone wrapped in a new - * decorator instance. This is a shallow clone except where primitives are - * concerned. - * - * @return a copy of the receiver - */ - @Override // GemStoneAddition - public Object clone() { - try { - TObjectLongHashMapDecorator copy = (TObjectLongHashMapDecorator) super.clone(); - copy._map = (TObjectLongHashMap)_map.clone(); - return copy; - } catch (CloneNotSupportedException e) { - // assert(false); - throw new InternalError(); // we are cloneable, so this does not happen - } - } - - /** - * Inserts a key/value pair into the map. - * - * @param key an Object value - * @param value an Object value - * @return the previous value associated with key, - * or Integer(0) if none was found. - */ - @Override // GemStoneAddition - public Object put(Object key, Object value) { - return wrapValue(_map.put(unwrapKey(key), unwrapValue(value))); - } - - /** - * Compares this map with another map for equality of their stored - * entries. - * - * @param other an Object value - * @return true if the maps are identical - */ - @Override // GemStoneAddition - public boolean equals(Object other) { - if (_map.equals(other)) { - return true; // comparing two trove maps - } else if (other instanceof Map) { - Map that = (Map)other; - if (that.size() != _map.size()) { - return false; // different sizes, no need to compare - } else { // now we have to do it the hard way - Iterator it = that.entrySet().iterator(); - for (int i = that.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - Object key = e.getKey(); - Object val = e.getValue(); - if (val instanceof Long) { - Object k = unwrapKey(key); - long v = unwrapValue(val); - if (_map.containsKey(k) && v == _map.get(k)) { - // match, ok to continue - } else { - return false; // no match: we're done - } - } else { - return false; // different type in other map - } - } - return true; // all entries match - } - } else { - return false; - } - } - - /** - * Retrieves the value for key - * - * @param key an Object value - * @return the value of key or null if no such mapping exists. - */ - @Override // GemStoneAddition - public Object get(Object key) { - Object k = unwrapKey(key); - long v = _map.get(k); - // 0 may be a false positive since primitive maps - // cannot return null, so we have to do an extra - // check here. - if (v == _map.getDefaultValue()) { - return _map.containsKey(k) ? wrapValue(v) : null; - } else { - return wrapValue(v); - } - } - - - /** - * Empties the map. - */ - @Override // GemStoneAddition - public void clear() { - this._map.clear(); - } - - /** - * Deletes a key/value pair from the map. - * - * @param key an Object value - * @return the removed value, or Integer(0) if it was not found in the map - */ - @Override // GemStoneAddition - public Object remove(Object key) { - return wrapValue(_map.remove(unwrapKey(key))); - } - - /** - * Returns a Set view on the entries of the map. - * - * @return a Set value - */ - @Override // GemStoneAddition - public Set entrySet() { - return new AbstractSet() { - @Override // GemStoneAddition - public int size() { - return _map.size(); - } - @Override // GemStoneAddition - public boolean isEmpty() { - return TObjectLongHashMapDecorator.this.isEmpty(); - } - @Override // GemStoneAddition - public boolean contains(Object o) { - if (o instanceof Map.Entry) { - Object k = ((Map.Entry)o).getKey(); - Object v = ((Map.Entry)o).getValue(); - return (TObjectLongHashMapDecorator.this.containsKey(k) && - TObjectLongHashMapDecorator.this.get(k).equals(v)); - } else { - return false; - } - } - @Override // GemStoneAddition - public Iterator iterator() { - return new Iterator() { - private final TObjectLongIterator it = _map.iterator(); - - public Object next() { - it.advance(); - final Object key = wrapKey(it.key()); - final Object v = wrapValue(it.value()); - return new Map.Entry() { - private Object val = v; - @Override // GemStoneAddition - public boolean equals(Object o) { - return ((o instanceof Map.Entry) && - ((Map.Entry)o).getKey().equals(key) && - ((Map.Entry)o).getValue().equals(val)); - } - public Object getKey() { - return key; - } - public Object getValue() { - return val; - } - @Override // GemStoneAddition - public int hashCode() { - return key.hashCode() + val.hashCode(); - } - public Object setValue(Object value) { - val = value; - return put(key, value); - } - }; - } - - public boolean hasNext() { - return it.hasNext(); - } - - public void remove() { - it.remove(); - } - }; - } - @Override // GemStoneAddition - public boolean add(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean addAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean retainAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public boolean removeAll(Collection c) { - throw new UnsupportedOperationException(); - } - @Override // GemStoneAddition - public void clear() { - TObjectLongHashMapDecorator.this.clear(); - } - }; - } - - /** - * Checks for the presence of val in the values of the map. - * - * @param val an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsValue(Object val) { - return _map.containsValue(unwrapValue(val)); - } - - /** - * Checks for the present of key in the keys of the map. - * - * @param key an Object value - * @return a boolean value - */ - @Override // GemStoneAddition - public boolean containsKey(Object key) { - return _map.containsKey(unwrapKey(key)); - } - - /** - * Returns the number of entries in the map. - * @return the map's size. - */ - @Override // GemStoneAddition - public int size() { - return this._map.size(); - } - - /** - * Indicates whether map has any entries. - * @return true if the map is empty - */ - @Override // GemStoneAddition - public boolean isEmpty() { - return (size() == 0); - } - - /** - * Copies the key/value mappings in map into this map. - * Note that this will be a deep copy, as storage is by - * primitive value. - * - * @param map a Map value - */ - @Override // GemStoneAddition - public void putAll(Map map) { - Iterator it = map.entrySet().iterator(); - for (int i = map.size(); i-- > 0;) { - Map.Entry e = (Map.Entry)it.next(); - this.put(e.getKey(), e.getValue()); - } - } - - /** - * Wraps a key - * - * @param o a key in the underlying map - * @return an Object representation of the key - */ - protected final Object wrapKey(Object o) { - return o; - } - - /** - * Unwraps a key - * - * @param key a wrapped key - * @return an unwrapped representation of the key - */ - protected final Object unwrapKey(Object key) { - return key; - } - /** - * Wraps a value - * - * @param k a value in the underlying map - * @return an Object representation of the value - */ - protected Long wrapValue(long k) { - return Long.valueOf(k); - } - - /** - * Unwraps a value - * - * @param value a wrapped value - * @return an unwrapped representation of the value - */ - protected long unwrapValue(Object value) { - return ((Long)value).longValue(); - } - -} // TObjectLongHashMapDecorator diff --git a/lgpl/gemfirexd-hibernate/build.gradle b/lgpl/gemfirexd-hibernate/build.gradle index 4c73eef50..60481de61 100644 --- a/lgpl/gemfirexd-hibernate/build.gradle +++ b/lgpl/gemfirexd-hibernate/build.gradle @@ -1,6 +1,6 @@ dependencies { compileOnly project(subprojectBase + 'snappydata-store-core') - compileOnly 'org.hibernate:hibernate-core:4.3.11.Final' + compileOnly "org.hibernate:hibernate-core:${hibernateVersion}" } if (rootProject.hasProperty('enablePublish')) { diff --git a/native/.cproject b/native/.cproject index 65a661c5d..2669cbefb 100644 --- a/native/.cproject +++ b/native/.cproject @@ -11,7 +11,7 @@ - + @@ -19,7 +19,7 @@ - + @@ -30,7 +30,7 @@ + diff --git a/native/.settings/language.settings.xml b/native/.settings/language.settings.xml index 7b3b3668f..f43c01d7c 100644 --- a/native/.settings/language.settings.xml +++ b/native/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -16,7 +16,7 @@ - + diff --git a/native/build.gradle b/native/build.gradle index cb56daeba..915c5cd21 100644 --- a/native/build.gradle +++ b/native/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -14,12 +14,20 @@ * permissions and limitations under the License. See accompanying * LICENSE file. */ +//plugins{ +//id "de.undercouch.download" version "3.4.3" +//} -plugins { - id 'de.undercouch.download' version '3.4.3' +buildscript { + repositories { + maven { url 'https://plugins.gradle.org/m2' } + } + dependencies { + classpath 'de.undercouch:gradle-download-task:3.4.3' + } } - apply plugin: 'wrapper' +apply plugin: 'de.undercouch.download' if ((rootProject.name.contains('native') && !rootProject.hasProperty('skipNative')) || rootProject.hasProperty('native')) { @@ -79,8 +87,9 @@ if ((rootProject.name.contains('native') && !rootProject.hasProperty('skipNative "boost-${boostVersion}-ubuntu14.04.tar.bz2", "unixODBC-${unixodbcVersion}-ubuntu14.04.tar.bz2", "googletest-${googletestVersion}-ubuntu14.04.tar.bz2" ] - } else if (flavour.startsWith('ubuntu16') || flavour.startsWith('linuxmint18') || - flavour.startsWith('elementary0.4')) { + } else if (flavour.startsWith('ubuntu16') || flavour.startsWith('ubuntu17') || flavour.startsWith('ubuntu18') || + flavour.startsWith('linuxmint18') || flavour.startsWith('linuxmint19') || + flavour.startsWith('elementary0.4') || flavour.startsWith('elementary5')) { thriftVersion = newThriftVersion boostVersion = newBoostVersion unixodbcVersion = newUnixodbcVersion @@ -133,7 +142,7 @@ if ((rootProject.name.contains('native') && !rootProject.hasProperty('skipNative dependsOn downloadDependencies inputs.files dependencies.collect { [ "${distDir}/${it}" ] }.flatten() - outputs.files dependencies.collect { [ "${distDir}/${it.replaceAll('-[^-]*.tar.bz2', '')}" ] }.flatten() + // outputs.files dependencies.collect { [ "${distDir}/${it.replaceAll('-[^-]*.tar.bz2', '')}" ] }.flatten() doLast { outputs.files.each { d -> delete d } diff --git a/native/gradle.properties b/native/gradle.properties index 7b33380fb..bb5fd6d7e 100644 --- a/native/gradle.properties +++ b/native/gradle.properties @@ -1,10 +1,15 @@ -org.gradle.daemon = false -#org.gradle.jvmargs = -Xmx2g -XX:MaxPermSize=350m +org.gradle.daemon=false +org.gradle.warning.mode=none +#org.gradle.parallel=true # Set this on the command line with -P or in ~/.gradle/gradle.properties # to change the buildDir location. Use an absolute path. buildRoot= -# Set this on the command line with -PbothArch to 1 to do -# both 64-bit and 32-bit builds else only 64-bit is built by default +# Empty credentials for maven publish on Sonatype +ossrhUsername= +ossrhPassword= + +#Set this on the command line with -PbothArch to 1 to do +#both 64-bit and 32-bit builds else only 64 bit is build by default bothArch=0 diff --git a/native/gradle/wrapper/gradle-wrapper.jar b/native/gradle/wrapper/gradle-wrapper.jar index f808147c2..457aad0d9 100644 Binary files a/native/gradle/wrapper/gradle-wrapper.jar and b/native/gradle/wrapper/gradle-wrapper.jar differ diff --git a/native/gradle/wrapper/gradle-wrapper.properties b/native/gradle/wrapper/gradle-wrapper.properties index 42deefabf..ee671127f 100644 --- a/native/gradle/wrapper/gradle-wrapper.properties +++ b/native/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Wed Sep 13 23:36:27 IST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.5.1-all.zip diff --git a/native/gradlew b/native/gradlew index 8f0616712..0bad6a51d 100755 --- a/native/gradlew +++ b/native/gradlew @@ -28,16 +28,16 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="-Xmx2g -XX:ReservedCodeCacheSize=512m -Djava.net.preferIPv4Stack=true" +DEFAULT_JVM_OPTS="-XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xmx1g -Xms1g -Djava.net.preferIPv4Stack=true" # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -155,7 +155,7 @@ if $cygwin ; then fi # Escape application args -save ( ) { +save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } diff --git a/native/gradlew.bat b/native/gradlew.bat index 78bf60415..5ce1db48e 100644 --- a/native/gradlew.bat +++ b/native/gradlew.bat @@ -14,7 +14,7 @@ set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS=-Xmx2g -XX:ReservedCodeCacheSize=512m -Djava.net.preferIPv4Stack=true +set DEFAULT_JVM_OPTS=-XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xmx1g -Xms1g -Djava.net.preferIPv4Stack=true @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome diff --git a/native/settings.gradle b/native/settings.gradle index 510e2ae8f..ea8fec8c7 100644 --- a/native/settings.gradle +++ b/native/settings.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/native/src/snappyclient/cpp/ClientProperty.cpp b/native/src/snappyclient/cpp/ClientProperty.cpp index 7f456ad72..512788c9d 100644 --- a/native/src/snappyclient/cpp/ClientProperty.cpp +++ b/native/src/snappyclient/cpp/ClientProperty.cpp @@ -37,7 +37,7 @@ using namespace io::snappydata::client; -#define _SNAPPY_SYSPROP_PREFIX "gemfirexd.client." +#define _SNAPPY_SYSPROP_PREFIX "snappydata.client." const std::string ClientProperty::DEFAULT_PROPERTY_NAME_PREFIX( _SNAPPY_SYSPROP_PREFIX); diff --git a/native/src/snappyclient/cpp/ColumnDescriptor.cpp b/native/src/snappyclient/cpp/ColumnDescriptor.cpp index c4d88f9ba..615252471 100644 --- a/native/src/snappyclient/cpp/ColumnDescriptor.cpp +++ b/native/src/snappyclient/cpp/ColumnDescriptor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/native/src/snappyclient/cpp/impl/ClientService.cpp b/native/src/snappyclient/cpp/impl/ClientService.cpp index 80a7d3385..41adbdc67 100644 --- a/native/src/snappyclient/cpp/impl/ClientService.cpp +++ b/native/src/snappyclient/cpp/impl/ClientService.cpp @@ -69,7 +69,7 @@ #include "DNSCacheService.h" #include "InternalLogger.h" #include "InternalUtils.h" - +#include "ControlConnection.h" using namespace io::snappydata; using namespace io::snappydata::client; using namespace io::snappydata::client::impl; @@ -239,67 +239,13 @@ void ClientService::handleTException(const char* op, const TException& te) { handleStdException(op, te); } - /* -void ClientService::handleException(const TException* te, const thrift::SnappyException* se, - const std::set& failedServers, bool tryFailover, +void ClientService::handleException(const TException* te, + const std::set& failedServers, bool tryFailover, bool ignoreFailOver, bool createNewConnection, const std::string& op) { - if (!m_isOpen && createNewConnection) { - if (se != NULL) { - throw GET_SQLEXCEPTION2(se); - } else { - throw GET_SQLEXCEPTION2(SQLState::NO_CURRENT_CONNECTION, te); - } - } - if (!m_loadBalance - // no failover for transactions yet - || m_isolationLevel != IsolationLevel::NONE) { - tryFailover = false; - } - if (se != NULL) { - const thrift::SnappyExceptionData& sedata = se->exceptionData; - const std::string& sqlState = sedata.sqlState; - NetConnection::FailoverStatus status; - if ((status = NetConnection.getFailoverStatus(sqlState, - sedata.getSeverity(), se)).isNone()) { - // convert DATA_CONTAINTER_CLOSED to "X0Z01" for non-transactional case - if (this.isolationLevel == Connection.TRANSACTION_NONE - && SQLState.DATA_CONTAINER_CLOSED.equals(sqlState)) { - throw newSnappyExceptionForNodeFailure(op, - ClientSharedUtils.newRuntimeException(sedata.getReason(), - se.getCause())); - } else { - throw se; - } - } else if (!tryFailover) { - throw newSnappyExceptionForNodeFailure(op, se); - } else if (status == NetConnection.FailoverStatus.RETRY) { - return failedServers; - } - } else if (t instanceof TException) { - if (!tryFailover) { - throw newSnappyExceptionForNodeFailure(op, t); - } - } else { - throw ClientExceptionUtil.newSnappyException(SQLState.JAVA_EXCEPTION, t, - t.getClass(), t.getMessage() + " (Server=" + this.currentHostAddr - + ')'); - } - // need to do failover to new server, so get the next one - if (failedServers == null) { - @SuppressWarnings("unchecked") - Set servers = new THashSet(2); - failedServers = servers; - } - failedServers.add(this.currentHostAddr); - if (createNewConnection) { - openConnection(this.currentHostAddr, failedServers); - } - return failedServers; -} -*/ +}*/ void ClientService::throwSQLExceptionForNodeFailure(const char* op, const std::exception& se) { @@ -343,14 +289,14 @@ void ClientService::setPendingTransactionAttrs( // settings; this could become configurable in future ClientService::ClientService(const std::string& host, const int port, thrift::OpenConnectionArgs& connArgs) : - // default for load-balance is true - m_connArgs(initConnectionArgs(connArgs)), m_loadBalance(true), - m_reqdServerType(thrift::ServerType::THRIFT_SNAPPY_CP), - m_useFramedTransport(false), m_serverGroups(), - m_transport(), m_client(createDummyProtocol()), - m_connHosts(1), m_connId(0), m_token(), m_isOpen(false), - m_pendingTXAttrs(), m_hasPendingTXAttrs(false), - m_isolationLevel(IsolationLevel::NONE), m_lock() { + // default for load-balance is false + m_connArgs(initConnectionArgs(connArgs)), m_loadBalance(false), + m_reqdServerType(thrift::ServerType::THRIFT_SNAPPY_CP), + m_useFramedTransport(false), m_serverGroups(), + m_transport(), m_client(createDummyProtocol()), + m_connHosts(1), m_connId(0), m_token(), m_isOpen(false), + m_pendingTXAttrs(), m_hasPendingTXAttrs(false), + m_isolationLevel(IsolationLevel::NONE), m_lock() { std::map& props = connArgs.properties; std::map::iterator propValue; @@ -362,7 +308,7 @@ ClientService::ClientService(const std::string& host, const int port, if (!props.empty()) { if ((propValue = props.find(ClientAttribute::LOAD_BALANCE)) != props.end()) { - m_loadBalance = boost::iequals("false", propValue->second); + m_loadBalance = boost::iequals("true", propValue->second); props.erase(propValue); } @@ -437,17 +383,15 @@ void ClientService::openConnection(thrift::HostAddress& hostAddr, m_connId, m_token, ex.get()); } - m_currentHostAddr = hostAddr; while (true) { - /* - if (m_loadBalance) { - ControlConnection controlService = ControlConnection - .getOrCreateControlConnection(this.connHosts.get(0), this); - // at this point query the control service for preferred server - hostAddr = controlService.getPreferredServer(failedServers, - this.serverGroups, false); - } - */ + boost::lock_guard serviceGuard(m_lock); + if (m_loadBalance) { + boost::optional controlService = ControlConnection:: + getOrCreateControlConnection(m_connHosts, this, nullptr); + // at this point query the control service for preferred server + controlService->getPreferredServer(hostAddr, nullptr, failedServers, + this->m_serverGroups, false); + } try { // first close any existing transport @@ -542,7 +486,7 @@ thrift::OpenConnectionArgs& ClientService::initConnectionArgs( } thrift::ServerType::type ClientService::getServerType(bool isServer, -bool useBinaryProtocol, bool useSSL) { + bool useBinaryProtocol, bool useSSL) { if (isServer) { if (useSSL) { return useBinaryProtocol ? thrift::ServerType::THRIFT_SNAPPY_BP_SSL @@ -1558,3 +1502,19 @@ void ClientService::close() { handleUnknownException("close"); } } + +void ClientService::updateFailedServersForCurrent( + std::set& failedServers, bool checkAllFailed, + std::exception* failure) { + + //TODO:: Need to discuss with sumedh about this method + thrift::HostAddress host = this->m_currentHostAddr; + + auto ret = failedServers.insert(host); + if (ret.second == false && checkAllFailed) { + boost::optional controlService = ControlConnection:: + getOrCreateControlConnection(m_connHosts, this, failure); + thrift::HostAddress pHost; + controlService->searchRandomServer(failedServers, failure, pHost); + } +} diff --git a/native/src/snappyclient/cpp/impl/ClientService.h b/native/src/snappyclient/cpp/impl/ClientService.h index 9de2ee487..992961e81 100644 --- a/native/src/snappyclient/cpp/impl/ClientService.h +++ b/native/src/snappyclient/cpp/impl/ClientService.h @@ -134,6 +134,9 @@ namespace impl { //const SSLSocketParameters& sslParams, boost::shared_ptr& returnTransport); + void updateFailedServersForCurrent(std::set& failedServers, + bool checkAllFailed, std::exception* failure); + protected: virtual void checkConnection(const char* op); @@ -167,6 +170,10 @@ namespace impl { void destroyTransport() noexcept; +// void handleException(const TException* te, +// const std::set& failedServers, bool tryFailover, bool ignoreFailOver, +// bool createNewConnection, const std::string& op); + private: // the static hostName and hostId used by all connections static std::string s_hostName; @@ -338,6 +345,19 @@ namespace impl { void bulkClose(const std::vector& entities); void close(); + + const std::vector& getLocators() const noexcept{ + return m_connHosts; + } + + const std::set& getServerGrps() const noexcept{ + return m_serverGroups; + } + + inline bool isFrameTransport() const noexcept { + return m_useFramedTransport; + } + }; } /* namespace impl */ diff --git a/native/src/snappyclient/cpp/impl/ClientTransport.h b/native/src/snappyclient/cpp/impl/ClientTransport.h index 09c8fc9c9..73ecb7ef0 100644 --- a/native/src/snappyclient/cpp/impl/ClientTransport.h +++ b/native/src/snappyclient/cpp/impl/ClientTransport.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/native/src/snappyclient/cpp/impl/ControlConnection.cpp b/native/src/snappyclient/cpp/impl/ControlConnection.cpp index c8a4e04d9..c373459a1 100644 --- a/native/src/snappyclient/cpp/impl/ControlConnection.cpp +++ b/native/src/snappyclient/cpp/impl/ControlConnection.cpp @@ -33,345 +33,362 @@ * LICENSE file. */ +//--------Headers---------- +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include #include "ControlConnection.h" -#include -using namespace apache::thrift; +using namespace io::snappydata; using namespace io::snappydata::client; - -/* -ControlConnection::ControlConnection() { - // TODO Auto-generated constructor stub - +using namespace io::snappydata::client::impl; +using namespace io::snappydata::thrift; + +//----private static data member initialiazation---- +std::vector > ControlConnection::s_allConnections; +boost::mutex ControlConnection::s_allConnsLock; + +ControlConnection::ControlConnection(ClientService *const &service) :m_serverGroups(service->getServerGrps()){ + m_locators= service->getLocators(); + m_framedTransport = service->isFrameTransport(); + m_snappyServerType=service->getServerType(true,false,false); + m_controlHost= service->getCurrentHostAddress(); + boost::assign::insert(m_snappyServerTypeSet)(service->getServerType(true,false,false)); + std::copy(m_locators.begin(),m_locators.end(),std::inserter(m_controlHostSet,m_controlHostSet.end())); + m_controlLocator = nullptr; } - public static final class SearchRandomServer implements TObjectProcedure { +const boost::optional ControlConnection::getOrCreateControlConnection( + const std::vector& hostAddrs, ClientService *const &service, std::exception* failure){ - private final ServerType searchServerType; - private final Set failedServers; - private HostAddress foundServer; - private int searchIndex; + // loop through all ControlConnections since size of this global list is + // expected to be in single digit (total number of distributed systems) - public static final Random rand = new Random(); + boost::lock_guard globalGuard(s_allConnsLock); - SearchRandomServer(ServerType searchServerType, int setSize, - Set failedServers) { - this.searchServerType = searchServerType; - this.failedServers = failedServers != null ? failedServers : Collections - . emptySet(); - this.searchIndex = rand.nextInt(setSize); - } + signed short index = static_cast(s_allConnections.size()); + while (--index >= 0) { + const std::unique_ptr& controlConn = s_allConnections.at(index); - public HostAddress getRandomServer() { - return this.foundServer; + boost::lock_guard serviceGuard(controlConn->m_lock); + std::vector _locators = controlConn->m_locators; + for(thrift::HostAddress hostAddr : hostAddrs){ + auto result = std::find(_locators.begin(),_locators.end(),hostAddr); + if(result == _locators.end()){ + continue; + } + auto serviceServerType = service->getServerType(true,false,false); // TODO: need to discuss with sumedh about this getServerType method + auto contrConnServerType = controlConn->m_snappyServerType; + if(contrConnServerType == serviceServerType){ + return *controlConn; + }else{ + thrift::SnappyException *ex = new thrift::SnappyException(); + std::string portStr; + Utils::convertIntToString(hostAddr.port,portStr); + std::string msg= hostAddr.hostName + ":" + portStr + + " as registered but having different type " + Utils::getServerTypeString(contrConnServerType) + + " than connection " + Utils::getServerTypeString( serviceServerType) ; + SnappyExceptionData snappyExData; + // snappyExData.__set_sqlState("08006.C");// TODO: discuss with sumedh about correct SQLState + snappyExData.__set_reason(msg); + + ex->__set_exceptionData(snappyExData); + ex->__set_serverInfo(hostAddr.hostName + ":" + portStr ); + throw ex; + } } - - @Override - public boolean execute(Object o) { - if (this.searchIndex > 0) { - this.searchIndex--; + } + // if we reached here, then need to create a new ControlConnection + std::unique_ptr controlService ( new ControlConnection(service)); + thrift::HostAddress preferredServer; + controlService->getPreferredServer(preferredServer,failure, true); + // check again if new control host already exist + index = static_cast(s_allConnections.size()); + while (--index >= 0) { + const std::unique_ptr& controlConn = s_allConnections.at(index); + boost::lock_guard serviceGuard(controlConn->m_lock); + std::vector _locators = controlConn->m_locators; + auto result = std::find(_locators.begin(),_locators.end(),preferredServer); + if(result == _locators.end()){ + return *controlConn; + } + } + s_allConnections.push_back(std::move(controlService)); + return *s_allConnections.back(); +} +void ControlConnection::getLocatorPreferredServer(thrift::HostAddress& prefHostAddr,std::set& failedServers, + std::setserverGroups){ + // TODO: SanityManager + m_controlLocator->getPreferredServer(prefHostAddr,m_snappyServerTypeSet,serverGroups,failedServers); + //TODO:SanityManager +} +void ControlConnection::getPreferredServer(thrift::HostAddress& preferredServer,std::exception* failure,bool forFailover){ + std::set failedServers; + std::set serverGroups; + return getPreferredServer(preferredServer,failure,failedServers,serverGroups,forFailover); +} +void ControlConnection::getPreferredServer(thrift::HostAddress& preferredServer,std::exception* failure, + std::set& failedServers, + std::set& serverGroups,bool forFailover){ + //boost::lock_guard localGuard(m_lock); + if(m_controlLocator == nullptr) + { + failoverToAvailableHost(failedServers, false,failure); + forFailover = true; + } + boost::lock_guard localGuard(m_lock); + bool firstCall = true; + while(true){ + + try{ + if(forFailover){ + //TODO: SanityManager + //refresh the full host list + std::vector prefServerAndAllHosts; + m_controlLocator->getAllServersWithPreferredServer(prefServerAndAllHosts,m_snappyServerTypeSet,serverGroups,failedServers); + //TODO :: refresh new server list--like java do. + if(! prefServerAndAllHosts.empty()) + { + std::vector allHosts(prefServerAndAllHosts.begin() +1,prefServerAndAllHosts.end()); + refreshAllHosts(allHosts); + preferredServer = prefServerAndAllHosts.at(0); + } + //TODO :SanityManger + }else{ + getLocatorPreferredServer(preferredServer,failedServers,serverGroups); } - else if (this.foundServer != null) { - return false; + // TODO: SanityManager + if(preferredServer.port <=0){ + /*For this case we don't have a locator or locator unable to + * determine a preferred server, so choose some server randomly + * as the "preferredServer". In case all servers have failed then + * the search below will also fail. + * Remove controlHost from failedServers since it is known to be + * working at this point (e.g after a reconnect) + * */ + std::set skipServers = failedServers; + if( !failedServers.empty() && std::find(failedServers.begin(),failedServers.end(),m_controlHost)!= failedServers.end()){ + //don't change the original failure list since that is proper + // for the current operation but change for random server search + skipServers.erase(m_controlHost); + } + searchRandomServer(skipServers, failure,preferredServer); } - - HostAddress hostAddr = (HostAddress)o; - SanityManager.DEBUG_PRINT("SW:", "SW: random host " + hostAddr - + " serverType=" + hostAddr.getServerType() + ", searchType=" - + this.searchServerType + ", failed servers = " + failedServers - + ", isFailed=" + failedServers.contains(hostAddr)); - if (hostAddr.getServerType() == this.searchServerType - && !this.failedServers.contains(hostAddr)) { - this.foundServer = hostAddr; + //TODO: Sanitymanger + return; + }catch(thrift::SnappyException &snEx){ + // TODO: + //Discuss with Sumedh + throw unexpectedError(snEx, m_controlHost); + }catch(TException &tex){ + // TODO: SanityManager + //Search for a new host for locator query + // for the first call do not mark controlhost as failed but retry(e.g. for a reconnect case) + if(firstCall){ + firstCall = false; + }else{ + failedServers.insert(m_controlHost); } - return true; + m_controlLocator->getOutputProtocol()->getTransport()->close(); + failoverToAvailableHost(failedServers,true,failure); + if(failure ==nullptr){ + failure = &(tex);// TODO: need to look again + } + }catch(std::exception &ex){ + throw unexpectedError(ex, m_controlHost); } + forFailover = true; } - -const std::vector ControlConnection::s_allConnections(2); -const boost::mutex ControlConnection::s_allConnsLock; - -ControlConnection::ControlConnection(const ClientService& service) : - m_snappyServerType(service.m_reqdServerType), m_snappyServerTypeSet( - boost::assign::list_of(service.m_reqdServerType)), m_locators( - service.m_locators), m_controlHost(), m_controlLocator(), - m_controlHosts(service.m_connHosts), m_controlHostSet( - service.m_connHosts), m_serverGroups(service.m_serverGroups) { } -const ControlConnection& ControlConnection::getOrCreateControlConnection( - const thrift::HostAddress& hostAddr, const ClientService& service) { - // loop through all ControlConnections since size of this global list is - // expected to be in single digit (total number of distributed systems) - boost::lock_guard globalGuard(s_allConnsLock); +void ControlConnection::searchRandomServer(const std::set& skipServers,std::exception* failure, + thrift::HostAddress& hostAddress){ - size_t index = s_allConnections.size(); - while (--index >= 0) { - std::unique_ptr& controlService = s_allConnections[index]; - - boost::lock_guard serviceGuard( - controlService->m_lock); - if (controlService->m_controlHostSet.find(hostAddr) - != controlService->m_controlHostSet.end()) { - return controlService; + //TODO: Need to discuss implemetation of this method and also ClientService:: updateFailedServersForCurrent with sumedh + std::vector searchServers; + // Note: Do not use unordered_set -- reason is http://www.cplusplus.com/forum/general/198319/ + std::copy(m_controlHostSet.begin(),m_controlHostSet.end(),std::inserter(searchServers,searchServers.end())); + if(searchServers.size() > 2){ + std::random_shuffle(searchServers.begin(),searchServers.end()); + } + bool findIt = false; + for(thrift::HostAddress host: searchServers){ + if(host.serverType == m_snappyServerType && + !(!skipServers.empty() && + std::find(skipServers.begin(),skipServers.end(),host)!=skipServers.end())){ + hostAddress = host; + findIt = true; + break; } } - // if we reached here, then need to create a new ControlConnection - std::unique_ptr controlService = new ControlConnection( - service); - std::set emptyServers; - controlService->getPreferredServer(emptyServers, true); - s_allConnections.push_back(controlService); - return controlService; + if(findIt) return; + throw failoverExhausted(skipServers,failure); } - -const thrift::HostAddress& ControlConnection::getPreferredServer( - std::set& failedServers, - bool forFailover) -{ - if (m_controlLocator.get() == NULL) { - failoverToAvailableHost(failedServers, NULL); - forFailover = true; +void ControlConnection::failoverToAvailableHost(std::set& failedServers,bool checkFailedControlHosts, + std::exception* failure){ + boost::lock_guard localGuard(m_lock); + for(auto iterator = m_controlHostSet.begin();iterator!= m_controlHostSet.end(); ++iterator ){ + // NEXT: for(thrift::HostAddress controlAddr : m_controlHostSet){ + thrift::HostAddress controlAddr = *iterator; + if(checkFailedControlHosts && ! failedServers.empty() && (failedServers.find(controlAddr) != failedServers.end())){ + continue; } + m_controlLocator.reset(nullptr); - while (true) { - try { - HostAddress preferredServer; - if (forFailover) { - if (SanityManager.TraceClientHA) { - SanityManager.DEBUG_PRINT(SanityManager.TRACE_CLIENT_HA, - "getAllServersWithPreferredServer() trying using host " - + this.controlHost); - } - if (SanityManager.TraceClientStatement) { - final long ns = System.nanoTime(); - SanityManager.DEBUG_PRINT_COMPACT( - "getAllServersWithPreferredServer_S", null, 0, ns, true, null); - } - - // refresh the full host list - List prefServerAndAllHosts = controlLocator - .getAllServersWithPreferredServer(this.snappyServerTypeSet, - this.serverGroups, failedServers); - // refresh the new server list - List allHosts = prefServerAndAllHosts.subList(1, - prefServerAndAllHosts.size()); - refreshAllHosts(allHosts); - preferredServer = prefServerAndAllHosts.get(0); - - if (SanityManager.TraceClientHA) { - SanityManager.DEBUG_PRINT(SanityManager.TRACE_CLIENT_HA, - "Returning all hosts " + allHosts - + " using control connection to " + this.controlHost); - } - if (SanityManager.TraceClientStatement) { - final long ns = System.nanoTime(); - SanityManager.DEBUG_PRINT_COMPACT( - "getAllServersWithPreferredServer_E", null, 0, ns, false, - null); - } - } - else { - if (SanityManager.TraceClientHA) { - SanityManager.DEBUG_PRINT(SanityManager.TRACE_CLIENT_HA, - "getPreferredServer() trying using host " + this.controlHost); - } - if (SanityManager.TraceClientStatement) { - final long ns = System.nanoTime(); - SanityManager.DEBUG_PRINT_COMPACT("getPreferredServer_S", null, - 0, ns, true, null); - } - - preferredServer = controlLocator.getPreferredServer( - this.snappyServerTypeSet, this.serverGroups, failedServers); - - if (SanityManager.TraceClientStatement) { - final long ns = System.nanoTime(); - SanityManager.DEBUG_PRINT_COMPACT("getPreferredServer_E", null, - 0, ns, false, null); - } - } + boost::shared_ptr inTransport =nullptr; + boost::shared_ptr outTransport =nullptr; + boost::shared_ptr inProtocol =nullptr; + boost::shared_ptr outProtocol =nullptr; - if (SanityManager.TraceClientHA) { - SanityManager.DEBUG_PRINT(SanityManager.TRACE_CLIENT_HA, - "Got preferred server " + preferredServer - + " using control connection to " + this.controlHost - + (preferredServer.getPort() <= 0 ? "" : " (trying random " - + "server since no preferred server received)")); + try{ + while(true){ + if(outTransport !=nullptr){ + outTransport->close(); } - if (preferredServer.getPort() <= 0) { - // for this case we don't have a locator so choose some server - // randomly as the "preferredServer" - SearchRandomServer search = new SearchRandomServer(this.snappyServerType, - this.controlHostSet.size(), failedServers); - this.controlHostSet.forEach(search); - if ((preferredServer = search.getRandomServer()) == null) { - throw failoverExhausted(null); - } + boost::shared_ptr tTransport = nullptr; + if(m_snappyServerType == thrift::ServerType::THRIFT_LOCATOR_BP_SSL || + m_snappyServerType == thrift::ServerType::THRIFT_LOCATOR_CP_SSL || + m_snappyServerType == thrift::ServerType::THRIFT_SNAPPY_BP_SSL || + m_snappyServerType==thrift::ServerType::THRIFT_SNAPPY_CP_SSL){ + // TODO: Find out whether SnappyTSSLSocket is needed or not, or any other thing is required + TSSLSocketFactory sslSocketFactory; + tTransport = sslSocketFactory.createSocket(controlAddr.hostName,controlAddr.port); + }else if(m_snappyServerType == thrift::ServerType::THRIFT_LOCATOR_BP || + m_snappyServerType== thrift::ServerType::THRIFT_LOCATOR_CP || + m_snappyServerType== thrift::ServerType::THRIFT_SNAPPY_BP || + m_snappyServerType== thrift::ServerType::THRIFT_SNAPPY_CP){ + tTransport = boost::make_shared(controlAddr.hostName,controlAddr.port); // TODO: Find out whether SnappyTSocket is needed or not, or any other thing is required } - if (SanityManager.TraceClientHA) { - SanityManager.DEBUG_PRINT(SanityManager.TRACE_CLIENT_HA, - "Returning preferred server " + preferredServer - + " with current control connection to " + this.controlHost); + tTransport->open(); + TTransportFactory* transportFactory = nullptr; + if(m_framedTransport){ + transportFactory = new TFramedTransportFactory(); + }else{ + transportFactory = new TTransportFactory(); } - return preferredServer; - } catch (TException te) { - if (SanityManager.TraceClientHA) { - SanityManager.DEBUG_PRINT(SanityManager.TRACE_CLIENT_HA, - "getPreferredServer() received exception from control host " - + this.controlHost, te); - } - if (te instanceof SnappyException) { - SnappyException se = (SnappyException)te; - NetConnection.FailoverStatus status; - if ((status = NetConnection.getFailoverStatus(se - .getExceptionData().getSqlState(), se.getExceptionData() - .getSeverity(), se)).isNone()) { - throw se; - } - else if (status == NetConnection.FailoverStatus.RETRY) { - forFailover = true; - continue; - } - } - // search for a new host for locator query - if (failedServers == null) { - Set servers = new THashSet(2); - failedServers = servers; - } - failedServers.add(controlHost); - controlLocator.getOutputProtocol().getTransport().close(); - failedServers = failoverToAvailableHost(failedServers, te); - } catch (Throwable t) { - throw unexpectedError(t, controlHost); - } - forFailover = true; - } - } - -void ControlConnection::failoverToAvailableHost( - std::set& failedServers, - const std::exception* failure) -{ - NEXT_SERVER: for (std::vector::const_iterator iter = - m_controlHosts.begin(); iter != m_controlHosts.end(); ++iter) { - const thrift::HostAddress& controlAddr = *iter; - if (!failedServers.empty() && failedServers.find(controlAddr) != failedServers.end()) { - continue; - } - m_controlHost.hostName.clear(); - m_controlLocator.reset(NULL); - - boost::shared_ptr transport; - boost::shared_ptr protocol; - while (true) { - try { - if (transport.get() != NULL) { - transport->close(); - } - if (SanityManager.TraceClientHA) { - SanityManager.DEBUG_PRINT(SanityManager.TRACE_CLIENT_HA, - "Trying control connection to host " + controlAddr); - } - if (SanityManager.TraceClientStatement - | SanityManager.TraceClientConn) { - final long ns = System.nanoTime(); - SanityManager.DEBUG_PRINT_COMPACT( - "failoverToAvailableHost_S", null, 0, ns, true, - SanityManager.TraceClientConn ? new Throwable() : null); - } - - // using socket with TCompactProtocol to match the server - // settings; this could become configurable in future - if (m_snappyServerType.isThriftSSL()) { - transport = new SnappyTSSLSocket(controlAddr, this.sslParams); - } - else { - transport = new SnappyTSocket(controlAddr); - } - if (this.snappyServerType.isThriftBinaryProtocol()) { - protocol = new TBinaryProtocol(transport); - } - else { - protocol = new TCompactProtocol(transport); - } - break; - } catch (TException te) { - if (SanityManager.TraceClientHA) { - SanityManager.DEBUG_PRINT(SanityManager.TRACE_CLIENT_HA, - "Received exception in control connection to host " - + controlAddr, te); - } - failure = te; - // search for a new host for locator query - if (failedServers == null) { - @SuppressWarnings("unchecked") - Set servers = new THashSet(2); - failedServers = servers; - } - failedServers.add(controlAddr); - if (transport != null) { - transport.close(); - } - continue NEXT_SERVER; - } catch (Throwable t) { - throw unexpectedError(t, controlAddr); + inTransport = transportFactory->getTransport(tTransport); + outTransport = transportFactory->getTransport(tTransport); + delete transportFactory; + transportFactory= 0; + + TProtocolFactory* protocolFactory = nullptr; + if(m_snappyServerType == thrift::ServerType::THRIFT_LOCATOR_BP || + m_snappyServerType==thrift::ServerType::THRIFT_LOCATOR_BP_SSL || + m_snappyServerType == thrift::ServerType::THRIFT_SNAPPY_BP || + m_snappyServerType == thrift::ServerType::THRIFT_SNAPPY_BP_SSL){ + protocolFactory = new TBinaryProtocolFactory(); + + }else{ + protocolFactory = new TCompactProtocolFactory(); } - } - this.controlHost = controlAddr; - this.controlLocator = new LocatorService.Client(protocol); + inProtocol= protocolFactory->getProtocol(inTransport); + outProtocol= protocolFactory->getProtocol(outTransport); - if (SanityManager.TraceClientHA) { - SanityManager.DEBUG_PRINT(SanityManager.TRACE_CLIENT_HA, - "Established control connection to host " + controlAddr); + delete protocolFactory; + protocolFactory=0; + break; } - if (SanityManager.TraceClientStatement - | SanityManager.TraceClientConn) { - final long ns = System.nanoTime(); - SanityManager.DEBUG_PRINT_COMPACT( - "failoverToAvailableHost_E", null, 0, ns, false, - SanityManager.TraceClientConn ? new Throwable() : null); + }catch(TException &tExp){ + failure = &tExp; // TODO: need to look again + failedServers.insert(controlAddr); + if(outTransport != nullptr){ + outTransport->close(); } - return failedServers; + continue; + //goto NEXT; + }catch(std::exception &ex){ + throw unexpectedError(ex,controlAddr); } - throw failoverExhausted(failure); - } - private void refreshAllHosts(List allHosts) { - // refresh the new server list + m_controlHost = controlAddr; - // we remove all from the set and re-populate since we would like - // to prefer the ones coming as "allServers" with "isServer" flag - // correctly set rather than the ones in "secondary-locators" - this.controlHostSet.clear(); - this.controlHosts.subList(this.locators.size(), this.controlHosts.size()) - .clear(); + m_controlLocator.reset (new thrift::LocatorServiceClient(inProtocol,outProtocol)); + return; + } + throw failoverExhausted(failedServers,failure); +} - this.controlHostSet.addAll(allHosts); - this.controlHostSet.addAll(this.controlHosts); +const thrift::SnappyException* ControlConnection:: unexpectedError(const std::exception& ex, const thrift::HostAddress& host){ - this.controlHosts.addAll(allHosts); + if(m_controlLocator != nullptr){ + m_controlLocator->getOutputProtocol()->getTransport()->close(); + m_controlLocator.reset(nullptr); } + thrift::SnappyException *snappyEx = new thrift::SnappyException(); + SnappyExceptionData snappyExData; + //snappyExData.__set_sqlState(std::string(SQLState::UNKNOWN_EXCEPTION));// TODO: discuss with sumedh about correct SQLState + snappyExData.__set_reason(ex.what()); + snappyEx->__set_exceptionData(snappyExData); + + std::string portNum; + Utils::convertIntToString(host.port,portNum); + snappyEx->__set_serverInfo(host.hostName + host.ipAddress + portNum + Utils::getServerTypeString(host.serverType)); + + return snappyEx; +} - private SnappyException unexpectedError(Throwable t, HostAddress host) { - this.controlHost = null; - if (this.controlLocator != null) { - this.controlLocator.getOutputProtocol().getTransport().close(); - this.controlLocator = null; +void ControlConnection::refreshAllHosts(const std::vector& allHosts) { + //refresh the locator list first(keep old but push current to front) + std::vector locators = m_locators; + std::vector newLocators(locators.size()); + + for(HostAddress host: allHosts){ + thrift::ServerType::type sType = host.serverType; + if(sType == ServerType::THRIFT_LOCATOR_BP || sType == ServerType::THRIFT_LOCATOR_BP_SSL || + sType == ServerType::THRIFT_LOCATOR_CP || sType == ServerType::THRIFT_LOCATOR_CP_SSL || + (std::find(locators.begin(),locators.end(), host)!=locators.end())){ + newLocators.push_back(host); + } + } + for(HostAddress host: locators){ + if(!(std::find(newLocators.begin(),newLocators.end(), host)!=newLocators.end())){ + newLocators.push_back(host); } - return ClientExceptionUtil.newSnappyException(SQLState.JAVA_EXCEPTION, t, - t.getClass(), t.getMessage() + " (Server=" + host + ')'); } + m_locators = newLocators; + // refresh the new server list + + // we remove all from the set and re-populate since we would like + // to prefer the ones coming as "allServers" with "isServer" flag + // correctly set rather than the ones in "secondary-locators" + m_controlHostSet.clear(); + m_controlHostSet.insert(newLocators.begin(),newLocators.end()); + m_controlHostSet.insert(allHosts.begin(),allHosts.end()); +} - private SnappyException failoverExhausted(Throwable cause) { - return ClientExceptionUtil.newSnappyException( - SQLState.DATA_CONTAINER_CLOSED, cause, this.locators.get(0), - " {failed after trying all available servers: " + controlHostSet - + (this.locators.size() > 1 ? ", secondary-locators=" - + this.locators.subList(1, this.locators.size()) : "") - + (cause instanceof TException ? " with: " + ThriftExceptionUtil - .getExceptionString(cause) + '}' : "}")); + +thrift::SnappyException* ControlConnection::failoverExhausted(const std::set& failedServers, + std::exception* failure) { + + std::string failedServerString; + for(thrift::HostAddress host : failedServers){ + std::string portStr; + Utils::convertIntToString(host.port,portStr); + failedServerString.append(host.hostName).append(":").append(portStr).append(","); } + thrift::SnappyException *snappyEx = new thrift::SnappyException(); + SnappyExceptionData snappyExData; + //snappyExData.__set_sqlState(std::string(SQLState::DATA_CONTAINER_CLOSED));// TODO: discuss with sumedh about correct SQLState + std::string reason ="{Failed afer trying all the servers:}" ; + snappyExData.__set_reason(reason); + snappyEx->__set_exceptionData(snappyExData); + //snappyExData.__set_sqlState();// + // TODO: complete this funtion + snappyEx->__set_serverInfo(failedServerString); + return snappyEx; } -*/ + + diff --git a/native/src/snappyclient/cpp/impl/ControlConnection.h b/native/src/snappyclient/cpp/impl/ControlConnection.h index 3fe3b97e6..36e53fe27 100644 --- a/native/src/snappyclient/cpp/impl/ControlConnection.h +++ b/native/src/snappyclient/cpp/impl/ControlConnection.h @@ -36,12 +36,19 @@ #ifndef CONTROLCONNECTION_H_ #define CONTROLCONNECTION_H_ -#include "ClientService.h" +#include "ClientService.h" #include - +#include #include "../thrift/LocatorService.h" +//-----------namespaces----- + +using namespace apache::thrift; +using namespace apache::thrift::transport; +using namespace apache::thrift::protocol; +using namespace io::snappydata; + namespace std { template<> struct hash { @@ -57,64 +64,74 @@ namespace std { } namespace io { -namespace snappydata { -namespace client { - -namespace impl { - - /** - * Holds locator, server information to use for failover. Also provides - * convenience methods to actually search for an appropriate host for - * failover. - *

- * One distributed system is supposed to have one ControlConnection. - */ - class ControlConnection { - private: - const thrift::ServerType m_snappyServerType; - //const SSLSocketParameters& m_sslParams; - const std::set m_snappyServerTypeSet; - const std::vector& m_locators; - thrift::HostAddress m_controlHost; - std::unique_ptr m_controlLocator; - const std::vector m_controlHosts; - const std::unordered_set m_controlHostSet; - const std::set& m_serverGroups; - - const boost::mutex m_lock; - - /** - * Since one DS is supposed to have one ControlConnection, so we expect the - * total size of this static global list to be small. - */ - static const std::vector s_allConnections; - /** Global lock for {@link allConnections} */ - static const boost::mutex s_allConnsLock; - - void failoverToAvailableHost(std::set& failedServers, - const std::exception* failure); - - void refreshAllHosts(const std::vector& allHosts); - - const thrift::SnappyException& unexpectedError( - const std::exception& e, const thrift::HostAddress& host); - - void failoverExhausted(const std::exception& cause, - thrift::SnappyException& result); - - public: - ControlConnection(const ClientService& service); - - static const ControlConnection& getOrCreateControlConnection( - const thrift::HostAddress& hostAddr, const ClientService& service); - - const thrift::HostAddress& getPreferredServer( - std::set& failedServers, bool forFailover); - }; - -} /* namespace impl */ -} /* namespace client */ -} /* namespace snappydata */ + namespace snappydata { + namespace client { + namespace impl { + + /** + * Holds locator, server information to use for failover. Also provides + * convenience methods to actually search for an appropriate host for + * failover. + *

+ * One distributed system is supposed to have one ControlConnection. + */ + class ControlConnection { + private: + /**********Data members********/ + thrift::ServerType::type m_snappyServerType; + //const SSLSocketParameters& m_sslParams; + std::set m_snappyServerTypeSet; + std::vector m_locators; + thrift::HostAddress m_controlHost; + std::unique_ptr m_controlLocator; + std::unordered_set m_controlHostSet; + const std::set& m_serverGroups; + + boost::mutex m_lock; + bool m_framedTransport; + /** + * Since one DS is supposed to have one ControlConnection, so we expect the + * total size of this static global list to be small. + */ + static std::vector > s_allConnections; + /** Global lock for {@link allConnections} */ + static boost::mutex s_allConnsLock; + + /*********Member functions**************/ + ControlConnection():m_serverGroups(std::set()){}; + ControlConnection(ClientService *const &service); + + void failoverToAvailableHost(std::set& failedServers, + bool checkFailedControlHosts, std::exception* failure); + + void refreshAllHosts(const std::vector& allHosts); + + const thrift::SnappyException* unexpectedError(const std::exception& e, const thrift::HostAddress& host); + + thrift::SnappyException* failoverExhausted(const std::set& failedServers,std::exception* failure); + + void getLocatorPreferredServer(thrift::HostAddress& prefHostAddr,std::set& failedServers, + std::setserverGroups); + + void getPreferredServer(thrift::HostAddress& preferredServer,std::exception* failure, + bool forFailover = false); + public: + + static const boost::optional getOrCreateControlConnection( + const std::vector& hostAddrs, ClientService *const &service, std::exception* failure); + + void getPreferredServer(thrift::HostAddress& preferredServer,std::exception* failure, + std::set& failedServers, + std::set& serverGroups,bool forFailover = false); + + + void searchRandomServer(const std::set& skipServers, + std::exception* failure,thrift::HostAddress& hostAddress); + }; + + } /* namespace impl */ + } /* namespace client */ + } /* namespace snappydata */ } /* namespace io */ #endif /* CONTROLCONNECTION_H_ */ diff --git a/native/src/snappyclient/cpp/impl/FramedClientTransport.cpp b/native/src/snappyclient/cpp/impl/FramedClientTransport.cpp index be1aadae4..eff717323 100644 --- a/native/src/snappyclient/cpp/impl/FramedClientTransport.cpp +++ b/native/src/snappyclient/cpp/impl/FramedClientTransport.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/native/src/snappyclient/cpp/impl/FramedClientTransport.h b/native/src/snappyclient/cpp/impl/FramedClientTransport.h index b68cb73a7..34208cd97 100644 --- a/native/src/snappyclient/cpp/impl/FramedClientTransport.h +++ b/native/src/snappyclient/cpp/impl/FramedClientTransport.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/settings.gradle b/settings.gradle index b917a7be7..4f283110a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -23,9 +23,7 @@ include 'gemfire-util' include 'gemfire-shared' include 'gemfire-core' include 'gemfire-junit' -// include 'gemfire-web' include 'gemfire-examples' -include ':snappydata-util' include ':snappydata-store-shared' include ':snappydata-store-prebuild' include ':snappydata-store-core' @@ -38,7 +36,6 @@ include ':snappydata-native' project(':gemfire-jgroups').projectDir = "$rootDir/lgpl/gemfire-jgroups" as File project(':gemfire-trove').projectDir = "$rootDir/lgpl/gemfire-trove" as File -project(':snappydata-util').projectDir = "$rootDir/snappy-util" as File project(':snappydata-store-shared').projectDir = "$rootDir/gemfirexd/shared" as File project(':snappydata-store-prebuild').projectDir = "$rootDir/gemfirexd/prebuild" as File project(':snappydata-store-core').projectDir = "$rootDir/gemfirexd/core" as File diff --git a/snappy-util/build.gradle b/snappy-util/build.gradle deleted file mode 100644 index a2079f334..000000000 --- a/snappy-util/build.gradle +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you - * may not use this file except in compliance with the License. You - * may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. See accompanying - * LICENSE file. - */ - -plugins { - id "net.ltgt.apt" version "0.12" -} - -apply plugin: 'net.ltgt.apt-eclipse' -apply plugin: 'net.ltgt.apt-idea' - -dependencies { - compile "com.koloboke:koloboke-api-jdk8:${kolobokeVersion}" - compile "com.koloboke:koloboke-impl-common-jdk8:${kolobokeVersion}" - // for classes using koloboke annotations - compileOnly "com.koloboke:koloboke-compile:${kolobokeCompileVersion}" - - compile project(subprojectBase + 'gemfire-shared') - compile project(subprojectBase + 'gemfire-trove') -} - -archivesBaseName = 'snappydata-util' diff --git a/snappy-util/src/main/java/io/snappydata/collection/IntObjectHashMap.java b/snappy-util/src/main/java/io/snappydata/collection/IntObjectHashMap.java deleted file mode 100644 index 05a2d0206..000000000 --- a/snappy-util/src/main/java/io/snappydata/collection/IntObjectHashMap.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2018 SnappyData, Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you - * may not use this file except in compliance with the License. You - * may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. See accompanying - * LICENSE file. - */ - -package io.snappydata.collection; - -import com.koloboke.compile.KolobokeMap; -import com.koloboke.function.IntObjPredicate; - -@KolobokeMap -public abstract class IntObjectHashMap { - - public static IntObjectHashMap withExpectedSize(int expectedSize) { - return new KolobokeIntObjectHashMap<>(expectedSize); - } - - public abstract void justPut(int key, V value); - - public abstract V get(int key); - - public abstract boolean contains(int key); - - public abstract boolean justRemove(int key); - - public abstract boolean forEachWhile(IntObjPredicate predicate); - - public abstract int size(); - - public abstract void clear(); -} diff --git a/snappy-util/src/main/java/io/snappydata/collection/LongObjectHashMap.java b/snappy-util/src/main/java/io/snappydata/collection/LongObjectHashMap.java deleted file mode 100644 index 5b299f0f3..000000000 --- a/snappy-util/src/main/java/io/snappydata/collection/LongObjectHashMap.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2018 SnappyData, Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you - * may not use this file except in compliance with the License. You - * may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. See accompanying - * LICENSE file. - */ - -package io.snappydata.collection; - -import java.util.function.LongFunction; - -import com.koloboke.compile.KolobokeMap; -import com.koloboke.function.LongObjPredicate; - -@KolobokeMap -public abstract class LongObjectHashMap { - - private Object globalState; - - public static LongObjectHashMap withExpectedSize(int expectedSize) { - return new KolobokeLongObjectHashMap<>(expectedSize); - } - - public abstract void justPut(long key, V value); - - public abstract V computeIfAbsent(long key, - LongFunction mappingFunction); - - public abstract V get(long key); - - public abstract boolean contains(long key); - - public abstract V remove(long key); - - public abstract boolean forEachWhile(LongObjPredicate predicate); - - public final Object getGlobalState() { - return this.globalState; - } - - public final void setGlobalState(Object state) { - this.globalState = state; - } - - public abstract int size(); - - public abstract void clear(); -} diff --git a/snappy-util/src/main/java/io/snappydata/collection/ObjectLongHashMap.java b/snappy-util/src/main/java/io/snappydata/collection/ObjectLongHashMap.java deleted file mode 100644 index 0788d3246..000000000 --- a/snappy-util/src/main/java/io/snappydata/collection/ObjectLongHashMap.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2018 SnappyData, Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you - * may not use this file except in compliance with the License. You - * may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. See accompanying - * LICENSE file. - */ - -package io.snappydata.collection; - -import java.util.Map; -import java.util.function.ObjLongConsumer; -import java.util.function.ToLongFunction; - -import com.koloboke.compile.KolobokeMap; -import com.koloboke.function.ObjLongToLongFunction; - -@KolobokeMap -public abstract class ObjectLongHashMap { - - public static ObjectLongHashMap withExpectedSize(int expectedSize) { - return new KolobokeObjectLongHashMap<>(expectedSize); - } - - public static ObjectLongHashMap from(Map map) { - KolobokeObjectLongHashMap m = new KolobokeObjectLongHashMap<>(map.size()); - for (Map.Entry entry : map.entrySet()) { - m.put(entry.getKey(), entry.getValue()); - } - return m; - } - - public abstract long put(K key, long value); - - public abstract long getLong(K key); - - public abstract boolean containsKey(K key); - - public abstract long removeAsLong(K key); - - public abstract long computeIfAbsent( - K key, ToLongFunction mappingFunction); - - public abstract long computeIfPresent( - K key, ObjLongToLongFunction mappingFunction); - - public abstract void forEach(ObjLongConsumer action); - - public abstract int size(); - - public abstract void clear(); - - public abstract long addValue(K key, long delta); -} diff --git a/snappy-util/src/main/java/io/snappydata/collection/ObjectObjectHashMap.java b/snappy-util/src/main/java/io/snappydata/collection/ObjectObjectHashMap.java deleted file mode 100644 index e0288fe5d..000000000 --- a/snappy-util/src/main/java/io/snappydata/collection/ObjectObjectHashMap.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2018 SnappyData, Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you - * may not use this file except in compliance with the License. You - * may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. See accompanying - * LICENSE file. - */ - -package io.snappydata.collection; - -import java.util.Map; -import java.util.function.BiPredicate; - -import com.koloboke.compile.CustomKeyEquivalence; -import com.koloboke.compile.KolobokeMap; - -@KolobokeMap -@CustomKeyEquivalence -public abstract class ObjectObjectHashMap implements Map { - - public static ObjectObjectHashMap withExpectedSize(int expectedSize) { - return new KolobokeObjectObjectHashMap<>(expectedSize); - } - - public static ObjectObjectHashMap from(Map map) { - KolobokeObjectObjectHashMap m = new KolobokeObjectObjectHashMap<>( - map.size()); - m.putAll(map); - return m; - } - - public abstract boolean forEachWhile(BiPredicate predicate); - - /** - * Mix the hash code of key else for sequential values the hash map becomes - * a linear search map. This is equivalent to ClientResolverUtils.fastHashInt - * with the XOR-shift mixing being done by the generated implementation. - */ - final int keyHashCode(K key) { - return key.hashCode() * 0x9E3779B9 /* INT_PHI */; - } - - final boolean keyEquals(K queriedKey, K keyInMap) { - return queriedKey.equals(keyInMap); - } -} diff --git a/snappy-util/src/main/java/io/snappydata/collection/OpenHashSet.java b/snappy-util/src/main/java/io/snappydata/collection/OpenHashSet.java deleted file mode 100644 index 8ecb1b2b5..000000000 --- a/snappy-util/src/main/java/io/snappydata/collection/OpenHashSet.java +++ /dev/null @@ -1,442 +0,0 @@ -/* - * Copyright (c) 2018 SnappyData, Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you - * may not use this file except in compliance with the License. You - * may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. See accompanying - * LICENSE file. - */ -package io.snappydata.collection; - -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -import java.util.NoSuchElementException; -import java.util.Set; -import java.util.function.Consumer; - -import com.gemstone.gemfire.internal.concurrent.MapCallback; -import com.gemstone.gemfire.internal.concurrent.MapResult; -import com.gemstone.gemfire.internal.shared.ClientResolverUtils; - -/** - * An optimized HashSet using open addressing with quadratic probing. - * In micro-benchmarks this is faster in both inserts, deletes and gets, - * as well as mixed workloads than most other HashSet implementations - * generally available in java (JDK HashSet, fastutil HashSets, or Trove's). - *

- * It adds additional APIs like {@link #create}, {@link #getKey}, - * {@link #addKey} which is the main reason for having this class. - */ -public class OpenHashSet extends AbstractSet - implements Set, Cloneable, java.io.Serializable { - - private static final long serialVersionUID = 2837689134511263091L; - - public static final Object REMOVED = new Object(); - // maximum power of 2 less than Integer.MAX_VALUE - protected static final int MAX_CAPACITY = 1 << 30; - - protected final float loadFactor; - - protected int size; - protected int occupied; - protected int growThreshold; - - protected int mask; - protected Object[] data; - - protected Consumer> postRehashHook; - - @SuppressWarnings("unused") - public OpenHashSet() { - this(16, 0.7f); - } - - public OpenHashSet(int initialCapacity) { - this(initialCapacity, 0.7f); - } - - public OpenHashSet(int initialCapacity, float loadFactor) { - final int capacity = nextPowerOf2(initialCapacity); - this.loadFactor = loadFactor; - this.growThreshold = (int)(loadFactor * capacity); - this.mask = capacity - 1; - this.data = new Object[capacity]; - } - - public OpenHashSet(Collection c) { - this(c.size()); - addAll(c); - } - - protected int keyHash(Object key) { - return ClientResolverUtils.fastHashInt(key != null ? key.hashCode() : 0); - } - - protected boolean keyEquals(Object mapKey, Object key) { - return mapKey.equals(key); - } - - protected final int insertionIndex(final Object[] data, final Object key, - final int hash) { - final int mask = this.mask; - int pos = hash & mask; - // try to fill the REMOVED slot but only if it is a new insertion - // else we need to keep searching for possible existing value - int removedPos = -1; - int delta = 1; - while (true) { - final Object mapKey = data[pos]; - if (mapKey != null) { - if (mapKey == REMOVED) { - removedPos = pos; - } else if (keyEquals(mapKey, key)) { - // return already present key position as negative - return -pos - 1; - } - // quadratic probing (increase delta) - pos = (pos + delta) & mask; - delta++; - } else { - final boolean slotIsNull = (removedPos == -1); - // if slot was a REMOVED token then skip incrementing the "occupied" count - if (slotIsNull) { - occupied++; - return pos; - } else { - return removedPos; - } - } - } - } - - protected boolean doInsert(final Object[] data, final Object key, - final int pos) { - data[pos] = key; - return handleNewInsert(); - } - - protected boolean doRemove(final Object[] data, final int pos) { - // mark as deleted - data[pos] = REMOVED; - return handleRemove(); - } - - protected final int index(final Object[] data, final Object key, - final int hash) { - final int mask = this.mask; - int pos = hash & mask; - int delta = 1; - while (true) { - final Object mapKey = data[pos]; - if (mapKey != null) { - if (mapKey != REMOVED && keyEquals(mapKey, key)) { - return pos; - } else { - // quadratic probing with position increase by 1, 2, 3, ... - pos = (pos + delta) & mask; - delta++; - } - } else { - return -1; - } - } - } - - protected final Object create(final K key, - final MapCallback creator, final C context, final P params, - final MapResult result, final int hash) { - final Object[] data = this.data; - final int mask = this.mask; - int pos = hash & mask; - // try to fill the REMOVED slot but only if it is a new insertion - // else we need to keep searching for possible existing value - int removedPos = -1; - int delta = 1; - while (true) { - final Object mapKey = data[pos]; - if (mapKey != null) { - if (mapKey == REMOVED) { - removedPos = pos; - } else if (keyEquals(mapKey, key)) { - // return old key - return mapKey; - } - // quadratic probing with position increase by 1, 2, 3, ... - pos = (pos + delta) & mask; - delta++; - } else { - // insert into the map and rehash if required - result.setNewValueCreated(true); - final Object newKey = creator.newValue(key, context, params, result); - if (result.isNewValueCreated()) { - // if slot was a REMOVED token then skip incrementing the "occupied" count - if (removedPos == -1) { - occupied++; - } else { - pos = removedPos; - } - doInsert(data, newKey, pos); - return newKey; - } else { - return null; - } - } - } - } - - public final void setPostRehashHook(Consumer> hook) { - this.postRehashHook = hook; - } - - public final Object addKey(final Object key, final boolean replace, - final int hash) { - final Object[] data = this.data; - final int pos = insertionIndex(data, key, hash); - if (pos >= 0) { - doInsert(data, key, pos); - return null; - } else { - final int currentPos = -pos - 1; - final Object mapKey = data[currentPos]; - if (replace) { - data[currentPos] = key; - } - return mapKey; - } - } - - public final Object getKey(final Object key) { - final Object[] data = this.data; - final int pos = index(data, key, keyHash(key)); - if (pos >= 0) return data[pos]; - else return null; - } - - public final Object removeKey(final Object key) { - return removeKey(key, keyHash(key)); - } - - private Object removeKey(final Object key, final int hash) { - final Object[] data = this.data; - final int pos = index(data, key, hash); - if (pos >= 0) { - final Object mapKey = data[pos]; - doRemove(data, pos); - return mapKey; - } else { - // no matching key - return null; - } - } - - public boolean contains(Object key) { - return index(data, key, keyHash(key)) >= 0; - } - - @Override - public boolean add(E key) { - final Object[] data = this.data; - final int pos = insertionIndex(data, key, keyHash(key)); - if (pos >= 0) { - doInsert(data, key, pos); - return true; - } else { - return false; - } - } - - @Override - public boolean remove(Object key) { - return removeKey(key, keyHash(key)) != null; - } - - @SuppressWarnings("NullableProblems") - @Override - public Itr iterator() { - return new Itr<>(this); - } - - @Override - public int size() { - return this.size; - } - - public final int capacity() { - return this.data.length; - } - - @Override - public void clear() { - final Object[] data = this.data; - final int size = data.length; - for (int i = 0; i < size; i++) { - data[i] = null; - } - this.size = 0; - this.occupied = 0; - } - - protected final boolean handleNewInsert() { - size++; - // check and trigger a rehash if load factor exceeded - if (occupied <= growThreshold) { - return false; - } else { - // double the capacity - rehash(checkCapacity(data.length << 1)); - return true; - } - } - - protected final boolean handleRemove() { - // reduce size but not the number of occupied cells - // if number of deleted entries is too large then rehash to shrink - if (--size > (occupied >>> 1) || data.length <= 128) { - return false; - } else { - // half the capacity - rehash(data.length >>> 1); - return true; - } - } - - /** - * Double the table's size and re-hash everything. - * Caller must check for overloaded set before triggering a rehash. - */ - protected final void rehash(final int newCapacity) { - final Object[] data = this.data; - final int capacity = data.length; - - final Object[] newData = new Object[newCapacity]; - final int newMask = newCapacity - 1; - - int oldPos = 0; - while (oldPos < capacity) { - final Object d = data[oldPos]; - if (d != null && d != REMOVED) { - final int newHash = keyHash(d); - int newPos = newHash & newMask; - int delta = 1; - // No need to check for equality here when we insert. - while (true) { - if (newData[newPos] == null) { - // Inserting the key at newPos - newData[newPos] = d; - break; - } else { - newPos = (newPos + delta) & newMask; - delta++; - } - } - } - oldPos++; - } - - // all deleted entries marked REMOVED have been cleared - this.occupied = this.size; - this.data = newData; - this.mask = newMask; - this.growThreshold = (int)(loadFactor * newCapacity); - - if (this.postRehashHook != null) { - this.postRehashHook.accept(this); - } - } - - public static int checkCapacity(int capacity) { - if (capacity > 0 && capacity <= MAX_CAPACITY) { - return capacity; - } else if (capacity == 0) { - return 2; - } else { - throw new IllegalStateException("Capacity (" + capacity + - ") can't be more than " + MAX_CAPACITY + " elements or negative"); - } - } - - public static int nextPowerOf2(int n) { - final int highBit = Integer.highestOneBit(n > 0 ? n : 2); - return checkCapacity(highBit == n ? n : highBit << 1); - } - - public static final class Itr implements Iterator { - - private final Object[] data; - private Object result; - private int pos; - private int prevPos; - private final OpenHashSet set; - - Itr(OpenHashSet set) { - // take a snapshot of the array to avoid problems due to rehash - this.data = set.data; - this.result = null; - this.pos = -1; - this.prevPos = -1; - this.set = set; - advance(this.data); - } - - private void advance(final Object[] data) { - final int size = data.length; - for (int pos = this.pos + 1; pos < size; pos++) { - final Object d = data[pos]; - if (d != null && d != REMOVED) { - this.result = d; - this.pos = pos; - return; - } - } - // no next element - this.result = null; - this.pos = -1; - } - - @Override - public boolean hasNext() { - return this.result != null; - } - - @SuppressWarnings("unchecked") - @Override - public E next() { - final Object result = this.result; - if (result != null) { - final Object[] data = this.data; - this.prevPos = this.pos; - advance(data); - return (E)result; - } else { - throw new NoSuchElementException("invalid iterator position"); - } - } - - @Override - public void remove() { - final int pos = this.prevPos; - if (pos >= 0) { - final Object[] data = this.data; - final OpenHashSet set = this.set; - // if no change in storage array (i.e. no rehash) then change in-place - if (data == set.data) { - set.doRemove(data, pos); - } else { - set.remove(data[pos]); - } - } else { - throw new NoSuchElementException("invalid iterator position"); - } - } - } -} diff --git a/tests/core/build.gradle b/tests/core/build.gradle index 15223cb84..2954f929e 100644 --- a/tests/core/build.gradle +++ b/tests/core/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -38,20 +38,20 @@ dependencies { compile "junit:junit:${junitVersion}" compile "org.apache.ant:ant:${antVersion}" compile "org.apache.ant:ant-junit:${antVersion}" - compile 'org.hamcrest:hamcrest-core:1.3' - compile 'org.hamcrest:hamcrest-library:1.3' + compile "org.hamcrest:hamcrest-core:${hamcrestVersion}" + compile "org.hamcrest:hamcrest-library:${hamcrestVersion}" compile "org.osgi:org.osgi.core:${osgiVersion}" - compile 'org.apache.bcel:bcel:5.2' - compile 'org.beanshell:bsh:2.0b5' - compile 'org.jmock:jmock:2.5.1' - compile 'org.jmock:jmock-legacy:2.5.1' - compile 'edu.umd.cs.mtc:multithreadedtc:1.01' - compile 'cglib:cglib-nodep:2.1_3' - compile 'org.objenesis:objenesis:2.6' - compile 'net.spy:spymemcached:2.12.0' - compile 'com.vmware:vijava:5.1' - compile 'org.jdom:jdom:1.1.3' - compile 'com.oracle:ojdbc6:11.2.0.1.0' + compile "org.apache.bcel:bcel:${bcelVersion}" + compile "org.beanshell:bsh:${bshVersion}" + compile "org.jmock:jmock:${jmockVersion}" + compile "org.jmock:jmock-legacy:${jmockVersion}" + compile "edu.umd.cs.mtc:multithreadedtc:${multiThreadedTCVersion}" + compile "cglib:cglib-nodep:${cglibVersion}" + compile "org.objenesis:objenesis:${objenesisVersion}" + compile "net.spy:spymemcached:${memcachedVersion}" + compile "com.vmware:vijava:${vijavaVersion}" + compile "org.jdom:jdom:${jdomVersion}" + compile "com.oracle:ojdbc6:${ojdbc6Version}" compile "javax.servlet:javax.servlet-api:${servletAPIVersion}" compile "org.eclipse.jetty:jetty-server:${jettyVersion}" compile "org.eclipse.jetty:jetty-servlet:${jettyVersion}" @@ -67,9 +67,10 @@ dependencies { compile "com.sun.jersey:jersey-servlet:${sunJerseyVersion}" compile "org.mortbay.jetty:jetty:${hadoopJettyVersion}" compile "org.mortbay.jetty:jetty-util:${hadoopJettyVersion}" - compile 'org.cloudera.htrace:htrace-core:2.05' + compile "org.mortbay.jetty:jetty-sslengine:${hadoopJettyVersion}" + compile "org.cloudera.htrace:htrace-core:${clouderaHtraceVersion}" - compileOnly 'net.sourceforge.jline:jline:1.0.S2-B' + compileOnly "net.sourceforge.jline:jline:${jlineSfVersion}" compileOnly files("${System.getProperty('java.home')}/../lib/tools.jar") compileOnly "org.apache.hadoop:hadoop-annotations:${hadoopVersion}" compileOnly "org.apache.hadoop:hadoop-auth:${hadoopVersion}" @@ -83,7 +84,7 @@ dependencies { compileOnly "org.eclipse.jetty:jetty-util:${jettyVersion}" compileOnly "com.google.code.findbugs:jsr305:${jsr305Version}" compileOnly "org.springframework:spring-core:${springVersion}" - compileOnly 'org.springframework.shell:spring-shell:1.0.0.RELEASE' + compileOnly "org.springframework.shell:spring-shell:${springShellVersion}" compileOnly "org.apache.hadoop:hadoop-common:${hadoopVersion}:tests" compileOnly "org.apache.hadoop:hadoop-hdfs:${hadoopVersion}:tests" diff --git a/tests/core/src/main/java/bin/run-snappy-store-bt.sh b/tests/core/src/main/java/bin/run-snappy-store-bt.sh index 0de87a32a..086d31de6 100755 --- a/tests/core/src/main/java/bin/run-snappy-store-bt.sh +++ b/tests/core/src/main/java/bin/run-snappy-store-bt.sh @@ -73,7 +73,7 @@ SOURCES=$TESTBIN/../../../../../.. export NO_BUILD_LOG=true export JPROBE_HOME=/do/not/use/JPROBE options='' -TESTSPATH=${SOURCES}/tests/sql/build-artifacts/linux/classes/main +TESTSPATH=${SOURCES}/tests/sql/build-artifacts/linux/classes/java/main export CLASSPATH=${TESTSPATH}:$CLASSPATH while [ $# -gt 0 ]; do diff --git a/tests/core/src/main/java/bin/sample-runbt.sh b/tests/core/src/main/java/bin/sample-runbt.sh index 0526eb9f6..19d4652be 100755 --- a/tests/core/src/main/java/bin/sample-runbt.sh +++ b/tests/core/src/main/java/bin/sample-runbt.sh @@ -26,7 +26,7 @@ fi SNAPPYDATADIR=$1 shift -export JTESTS=$SNAPPYDATADIR/store/tests/sql/build-artifacts/linux/classes/main +export JTESTS=$SNAPPYDATADIR/store/tests/sql/build-artifacts/linux/classes/java/main export PATH=$JAVA_HOME:$PATH:$JTESTS export GEMFIRE=$SNAPPYDATADIR/build-artifacts/scala-2.11/store export OUTPUT_DIR=$resultDir @@ -78,7 +78,7 @@ processArgs() { processArgs $* #list=`ls $GEMFIRE/lib/gemfirexd-client-*` -list=`ls $JTESTS/../../libs/snappydata-store-hydra-tests-*` +list=`ls $JTESTS/../../../libs/snappydata-store-hydra-tests-*` filename=`tr "/" "\n" <<< $list | tail -1` export releaseVersion=`echo "${filename%*.*}"| cut -d'-' -f5-6` @@ -87,12 +87,12 @@ snappyTestsJarName=`ls $SNAPPYDATADIR/dtests/build-artifacts/scala-2.11/libs/sna snappyTestsJarFilename=`tr "/" "\n" <<< $snappyTestsJarName | tail -1` export snappyTestsJarVersion=`echo "${snappyTestsJarFilename%*.*}"| cut -d'-' -f5-6` -CLASSPATH=$JTESTS:$EXTRA_JTESTS:$JTESTS/../../libs/snappydata-store-hydra-tests-${releaseVersion}-all.jar:$SNAPPYDATADIR/dtests/build-artifacts/scala-2.11/libs/snappydata-store-scala-tests-${snappyTestsJarVersion}-tests.jar +CLASSPATH=$JTESTS:$EXTRA_JTESTS:$JTESTS/../../../libs/snappydata-store-hydra-tests-${releaseVersion}-all.jar:$SNAPPYDATADIR/dtests/build-artifacts/scala-2.11/libs/snappydata-store-scala-tests-${snappyTestsJarVersion}-tests.jar LIB=$SNAPPYDATADIR/build-artifacts/scala-2.11/snappy/jars for i in $LIB/*.jar; do CLASSPATH=$CLASSPATH:$i; done export CLASSPATH=$CLASSPATH -export EXTRA_JTESTS=$SNAPPYDATADIR/store/tests/core/build-artifacts/linux/classes/main +export EXTRA_JTESTS=$SNAPPYDATADIR/store/tests/core/build-artifacts/linux/classes/java/main #export JTESTS_RESOURCES=$SNAPPYDATADIR/store/tests/core/src/main/java # This is the command to run the test, make sure the correct release version of jar used or change the jar path to use correctly. Also change the jar name in sql/snappy.local.conf if incorrect diff --git a/tests/core/src/main/java/bin/scaleperf/run.sh b/tests/core/src/main/java/bin/scaleperf/run.sh index 3108bc404..fc57c77bd 100755 --- a/tests/core/src/main/java/bin/scaleperf/run.sh +++ b/tests/core/src/main/java/bin/scaleperf/run.sh @@ -4,9 +4,9 @@ runtest() { export SNAPPYDATADIR=$1 export GEMFIRE=$SNAPPYDATADIR/build-artifacts/scala-2.10/store export LD_LIBRARY_PATH=$GEMFIRE/lib - export EXTRA_JTESTS=$SNAPPYDATADIR/store/tests/sql/build-artifacts/linux/classes/main - export JTESTS=$SNAPPYDATADIR/store/tests/core/build-artifacts/linux/classes/main - export CLASSPATH=$JTESTS:$EXTRA_JTESTS:$GEMFIRE/lib/snappydata-store-1.5.0-SNAPSHOT.jar:$GEMFIRE/lib/snappydata-store-client-1.5.0-SNAPSHOT.jar:JTESTS/../../libs/snappydata-store-hydra-tests-1.5.0-SNAPSHOT-all.jar:$GEMFIRE/lib/snappydata-store-tools-1.5.0-SNAPSHOT.jar:$SNAPPYDATADIR/snappy-dtests/build-artifacts/scala-2.10/libs/snappydata-store-scala-tests-0.1.0-SNAPSHOT.jar + export EXTRA_JTESTS=$SNAPPYDATADIR/store/tests/sql/build-artifacts/linux/classes/java/main + export JTESTS=$SNAPPYDATADIR/store/tests/core/build-artifacts/linux/classes/java/main + export CLASSPATH=$JTESTS:$EXTRA_JTESTS:$GEMFIRE/lib/snappydata-store-1.5.0-SNAPSHOT.jar:$GEMFIRE/lib/snappydata-store-client-1.5.0-SNAPSHOT.jar:JTESTS/../../../libs/snappydata-store-hydra-tests-1.5.0-SNAPSHOT-all.jar:$GEMFIRE/lib/snappydata-store-tools-1.5.0-SNAPSHOT.jar:$SNAPPYDATADIR/snappy-dtests/build-artifacts/scala-2.10/libs/snappydata-store-scala-tests-0.1.0-SNAPSHOT.jar echo "Running $JTESTS/smoketest/scale/scale.bt with $JTESTS/smoketest/scale/local.conf..." echo "" diff --git a/tests/core/src/main/java/cacheperf/comparisons/connection/preload/classlist.txt b/tests/core/src/main/java/cacheperf/comparisons/connection/preload/classlist.txt index db4b05437..934eecfa8 100644 --- a/tests/core/src/main/java/cacheperf/comparisons/connection/preload/classlist.txt +++ b/tests/core/src/main/java/cacheperf/comparisons/connection/preload/classlist.txt @@ -140,7 +140,7 @@ com.gemstone.gemfire.cache.RegionExistsException com.gemstone.gemfire.internal.cache.HasCachePerfStats com.gemstone.gemfire.cache.EntryNotFoundException com.gemstone.gemfire.cache.TransactionException -com.gemstone.gemfire.cache.CommitConflictException +com.gemstone.gemfire.cache.ConflictException com.gemstone.gemfire.admin.AdminDistributedSystem com.gemstone.gemfire.cache.query.IndexNameConflictException com.gemstone.gemfire.cache.query.IndexExistsException diff --git a/tests/core/src/main/java/com/gemstone/gemfire/admin/jmx/MailManagerDUnitTest.java b/tests/core/src/main/java/com/gemstone/gemfire/admin/jmx/MailManagerDUnitTest.java deleted file mode 100644 index daf0d9ee2..000000000 --- a/tests/core/src/main/java/com/gemstone/gemfire/admin/jmx/MailManagerDUnitTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you - * may not use this file except in compliance with the License. You - * may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. See accompanying - * LICENSE file. - */ -package com.gemstone.gemfire.admin.jmx; - -import com.gemstone.gemfire.admin.AdminDUnitTestCase; -import com.gemstone.gemfire.admin.jmx.internal.MailManager; -import com.gemstone.gemfire.cache.Cache; - -/** - * tesing functionality of mail manager - * - * @author mjha - * - */ -public class MailManagerDUnitTest extends AdminDUnitTestCase { - public static final long REFRESH_INTERVAL = 10000; - - public static final int MEM_VM = 0; - - protected static Cache cache = null; - - /** - * The constructor. - * - * @param name - */ - public MailManagerDUnitTest(String name) { - super(name); - } - - /** - * Testing the singleton behavior of stat alert manager - * - * @throws Exception - */ - public void testMailManager() throws Exception { - MailManager mailManager = new MailManager("mailsrv1.gemstone.com", - "temp@gemstone.com"); - - assertEquals(" 'mail from' id of mail manager is not correct", - "temp@gemstone.com", mailManager.getMailFromAddress()); - assertEquals(" 'mail host' of mail manager is not correct", - "mailsrv1.gemstone.com", mailManager.getMailHost()); - - mailManager.setMailHost("mailsrv2.gemstone.com"); - assertEquals(" 'mail host' of mail manager is not correct", - "mailsrv2.gemstone.com", mailManager.getMailHost()); - - mailManager.setMailFromAddress("temp1@gemstone.com"); - assertEquals(" 'mail from' of mail manager is not correct", - "temp1@gemstone.com", mailManager.getMailFromAddress()); - - mailManager.addMailToAddress("xyz@gemstone.com"); - mailManager.addMailToAddress("xyz1@gemstone.com"); - mailManager.addMailToAddress("xyz2@gemstone.com"); - assertEquals("No of 'To list' of mail manager is supposed to be 3 ", 3, - mailManager.getAllToAddresses().length); - - mailManager.removeMailToAddress("xyz1@gemstone.com"); - mailManager.removeMailToAddress("xyz2@gemstone.com"); - - assertEquals(" 'mail from' of mail manager is not correct", - "xyz@gemstone.com", mailManager.getAllToAddresses()[0]); - assertEquals("No of 'To list' of mail manager is supposed to be 1 ", 1, - mailManager.getAllToAddresses().length); - - mailManager.addMailToAddress("xyz1@gemstone.com"); - mailManager.addMailToAddress("xyz1@gemstone.com"); - assertEquals("No of 'To list' of mail manager is supposed to be 2 ", 2, - mailManager.getAllToAddresses().length); - - mailManager.addMailToAddress("xyz2@gemstone.com"); - - mailManager.removeAllMailToAddresses(); - assertEquals("No of 'To list' of mail manager is supposed to be 0 ", 0, - mailManager.getAllToAddresses().length); - - assertNotNull("to string method should not return null ", mailManager - .toString()); - } - -} diff --git a/tests/core/src/main/java/com/gemstone/gemfire/cache/query/PerfQuery.java b/tests/core/src/main/java/com/gemstone/gemfire/cache/query/PerfQuery.java index 44a64392e..4d1eb1ff0 100644 --- a/tests/core/src/main/java/com/gemstone/gemfire/cache/query/PerfQuery.java +++ b/tests/core/src/main/java/com/gemstone/gemfire/cache/query/PerfQuery.java @@ -34,7 +34,7 @@ import com.gemstone.gemfire.cache.query.internal.ResultsSet; import com.gemstone.gemfire.distributed.DistributedSystem; import com.gemstone.gemfire.internal.NanoTimer; -import com.gemstone.gnu.trove.TFloatArrayList; +import org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList; /** * @@ -60,16 +60,16 @@ public class PerfQuery { protected Cache cache; // RESULTS - private final TFloatArrayList[] results; + private final FloatArrayList[] results; /** Creates a new instance of PerfQuery */ public PerfQuery() { - results = new TFloatArrayList[4]; - results[BRUTE_FORCE] = new TFloatArrayList(); - results[HAND_CODED] = new TFloatArrayList(); - results[INDEXED] = new TFloatArrayList(); - results[INDEX_CREATE] = new TFloatArrayList(); + results = new FloatArrayList[4]; + results[BRUTE_FORCE] = new FloatArrayList(); + results[HAND_CODED] = new FloatArrayList(); + results[INDEXED] = new FloatArrayList(); + results[INDEX_CREATE] = new FloatArrayList(); } public void run() throws Exception { diff --git a/tests/core/src/main/java/com/gemstone/gemfire/cache30/RegionReliabilityTestCase.java b/tests/core/src/main/java/com/gemstone/gemfire/cache30/RegionReliabilityTestCase.java index b40549b13..8a1a9d165 100644 --- a/tests/core/src/main/java/com/gemstone/gemfire/cache30/RegionReliabilityTestCase.java +++ b/tests/core/src/main/java/com/gemstone/gemfire/cache30/RegionReliabilityTestCase.java @@ -1117,9 +1117,9 @@ public void run2() throws CacheException { try { ctm.commit(); - fail("Should have thrown CommitDistributionException"); + fail("Should have thrown ConflictException"); } - catch (CommitDistributionException e) { + catch (ConflictException e) { // pass } finally { diff --git a/tests/core/src/main/java/com/gemstone/gemfire/internal/cache/ClientServerTransactionDUnitTest.java b/tests/core/src/main/java/com/gemstone/gemfire/internal/cache/ClientServerTransactionDUnitTest.java index 3c7875f01..c0ccfb237 100644 --- a/tests/core/src/main/java/com/gemstone/gemfire/internal/cache/ClientServerTransactionDUnitTest.java +++ b/tests/core/src/main/java/com/gemstone/gemfire/internal/cache/ClientServerTransactionDUnitTest.java @@ -16,76 +16,7 @@ */ package com.gemstone.gemfire.internal.cache; -import com.gemstone.gemfire.cache.AttributesFactory; -import com.gemstone.gemfire.cache.Cache; -import com.gemstone.gemfire.cache.CacheFactory; -import com.gemstone.gemfire.cache.CacheListener; -import com.gemstone.gemfire.cache.CacheLoader; -import com.gemstone.gemfire.cache.CacheLoaderException; -import com.gemstone.gemfire.cache.CacheTransactionManager; -import com.gemstone.gemfire.cache.CacheWriterException; -import com.gemstone.gemfire.cache.CommitConflictException; -import com.gemstone.gemfire.cache.DataPolicy; -import com.gemstone.gemfire.cache.EntryEvent; -import com.gemstone.gemfire.cache.LoaderHelper; -import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache.Region.Entry; -import com.gemstone.gemfire.cache.RegionFactory; -import com.gemstone.gemfire.cache.RegionShortcut; -import com.gemstone.gemfire.cache.Scope; -import com.gemstone.gemfire.cache.TransactionDataNodeHasDepartedException; -import com.gemstone.gemfire.cache.TransactionEvent; -import com.gemstone.gemfire.cache.TransactionException; -import com.gemstone.gemfire.cache.TransactionId; -import com.gemstone.gemfire.cache.TransactionInDoubtException; -import com.gemstone.gemfire.cache.TransactionWriter; -import com.gemstone.gemfire.cache.TransactionWriterException; -import com.gemstone.gemfire.cache.UnsupportedOperationInTransactionException; -import com.gemstone.gemfire.cache.client.ClientCache; -import com.gemstone.gemfire.cache.client.ClientCacheFactory; -import com.gemstone.gemfire.cache.client.ClientRegionFactory; -import com.gemstone.gemfire.cache.client.ClientRegionShortcut; -import com.gemstone.gemfire.cache.client.PoolFactory; -import com.gemstone.gemfire.cache.client.PoolManager; -import com.gemstone.gemfire.cache.execute.Execution; -import com.gemstone.gemfire.cache.execute.FunctionAdapter; -import com.gemstone.gemfire.cache.execute.FunctionContext; -import com.gemstone.gemfire.cache.execute.FunctionException; -import com.gemstone.gemfire.cache.execute.FunctionService; -import com.gemstone.gemfire.cache.execute.RegionFunctionContext; -import com.gemstone.gemfire.cache.server.CacheServer; -import com.gemstone.gemfire.cache.util.CacheListenerAdapter; -import com.gemstone.gemfire.cache.util.CacheWriterAdapter; -import com.gemstone.gemfire.cache.util.TransactionListenerAdapter; import com.gemstone.gemfire.cache30.CacheTestCase; -import com.gemstone.gemfire.distributed.DistributedMember; -import com.gemstone.gemfire.distributed.DistributedSystem; -import com.gemstone.gemfire.distributed.internal.DistributionConfig; -import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; -import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember; -import com.gemstone.gemfire.internal.AvailablePort; -import com.gemstone.gemfire.internal.cache.execute.data.CustId; -import com.gemstone.gemfire.internal.cache.execute.data.Customer; -import com.gemstone.gemfire.internal.cache.execute.data.Order; -import com.gemstone.gemfire.internal.cache.execute.data.OrderId; - -import dunit.Host; -import dunit.SerializableCallable; -import dunit.SerializableRunnable; -import dunit.VM; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; -import java.util.concurrent.CountDownLatch; - -import javax.naming.Context; -import javax.transaction.UserTransaction; /** * Tests the basic client-server transaction functionality @@ -2608,7 +2539,7 @@ public void testDummy() { // getCache().getLogger().info("SWAP:Commit expect CCE"); // getCache().getCacheTransactionManager().commit(); // fail("expected CCE not thrown"); -// } catch (CommitConflictException cce) { +// } catch (ConflictException cce) { // getCache().getLogger().info("SWAP:Commit Caught CCE"); // } // outer.countDown(); diff --git a/tests/core/src/main/java/cq/CQKnownKeysTest.java b/tests/core/src/main/java/cq/CQKnownKeysTest.java index 889e252dc..ea1544f2f 100644 --- a/tests/core/src/main/java/cq/CQKnownKeysTest.java +++ b/tests/core/src/main/java/cq/CQKnownKeysTest.java @@ -14,17 +14,22 @@ * permissions and limitations under the License. See accompanying * LICENSE file. */ -package cq; +package cq; -import hydra.*; -import hydra.blackboard.*; -import util.*; import java.util.*; -import com.gemstone.gemfire.cache.*; -import com.gemstone.gemfire.cache.util.*; + +import com.gemstone.gemfire.cache.CacheLoaderException; +import com.gemstone.gemfire.cache.CacheWriterException; +import com.gemstone.gemfire.cache.ConflictException; +import com.gemstone.gemfire.cache.EntryNotFoundException; +import com.gemstone.gemfire.cache.InterestResultPolicy; +import com.gemstone.gemfire.cache.Region; +import com.gemstone.gemfire.cache.TimeoutException; import com.gemstone.gemfire.cache.client.Pool; import com.gemstone.gemfire.cache.query.*; -import com.gemstone.gemfire.distributed.*; +import hydra.*; +import hydra.blackboard.SharedCounters; +import util.*; public class CQKnownKeysTest { @@ -411,9 +416,9 @@ public void doOps(BitSet availableOps) { if (useTransactions) { try { TxHelper.commit(); - } catch (CommitConflictException e) { + } catch (ConflictException e) { // currently not expecting any conflicts ... - throw new TestException("Unexpected CommitConflictException " + TestHelper.getStackTrace(e)); + throw new TestException("Unexpected ConflictException " + TestHelper.getStackTrace(e)); } } @@ -763,7 +768,6 @@ protected void checkContainsValueForKey(Object key, boolean expected, String log * * @param key The key to check. * @param value The value for the key. - * @param logStr Used if throwing an error due to an unexpected value. */ protected void checkValue(Object key, Object value) { if (value instanceof QueryObject) { @@ -783,7 +787,6 @@ protected void checkValue(Object key, Object value) { * * @param key The key to check. * @param value The value for the key. - * @param logStr Used if throwing an error due to an unexpected value. */ protected void checkUpdatedValue(Object key, Object value) { if (value instanceof QueryObject) { diff --git a/tests/core/src/main/java/cq/CQTestVersionHelper.java b/tests/core/src/main/java/cq/CQTestVersionHelper.java index 8afe88249..ff40aa5fa 100644 --- a/tests/core/src/main/java/cq/CQTestVersionHelper.java +++ b/tests/core/src/main/java/cq/CQTestVersionHelper.java @@ -16,30 +16,28 @@ */ package cq; -import java.util.*; - -import pdx.PdxTest; -import pdx.PdxTestVersionHelper; -import util.*; -import hydra.*; +import java.io.File; +import java.util.HashMap; +import java.util.Map; +import java.util.Vector; -import com.gemstone.gemfire.cache.*; -import com.gemstone.gemfire.cache.client.Pool; -import com.gemstone.gemfire.pdx.PdxSerializable; +import com.gemstone.gemfire.cache.ConflictException; +import com.gemstone.gemfire.cache.GemFireCache; +import com.gemstone.gemfire.cache.Region; import com.gemstone.gemfire.cache.TransactionDataNodeHasDepartedException; import com.gemstone.gemfire.cache.TransactionDataRebalancedException; import com.gemstone.gemfire.cache.TransactionException; import com.gemstone.gemfire.cache.TransactionInDoubtException; +import com.gemstone.gemfire.cache.client.Pool; import com.gemstone.gemfire.pdx.PdxInstance; - -import java.io.File; -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Vector; +import hydra.*; +import pdx.PdxTest; +import pdx.PdxTestVersionHelper; +import util.CacheUtil; +import util.TestException; +import util.TestHelper; +import util.TestHelperPrms; +import util.TxHelper; /** * @author lhughes @@ -60,8 +58,6 @@ public CQTestVersionHelper(CQTest testInstance) { /** * Create a region with the given region description name. - * - * @param regDescriptName The name of a region description. */ public static void setTxMgr() { if (getInitialImage.InitImagePrms.useTransactions()) { @@ -261,7 +257,7 @@ protected void doEntryOperations(Region aRegion) { // Known to cause data inconsistency, keep track of keys involved in TxInDoubt transactions on the BB recordFailedOps(CQUtilBB.INDOUBT_TXOPS); } - } catch (CommitConflictException e) { + } catch (ConflictException e) { if (isSerialExecution) { // only one tx active, so we should have no conflicts throw new TestException("Unexpected " + e + " " + TestHelper.getStackTrace(e)); } else { // can occur with concurrent execution diff --git a/tests/core/src/main/java/delta/DeltaTest.java b/tests/core/src/main/java/delta/DeltaTest.java index e65cadd91..c7d7cd223 100644 --- a/tests/core/src/main/java/delta/DeltaTest.java +++ b/tests/core/src/main/java/delta/DeltaTest.java @@ -16,68 +16,14 @@ */ package delta; -import hydra.BridgeHelper; -import hydra.BridgePrms; -import hydra.CacheHelper; -import hydra.DistributedSystemHelper; -import hydra.GemFirePrms; -import hydra.GsRandom; -import hydra.HydraThreadLocal; -import hydra.Log; -import hydra.MasterController; -import hydra.ProcessMgr; -import hydra.RegionHelper; -import hydra.RegionPrms; -import hydra.RemoteTestModule; -import hydra.StopSchedulingOrder; -import hydra.StopSchedulingTaskOnClientOrder; -import hydra.TestConfig; - import java.io.EOFException; import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Vector; - -import parReg.ParRegUtil; -import util.BaseValueHolder; -import util.MethodCoordinator; -import util.NameFactory; -import util.SilenceListener; -import util.StopStartPrms; -import util.StopStartVMs; -import util.TestException; -import util.TestHelper; -import util.TestHelperPrms; -import util.TxHelper; -import util.ValueHolder; +import java.util.*; import com.gemstone.gemfire.CancelException; import com.gemstone.gemfire.Delta; import com.gemstone.gemfire.DeltaSerializationException; -import com.gemstone.gemfire.cache.AttributesFactory; -import com.gemstone.gemfire.cache.CacheLoaderException; -import com.gemstone.gemfire.cache.ClientHelper; -import com.gemstone.gemfire.cache.CommitConflictException; -import com.gemstone.gemfire.cache.EntryExistsException; -import com.gemstone.gemfire.cache.EntryNotFoundException; -import com.gemstone.gemfire.cache.InterestResultPolicy; -import com.gemstone.gemfire.cache.PartitionAttributes; -import com.gemstone.gemfire.cache.PartitionAttributesFactory; -import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache.RegionAttributes; -import com.gemstone.gemfire.cache.TimeoutException; -import com.gemstone.gemfire.cache.TransactionDataNodeHasDepartedException; -import com.gemstone.gemfire.cache.TransactionDataRebalancedException; -import com.gemstone.gemfire.cache.TransactionException; -import com.gemstone.gemfire.cache.TransactionInDoubtException; +import com.gemstone.gemfire.cache.*; import com.gemstone.gemfire.cache.client.ServerConnectivityException; import com.gemstone.gemfire.cache.client.ServerOperationException; import com.gemstone.gemfire.cache.partition.PartitionRegionHelper; @@ -88,8 +34,10 @@ import com.gemstone.gemfire.internal.cache.LocalRegion; import com.gemstone.gemfire.internal.cache.PartitionedRegion; import com.gemstone.gemfire.internal.cache.Token; - import diskReg.DiskRegUtil; +import hydra.*; +import parReg.ParRegUtil; +import util.*; public class DeltaTest { @@ -1018,9 +966,9 @@ protected void doEntryOperations(Region aReg) { Log.getLogWriter().info("Caught Exception " + e + ". Expected with concurrent execution, continuing test."); } catch (TransactionInDoubtException e) { Log.getLogWriter().info("Caught TransactionInDoubtException. Expected with concurrent execution, continuing test."); - } catch (CommitConflictException e) { + } catch (ConflictException e) { // can occur with concurrent execution - Log.getLogWriter().info("Caught CommitConflictException. Expected with concurrent execution, continuing test."); + Log.getLogWriter().info("Caught ConflictException. Expected with concurrent execution, continuing test."); } } @@ -1121,7 +1069,7 @@ protected void recordLoadToBB() { /** Add a new entry to the given region. * - * @param aRegion The region to use for adding a new entry. + * @param aReg The region to use for adding a new entry. * * @returns The key that was added. */ @@ -1158,7 +1106,7 @@ protected Object addEntry(Region aReg) { /** Invalidate an entry in the given region. * - * @param aRegion The region to use for invalidating an entry. + * @param aReg The region to use for invalidating an entry. * @param isLocalInvalidate True if the invalidate should be local, false otherwise. */ protected void invalidateEntry(Region aReg, boolean isLocalInvalidate) { @@ -1215,7 +1163,7 @@ protected void invalidateEntry(Region aReg, boolean isLocalInvalidate) { /** Destroy an entry in the given region. * - * @param aRegion The region to use for destroying an entry. + * @param aReg The region to use for destroying an entry. * @param isLocalDestroy True if the destroy should be local, false otherwise. */ protected void destroyEntry(Region aReg, boolean isLocalDestroy) { @@ -1269,7 +1217,7 @@ protected void destroyEntry(Region aReg, boolean isLocalDestroy) { /** Update an existing entry in the given region. If there are * no available keys in the region, then this is a noop. * - * @param aRegion The region to use for updating an entry. + * @param aReg The region to use for updating an entry. */ protected void updateEntry(Region aReg) { Object key = getExistingKey(aReg, uniqueKeys, numThreadsInClients); @@ -1312,7 +1260,7 @@ protected void updateEntry(Region aReg) { /** Get an existing key in the given region if one is available, * otherwise get a new key. * - * @param aRegion The region to use for getting an entry. + * @param aReg The region to use for getting an entry. */ protected void getKey(Region aReg) { Object key = getExistingKey(aReg, uniqueKeys, numThreadsInClients); @@ -1355,7 +1303,7 @@ protected void getKey(Region aReg) { /** Get a new key int the given region. * - * @param aRegion The region to use for getting an entry. + * @param aReg The region to use for getting an entry. */ protected void getNewKey(Region aReg) { Object key = getNewKey(); diff --git a/tests/core/src/main/java/hct/BridgeNotify.java b/tests/core/src/main/java/hct/BridgeNotify.java index 904343569..cdea0f0bf 100644 --- a/tests/core/src/main/java/hct/BridgeNotify.java +++ b/tests/core/src/main/java/hct/BridgeNotify.java @@ -18,22 +18,24 @@ package hct; -import java.util.*; -import hydra.*; -import util.*; -import vsphere.vijava.VMotionTestBase; -import delta.DeltaValueHolder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.Set; import com.gemstone.gemfire.SystemFailure; import com.gemstone.gemfire.cache.*; +import com.gemstone.gemfire.cache.query.QueryInvocationTargetException; +import com.gemstone.gemfire.cache.query.SelectResults; import com.gemstone.gemfire.cache.server.CacheServer; -import com.gemstone.gemfire.cache.util.*; -import com.gemstone.gemfire.cache.client.PoolManager; -import com.gemstone.gemfire.cache.query.*; // SelectResults -import com.gemstone.gemfire.distributed.*; - - +import com.gemstone.gemfire.cache.util.BridgeWriterException; import cq.CQUtil; +import delta.DeltaValueHolder; +import hydra.*; +import util.*; +import vsphere.vijava.VMotionTestBase; /** * Contains Hydra tasks and supporting methods for testing the GemFire @@ -169,7 +171,7 @@ public static void clearEventCounters() { } /** - * @see HydraTask_initialize + * see HydraTask_initialize */ public void initialize() { @@ -307,7 +309,7 @@ protected void populateRegion(Region aRegion) { * bridgeClients with notifyBySubscription = false need to get all the * entries after the region has been created/populated * - * @see HydraTask_populateRegion + * see HydraTask_populateRegion */ public static void HydraTask_getEntriesFromServer() { Region rootRegion = CacheHelper.getCache().getRegion(BridgeNotify.REGION_NAME); @@ -445,9 +447,9 @@ protected void doEntryOperations(Region aRegion) { throw new TestException("Unexpected Exception " + e + ". " + TestHelper.getStackTrace(e)); } catch (TransactionInDoubtException e) { Log.getLogWriter().info("Caught TransactionInDoubtException. Expected with concurrent execution, continuing test."); - } catch (CommitConflictException e) { + } catch (ConflictException e) { // can occur with concurrent execution - Log.getLogWriter().info("Caught CommitConflictException. Expected with concurrent execution, continuing test."); + Log.getLogWriter().info("Caught ConflictException. Expected with concurrent execution, continuing test."); } if (isSerialExecution) { @@ -1321,7 +1323,7 @@ public static void HydraTask_validateEventsReceived() { } /** - * @see HydraTask_validateEventsReceived + * see HydraTask_validateEventsReceived */ protected void validateEventsReceived() { Log.getLogWriter().info("invoked validateEventReceived()"); diff --git a/tests/core/src/main/java/hct/RandInterestPolicyTest.java b/tests/core/src/main/java/hct/RandInterestPolicyTest.java index 4f5fe50c9..85d5761d9 100644 --- a/tests/core/src/main/java/hct/RandInterestPolicyTest.java +++ b/tests/core/src/main/java/hct/RandInterestPolicyTest.java @@ -16,12 +16,17 @@ */ package hct; -import java.util.*; -import util.*; -import hydra.*; -import cq.*; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + import com.gemstone.gemfire.cache.*; import com.gemstone.gemfire.internal.cache.LocalRegion; +import cq.CQUtil; +import hydra.*; +import util.*; public class RandInterestPolicyTest { @@ -453,9 +458,9 @@ protected void doEntryOperations(Region aRegion) { Log.getLogWriter().info("Caught Exception " + e + ". Expected with concurrent execution, continuing test."); } catch (TransactionInDoubtException e) { Log.getLogWriter().info("Caught TransactionInDoubtException. Expected with concurrent execution, continuing test."); - } catch (CommitConflictException e) { + } catch (ConflictException e) { // can occur with concurrent execution - Log.getLogWriter().info("Caught CommitConflictException. Expected with concurrent execution, continuing test."); + Log.getLogWriter().info("Caught ConflictException. Expected with concurrent execution, continuing test."); } } @@ -1256,7 +1261,7 @@ protected static void verifyContainsValueForKey(Region aRegion, Object key, bool * @param key The key in aRegion to verify. * @param expectedValue The expected myValue field of a ValueHolder in aRegion, or null * if the expected value should be null. - * @param valuetoCheck This is expected to be a ValueHolder, whose myValue field compares + * @param valueToCheck This is expected to be a ValueHolder, whose myValue field compares * to expectedValue, according to comparStrategy * @param compareStrategy Whether the compare is equals or equivalent (for ValueHolders) * diff --git a/tests/core/src/main/java/hct/backwardCompatibility/BackwardCompatibilityVersionHelper.java b/tests/core/src/main/java/hct/backwardCompatibility/BackwardCompatibilityVersionHelper.java index ecdd4a953..8fe4f2eab 100644 --- a/tests/core/src/main/java/hct/backwardCompatibility/BackwardCompatibilityVersionHelper.java +++ b/tests/core/src/main/java/hct/backwardCompatibility/BackwardCompatibilityVersionHelper.java @@ -14,15 +14,20 @@ * permissions and limitations under the License. See accompanying * LICENSE file. */ -package hct.backwardCompatibility; +package hct.backwardCompatibility; -import java.util.*; - -import hydra.*; -import util.*; -import cq.*; - -import com.gemstone.gemfire.cache.*; +import com.gemstone.gemfire.cache.ConflictException; +import com.gemstone.gemfire.cache.Region; +import com.gemstone.gemfire.cache.TransactionDataNodeHasDepartedException; +import com.gemstone.gemfire.cache.TransactionDataRebalancedException; +import com.gemstone.gemfire.cache.TransactionException; +import com.gemstone.gemfire.cache.TransactionInDoubtException; +import hydra.Log; +import hydra.TestConfig; +import util.TestException; +import util.TestHelper; +import util.TestHelperPrms; +import util.TxHelper; /** VersionHelper class (for Transaction support) */ public class BackwardCompatibilityVersionHelper { @@ -104,8 +109,8 @@ protected void doEntryOperations(BackwardCompatibilityTest testInstance, Region Log.getLogWriter().info("Caught TransactionDataNodeHasDepartedException. Expected with concurrent execution, continuing test."); } catch (TransactionInDoubtException e) { Log.getLogWriter().info("Caught TransactionInDoubtException. Expected with concurrent execution, continuing test."); - } catch (CommitConflictException e) { - Log.getLogWriter().info("CommitConflictException " + e + " expected, continuing test"); + } catch (ConflictException e) { + Log.getLogWriter().info("ConflictException " + e + " expected, continuing test"); } } else { TxHelper.rollback(); diff --git a/tests/core/src/main/java/hct/ha/Feeder.java b/tests/core/src/main/java/hct/ha/Feeder.java index 39b3f5341..e5105f772 100644 --- a/tests/core/src/main/java/hct/ha/Feeder.java +++ b/tests/core/src/main/java/hct/ha/Feeder.java @@ -17,18 +17,17 @@ package hct.ha; import java.util.ArrayList; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.HashMap; import java.util.Random; - -import com.gemstone.gemfire.cache.*; - -import util.TestException; -import util.TestHelper; -import util.TxHelper; +import com.gemstone.gemfire.cache.Cache; +import com.gemstone.gemfire.cache.ConflictException; +import com.gemstone.gemfire.cache.EntryExistsException; +import com.gemstone.gemfire.cache.EntryNotFoundException; +import com.gemstone.gemfire.cache.Region; import hct.HctPrms; import hydra.CacheHelper; import hydra.ConfigPrms; @@ -36,6 +35,9 @@ import hydra.ProcessMgr; import hydra.RegionHelper; import hydra.TestConfig; +import util.TestException; +import util.TestHelper; +import util.TxHelper; /** @@ -745,8 +747,8 @@ else if (operation.equals("destroy")) { try { TxHelper.commit(); } - catch (CommitConflictException e){ - // revert the counters in case of CommitConflictException + catch (ConflictException e){ + // revert the counters in case of ConflictException numCreate = 0 ; numDestroy = 0 ; numInvalidate = 0 ; diff --git a/tests/core/src/main/java/hydra/DerbyServerMgr.java b/tests/core/src/main/java/hydra/DerbyServerMgr.java index ee52aa1ff..4e38613c0 100644 --- a/tests/core/src/main/java/hydra/DerbyServerMgr.java +++ b/tests/core/src/main/java/hydra/DerbyServerMgr.java @@ -31,11 +31,13 @@ public class DerbyServerMgr HostDescription hd = TestConfig.getInstance().getMasterDescription() .getVmDescription().getHostDescription(); if (HostHelper.getLocalHostOS() == OSType.windows) { - defaultDerbyNetJarPath = hd.getTestDir() + hd.getFileSep() + ".." + hd.getFileSep() + ".." + hd.getFileSep() + "libs" + hd.getFileSep() + "snappydata-store-hydra-tests-" + + defaultDerbyNetJarPath = hd.getTestDir() + hd.getFileSep() + ".." + hd.getFileSep() + ".." + + hd.getFileSep() + ".." + hd.getFileSep() + "libs" + hd.getFileSep() + "snappydata-store-hydra-tests-" + ProductVersionHelper.getInfo().getProperty(ProductVersionHelper.SNAPPYRELEASEVERSION) + "-all.jar"; cpSep = ";"; } else { - defaultDerbyNetJarPath = hd.getTestDir() + hd.getFileSep() + ".." + hd.getFileSep() + ".." + hd.getFileSep() + "libs" + hd.getFileSep() + "snappydata-store-hydra-tests-" + + defaultDerbyNetJarPath = hd.getTestDir() + hd.getFileSep() + ".." + hd.getFileSep() + ".." + + hd.getFileSep() + ".." + hd.getFileSep() + "libs" + hd.getFileSep() + "snappydata-store-hydra-tests-" + ProductVersionHelper.getInfo().getProperty(ProductVersionHelper.SNAPPYRELEASEVERSION) + "-all.jar"; cpSep = ":"; } diff --git a/tests/core/src/main/java/hydra/HostAgentDescription.java b/tests/core/src/main/java/hydra/HostAgentDescription.java index b4672c2c0..322fda544 100644 --- a/tests/core/src/main/java/hydra/HostAgentDescription.java +++ b/tests/core/src/main/java/hydra/HostAgentDescription.java @@ -150,7 +150,7 @@ private static void configure(TestConfig config, HostDescription hd, boolean arc //Needed to run hydra tests on multiple hosts classPath.add(hd.getTestDir() + hd.getFileSep() + ".." + hd.getFileSep() + ".." + - hd.getFileSep() + "libs" + hd.getFileSep() + "snappydata-store-hydra-tests-" + + hd.getFileSep() + ".." + hd.getFileSep() + "libs" + hd.getFileSep() + "snappydata-store-hydra-tests-" + ProductVersionHelper.getInfo().getProperty(ProductVersionHelper.SNAPPYRELEASEVERSION) + "-all.jar"); classPath.add(VmDescription.getSnappyJarPath(hd.getGemFireHome() + diff --git a/tests/core/src/main/java/hydra/HostPrms.java b/tests/core/src/main/java/hydra/HostPrms.java index e9f167672..9b7a30a52 100644 --- a/tests/core/src/main/java/hydra/HostPrms.java +++ b/tests/core/src/main/java/hydra/HostPrms.java @@ -213,10 +213,11 @@ public static String getJavaVendor() { } else if (vendor.contains("Hitachi")) { vendor = HITACHI; } else if (vendor.contains("Apple")) { - vendor = APPLE; + vendor = APPLE; } else if (vendor.contains("Oracle") && vmname.contains("JRockit")) { vendor = JROCKIT; - } else if (vendor.contains("Oracle") && vmname.contains("HotSpot")) { + } else if (vendor.contains("Oracle") && + (vmname.contains("HotSpot") || vmname.contains("OpenJDK"))) { vendor = SUN; } else { String s = "Unable to classify JVM with vendor: " + vendor diff --git a/tests/core/src/main/java/hydra/VersionDescription.java b/tests/core/src/main/java/hydra/VersionDescription.java index 1db2565fb..7703caabd 100644 --- a/tests/core/src/main/java/hydra/VersionDescription.java +++ b/tests/core/src/main/java/hydra/VersionDescription.java @@ -194,7 +194,7 @@ protected String getClassPath(VmDescription vmd, String version, // test jars classpath.add(hd.getTestDir() + hd.getFileSep() + ".." + hd.getFileSep() + ".." + - hd.getFileSep() + "libs" + hd.getFileSep() + "snappydata-store-hydra-tests-" + + hd.getFileSep() + ".." + hd.getFileSep() + "libs" + hd.getFileSep() + "snappydata-store-hydra-tests-" + ProductVersionHelper.getInfo().getProperty(ProductVersionHelper.SNAPPYRELEASEVERSION) + "-all.jar"); classpath.add(VmDescription.getSnappyJarPath(hd.getGemFireHome() + diff --git a/tests/core/src/main/java/hydra/VmDescription.java b/tests/core/src/main/java/hydra/VmDescription.java index 4e1ca89bc..31308e5f6 100644 --- a/tests/core/src/main/java/hydra/VmDescription.java +++ b/tests/core/src/main/java/hydra/VmDescription.java @@ -277,7 +277,7 @@ protected static void configure( TestConfig config ) { // classPath -- test jars classPath.add(hd.getTestDir() + hd.getFileSep() + ".." + hd.getFileSep() + ".." + - hd.getFileSep() + "libs" + hd.getFileSep() + "snappydata-store-hydra-tests-" + + hd.getFileSep() + ".." + hd.getFileSep() + "libs" + hd.getFileSep() + "snappydata-store-hydra-tests-" + ProductVersionHelper.getInfo().getProperty(ProductVersionHelper.SNAPPYRELEASEVERSION) + "-all.jar"); classPath.add(VmDescription.getSnappyJarPath(hd.getGemFireHome() + diff --git a/tests/core/src/main/java/nbsTests/NBSTest.java b/tests/core/src/main/java/nbsTests/NBSTest.java index a1bde169f..cf49e7a60 100644 --- a/tests/core/src/main/java/nbsTests/NBSTest.java +++ b/tests/core/src/main/java/nbsTests/NBSTest.java @@ -16,44 +16,32 @@ */ package nbsTests; +import java.util.BitSet; +import java.util.HashMap; +import java.util.Vector; + +import com.gemstone.gemfire.cache.CacheWriterException; +import com.gemstone.gemfire.cache.ConflictException; +import com.gemstone.gemfire.cache.TransactionDataNodeHasDepartedException; +import com.gemstone.gemfire.cache.TransactionDataRebalancedException; +import com.gemstone.gemfire.cache.TransactionException; +import com.gemstone.gemfire.cache.TransactionInDoubtException; +import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; +import durableClients.DurableClientsBB; import getInitialImage.InitImageBB; -import getInitialImage.InitImageTest; import getInitialImage.InitImagePrms; +import getInitialImage.InitImageTest; import hct.BBoard; import hct.HctPrms; import hct.InterestPolicyTest; -import hydra.ClientVmInfo; -import hydra.ClientVmMgr; -import hydra.ClientVmNotFoundException; -import hydra.Log; -import hydra.MasterController; -import hydra.CacheHelper; -import hydra.RegionHelper; -import hydra.StopSchedulingTaskOnClientOrder; -import hydra.TestConfig; -import hydra.blackboard.*; - -import java.util.BitSet; -import java.util.HashMap; -import java.util.Vector; - +import hydra.*; +import hydra.blackboard.SharedCounters; import parReg.ParRegBB; - import util.KeyIntervals; import util.TestException; import util.TestHelper; import util.TxHelper; -import com.gemstone.gemfire.cache.CacheWriterException; -import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; -import com.gemstone.gemfire.cache.TransactionDataNodeHasDepartedException; -import com.gemstone.gemfire.cache.TransactionException; -import com.gemstone.gemfire.cache.TransactionInDoubtException; -import com.gemstone.gemfire.cache.TransactionDataRebalancedException; -import com.gemstone.gemfire.cache.CommitConflictException; - -import durableClients.DurableClientsBB; - public class NBSTest extends InterestPolicyTest{ public static final String VM_REG_INTEREST = "Vm Register Interest"; @@ -351,9 +339,9 @@ public void doOps(BitSet availableOps) { Log.getLogWriter().info("Caught " + e + " Expected with 6.5 PR Tx behavior, continuing test."); incrementFailedOpCounter(whichOp); } - } catch (CommitConflictException e) { + } catch (ConflictException e) { // currently not expecting any conflicts ... only one op per tx - throw new TestException("Unexpected CommitConflictException " + TestHelper.getStackTrace(e)); + throw new TestException("Unexpected ConflictException " + TestHelper.getStackTrace(e)); } } @@ -559,8 +547,6 @@ protected void registerInterestRegex(boolean receiveValues) { * @param isPartial If true, we only registered a partial set of keys, * rather than all keys used by the test. * (Used only if verify is true) -* @param expected The expected region contents if we should verify after -* each registerInterest call, false otherwise. */ protected void registerInterestSingle(boolean isPartial, boolean receiveValues) throws Exception { final int NUM_CASES = 3; diff --git a/tests/core/src/main/java/newWan/WANOperationsClient.java b/tests/core/src/main/java/newWan/WANOperationsClient.java index b3e082acb..c532c5b9f 100644 --- a/tests/core/src/main/java/newWan/WANOperationsClient.java +++ b/tests/core/src/main/java/newWan/WANOperationsClient.java @@ -16,52 +16,13 @@ */ package newWan; -import hydra.CacheHelper; -import hydra.GatewaySenderHelper; -import hydra.GsRandom; -import hydra.HydraRuntimeException; -import hydra.Log; -import hydra.MasterController; -import hydra.ProcessMgr; -import hydra.RemoteTestModule; -import hydra.StopSchedulingOrder; -import hydra.TestConfig; -import hydra.TestTask; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Set; -import java.util.TreeMap; - -import util.BaseValueHolder; -import util.NameFactory; -import util.OperationCountersBB; -import util.OperationsClient; -import util.OperationsClientPrms; -import util.StopStartVMs; -import util.TestException; -import util.TestHelper; -import util.TxHelper; -import util.ValueHolder; +import java.util.*; import com.gemstone.gemfire.LogWriter; -import com.gemstone.gemfire.cache.CacheClosedException; -import com.gemstone.gemfire.cache.CacheLoaderException; -import com.gemstone.gemfire.cache.CommitConflictException; -import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache.TimeoutException; -import com.gemstone.gemfire.cache.TransactionDataNodeHasDepartedException; -import com.gemstone.gemfire.cache.TransactionDataRebalancedException; -import com.gemstone.gemfire.cache.TransactionException; -import com.gemstone.gemfire.cache.TransactionInDoubtException; +import com.gemstone.gemfire.cache.*; import com.gemstone.gemfire.cache.wan.GatewaySender; +import hydra.*; +import util.*; public class WANOperationsClient extends OperationsClient { @@ -277,13 +238,13 @@ private void finishTransaction() { "Caught TransactionInDoubtException. " + "Expected with concurrent execution, continuing test."); } - catch (CommitConflictException e) { + catch (ConflictException e) { Log.getLogWriter().info( - "CommitConflictException " + e + " expected, continuing test"); + "ConflictException " + e + " expected, continuing test"); } catch (TransactionDataRebalancedException e) { Log.getLogWriter().info( - "CommitConflictException " + e + " expected, continuing test"); + "TransactionDataRebalancedException " + e + " expected, continuing test"); } } else { @@ -385,10 +346,8 @@ protected void putIfAbsent(Region aRegion, boolean logAddition) { /** * putall a map to the given region. - * - * @param aRegion - * The region to use for putall a map. - * + * + * @param r The region to use for putall a map. */ protected void putAll(Region r) { // determine the number of new keys to put in the putAll diff --git a/tests/core/src/main/java/orderPolicy/OrderPolicyTest.java b/tests/core/src/main/java/orderPolicy/OrderPolicyTest.java index 8cfca6089..b40d752ca 100644 --- a/tests/core/src/main/java/orderPolicy/OrderPolicyTest.java +++ b/tests/core/src/main/java/orderPolicy/OrderPolicyTest.java @@ -17,86 +17,27 @@ package orderPolicy; -import hct.BBoard; -import hct.HctPrms; -import hydra.blackboard.*; -import hydra.BridgeHelper; -import hydra.CacheHelper; -import hydra.ClientPrms; -import hydra.ClientVmInfo; -import hydra.ClientVmMgr; -import hydra.ClientVmNotFoundException; -import hydra.ConfigHashtable; -import hydra.ConfigPrms; -import hydra.DistributedSystemHelper; -import hydra.EdgeHelper; -import hydra.GatewayHubHelper; -import hydra.GatewaySenderHelper; -import hydra.GatewaySenderPrms; -import hydra.GsRandom; -import hydra.HydraRuntimeException; -import hydra.HydraThreadLocal; -import hydra.Log; -import hydra.MasterController; -import hydra.RegionHelper; -import hydra.RemoteTestModule; -import hydra.StopSchedulingTaskOnClientOrder; -import hydra.TestConfig; -import hydra.BridgeHelper.Endpoint; -import hydra.blackboard.SharedCounters; -import hydra.blackboard.SharedMap; - -import java.net.InetSocketAddress; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Vector; -import security.SecurityClientsPrms; +import com.gemstone.gemfire.cache.Cache; +import com.gemstone.gemfire.cache.ClientHelper; +import com.gemstone.gemfire.cache.Region; +import com.gemstone.gemfire.cache.client.internal.PoolImpl; +import com.gemstone.gemfire.cache.util.GatewayHub; +import com.gemstone.gemfire.distributed.internal.ServerLocation; +import hct.HctPrms; +import hydra.*; +import hydra.blackboard.Blackboard; import util.NameFactory; import util.RandomValues; import util.TestException; import util.TestHelper; import util.TestHelperPrms; -import util.TxHelper; import util.ValueHolder; - -import com.gemstone.gemfire.InternalGemFireException; -import com.gemstone.gemfire.LogWriter; -import com.gemstone.gemfire.Statistics; -import com.gemstone.gemfire.StatisticsFactory; -import com.gemstone.gemfire.SystemFailure; -import com.gemstone.gemfire.cache.Cache; -import com.gemstone.gemfire.cache.CacheException; -import com.gemstone.gemfire.cache.ClientHelper; -import com.gemstone.gemfire.cache.EntryDestroyedException; -import com.gemstone.gemfire.cache.EntryNotFoundException; -import com.gemstone.gemfire.cache.InterestResultPolicy; -import com.gemstone.gemfire.cache.PartitionAttributes; -import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache.client.internal.PoolImpl; -import com.gemstone.gemfire.cache.query.SelectResults; -import com.gemstone.gemfire.cache.server.CacheServer; -import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; -import com.gemstone.gemfire.distributed.internal.ServerLocation; -import com.gemstone.gemfire.internal.cache.GatewayStats; -import com.gemstone.gemfire.internal.cache.LocalRegion; -import com.gemstone.gemfire.security.AuthenticationFailedException; - -import com.gemstone.gemfire.cache.CommitConflictException; -import com.gemstone.gemfire.cache.TransactionDataNodeHasDepartedException; -import com.gemstone.gemfire.cache.TransactionException; -import com.gemstone.gemfire.cache.TransactionInDoubtException; -import com.gemstone.gemfire.cache.util.GatewayHub; - -import cq.CQUtil; -import cq.CQUtilBB; -import diskReg.DiskRegUtil; -import durableClients.DurableClientsBB; -import wan.*; +import wan.CacheClientPrms; +import wan.CacheServerPrms; +import wan.WANBlackboard; +import wan.WANClient; /** * Extends wan.OrderPolicyTest for Gateway.OrderPolicy and Gateway.ConcurrencyLevel diff --git a/tests/core/src/main/java/parReg/ParRegTest.java b/tests/core/src/main/java/parReg/ParRegTest.java index 56569612e..28bc57128 100644 --- a/tests/core/src/main/java/parReg/ParRegTest.java +++ b/tests/core/src/main/java/parReg/ParRegTest.java @@ -16,120 +16,15 @@ */ package parReg; -import hdfs.HDFSUtil; - -import hydra.BridgeHelper; -import hydra.BridgePrms; -import hydra.CacheHelper; -import hydra.CachePrms; -import hydra.ClientPrms; -import hydra.ClientVmInfo; -import hydra.ClientVmMgr; -import hydra.ConfigPrms; -import hydra.DiskStoreDescription; -import hydra.DiskStoreHelper; -import hydra.DistributedSystemHelper; -import hydra.HostHelper; -import hydra.HydraConfigException; -import hydra.HydraRuntimeException; -import hydra.HydraThreadLocal; -import hydra.Log; -import hydra.MasterController; -import hydra.PoolDescription; -import hydra.ProcessMgr; -import hydra.RegionHelper; -import hydra.RegionPrms; -import hydra.RemoteTestModule; -import hydra.StopSchedulingOrder; -import hydra.StopSchedulingTaskOnClientOrder; -import hydra.TestConfig; - -import hydra.ClientCacheHelper; -import hydra.ClientCachePrms; -import hydra.ClientRegionHelper; -import hydra.ClientRegionPrms; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.Set; -import java.util.TreeMap; -import java.util.Vector; +import java.io.*; +import java.util.*; import java.util.concurrent.CancellationException; -import memscale.MemScaleBB; -import memscale.OffHeapHelper; - -import pdx.PdxTest; -import pdx.PdxTestVersionHelper; -import rebalance.RebalanceUtil; -import util.AdminHelper; -import util.BaseValueHolder; -import util.CacheDefPrms; -import util.CacheDefinition; -import util.CacheUtil; -import util.CliHelper; -import util.CliHelperPrms; -import util.DeclarativeGenerator; -import util.MethodCoordinator; -import util.NameFactory; -import util.PRObserver; -import util.PersistenceUtil; -import util.RandomValues; -import util.RegionDefinition; -import util.SilenceListener; -import util.StopStartBB; -import util.StopStartPrms; -import util.StopStartVMs; -import util.TestException; -import util.TestHelper; -import util.TestHelperPrms; -import util.TxHelper; -import util.ValueHolder; -import util.ValueHolderPrms; - -import cacheperf.CachePerfClient; - import com.gemstone.gemfire.CancelException; import com.gemstone.gemfire.ToDataException; import com.gemstone.gemfire.admin.AdminDistributedSystem; import com.gemstone.gemfire.admin.RegionNotFoundException; -import com.gemstone.gemfire.cache.Cache; -import com.gemstone.gemfire.cache.CacheClosedException; -import com.gemstone.gemfire.cache.CacheLoaderException; -import com.gemstone.gemfire.cache.ClientHelper; -import com.gemstone.gemfire.cache.CommitConflictException; -import com.gemstone.gemfire.cache.ConflictException; -import com.gemstone.gemfire.cache.DataPolicy; -import com.gemstone.gemfire.cache.EntryExistsException; -import com.gemstone.gemfire.cache.EntryNotFoundException; -import com.gemstone.gemfire.cache.EvictionAlgorithm; -import com.gemstone.gemfire.cache.GemFireCache; -import com.gemstone.gemfire.cache.PartitionAttributes; -import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache.RegionAttributes; -import com.gemstone.gemfire.cache.RegionDestroyedException; -import com.gemstone.gemfire.cache.TransactionDataNodeHasDepartedException; -import com.gemstone.gemfire.cache.TransactionDataRebalancedException; -import com.gemstone.gemfire.cache.TransactionException; -import com.gemstone.gemfire.cache.TransactionInDoubtException; +import com.gemstone.gemfire.cache.*; import com.gemstone.gemfire.cache.client.ServerOperationException; import com.gemstone.gemfire.cache.control.RebalanceFactory; import com.gemstone.gemfire.cache.control.RebalanceOperation; @@ -137,17 +32,7 @@ import com.gemstone.gemfire.cache.control.ResourceManager; import com.gemstone.gemfire.cache.partition.PartitionRegionHelper; import com.gemstone.gemfire.cache.persistence.PartitionOfflineException; -import com.gemstone.gemfire.cache.query.FunctionDomainException; -import com.gemstone.gemfire.cache.query.Index; -import com.gemstone.gemfire.cache.query.IndexExistsException; -import com.gemstone.gemfire.cache.query.IndexInvalidException; -import com.gemstone.gemfire.cache.query.IndexNameConflictException; -import com.gemstone.gemfire.cache.query.NameResolutionException; -import com.gemstone.gemfire.cache.query.Query; -import com.gemstone.gemfire.cache.query.QueryInvocationTargetException; -import com.gemstone.gemfire.cache.query.QueryService; -import com.gemstone.gemfire.cache.query.SelectResults; -import com.gemstone.gemfire.cache.query.TypeMismatchException; +import com.gemstone.gemfire.cache.query.*; import com.gemstone.gemfire.cache.util.BridgeWriterException; import com.gemstone.gemfire.distributed.DistributedLockService; import com.gemstone.gemfire.distributed.DistributedSystemDisconnectedException; @@ -157,8 +42,16 @@ import com.gemstone.gemfire.internal.cache.PartitionedRegion; import com.gemstone.gemfire.pdx.PdxInstance; import com.gemstone.gemfire.pdx.WritablePdxInstance; - import delta.DeltaValueHolder; +import hdfs.HDFSUtil; +import hydra.*; +import hydra.CachePrms; +import memscale.MemScaleBB; +import memscale.OffHeapHelper; +import pdx.PdxTest; +import pdx.PdxTestVersionHelper; +import rebalance.RebalanceUtil; +import util.*; /** Test class for serial and concurrent partitioned region tests with * verification. diff --git a/tests/core/src/main/java/parReg/colocation/ParRegColocation.java b/tests/core/src/main/java/parReg/colocation/ParRegColocation.java index 45fc5671c..4393576ca 100644 --- a/tests/core/src/main/java/parReg/colocation/ParRegColocation.java +++ b/tests/core/src/main/java/parReg/colocation/ParRegColocation.java @@ -16,80 +16,23 @@ */ package parReg.colocation; +import java.io.File; +import java.util.*; + +import com.gemstone.gemfire.cache.*; +import com.gemstone.gemfire.internal.cache.BucketDump; +import com.gemstone.gemfire.internal.cache.ForceReattemptException; +import com.gemstone.gemfire.internal.cache.PartitionedRegion; import getInitialImage.InitImageBB; import getInitialImage.InitImagePrms; -import hydra.BridgeHelper; -import hydra.BridgePrms; -import hydra.CacheHelper; -import hydra.ClientVmInfo; -import hydra.ClientVmMgr; -import hydra.ClientVmNotFoundException; -import hydra.ConfigPrms; -import hydra.DiskStorePrms; -import hydra.DistributedSystemHelper; -import hydra.GatewayPrms; -import hydra.GatewaySenderHelper; -import hydra.GatewaySenderPrms; -import hydra.HDFSStoreHelper; -import hydra.Log; -import hydra.PoolHelper; -import hydra.PoolPrms; -import hydra.RegionHelper; -import hydra.RegionPrms; -import hydra.RemoteTestModule; -import hydra.StopSchedulingTaskOnClientOrder; -import hydra.TestConfig; +import hydra.*; import hydratest.grid.GridPrms; - -import java.io.File; -import java.util.ArrayList; -import java.util.BitSet; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Vector; - import parReg.ParRegBB; import parReg.ParRegPrms; import parReg.ParRegUtil; -import parReg.ParRegUtilVersionHelper; import parReg.execute.UpdateBBPartitionListener; import pdx.PdxTest; -import util.BaseValueHolder; -import util.KeyIntervals; -import util.NameBB; -import util.NameFactory; -import util.PRObserver; -import util.RandomValues; -import util.SilenceListener; -import util.StopStartVMs; -import util.TestException; -import util.TestHelper; -import util.TestHelperPrms; -import util.TxHelper; -import util.ValueHolder; -import util.ValueHolderPrms; - -import com.gemstone.gemfire.cache.Cache; -import com.gemstone.gemfire.cache.CacheLoaderException; -import com.gemstone.gemfire.cache.CacheWriterException; -import com.gemstone.gemfire.cache.CommitConflictException; -import com.gemstone.gemfire.cache.DataPolicy; -import com.gemstone.gemfire.cache.PartitionAttributes; -import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache.RegionAttributes; -import com.gemstone.gemfire.cache.RegionExistsException; -import com.gemstone.gemfire.cache.TimeoutException; -import com.gemstone.gemfire.cache.TransactionDataNodeHasDepartedException; -import com.gemstone.gemfire.cache.TransactionDataRebalancedException; -import com.gemstone.gemfire.cache.TransactionException; -import com.gemstone.gemfire.cache.TransactionInDoubtException; -import com.gemstone.gemfire.internal.cache.BucketDump; -import com.gemstone.gemfire.internal.cache.ForceReattemptException; -import com.gemstone.gemfire.internal.cache.PartitionedRegion; +import util.*; public class ParRegColocation { @@ -996,9 +939,9 @@ public void doOps(BitSet availableOps) { } catch (TransactionInDoubtException e) { Log.getLogWriter().info("Caught Exception " + e + ". Expected with concurrent execution, continuing test."); recordFailedOps(ParRegBB.INDOUBT_TXOPS); - } catch (CommitConflictException e) { + } catch (ConflictException e) { // Not expected as there is only one op per tx - throw new TestException("Unexpected CommitConflictException " + TestHelper.getStackTrace(e)); + throw new TestException("Unexpected ConflictException " + TestHelper.getStackTrace(e)); } } @@ -1091,8 +1034,6 @@ protected void checkContainsKey(Region aRegion, Object key, boolean expected, * The key to check. * @param value * The value for the key. - * @param logStr - * Used if throwing an error due to an unexpected value. */ protected void checkValue(Object key, Object value) { if (value instanceof BaseValueHolder) { @@ -1124,8 +1065,6 @@ protected void checkValue(Object key, Object value) { * The key to check. * @param value * The value for the key. - * @param logStr - * Used if throwing an error due to an unexpected value. */ protected void checkUpdatedValue(Object key, Object value) { if (value instanceof BaseValueHolder) { diff --git a/tests/core/src/main/java/parReg/execute/ExecutionAndColocationTest.java b/tests/core/src/main/java/parReg/execute/ExecutionAndColocationTest.java index a537c442e..9e0cc9329 100644 --- a/tests/core/src/main/java/parReg/execute/ExecutionAndColocationTest.java +++ b/tests/core/src/main/java/parReg/execute/ExecutionAndColocationTest.java @@ -16,58 +16,9 @@ */ package parReg.execute; -import getInitialImage.InitImageBB; -import hydra.BridgeHelper; -import hydra.BridgePrms; -import hydra.CacheHelper; -import hydra.ClientVmMgr; -import hydra.ClientVmNotFoundException; -import hydra.ConfigPrms; -import hydra.DistributedSystemHelper; -import hydra.GatewayHubHelper; -import hydra.GatewayPrms; -import hydra.Log; -import hydra.PoolHelper; -import hydra.RegionHelper; -import hydra.RemoteTestModule; -import hydra.StopSchedulingTaskOnClientOrder; -import hydra.TestConfig; - -import java.util.ArrayList; -import java.util.BitSet; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; -import parReg.KnownKeysTest; -import parReg.ParRegBB; -import parReg.ParRegPrms; -import parReg.ParRegUtil; -import parReg.colocation.Month; -import pdx.PdxTest; -import pdx.PdxTestVersionHelper; -import util.KeyIntervals; -import util.NameFactory; -import util.PRObserver; -import util.RandomValues; -import util.SilenceListener; -import util.TestException; -import util.TestHelper; -import util.TestHelperPrms; -import util.TxHelper; - -import com.gemstone.gemfire.cache.Cache; -import com.gemstone.gemfire.cache.CommitConflictException; -import com.gemstone.gemfire.cache.DataPolicy; -import com.gemstone.gemfire.cache.PartitionAttributes; -import com.gemstone.gemfire.cache.RegionAttributes; -import com.gemstone.gemfire.cache.TransactionDataNodeHasDepartedException; -import com.gemstone.gemfire.cache.TransactionDataRebalancedException; -import com.gemstone.gemfire.cache.TransactionException; -import com.gemstone.gemfire.cache.TransactionInDoubtException; +import com.gemstone.gemfire.cache.*; import com.gemstone.gemfire.cache.client.Pool; import com.gemstone.gemfire.cache.execute.Execution; import com.gemstone.gemfire.cache.execute.Function; @@ -85,6 +36,16 @@ import com.gemstone.gemfire.internal.cache.execute.InternalExecution; import com.gemstone.gemfire.internal.cache.execute.MemberMappedArgument; import com.gemstone.gemfire.pdx.PdxInstance; +import getInitialImage.InitImageBB; +import hydra.*; +import parReg.KnownKeysTest; +import parReg.ParRegBB; +import parReg.ParRegPrms; +import parReg.ParRegUtil; +import parReg.colocation.Month; +import pdx.PdxTest; +import pdx.PdxTestVersionHelper; +import util.*; public class ExecutionAndColocationTest extends KnownKeysTest { @@ -436,7 +397,7 @@ public void doFunctionExecution(BitSet availableOps) { } catch (TransactionInDoubtException e) { Log.getLogWriter().info("Caught Exception " + e + ". Expected with concurrent execution, continuing test."); recordFailedOps(ParRegBB.INDOUBT_TXOPS); - } catch (CommitConflictException e) { + } catch (ConflictException e) { // not expected (with only one op per tx) throw new TestException("Unexpected Exception " + e + ". " + TestHelper.getStackTrace(e)); } diff --git a/tests/core/src/main/java/parReg/execute/FunctionServiceTest.java b/tests/core/src/main/java/parReg/execute/FunctionServiceTest.java index 2b578666c..ef5476989 100644 --- a/tests/core/src/main/java/parReg/execute/FunctionServiceTest.java +++ b/tests/core/src/main/java/parReg/execute/FunctionServiceTest.java @@ -16,72 +16,22 @@ */ package parReg.execute; -import getInitialImage.InitImageBB; -import hydra.BridgeHelper; -import hydra.BridgePrms; -import hydra.CacheHelper; -import hydra.DistributedSystemHelper; -import hydra.Log; -import hydra.PoolHelper; -import hydra.RegionDescription; -import hydra.RegionHelper; -import hydra.RemoteTestModule; -import hydra.StopSchedulingTaskOnClientOrder; -import hydra.TestConfig; -import hydra.BridgeHelper.Endpoint; - -import java.util.ArrayList; -import java.util.BitSet; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.Set; -import java.util.Vector; +import java.util.*; import java.util.Map.Entry; import java.util.concurrent.TimeUnit; -import parReg.ParRegBB; -import parReg.ParRegUtil; -import parReg.colocation.Month; -import parReg.colocation.ParRegColocation; -import pdx.PdxTest; -import perffmwk.PerfStatMgr; -import perffmwk.PerfStatValue; -import perffmwk.StatSpecTokens; -import util.KeyIntervals; -import util.NameFactory; -import util.PRObserver; -import util.RandomValues; -import util.SilenceListener; -import util.TestException; -import util.TestHelper; -import util.TestHelperPrms; -import util.TxHelper; -import util.BaseValueHolder; -import util.ValueHolder; - import com.gemstone.gemfire.cache.Cache; +import com.gemstone.gemfire.cache.ConflictException; import com.gemstone.gemfire.cache.Region; import com.gemstone.gemfire.cache.TransactionDataNodeHasDepartedException; import com.gemstone.gemfire.cache.TransactionDataRebalancedException; import com.gemstone.gemfire.cache.TransactionException; import com.gemstone.gemfire.cache.TransactionInDoubtException; -import com.gemstone.gemfire.cache.CommitConflictException; import com.gemstone.gemfire.cache.client.Pool; import com.gemstone.gemfire.cache.client.internal.ClientMetadataService; import com.gemstone.gemfire.cache.client.internal.ClientPartitionAdvisor; import com.gemstone.gemfire.cache.client.internal.PoolImpl; -import com.gemstone.gemfire.cache.execute.Execution; -import com.gemstone.gemfire.cache.execute.Function; -import com.gemstone.gemfire.cache.execute.FunctionAdapter; -import com.gemstone.gemfire.cache.execute.FunctionContext; -import com.gemstone.gemfire.cache.execute.FunctionException; -import com.gemstone.gemfire.cache.execute.FunctionService; -import com.gemstone.gemfire.cache.execute.RegionFunctionContext; -import com.gemstone.gemfire.cache.execute.ResultCollector; +import com.gemstone.gemfire.cache.execute.*; import com.gemstone.gemfire.cache.server.CacheServer; import com.gemstone.gemfire.distributed.DistributedSystem; import com.gemstone.gemfire.distributed.internal.DistributionConfig; @@ -94,6 +44,18 @@ import com.gemstone.gemfire.internal.cache.execute.PartitionedRegionFunctionExecutor; import com.gemstone.gemfire.internal.cache.execute.ServerRegionFunctionExecutor; import com.gemstone.gemfire.pdx.PdxInstance; +import getInitialImage.InitImageBB; +import hydra.*; +import hydra.BridgeHelper.Endpoint; +import parReg.ParRegBB; +import parReg.ParRegUtil; +import parReg.colocation.Month; +import parReg.colocation.ParRegColocation; +import pdx.PdxTest; +import perffmwk.PerfStatMgr; +import perffmwk.PerfStatValue; +import perffmwk.StatSpecTokens; +import util.*; public class FunctionServiceTest extends ParRegColocation { @@ -3588,9 +3550,9 @@ public void doFunctionExecution(BitSet availableOps) { } catch (TransactionInDoubtException e) { Log.getLogWriter().info("Caught Exception " + e + ". Expected with concurrent execution, continuing test."); recordFailedOps(ParRegBB.INDOUBT_TXOPS); - } catch (CommitConflictException e) { + } catch (ConflictException e) { // can occur with concurrent execution - Log.getLogWriter().info("Caught CommitConflictException. Expected with concurrent execution, continuing test."); + Log.getLogWriter().info("Caught ConflictException. Expected with concurrent execution, continuing test."); } } diff --git a/tests/core/src/main/java/parReg/tx/ParRegBridgeView.java b/tests/core/src/main/java/parReg/tx/ParRegBridgeView.java index 605ac1232..30df48e24 100644 --- a/tests/core/src/main/java/parReg/tx/ParRegBridgeView.java +++ b/tests/core/src/main/java/parReg/tx/ParRegBridgeView.java @@ -17,19 +17,26 @@ package parReg.tx; -import java.util.*; +import java.util.Iterator; +import java.util.List; -import com.gemstone.gemfire.distributed.DistributedMember; -import com.gemstone.gemfire.distributed.internal.ServerLocation; -import com.gemstone.gemfire.cache.*; +import com.gemstone.gemfire.cache.ConflictException; +import com.gemstone.gemfire.cache.Region; import com.gemstone.gemfire.cache.client.PoolManager; import com.gemstone.gemfire.cache.client.internal.PoolImpl; import com.gemstone.gemfire.cache.server.CacheServer; - +import com.gemstone.gemfire.distributed.DistributedMember; +import com.gemstone.gemfire.distributed.internal.ServerLocation; import hydra.*; - -import tx.*; -import util.*; +import tx.CollectionsTest; +import tx.OpList; +import tx.TxBB; +import tx.TxPrms; +import tx.ViewTest; +import util.CacheUtil; +import util.TestException; +import util.TestHelper; +import util.TxHelper; /** * A test to validate what different threads/VMs see in terms of @@ -126,8 +133,8 @@ protected void verifyResourcesReleased() { try { TxHelper.commit(); - } catch (CommitConflictException e) { - throw new TestException("Unexpected CommitConflictException " + TestHelper.getStackTrace(e)); + } catch (ConflictException e) { + throw new TestException("Unexpected ConflictException " + TestHelper.getStackTrace(e)); } } diff --git a/tests/core/src/main/java/parReg/wbcl/newWan/MyAsyncEventListener.java b/tests/core/src/main/java/parReg/wbcl/newWan/MyAsyncEventListener.java index 0df410358..346b188d9 100644 --- a/tests/core/src/main/java/parReg/wbcl/newWan/MyAsyncEventListener.java +++ b/tests/core/src/main/java/parReg/wbcl/newWan/MyAsyncEventListener.java @@ -51,10 +51,10 @@ * 2) For each event's DistributedMembershipID_ThreadID, if current_SequenceID > last_SequenceId then proceed, else ignore as event is duplicate. * 3) Provide key level synchronisation while processing duplicated keys. I.e. if event k1v1 is received by two vms vm1 and vm2, * we want only one to be processed and other to be ignore. We are using transaction to achieve this. Tx provides key level isolation and - * makes processing event and updating sequenceID as atomic operation, so if vm1 is processing k1v1, vm2 will get CommitConflictException + * makes processing event and updating sequenceID as atomic operation, so if vm1 is processing k1v1, vm2 will get ConflictException * 4) We should hold on processing the subsequent events till duplicate event is successfully processed i.e. say vm1 received (and processing) k1v1, * whereas vm2 received events k1v1(duplicate) followed by k1v2; then vm2 should ignore k1v1 and wait till vm1 process k1v1. To achieve this, - * we loops on CommitConflictException in vm2 till vm1 successfully processed k1v1 and updated SequenceID in dupEventPRegion. + * we loops on ConflictException in vm2 till vm1 successfully processed k1v1 and updated SequenceID in dupEventPRegion. * * @author Rahul Diyewar * @since 7.0 diff --git a/tests/core/src/main/java/resumeTx/CommitTx.java b/tests/core/src/main/java/resumeTx/CommitTx.java index 400e7ee52..3cd66785c 100644 --- a/tests/core/src/main/java/resumeTx/CommitTx.java +++ b/tests/core/src/main/java/resumeTx/CommitTx.java @@ -17,19 +17,25 @@ package resumeTx; -import java.util.*; +import java.util.ArrayList; +import java.util.Properties; import java.util.concurrent.TimeUnit; -import com.gemstone.gemfire.cache.*; -import com.gemstone.gemfire.distributed.*; -import com.gemstone.gemfire.cache.execute.*; -import com.gemstone.gemfire.cache.partition.PartitionRegionHelper; -import com.gemstone.gemfire.internal.cache.PartitionedRegion; - -import hydra.*; - -import util.*; -import tx.*; +import com.gemstone.gemfire.cache.ConflictException; +import com.gemstone.gemfire.cache.Declarable; +import com.gemstone.gemfire.cache.TransactionDataNodeHasDepartedException; +import com.gemstone.gemfire.cache.TransactionDataRebalancedException; +import com.gemstone.gemfire.cache.TransactionId; +import com.gemstone.gemfire.cache.TransactionInDoubtException; +import com.gemstone.gemfire.cache.execute.Function; +import com.gemstone.gemfire.cache.execute.FunctionContext; +import com.gemstone.gemfire.distributed.DistributedMember; +import hydra.CacheHelper; +import hydra.Log; +import hydra.TestConfig; +import util.TestException; +import util.TestHelper; +import util.TxHelper; /** CommitTx * A Function to commit a resumeable transaction. @@ -60,7 +66,7 @@ public void execute(FunctionContext context) { Log.getLogWriter().fine("CommitTx RESUMED " + txId); try { TxHelper.commit(); - } catch (CommitConflictException e) { + } catch (ConflictException e) { committed = false; if (isSerialExecution) { // rethrow original Exception diff --git a/tests/core/src/main/java/resumeTx/ConcResumableTxTest.java b/tests/core/src/main/java/resumeTx/ConcResumableTxTest.java index 4c0b1b9ce..cc97499e0 100644 --- a/tests/core/src/main/java/resumeTx/ConcResumableTxTest.java +++ b/tests/core/src/main/java/resumeTx/ConcResumableTxTest.java @@ -16,28 +16,17 @@ */ package resumeTx; -import hydra.BridgeHelper; -import hydra.BridgePrms; -import hydra.CacheHelper; -import hydra.GsRandom; -import hydra.Log; -import hydra.MasterController; -import hydra.RegionHelper; -import hydra.RegionPrms; -import hydra.RemoteTestModule; -import hydra.TestConfig; -import hydra.blackboard.SharedCounters; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Set; -import java.util.Vector; +import java.util.*; +import com.gemstone.gemfire.cache.Cache; +import com.gemstone.gemfire.cache.CacheTransactionManager; +import com.gemstone.gemfire.cache.ConflictException; +import com.gemstone.gemfire.cache.EntryNotFoundException; +import com.gemstone.gemfire.cache.Region; +import com.gemstone.gemfire.cache.TransactionId; +import com.gemstone.gemfire.cache.partition.PartitionRegionHelper; +import hydra.*; +import hydra.blackboard.SharedCounters; import parReg.ParRegUtil; import tx.TxUtil; import util.NameFactory; @@ -47,16 +36,6 @@ import util.TestHelperPrms; import util.TxHelper; -import com.gemstone.gemfire.cache.Cache; -import com.gemstone.gemfire.cache.CacheTransactionManager; -import com.gemstone.gemfire.cache.CommitConflictException; -import com.gemstone.gemfire.cache.EntryNotFoundException; -import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache.TransactionId; -import com.gemstone.gemfire.cache.partition.PartitionRegionHelper; - -import diskRecovery.RecoveryTestVersionHelper; - public class ConcResumableTxTest { static ConcResumableTxTest testInstance = null; @@ -215,7 +194,7 @@ public static void HydraTask_completeTxns() { try { TxHelper.commit(); sc.increment(ResumeTxBB.numSuccessfulCommits); - } catch (CommitConflictException e) { + } catch (ConflictException e) { sc.increment(ResumeTxBB.numFailedCommits); } sc.increment(ResumeTxBB.numCommits); @@ -395,7 +374,7 @@ private void concSuspendResumeTx() { try { TxHelper.commit(); sc.increment(ResumeTxBB.numSuccessfulCommits); - } catch (CommitConflictException e) { + } catch (ConflictException e) { sc.increment(ResumeTxBB.numFailedCommits); } sc.increment(ResumeTxBB.numCommits); diff --git a/tests/core/src/main/java/resumeTx/ResumeTxTest.java b/tests/core/src/main/java/resumeTx/ResumeTxTest.java index 74a1c46a2..114df1573 100644 --- a/tests/core/src/main/java/resumeTx/ResumeTxTest.java +++ b/tests/core/src/main/java/resumeTx/ResumeTxTest.java @@ -14,19 +14,32 @@ * permissions and limitations under the License. See accompanying * LICENSE file. */ -package resumeTx; +package resumeTx; -import util.*; -import hydra.*; -import hydra.blackboard.*; -import tx.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; import com.gemstone.gemfire.cache.*; -import com.gemstone.gemfire.cache.client.*; -import com.gemstone.gemfire.cache.execute.*; -import com.gemstone.gemfire.distributed.*; - -import java.util.*; +import com.gemstone.gemfire.cache.client.Pool; +import com.gemstone.gemfire.cache.client.PoolManager; +import com.gemstone.gemfire.cache.client.ServerConnectivityException; +import com.gemstone.gemfire.cache.execute.Execution; +import com.gemstone.gemfire.cache.execute.FunctionException; +import com.gemstone.gemfire.cache.execute.FunctionInvocationTargetException; +import com.gemstone.gemfire.cache.execute.FunctionService; +import com.gemstone.gemfire.cache.execute.ResultCollector; +import com.gemstone.gemfire.distributed.DistributedMember; +import com.gemstone.gemfire.distributed.DistributedSystem; +import hydra.*; +import hydra.blackboard.Blackboard; +import hydra.blackboard.SharedMap; +import tx.TxPrms; +import util.*; /** * A class to test resumeable transactions. @@ -105,7 +118,7 @@ protected void concTxWithFE() throws Exception { Log.getLogWriter().info("causedBy = " + causedBy); Throwable lastCause = TestHelper.getLastCausedBy(e); Log.getLogWriter().info("lastCause = " + lastCause); - if (causedBy instanceof CommitConflictException) { + if (causedBy instanceof ConflictException) { Log.getLogWriter().info("Caught " + e + ", expected with concurrent execution, continuing test"); } else if ((causedBy instanceof TransactionDataRebalancedException) || (causedBy instanceof TransactionDataNodeHasDepartedException) || @@ -270,7 +283,7 @@ protected void finishAllActiveTx() throws Exception{ commit(txInfo); } catch (FunctionException e) { Throwable causedBy = e.getCause(); - if (causedBy instanceof CommitConflictException) { + if (causedBy instanceof ConflictException) { if (isSerialExecution) { throw new TestException("Caught " + e + " " + TestHelper.getStackTrace(e)); } else { diff --git a/tests/core/src/main/java/tx/BridgeConflictTest.java b/tests/core/src/main/java/tx/BridgeConflictTest.java index 1289e5264..18e06cc46 100644 --- a/tests/core/src/main/java/tx/BridgeConflictTest.java +++ b/tests/core/src/main/java/tx/BridgeConflictTest.java @@ -14,15 +14,31 @@ * permissions and limitations under the License. See accompanying * LICENSE file. */ -package tx; - -import util.*; -import hydra.*; - -import com.gemstone.gemfire.cache.*; -import com.gemstone.gemfire.internal.cache.*; - -import java.util.*; +package tx; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +import com.gemstone.gemfire.cache.ConflictException; +import com.gemstone.gemfire.cache.Region; +import com.gemstone.gemfire.internal.cache.LocalRegion; +import com.gemstone.gemfire.internal.cache.TXStateProxy; +import hydra.BridgeHelper; +import hydra.ClientDescription; +import hydra.GsRandom; +import hydra.HydraThreadLocal; +import hydra.Log; +import hydra.ProcessMgr; +import hydra.TestConfig; +import util.BaseValueHolder; +import util.CacheUtil; +import util.NameFactory; +import util.TestException; +import util.TestHelper; +import util.TxHelper; +import util.ValueHolder; /** * A class to test conflicts in transactions. @@ -166,7 +182,7 @@ protected void concConflictTest() { try { TxHelper.commit(); TxBB.inc(TxBB.TX_SUCCESS); - } catch (CommitConflictException e) { + } catch (ConflictException e) { TxBB.inc(TxBB.TX_FAILURE); Log.getLogWriter().info("Caught " + e + "; continuing test"); } @@ -490,7 +506,7 @@ protected OpList doOps(OpList opList, int numOps, boolean targetSame) { /** Given an operation, execute an operation that involves that same * key and/or region. * - * @param Operation - the operation to base the new operation on. + * @param operation - the operation to base the new operation on. * * @return The operation that was executed. */ @@ -1018,7 +1034,7 @@ protected boolean thread1HasConflict(OpList opList1, OpList opList2, boolean inT * * @param op1 The operation done by thread1. * @param op2 The operation done by thread2. - * @param inTrans True if op2 was done in a transaction, false otherwise. + * @param op2InTrans True if op2 was done in a transaction, false otherwise. * @param logStr A buffer to append any logging to. * * @return True if thread1 will have a conflict (because of op2) if it diff --git a/tests/core/src/main/java/wan/WANClient.java b/tests/core/src/main/java/wan/WANClient.java index 5550cfb07..dc42c066a 100644 --- a/tests/core/src/main/java/wan/WANClient.java +++ b/tests/core/src/main/java/wan/WANClient.java @@ -17,24 +17,21 @@ package wan; +import java.net.InetSocketAddress; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Vector; + import com.gemstone.gemfire.InternalGemFireException; import com.gemstone.gemfire.LogWriter; import com.gemstone.gemfire.Statistics; import com.gemstone.gemfire.StatisticsFactory; import com.gemstone.gemfire.SystemFailure; -import com.gemstone.gemfire.cache.Cache; -import com.gemstone.gemfire.cache.CacheException; -import com.gemstone.gemfire.cache.ClientHelper; -import com.gemstone.gemfire.cache.CommitConflictException; -import com.gemstone.gemfire.cache.EntryDestroyedException; -import com.gemstone.gemfire.cache.EntryNotFoundException; -import com.gemstone.gemfire.cache.InterestResultPolicy; -import com.gemstone.gemfire.cache.PartitionAttributes; -import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache.TransactionDataNodeHasDepartedException; -import com.gemstone.gemfire.cache.TransactionDataRebalancedException; -import com.gemstone.gemfire.cache.TransactionException; -import com.gemstone.gemfire.cache.TransactionInDoubtException; +import com.gemstone.gemfire.cache.*; import com.gemstone.gemfire.cache.client.internal.PoolImpl; import com.gemstone.gemfire.cache.query.SelectResults; import com.gemstone.gemfire.cache.server.CacheServer; @@ -44,89 +41,31 @@ import com.gemstone.gemfire.internal.cache.LocalRegion; import com.gemstone.gemfire.pdx.PdxInstance; import com.gemstone.gemfire.security.AuthenticationFailedException; - import cq.CQUtil; import cq.CQUtilBB; import diskReg.DiskRegUtil; import durableClients.DurableClientsBB; import hct.BBoard; import hct.HctPrms; -import hydra.BridgeHelper; +import hydra.*; import hydra.BridgeHelper.Endpoint; -import hydra.CacheHelper; -import hydra.CachePrms; -import hydra.ClientPrms; -import hydra.ClientVmInfo; -import hydra.ClientVmMgr; -import hydra.ClientVmNotFoundException; -import hydra.ConfigHashtable; -import hydra.DiskStoreHelper; -import hydra.DistributedSystemHelper; -import hydra.EdgeHelper; -import hydra.GatewayHubHelper; -import hydra.GsRandom; -import hydra.HydraRuntimeException; -import hydra.Log; -import hydra.MasterController; -import hydra.RegionHelper; -import hydra.RemoteTestModule; -import hydra.StopSchedulingTaskOnClientOrder; -import hydra.TestConfig; import hydra.blackboard.SharedCounters; import hydra.blackboard.SharedMap; - -import java.net.InetSocketAddress; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Vector; - import objects.ObjectHelper; import objects.PSTObject; import pdx.PdxTest; import security.SecurityClientsPrms; +import util.BaseValueHolder; import util.NameFactory; import util.RandomValues; import util.SilenceListener; import util.TestException; import util.TestHelper; -import util.TxHelper; -import util.BaseValueHolder; import wan.ml.GemFireQuoteFeeder; import wan.ml.GemFireTradeBurstFeeder; import wan.ml.GemFireTradeFeeder; import wan.ml.MLPrms; -import com.gemstone.gemfire.InternalGemFireException; -import com.gemstone.gemfire.LogWriter; -import com.gemstone.gemfire.Statistics; -import com.gemstone.gemfire.StatisticsFactory; -import com.gemstone.gemfire.SystemFailure; -import com.gemstone.gemfire.cache.Cache; -import com.gemstone.gemfire.cache.CacheException; -import com.gemstone.gemfire.cache.ClientHelper; -import com.gemstone.gemfire.cache.EntryDestroyedException; -import com.gemstone.gemfire.cache.EntryNotFoundException; -import com.gemstone.gemfire.cache.InterestResultPolicy; -import com.gemstone.gemfire.cache.PartitionAttributes; -import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache.client.internal.PoolImpl; -import com.gemstone.gemfire.cache.query.SelectResults; -import com.gemstone.gemfire.cache.server.CacheServer; -import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; -import com.gemstone.gemfire.distributed.internal.ServerLocation; -import com.gemstone.gemfire.internal.cache.GatewayStats; -import com.gemstone.gemfire.internal.cache.LocalRegion; -import com.gemstone.gemfire.security.AuthenticationFailedException; - -import cq.CQUtil; -import cq.CQUtilBB; -import diskReg.DiskRegUtil; -import durableClients.DurableClientsBB; - /** * Supports example tests for WAN distribution. * @@ -1132,7 +1071,7 @@ public static synchronized void closeEdgeClientCacheTask() { * clientName). An ENDTASK is required to validate the regionSizes * at test end. * - * @see WANBlackboard.REGION_SIZE + * see WANBlackboard.REGION_SIZE */ public static void HydraCloseTask_regionSizeToBB() { String clientName = System.getProperty(ClientPrms.CLIENT_NAME_PROPERTY); @@ -1675,7 +1614,7 @@ protected void closeCache() { /** * A Hydra TASK that stops a specified server - * @see CacheClientPrms.bridgeKillTarget + * see CacheClientPrms.bridgeKillTarget */ public synchronized static void killServer() throws ClientVmNotFoundException { @@ -1706,7 +1645,7 @@ public static void killClient() { /** * A Hydra TASK that re-starts a specified server - * @see CacheClientPrms.bridgeKillTarget + * see CacheClientPrms.bridgeKillTarget */ public synchronized static void restartServer() throws ClientVmNotFoundException { @@ -1721,7 +1660,7 @@ public synchronized static void restartServer() /** * A Hydra TASK that stops/starts a specified server - * @see CacheClientPrms.bridgeKillTarget + * see CacheClientPrms.bridgeKillTarget */ public synchronized static void recycleServer() throws ClientVmNotFoundException { @@ -1776,7 +1715,7 @@ public synchronized static void killGatewayHub() /** * Client task for clients that way indefinitely * - * @see MasterController.sleepForMs() + * see MasterController.sleepForMs() */ public static void waitForEvents() { int sleepMs = CacheClientPrms.getSleepSec() * 1000; diff --git a/tests/core/src/main/java/wan/WANClientVersionHelper.java b/tests/core/src/main/java/wan/WANClientVersionHelper.java index 1d69e7899..ac4976cbc 100644 --- a/tests/core/src/main/java/wan/WANClientVersionHelper.java +++ b/tests/core/src/main/java/wan/WANClientVersionHelper.java @@ -17,15 +17,26 @@ package wan; -import java.util.*; - -import com.gemstone.gemfire.cache.*; +import com.gemstone.gemfire.cache.ConflictException; +import com.gemstone.gemfire.cache.Region; +import com.gemstone.gemfire.cache.TransactionDataNodeHasDepartedException; +import com.gemstone.gemfire.cache.TransactionException; +import com.gemstone.gemfire.cache.TransactionInDoubtException; +import hydra.CacheHelper; +import hydra.DiskStoreHelper; +import hydra.GsRandom; +import hydra.Log; +import hydra.MasterController; +import hydra.RegionHelper; +import hydra.TestConfig; +import objects.ObjectHelper; import pdx.PdxTest; - -import hydra.*; -import hydra.blackboard.*; -import objects.*; -import util.*; +import util.BaseValueHolder; +import util.NameFactory; +import util.RandomValues; +import util.TestException; +import util.TestHelper; +import util.TxHelper; /** * VersionHelper class for WANClient (TXInDoubtExceptions prevent backward compatibility in test code) @@ -118,9 +129,9 @@ public static void putSequentialKeysTask(WANClient client) throws Exception { Log.getLogWriter().info("Caught TransactionDataNodeHasDepartedException. Expected with concurrent execution, continuing test."); } catch (TransactionInDoubtException e) { Log.getLogWriter().info("Caught TransactionInDoubtException. Expected with concurrent execution, continuing test."); - } catch (CommitConflictException e) { + } catch (ConflictException e) { // we don't expect this as each thread works on its own set of keys - throw new TestException("Unexpected CommitConflictException " + e + " " + TestHelper.getStackTrace(e)); + throw new TestException("Unexpected ConflictException " + e + " " + TestHelper.getStackTrace(e)); } } } diff --git a/tests/sql/build.gradle b/tests/sql/build.gradle index bd783c738..3590e2ce9 100644 --- a/tests/sql/build.gradle +++ b/tests/sql/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -15,10 +15,6 @@ * LICENSE file. */ -plugins { - id 'com.github.johnrengelman.shadow' version '2.0.4' -} - sourceSets.main.java { // requires WebLogic jars exclude 'sql/ecotests/wls/**' @@ -77,14 +73,15 @@ dependencies { compile "com.sun.jersey:jersey-servlet:${sunJerseyVersion}" compile "org.mortbay.jetty:jetty:${hadoopJettyVersion}" compile "org.mortbay.jetty:jetty-util:${hadoopJettyVersion}" - compile 'org.cloudera.htrace:htrace-core:2.05' + compile "org.mortbay.jetty:jetty-sslengine:${hadoopJettyVersion}" + compile "org.cloudera.htrace:htrace-core:${clouderaHtraceVersion}" - compile 'com.googlecode.json-simple:json-simple:1.1.1' - compile 'org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final' - compile 'javax.ejb:javax.ejb-api:3.2' - compile 'org.apache.tomcat:tomcat-juli:8.5.23' - compile 'org.apache.tomcat:tomcat-jdbc:8.5.23' - compile 'com.mchange:c3p0:0.9.5.2' + compile "com.googlecode.json-simple:json-simple:${jsonSimpleVersion}" + compile "org.hibernate.javax.persistence:hibernate-jpa-2.1-api:${hibernateJpaVersion}" + compile "javax.ejb:javax.ejb-api:${ejbVersion}" + compile "org.apache.tomcat:tomcat-juli:${tomcatJdbcVersion}" + compile "org.apache.tomcat:tomcat-jdbc:${tomcatJdbcVersion}" + compile "com.mchange:c3p0:${c3p0Version}" compile "org.apache.derby:derbytools:${derbyVersion}" runtime "org.apache.derby:derby:${derbyVersion}" runtime "org.apache.derby:derbynet:${derbyVersion}" diff --git a/tests/sql/src/main/java/cacheperf/comparisons/gemfirexd/tpcc/Suites/horizontal/SCALE.L/run.sh b/tests/sql/src/main/java/cacheperf/comparisons/gemfirexd/tpcc/Suites/horizontal/SCALE.L/run.sh index fd7f19d42..100794821 100755 --- a/tests/sql/src/main/java/cacheperf/comparisons/gemfirexd/tpcc/Suites/horizontal/SCALE.L/run.sh +++ b/tests/sql/src/main/java/cacheperf/comparisons/gemfirexd/tpcc/Suites/horizontal/SCALE.L/run.sh @@ -28,11 +28,11 @@ runtest() { export SNAPPYDATADIR=$1 export GEMFIRE=$SNAPPYDATADIR/build-artifacts/scala-2.11/store export LD_LIBRARY_PATH=$GEMFIRE/lib - export JTESTS=$SNAPPYDATADIR/store/tests/sql/build-artifacts/linux/classes/main - export EXTRA_JTESTS=$SNAPPYDATADIR/store/tests/core/build-artifacts/linux/classes/main + export JTESTS=$SNAPPYDATADIR/store/tests/sql/build-artifacts/linux/classes/java/main + export EXTRA_JTESTS=$SNAPPYDATADIR/store/tests/core/build-artifacts/linux/classes/java/main ## find out the release version - list=`ls $JTESTS/../../libs/snappydata-store-hydra-tests-*` + list=`ls $JTESTS/../../../libs/snappydata-store-hydra-tests-*` filename=`tr "/" "\n" <<< $list | tail -1` export releaseVersion=`echo "${filename%*.*}"| cut -d'-' -f5-6` @@ -42,7 +42,7 @@ runtest() { export snappyTestsJarVersion=`echo "${snappyTestsJarFilename%*.*}"| cut -d'-' -f5-6` ##set classpath - CLASSPATH=$JTESTS:$EXTRA_JTESTS:$JTESTS/../../libs/snappydata-store-hydra-tests-${releaseVersion}-all.jar:$SNAPPYDATADIR/dtests/build-artifacts/scala-2.11/libs/snappydata-store-scala-tests-${snappyTestsJarVersion}-tests.jar + CLASSPATH=$JTESTS:$EXTRA_JTESTS:$JTESTS/../../../libs/snappydata-store-hydra-tests-${releaseVersion}-all.jar:$SNAPPYDATADIR/dtests/build-artifacts/scala-2.11/libs/snappydata-store-scala-tests-${snappyTestsJarVersion}-tests.jar LIB=$SNAPPYDATADIR/build-artifacts/scala-2.11/snappy/jars for i in $LIB/*.jar; do CLASSPATH=$CLASSPATH:$i; done export CLASSPATH=$CLASSPATH diff --git a/tests/sql/src/main/java/cacheperf/comparisons/gemfirexd/tpcc/Suites/horizontal/SCALE.M/run.sh b/tests/sql/src/main/java/cacheperf/comparisons/gemfirexd/tpcc/Suites/horizontal/SCALE.M/run.sh index fd7f19d42..100794821 100755 --- a/tests/sql/src/main/java/cacheperf/comparisons/gemfirexd/tpcc/Suites/horizontal/SCALE.M/run.sh +++ b/tests/sql/src/main/java/cacheperf/comparisons/gemfirexd/tpcc/Suites/horizontal/SCALE.M/run.sh @@ -28,11 +28,11 @@ runtest() { export SNAPPYDATADIR=$1 export GEMFIRE=$SNAPPYDATADIR/build-artifacts/scala-2.11/store export LD_LIBRARY_PATH=$GEMFIRE/lib - export JTESTS=$SNAPPYDATADIR/store/tests/sql/build-artifacts/linux/classes/main - export EXTRA_JTESTS=$SNAPPYDATADIR/store/tests/core/build-artifacts/linux/classes/main + export JTESTS=$SNAPPYDATADIR/store/tests/sql/build-artifacts/linux/classes/java/main + export EXTRA_JTESTS=$SNAPPYDATADIR/store/tests/core/build-artifacts/linux/classes/java/main ## find out the release version - list=`ls $JTESTS/../../libs/snappydata-store-hydra-tests-*` + list=`ls $JTESTS/../../../libs/snappydata-store-hydra-tests-*` filename=`tr "/" "\n" <<< $list | tail -1` export releaseVersion=`echo "${filename%*.*}"| cut -d'-' -f5-6` @@ -42,7 +42,7 @@ runtest() { export snappyTestsJarVersion=`echo "${snappyTestsJarFilename%*.*}"| cut -d'-' -f5-6` ##set classpath - CLASSPATH=$JTESTS:$EXTRA_JTESTS:$JTESTS/../../libs/snappydata-store-hydra-tests-${releaseVersion}-all.jar:$SNAPPYDATADIR/dtests/build-artifacts/scala-2.11/libs/snappydata-store-scala-tests-${snappyTestsJarVersion}-tests.jar + CLASSPATH=$JTESTS:$EXTRA_JTESTS:$JTESTS/../../../libs/snappydata-store-hydra-tests-${releaseVersion}-all.jar:$SNAPPYDATADIR/dtests/build-artifacts/scala-2.11/libs/snappydata-store-scala-tests-${snappyTestsJarVersion}-tests.jar LIB=$SNAPPYDATADIR/build-artifacts/scala-2.11/snappy/jars for i in $LIB/*.jar; do CLASSPATH=$CLASSPATH:$i; done export CLASSPATH=$CLASSPATH diff --git a/tests/sql/src/main/java/cacheperf/comparisons/gemfirexd/tpcc/Suites/horizontal/SCALE.S/run.sh b/tests/sql/src/main/java/cacheperf/comparisons/gemfirexd/tpcc/Suites/horizontal/SCALE.S/run.sh index fd7f19d42..100794821 100755 --- a/tests/sql/src/main/java/cacheperf/comparisons/gemfirexd/tpcc/Suites/horizontal/SCALE.S/run.sh +++ b/tests/sql/src/main/java/cacheperf/comparisons/gemfirexd/tpcc/Suites/horizontal/SCALE.S/run.sh @@ -28,11 +28,11 @@ runtest() { export SNAPPYDATADIR=$1 export GEMFIRE=$SNAPPYDATADIR/build-artifacts/scala-2.11/store export LD_LIBRARY_PATH=$GEMFIRE/lib - export JTESTS=$SNAPPYDATADIR/store/tests/sql/build-artifacts/linux/classes/main - export EXTRA_JTESTS=$SNAPPYDATADIR/store/tests/core/build-artifacts/linux/classes/main + export JTESTS=$SNAPPYDATADIR/store/tests/sql/build-artifacts/linux/classes/java/main + export EXTRA_JTESTS=$SNAPPYDATADIR/store/tests/core/build-artifacts/linux/classes/java/main ## find out the release version - list=`ls $JTESTS/../../libs/snappydata-store-hydra-tests-*` + list=`ls $JTESTS/../../../libs/snappydata-store-hydra-tests-*` filename=`tr "/" "\n" <<< $list | tail -1` export releaseVersion=`echo "${filename%*.*}"| cut -d'-' -f5-6` @@ -42,7 +42,7 @@ runtest() { export snappyTestsJarVersion=`echo "${snappyTestsJarFilename%*.*}"| cut -d'-' -f5-6` ##set classpath - CLASSPATH=$JTESTS:$EXTRA_JTESTS:$JTESTS/../../libs/snappydata-store-hydra-tests-${releaseVersion}-all.jar:$SNAPPYDATADIR/dtests/build-artifacts/scala-2.11/libs/snappydata-store-scala-tests-${snappyTestsJarVersion}-tests.jar + CLASSPATH=$JTESTS:$EXTRA_JTESTS:$JTESTS/../../../libs/snappydata-store-hydra-tests-${releaseVersion}-all.jar:$SNAPPYDATADIR/dtests/build-artifacts/scala-2.11/libs/snappydata-store-scala-tests-${snappyTestsJarVersion}-tests.jar LIB=$SNAPPYDATADIR/build-artifacts/scala-2.11/snappy/jars for i in $LIB/*.jar; do CLASSPATH=$CLASSPATH:$i; done export CLASSPATH=$CLASSPATH diff --git a/tests/sql/src/main/java/cacheperf/comparisons/gemfirexd/useCase6/run/run.sh b/tests/sql/src/main/java/cacheperf/comparisons/gemfirexd/useCase6/run/run.sh index c57883079..0c65e8ce7 100755 --- a/tests/sql/src/main/java/cacheperf/comparisons/gemfirexd/useCase6/run/run.sh +++ b/tests/sql/src/main/java/cacheperf/comparisons/gemfirexd/useCase6/run/run.sh @@ -22,8 +22,8 @@ runtest() { # If JAVA_HOME is not already set in system then set JAVA_HOME using TEST_JVM TEST_JVM= - export JTESTS=$SNAPPYDATADIR/store/tests/sql/build-artifacts/linux/classes/main - export PATH=$JAVA_HOME:$PATH:$SNAPPYDATADIR/store/tests/sql/build-artifacts/linux/classes/main:$JTESTS + export JTESTS=$SNAPPYDATADIR/store/tests/sql/build-artifacts/linux/classes/java/main + export PATH=$JAVA_HOME:$PATH:$SNAPPYDATADIR/store/tests/sql/build-artifacts/linux/classes/java/main:$JTESTS export GEMFIRE=$SNAPPYDATADIR/build-artifacts/scala-2.10/store export LD_LIBRARY_PATH=$GEMFIRE/lib export OUTPUT_DIR=$resultDir @@ -33,9 +33,9 @@ runtest() { TEST_JVM=$JAVA_HOME fi - export EXTRA_JTESTS=$SNAPPYDATADIR/store/tests/core/build-artifacts/linux/classes/main:$GEMFIRE/lib/snappydata-store-client-1.5.0-SNAPSHOT.jar + export EXTRA_JTESTS=$SNAPPYDATADIR/store/tests/core/build-artifacts/linux/classes/java/main:$GEMFIRE/lib/snappydata-store-client-1.5.0-SNAPSHOT.jar #export JTESTS_RESOURCES=$SNAPPYDATADIR/store/tests/core/src/main/java - export CLASSPATH=$JTESTS:$EXTRA_JTESTS:$GEMFIRE/lib/snappydata-store-1.5.0-SNAPSHOT.jar:$GEMFIRE/lib/snappydata-store-client-1.5.0-SNAPSHOT.jar:$JTESTS/../../libs/snappydata-store-hydra-tests-1.5.0-SNAPSHOT-all.jar:$GEMFIRE/lib/snappydata-store-tools-1.5.0-SNAPSHOT.jar:$SNAPPYDATADIR/snappy-dtests/build-artifacts/scala-2.10/libs/snappydata-store-scala-tests-0.1.0-SNAPSHOT.jar + export CLASSPATH=$JTESTS:$EXTRA_JTESTS:$GEMFIRE/lib/snappydata-store-1.5.0-SNAPSHOT.jar:$GEMFIRE/lib/snappydata-store-client-1.5.0-SNAPSHOT.jar:$JTESTS/../../../libs/snappydata-store-hydra-tests-1.5.0-SNAPSHOT-all.jar:$GEMFIRE/lib/snappydata-store-tools-1.5.0-SNAPSHOT.jar:$SNAPPYDATADIR/snappy-dtests/build-artifacts/scala-2.10/libs/snappydata-store-scala-tests-0.1.0-SNAPSHOT.jar echo "Running useCase6.bt using useCase6.local.conf..." $TEST_JVM/bin/java -server \ diff --git a/tests/sql/src/main/java/connectionPool/HikariConnectionPool.java b/tests/sql/src/main/java/connectionPool/HikariConnectionPool.java index c40b58386..06bddffca 100644 --- a/tests/sql/src/main/java/connectionPool/HikariConnectionPool.java +++ b/tests/sql/src/main/java/connectionPool/HikariConnectionPool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/tests/sql/src/main/java/connectionPool/SnappyConnectionPoolPrms.java b/tests/sql/src/main/java/connectionPool/SnappyConnectionPoolPrms.java index 95ab45916..f7d105c44 100644 --- a/tests/sql/src/main/java/connectionPool/SnappyConnectionPoolPrms.java +++ b/tests/sql/src/main/java/connectionPool/SnappyConnectionPoolPrms.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/tests/sql/src/main/java/connectionPool/TomcatConnectionPool.java b/tests/sql/src/main/java/connectionPool/TomcatConnectionPool.java index 927e9a2ed..a4aa06974 100644 --- a/tests/sql/src/main/java/connectionPool/TomcatConnectionPool.java +++ b/tests/sql/src/main/java/connectionPool/TomcatConnectionPool.java @@ -1,6 +1,6 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/tests/sql/src/main/java/sql/datagen/ColumnMetaData.java b/tests/sql/src/main/java/sql/datagen/ColumnMetaData.java index f3b7e16fd..511b85ced 100644 --- a/tests/sql/src/main/java/sql/datagen/ColumnMetaData.java +++ b/tests/sql/src/main/java/sql/datagen/ColumnMetaData.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/tests/sql/src/main/java/sql/datagen/DataGenerator.java b/tests/sql/src/main/java/sql/datagen/DataGenerator.java index 141789242..b1de5a57d 100644 --- a/tests/sql/src/main/java/sql/datagen/DataGenerator.java +++ b/tests/sql/src/main/java/sql/datagen/DataGenerator.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/tests/sql/src/main/java/sql/datagen/RandomValueGenerator.java b/tests/sql/src/main/java/sql/datagen/RandomValueGenerator.java index 194f5e381..4b17324c0 100644 --- a/tests/sql/src/main/java/sql/datagen/RandomValueGenerator.java +++ b/tests/sql/src/main/java/sql/datagen/RandomValueGenerator.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/tests/sql/src/main/java/sql/datagen/TableMetaDataGenerator.java b/tests/sql/src/main/java/sql/datagen/TableMetaDataGenerator.java index b01a0f7d9..ef0e6dcab 100644 --- a/tests/sql/src/main/java/sql/datagen/TableMetaDataGenerator.java +++ b/tests/sql/src/main/java/sql/datagen/TableMetaDataGenerator.java @@ -17,7 +17,7 @@ /* * Changes for SnappyData data platform. * - * Portions Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Portions Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/tests/sql/src/main/java/sql/snappy.local.conf b/tests/sql/src/main/java/sql/snappy.local.conf index 8fd3d5a7c..65e07662a 100644 --- a/tests/sql/src/main/java/sql/snappy.local.conf +++ b/tests/sql/src/main/java/sql/snappy.local.conf @@ -28,3 +28,4 @@ hydra.VmPrms-extraVMArgs += "-Dgemfire.HeapLRUCapacityController.evictHighEntryC //For disabling snaphotIsolation in rowStore tests. Remove this if snapshotIsolation is enabled in product. //Note : For transaction tests, there is a separate conf local.snapshotForTX.conf, to disable snapshotIsolation in transaction tests only. Please run the transaction bts with local.snapshotForTX.conf. INCLUDE $JTESTS/sql/local.snapshot.conf; +io.snappydata.hydra.security.SnappySecurityPrms-isSecurity = ONEOF true false FOENO; diff --git a/tests/sql/src/main/java/sql/snappy/SnappyBB.java b/tests/sql/src/main/java/sql/snappy/SnappyBB.java index f975bfbc6..c5f32c9a0 100644 --- a/tests/sql/src/main/java/sql/snappy/SnappyBB.java +++ b/tests/sql/src/main/java/sql/snappy/SnappyBB.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/tests/sql/src/main/java/sql/snappy/SnappyNetworkServerBB.java b/tests/sql/src/main/java/sql/snappy/SnappyNetworkServerBB.java index 89bb3e6e4..3f4e7282d 100644 --- a/tests/sql/src/main/java/sql/snappy/SnappyNetworkServerBB.java +++ b/tests/sql/src/main/java/sql/snappy/SnappyNetworkServerBB.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/tests/sql/src/main/java/sql/snappy/SnappyPrms.java b/tests/sql/src/main/java/sql/snappy/SnappyPrms.java index f40fcc85e..d25cc121f 100644 --- a/tests/sql/src/main/java/sql/snappy/SnappyPrms.java +++ b/tests/sql/src/main/java/sql/snappy/SnappyPrms.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You diff --git a/tests/sql/src/main/java/sql/snappy/SnappyTest.java b/tests/sql/src/main/java/sql/snappy/SnappyTest.java index b8eff85d4..fd9dab09f 100644 --- a/tests/sql/src/main/java/sql/snappy/SnappyTest.java +++ b/tests/sql/src/main/java/sql/snappy/SnappyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 SnappyData, Inc. All rights reserved. + * Copyright (c) 2018 SnappyData, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You @@ -173,7 +173,7 @@ public static void initSnappyArtifacts() { protected String getStoreTestsJar() { String storeTestsJar = hd.getTestDir() + hd.getFileSep() + ".." + hd.getFileSep() + ".." + - hd.getFileSep() + "libs" + hd.getFileSep() + "snappydata-store-hydra-tests-" + + hd.getFileSep() + ".." + hd.getFileSep() + "libs" + hd.getFileSep() + "snappydata-store-hydra-tests-" + ProductVersionHelper.getInfo().getProperty(ProductVersionHelper.SNAPPYRELEASEVERSION) + "-all.jar"; return storeTestsJar;