Helping to understand a c++ code
Hello everybody.
I have a problem with an example provided by NI for DAQmx ANSI C programmation. I putted this question here, because I could not find a suitable board for it.
About the problem: I'm currently working with a NI PCI-6120 device and therefore I like to connect a trigger signal to PFIO and a AI channel at which the software should acquire data in combination with a trigger event (->PFIO). Serveral times.
I found a good example (http://zone.ni.com/devzone/cda/tut/p/id/5382) which should do the things I'd like to have, but I have problems to understand the code or maybe I don't really understand the way they realized it.
Here the code:
#include <string.h>
#include <stdio.h>
#include <NIDAQmx.h>
static TaskHandle AItaskHandle=0,DItaskHandle=0;
#define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else
static int32 GetTerminalNameWithDevPrefix(TaskHandle taskHandle, const char terminalName[], char triggerName[]);
int32 CVICALLBACK EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData);
int32 CVICALLBACK DoneCallback(TaskHandle taskHandle, int32 status, void *callbackData);
int main(void)
int32 error=0;
char errBuff[2048]={'\0'};
char trigName[256];
// DAQmx Configure Code
DAQmxErrChk (DAQmxCreateTask("",&AItaskHandle));
DAQmxErrChk (DAQmxCreateAIVoltageChan(AItaskHandle,"Dev1/ai0","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(AItaskHandle,"",10000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000));
DAQmxErrChk (GetTerminalNameWithDevPrefix(AItaskHandle,"ai/SampleClock",trigName));
DAQmxErrChk (DAQmxCreateTask("",&DItaskHandle));
DAQmxErrChk (DAQmxCreateDIChan(DItaskHandle,"Dev1/port0","",DAQmx_Val_ChanForAllLines));
DAQmxErrChk (DAQmxCfgSampClkTiming(DItaskHandle,trigName,10000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000));
DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent(AItaskHandle,DAQmx_Val_Acquired_Into_Buffer,1000,0,EveryNCallback,NULL));
DAQmxErrChk (DAQmxRegisterDoneEvent(AItaskHandle,0,DoneCallback,NULL));
// DAQmx Start Code
DAQmxErrChk (DAQmxStartTask(DItaskHandle));
DAQmxErrChk (DAQmxStartTask(AItaskHandle));
printf("Acquiring samples continuously. Press Enter to interrupt\n");
printf("\nRead:\tAI\tDI\tTotal:\tAI\tDI\n");
getchar();
Error:
if( DAQmxFailed(error) )
DAQmxGetExtendedErrorInfo(errBuff,2048);
if( AItaskHandle ) {
// DAQmx Stop Code
DAQmxStopTask(AItaskHandle);
DAQmxClearTask(AItaskHandle);
AItaskHandle = 0;
if( DItaskHandle ) {
// DAQmx Stop Code
DAQmxStopTask(DItaskHandle);
DAQmxClearTask(DItaskHandle);
DItaskHandle = 0;
if( DAQmxFailed(error) )
printf("DAQmx Error: %s\n",errBuff);
printf("End of program, press Enter key to quit\n");
getchar();
return 0;
static int32 GetTerminalNameWithDevPrefix(TaskHandle taskHandle, const char terminalName[], char triggerName[])
int32 error=0;
char device[256];
int32 productCategory;
uInt32 numDevices,i=1;
DAQmxErrChk (DAQmxGetTaskNumDevices(taskHandle,&numDevices));
while( i<=numDevices ) {
DAQmxErrChk (DAQmxGetNthTaskDevice(taskHandle,i++,device,256));
DAQmxErrChk (DAQmxGetDevProductCategory(device,&productCategory));
if( productCategory!=DAQmx_Val_CSeriesModule && productCategory!=DAQmx_Val_SCXIModule ) {
*triggerName++ = '/';
strcat(strcat(strcpy(triggerName,device),"/"),terminalName);
break;
Error:
return error;
int32 CVICALLBACK EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData)
int32 error=0;
char errBuff[2048]={'\0'};
static int totalAI=0,totalDI=0;
int32 readAI,readDI;
float64 AIdata[1000];
uInt32 DIdata[1000];
// DAQmx Read Code
DAQmxErrChk (DAQmxReadAnalogF64(AItaskHandle,1000,10.0,DAQmx_Val_GroupByChannel,AIdata,1000,&readAI,NULL));
DAQmxErrChk (DAQmxReadDigitalU32(DItaskHandle,1000,10.0,DAQmx_Val_GroupByChannel,DIdata,1000,&readDI,NULL));
printf("\t%d\t%d\t\t%d\t%d\r",readAI,readDI,totalAI+=readAI,totalDI+=readDI);
fflush(stdout);
Error:
if( DAQmxFailed(error) ) {
DAQmxGetExtendedErrorInfo(errBuff,2048);
// DAQmx Stop Code
if( AItaskHandle ) {
DAQmxStopTask(AItaskHandle);
DAQmxClearTask(AItaskHandle);
AItaskHandle = 0;
if( DItaskHandle ) {
DAQmxStopTask(DItaskHandle);
DAQmxClearTask(DItaskHandle);
DItaskHandle = 0;
printf("DAQmx Error: %s\n",errBuff);
return 0;
int32 CVICALLBACK DoneCallback(TaskHandle taskHandle, int32 status, void *callbackData)
int32 error=0;
char errBuff[2048]={'\0'};
// Check to see if an error stopped the task.
DAQmxErrChk (status);
Error:
if( DAQmxFailed(error) ) {
DAQmxGetExtendedErrorInfo(errBuff,2048);
DAQmxClearTask(taskHandle);
if( DItaskHandle ) {
DAQmxStopTask(DItaskHandle);
DAQmxClearTask(DItaskHandle);
DItaskHandle = 0;
printf("DAQmx Error: %s\n",errBuff);
return 0;
Here my questions:
1: DAQmxErrChk (GetTerminalNameWithDevPrefix(AItaskHandle,"ai/SampleClock",trigName));
I don't get this. Why don't they just put one specific channel name at var: trigName?
2.1: DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent(AItaskHandle,DAQmx_Val_Acquired_Into_Buffer,1000,0,EveryNCallback,NULL));
2.2: DAQmxErrChk (DAQmxRegisterDoneEvent(AItaskHandle,0,DoneCallback,NULL));
Why do they setup the event on the AI channel? I thought I have to check for events on the trigger channel?!
3: int32 CVICALLBACK EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData)
Does this event occur for every N samples acquired?
In summary I don't understand how the program is realising the 'wait on trigger' and then starts to acquire the data. In my eyes they just plot the data on both channels without any trigger.
Thank you for reading that far. Maybe someone can help me to understand it correctly!
Bye
Denis
Hello,
it is me again. I modified the code you provided to me. So far I can say it is working =)
But there are some things I like to know and maybe you can explain it to me.
Right now my code acquires data from two channels. I removed the BufferInput-function, because he was not able to trigger or run corretly if I have serveral scans/triggers.
Questions:
Why does it run if I dont use a specific InputBufferSize?
// ---------------------------------------- code snippet ----------------------------------------------
// ChanSR - SampleRate
// ChanSmpPts - SamplesPerChan
// Channels = \Dev3\ai0:1 (2 channels)
// -- create Tasks
DAQmxErrChk (DAQmxCreateTask("", &AItaskHandle));
DAQmxErrChk (DAQmxCreateTask("", &COtaskHandle));
// -- create voltage chan, configure timing and optional the buffer size
DAQmxErrChk (DAQmxCreateAIVoltageChan(AItaskHandle, Channels, "", DAQmx_Val_Cfg_Default, -ChanVolts, ChanVolts, DAQmx_Val_Volts, NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(AItaskHandle, "Ctr0InternalOutput", ChanSR, DAQmx_Val_Falling, DAQmx_Val_ContSamps, (int32) ChanSmpPts));
//DAQmxErrChk (DAQmxSetBufferAttribute (AItaskHandle, DAQmx_Buf_Input_BufSize, ChanSmpPts*2));
// -- create the clock for the acquistion
DAQmxErrChk (DAQmxCreateCOPulseChanFreq (COtaskHandle, "Dev3/ctr0", "", DAQmx_Val_Hz, DAQmx_Val_Low, 0., ChanSR, 0.5));
DAQmxErrChk (DAQmxCfgImplicitTiming (COtaskHandle, DAQmx_Val_FiniteSamps, ChanSmpPts));
// -- create trigger and define the edge
DAQmxErrChk (DAQmxCfgDigEdgeStartTrig(COtaskHandle,"PFI0", DAQmx_Val_Rising));
DAQmxErrChk (DAQmxSetTrigAttribute (COtaskHandle, DAQmx_StartTrig_Retriggerable, TRUE));
// -- start the tasks
DAQmxErrChk (DAQmxStartTask(COtaskHandle));
DAQmxErrChk (DAQmxStartTask(AItaskHandle));
// -- knowing the numbers of triggers we repeat the acquisition
for(i=0; i<TrigEvents; i++)
DAQmxErrChk (DAQmxReadAnalogF64(AItaskHandle, (int32) ChanSmpPts, 2.0, DAQmx_Val_GroupByChannel, buffer,
(int32) (ChanCount * ChanSmpPts), &read, NULL));
for(k = 0; k < len; k++)
result[k + i*len] = buffer[k]; // just plot/save the data
Cleanup();
Bye
Denis
Similar Messages
-
Help with understanding multi-threaded code
Hi Everyone,
I am currently reading a book on multi-threading and up until recently I have been able to understand what is going on. The thing is the complexity of the code has just jumped up about two gears without warning. The code is now using inner classes which I am trying to develop an understanding of but I am not finding it easy going, and the book has been lite on explanations. If anybody can help with the following code it will be really appreciated.
public class SetPriority extends Object
private static Runnable makeRunnable()
Runnable r = new Runnable()
public void run()
for(int i=0; i<5; i++)
Thread t = Thread.currentThread();
System.out.println("in run() - priority=" + t.getPriority() +
", name=" + t.getName());
try{
Thread.sleep(2000);
}catch(InterruptedException x){
//ignore
return r;
public static void main(String[] args)
Thread threadA = new Thread(makeRunnable(), "threadA");
threadA.setPriority(8);
threadA.start();
Thread threadB = new Thread(makeRunnable(), "threadB");
threadB.setPriority(2);
threadB.start();
Runnable r = new Runnable()
public void run()
Thread threadC = new Thread(makeRunnable(), "threadC");
threadC.start();
Thread threadD = new Thread(r, "threadD");
threadD.setPriority(7);
threadD.start();
try{
Thread.sleep(3000);
}catch(InterruptedException x){
//ignore
threadA.setPriority(3);
System.out.println("in main() - threadA.getPriority()=" + threadA.getPriority());
}My greatest challenge is understanding how the makeRunnable() method works. I don't understand how this inner class can be declared static and then multiple "instances" created from it. I know that I have no idea what is going on, please help!!!
Thanks for your time.
Regards
Davo
P.S.: If you know of any really good references on inner classes, particularly URL resources, please let me know. Thanks again.Yikes!! The good news is that you're unlikely to see such convoluted code in real life. But here we go.
"private static Runnable makeRunnable()" declares a method that returns objects of type Runnable. The fact that the method is declared "static" is pretty irrelevant - I'll describe what that means later.
The body of the method creates and returns an object of type Runnable. Not much special about it, except that you can give such an object to the constructor of class Thread and as a result the run() method of this Runnable object will be called on a new thread of execution (think - in parallel).
Now the way it creates this Runnable object is by using the "anonymous inner class" syntax. In effect the method is doing the same as
public class MyNewClass implements Runnable {
public void run() {
// All the same code inside run()
public class SetPriority {
private static Runnable makeRunnable() {
Runnable r = new MyNewClass();
return r;
// The rest of the original code
}Except you don't bother declaring MyNewClass. You're not interested in defining any new method signatures. You just want to create an object that implements Runnable and has certain instructions that you want inside the run() method. Think of the whole approach as shorthand.
Think about this for a while. In the mean time I'll write up the "static". -
Need help in Understanding synchronization through code
I read someone that synchronization is suppose to allow only one thread to access a synchronized method or block of code. But then I wrote some code just to test it out.
import java.util.ArrayList;
import java.util.Vector;
public class Testing extends Thread {
private String someString;
static Vector<Integer> someVec;
static ArrayList<Integer> someArrayList;
public Testing(String value) {
someString = value;
someVec = new Vector<Integer>();
someArrayList = new ArrayList<Integer>();
public static void main(String args[]) {
Testing one = new Testing("one");
Testing two = new Testing("two");
one.start();
two.start();
public void run() {
if (someString.equals("one")) {
for (int i = 0; i < 1000; i++) {
try {
someVec.add(i);
} catch (RuntimeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("adding with " + i);
} else
for (int i = 0; i < someVec.size(); i++)
try {
System.out.println("getting .. " + someVec.get(i)+ " from "+someVec.size());
} catch (RuntimeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}Now my questions
1. Why the 2nd thread is able to access the someVec ( Vector) when the 1st thread is still adding some values?
2. When I changed someVec to someArrayList the result is still the same. I wonder why ?
3. Lastly, Can anyone modify my code so only either a Vector or a Arraylist will make the program run without error ? Because right now I can run them both fine, so I don't see the difference.
Thank you.
Regards,
MustafaVrijmetse wrote:
1. Why the 2nd thread is able to access the someVec ( Vector) when the 1st thread is still adding some values?You have not added any synchronization around your Vector operations. Vector's individual methods are synchronized, but that only extends to the execution of those methods. There's no way for that syncing to know that you're doing stuff in a for loop. If you want to complete the for loop without anything else affecting that Vector, then you need a sync block around the body of the loop, and anything else that acceses the Vector must also sync on the same object. The Vector itself is a good candidate for the lock here.
(There may be other problems as well. I haven't read your code closely. Just noticed the for loop and lack of syncing.)
2. When I changed someVec to someArrayList the result is still the same. I wonder why ?Same reason.
3. Lastly, Can anyone modify my code so only either a Vector or a Arraylist will make the program run without error ?No. -
Help in understanding some code
I am new to java and need some help in understanding what the setHeapWithSize method does listed below. Thanks
public class HeapSort {
public void heapsort(int[] a){
int [] A = setHeapWithSize(a, a.length);
buildHeap(A);
for (int i = a.length; i>1; i--){
a[i-1] = A[0];
A[0] = a[i-1];
A=setHeapWithSize (A, A.length-1);
heapify(a, 1);
a[0] = A[0];
public void buildHeap (int[] a) {
for (int i = a.length/2; i>0; i--){
heapify(a, i);
public void heapify (int[] a, int i){
int l = left(i);
int r = right(i);
int largest;
if (l<= heapSize(a) && a[i-1]>a[i-1]){
largest = l;
else{
largest=i;
if (r<=heapSize(a) && a[r-1]> a[largest-1]){
largest = r;
if (largest != i){
int tmp = a[i-1];
a[i-1] = a[largest-1];
a[largest-1] = tmp;
heapify(a, largest);
public int heapSize (int [] a){
return a.length;
public int parent (int i){
return(i/2);
public int left (int i){
return (2*i);
public int right (int i){
return (2*i +1);
}>I am new to java and need some help in understanding
what the setHeapWithSize method does listed below.Don't you think it would be a smart move to show us the code for setHeapWithSize? Or do you want us to make a wild guess at what it does based on its name? -
Error Posting IDOC: need help in understanding the following error
Hi ALL
Can you please, help me understand the following error encountered while the message was trying to post a IDOC.
where SAP_050 is the RFC destination created to post IDOCs
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
- <!-- Call Adapter
-->
- <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">
<SAP:Category>XIAdapter</SAP:Category>
<SAP:Code area="IDOC_ADAPTER">ATTRIBUTE_IDOC_RUNTIME</SAP:Code>
<SAP:P1>FM NLS_GET_LANGU_CP_TAB: Could not determine code page with SAP_050 Operation successfully executed FM NLS_GET_LANGU_CP_TAB</SAP:P1>
<SAP:P2 />
<SAP:P3 />
<SAP:P4 />
<SAP:AdditionalText />
<SAP:ApplicationFaultMessage namespace="" />
<SAP:Stack>Error: FM NLS_GET_LANGU_CP_TAB: Could not determine code page with SAP_050 Operation successfully executed FM NLS_GET_LANGU_CP_TAB</SAP:Stack>
<SAP:Retry>M</SAP:Retry>
</SAP:Error>
Your help is greatly appreciated.............Thank you!Hi Patrick,
Check the authorizations assigned to the user which you used in the RFC destinations, If there is no enough authorizations then it is not possible to post the idocs.
Also Refer this Note 747322
Regards,
Prakash -
Need help in understanding why so many gets and I/O
Hi there,
I have a sql file somewhat similar in structure to below:
delete from table emp;-- changed to Truncate table emp;
delete from table dept;--changed to Truncate table dept;
insert into emp values() select a,b,c from temp_emp,temp_dept where temp_emp.id=temp_dept.emp_id
update emp set emp_name=(select emp_name from dept where emp.id=dept.emp_id);
commit --only at the end
the above file takes about 9-10 hrs to complete its operation. and
the values from v$sql for the statement
update emp set emp_name=(select emp_name from dept where emp.id=dept.emp_id);
are as below:
SHARABLE_MEM PERSISTENT_MEM RUNTIME_MEM SORTS LOADED_VERSIONS OPEN_VERSIONS USERS_OPENING FETCHES EXECUTIONS PX_SERVERS_EXECUTIONS END_OF_FETCH_COUNT USERS_EXECUTING LOADS FIRST_LOAD_TIME INVALIDATIONS PARSE_CALLS DISK_READS DIRECT_WRITES BUFFER_GETS APPLICATION_WAIT_TIME CONCURRENCY_WAIT_TIME CLUSTER_WAIT_TIME USER_IO_WAIT_TIME PLSQL_EXEC_TIME JAVA_EXEC_TIME ROWS_PROCESSED COMMAND_TYPE OPTIMIZER_MODE OPTIMIZER_COST OPTIMIZER_ENV OPTIMIZER_ENV_HASH_VALUE PARSING_USER_ID PARSING_SCHEMA_ID PARSING_SCHEMA_NAME KEPT_VERSIONS ADDRESS TYPE_CHK_HEAP HASH_VALUE OLD_HASH_VALUE PLAN_HASH_VALUE CHILD_NUMBER SERVICE SERVICE_HASH MODULE MODULE_HASH ACTION ACTION_HASH SERIALIZABLE_ABORTS OUTLINE_CATEGORY CPU_TIME ELAPSED_TIME OUTLINE_SID CHILD_ADDRESS SQLTYPE REMOTE OBJECT_STATUS LITERAL_HASH_VALUE LAST_LOAD_TIME IS_OBSOLETE CHILD_LATCH SQL_PROFILE PROGRAM_ID PROGRAM_LINE# EXACT_MATCHING_SIGNATURE FORCE_MATCHING_SIGNATURE LAST_ACTIVE_TIME BIND_DATA TYPECHECK_MEM
18965 8760 7880 0 1 0 0 0 2 0 2 0 2 2011-05-10/21:16:44 1 2 163270378 0 164295929 0 509739 0 3215857850 0 0 20142 6 ALL_ROWS 656 E289FB89A4E49800CE001000AEF9E3E2CFFA331056414155519421105555551545555558591555449665851D5511058555155511152552455580588055A1454A8E0950402000002000000000010000100050000002002080007D000000000002C06566001010000080830F400000E032330000000001404A8E09504646262040262320030020003020A000A5A000 4279923421 50 50 APPS 0 00000003CBE5EF50 00 1866523305 816672812 1937724149 0 SYS$USERS 0 01@</my.sql -2038272289 -265190056 0 9468268067 10420092918 00000003E8593000 6 N VALID 0 2011-05-11/10:23:45 N 5 0 0 1.57848E+19 1.57848E+19 5/12/2011 4:39 0
1) how do i re-write this legacy script? and what should be done to improve performance?
2) Should i use PL/sql to re-write it?
3) Also help in understanding why a simple update statement is doing so many buffer gets and reading , Is this Read consistency Trap as i'm not committing anywhere in between or it is actually doing so much of work.
(assume dept table has cols emp_name and emp_id also)update emp set emp_name=(select emp_name from dept where emp.id=dept.emp_id);I guess that these are masked table names ? Nobody would have emp_name in a dept table.
Can you re-format the output, using "code" tags ( [ or { }
Hemant K Chitale
Edited by: Hemant K Chitale on May 12, 2011 12:44 PM -
CrashReporter - Could you please help to understand this crash report?
Could you please help to understand this crash report below?
If I'm not wrong it started after update the Mac OS X to version 10.5.6 - every startup.
Note: First update by regular update then after by combo.
Thanks in advance!
_ CrashReporter
Process: aslmanager [218]
Path: /usr/sbin/aslmanager
Identifier: aslmanager
Version: ??? (???)
Code Type: X86 (Native)
Parent Process: launchd [1]
Date/Time: 2009-04-05 08:29:52.069 -0300
OS Version: Mac OS X 10.5.6 (9G55)
Report Version: 6
Exception Type: EXCBADACCESS (SIGSEGV)
Exception Codes: KERNINVALIDADDRESS at 0x0000000000200000
Crashed Thread: 0
Thread 0 Crashed:
0 libSystem.B.dylib 0x952a8a85 asl_get64 + 11
1 libSystem.B.dylib 0x952aa034 aslfile_fetchpos + 939
2 libSystem.B.dylib 0x952aa2f6 aslfilematch + 339
3 aslmanager 0x00002409 0x1000 + 5129
4 aslmanager 0x00002b3e 0x1000 + 6974
5 aslmanager 0x0000211a 0x1000 + 4378
Thread 0 crashed with X86 Thread State (32-bit):
eax: 0x001ffffc ebx: 0x952a9ca1 ecx: 0x00000000 edx: 0x00000000
edi: 0x0000ff3d esi: 0x00100b30 ebp: 0xbffffbc8 esp: 0xbffffba0
ss: 0x0000001f efl: 0x00010286 eip: 0x952a8a85 cs: 0x00000017
ds: 0x0000001f es: 0x0000001f fs: 0x00000000 gs: 0x00000037
cr2: 0x00200000
Binary Images:
0x1000 - 0x2ffd +aslmanager ??? (???) <201b2dea48b8d80ac1432ff85244ed31> /usr/sbin/aslmanager
0x8fe00000 - 0x8fe2db43 dyld 97.1 (???) <100d362e03410f181a34e04e94189ae5> /usr/lib/dyld
0x9444a000 - 0x9444efff libmathCommon.A.dylib ??? (???) /usr/lib/system/libmathCommon.A.dylib
0x951a4000 - 0x951abfe9 libgcc_s.1.dylib ??? (???) <f53c808e87d1184c0f9df63aef53ce0b> /usr/lib/libgcc_s.1.dylib
0x951ba000 - 0x95321ff3 libSystem.B.dylib ??? (???) <d68880dfb1f8becdbdac6928db1510fb> /usr/lib/libSystem.B.dylib
0xffff0000 - 0xffff1780 libSystem.B.dylib ??? (???) /usr/lib/libSystem.B.dylib
_ Log
05/04/09 8:25:58 com.apple.loginwindow[35] Shutdown NOW!
05/04/09 8:25:58 com.apple.loginwindow[35] System shutdown time has arrived
05/04/09 8:25:58 com.apple.SystemStarter[30] Stopping Missing Sync Listener
05/04/09 8:25:58 com.apple.SystemStarter[30] Stopping HP Trap Monitor
05/04/09 8:25:58 com.apple.SystemStarter[30] Stopping HP IO Monitor
05/04/09 8:25:59 com.apple.SystemStarter[30] kextunload: unload kext /System/Library/Extensions/Pvsnet.kext succeeded
05/04/09 8:25:59 com.apple.SystemStarter[30] kextunload: unload kext /System/Library/Extensions/ConnectUSB.kext succeeded
05/04/09 8:26:02 com.apple.SystemStarter[30] kextunload: unload kext /System/Library/Extensions/vmmain.kext succeeded
05/04/09 8:26:02 com.apple.SystemStarter[30] kextunload: unload kext /System/Library/Extensions/hypervisor.kext succeeded
05/04/09 8:26:35 com.apple.launchctl.System[2] BootCacheControl: could not open /var/db/BootCache.playlist: No such file or directory
05/04/09 8:26:35 com.apple.launchctl.System[2] BootCacheControl: could not unlink playlist /var/db/BootCache.playlist: Unknown error: -1
05/04/09 8:26:37 com.apple.launchctl.System[2] launchctl: Please convert the following to launchd: /etc/mach_init.d/dashboardadvisoryd.plist
05/04/09 8:26:37 com.apple.launchd[1] (com.apple.blued) Unknown key for boolean: EnableTransactions
05/04/09 8:26:37 com.apple.launchd[1] (org.cups.cupsd) Unknown key: SHAuthorizationRight
05/04/09 8:26:37 com.apple.launchd[1] (org.ntp.ntpd) Unknown key: SHAuthorizationRight
05/04/09 8:26:49 org.ntp.ntpd[27] Error : nodename nor servname provided, or not known
05/04/09 8:26:57 com.apple.SystemStarter[30] Starting up Missing Sync Listener
05/04/09 8:26:57 com.apple.SystemStarter[30] Starting HP IO Monitor
05/04/09 8:26:58 com.apple.SystemStarter[30] kextload: extension /System/Library/Extensions/hypervisor.kext is already loaded
05/04/09 8:26:58 com.apple.SystemStarter[30] Starting HP Trap Monitor
05/04/09 8:26:58 com.apple.SystemStarter[30] kextload: extension /System/Library/Extensions/vmmain.kext is already loaded
05/04/09 8:26:59 com.apple.SystemStarter[30] kextload: extension /System/Library/Extensions/ConnectUSB.kext is already loaded
05/04/09 8:27:00 com.apple.SystemStarter[30] kextload: extension /System/Library/Extensions/Pvsnet.kext is already loaded
05/04/09 8:27:00 com.apple.SystemStarter[30] kextload: /Library/StartupItems/Parallels/Pvsvnic.kext loaded successfully
05/04/09 8:27:06 com.apple.SystemStarter[30] Sun Apr 5 08:27:06 wslys-Mac.local Missing Sync Listener[77] <Warning>: 3891612: (CGSLookupServerRootPort) Untrusted apps are not allowed to connect to or launch Window Server before login.
05/04/09 8:27:06 com.apple.SystemStarter[30] Sun Apr 5 08:27:06 wslys-Mac.local Missing Sync Listener[77] <Error>: kCGErrorRangeCheck : On-demand launch of the Window Server is allowed for root user only.
05/04/09 8:27:06 com.apple.SystemStarter[30] Sun Apr 5 08:27:06 wslys-Mac.local Missing Sync Listener[77] <Error>: kCGErrorRangeCheck : Set a breakpoint at CGErrorBreakpoint() to catch errors as they are returned
05/04/09 8:27:08 com.apple.SystemStarter[30] _RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
05/04/09 8:27:20 com.apple.launchd[1] (com.apple.UserEventAgent-LoginWindow[123]) Exited: Terminated
05/04/09 8:27:20 com.apple.launchctl.Aqua[129] launchctl: Please convert the following to launchd: /etc/machinit_peruser.d/RemoteUI.plist
05/04/09 8:27:20 com.apple.launchd[116] (com.apple.AirPortBaseStationAgent) Unknown key for boolean: EnableTransactions
05/04/09 8:27:21 com.apple.FolderActions.enabled[130] launchctl: Error unloading: com.apple.FolderActions.folders
05/04/09 8:27:42 quicklookd[146] [QL ERROR] 'Creating thumbnail' timed out for '<QLThumbnailRequest /Users/wsly/Downloads/m090374535329zdwg_650ref.mov>'
05/04/09 8:27:42 Dock[138] [QL ERROR] quicklookd crashed while thumbnailing /Users/wsly/Downloads/m090374535329zdwg_hdref.mov
05/04/09 8:29:52 com.apple.launchd[1] (com.apple.aslmanager[218]) Exited abnormally: Segmentation faultTry repairing the disk through the Mac OS X install disk.
-
Help with understanding key event propagation
Hello,
I am hoping someone can help me understand a few things which are not clear to me with respect to handling of key events by Swing components. My understanding is summarized as:
(1) Components have 3 input maps which map keys to actions
one for when they are the focused component
one for when they are an ancestor of the focused component
one for when they are in the same window as the focused component
(2) Components have a single action map which contains actions to be fired by key events
(3) Key events go to the currently focused component
(4) Key events are consumed by the first matching action that is found
(5) Key events are sent up the containment hierarchy up to the window (in which case components with a matching mapping in the WHEN_IN_FOCUSED_WINDOW map are searched for)
(6) The first matching action handles the event which does not propagate further
I have a test class (source below) and I obtained the following console output:
Printing keyboard map for Cancel button
Level 0
Key: pressed C
Key: released SPACE
Key: pressed SPACE
Level 1
Key: pressed SPACE
Key: released SPACE
Printing keyboard map for Save button
Level 0
Key: pressed SPACE
Key: released SPACE
Level 1
Key: pressed SPACE
Key: released SPACE
Printing keyboard map for Main panel
Event: cancel // typed SPACE with Cancel button having focus
Event: save // typed SPACE with Save button having focus
Event: panel // typed 'C' with panel having focus
Event: panel // typed 'C' with Cancel button having focus
Event: panel // typed 'C' with Save button having focus
I do not understand the following aspects of its behaviour (tested on MacOSX although I believe the behaviour is not platform dependent):
(1) I assume that the actions are mapped to SPACE since the spacebar clicks the focused component but I don't explicitly set it?
(2) assuming (1) is as I described why are there two mappings, one for key pressed and one for key released yet the 'C' key action only has a key pressed set?
(3) assuming (1) and (2) are true then why don't I get the action fired twice when I typed the spacebar, once when I pressed SPACE and again when I released SPACE?
(4) I read that adding a dummy action with the value "none" (i.e. the action is the string 'none') should hide the underlying mappings for the given key, 'C' the my example so why when I focus the Cancel button and press the 'C' key do I get a console message from the underlying panel action (the last but one line in the output)?
Any help appreciated. The source is:
import javax.swing.*;
public class FocusTest extends JFrame {
public FocusTest () {
initComponents();
setTitle ("FocusTest");
setLocationRelativeTo (null);
setSize(325, 160);
setVisible (true);
public static void main (String[] args) {
new FocusTest();
private void initComponents()
JPanel panTop = new JPanel();
panTop.setBackground (java.awt.Color.RED);
JLabel lblBanner = new javax.swing.JLabel ("PROPERTY TABLE");
lblBanner.setFont(new java.awt.Font ("Lucida Grande", 1, 14));
lblBanner.setHorizontalAlignment (javax.swing.SwingConstants.CENTER);
panTop.add (lblBanner);
JPanel panMain = new JPanel ();
JLabel lblKey = new JLabel ("Key:");
lblKey.setFocusable (true);
JLabel lblValue = new JLabel ("Value:");
JTextField tfKey = new JTextField(20);
JTextField tfValue = new JTextField(20);
JButton btnCancel = new JButton (createAction("cancel")); // Add a cancel action.
JButton btnSave = new JButton (createAction("save")); // Add a sve action.
panMain.add (lblKey);
panMain.add (tfKey);
panMain.add (lblValue);
panMain.add (tfValue);
panMain.add (btnCancel);
panMain.add (btnSave);
add (panTop, java.awt.BorderLayout.NORTH);
add (panMain, java.awt.BorderLayout.CENTER);
setDefaultCloseOperation (javax.swing.WindowConstants.EXIT_ON_CLOSE);
// Add an action to the panel for the C key.
panMain.getInputMap (JComponent.WHEN_IN_FOCUSED_WINDOW).put (KeyStroke.getKeyStroke (java.awt.event.KeyEvent.VK_C, 0), "panel");
panMain.getActionMap ().put ("panel", createAction("panel"));
// FAILS ???
// Add an empty action to the Cancel button to block the underlying panel C key action.
btnCancel.getInputMap().put (KeyStroke.getKeyStroke (java.awt.event.KeyEvent.VK_C, 0), "none");
// Print out the input map contents for the Cancel and Save buttons.
System.out.println ("\nPrinting keyboard map for Cancel button");
printInputMaps (btnCancel);
System.out.println ("\nPrinting keyboard map for Save button");
printInputMaps (btnSave);
// FAILS NullPointer because the map contents are null ???
System.out.println ("\nPrinting keyboard map for Main panel");
// printInputMaps (panMain);
private AbstractAction createAction (final String actionName) {
return new AbstractAction (actionName) {
public void actionPerformed (java.awt.event.ActionEvent evt) {
System.out.println ("Event: " + actionName);
private void printInputMaps (JComponent comp) {
InputMap map = comp.getInputMap();
printInputMap (map, 0);
private void printInputMap (InputMap map, int level) {
System.out.println ("Level " + level);
InputMap parent = map.getParent();
Object[] keys = map.allKeys();
for (Object key : keys) {
if (key.equals (parent)) {
continue;
System.out.println ("Key: " + key);
if (parent != null) {
level++;
printInputMap (parent, level);
Thanks,
Tim MowlemUse the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the posted code retains its original formatting.
1) In the Metal LAF the space bar activates the button. In the Windows LAF the Enter key is used to activate the button. Therefore these bindings are added by the LAF.
2) The pressed binding paints the button in its pressed state. The released binding paint the button in its normal state. Thats why the LAF adds two bindings.
In your case you only added a single binding.
3) The ActionEvent is only fired when the key is released. Same as a mouse click. You can hold the mouse down as long as you want and the ActionEvent isn't generated until you release the mouse. In fact, if you move the mouse off of the button before releasing the button, the ActionEvent isn't even fired at all. The mouse pressed/released my be generated by the same component.
4) Read (or reread) the [url http://java.sun.com/docs/books/tutorial/uiswing/misc/keybinding.html#howto]How to Remove Key Bindings section. "none" is only used to override the default action of a component, it does not prevent the key stroke from being passed on to its parent. -
I forgot restrictions cod in ipad air1 and don't off it , please help me for recovery this cod
i forgot restrictions cod in ipad air1 and don't off it , please help me for recovery this cod...
Locked Out, Forgot Lock or Restrictions Passcode, or Need to Restore Your Device: Several Alternative Solutions
A
1. iOS- Forgotten passcode or device disabled after entering wrong passcode
2. iPhone, iPad, iPod touch: Wrong passcode results in red disabled screen
3. Restoring iPod touch after forgotten passcode
4. What to Do If You've Forgotten Your iPhone's Passcode
5. iOS- Understanding passcodes
6. iTunes 10 for Mac- Update and restore software on iPod, iPhone, or iPad
7. iOS - Unable to update or restore
Forgotten Restrictions Passcode Help
iPad,iPod,iPod Touch Recovery Mode
You will need to restore your device as New to remove a Restrictions passcode. Go through the normal process to restore your device, but when you see the options to restore as New or from a backup, be sure to choose New.
You can restore from a backup if you have one from BEFORE you set the restrictions passcode.
Also, see iTunes- Restoring iOS software.
And also see How to Recover Forgotten iPhone, iPad Restrictions Passcode. -
Help in obatinin SD certification code and material
Hi SD Guru's,
I am looking to get certified on SD. and i am having a difficult time finding the correct resources to help me understand, hwo to prepare for the SD certification and also obtain useful SD material online. looking for recommendation to the SD codes and related material to follow, in preparation for the exam.
Will be looking forward to a favorable response in this regard.
Thanks in advance.Dont post the same question multiple times. Already you have posted the same question which has been moved to SAP Certified Professional forum.
G. Lakshmipathi -
Can anyone help me understand "Continue Statements"?
Hi,
I was wondering if anyone could help me understand continue statements. I've been studying the java tutorials this weekend but can not get my head around the following explanation: (My thoughts are at the end of this message and it might be easiest to read them first!)
"The continue statement skips the current iteration of a for, while , or do-while loop. The unlabeled form skips to the end of the innermost loop's body and evaluates the boolean expression that controls the loop. The following program, ContinueDemo , steps through a String, counting the occurences of the letter "p". If the current character is not a p, the continue statement skips the rest of the loop and proceeds to the next character. If it is a "p", the program increments the letter count.
{code}class ContinueDemo {
public static void main(String[] args) {
String searchMe = "peter piper picked a peck of pickled peppers";
int max = searchMe.length();
int numPs = 0;
for (int i = 0; i < max; i++) {
//interested only in p's
if (searchMe.charAt(i) != 'p')
continue;
//process p's
numPs++;
System.out.println("Found " + numPs + " p's in the string.");
}{code}
Here is the output of this program:
Found 9 p's in the string.
To see this effect more clearly, try removing the continue statement and recompiling. When you run the program again, the count will be wrong, saying that it found 35 p's instead of 9.
A labeled continue statement skips the current iteration of an outer loop marked with the given label. The following example program, ContinueWithLabelDemo, uses nested loops to search for a substring within another string. Two nested loops are required: one to iterate over the substring and one to iterate over the string being searched. The following program, ContinueWithLabelDemo, uses the labeled form of continue to skip an iteration in the outer loop.
{code}class ContinueWithLabelDemo {
public static void main(String[] args) {
String searchMe = "Look for a substring in me";
String substring = "sub";
boolean foundIt = false;
int max = searchMe.length() - substring.length();
test:
for (int i = 0; i <= max; i++) {
int n = substring.length();
int j = i;
int k = 0;
while (n-- != 0) {
if (searchMe.charAt(j++)
!= substring.charAt(k++)) {
continue test;
foundIt = true;
break test;
System.out.println(foundIt ? "Found it" :
"Didn't find it");
}{code}
Here is the output from this program.
Found it"
Here are Woodie's thoughts........................................
1) With the first program I don't understand how the program counts the number of "p's". Like for example how it stores the number of "p's". Shouldn't it say:
if (searchMe.charAt(i) = 'p') then store it in some sort of containers??? 2) With the second program, I don't understand the test section. For example: Why does it have --? why does it have != after while and why does it have != after if?
while (n-- != 0)
if (searchMe.charAt(j++) != substring.charAt(k++))
continue test;
foundIt = true;
break test;Edited by: woodie_woodpeck on Nov 23, 2008 3:29 AMWoodie, I think they're just silly "theoretical" examples... ergo don't worry too much not understanding them, coz they don't actually make a lot of sense... as you've allready pointed out there are other "more normal" control structures which achieve the same thing, and which in this case (in my humble opinion) would make for clearer, more concise, more maintainable code.
All you need to know about continue is "it means go back to the top of the loop"... If you're not comfortable using "continue" then don't.
There's more than one way to do it.
public static void main(String[] args) {
try {
final String s = "peter piper picked a peck of pickled peppers";
int count = 0;
for ( char c : s.toStringArray() ) {
if (c=='p') count++;
System.out.println("There are "+count+ " p's in '"+s+"'");
} catch (Exception e) {
e.printStackTrace();
}Having said all that... I did use continue in anger the other day... I was reading Geometries from a shape file... the reader was throwing an ArrayIndexOutOfBoundsException given an "empty Feature" (ie a feature with the geospatial presence)... All I did was catch the exception and continue trying to read the new feature... the alternative would have been to rewrite the control logic of the whole reader loop... quick, simple effective... but I don't routinely build continue statements into new code... just a matter of personal taste.
Cheers. Keith. -
Please help me break down this code
i really need help at understanding this, i put it together a while ago with some help but im really no pro at java but my tutor has asked me to give a break down of the code line by line
/* This program rolls two six-sided dice a user-specified
number of times, and prints how many times an ordered dice combination occured.
This is followed by a column stating how many times the sum of the two dice
equalled 2 through 12.
import java.util.Scanner;
public class DiceSumDistribution
public static void main(String[] args)
Scanner scan = new Scanner(System.in); //receive input from keyboard
System.out.print("Enter the number of times you would like to toss two dice: "); //prompt user for input
int timesToToss = scan.nextInt(); //read in user input
int[] diceSum = new int[37]; //this array holds the dice roll distribution table
int[] frequencySum = new int[13]; //this array holds how many times a dice sum occured
int die1, die2; //integers representing the two dice
for(int i = 0; i < timesToToss; i++) //toss two dice as many times as the user specified
die1 = (int) (Math.random()*6+1); //assign random number (1 through 6) to dice one
die2 = (int) (Math.random()*6+1); //assign random number (1 through 6) to dice two
diceSum[(6*(die1-1))+die2]++; //add one to appropriate cell in distribution table
frequencySum[die1+die2]++; //add one to appropriate sum counter
/*the dice roll distribution table shows how many times a certain combination of dice rolls
and the rows represent the other dice.
System.out.println("\n---Dice Roll Distribution Table---");
System.out.println("\t 1\t2\t3\t4\t5\t6"); //print distribution table
System.out.println("\t____________________________________________"); //print distribution table
for(int i = 1; i < 37; i++) //print all 36 cells of distribution tables
if(i%6 == 1) //if at the beginning of a table row
System.out.print(i/6+1 + "\t|"); //print row number
System.out.print(diceSum[i]+ "\t"); //for each cell in a row, print its value
if(i%6 == 0) //if at the end of a row
System.out.println(); //go down a line
/*this column represents how many times a sum occured. For example, if the following output occurs
System.out.println("\n---Dice Roll Sums---");
for(int i=2; i<=12; i++) //for each possible dice sum
System.out.println(i+": " + frequencySum); //print each dice sum on its own row
ii wrote this with some help a while ago but i havent done java at all since so im totaly clueless again. if someone could help i would be really greatful, thanks.ok chill man, and i wasnt asking you to do it for me or nothign liek that.
its mostly these parts im having trouble explaining
Scanner scan = new Scanner(System.in); //receive input from keyboard
System.out.print("Enter the number of times you would like to toss two dice: "); //prompt user for input
int timesToToss = scan.nextInt(); //read in user input
die1 = (int) (Math.random()*6+1); //assign random number (1 through 6) to dice one
die2 = (int) (Math.random()*6+1); //assign random number (1 through 6) to dice two
diceSum[(6*(die1-1))+die2]++; //add one to appropriate cell in distribution table
frequencySum[die1+die2]++; //add one to appropriate sum counter
if(i%6 == 1) //if at the beginning of a table row
System.out.print(i/6+1 + "\t|"); //print row number
System.out.print(diceSum[i]+ "\t"); //for each cell in a row, print its value
if(i%6 == 0) //if at the end of a row
System.out.println(); //go down a linei know in the last one there the "if(i%6 == 1) " and "if(i%6 == 0) " effect the
"System.out.print(i/6+1 + "\t|");" in some way, but i dont really know how to explain it.
thanks -
How to understand this strange code?
Hi,everyone
When I analysing the petstore source code ,I find it very difficult to understand the following code,who can help me?please send email to [email protected]
thank you!
public XMLFilter setup(XMLReader reader) throws PopulateException {
return new XMLDBHandler(reader, rootTag, XML_INVENTORY) {
public void update() throws PopulateException {}
public void create() throws PopulateException {
createInventory(getValue(XML_ID), getValue(XML_QUANTITY, 0));
return;
}This function is returning an anonymous class.
This new class is constructed and defined on the fly in this code. -
How doest jdk docs help as in writing java code?
hi i wonder how does jdk docs help as in writing java code because if i google a java code the jdk docs always becomes the result of my search but in my experience jdk docs never helps me.
is there any one know how to use jdk docs? and how to get the code from there.
im telling about jdk docs from here http://download.oracle.com/javase/1.4.2/docs/api/
cross posted from http://www.thenewboston.com/forum/viewtopic.php?f=119&t=13778
Edited by: 871484 on Jul 18, 2011 4:18 PM871484 wrote:
ok can any one give me example how to use jdk docs? for example this code
Your question still does not make any sense, and you still haven't clarified what you're not understanding.
However, if you think that just by reading the API docs, with no other training or study, that you will be able to write that code, then you are seriously misunderstanding the purpose of the docs.
Obviously English is not your native language. You grew up speaking some other language at home and with your friends, and at some point in school or as private study, you started to learn English. You learned about the grammar and the alphabet and pronunciation, sentence structure, word order, etc. Now you have the basics of how the language works, and you know some words. When you want to learn new words to fit into the structure you have learned, you use a dictionary.
If you didn't study the grammar, sentence structure, etc., and just said, "I want to learn English. I will look at a dicationary," clearly that would not work.
Right?
So, since you now understand and agree with the English example, let me state something that I hope is obvious to you by now: The API docs are your dictionary. They are not a substitute for learning the language basics.
Furthermore, once you know the language basics in English and have your dictionary, you still won't know how to write a resume (which you may know as a CV). You will look at examples and perhaps take a course on resume (CV) writing. Just reading a dictionary won't help you write a resume(CV). Similarly, if you know some Java basics, you can't learn how to write a Swing app just by reading the Javadocs. You'll look at tutorials and examples. Then, once you know the basic structure of a Swing app, you'll look to the javadocs for more details about more kinds of GUI classes--different buttons and windows and panes and panels and layout managers, etc. -
E-Rows = NULL and A-Rows=42M? Need help in understanding why.
Hi,
Oracle Standard Edition 11.2.0.3.0 CPU Oct 2012 running on Windows 2008 R2 x64. I am using Oracle 10g syntax for WITH clause as the query will also run on Oracle 10gR2. I do not have a Oracle 10gR2 environment at hand to comment if this behaves the same.
Following query is beyond me. It takes around 2 minutes to return the "computed" result set of 66 rows.
SQL> WITH dat AS
2 (SELECT 723677 vid,
3 243668 fid,
4 TO_DATE ('06.03.2013', 'dd.mm.yyyy') mindt,
5 TO_DATE ('06.03.2013', 'dd.mm.yyyy') maxdt
6 FROM DUAL
7 UNION ALL
8 SELECT 721850,
9 243668,
10 TO_DATE ('06.02.2013', 'dd.mm.yyyy'),
11 TO_DATE (' 22.03.2013', 'dd.mm.yyyy')
12 FROM DUAL
13 UNION ALL
14 SELECT 723738,
15 243668,
16 TO_DATE ('16.03.2013', 'dd.mm.yyyy'),
17 TO_DATE (' 04.04.2013', 'dd.mm.yyyy')
18 FROM DUAL)
19 SELECT /*+ GATHER_PLAN_STATISTICS */ DISTINCT vid, fid, mindt - 1 + LEVEL dtshow
20 FROM dat
21 CONNECT BY LEVEL <= maxdt - mindt + 1
22 order by fid, vid, dtshow;
66 rows selected.
SQL>
SQL> SELECT * FROM TABLE (DBMS_XPLAN.display_cursor (NULL, NULL, 'ALLSTATS LAST'));
PLAN_TABLE_OUTPUT
SQL_ID 9c4vma4mds6zk, child number 0
WITH dat AS (SELECT 723677 vid, 243668 fid,
TO_DATE ('06.03.2013', 'dd.mm.yyyy') mindt,
TO_DATE ('06.03.2013', 'dd.mm.yyyy') maxdt FROM DUAL
UNION ALL SELECT 721850, 243668,
TO_DATE ('06.02.2013', 'dd.mm.yyyy'), TO_DATE ('
22.03.2013', 'dd.mm.yyyy') FROM DUAL UNION ALL
SELECT 723738, 243668, TO_DATE
('16.03.2013', 'dd.mm.yyyy'), TO_DATE (' 04.04.2013',
'dd.mm.yyyy') FROM DUAL) SELECT /*+
GATHER_PLAN_STATISTICS */ DISTINCT vid, fid, mindt - 1 + LEVEL dtshow
FROM dat CONNECT BY LEVEL <= maxdt - mindt + 1 order by fid, vid,
dtshow
Plan hash value: 1865145249
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | OMem | 1Mem | Used-Mem |
| 0 | SELECT STATEMENT | | 1 | | 66 |00:01:54.64 | | | |
| 1 | SORT UNIQUE | | 1 | 3 | 66 |00:01:54.64 | 6144 | 6144 | 6144 (0)|
| 2 | CONNECT BY WITHOUT FILTERING (UNIQUE)| | 1 | | 42M|00:01:04.00 | | | |
| 3 | VIEW | | 1 | 3 | 3 |00:00:00.01 | | | |
| 4 | UNION-ALL | | 1 | | 3 |00:00:00.01 | | | |
| 5 | FAST DUAL | | 1 | 1 | 1 |00:00:00.01 | | | |
| 6 | FAST DUAL | | 1 | 1 | 1 |00:00:00.01 | | | |
| 7 | FAST DUAL | | 1 | 1 | 1 |00:00:00.01 | | | |
--------------------------------------------------------------------------------------------------------------------------If I take out one of the UNION queries, the query returns in under 1 second.
SQL> WITH dat AS
2 (SELECT 723677 vid,
3 243668 fid,
4 TO_DATE ('06.03.2013', 'dd.mm.yyyy') mindt,
5 TO_DATE ('06.03.2013', 'dd.mm.yyyy') maxdt
6 FROM DUAL
7 UNION ALL
8 SELECT 721850,
9 243668,
10 TO_DATE ('06.02.2013', 'dd.mm.yyyy'),
11 TO_DATE (' 22.03.2013', 'dd.mm.yyyy')
12 FROM DUAL)
13 SELECT /*+ GATHER_PLAN_STATISTICS */ DISTINCT vid, fid, mindt - 1 + LEVEL dtshow
14 FROM dat
15 CONNECT BY LEVEL <= maxdt - mindt + 1
16 order by fid, vid, dtshow;
46 rows selected.
SQL>
SQL> SELECT * FROM TABLE (DBMS_XPLAN.display_cursor (NULL, NULL, 'ALLSTATS LAST'));
PLAN_TABLE_OUTPUT
SQL_ID 1d2f62uy0521p, child number 0
WITH dat AS (SELECT 723677 vid, 243668 fid,
TO_DATE ('06.03.2013', 'dd.mm.yyyy') mindt,
TO_DATE ('06.03.2013', 'dd.mm.yyyy') maxdt FROM DUAL
UNION ALL SELECT 721850, 243668,
TO_DATE ('06.02.2013', 'dd.mm.yyyy'), TO_DATE ('
22.03.2013', 'dd.mm.yyyy') FROM DUAL) SELECT /*+
GATHER_PLAN_STATISTICS */ DISTINCT vid, fid, mindt - 1 + LEVEL dtshow
FROM dat CONNECT BY LEVEL <= maxdt - mindt + 1 order by fid, vid,
dtshow
Plan hash value: 2232696677
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | OMem | 1Mem | Used-Mem |
| 0 | SELECT STATEMENT | | 1 | | 46 |00:00:00.01 | | | |
| 1 | SORT UNIQUE | | 1 | 2 | 46 |00:00:00.01 | 4096 | 4096 | 4096 (0)|
| 2 | CONNECT BY WITHOUT FILTERING (UNIQUE)| | 1 | | 90 |00:00:00.01 | | | |
| 3 | VIEW | | 1 | 2 | 2 |00:00:00.01 | | | |
| 4 | UNION-ALL | | 1 | | 2 |00:00:00.01 | | | |
| 5 | FAST DUAL | | 1 | 1 | 1 |00:00:00.01 | | | |
| 6 | FAST DUAL | | 1 | 1 | 1 |00:00:00.01 | | | |
26 rows selected.What I cannot understand is why the E-Rows is NULL for "CONNECT BY WITHOUT FILTERING (UNIQUE)" step and A-Rows shoots up to 42M for first case. The behaviour is the same for any number of UNION queries above two.
Can anyone please help me understand this and aid in tuning this accordingly? Also, I would be happy to know if there are better ways to generate the missing date range.
Regards,
SatishMay be, this?
WITH dat AS
(SELECT 723677 vid,
243668 fid,
TO_DATE ('06.03.2013', 'dd.mm.yyyy') mindt,
TO_DATE ('06.03.2013', 'dd.mm.yyyy') maxdt
FROM DUAL
UNION ALL
SELECT 721850,
243668,
TO_DATE ('06.02.2013', 'dd.mm.yyyy'),
TO_DATE (' 22.03.2013', 'dd.mm.yyyy')
FROM DUAL
UNION ALL
SELECT 723738,
243668,
TO_DATE ('16.03.2013', 'dd.mm.yyyy'),
TO_DATE (' 04.04.2013', 'dd.mm.yyyy')
FROM DUAL)
SELECT vid, fid, mindt - 1 + LEVEL dtshow
FROM dat
CONNECT BY LEVEL <= maxdt - mindt + 1
and prior vid = vid
and prior fid = fid
and prior sys_guid() is not null
order by fid, vid, dtshow;
66 rows selected.
Elapsed: 00:00:00.03
Maybe you are looking for
-
Rotating Text: in Adobe Acrobat 8.1
Under Tools/Comment & Mark up/ using the Text Box Tool command I am able to insert windowed text images to my document. The window and included text both default in a horizontal direction. I want the window and included text to run in rotated directi
-
Questions with Third-Party Access Management Systems
I was reading: http://download-east.oracle.com/docs/cd/B14099_18/idmanage.1012/b14078/tpsso.htm#i1009152 And few questions raised in my head: 1st: On the IPASAuthInterface implementation we're told to fetch a header that was set by the third party se
-
Lost functionality DVD Studio Pro 2
Yes, I know I should upgrade but DVD Studio Pro 2 was such a good programme I never needed any more. Anyway, over the last few months I've been losing odd bits of functionality but today I'm told that it can't read Mpeg 2 files ( .m2v ) which is biza
-
10.5.2: Expert Advice Needed
I realize there's a small percentage of the Mac community that believes this, so I'd like it if only experienced mac users of 10+ years would respond. PAST: I've used a mac since 1994, but have been dealing with speed problems of OSX since I first bo
-
Hard drive can only be written to by root?
I've been using Linux for a little over a year now, and I just switched to Arch. It's the best distro I have ever use, by far. So far, there has only been one thing I cannot figure out; when my hard drive mounts, it can only be written to by root. I